@fluentui/react-popover 9.14.5 → 9.14.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/CHANGELOG.md +33 -2
  2. package/dist/index.d.cts +338 -0
  3. package/lib/Popover.js +1 -1
  4. package/lib/Popover.js.map +1 -1
  5. package/lib/PopoverSurface.js +1 -1
  6. package/lib/PopoverSurface.js.map +1 -1
  7. package/lib/PopoverTrigger.js +1 -1
  8. package/lib/PopoverTrigger.js.map +1 -1
  9. package/lib/components/Popover/Popover.js +3 -3
  10. package/lib/components/Popover/Popover.js.map +1 -1
  11. package/lib/components/Popover/PopoverSurfaceMotion.js +3 -3
  12. package/lib/components/Popover/index.js +4 -4
  13. package/lib/components/Popover/index.js.map +1 -1
  14. package/lib/components/Popover/renderPopover.js +4 -4
  15. package/lib/components/Popover/renderPopover.js.map +1 -1
  16. package/lib/components/Popover/usePopover.js +9 -9
  17. package/lib/components/Popover/usePopover.js.map +1 -1
  18. package/lib/components/Popover/usePopoverContextValues.js +1 -1
  19. package/lib/components/PopoverSurface/PopoverSurface.js +5 -5
  20. package/lib/components/PopoverSurface/PopoverSurface.js.map +1 -1
  21. package/lib/components/PopoverSurface/index.js +4 -4
  22. package/lib/components/PopoverSurface/index.js.map +1 -1
  23. package/lib/components/PopoverSurface/renderPopoverSurface.js +2 -2
  24. package/lib/components/PopoverSurface/usePopoverSurface.js +4 -4
  25. package/lib/components/PopoverSurface/usePopoverSurface.js.map +1 -1
  26. package/lib/components/PopoverSurface/usePopoverSurfaceStyles.styles.js +3 -3
  27. package/lib/components/PopoverSurface/usePopoverSurfaceStyles.styles.js.map +1 -1
  28. package/lib/components/PopoverSurface/usePopoverSurfaceStyles.styles.raw.js +3 -3
  29. package/lib/components/PopoverTrigger/PopoverTrigger.js +2 -2
  30. package/lib/components/PopoverTrigger/PopoverTrigger.js.map +1 -1
  31. package/lib/components/PopoverTrigger/index.js +3 -3
  32. package/lib/components/PopoverTrigger/index.js.map +1 -1
  33. package/lib/components/PopoverTrigger/usePopoverTrigger.js +5 -5
  34. package/lib/components/PopoverTrigger/usePopoverTrigger.js.map +1 -1
  35. package/lib/index.js +4 -4
  36. package/lib/index.js.map +1 -1
  37. package/lib/popoverContext.js +1 -1
  38. package/lib-commonjs/{Popover.js → Popover.cjs} +1 -1
  39. package/lib-commonjs/{Popover.js.map → Popover.cjs.map} +1 -1
  40. package/lib-commonjs/{PopoverSurface.js → PopoverSurface.cjs} +1 -1
  41. package/lib-commonjs/{PopoverSurface.js.map → PopoverSurface.cjs.map} +1 -1
  42. package/lib-commonjs/{PopoverTrigger.js → PopoverTrigger.cjs} +1 -1
  43. package/lib-commonjs/{PopoverTrigger.js.map → PopoverTrigger.cjs.map} +1 -1
  44. package/lib-commonjs/components/Popover/{Popover.js → Popover.cjs} +3 -3
  45. package/lib-commonjs/components/Popover/{Popover.js.map → Popover.cjs.map} +1 -1
  46. package/lib-commonjs/components/Popover/{index.js → index.cjs} +4 -4
  47. package/lib-commonjs/components/Popover/{index.js.map → index.cjs.map} +1 -1
  48. package/lib-commonjs/components/Popover/{renderPopover.js → renderPopover.cjs} +1 -1
  49. package/lib-commonjs/components/Popover/{renderPopover.js.map → renderPopover.cjs.map} +1 -1
  50. package/lib-commonjs/components/Popover/{usePopover.js → usePopover.cjs} +3 -3
  51. package/lib-commonjs/components/Popover/{usePopover.js.map → usePopover.cjs.map} +1 -1
  52. package/lib-commonjs/components/PopoverSurface/{PopoverSurface.js → PopoverSurface.cjs} +3 -3
  53. package/lib-commonjs/components/PopoverSurface/{PopoverSurface.js.map → PopoverSurface.cjs.map} +1 -1
  54. package/lib-commonjs/components/PopoverSurface/{index.js → index.cjs} +4 -4
  55. package/lib-commonjs/components/PopoverSurface/{index.js.map → index.cjs.map} +1 -1
  56. package/lib-commonjs/components/PopoverSurface/{usePopoverSurface.js → usePopoverSurface.cjs} +1 -1
  57. package/lib-commonjs/components/PopoverSurface/{usePopoverSurface.js.map → usePopoverSurface.cjs.map} +1 -1
  58. package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.styles.cjs.map +1 -0
  59. package/lib-commonjs/components/PopoverTrigger/{PopoverTrigger.js → PopoverTrigger.cjs} +2 -2
  60. package/lib-commonjs/components/PopoverTrigger/{PopoverTrigger.js.map → PopoverTrigger.cjs.map} +1 -1
  61. package/lib-commonjs/components/PopoverTrigger/{index.js → index.cjs} +3 -3
  62. package/lib-commonjs/components/PopoverTrigger/{index.js.map → index.cjs.map} +1 -1
  63. package/lib-commonjs/components/PopoverTrigger/{usePopoverTrigger.js → usePopoverTrigger.cjs} +1 -1
  64. package/lib-commonjs/components/PopoverTrigger/{usePopoverTrigger.js.map → usePopoverTrigger.cjs.map} +1 -1
  65. package/lib-commonjs/{index.js → index.cjs} +4 -4
  66. package/lib-commonjs/{index.js.map → index.cjs.map} +1 -1
  67. package/package.json +25 -19
  68. package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.styles.js.map +0 -1
  69. /package/lib-commonjs/components/Popover/{Popover.types.js → Popover.types.cjs} +0 -0
  70. /package/lib-commonjs/components/Popover/{Popover.types.js.map → Popover.types.cjs.map} +0 -0
  71. /package/lib-commonjs/components/Popover/{PopoverSurfaceMotion.js → PopoverSurfaceMotion.cjs} +0 -0
  72. /package/lib-commonjs/components/Popover/{PopoverSurfaceMotion.js.map → PopoverSurfaceMotion.cjs.map} +0 -0
  73. /package/lib-commonjs/components/Popover/{constants.js → constants.cjs} +0 -0
  74. /package/lib-commonjs/components/Popover/{constants.js.map → constants.cjs.map} +0 -0
  75. /package/lib-commonjs/components/Popover/{usePopoverContextValues.js → usePopoverContextValues.cjs} +0 -0
  76. /package/lib-commonjs/components/Popover/{usePopoverContextValues.js.map → usePopoverContextValues.cjs.map} +0 -0
  77. /package/lib-commonjs/components/PopoverSurface/{PopoverSurface.types.js → PopoverSurface.types.cjs} +0 -0
  78. /package/lib-commonjs/components/PopoverSurface/{PopoverSurface.types.js.map → PopoverSurface.types.cjs.map} +0 -0
  79. /package/lib-commonjs/components/PopoverSurface/{renderPopoverSurface.js → renderPopoverSurface.cjs} +0 -0
  80. /package/lib-commonjs/components/PopoverSurface/{renderPopoverSurface.js.map → renderPopoverSurface.cjs.map} +0 -0
  81. /package/lib-commonjs/components/PopoverSurface/{usePopoverSurfaceStyles.styles.js → usePopoverSurfaceStyles.styles.cjs} +0 -0
  82. /package/lib-commonjs/components/PopoverSurface/{usePopoverSurfaceStyles.styles.raw.js → usePopoverSurfaceStyles.styles.raw.cjs} +0 -0
  83. /package/lib-commonjs/components/PopoverSurface/{usePopoverSurfaceStyles.styles.raw.js.map → usePopoverSurfaceStyles.styles.raw.cjs.map} +0 -0
  84. /package/lib-commonjs/components/PopoverTrigger/{PopoverTrigger.types.js → PopoverTrigger.types.cjs} +0 -0
  85. /package/lib-commonjs/components/PopoverTrigger/{PopoverTrigger.types.js.map → PopoverTrigger.types.cjs.map} +0 -0
  86. /package/lib-commonjs/components/PopoverTrigger/{renderPopoverTrigger.js → renderPopoverTrigger.cjs} +0 -0
  87. /package/lib-commonjs/components/PopoverTrigger/{renderPopoverTrigger.js.map → renderPopoverTrigger.cjs.map} +0 -0
  88. /package/lib-commonjs/{popoverContext.js → popoverContext.cjs} +0 -0
  89. /package/lib-commonjs/{popoverContext.js.map → popoverContext.cjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,12 +1,43 @@
1
1
  # Change Log - @fluentui/react-popover
2
2
 
3
- This log was last generated on Tue, 04 Aug 2026 10:10:11 GMT and should not be manually modified.
3
+ <!-- This log was last generated on Mon, 24 Aug 2026 08:15:11 GMT and should not be manually modified. -->
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.14.7](https://github.com/microsoft/fluentui/tree/@fluentui/react-popover_v9.14.7)
8
+
9
+ Mon, 24 Aug 2026 08:15:11 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-popover_v9.14.6..@fluentui/react-popover_v9.14.7)
11
+
12
+ ### Patches
13
+
14
+ - Bump @fluentui/react-motion to v9.16.3 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
15
+ - Bump @fluentui/react-motion-components-preview to v0.15.8 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
16
+
17
+ ## [9.14.6](https://github.com/microsoft/fluentui/tree/@fluentui/react-popover_v9.14.6)
18
+
19
+ Tue, 11 Aug 2026 17:20:14 GMT
20
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-popover_v9.14.5..@fluentui/react-popover_v9.14.6)
21
+
22
+ ### Patches
23
+
24
+ - Ship ESM-first (type:module): valid ESM under lib/, CommonJS under lib-commonjs/*.cjs, and drop the `node` export condition - bare-Node `import` resolves ESM, `require` resolves CJS; node-targeted bundlers tree-shake. ([PR #36327](https://github.com/microsoft/fluentui/pull/36327) by martinhochel@microsoft.com)
25
+ - Bump @fluentui/keyboard-keys to v9.0.9 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
26
+ - Bump @fluentui/react-aria to v9.17.14 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
27
+ - Bump @fluentui/react-context-selector to v9.2.19 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
28
+ - Bump @fluentui/react-jsx-runtime to v9.4.5 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
29
+ - Bump @fluentui/react-motion to v9.16.2 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
30
+ - Bump @fluentui/react-motion-components-preview to v0.15.7 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
31
+ - Bump @fluentui/react-portal to v9.8.15 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
32
+ - Bump @fluentui/react-positioning to v9.23.1 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
33
+ - Bump @fluentui/react-shared-contexts to v9.26.3 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
34
+ - Bump @fluentui/react-tabster to v9.26.17 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
35
+ - Bump @fluentui/react-theme to v9.2.2 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
36
+ - Bump @fluentui/react-utilities to v9.26.6 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
37
+
7
38
  ## [9.14.5](https://github.com/microsoft/fluentui/tree/@fluentui/react-popover_v9.14.5)
8
39
 
9
- Tue, 04 Aug 2026 10:10:11 GMT
40
+ Tue, 04 Aug 2026 10:12:24 GMT
10
41
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-popover_v9.14.4..@fluentui/react-popover_v9.14.5)
11
42
 
12
43
  ### Patches
@@ -0,0 +1,338 @@
1
+ import type { ARIAButtonResultProps } from '@fluentui/react-aria';
2
+ import type { ARIAButtonType } from '@fluentui/react-aria';
3
+ import type { ComponentProps } from '@fluentui/react-utilities';
4
+ import type { ComponentState } from '@fluentui/react-utilities';
5
+ import type { ContextSelector } from '@fluentui/react-context-selector';
6
+ import { FC } from 'react';
7
+ import type { ForwardRefComponent } from '@fluentui/react-utilities';
8
+ import { JSXElement } from '@fluentui/react-utilities';
9
+ import type { PortalProps } from '@fluentui/react-portal';
10
+ import type { PositioningShorthand } from '@fluentui/react-positioning';
11
+ import type { PositioningVirtualElement } from '@fluentui/react-positioning';
12
+ import type { PresenceMotionSlotProps } from '@fluentui/react-motion';
13
+ import { Provider } from 'react';
14
+ import { ProviderProps } from 'react';
15
+ import type * as React_2 from 'react';
16
+ import type { SetVirtualMouseTarget } from '@fluentui/react-positioning';
17
+ import type { Slot } from '@fluentui/react-utilities';
18
+ import type { SlotClassNames } from '@fluentui/react-utilities';
19
+ import type { TriggerProps } from '@fluentui/react-utilities';
20
+
21
+ export declare const arrowHeights: Record<PopoverSize, number>;
22
+
23
+ declare type InternalPopoverSlots = {
24
+ surfaceMotion: NonNullable<Slot<PresenceMotionSlotProps>>;
25
+ };
26
+
27
+ /**
28
+ * Data attached to open/close events
29
+ */
30
+ export declare type OnOpenChangeData = {
31
+ open: boolean;
32
+ };
33
+
34
+ /**
35
+ * The supported events that will trigger open/close of the menu
36
+ */
37
+ export declare type OpenPopoverEvents = MouseEvent | TouchEvent | FocusEvent | React_2.FocusEvent<HTMLElement> | React_2.KeyboardEvent<HTMLElement> | React_2.MouseEvent<HTMLElement>;
38
+
39
+ /**
40
+ * Wrapper component that manages state for a PopoverTrigger and a PopoverSurface components.
41
+ */
42
+ export declare const Popover: React_2.FC<PopoverProps>;
43
+
44
+ /**
45
+ * Context shared between Popover and its children components
46
+ */
47
+ export declare type PopoverContextValue = Pick<PopoverState, 'open' | 'toggleOpen' | 'setOpen' | 'triggerRef' | 'contentRef' | 'openOnHover' | 'openOnContext' | 'mountNode' | 'withArrow' | 'arrowRef' | 'size' | 'appearance' | 'trapFocus' | 'inertTrapFocus' | 'inline'>;
48
+
49
+ export declare type PopoverContextValues = {
50
+ popover: PopoverContextValue;
51
+ };
52
+
53
+ /**
54
+ * Popover Props
55
+ */
56
+ export declare type PopoverProps = ComponentProps<Partial<PopoverSlots>> & Pick<PortalProps, 'mountNode'> & {
57
+ /**
58
+ * A popover can appear styled with brand or inverted.
59
+ * When not specified, the default style is used.
60
+ */
61
+ appearance?: 'brand' | 'inverted';
62
+ /**
63
+ * Can contain two children including `PopoverTrigger` and `PopoverSurface`.
64
+ * Alternatively can only contain `PopoverSurface` if using a custom `target`.
65
+ */
66
+ children: [JSXElement, JSXElement] | JSXElement;
67
+ /**
68
+ * Close when scroll outside of it
69
+ *
70
+ * @default false
71
+ */
72
+ closeOnScroll?: boolean;
73
+ /**
74
+ * Used to set the initial open state of the Popover in uncontrolled mode
75
+ *
76
+ * @default false
77
+ */
78
+ defaultOpen?: boolean;
79
+ /**
80
+ * Popovers are rendered out of DOM order on `document.body` by default, use this to render the popover in DOM order
81
+ *
82
+ * @default false
83
+ */
84
+ inline?: boolean;
85
+ /**
86
+ * Sets the delay for closing popover on mouse leave
87
+ */
88
+ mouseLeaveDelay?: number;
89
+ /**
90
+ * Display an arrow pointing to the target.
91
+ *
92
+ * @default false
93
+ */
94
+ withArrow?: boolean;
95
+ /**
96
+ * Call back when the component requests to change value
97
+ * The `open` value is used as a hint when directly controlling the component
98
+ */
99
+ onOpenChange?: (e: OpenPopoverEvents, data: OnOpenChangeData) => void;
100
+ /**
101
+ * Controls the opening of the Popover
102
+ *
103
+ * @default false
104
+ */
105
+ open?: boolean;
106
+ /**
107
+ * Flag to open the Popover as a context menu. Disables all other interactions
108
+ *
109
+ * @default false
110
+ */
111
+ openOnContext?: boolean;
112
+ /**
113
+ * Flag to open the Popover by hovering the trigger
114
+ *
115
+ * @default false
116
+ */
117
+ openOnHover?: boolean;
118
+ /**
119
+ * Flag to close the Popover when an iframe outside a PopoverSurface is focused
120
+ *
121
+ * @default true
122
+ */
123
+ closeOnIframeFocus?: boolean;
124
+ /**
125
+ * Configures the position of the Popover.
126
+ * Explore [Positioning docs](https://react.fluentui.dev/?path=/docs/concepts-developer-positioning-components--docs) for more options.
127
+ */
128
+ positioning?: PositioningShorthand;
129
+ /**
130
+ * Determines popover padding and arrow size
131
+ *
132
+ * @default medium
133
+ */
134
+ size?: PopoverSize;
135
+ /**
136
+ * Should trap focus
137
+ *
138
+ * @default false
139
+ */
140
+ trapFocus?: boolean;
141
+ /**
142
+ * Must be used with the `trapFocus` prop
143
+ * Enables older Fluent UI focus trap behavior where the user
144
+ * cannot tab into the window outside of the document. This is now
145
+ * non-standard behavior according to the [HTML dialog spec](https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/showModal)
146
+ * where the focus trap involves setting outside elements inert.
147
+ *
148
+ * @deprecated this behavior is default provided now, to opt-out of it in favor of standard behavior use the `inertTrapFocus` property
149
+ */
150
+ legacyTrapFocus?: boolean;
151
+ /**
152
+ * Enables standard behavior according to the [HTML dialog spec](https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/showModal)
153
+ * where the focus trap involves setting outside elements inert,
154
+ * making navigation leak from the trapped area back to the browser toolbar and vice-versa.
155
+ *
156
+ * @default false
157
+ */
158
+ inertTrapFocus?: boolean;
159
+ /**
160
+ * By default Popover focuses the first focusable element in PopoverSurface on open.
161
+ * Specify `disableAutoFocus` to prevent this behavior.
162
+ *
163
+ * @default false
164
+ */
165
+ unstable_disableAutoFocus?: boolean;
166
+ };
167
+
168
+ export declare const PopoverProvider: Provider<PopoverContextValue> & FC<ProviderProps<PopoverContextValue>>;
169
+
170
+ /**
171
+ * Determines popover padding and arrow size
172
+ */
173
+ export declare type PopoverSize = 'small' | 'medium' | 'large';
174
+
175
+ declare type PopoverSlots = {
176
+ /**
177
+ * Slot for the surface motion animation.
178
+ * For more information refer to the [Motion docs page](https://react.fluentui.dev/?path=/docs/motion-motion-slot--docs).
179
+ */
180
+ surfaceMotion: Slot<PresenceMotionSlotProps>;
181
+ };
182
+
183
+ /**
184
+ * Popover State
185
+ */
186
+ export declare type PopoverState = ComponentState<InternalPopoverSlots> & Pick<PopoverProps, 'appearance' | 'mountNode' | 'onOpenChange' | 'openOnContext' | 'openOnHover' | 'trapFocus' | 'withArrow' | 'inertTrapFocus'> & Required<Pick<PopoverProps, 'inline' | 'open'>> & Pick<PopoverProps, 'children'> & {
187
+ /**
188
+ * Ref of the pointing arrow
189
+ */
190
+ arrowRef: React_2.MutableRefObject<HTMLDivElement | null>;
191
+ /**
192
+ * Ref of the PopoverSurface
193
+ */
194
+ contentRef: React_2.MutableRefObject<HTMLElement | null>;
195
+ /**
196
+ * Anchors the popper to the mouse click for context events
197
+ */
198
+ contextTarget: PositioningVirtualElement | undefined;
199
+ popoverSurface: React_2.ReactElement | undefined;
200
+ popoverTrigger: React_2.ReactElement | undefined;
201
+ /**
202
+ * A callback to set the target of the popper to the mouse click for context events
203
+ */
204
+ setContextTarget: SetVirtualMouseTarget;
205
+ /**
206
+ * Callback to open/close the Popover
207
+ */
208
+ setOpen: (e: OpenPopoverEvents, open: boolean) => void;
209
+ size: NonNullable<PopoverProps['size']>;
210
+ /**
211
+ * Callback to toggle the open state of the Popover
212
+ */
213
+ toggleOpen: (e: OpenPopoverEvents) => void;
214
+ /**
215
+ * Ref of the PopoverTrigger
216
+ */
217
+ triggerRef: React_2.MutableRefObject<HTMLElement | null>;
218
+ };
219
+
220
+ /**
221
+ * PopoverSurface component renders react children in a positioned box
222
+ */
223
+ export declare const PopoverSurface: ForwardRefComponent<PopoverSurfaceProps>;
224
+
225
+ export declare const popoverSurfaceClassNames: SlotClassNames<PopoverSurfaceSlots>;
226
+
227
+ /**
228
+ * PopoverSurface Props
229
+ */
230
+ export declare type PopoverSurfaceProps = ComponentProps<PopoverSurfaceSlots>;
231
+
232
+ /**
233
+ * Names of the slots in PopoverSurfaceProps
234
+ */
235
+ export declare type PopoverSurfaceSlots = {
236
+ root: Slot<'div'>;
237
+ };
238
+
239
+ /**
240
+ * PopoverSurface State
241
+ */
242
+ export declare type PopoverSurfaceState = ComponentState<PopoverSurfaceSlots> & Pick<PopoverContextValue, 'appearance' | 'arrowRef' | 'inline' | 'mountNode' | 'size' | 'withArrow'> & {
243
+ /**
244
+ * CSS class for the arrow element
245
+ */
246
+ arrowClassName?: string;
247
+ };
248
+
249
+ /**
250
+ * Wraps a trigger element as an only child and adds the necessary event handling to open a popover.
251
+ */
252
+ export declare const PopoverTrigger: React_2.FC<PopoverTriggerProps>;
253
+
254
+ /**
255
+ * Props that are passed to the child of the DialogTrigger when cloned to ensure correct behaviour for the Dialog
256
+ */
257
+ export declare type PopoverTriggerChildProps<Type extends ARIAButtonType = ARIAButtonType, Props = {}> = ARIAButtonResultProps<Type, Props & {
258
+ 'aria-expanded'?: 'true' | 'false';
259
+ ref: React_2.Ref<unknown>;
260
+ onMouseEnter: React_2.MouseEventHandler<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>;
261
+ onMouseLeave: React_2.MouseEventHandler<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>;
262
+ onContextMenu: React_2.MouseEventHandler<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>;
263
+ }>;
264
+
265
+ /**
266
+ * PopoverTrigger Props
267
+ */
268
+ export declare type PopoverTriggerProps = TriggerProps<PopoverTriggerChildProps> & {
269
+ /**
270
+ * Disables internal trigger mechanism that ensures a child provided will be a compliant ARIA button.
271
+ * @default false
272
+ */
273
+ disableButtonEnhancement?: boolean;
274
+ };
275
+
276
+ /**
277
+ * PopoverTrigger State
278
+ */
279
+ export declare type PopoverTriggerState = {
280
+ children: React_2.ReactElement | null;
281
+ };
282
+
283
+ /**
284
+ * Render the final JSX of Popover
285
+ */
286
+ export declare const renderPopover_unstable: (state: PopoverState, contextValues?: PopoverContextValues) => JSXElement;
287
+
288
+ /**
289
+ * Render the final JSX of PopoverSurface
290
+ */
291
+ export declare const renderPopoverSurface_unstable: (state: PopoverSurfaceState) => JSXElement;
292
+
293
+ /**
294
+ * Render the final JSX of PopoverTrigger
295
+ */
296
+ export declare const renderPopoverTrigger_unstable: (state: PopoverTriggerState) => JSXElement | null;
297
+
298
+ /**
299
+ * Create the state required to render Popover.
300
+ *
301
+ * The returned state can be modified with hooks such as usePopoverStyles,
302
+ * before being passed to renderPopover_unstable.
303
+ *
304
+ * @param props - props from this instance of Popover
305
+ */
306
+ export declare const usePopover_unstable: (props: PopoverProps) => PopoverState;
307
+
308
+ export declare const usePopoverContext_unstable: <T>(selector: ContextSelector<PopoverContextValue, T>) => T;
309
+
310
+ export declare function usePopoverContextValues_unstable(state: PopoverState): PopoverContextValues;
311
+
312
+ /**
313
+ * Create the state required to render PopoverSurface.
314
+ *
315
+ * The returned state can be modified with hooks such as usePopoverSurfaceStyles_unstable,
316
+ * before being passed to renderPopoverSurface_unstable.
317
+ *
318
+ * @param props - props from this instance of PopoverSurface
319
+ * @param ref - reference to root HTMLDivElement of PopoverSurface
320
+ */
321
+ export declare const usePopoverSurface_unstable: (props: PopoverSurfaceProps, ref: React_2.Ref<HTMLDivElement>) => PopoverSurfaceState;
322
+
323
+ /**
324
+ * Apply styling to the PopoverSurface slots based on the state
325
+ */
326
+ export declare const usePopoverSurfaceStyles_unstable: (state: PopoverSurfaceState) => PopoverSurfaceState;
327
+
328
+ /**
329
+ * Create the state required to render PopoverTrigger.
330
+ *
331
+ * The returned state can be modified with hooks such as usePopoverTriggerStyles,
332
+ * before being passed to renderPopoverTrigger_unstable.
333
+ *
334
+ * @param props - props from this instance of PopoverTrigger
335
+ */
336
+ export declare const usePopoverTrigger_unstable: (props: PopoverTriggerProps) => PopoverTriggerState;
337
+
338
+ export { }
package/lib/Popover.js CHANGED
@@ -1 +1 @@
1
- export { Popover, renderPopover_unstable, usePopover_unstable, usePopoverContextValues_unstable } from './components/Popover/index';
1
+ export { Popover, renderPopover_unstable, usePopover_unstable, usePopoverContextValues_unstable } from "./components/Popover/index.js";
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/Popover.ts"],"sourcesContent":["export type {\n OnOpenChangeData,\n OpenPopoverEvents,\n PopoverContextValues,\n PopoverProps,\n PopoverSize,\n PopoverState,\n} from './components/Popover/index';\nexport {\n Popover,\n renderPopover_unstable,\n usePopover_unstable,\n usePopoverContextValues_unstable,\n} from './components/Popover/index';\n"],"names":["Popover","renderPopover_unstable","usePopover_unstable","usePopoverContextValues_unstable"],"mappings":"AAQA,SACEA,OAAO,EACPC,sBAAsB,EACtBC,mBAAmB,EACnBC,gCAAgC,QAC3B,6BAA6B"}
1
+ {"version":3,"sources":["../src/Popover.ts"],"sourcesContent":["export type {\n OnOpenChangeData,\n OpenPopoverEvents,\n PopoverContextValues,\n PopoverProps,\n PopoverSize,\n PopoverState,\n} from './components/Popover/index';\nexport {\n Popover,\n renderPopover_unstable,\n usePopover_unstable,\n usePopoverContextValues_unstable,\n} from './components/Popover/index';\n"],"names":["Popover","renderPopover_unstable","usePopover_unstable","usePopoverContextValues_unstable"],"mappings":"AAQA,SACEA,OAAO,EACPC,sBAAsB,EACtBC,mBAAmB,EACnBC,gCAAgC,QAC3B,gCAA6B"}
@@ -1 +1 @@
1
- export { PopoverSurface, arrowHeights, popoverSurfaceClassNames, renderPopoverSurface_unstable, usePopoverSurfaceStyles_unstable, usePopoverSurface_unstable } from './components/PopoverSurface/index';
1
+ export { PopoverSurface, arrowHeights, popoverSurfaceClassNames, renderPopoverSurface_unstable, usePopoverSurfaceStyles_unstable, usePopoverSurface_unstable } from "./components/PopoverSurface/index.js";
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/PopoverSurface.ts"],"sourcesContent":["export type { PopoverSurfaceProps, PopoverSurfaceSlots, PopoverSurfaceState } from './components/PopoverSurface/index';\nexport {\n PopoverSurface,\n arrowHeights,\n popoverSurfaceClassNames,\n renderPopoverSurface_unstable,\n usePopoverSurfaceStyles_unstable,\n usePopoverSurface_unstable,\n} from './components/PopoverSurface/index';\n"],"names":["PopoverSurface","arrowHeights","popoverSurfaceClassNames","renderPopoverSurface_unstable","usePopoverSurfaceStyles_unstable","usePopoverSurface_unstable"],"mappings":"AACA,SACEA,cAAc,EACdC,YAAY,EACZC,wBAAwB,EACxBC,6BAA6B,EAC7BC,gCAAgC,EAChCC,0BAA0B,QACrB,oCAAoC"}
1
+ {"version":3,"sources":["../src/PopoverSurface.ts"],"sourcesContent":["export type { PopoverSurfaceProps, PopoverSurfaceSlots, PopoverSurfaceState } from './components/PopoverSurface/index';\nexport {\n PopoverSurface,\n arrowHeights,\n popoverSurfaceClassNames,\n renderPopoverSurface_unstable,\n usePopoverSurfaceStyles_unstable,\n usePopoverSurface_unstable,\n} from './components/PopoverSurface/index';\n"],"names":["PopoverSurface","arrowHeights","popoverSurfaceClassNames","renderPopoverSurface_unstable","usePopoverSurfaceStyles_unstable","usePopoverSurface_unstable"],"mappings":"AACA,SACEA,cAAc,EACdC,YAAY,EACZC,wBAAwB,EACxBC,6BAA6B,EAC7BC,gCAAgC,EAChCC,0BAA0B,QACrB,uCAAoC"}
@@ -1 +1 @@
1
- export { PopoverTrigger, renderPopoverTrigger_unstable, usePopoverTrigger_unstable } from './components/PopoverTrigger/index';
1
+ export { PopoverTrigger, renderPopoverTrigger_unstable, usePopoverTrigger_unstable } from "./components/PopoverTrigger/index.js";
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/PopoverTrigger.ts"],"sourcesContent":["export type {\n PopoverTriggerChildProps,\n PopoverTriggerProps,\n PopoverTriggerState,\n} from './components/PopoverTrigger/index';\nexport {\n PopoverTrigger,\n renderPopoverTrigger_unstable,\n usePopoverTrigger_unstable,\n} from './components/PopoverTrigger/index';\n"],"names":["PopoverTrigger","renderPopoverTrigger_unstable","usePopoverTrigger_unstable"],"mappings":"AAKA,SACEA,cAAc,EACdC,6BAA6B,EAC7BC,0BAA0B,QACrB,oCAAoC"}
1
+ {"version":3,"sources":["../src/PopoverTrigger.ts"],"sourcesContent":["export type {\n PopoverTriggerChildProps,\n PopoverTriggerProps,\n PopoverTriggerState,\n} from './components/PopoverTrigger/index';\nexport {\n PopoverTrigger,\n renderPopoverTrigger_unstable,\n usePopoverTrigger_unstable,\n} from './components/PopoverTrigger/index';\n"],"names":["PopoverTrigger","renderPopoverTrigger_unstable","usePopoverTrigger_unstable"],"mappings":"AAKA,SACEA,cAAc,EACdC,6BAA6B,EAC7BC,0BAA0B,QACrB,uCAAoC"}
@@ -1,7 +1,7 @@
1
1
  'use client';
