@fluentui/react-popover 9.0.0-nightly.d730088d7f.0 → 9.0.0-rc.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. package/CHANGELOG.json +868 -27
  2. package/CHANGELOG.md +280 -81
  3. package/Spec.md +20 -0
  4. package/dist/{react-popover.d.ts → index.d.ts} +116 -67
  5. package/{lib → dist}/tsdoc-metadata.json +0 -0
  6. package/lib/Popover.js.map +1 -1
  7. package/lib/PopoverSurface.js.map +1 -1
  8. package/lib/PopoverTrigger.js.map +1 -1
  9. package/lib/components/Popover/Popover.js +5 -5
  10. package/lib/components/Popover/Popover.js.map +1 -1
  11. package/lib/components/Popover/Popover.types.js.map +1 -1
  12. package/lib/components/Popover/index.js.map +1 -1
  13. package/lib/components/Popover/renderPopover.js +30 -26
  14. package/lib/components/Popover/renderPopover.js.map +1 -1
  15. package/lib/components/Popover/usePopover.js +116 -54
  16. package/lib/components/Popover/usePopover.js.map +1 -1
  17. package/lib/components/PopoverSurface/PopoverSurface.js +7 -7
  18. package/lib/components/PopoverSurface/PopoverSurface.js.map +1 -1
  19. package/lib/components/PopoverSurface/PopoverSurface.types.js.map +1 -1
  20. package/lib/components/PopoverSurface/index.js.map +1 -1
  21. package/lib/components/PopoverSurface/renderPopoverSurface.js +13 -13
  22. package/lib/components/PopoverSurface/renderPopoverSurface.js.map +1 -1
  23. package/lib/components/PopoverSurface/usePopoverSurface.js +40 -64
  24. package/lib/components/PopoverSurface/usePopoverSurface.js.map +1 -1
  25. package/lib/components/PopoverSurface/usePopoverSurfaceStyles.js +41 -22
  26. package/lib/components/PopoverSurface/usePopoverSurfaceStyles.js.map +1 -1
  27. package/lib/components/PopoverTrigger/PopoverTrigger.js +6 -5
  28. package/lib/components/PopoverTrigger/PopoverTrigger.js.map +1 -1
  29. package/lib/components/PopoverTrigger/PopoverTrigger.types.js.map +1 -1
  30. package/lib/components/PopoverTrigger/index.js.map +1 -1
  31. package/lib/components/PopoverTrigger/renderPopoverTrigger.js +1 -1
  32. package/lib/components/PopoverTrigger/renderPopoverTrigger.js.map +1 -1
  33. package/lib/components/PopoverTrigger/usePopoverTrigger.js +40 -55
  34. package/lib/components/PopoverTrigger/usePopoverTrigger.js.map +1 -1
  35. package/lib/index.js +5 -4
  36. package/lib/index.js.map +1 -1
  37. package/lib/popoverContext.js +6 -9
  38. package/lib/popoverContext.js.map +1 -1
  39. package/lib-commonjs/Popover.js +1 -1
  40. package/lib-commonjs/Popover.js.map +1 -1
  41. package/lib-commonjs/PopoverSurface.js +1 -1
  42. package/lib-commonjs/PopoverSurface.js.map +1 -1
  43. package/lib-commonjs/PopoverTrigger.js +1 -1
  44. package/lib-commonjs/PopoverTrigger.js.map +1 -1
  45. package/lib-commonjs/components/Popover/Popover.js +5 -5
  46. package/lib-commonjs/components/Popover/Popover.js.map +1 -1
  47. package/lib-commonjs/components/Popover/Popover.types.js.map +1 -1
  48. package/lib-commonjs/components/Popover/index.js +1 -1
  49. package/lib-commonjs/components/Popover/index.js.map +1 -1
  50. package/lib-commonjs/components/Popover/renderPopover.js +34 -30
  51. package/lib-commonjs/components/Popover/renderPopover.js.map +1 -1
  52. package/lib-commonjs/components/Popover/usePopover.js +121 -59
  53. package/lib-commonjs/components/Popover/usePopover.js.map +1 -1
  54. package/lib-commonjs/components/PopoverSurface/PopoverSurface.js +8 -8
  55. package/lib-commonjs/components/PopoverSurface/PopoverSurface.js.map +1 -1
  56. package/lib-commonjs/components/PopoverSurface/PopoverSurface.types.js.map +1 -1
  57. package/lib-commonjs/components/PopoverSurface/index.js +1 -1
  58. package/lib-commonjs/components/PopoverSurface/index.js.map +1 -1
  59. package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.js +18 -20
  60. package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.js.map +1 -1
  61. package/lib-commonjs/components/PopoverSurface/usePopoverSurface.js +44 -70
  62. package/lib-commonjs/components/PopoverSurface/usePopoverSurface.js.map +1 -1
  63. package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.js +45 -24
  64. package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.js.map +1 -1
  65. package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.js +6 -5
  66. package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.js.map +1 -1
  67. package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.types.js.map +1 -1
  68. package/lib-commonjs/components/PopoverTrigger/index.js +1 -1
  69. package/lib-commonjs/components/PopoverTrigger/index.js.map +1 -1
  70. package/lib-commonjs/components/PopoverTrigger/renderPopoverTrigger.js +3 -3
  71. package/lib-commonjs/components/PopoverTrigger/renderPopoverTrigger.js.map +1 -1
  72. package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.js +45 -61
  73. package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.js.map +1 -1
  74. package/lib-commonjs/index.js +99 -5
  75. package/lib-commonjs/index.js.map +1 -1
  76. package/lib-commonjs/popoverContext.js +8 -11
  77. package/lib-commonjs/popoverContext.js.map +1 -1
  78. package/package.json +23 -27
  79. package/lib/Popover.d.ts +0 -1
  80. package/lib/PopoverSurface.d.ts +0 -1
  81. package/lib/PopoverTrigger.d.ts +0 -1
  82. package/lib/common/isConformant.d.ts +0 -4
  83. package/lib/common/isConformant.js +0 -13
  84. package/lib/common/isConformant.js.map +0 -1
  85. package/lib/common/mockUsePopoverContext.d.ts +0 -7
  86. package/lib/common/mockUsePopoverContext.js +0 -38
  87. package/lib/common/mockUsePopoverContext.js.map +0 -1
  88. package/lib/components/Popover/Popover.d.ts +0 -6
  89. package/lib/components/Popover/Popover.types.d.ts +0 -100
  90. package/lib/components/Popover/index.d.ts +0 -4
  91. package/lib/components/Popover/renderPopover.d.ts +0 -5
  92. package/lib/components/Popover/usePopover.d.ts +0 -10
  93. package/lib/components/PopoverSurface/PopoverSurface.d.ts +0 -6
  94. package/lib/components/PopoverSurface/PopoverSurface.types.d.ts +0 -21
  95. package/lib/components/PopoverSurface/index.d.ts +0 -5
  96. package/lib/components/PopoverSurface/renderPopoverSurface.d.ts +0 -5
  97. package/lib/components/PopoverSurface/usePopoverSurface.d.ts +0 -13
  98. package/lib/components/PopoverSurface/usePopoverSurfaceStyles.d.ts +0 -7
  99. package/lib/components/PopoverTrigger/PopoverTrigger.d.ts +0 -6
  100. package/lib/components/PopoverTrigger/PopoverTrigger.types.d.ts +0 -11
  101. package/lib/components/PopoverTrigger/index.d.ts +0 -4
  102. package/lib/components/PopoverTrigger/renderPopoverTrigger.d.ts +0 -5
  103. package/lib/components/PopoverTrigger/usePopoverTrigger.d.ts +0 -10
  104. package/lib/index.d.ts +0 -4
  105. package/lib/popoverContext.d.ts +0 -8
  106. package/lib-commonjs/Popover.d.ts +0 -1
  107. package/lib-commonjs/PopoverSurface.d.ts +0 -1
  108. package/lib-commonjs/PopoverTrigger.d.ts +0 -1
  109. package/lib-commonjs/common/isConformant.d.ts +0 -4
  110. package/lib-commonjs/common/isConformant.js +0 -24
  111. package/lib-commonjs/common/isConformant.js.map +0 -1
  112. package/lib-commonjs/common/mockUsePopoverContext.d.ts +0 -7
  113. package/lib-commonjs/common/mockUsePopoverContext.js +0 -49
  114. package/lib-commonjs/common/mockUsePopoverContext.js.map +0 -1
  115. package/lib-commonjs/components/Popover/Popover.d.ts +0 -6
  116. package/lib-commonjs/components/Popover/Popover.types.d.ts +0 -100
  117. package/lib-commonjs/components/Popover/index.d.ts +0 -4
  118. package/lib-commonjs/components/Popover/renderPopover.d.ts +0 -5
  119. package/lib-commonjs/components/Popover/usePopover.d.ts +0 -10
  120. package/lib-commonjs/components/PopoverSurface/PopoverSurface.d.ts +0 -6
  121. package/lib-commonjs/components/PopoverSurface/PopoverSurface.types.d.ts +0 -21
  122. package/lib-commonjs/components/PopoverSurface/index.d.ts +0 -5
  123. package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.d.ts +0 -5
  124. package/lib-commonjs/components/PopoverSurface/usePopoverSurface.d.ts +0 -13
  125. package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.d.ts +0 -7
  126. package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.d.ts +0 -6
  127. package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.types.d.ts +0 -11
  128. package/lib-commonjs/components/PopoverTrigger/index.d.ts +0 -4
  129. package/lib-commonjs/components/PopoverTrigger/renderPopoverTrigger.d.ts +0 -5
  130. package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.d.ts +0 -10
  131. package/lib-commonjs/index.d.ts +0 -4
  132. package/lib-commonjs/popoverContext.d.ts +0 -8
