Skip to content

Commit fb9e16d

Browse files
committed
fix(react-popover): add surfaceMotion types and fix presenceMotionSlot defaultProps
- Add surfaceMotion prop to PopoverProps (PresenceMotionSlotProps<{ mainAxis }>) - Add surfaceMotion slot to PopoverState (SlotComponentType) - Exclude surfaceMotion from PopoverBaseState - Add missing mainAxis to presenceMotionSlot defaultProps
1 parent 719400b commit fb9e16d

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

packages/react-components/react-popover/library/src/components/Popover/Popover.types.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as React from 'react';
2-
import type { JSXElement } from '@fluentui/react-utilities';
2+
import type { PresenceComponentProps, PresenceMotionSlotProps } from '@fluentui/react-motion';
3+
import type { JSXElement, SlotComponentType } from '@fluentui/react-utilities';
34
import type {
45
PositioningVirtualElement,
56
PositioningShorthand,
@@ -109,6 +110,12 @@ export type PopoverProps = Pick<PortalProps, 'mountNode'> & {
109110
*/
110111
size?: PopoverSize;
111112

113+
/**
114+
* Slot for the surface motion animation.
115+
* For more information refer to the [Motion docs page](https://react.fluentui.dev/?path=/docs/motion-motion-slot--docs).
116+
*/
117+
surfaceMotion?: PresenceMotionSlotProps<{ mainAxis: number }>;
118+
112119
/**
113120
* Should trap focus
114121
*
@@ -196,6 +203,15 @@ export type PopoverState = Pick<
196203

197204
size: NonNullable<PopoverProps['size']>;
198205

206+
/**
207+
* Slot for the surface motion animation.
208+
*/
209+
surfaceMotion: SlotComponentType<
210+
Pick<PresenceComponentProps, 'appear' | 'onMotionFinish' | 'onMotionStart' | 'unmountOnExit' | 'visible'> & {
211+
mainAxis: number;
212+
}
213+
>;
214+
199215
/**
200216
* Callback to toggle the open state of the Popover
201217
*/
@@ -208,7 +224,7 @@ export type PopoverState = Pick<
208224
triggerRef: React.MutableRefObject<HTMLElement | null>;
209225
};
210226

211-
export type PopoverBaseState = Omit<PopoverState, 'appearance' | 'size'>;
227+
export type PopoverBaseState = Omit<PopoverState, 'appearance' | 'size' | 'surfaceMotion'>;
212228

213229
/**
214230
* Data attached to open/close events

packages/react-components/react-popover/library/src/components/Popover/usePopover.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ export const usePopover_unstable = (props: PopoverProps): PopoverState => {
156156
visible: state.open,
157157
appear: true,
158158
unmountOnExit: true,
159+
mainAxis: 10,
159160
},
160161
}),
161162
};

0 commit comments

Comments
 (0)