2
- import { usePopover_unstable } from './usePopover';
3
- import { usePopoverContextValues_unstable } from './usePopoverContextValues';
4
- import { renderPopover_unstable } from './renderPopover';
2
+ import { usePopover_unstable } from "./usePopover.js";
3
+ import { usePopoverContextValues_unstable } from "./usePopoverContextValues.js";
4
+ import { renderPopover_unstable } from "./renderPopover.js";
5
5
  /**
6
6
  * Wrapper component that manages state for a PopoverTrigger and a PopoverSurface components.
7
7
  */ export const Popover = (props)=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Popover/Popover.tsx"],"sourcesContent":["'use client';\n\nimport type * as React from 'react';\nimport { usePopover_unstable } from './usePopover';\nimport { usePopoverContextValues_unstable } from './usePopoverContextValues';\nimport { renderPopover_unstable } from './renderPopover';\nimport type { PopoverProps } from './Popover.types';\n\n/**\n * Wrapper component that manages state for a PopoverTrigger and a PopoverSurface components.\n */\nexport const Popover: React.FC<PopoverProps> = props => {\n const state = usePopover_unstable(props);\n const contextValues = usePopoverContextValues_unstable(state);\n\n return renderPopover_unstable(state, contextValues);\n};\n\nPopover.displayName = 'Popover';\n"],"names":["usePopover_unstable","usePopoverContextValues_unstable","renderPopover_unstable","Popover","props","state","contextValues","displayName"],"mappings":"AAAA;AAGA,SAASA,mBAAmB,QAAQ,eAAe;AACnD,SAASC,gCAAgC,QAAQ,4BAA4B;AAC7E,SAASC,sBAAsB,QAAQ,kBAAkB;AAGzD;;CAEC,GACD,OAAO,MAAMC,UAAkCC,CAAAA;IAC7C,MAAMC,QAAQL,oBAAoBI;IAClC,MAAME,gBAAgBL,iCAAiCI;IAEvD,OAAOH,uBAAuBG,OAAOC;AACvC,EAAE;AAEFH,QAAQI,WAAW,GAAG"}