package/Spec.md CHANGED
@@ -238,6 +238,11 @@ export type PopoverProps = {
238
238
  */
239
239
  onOpenChange?: (e: OpenPopoverEvents, data: OpenEventData) => void;
240
240
 
241
+ /**
242
+ * Flag to open the Popover by hovering the trigger
243
+ */
244
+ openOnHover?: boolean;
245
+
241
246
  /**
242
247
  * Anchor the popover to an element other than the trigger
243
248
  */
@@ -284,6 +289,16 @@ export type PopoverProps = {
284
289
  * Do not render an arrow pointing to the target element. This is the `PopoverTrigger` unless `target` prop is used
285
290
  */
286
291
  noArrow?: boolean;
292
+
293
+ /**
294
+ * Sets the delay for closing popover on mouse leave
295
+ */
296
+ mouseLeaveDelay?: number;
297
+
298
+ /**
299
+ * Close when scrolling outside of it
300
+ */
301
+ closeOnScroll?: boolean;
287
302
  };
288
303
  ```
289
304
 
@@ -445,6 +460,11 @@ The popover closes with the escape key when the trigger or popover content has f
445
460
 
446
461
  The popover closes when a click happens outside the popover trigger or content.
447
462
 
463
+ #### Scroll outside
464
+
465
+ The context menu popover closes when scroll happens outside the popover trigger or content.
466
+ When popover is configured with `closeOnScroll`, popover closes when scroll happens outside the popover trigger or content.
467
+
448
468
  ### Focus trap
449
469
 
450
470
  When the popover is configured to be a focus trap, focus the first focusable element inside the popover on open.
@@ -2,12 +2,16 @@ import type { ComponentProps } from '@fluentui/react-utilities';
2
2
  import type { ComponentState } from '@fluentui/react-utilities';
3
3
  import type { Context } from '@fluentui/react-context-selector';
4
4
  import type { ContextSelector } from '@fluentui/react-context-selector';
5
+ import type { FluentTriggerComponent } from '@fluentui/react-utilities';
5
6
  import type { ForwardRefComponent } from '@fluentui/react-utilities';
6
- import type { IntrinsicShorthandProps } from '@fluentui/react-utilities';
7
+ import { JSXElementConstructor } from 'react';
7
8
  import type { PopperVirtualElement } from '@fluentui/react-positioning';
8
9
  import type { PortalProps } from '@fluentui/react-portal';
9
10
  import type { PositioningShorthand } from '@fluentui/react-positioning';
10
11
  import * as React_2 from 'react';
12
+ import { ReactElement } from 'react';
13
+ import type { Slot } from '@fluentui/react-utilities';
14
+ import type { SlotClassNames } from '@fluentui/react-utilities';
11
15
  import type { usePopperMouseTarget } from '@fluentui/react-positioning';
12
16
 
13
17
  export declare const arrowHeights: Record<PopoverSize, number>;
@@ -15,80 +19,106 @@ export declare const arrowHeights: Record<PopoverSize, number>;
15
19
  /**
16
20
  * Data attached to open/close events
17
21
  */
18
- export declare type OnOpenChangeData = Pick<PopoverState, 'open'>;
22
+ export declare type OnOpenChangeData = {
23
+ open: boolean;
24
+ };
19
25
 
20
26
  /**
21
27
  * The supported events that will trigger open/close of the menu
22
28
  */
23
- export declare type OpenPopoverEvents = MouseEvent | TouchEvent | React_2.MouseEvent<HTMLElement> | React_2.KeyboardEvent<HTMLElement> | React_2.FocusEvent<HTMLElement>;
29
+ export declare type OpenPopoverEvents = MouseEvent | TouchEvent | React_2.FocusEvent<HTMLElement> | React_2.KeyboardEvent<HTMLElement> | React_2.MouseEvent<HTMLElement>;
24
30
 
25
31
  /**
26
32
  * Wrapper component that manages state for a PopoverTrigger and a PopoverSurface components.
27
33
  */
28
34
  export declare const Popover: React_2.FC<PopoverProps>;
29
35
 
30
- export declare type PopoverCommons = Pick<PortalProps, 'mountNode'> & {
36
+ export declare const PopoverContext: Context<PopoverContextValue>;
37
+
38
+ /**
39
+ * Context shared between Popover and its children components
40
+ */
41
+ export declare type PopoverContextValue = Pick<PopoverState, 'toggleOpen' | 'setOpen' | 'triggerRef' | 'contentRef' | 'openOnHover' | 'openOnContext' | 'mountNode' | 'noArrow' | 'arrowRef' | 'size' | 'appearance' | 'trapFocus' | 'inline'>;
42
+
43
+ /**
44
+ * Popover Props
45
+ */
46
+ export declare type PopoverProps = Pick<PortalProps, 'mountNode'> & {
31
47
  /**
32
- * Controls the opening of the Popover
48
+ * A popover can appear styled with brand or inverted.
49
+ * When not specified, the default style is used.
33
50
  */
34
- open: boolean;
51
+ appearance?: 'brand' | 'inverted';
52
+ /**
53
+ * Can contain two children including {@link PopoverTrigger} and {@link PopoverSurface}.
54
+ * Alternatively can only contain {@link PopoverSurface} if using a custom `target`.
55
+ */
56
+ children: [JSX.Element, JSX.Element] | JSX.Element;
57
+ /**
58
+ * Close when scroll outside of it
59
+ *
60
+ * @default false
61
+ */
62
+ closeOnScroll?: boolean;
35
63
  /**
36
64
  * Used to set the initial open state of the Popover in uncontrolled mode
65
+ *
66
+ * @default false
37
67
  */
38
68
  defaultOpen?: boolean;
69
+ /**
70
+ * Popovers are rendered out of DOM order on `document.body` by default, use this to render the popover in DOM order
71
+ *
72
+ * @default false
73
+ */
74
+ inline?: boolean;
75
+ /**
76
+ * Sets the delay for closing popover on mouse leave
77
+ */
78
+ mouseLeaveDelay?: number;
79
+ /**
80
+ * Do not display the arrow
81
+ */
82
+ noArrow?: boolean;
39
83
  /**
40
84
  * Call back when the component requests to change value
41
85
  * The `open` value is used as a hint when directly controlling the component
42
86
  */
43
87
  onOpenChange?: (e: OpenPopoverEvents, data: OnOpenChangeData) => void;
44
88
  /**
45
- * Flag to open the Popover by hovering the trigger
89
+ * Controls the opening of the Popover
90
+ *
91
+ * @default false
46
92
  */
47
- openOnHover?: boolean;
93
+ open?: boolean;
48
94
  /**
49
95
  * Flag to open the Popover as a context menu. Disables all other interactions
96
+ *
97
+ * @default false
50
98
  */
51
99
  openOnContext?: boolean;
52
100
  /**
53
- * Do not display the arrow
101
+ * Flag to open the Popover by hovering the trigger
102
+ *
103
+ * @default false
54
104
  */
55
- noArrow?: boolean;
105
+ openOnHover?: boolean;
106
+ /**
107
+ * Configures the position of the Popover
108
+ */
109
+ positioning?: PositioningShorthand;
56
110
  /**
57
111
  * Determines popover padding and arrow size
112
+ *
58
113
  * @default medium
59
114
  */
60
115
  size?: PopoverSize;
61
- /**
62
- * A popover can appear styled with brand or inverted.
63
- * When not specified, the default style is used.
64
- */
65
- appearance?: 'brand' | 'inverted';
66
116
  /**
67
117
  * Should trap focus
118
+ *
119
+ * @default false
68
120
  */
69
121
  trapFocus?: boolean;
70
- /**
71
- * Configures the position of the Popover
72
- */
73
- positioning?: PositioningShorthand;
74
- };
75
-
76
- export declare const PopoverContext: Context<PopoverContextValue>;
77
-
78
- /**
79
- * Context shared between Popover and its children components
80
- */
81
- export declare type PopoverContextValue = Pick<PopoverState, 'open' | 'setOpen' | 'triggerRef' | 'contentRef' | 'openOnHover' | 'openOnContext' | 'mountNode' | 'noArrow' | 'arrowRef' | 'size' | 'appearance' | 'trapFocus'>;
82
-
83
- /**
84
- * Popover Props
85
- */
86
- export declare type PopoverProps = Partial<PopoverCommons> & {
87
- /**
88
- * Can contain two children including {@link PopoverTrigger} and {@link PopoverPopover}.
89
- * Alternatively can only contain {@link PopoverPopover} if using a custom `target`.
90
- */
91
- children: [JSX.Element, JSX.Element] | JSX.Element;
92
122
  };
93
123
 
94
124
  /**
@@ -99,32 +129,38 @@ export declare type PopoverSize = 'small' | 'medium' | 'large';
99
129
  /**
100
130
  * Popover State
101
131
  */
102
- export declare type PopoverState = PopoverCommons & Pick<PopoverProps, 'children'> & {
132
+ export declare type PopoverState = Pick<PopoverProps, 'appearance' | 'mountNode' | 'noArrow' | 'onOpenChange' | 'openOnContext' | 'openOnHover' | 'trapFocus'> & Required<Pick<PopoverProps, 'inline' | 'open'>> & Pick<PopoverProps, 'children'> & {
103
133
  /**
104
- * Callback to open/close the Popover
105
- */
106
- setOpen: (e: OpenPopoverEvents, open: boolean) => void;
107
- /**
108
- * Ref of the PopoverTrigger
134
+ * Ref of the pointing arrow
109
135
  */
110
- triggerRef: React_2.MutableRefObject<HTMLElement | null>;
136
+ arrowRef: React_2.MutableRefObject<HTMLDivElement | null>;
111
137
  /**
112
138
  * Ref of the PopoverSurface
113
139
  */
114
140
  contentRef: React_2.MutableRefObject<HTMLElement | null>;
115
- /**
116
- * Ref of the pointing arrow
117
- */
118
- arrowRef: React_2.MutableRefObject<HTMLDivElement | null>;
119
141
  /**
120
142
  * Anchors the popper to the mouse click for context events
121
143
  */
122
144
  contextTarget: PopperVirtualElement | undefined;
145
+ popoverSurface: React_2.ReactElement | undefined;
146
+ popoverTrigger: React_2.ReactElement | undefined;
123
147
  /**
124
148
  * A callback to set the target of the popper to the mouse click for context events
125
149
  */
126
150
  setContextTarget: ReturnType<typeof usePopperMouseTarget>[1];
151
+ /**
152
+ * Callback to open/close the Popover
153
+ */
154
+ setOpen: (e: OpenPopoverEvents, open: boolean) => void;
127
155
  size: NonNullable<PopoverProps['size']>;
156
+ /**
157
+ * Callback to toggle the open state of the Popover
158
+ */
159
+ toggleOpen: (e: OpenPopoverEvents) => void;
160
+ /**
161
+ * Ref of the PopoverTrigger
162
+ */
163
+ triggerRef: React_2.MutableRefObject<HTMLElement | null>;
128
164
  };
129
165
 
130
166
  /**
@@ -132,6 +168,13 @@ export declare type PopoverState = PopoverCommons & Pick<PopoverProps, 'children
132
168
  */
133
169
  export declare const PopoverSurface: ForwardRefComponent<PopoverSurfaceProps>;
134
170
 
171
+ /**
172
+ * @deprecated Use `popoverSurfaceClassNames.root` instead.
173
+ */
174
+ export declare const popoverSurfaceClassName = "fui-PopoverSurface";
175
+
176
+ export declare const popoverSurfaceClassNames: SlotClassNames<PopoverSurfaceSlots>;
177
+
135
178
  /**
136
179
  * PopoverSurface Props
137
180
  */
@@ -141,15 +184,13 @@ export declare type PopoverSurfaceProps = ComponentProps<PopoverSurfaceSlots>;
141
184
  * Names of the slots in PopoverSurfaceProps
142
185
  */
143
186
  export declare type PopoverSurfaceSlots = {
144
- root: IntrinsicShorthandProps<'div'>;
187
+ root: Slot<'div'>;
145
188
  };
146
189
 
147
- export declare const popoverSurfaceSlots: Array<keyof PopoverSurfaceSlots>;
148
-
149
190
  /**
150
191
  * PopoverSurface State
151
192
  */
152
- export declare type PopoverSurfaceState = ComponentState<PopoverSurfaceSlots> & Pick<PopoverContextValue, 'open' | 'mountNode' | 'noArrow' | 'size' | 'appearance' | 'arrowRef'> & {
193
+ export declare type PopoverSurfaceState = ComponentState<PopoverSurfaceSlots> & Pick<PopoverContextValue, 'appearance' | 'arrowRef' | 'inline' | 'mountNode' | 'noArrow' | 'size'> & {
153
194
  /**
154
195
  * CSS class for the arrow element
155
196
  */
@@ -159,71 +200,79 @@ export declare type PopoverSurfaceState = ComponentState<PopoverSurfaceSlots> &
159
200
  /**
160
201
  * Wraps a trigger element as an only child and adds the necessary event handling to open a popover.
161
202
  */
162
- export declare const PopoverTrigger: React_2.FC<PopoverTriggerProps>;
203
+ export declare const PopoverTrigger: React_2.FC<PopoverTriggerProps> & FluentTriggerComponent;
204
+
205
+ export declare type PopoverTriggerChildProps = {
206
+ ref?: React_2.Ref<never>;
207
+ } & Pick<React_2.HTMLAttributes<HTMLElement>, 'aria-haspopup' | 'onClick' | 'onContextMenu' | 'onKeyDown' | 'onMouseEnter' | 'onMouseLeave'>;
163
208
 
164
209
  /**
165
210
  * PopoverTrigger Props
166
211
  */
167
212
  export declare type PopoverTriggerProps = {
168
- children: React_2.ReactElement;
213
+ children: (React_2.ReactElement & {
214
+ ref?: React_2.Ref<unknown>;
215
+ }) | ((props: PopoverTriggerChildProps) => React_2.ReactElement | null);
169
216
  };
170
217
 
171
218
  /**
172
219
  * PopoverTrigger State
173
220
  */
174
- export declare type PopoverTriggerState = PopoverTriggerProps;
221
+ export declare type PopoverTriggerState = {
222
+ children: React_2.ReactElement | null;
223
+ };
175
224
 
176
225
  /**
177
226
  * Render the final JSX of Popover
178
227
  */
179
- export declare const renderPopover: (state: PopoverState) => JSX.Element;
228
+ export declare const renderPopover_unstable: (state: PopoverState) => JSX.Element;
180
229
 
181
230
  /**
182
231
  * Render the final JSX of PopoverSurface
183
232
  */
184
- export declare const renderPopoverSurface: (state: PopoverSurfaceState) => JSX.Element | null;
233
+ export declare const renderPopoverSurface_unstable: (state: PopoverSurfaceState) => JSX.Element;
185
234
 
186
235
  /**
187
236
  * Render the final JSX of PopoverTrigger
188
237
  */
189
- export declare const renderPopoverTrigger: (state: PopoverTriggerState) => JSX.Element;
238
+ export declare const renderPopoverTrigger_unstable: (state: PopoverTriggerState) => ReactElement<any, string | JSXElementConstructor<any>> | null;
190
239
 
191
240
  /**
192
241
  * Create the state required to render Popover.
193
242
  *
194
243
  * The returned state can be modified with hooks such as usePopoverStyles,
195
- * before being passed to renderPopover.
244
+ * before being passed to renderPopover_unstable.
196
245
  *
197
246
  * @param props - props from this instance of Popover
198
247
  */
199
- export declare const usePopover: (props: PopoverProps) => PopoverState;
248
+ export declare const usePopover_unstable: (props: PopoverProps) => PopoverState;
200
249
 
201
- export declare const usePopoverContext: <T>(selector: ContextSelector<Pick<PopoverState, "mountNode" | "open" | "setOpen" | "triggerRef" | "contentRef" | "openOnHover" | "openOnContext" | "noArrow" | "arrowRef" | "size" | "appearance" | "trapFocus">, T>) => T;
250
+ export declare const usePopoverContext_unstable: <T>(selector: ContextSelector<PopoverContextValue, T>) => T;
202
251
 
203
252
  /**
204
253
  * Create the state required to render PopoverSurface.
205
254
  *
206
- * The returned state can be modified with hooks such as usePopoverSurfaceStyles,
207
- * before being passed to renderPopoverSurface.
255
+ * The returned state can be modified with hooks such as usePopoverSurfaceStyles_unstable,
256
+ * before being passed to renderPopoverSurface_unstable.
208
257
  *
209
258
  * @param props - props from this instance of PopoverSurface
210
259
  * @param ref - reference to root HTMLDivElement of PopoverSurface
211
260
  */
212
- export declare const usePopoverSurface: (props: PopoverSurfaceProps, ref: React_2.Ref<HTMLDivElement>) => PopoverSurfaceState;
261
+ export declare const usePopoverSurface_unstable: (props: PopoverSurfaceProps, ref: React_2.Ref<HTMLDivElement>) => PopoverSurfaceState;
213
262
 
214
263
  /**
215
264
  * Apply styling to the PopoverSurface slots based on the state
216
265
  */
217
- export declare const usePopoverSurfaceStyles: (state: PopoverSurfaceState) => PopoverSurfaceState;
266
+ export declare const usePopoverSurfaceStyles_unstable: (state: PopoverSurfaceState) => PopoverSurfaceState;
218
267
 
219
268
  /**
220
269
  * Create the state required to render PopoverTrigger.
221
270
  *
222
271
  * The returned state can be modified with hooks such as usePopoverTriggerStyles,
223
- * before being passed to renderPopoverTrigger.
272
+ * before being passed to renderPopoverTrigger_unstable.
224
273
  *
225
274
  * @param props - props from this instance of PopoverTrigger
226
275
  */
227
- export declare const usePopoverTrigger: (props: PopoverTriggerProps) => PopoverTriggerState;
276
+ export declare const usePopoverTrigger_unstable: (props: PopoverTriggerProps) => PopoverTriggerState;
228
277
 
229
278
  export { }
File without changes
@@ -1 +1 @@
1
- {"version":3,"file":"Popover.js","sourceRoot":"","sources":["../src/Popover.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC"}
1
+ {"version":3,"file":"Popover.js","sourceRoot":"../src/","sources":["Popover.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC","sourcesContent":["export * from './components/Popover/index';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"PopoverSurface.js","sourceRoot":"","sources":["../src/PopoverSurface.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC"}
1
+ {"version":3,"file":"PopoverSurface.js","sourceRoot":"../src/","sources":["PopoverSurface.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC","sourcesContent":["export * from './components/PopoverSurface/index';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"PopoverTrigger.js","sourceRoot":"","sources":["../src/PopoverTrigger.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC"}
1
+ {"version":3,"file":"PopoverTrigger.js","sourceRoot":"../src/","sources":["PopoverTrigger.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC","sourcesContent":["export * from './components/PopoverTrigger/index';\n"]}
@@ -1,12 +1,12 @@
1
- import { usePopover } from './usePopover';
2
- import { renderPopover } from './renderPopover';
1
+ import { usePopover_unstable } from './usePopover';
2
+ import { renderPopover_unstable } from './renderPopover';
3
3
  /**
4
4
  * Wrapper component that manages state for a PopoverTrigger and a PopoverSurface components.
5
5
  */
6
6
 
7
- export var Popover = function (props) {
8
- var state = usePopover(props);
9
- return renderPopover(state);
7
+ export const Popover = props => {
8
+ const state = usePopover_unstable(props);
9
+ return renderPopover_unstable(state);
10
10
  };
11
11
  Popover.displayName = 'Popover';
12
12
  //# sourceMappingURL=Popover.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Popover/Popover.tsx"],"names":[],"mappings":"AACA,SAAS,UAAT,QAA2B,cAA3B;AACA,SAAS,aAAT,QAA8B,iBAA9B;AAGA;;AAEG;;AACH,OAAO,IAAM,OAAO,GAA2B,UAAA,KAAA,EAAK;AAClD,MAAM,KAAK,GAAG,UAAU,CAAC,KAAD,CAAxB;AAEA,SAAO,aAAa,CAAC,KAAD,CAApB;AACD,CAJM;AAMP,OAAO,CAAC,WAAR,GAAsB,SAAtB","sourceRoot":""}
1
+ {"version":3,"sources":["components/Popover/Popover.tsx"],"names":[],"mappings":"AACA,SAAS,mBAAT,QAAoC,cAApC;AACA,SAAS,sBAAT,QAAuC,iBAAvC;AAGA;;AAEG;;AACH,OAAO,MAAM,OAAO,GAA2B,KAAK,IAAG;AACrD,QAAM,KAAK,GAAG,mBAAmB,CAAC,KAAD,CAAjC;AAEA,SAAO,sBAAsB,CAAC,KAAD,CAA7B;AACD,CAJM;AAMP,OAAO,CAAC,WAAR,GAAsB,SAAtB","sourcesContent":["import * as React from 'react';\nimport { usePopover_unstable } from './usePopover';\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\n return renderPopover_unstable(state);\n};\n\nPopover.displayName = 'Popover';\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"file":"Popover.types.js","sourceRoot":"","sources":["../../../src/components/Popover/Popover.types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"Popover.types.js","sourceRoot":"../src/","sources":["components/Popover/Popover.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport type { PortalProps } from '@fluentui/react-portal';\nimport type { PopperVirtualElement, PositioningShorthand, usePopperMouseTarget } from '@fluentui/react-positioning';\n\n/**\n * Determines popover padding and arrow size\n */\nexport type PopoverSize = 'small' | 'medium' | 'large';\n\n/**\n * Popover Props\n */\nexport type PopoverProps = Pick<PortalProps, 'mountNode'> & {\n /**\n * A popover can appear styled with brand or inverted.\n * When not specified, the default style is used.\n */\n appearance?: 'brand' | 'inverted';\n\n /**\n * Can contain two children including {@link PopoverTrigger} and {@link PopoverSurface}.\n * Alternatively can only contain {@link PopoverSurface} if using a custom `target`.\n */\n children: [JSX.Element, JSX.Element] | JSX.Element;\n\n /**\n * Close when scroll outside of it\n *\n * @default false\n */\n closeOnScroll?: boolean;\n\n /**\n * Used to set the initial open state of the Popover in uncontrolled mode\n *\n * @default false\n */\n defaultOpen?: boolean;\n\n /**\n * Popovers are rendered out of DOM order on `document.body` by default, use this to render the popover in DOM order\n *\n * @default false\n */\n inline?: boolean;\n\n /**\n * Sets the delay for closing popover on mouse leave\n */\n mouseLeaveDelay?: number;\n\n /**\n * Do not display the arrow\n */\n noArrow?: boolean;\n\n /**\n * Call back when the component requests to change value\n * The `open` value is used as a hint when directly controlling the component\n */\n onOpenChange?: (e: OpenPopoverEvents, data: OnOpenChangeData) => void;\n\n /**\n * Controls the opening of the Popover\n *\n * @default false\n */\n open?: boolean;\n\n /**\n * Flag to open the Popover as a context menu. Disables all other interactions\n *\n * @default false\n */\n openOnContext?: boolean;\n\n /**\n * Flag to open the Popover by hovering the trigger\n *\n * @default false\n */\n openOnHover?: boolean;\n\n /**\n * Configures the position of the Popover\n */\n positioning?: PositioningShorthand;\n\n /**\n * Determines popover padding and arrow size\n *\n * @default medium\n */\n size?: PopoverSize;\n\n /**\n * Should trap focus\n *\n * @default false\n */\n trapFocus?: boolean;\n};\n\n/**\n * Popover State\n */\nexport type PopoverState = Pick<\n PopoverProps,\n 'appearance' | 'mountNode' | 'noArrow' | 'onOpenChange' | 'openOnContext' | 'openOnHover' | 'trapFocus'\n> &\n Required<Pick<PopoverProps, 'inline' | 'open'>> &\n Pick<PopoverProps, 'children'> & {\n /**\n * Ref of the pointing arrow\n */\n arrowRef: React.MutableRefObject<HTMLDivElement | null>;\n\n /**\n * Ref of the PopoverSurface\n */\n contentRef: React.MutableRefObject<HTMLElement | null>;\n\n /**\n * Anchors the popper to the mouse click for context events\n */\n contextTarget: PopperVirtualElement | undefined;\n\n popoverSurface: React.ReactElement | undefined;\n\n popoverTrigger: React.ReactElement | undefined;\n\n /**\n * A callback to set the target of the popper to the mouse click for context events\n */\n setContextTarget: ReturnType<typeof usePopperMouseTarget>[1];\n\n /**\n * Callback to open/close the Popover\n */\n setOpen: (e: OpenPopoverEvents, open: boolean) => void;\n\n size: NonNullable<PopoverProps['size']>;\n\n /**\n * Callback to toggle the open state of the Popover\n */\n toggleOpen: (e: OpenPopoverEvents) => void;\n\n /**\n * Ref of the PopoverTrigger\n */\n triggerRef: React.MutableRefObject<HTMLElement | null>;\n };\n\n/**\n * Data attached to open/close events\n */\nexport type OnOpenChangeData = { open: boolean };\n\n/**\n * The supported events that will trigger open/close of the menu\n */\nexport type OpenPopoverEvents =\n | MouseEvent\n | TouchEvent\n | React.FocusEvent<HTMLElement>\n | React.KeyboardEvent<HTMLElement>\n | React.MouseEvent<HTMLElement>;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Popover/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/Popover/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC","sourcesContent":["export * from './Popover';\nexport * from './Popover.types';\nexport * from './renderPopover';\nexport * from './usePopover';\n"]}
@@ -4,34 +4,38 @@ import { PopoverContext } from '../../popoverContext';
4
4
  * Render the final JSX of Popover
5
5
  */
6
6
 
7
- export var renderPopover = function (state) {
8
- var open = state.open,
9
- setOpen = state.setOpen,
10
- triggerRef = state.triggerRef,
11
- contentRef = state.contentRef,
12
- openOnContext = state.openOnContext,
13
- openOnHover = state.openOnHover,
14
- mountNode = state.mountNode,
15
- arrowRef = state.arrowRef,
16
- size = state.size,
17
- noArrow = state.noArrow,
18
- appearance = state.appearance,
19
- trapFocus = state.trapFocus;
7
+ export const renderPopover_unstable = state => {
8
+ const {
9
+ appearance,
10
+ arrowRef,
11
+ contentRef,
12
+ inline,
13
+ mountNode,
14
+ noArrow,
15
+ openOnContext,
16
+ openOnHover,
17
+ setOpen,
18
+ size,
19
+ toggleOpen,
20
+ trapFocus,
21
+ triggerRef
22
+ } = state;
20
23
  return /*#__PURE__*/React.createElement(PopoverContext.Provider, {
21
24
  value: {
22
- open: open,
23
- setOpen: setOpen,
24
- triggerRef: triggerRef,
25
- contentRef: contentRef,
26
- openOnHover: openOnHover,
27
- openOnContext: openOnContext,
28
- mountNode: mountNode,
29
- arrowRef: arrowRef,
30
- size: size,
31
- noArrow: noArrow,
32
- appearance: appearance,
33
- trapFocus: trapFocus
25
+ appearance,
26
+ arrowRef,
27
+ contentRef,
28
+ inline,
29
+ mountNode,
30
+ noArrow,
31
+ openOnContext,
32
+ openOnHover,
33
+ setOpen,
34
+ toggleOpen,
35
+ triggerRef,
36
+ size,
37
+ trapFocus
34
38
  }
35
- }, state.children);
39
+ }, state.popoverTrigger, state.open && state.popoverSurface);
36
40
  };
37
41
  //# sourceMappingURL=renderPopover.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Popover/renderPopover.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,cAAT,QAA+B,sBAA/B;AAGA;;AAEG;;AACH,OAAO,IAAM,aAAa,GAAG,UAAC,KAAD,EAAoB;AAE7C,MAAA,IAAI,GAYF,KAAK,CAZH,IAAJ;AAAA,MACA,OAAO,GAWL,KAAK,CAXA,OADP;AAAA,MAEA,UAAU,GAUR,KAAK,CAVG,UAFV;AAAA,MAGA,UAAU,GASR,KAAK,CATG,UAHV;AAAA,MAIA,aAAa,GAQX,KAAK,CARM,aAJb;AAAA,MAKA,WAAW,GAOT,KAAK,CAPI,WALX;AAAA,MAMA,SAAS,GAMP,KAAK,CANE,SANT;AAAA,MAOA,QAAQ,GAKN,KAAK,CALC,QAPR;AAAA,MAQA,IAAI,GAIF,KAAK,CAJH,IARJ;AAAA,MASA,OAAO,GAGL,KAAK,CAHA,OATP;AAAA,MAUA,UAAU,GAER,KAAK,CAFG,UAVV;AAAA,MAWA,SAAS,GACP,KAAK,CADE,SAXT;AAcF,sBACE,KAAA,CAAA,aAAA,CAAC,cAAc,CAAC,QAAhB,EAAwB;AACtB,IAAA,KAAK,EAAE;AACL,MAAA,IAAI,EAAA,IADC;AAEL,MAAA,OAAO,EAAA,OAFF;AAGL,MAAA,UAAU,EAAA,UAHL;AAIL,MAAA,UAAU,EAAA,UAJL;AAKL,MAAA,WAAW,EAAA,WALN;AAML,MAAA,aAAa,EAAA,aANR;AAOL,MAAA,SAAS,EAAA,SAPJ;AAQL,MAAA,QAAQ,EAAA,QARH;AASL,MAAA,IAAI,EAAA,IATC;AAUL,MAAA,OAAO,EAAA,OAVF;AAWL,MAAA,UAAU,EAAA,UAXL;AAYL,MAAA,SAAS,EAAA;AAZJ;AADe,GAAxB,EAgBG,KAAK,CAAC,QAhBT,CADF;AAoBD,CApCM","sourceRoot":""}
1
+ {"version":3,"sources":["components/Popover/renderPopover.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,cAAT,QAA+B,sBAA/B;AAGA;;AAEG;;AACH,OAAO,MAAM,sBAAsB,GAAI,KAAD,IAAwB;AAC5D,QAAM;AACJ,IAAA,UADI;AAEJ,IAAA,QAFI;AAGJ,IAAA,UAHI;AAIJ,IAAA,MAJI;AAKJ,IAAA,SALI;AAMJ,IAAA,OANI;AAOJ,IAAA,aAPI;AAQJ,IAAA,WARI;AASJ,IAAA,OATI;AAUJ,IAAA,IAVI;AAWJ,IAAA,UAXI;AAYJ,IAAA,SAZI;AAaJ,IAAA;AAbI,MAcF,KAdJ;AAgBA,sBACE,KAAA,CAAA,aAAA,CAAC,cAAc,CAAC,QAAhB,EAAwB;AACtB,IAAA,KAAK,EAAE;AACL,MAAA,UADK;AAEL,MAAA,QAFK;AAGL,MAAA,UAHK;AAIL,MAAA,MAJK;AAKL,MAAA,SALK;AAML,MAAA,OANK;AAOL,MAAA,aAPK;AAQL,MAAA,WARK;AASL,MAAA,OATK;AAUL,MAAA,UAVK;AAWL,MAAA,UAXK;AAYL,MAAA,IAZK;AAaL,MAAA;AAbK;AADe,GAAxB,EAiBG,KAAK,CAAC,cAjBT,EAkBG,KAAK,CAAC,IAAN,IAAc,KAAK,CAAC,cAlBvB,CADF;AAsBD,CAvCM","sourcesContent":["import * as React from 'react';\nimport { PopoverContext } from '../../popoverContext';\nimport type { PopoverState } from './Popover.types';\n\n/**\n * Render the final JSX of Popover\n */\nexport const renderPopover_unstable = (state: PopoverState) => {\n const {\n appearance,\n arrowRef,\n contentRef,\n inline,\n mountNode,\n noArrow,\n openOnContext,\n openOnHover,\n setOpen,\n size,\n toggleOpen,\n trapFocus,\n triggerRef,\n } = state;\n\n return (\n <PopoverContext.Provider\n value={{\n appearance,\n arrowRef,\n contentRef,\n inline,\n mountNode,\n noArrow,\n openOnContext,\n openOnHover,\n setOpen,\n toggleOpen,\n triggerRef,\n size,\n trapFocus,\n }}\n >\n {state.popoverTrigger}\n {state.open && state.popoverSurface}\n </PopoverContext.Provider>\n );\n};\n"],"sourceRoot":"../src/"}