1
+ {"version":3,"sources":["../src/components/Popover/Popover.tsx"],"sourcesContent":["'use client';\n\nimport type * as React from 'react';\nimport { usePopover_unstable } from './usePopover';\nimport { usePopoverContextValues_unstable } from './usePopoverContextValues';\nimport { renderPopover_unstable } from './renderPopover';\nimport type { PopoverProps } from './Popover.types';\n\n/**\n * Wrapper component that manages state for a PopoverTrigger and a PopoverSurface components.\n */\nexport const Popover: React.FC<PopoverProps> = props => {\n const state = usePopover_unstable(props);\n const contextValues = usePopoverContextValues_unstable(state);\n\n return renderPopover_unstable(state, contextValues);\n};\n\nPopover.displayName = 'Popover';\n"],"names":["usePopover_unstable","usePopoverContextValues_unstable","renderPopover_unstable","Popover","props","state","contextValues","displayName"],"mappings":"AAAA;AAGA,SAASA,mBAAmB,QAAQ,kBAAe;AACnD,SAASC,gCAAgC,QAAQ,+BAA4B;AAC7E,SAASC,sBAAsB,QAAQ,qBAAkB;AAGzD;;CAEC,GACD,OAAO,MAAMC,UAAkCC,CAAAA;IAC7C,MAAMC,QAAQL,oBAAoBI;IAClC,MAAME,gBAAgBL,iCAAiCI;IAEvD,OAAOH,uBAAuBG,OAAOC;AACvC,EAAE;AAEFH,QAAQI,WAAW,GAAG"}
@@ -1,6 +1,6 @@
1
- import { createPresenceComponent, motionTokens } from '@fluentui/react-motion';
2
- import { fadeAtom, slideAtom } from '@fluentui/react-motion-components-preview';
3
- import { POSITIONING_SLIDE_DIRECTION_VAR_X as slideDirectionVarX, POSITIONING_SLIDE_DIRECTION_VAR_Y as slideDirectionVarY } from '@fluentui/react-positioning';
1
+ import { createPresenceComponent, motionTokens } from "@fluentui/react-motion";
2
+ import { fadeAtom, slideAtom } from "@fluentui/react-motion-components-preview";
3
+ import { POSITIONING_SLIDE_DIRECTION_VAR_X as slideDirectionVarX, POSITIONING_SLIDE_DIRECTION_VAR_Y as slideDirectionVarY } from "@fluentui/react-positioning";
4
4
  // Shared timing constants for the enter animation.
5
5
  const duration = motionTokens.durationSlower;
6
6
  const easing = motionTokens.curveDecelerateMid;
@@ -1,4 +1,4 @@
1
- export { Popover } from './Popover';
2
- export { renderPopover_unstable } from './renderPopover';
3
- export { usePopover_unstable } from './usePopover';
4
- export { usePopoverContextValues_unstable } from './usePopoverContextValues';
1
+ export { Popover } from "./Popover.js";
2
+ export { renderPopover_unstable } from "./renderPopover.js";
3
+ export { usePopover_unstable } from "./usePopover.js";
4
+ export { usePopoverContextValues_unstable } from "./usePopoverContextValues.js";
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Popover/index.ts"],"sourcesContent":["export { Popover } from './Popover';\nexport type { OnOpenChangeData, OpenPopoverEvents, PopoverProps, PopoverSize, PopoverState } from './Popover.types';\nexport { renderPopover_unstable } from './renderPopover';\nexport { usePopover_unstable } from './usePopover';\nexport { usePopoverContextValues_unstable } from './usePopoverContextValues';\nexport type { PopoverContextValues } from './usePopoverContextValues';\n"],"names":["Popover","renderPopover_unstable","usePopover_unstable","usePopoverContextValues_unstable"],"mappings":"AAAA,SAASA,OAAO,QAAQ,YAAY;AAEpC,SAASC,sBAAsB,QAAQ,kBAAkB;AACzD,SAASC,mBAAmB,QAAQ,eAAe;AACnD,SAASC,gCAAgC,QAAQ,4BAA4B"}
1
+ {"version":3,"sources":["../src/components/Popover/index.ts"],"sourcesContent":["export { Popover } from './Popover';\nexport type { OnOpenChangeData, OpenPopoverEvents, PopoverProps, PopoverSize, PopoverState } from './Popover.types';\nexport { renderPopover_unstable } from './renderPopover';\nexport { usePopover_unstable } from './usePopover';\nexport { usePopoverContextValues_unstable } from './usePopoverContextValues';\nexport type { PopoverContextValues } from './usePopoverContextValues';\n"],"names":["Popover","renderPopover_unstable","usePopover_unstable","usePopoverContextValues_unstable"],"mappings":"AAAA,SAASA,OAAO,QAAQ,eAAY;AAEpC,SAASC,sBAAsB,QAAQ,qBAAkB;AACzD,SAASC,mBAAmB,QAAQ,kBAAe;AACnD,SAASC,gCAAgC,QAAQ,+BAA4B"}
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "@fluentui/react-jsx-runtime/jsx-runtime";
2
- import * as React from 'react';
3
- import { assertSlots } from '@fluentui/react-utilities';
4
- import { MotionRefForwarder } from '@fluentui/react-motion';
5
- import { PopoverContext, popoverContextDefaultValue } from '../../popoverContext';
2
+ import * as React from "react";
3
+ import { assertSlots } from "@fluentui/react-utilities";
4
+ import { MotionRefForwarder } from "@fluentui/react-motion";
5
+ import { PopoverContext, popoverContextDefaultValue } from "../../popoverContext.js";
6
6
  /**
7
7
  * Render the final JSX of Popover
8
8
  */ export const renderPopover_unstable = (state, contextValues)=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Popover/renderPopover.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport * as React from 'react';\nimport { assertSlots, type JSXElement } from '@fluentui/react-utilities';\nimport { MotionRefForwarder } from '@fluentui/react-motion';\nimport { PopoverContext, popoverContextDefaultValue } from '../../popoverContext';\nimport type { InternalPopoverSlots, PopoverState } from './Popover.types';\nimport type { PopoverContextValues } from './usePopoverContextValues';\n\n/**\n * Render the final JSX of Popover\n */\nexport const renderPopover_unstable = (state: PopoverState, contextValues?: PopoverContextValues): JSXElement => {\n assertSlots<InternalPopoverSlots>(state);\n\n return (\n <PopoverContext.Provider value={contextValues?.popover ?? popoverContextDefaultValue}>\n {state.popoverTrigger}\n {state.popoverSurface && (\n <state.surfaceMotion>\n <MotionRefForwarder>\n {/* Casting here as content should be equivalent to <PopoverSurface /> */}\n {/* FIXME: content should not be ReactNode it should be ReactElement instead. */}\n {state.popoverSurface as React.ReactElement}\n </MotionRefForwarder>\n </state.surfaceMotion>\n )}\n </PopoverContext.Provider>\n );\n};\n"],"names":["React","assertSlots","MotionRefForwarder","PopoverContext","popoverContextDefaultValue","renderPopover_unstable","state","contextValues","Provider","value","popover","popoverTrigger","popoverSurface","surfaceMotion"],"mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,YAAYA,WAAW,QAAQ;AAC/B,SAASC,WAAW,QAAyB,4BAA4B;AACzE,SAASC,kBAAkB,QAAQ,yBAAyB;AAC5D,SAASC,cAAc,EAAEC,0BAA0B,QAAQ,uBAAuB;AAIlF;;CAEC,GACD,OAAO,MAAMC,yBAAyB,CAACC,OAAqBC;IAC1DN,YAAkCK;QAGAC;IADlC,qBACE,MAACJ,eAAeK,QAAQ;QAACC,OAAOF,CAAAA,yBAAAA,0BAAAA,oCAAAA,cAAeG,OAAO,cAAtBH,oCAAAA,yBAA0BH;;YACvDE,MAAMK,cAAc;YACpBL,MAAMM,cAAc,kBACnB,KAACN,MAAMO,aAAa;0BAClB,cAAA,KAACX;8BAGEI,MAAMM,cAAc;;;;;AAMjC,EAAE"}
1
+ {"version":3,"sources":["../src/components/Popover/renderPopover.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport * as React from 'react';\nimport { assertSlots, type JSXElement } from '@fluentui/react-utilities';\nimport { MotionRefForwarder } from '@fluentui/react-motion';\nimport { PopoverContext, popoverContextDefaultValue } from '../../popoverContext';\nimport type { InternalPopoverSlots, PopoverState } from './Popover.types';\nimport type { PopoverContextValues } from './usePopoverContextValues';\n\n/**\n * Render the final JSX of Popover\n */\nexport const renderPopover_unstable = (state: PopoverState, contextValues?: PopoverContextValues): JSXElement => {\n assertSlots<InternalPopoverSlots>(state);\n\n return (\n <PopoverContext.Provider value={contextValues?.popover ?? popoverContextDefaultValue}>\n {state.popoverTrigger}\n {state.popoverSurface && (\n <state.surfaceMotion>\n <MotionRefForwarder>\n {/* Casting here as content should be equivalent to <PopoverSurface /> */}\n {/* FIXME: content should not be ReactNode it should be ReactElement instead. */}\n {state.popoverSurface as React.ReactElement}\n </MotionRefForwarder>\n </state.surfaceMotion>\n )}\n </PopoverContext.Provider>\n );\n};\n"],"names":["React","assertSlots","MotionRefForwarder","PopoverContext","popoverContextDefaultValue","renderPopover_unstable","state","contextValues","Provider","value","popover","popoverTrigger","popoverSurface","surfaceMotion"],"mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,YAAYA,WAAW,QAAQ;AAC/B,SAASC,WAAW,QAAyB,4BAA4B;AACzE,SAASC,kBAAkB,QAAQ,yBAAyB;AAC5D,SAASC,cAAc,EAAEC,0BAA0B,QAAQ,0BAAuB;AAIlF;;CAEC,GACD,OAAO,MAAMC,yBAAyB,CAACC,OAAqBC;IAC1DN,YAAkCK;QAGAC;IADlC,qBACE,MAACJ,eAAeK,QAAQ;QAACC,OAAOF,CAAAA,yBAAAA,0BAAAA,oCAAAA,cAAeG,OAAO,cAAtBH,oCAAAA,yBAA0BH;;YACvDE,MAAMK,cAAc;YACpBL,MAAMM,cAAc,kBACnB,KAACN,MAAMO,aAAa;0BAClB,cAAA,KAACX;8BAGEI,MAAMM,cAAc;;;;;AAMjC,EAAE"}
@@ -1,13 +1,13 @@
1
1
  'use client';
2
- import * as React from 'react';
3
- import { useControllableState, useEventCallback, useOnClickOutside, useOnScrollOutside, elementContains, useTimeout } from '@fluentui/react-utilities';
4
- import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
5
- import { usePositioning, resolvePositioningShorthand, mergeArrowOffset, usePositioningMouseTarget, usePositioningSlideDirection } from '@fluentui/react-positioning';
6
- import { useFocusFinders, useActivateModal } from '@fluentui/react-tabster';
7
- import { arrowHeights } from '../PopoverSurface/index';
8
- import { popoverSurfaceBorderRadius } from './constants';
9
- import { presenceMotionSlot } from '@fluentui/react-motion';
10
- import { PopoverSurfaceMotion } from './PopoverSurfaceMotion';
2
+ import * as React from "react";
3
+ import { useControllableState, useEventCallback, useOnClickOutside, useOnScrollOutside, elementContains, useTimeout } from "@fluentui/react-utilities";
4
+ import { useFluent_unstable as useFluent } from "@fluentui/react-shared-contexts";
5
+ import { usePositioning, resolvePositioningShorthand, mergeArrowOffset, usePositioningMouseTarget, usePositioningSlideDirection } from "@fluentui/react-positioning";
6
+ import { useFocusFinders, useActivateModal } from "@fluentui/react-tabster";
7
+ import { arrowHeights } from "../PopoverSurface/index.js";
8
+ import { popoverSurfaceBorderRadius } from "./constants.js";
9
+ import { presenceMotionSlot } from "@fluentui/react-motion";
10
+ import { PopoverSurfaceMotion } from "./PopoverSurfaceMotion.js";
11
11
  /**
12
12
  * Create the state required to render Popover.
13
13
  *
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Popover/usePopover.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport {\n useControllableState,\n useEventCallback,\n useOnClickOutside,\n useOnScrollOutside,\n elementContains,\n useTimeout,\n} from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport {\n usePositioning,\n resolvePositioningShorthand,\n mergeArrowOffset,\n usePositioningMouseTarget,\n usePositioningSlideDirection,\n} from '@fluentui/react-positioning';\nimport { useFocusFinders, useActivateModal } from '@fluentui/react-tabster';\nimport { arrowHeights } from '../PopoverSurface/index';\nimport type { OpenPopoverEvents, PopoverProps, PopoverState } from './Popover.types';\nimport { popoverSurfaceBorderRadius } from './constants';\nimport { presenceMotionSlot } from '@fluentui/react-motion';\nimport { PopoverSurfaceMotion } from './PopoverSurfaceMotion';\n\n/**\n * Create the state required to render Popover.\n *\n * The returned state can be modified with hooks such as usePopoverStyles,\n * before being passed to renderPopover_unstable.\n *\n * @param props - props from this instance of Popover\n */\nexport const usePopover_unstable = (props: PopoverProps): PopoverState => {\n const [contextTarget, setContextTarget] = usePositioningMouseTarget();\n const { targetDocument } = useFluent();\n\n const positioning = resolvePositioningShorthand(props.positioning);\n const handlePositionEnd = usePositioningSlideDirection({\n targetDocument,\n onPositioningEnd: positioning.onPositioningEnd,\n });\n\n const initialState = {\n size: 'medium',\n contextTarget,\n setContextTarget,\n ...props,\n positioning: {\n ...positioning,\n onPositioningEnd: handlePositionEnd,\n },\n } as const;\n\n const children = React.Children.toArray(props.children) as React.ReactElement[];\n\n if (process.env.NODE_ENV !== 'production') {\n if (children.length === 0) {\n // eslint-disable-next-line no-console\n console.warn('Popover must contain at least one child');\n }\n\n if (children.length > 2) {\n // eslint-disable-next-line no-console\n console.warn('Popover must contain at most two children');\n }\n }\n\n let popoverTrigger: React.ReactElement | undefined = undefined;\n let popoverSurface: React.ReactElement | undefined = undefined;\n if (children.length === 2) {\n popoverTrigger = children[0];\n popoverSurface = children[1];\n } else if (children.length === 1) {\n popoverSurface = children[0];\n }\n\n const [open, setOpenState] = useOpenState(initialState);\n\n const [setOpenTimeout, clearOpenTimeout] = useTimeout();\n const setOpen = useEventCallback((e: OpenPopoverEvents, shouldOpen: boolean) => {\n clearOpenTimeout();\n if (!(e instanceof Event) && e.persist) {\n // < React 17 still uses pooled synthetic events\n e.persist();\n }\n\n if (e.type === 'mouseleave') {\n // FIXME leaking Node timeout type\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n setOpenTimeout(() => {\n setOpenState(e, shouldOpen);\n }, props.mouseLeaveDelay ?? 500);\n } else {\n setOpenState(e, shouldOpen);\n }\n });\n\n const toggleOpen = React.useCallback<PopoverState['toggleOpen']>(\n (e: OpenPopoverEvents) => {\n setOpen(e, !open);\n },\n [setOpen, open],\n );\n\n const positioningRefs = usePopoverRefs(initialState);\n\n useOnClickOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => setOpen(ev, false),\n refs: [positioningRefs.triggerRef, positioningRefs.contentRef],\n disabled: !open,\n disabledFocusOnIframe: !(props.closeOnIframeFocus ?? true),\n });\n\n // only close on scroll for context, or when closeOnScroll is specified\n const closeOnScroll = initialState.openOnContext || initialState.closeOnScroll;\n useOnScrollOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => setOpen(ev, false),\n refs: [positioningRefs.triggerRef, positioningRefs.contentRef],\n disabled: !open || !closeOnScroll,\n });\n\n // When trapFocus is enabled, dismiss the popover only on a genuine inside -> outside focus\n // transition. Focus that was never inside - e.g. a consumer keeping focus on an external element\n // via `unstable_disableAutoFocus` - must not dismiss it on an outside -> outside focus change.\n // Internal `closeOnFocusOutside` prop allows consumers to opt out during gradual rollout.\n const closeOnFocusOutside = (props as PopoverProps & { closeOnFocusOutside?: boolean }).closeOnFocusOutside ?? true;\n\n const focusWasInsideRef = React.useRef(false);\n\n const closeOnFocusOutCallback = useEventCallback((ev: FocusEvent) => {\n const target = (ev.composedPath()[0] ?? ev.target) as HTMLElement | null;\n const contentElement = positioningRefs.contentRef.current;\n const triggerElement = positioningRefs.triggerRef.current ?? null;\n\n if (!contentElement) {\n return;\n }\n\n const isInside = elementContains(contentElement, target) || elementContains(triggerElement, target);\n\n if (isInside) {\n focusWasInsideRef.current = true;\n return;\n }\n\n // Only dismiss if focus previously lived inside the popover.\n if (focusWasInsideRef.current) {\n focusWasInsideRef.current = false;\n setOpen(ev, false);\n }\n });\n\n React.useEffect(() => {\n if (!open || !props.trapFocus || !closeOnFocusOutside) {\n return;\n }\n\n focusWasInsideRef.current = false;\n targetDocument?.addEventListener('focusin', closeOnFocusOutCallback, true);\n return () => {\n targetDocument?.removeEventListener('focusin', closeOnFocusOutCallback, true);\n };\n }, [open, props.trapFocus, closeOnFocusOutside, targetDocument, closeOnFocusOutCallback]);\n\n const { findFirstFocusable } = useFocusFinders();\n const activateModal = useActivateModal();\n\n React.useEffect(() => {\n if (props.unstable_disableAutoFocus) {\n return;\n }\n\n const contentElement = positioningRefs.contentRef.current;\n\n if (open && contentElement) {\n const shouldFocusContainer = !isNaN(contentElement.getAttribute('tabIndex') ?? undefined);\n const firstFocusable = shouldFocusContainer ? contentElement : findFirstFocusable(contentElement);\n\n firstFocusable?.focus();\n\n if (shouldFocusContainer) {\n // Modal activation happens automatically when something inside the modal is focused programmatically.\n // When the container is focused, we need to activate the modal manually.\n activateModal(contentElement);\n }\n }\n }, [findFirstFocusable, activateModal, open, positioningRefs.contentRef, props.unstable_disableAutoFocus]);\n\n return {\n components: {\n surfaceMotion: PopoverSurfaceMotion,\n },\n ...initialState,\n ...positioningRefs,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n inertTrapFocus: props.inertTrapFocus ?? (props.legacyTrapFocus === undefined ? false : !props.legacyTrapFocus),\n popoverTrigger,\n popoverSurface,\n open,\n setOpen,\n toggleOpen,\n setContextTarget,\n contextTarget,\n inline: props.inline ?? false,\n surfaceMotion: presenceMotionSlot(props.surfaceMotion, {\n elementType: PopoverSurfaceMotion,\n defaultProps: {\n visible: open,\n appear: true,\n unmountOnExit: true,\n },\n }),\n };\n};\n\n/**\n * Creates and manages the Popover open state\n */\nfunction useOpenState(\n state: Pick<PopoverState, 'setContextTarget' | 'onOpenChange'> & Pick<PopoverProps, 'open' | 'defaultOpen'>,\n) {\n const onOpenChange: PopoverState['onOpenChange'] = useEventCallback((e, data) => state.onOpenChange?.(e, data));\n\n const [open, setOpenState] = useControllableState({\n state: state.open,\n defaultState: state.defaultOpen,\n initialState: false,\n });\n // eslint-disable-next-line react-hooks/immutability\n state.open = open !== undefined ? open : state.open;\n const setContextTarget = state.setContextTarget;\n\n const setOpen = React.useCallback(\n (e: OpenPopoverEvents, shouldOpen: boolean) => {\n if (shouldOpen && e.type === 'contextmenu') {\n setContextTarget(e as React.MouseEvent);\n }\n\n if (!shouldOpen) {\n setContextTarget(undefined);\n }\n\n setOpenState(shouldOpen);\n onOpenChange?.(e, { open: shouldOpen });\n },\n [setOpenState, onOpenChange, setContextTarget],\n );\n\n return [open, setOpen] as const;\n}\n\n/**\n * Creates and sets the necessary trigger, target and content refs used by Popover\n */\nfunction usePopoverRefs(\n state: Pick<PopoverState, 'size' | 'contextTarget'> &\n Pick<PopoverProps, 'positioning' | 'openOnContext' | 'withArrow'>,\n) {\n const positioningOptions = {\n position: 'above' as const,\n align: 'center' as const,\n arrowPadding: 2 * popoverSurfaceBorderRadius,\n target: state.openOnContext ? state.contextTarget : undefined,\n ...resolvePositioningShorthand(state.positioning),\n };\n\n // no reason to render arrow when covering the target\n if (positioningOptions.coverTarget) {\n // eslint-disable-next-line react-hooks/immutability\n state.withArrow = false;\n }\n\n if (state.withArrow) {\n positioningOptions.offset = mergeArrowOffset(positioningOptions.offset, arrowHeights[state.size]);\n }\n\n const { targetRef: triggerRef, containerRef: contentRef, arrowRef } = usePositioning(positioningOptions);\n\n return {\n triggerRef,\n contentRef,\n arrowRef,\n } as const;\n}\n"],"names":["React","useControllableState","useEventCallback","useOnClickOutside","useOnScrollOutside","elementContains","useTimeout","useFluent_unstable","useFluent","usePositioning","resolvePositioningShorthand","mergeArrowOffset","usePositioningMouseTarget","usePositioningSlideDirection","useFocusFinders","useActivateModal","arrowHeights","popoverSurfaceBorderRadius","presenceMotionSlot","PopoverSurfaceMotion","usePopover_unstable","props","contextTarget","setContextTarget","targetDocument","positioning","handlePositionEnd","onPositioningEnd","initialState","size","children","Children","toArray","process","env","NODE_ENV","length","console","warn","popoverTrigger","undefined","popoverSurface","open","setOpenState","useOpenState","setOpenTimeout","clearOpenTimeout","setOpen","e","shouldOpen","Event","persist","type","mouseLeaveDelay","toggleOpen","useCallback","positioningRefs","usePopoverRefs","contains","element","callback","ev","refs","triggerRef","contentRef","disabled","disabledFocusOnIframe","closeOnIframeFocus","closeOnScroll","openOnContext","closeOnFocusOutside","focusWasInsideRef","useRef","closeOnFocusOutCallback","target","composedPath","contentElement","current","triggerElement","isInside","useEffect","trapFocus","addEventListener","removeEventListener","findFirstFocusable","activateModal","unstable_disableAutoFocus","shouldFocusContainer","isNaN","getAttribute","firstFocusable","focus","components","surfaceMotion","inertTrapFocus","legacyTrapFocus","inline","elementType","defaultProps","visible","appear","unmountOnExit","state","onOpenChange","data","defaultState","defaultOpen","positioningOptions","position","align","arrowPadding","coverTarget","withArrow","offset","targetRef","containerRef","arrowRef"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SACEC,oBAAoB,EACpBC,gBAAgB,EAChBC,iBAAiB,EACjBC,kBAAkB,EAClBC,eAAe,EACfC,UAAU,QACL,4BAA4B;AACnC,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,SACEC,cAAc,EACdC,2BAA2B,EAC3BC,gBAAgB,EAChBC,yBAAyB,EACzBC,4BAA4B,QACvB,8BAA8B;AACrC,SAASC,eAAe,EAAEC,gBAAgB,QAAQ,0BAA0B;AAC5E,SAASC,YAAY,QAAQ,0BAA0B;AAEvD,SAASC,0BAA0B,QAAQ,cAAc;AACzD,SAASC,kBAAkB,QAAQ,yBAAyB;AAC5D,SAASC,oBAAoB,QAAQ,yBAAyB;AAE9D;;;;;;;CAOC,GACD,OAAO,MAAMC,sBAAsB,CAACC;IAClC,MAAM,CAACC,eAAeC,iBAAiB,GAAGX;IAC1C,MAAM,EAAEY,cAAc,EAAE,GAAGhB;IAE3B,MAAMiB,cAAcf,4BAA4BW,MAAMI,WAAW;IACjE,MAAMC,oBAAoBb,6BAA6B;QACrDW;QACAG,kBAAkBF,YAAYE,gBAAgB;IAChD;IAEA,MAAMC,eAAe;QACnBC,MAAM;QACNP;QACAC;QACA,GAAGF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ByD,QAAQ4B,MAAMjC,aAAa,GAAGiC,MAAMhF,aAAa,GAAGkB;QACpD,GAAG9B,4BAA4B4F,MAAM7E,WAAW,CAAC;IACnD;IAEA,qDAAqD;IACrD,IAAIkF,mBAAmBI,WAAW,EAAE;QAClC,oDAAoD;QACpDT,MAAMU,SAAS,GAAG;IACpB;IAEA,IAAIV,MAAMU,SAAS,EAAE;QACnBL,mBAAmBM,MAAM,GAAGtG,iBAAiBgG,mBAAmBM,MAAM,EAAEjG,YAAY,CAACsF,MAAMzE,IAAI,CAAC;IAClG;IAEA,MAAM,EAAEqF,WAAWnD,UAAU,EAAEoD,cAAcnD,UAAU,EAAEoD,QAAQ,EAAE,GAAG3G,eAAekG;IAErF,OAAO;QACL5C;QACAC;QACAoD;IACF;AACF"}
1
+ {"version":3,"sources":["../src/components/Popover/usePopover.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport {\n useControllableState,\n useEventCallback,\n useOnClickOutside,\n useOnScrollOutside,\n elementContains,\n useTimeout,\n} from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport {\n usePositioning,\n resolvePositioningShorthand,\n mergeArrowOffset,\n usePositioningMouseTarget,\n usePositioningSlideDirection,\n} from '@fluentui/react-positioning';\nimport { useFocusFinders, useActivateModal } from '@fluentui/react-tabster';\nimport { arrowHeights } from '../PopoverSurface/index';\nimport type { OpenPopoverEvents, PopoverProps, PopoverState } from './Popover.types';\nimport { popoverSurfaceBorderRadius } from './constants';\nimport { presenceMotionSlot } from '@fluentui/react-motion';\nimport { PopoverSurfaceMotion } from './PopoverSurfaceMotion';\n\n/**\n * Create the state required to render Popover.\n *\n * The returned state can be modified with hooks such as usePopoverStyles,\n * before being passed to renderPopover_unstable.\n *\n * @param props - props from this instance of Popover\n */\nexport const usePopover_unstable = (props: PopoverProps): PopoverState => {\n const [contextTarget, setContextTarget] = usePositioningMouseTarget();\n const { targetDocument } = useFluent();\n\n const positioning = resolvePositioningShorthand(props.positioning);\n const handlePositionEnd = usePositioningSlideDirection({\n targetDocument,\n onPositioningEnd: positioning.onPositioningEnd,\n });\n\n const initialState = {\n size: 'medium',\n contextTarget,\n setContextTarget,\n ...props,\n positioning: {\n ...positioning,\n onPositioningEnd: handlePositionEnd,\n },\n } as const;\n\n const children = React.Children.toArray(props.children) as React.ReactElement[];\n\n if (process.env.NODE_ENV !== 'production') {\n if (children.length === 0) {\n // eslint-disable-next-line no-console\n console.warn('Popover must contain at least one child');\n }\n\n if (children.length > 2) {\n // eslint-disable-next-line no-console\n console.warn('Popover must contain at most two children');\n }\n }\n\n let popoverTrigger: React.ReactElement | undefined = undefined;\n let popoverSurface: React.ReactElement | undefined = undefined;\n if (children.length === 2) {\n popoverTrigger = children[0];\n popoverSurface = children[1];\n } else if (children.length === 1) {\n popoverSurface = children[0];\n }\n\n const [open, setOpenState] = useOpenState(initialState);\n\n const [setOpenTimeout, clearOpenTimeout] = useTimeout();\n const setOpen = useEventCallback((e: OpenPopoverEvents, shouldOpen: boolean) => {\n clearOpenTimeout();\n if (!(e instanceof Event) && e.persist) {\n // < React 17 still uses pooled synthetic events\n e.persist();\n }\n\n if (e.type === 'mouseleave') {\n // FIXME leaking Node timeout type\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n setOpenTimeout(() => {\n setOpenState(e, shouldOpen);\n }, props.mouseLeaveDelay ?? 500);\n } else {\n setOpenState(e, shouldOpen);\n }\n });\n\n const toggleOpen = React.useCallback<PopoverState['toggleOpen']>(\n (e: OpenPopoverEvents) => {\n setOpen(e, !open);\n },\n [setOpen, open],\n );\n\n const positioningRefs = usePopoverRefs(initialState);\n\n useOnClickOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => setOpen(ev, false),\n refs: [positioningRefs.triggerRef, positioningRefs.contentRef],\n disabled: !open,\n disabledFocusOnIframe: !(props.closeOnIframeFocus ?? true),\n });\n\n // only close on scroll for context, or when closeOnScroll is specified\n const closeOnScroll = initialState.openOnContext || initialState.closeOnScroll;\n useOnScrollOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => setOpen(ev, false),\n refs: [positioningRefs.triggerRef, positioningRefs.contentRef],\n disabled: !open || !closeOnScroll,\n });\n\n // When trapFocus is enabled, dismiss the popover only on a genuine inside -> outside focus\n // transition. Focus that was never inside - e.g. a consumer keeping focus on an external element\n // via `unstable_disableAutoFocus` - must not dismiss it on an outside -> outside focus change.\n // Internal `closeOnFocusOutside` prop allows consumers to opt out during gradual rollout.\n const closeOnFocusOutside = (props as PopoverProps & { closeOnFocusOutside?: boolean }).closeOnFocusOutside ?? true;\n\n const focusWasInsideRef = React.useRef(false);\n\n const closeOnFocusOutCallback = useEventCallback((ev: FocusEvent) => {\n const target = (ev.composedPath()[0] ?? ev.target) as HTMLElement | null;\n const contentElement = positioningRefs.contentRef.current;\n const triggerElement = positioningRefs.triggerRef.current ?? null;\n\n if (!contentElement) {\n return;\n }\n\n const isInside = elementContains(contentElement, target) || elementContains(triggerElement, target);\n\n if (isInside) {\n focusWasInsideRef.current = true;\n return;\n }\n\n // Only dismiss if focus previously lived inside the popover.\n if (focusWasInsideRef.current) {\n focusWasInsideRef.current = false;\n setOpen(ev, false);\n }\n });\n\n React.useEffect(() => {\n if (!open || !props.trapFocus || !closeOnFocusOutside) {\n return;\n }\n\n focusWasInsideRef.current = false;\n targetDocument?.addEventListener('focusin', closeOnFocusOutCallback, true);\n return () => {\n targetDocument?.removeEventListener('focusin', closeOnFocusOutCallback, true);\n };\n }, [open, props.trapFocus, closeOnFocusOutside, targetDocument, closeOnFocusOutCallback]);\n\n const { findFirstFocusable } = useFocusFinders();\n const activateModal = useActivateModal();\n\n React.useEffect(() => {\n if (props.unstable_disableAutoFocus) {\n return;\n }\n\n const contentElement = positioningRefs.contentRef.current;\n\n if (open && contentElement) {\n const shouldFocusContainer = !isNaN(contentElement.getAttribute('tabIndex') ?? undefined);\n const firstFocusable = shouldFocusContainer ? contentElement : findFirstFocusable(contentElement);\n\n firstFocusable?.focus();\n\n if (shouldFocusContainer) {\n // Modal activation happens automatically when something inside the modal is focused programmatically.\n // When the container is focused, we need to activate the modal manually.\n activateModal(contentElement);\n }\n }\n }, [findFirstFocusable, activateModal, open, positioningRefs.contentRef, props.unstable_disableAutoFocus]);\n\n return {\n components: {\n surfaceMotion: PopoverSurfaceMotion,\n },\n ...initialState,\n ...positioningRefs,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n inertTrapFocus: props.inertTrapFocus ?? (props.legacyTrapFocus === undefined ? false : !props.legacyTrapFocus),\n popoverTrigger,\n popoverSurface,\n open,\n setOpen,\n toggleOpen,\n setContextTarget,\n contextTarget,\n inline: props.inline ?? false,\n surfaceMotion: presenceMotionSlot(props.surfaceMotion, {\n elementType: PopoverSurfaceMotion,\n defaultProps: {\n visible: open,\n appear: true,\n unmountOnExit: true,\n },\n }),\n };\n};\n\n/**\n * Creates and manages the Popover open state\n */\nfunction useOpenState(\n state: Pick<PopoverState, 'setContextTarget' | 'onOpenChange'> & Pick<PopoverProps, 'open' | 'defaultOpen'>,\n) {\n const onOpenChange: PopoverState['onOpenChange'] = useEventCallback((e, data) => state.onOpenChange?.(e, data));\n\n const [open, setOpenState] = useControllableState({\n state: state.open,\n defaultState: state.defaultOpen,\n initialState: false,\n });\n // eslint-disable-next-line react-hooks/immutability\n state.open = open !== undefined ? open : state.open;\n const setContextTarget = state.setContextTarget;\n\n const setOpen = React.useCallback(\n (e: OpenPopoverEvents, shouldOpen: boolean) => {\n if (shouldOpen && e.type === 'contextmenu') {\n setContextTarget(e as React.MouseEvent);\n }\n\n if (!shouldOpen) {\n setContextTarget(undefined);\n }\n\n setOpenState(shouldOpen);\n onOpenChange?.(e, { open: shouldOpen });\n },\n [setOpenState, onOpenChange, setContextTarget],\n );\n\n return [open, setOpen] as const;\n}\n\n/**\n * Creates and sets the necessary trigger, target and content refs used by Popover\n */\nfunction usePopoverRefs(\n state: Pick<PopoverState, 'size' | 'contextTarget'> &\n Pick<PopoverProps, 'positioning' | 'openOnContext' | 'withArrow'>,\n) {\n const positioningOptions = {\n position: 'above' as const,\n align: 'center' as const,\n arrowPadding: 2 * popoverSurfaceBorderRadius,\n target: state.openOnContext ? state.contextTarget : undefined,\n ...resolvePositioningShorthand(state.positioning),\n };\n\n // no reason to render arrow when covering the target\n if (positioningOptions.coverTarget) {\n // eslint-disable-next-line react-hooks/immutability\n state.withArrow = false;\n }\n\n if (state.withArrow) {\n positioningOptions.offset = mergeArrowOffset(positioningOptions.offset, arrowHeights[state.size]);\n }\n\n const { targetRef: triggerRef, containerRef: contentRef, arrowRef } = usePositioning(positioningOptions);\n\n return {\n triggerRef,\n contentRef,\n arrowRef,\n } as const;\n}\n"],"names":["React","useControllableState","useEventCallback","useOnClickOutside","useOnScrollOutside","elementContains","useTimeout","useFluent_unstable","useFluent","usePositioning","resolvePositioningShorthand","mergeArrowOffset","usePositioningMouseTarget","usePositioningSlideDirection","useFocusFinders","useActivateModal","arrowHeights","popoverSurfaceBorderRadius","presenceMotionSlot","PopoverSurfaceMotion","usePopover_unstable","props","contextTarget","setContextTarget","targetDocument","positioning","handlePositionEnd","onPositioningEnd","initialState","size","children","Children","toArray","process","env","NODE_ENV","length","console","warn","popoverTrigger","undefined","popoverSurface","open","setOpenState","useOpenState","setOpenTimeout","clearOpenTimeout","setOpen","e","shouldOpen","Event","persist","type","mouseLeaveDelay","toggleOpen","useCallback","positioningRefs","usePopoverRefs","contains","element","callback","ev","refs","triggerRef","contentRef","disabled","disabledFocusOnIframe","closeOnIframeFocus","closeOnScroll","openOnContext","closeOnFocusOutside","focusWasInsideRef","useRef","closeOnFocusOutCallback","target","composedPath","contentElement","current","triggerElement","isInside","useEffect","trapFocus","addEventListener","removeEventListener","findFirstFocusable","activateModal","unstable_disableAutoFocus","shouldFocusContainer","isNaN","getAttribute","firstFocusable","focus","components","surfaceMotion","inertTrapFocus","legacyTrapFocus","inline","elementType","defaultProps","visible","appear","unmountOnExit","state","onOpenChange","data","defaultState","defaultOpen","positioningOptions","position","align","arrowPadding","coverTarget","withArrow","offset","targetRef","containerRef","arrowRef"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SACEC,oBAAoB,EACpBC,gBAAgB,EAChBC,iBAAiB,EACjBC,kBAAkB,EAClBC,eAAe,EACfC,UAAU,QACL,4BAA4B;AACnC,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,SACEC,cAAc,EACdC,2BAA2B,EAC3BC,gBAAgB,EAChBC,yBAAyB,EACzBC,4BAA4B,QACvB,8BAA8B;AACrC,SAASC,eAAe,EAAEC,gBAAgB,QAAQ,0BAA0B;AAC5E,SAASC,YAAY,QAAQ,6BAA0B;AAEvD,SAASC,0BAA0B,QAAQ,iBAAc;AACzD,SAASC,kBAAkB,QAAQ,yBAAyB;AAC5D,SAASC,oBAAoB,QAAQ,4BAAyB;AAE9D;;;;;;;CAOC,GACD,OAAO,MAAMC,sBAAsB,CAACC;IAClC,MAAM,CAACC,eAAeC,iBAAiB,GAAGX;IAC1C,MAAM,EAAEY,cAAc,EAAE,GAAGhB;IAE3B,MAAMiB,cAAcf,4BAA4BW,MAAMI,WAAW;IACjE,MAAMC,oBAAoBb,6BAA6B;QACrDW;QACAG,kBAAkBF,YAAYE,gBAAgB;IAChD;IAEA,MAAMC,eAAe;QACnBC,MAAM;QACNP;QACAC;QACA,GAAGF,KAAK;QACRI,aAAa;YACX,GAAGA,WAAW;YACdE,kBAAkBD;QACpB;IACF;IAEA,MAAMI,WAAW9B,MAAM+B,QAAQ,CAACC,OAAO,CAACX,MAAMS,QAAQ;IAEtD,IAAIG,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,IAAIL,SAASM,MAAM,KAAK,GAAG;YACzB,sCAAsC;YACtCC,QAAQC,IAAI,CAAC;QACf;QAEA,IAAIR,SAASM,MAAM,GAAG,GAAG;YACvB,sCAAsC;YACtCC,QAAQC,IAAI,CAAC;QACf;IACF;IAEA,IAAIC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AWnD,UAAU,EAAEoD,cAAcnD,UAAU,EAAEoD,QAAQ,EAAE,GAAG3G,eAAekG;IAErF,OAAO;QACL5C;QACAC;QACAoD;IACF;AACF"}
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import * as React from 'react';
2
+ import * as React from "react";
3
3
  export function usePopoverContextValues_unstable(state) {
4
4
  const { appearance, arrowRef, contentRef, inline, mountNode, open, openOnContext, openOnHover, setOpen, size, toggleOpen, trapFocus, triggerRef, withArrow, inertTrapFocus } = state;
5
5
  const popover = React.useMemo(()=>({
@@ -1,9 +1,9 @@
1
1
  'use client';
2
- import * as React from 'react';
3
- import { usePopoverSurface_unstable } from './usePopoverSurface';
4
- import { renderPopoverSurface_unstable } from './renderPopoverSurface';
5
- import { usePopoverSurfaceStyles_unstable } from './usePopoverSurfaceStyles.styles';
6
- import { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';
2
+ import * as React from "react";
3
+ import { usePopoverSurface_unstable } from "./usePopoverSurface.js";
4
+ import { renderPopoverSurface_unstable } from "./renderPopoverSurface.js";
5
+ import { usePopoverSurfaceStyles_unstable } from "./usePopoverSurfaceStyles.styles.js";
6
+ import { useCustomStyleHook_unstable } from "@fluentui/react-shared-contexts";
7
7
  /**
8
8
  * PopoverSurface component renders react children in a positioned box
9
9
  */ export const PopoverSurface = /*#__PURE__*/ React.forwardRef((props, ref)=>{