@fluentui/react-popover 9.0.0-rc.1 → 9.0.0-rc.12
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.
- package/CHANGELOG.json +595 -1
- package/CHANGELOG.md +229 -71
- package/Spec.md +20 -0
- package/dist/{react-popover.d.ts → index.d.ts} +89 -54
- package/{lib → dist}/tsdoc-metadata.json +0 -0
- package/lib/Popover.js.map +1 -1
- package/lib/PopoverSurface.js.map +1 -1
- package/lib/PopoverTrigger.js.map +1 -1
- package/lib/components/Popover/Popover.js.map +1 -1
- package/lib/components/Popover/Popover.types.js.map +1 -1
- package/lib/components/Popover/index.js.map +1 -1
- package/lib/components/Popover/renderPopover.js +20 -18
- package/lib/components/Popover/renderPopover.js.map +1 -1
- package/lib/components/Popover/usePopover.js +90 -17
- package/lib/components/Popover/usePopover.js.map +1 -1
- package/lib/components/PopoverSurface/PopoverSurface.js.map +1 -1
- package/lib/components/PopoverSurface/PopoverSurface.types.js.map +1 -1
- package/lib/components/PopoverSurface/index.js.map +1 -1
- package/lib/components/PopoverSurface/renderPopoverSurface.js +9 -8
- package/lib/components/PopoverSurface/renderPopoverSurface.js.map +1 -1
- package/lib/components/PopoverSurface/usePopoverSurface.js +5 -15
- package/lib/components/PopoverSurface/usePopoverSurface.js.map +1 -1
- package/lib/components/PopoverSurface/usePopoverSurfaceStyles.js +4 -2
- package/lib/components/PopoverSurface/usePopoverSurfaceStyles.js.map +1 -1
- package/lib/components/PopoverTrigger/PopoverTrigger.js.map +1 -1
- package/lib/components/PopoverTrigger/PopoverTrigger.types.js.map +1 -1
- package/lib/components/PopoverTrigger/index.js.map +1 -1
- package/lib/components/PopoverTrigger/renderPopoverTrigger.js.map +1 -1
- package/lib/components/PopoverTrigger/usePopoverTrigger.js +2 -2
- package/lib/components/PopoverTrigger/usePopoverTrigger.js.map +1 -1
- package/lib/index.js +4 -4
- package/lib/index.js.map +1 -1
- package/lib/popoverContext.js +4 -2
- package/lib/popoverContext.js.map +1 -1
- package/lib-commonjs/Popover.js.map +1 -1
- package/lib-commonjs/PopoverSurface.js.map +1 -1
- package/lib-commonjs/PopoverTrigger.js.map +1 -1
- package/lib-commonjs/components/Popover/Popover.js.map +1 -1
- package/lib-commonjs/components/Popover/Popover.types.js.map +1 -1
- package/lib-commonjs/components/Popover/index.js.map +1 -1
- package/lib-commonjs/components/Popover/renderPopover.js +20 -18
- package/lib-commonjs/components/Popover/renderPopover.js.map +1 -1
- package/lib-commonjs/components/Popover/usePopover.js +90 -16
- package/lib-commonjs/components/Popover/usePopover.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/PopoverSurface.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/PopoverSurface.types.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/index.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.js +9 -8
- package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/usePopoverSurface.js +4 -15
- package/lib-commonjs/components/PopoverSurface/usePopoverSurface.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.js +5 -3
- package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.js.map +1 -1
- package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.js.map +1 -1
- package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.types.js.map +1 -1
- package/lib-commonjs/components/PopoverTrigger/index.js.map +1 -1
- package/lib-commonjs/components/PopoverTrigger/renderPopoverTrigger.js.map +1 -1
- package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.js +2 -2
- package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.js.map +1 -1
- package/lib-commonjs/index.js +92 -5
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/popoverContext.js +5 -3
- package/lib-commonjs/popoverContext.js.map +1 -1
- package/package.json +21 -23
- package/lib/Popover.d.ts +0 -1
- package/lib/PopoverSurface.d.ts +0 -1
- package/lib/PopoverTrigger.d.ts +0 -1
- package/lib/components/Popover/Popover.d.ts +0 -6
- package/lib/components/Popover/Popover.types.d.ts +0 -103
- package/lib/components/Popover/index.d.ts +0 -4
- package/lib/components/Popover/renderPopover.d.ts +0 -5
- package/lib/components/Popover/usePopover.d.ts +0 -10
- package/lib/components/PopoverSurface/PopoverSurface.d.ts +0 -6
- package/lib/components/PopoverSurface/PopoverSurface.types.d.ts +0 -21
- package/lib/components/PopoverSurface/index.d.ts +0 -5
- package/lib/components/PopoverSurface/renderPopoverSurface.d.ts +0 -5
- package/lib/components/PopoverSurface/usePopoverSurface.d.ts +0 -12
- package/lib/components/PopoverSurface/usePopoverSurfaceStyles.d.ts +0 -8
- package/lib/components/PopoverTrigger/PopoverTrigger.d.ts +0 -7
- package/lib/components/PopoverTrigger/PopoverTrigger.types.d.ts +0 -18
- package/lib/components/PopoverTrigger/index.d.ts +0 -4
- package/lib/components/PopoverTrigger/renderPopoverTrigger.d.ts +0 -5
- package/lib/components/PopoverTrigger/usePopoverTrigger.d.ts +0 -10
- package/lib/index.d.ts +0 -4
- package/lib/popoverContext.d.ts +0 -8
- package/lib-commonjs/Popover.d.ts +0 -1
- package/lib-commonjs/PopoverSurface.d.ts +0 -1
- package/lib-commonjs/PopoverTrigger.d.ts +0 -1
- package/lib-commonjs/components/Popover/Popover.d.ts +0 -6
- package/lib-commonjs/components/Popover/Popover.types.d.ts +0 -103
- package/lib-commonjs/components/Popover/index.d.ts +0 -4
- package/lib-commonjs/components/Popover/renderPopover.d.ts +0 -5
- package/lib-commonjs/components/Popover/usePopover.d.ts +0 -10
- package/lib-commonjs/components/PopoverSurface/PopoverSurface.d.ts +0 -6
- package/lib-commonjs/components/PopoverSurface/PopoverSurface.types.d.ts +0 -21
- package/lib-commonjs/components/PopoverSurface/index.d.ts +0 -5
- package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.d.ts +0 -5
- package/lib-commonjs/components/PopoverSurface/usePopoverSurface.d.ts +0 -12
- package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.d.ts +0 -8
- package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.d.ts +0 -7
- package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.types.d.ts +0 -18
- package/lib-commonjs/components/PopoverTrigger/index.d.ts +0 -4
- package/lib-commonjs/components/PopoverTrigger/renderPopoverTrigger.d.ts +0 -5
- package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.d.ts +0 -10
- package/lib-commonjs/index.d.ts +0 -4
- 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.
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import type { ComponentProps } from '@fluentui/react-utilities';
|
|
2
2
|
import type { ComponentState } from '@fluentui/react-utilities';
|
|
3
|
-
import type { Context } from '@fluentui/react-context-selector';
|
|
4
3
|
import type { ContextSelector } from '@fluentui/react-context-selector';
|
|
4
|
+
import { FC } from 'react';
|
|
5
5
|
import type { FluentTriggerComponent } from '@fluentui/react-utilities';
|
|
6
6
|
import type { ForwardRefComponent } from '@fluentui/react-utilities';
|
|
7
7
|
import { JSXElementConstructor } from 'react';
|
|
8
|
-
import type { PopperVirtualElement } from '@fluentui/react-positioning';
|
|
9
8
|
import type { PortalProps } from '@fluentui/react-portal';
|
|
10
9
|
import type { PositioningShorthand } from '@fluentui/react-positioning';
|
|
10
|
+
import type { PositioningVirtualElement } from '@fluentui/react-positioning';
|
|
11
|
+
import { Provider } from 'react';
|
|
12
|
+
import { ProviderProps } from 'react';
|
|
11
13
|
import * as React_2 from 'react';
|
|
12
14
|
import { ReactElement } from 'react';
|
|
13
15
|
import type { Slot } from '@fluentui/react-utilities';
|
|
14
|
-
import type {
|
|
16
|
+
import type { SlotClassNames } from '@fluentui/react-utilities';
|
|
17
|
+
import type { usePositioningMouseTarget } from '@fluentui/react-positioning';
|
|
15
18
|
|
|
16
19
|
export declare const arrowHeights: Record<PopoverSize, number>;
|
|
17
20
|
|
|
@@ -25,76 +28,102 @@ export declare type OnOpenChangeData = {
|
|
|
25
28
|
/**
|
|
26
29
|
* The supported events that will trigger open/close of the menu
|
|
27
30
|
*/
|
|
28
|
-
export declare type OpenPopoverEvents = MouseEvent | TouchEvent | React_2.
|
|
31
|
+
export declare type OpenPopoverEvents = MouseEvent | TouchEvent | React_2.FocusEvent<HTMLElement> | React_2.KeyboardEvent<HTMLElement> | React_2.MouseEvent<HTMLElement>;
|
|
29
32
|
|
|
30
33
|
/**
|
|
31
34
|
* Wrapper component that manages state for a PopoverTrigger and a PopoverSurface components.
|
|
32
35
|
*/
|
|
33
36
|
export declare const Popover: React_2.FC<PopoverProps>;
|
|
34
37
|
|
|
35
|
-
|
|
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' | 'withArrow' | 'arrowRef' | 'size' | 'appearance' | 'trapFocus' | 'inline'>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Popover Props
|
|
45
|
+
*/
|
|
46
|
+
export declare type PopoverProps = Pick<PortalProps, 'mountNode'> & {
|
|
36
47
|
/**
|
|
37
|
-
*
|
|
48
|
+
* A popover can appear styled with brand or inverted.
|
|
49
|
+
* When not specified, the default style is used.
|
|
38
50
|
*/
|
|
39
|
-
|
|
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;
|
|
40
63
|
/**
|
|
41
64
|
* Used to set the initial open state of the Popover in uncontrolled mode
|
|
65
|
+
*
|
|
66
|
+
* @default false
|
|
42
67
|
*/
|
|
43
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
|
+
* Display an arrow pointing to the target.
|
|
81
|
+
*
|
|
82
|
+
* @default false
|
|
83
|
+
*/
|
|
84
|
+
withArrow?: boolean;
|
|
44
85
|
/**
|
|
45
86
|
* Call back when the component requests to change value
|
|
46
87
|
* The `open` value is used as a hint when directly controlling the component
|
|
47
88
|
*/
|
|
48
89
|
onOpenChange?: (e: OpenPopoverEvents, data: OnOpenChangeData) => void;
|
|
49
90
|
/**
|
|
50
|
-
*
|
|
91
|
+
* Controls the opening of the Popover
|
|
92
|
+
*
|
|
93
|
+
* @default false
|
|
51
94
|
*/
|
|
52
|
-
|
|
95
|
+
open?: boolean;
|
|
53
96
|
/**
|
|
54
97
|
* Flag to open the Popover as a context menu. Disables all other interactions
|
|
98
|
+
*
|
|
99
|
+
* @default false
|
|
55
100
|
*/
|
|
56
101
|
openOnContext?: boolean;
|
|
57
102
|
/**
|
|
58
|
-
*
|
|
103
|
+
* Flag to open the Popover by hovering the trigger
|
|
104
|
+
*
|
|
105
|
+
* @default false
|
|
106
|
+
*/
|
|
107
|
+
openOnHover?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Configures the position of the Popover
|
|
59
110
|
*/
|
|
60
|
-
|
|
111
|
+
positioning?: PositioningShorthand;
|
|
61
112
|
/**
|
|
62
113
|
* Determines popover padding and arrow size
|
|
114
|
+
*
|
|
63
115
|
* @default medium
|
|
64
116
|
*/
|
|
65
117
|
size?: PopoverSize;
|
|
66
|
-
/**
|
|
67
|
-
* A popover can appear styled with brand or inverted.
|
|
68
|
-
* When not specified, the default style is used.
|
|
69
|
-
*/
|
|
70
|
-
appearance?: 'brand' | 'inverted';
|
|
71
118
|
/**
|
|
72
119
|
* Should trap focus
|
|
120
|
+
*
|
|
121
|
+
* @default false
|
|
73
122
|
*/
|
|
74
123
|
trapFocus?: boolean;
|
|
75
|
-
/**
|
|
76
|
-
* Configures the position of the Popover
|
|
77
|
-
*/
|
|
78
|
-
positioning?: PositioningShorthand;
|
|
79
124
|
};
|
|
80
125
|
|
|
81
|
-
export declare const
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Context shared between Popover and its children components
|
|
85
|
-
*/
|
|
86
|
-
export declare type PopoverContextValue = Pick<PopoverState, 'open' | 'setOpen' | 'triggerRef' | 'contentRef' | 'openOnHover' | 'openOnContext' | 'mountNode' | 'noArrow' | 'arrowRef' | 'size' | 'appearance' | 'trapFocus'>;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Popover Props
|
|
90
|
-
*/
|
|
91
|
-
export declare type PopoverProps = Partial<PopoverCommons> & {
|
|
92
|
-
/**
|
|
93
|
-
* Can contain two children including {@link PopoverTrigger} and {@link PopoverSurface}.
|
|
94
|
-
* Alternatively can only contain {@link PopoverSurface} if using a custom `target`.
|
|
95
|
-
*/
|
|
96
|
-
children: [JSX.Element, JSX.Element] | JSX.Element;
|
|
97
|
-
};
|
|
126
|
+
export declare const PopoverProvider: Provider<PopoverContextValue> & FC<ProviderProps<PopoverContextValue>>;
|
|
98
127
|
|
|
99
128
|
/**
|
|
100
129
|
* Determines popover padding and arrow size
|
|
@@ -104,32 +133,38 @@ export declare type PopoverSize = 'small' | 'medium' | 'large';
|
|
|
104
133
|
/**
|
|
105
134
|
* Popover State
|
|
106
135
|
*/
|
|
107
|
-
export declare type PopoverState =
|
|
136
|
+
export declare type PopoverState = Pick<PopoverProps, 'appearance' | 'mountNode' | 'onOpenChange' | 'openOnContext' | 'openOnHover' | 'trapFocus' | 'withArrow'> & Required<Pick<PopoverProps, 'inline' | 'open'>> & Pick<PopoverProps, 'children'> & {
|
|
108
137
|
/**
|
|
109
|
-
*
|
|
110
|
-
*/
|
|
111
|
-
setOpen: (e: OpenPopoverEvents, open: boolean) => void;
|
|
112
|
-
/**
|
|
113
|
-
* Ref of the PopoverTrigger
|
|
138
|
+
* Ref of the pointing arrow
|
|
114
139
|
*/
|
|
115
|
-
|
|
140
|
+
arrowRef: React_2.MutableRefObject<HTMLDivElement | null>;
|
|
116
141
|
/**
|
|
117
142
|
* Ref of the PopoverSurface
|
|
118
143
|
*/
|
|
119
144
|
contentRef: React_2.MutableRefObject<HTMLElement | null>;
|
|
120
|
-
/**
|
|
121
|
-
* Ref of the pointing arrow
|
|
122
|
-
*/
|
|
123
|
-
arrowRef: React_2.MutableRefObject<HTMLDivElement | null>;
|
|
124
145
|
/**
|
|
125
146
|
* Anchors the popper to the mouse click for context events
|
|
126
147
|
*/
|
|
127
|
-
contextTarget:
|
|
148
|
+
contextTarget: PositioningVirtualElement | undefined;
|
|
149
|
+
popoverSurface: React_2.ReactElement | undefined;
|
|
150
|
+
popoverTrigger: React_2.ReactElement | undefined;
|
|
128
151
|
/**
|
|
129
152
|
* A callback to set the target of the popper to the mouse click for context events
|
|
130
153
|
*/
|
|
131
|
-
setContextTarget: ReturnType<typeof
|
|
154
|
+
setContextTarget: ReturnType<typeof usePositioningMouseTarget>[1];
|
|
155
|
+
/**
|
|
156
|
+
* Callback to open/close the Popover
|
|
157
|
+
*/
|
|
158
|
+
setOpen: (e: OpenPopoverEvents, open: boolean) => void;
|
|
132
159
|
size: NonNullable<PopoverProps['size']>;
|
|
160
|
+
/**
|
|
161
|
+
* Callback to toggle the open state of the Popover
|
|
162
|
+
*/
|
|
163
|
+
toggleOpen: (e: OpenPopoverEvents) => void;
|
|
164
|
+
/**
|
|
165
|
+
* Ref of the PopoverTrigger
|
|
166
|
+
*/
|
|
167
|
+
triggerRef: React_2.MutableRefObject<HTMLElement | null>;
|
|
133
168
|
};
|
|
134
169
|
|
|
135
170
|
/**
|
|
@@ -137,7 +172,7 @@ export declare type PopoverState = PopoverCommons & Pick<PopoverProps, 'children
|
|
|
137
172
|
*/
|
|
138
173
|
export declare const PopoverSurface: ForwardRefComponent<PopoverSurfaceProps>;
|
|
139
174
|
|
|
140
|
-
export declare const
|
|
175
|
+
export declare const popoverSurfaceClassNames: SlotClassNames<PopoverSurfaceSlots>;
|
|
141
176
|
|
|
142
177
|
/**
|
|
143
178
|
* PopoverSurface Props
|
|
@@ -154,7 +189,7 @@ export declare type PopoverSurfaceSlots = {
|
|
|
154
189
|
/**
|
|
155
190
|
* PopoverSurface State
|
|
156
191
|
*/
|
|
157
|
-
export declare type PopoverSurfaceState = ComponentState<PopoverSurfaceSlots> & Pick<PopoverContextValue, '
|
|
192
|
+
export declare type PopoverSurfaceState = ComponentState<PopoverSurfaceSlots> & Pick<PopoverContextValue, 'appearance' | 'arrowRef' | 'inline' | 'mountNode' | 'size' | 'withArrow'> & {
|
|
158
193
|
/**
|
|
159
194
|
* CSS class for the arrow element
|
|
160
195
|
*/
|
|
@@ -168,7 +203,7 @@ export declare const PopoverTrigger: React_2.FC<PopoverTriggerProps> & FluentTri
|
|
|
168
203
|
|
|
169
204
|
export declare type PopoverTriggerChildProps = {
|
|
170
205
|
ref?: React_2.Ref<never>;
|
|
171
|
-
} & Pick<React_2.HTMLAttributes<HTMLElement>, 'aria-haspopup' | 'onClick' | '
|
|
206
|
+
} & Pick<React_2.HTMLAttributes<HTMLElement>, 'aria-haspopup' | 'onClick' | 'onContextMenu' | 'onKeyDown' | 'onMouseEnter' | 'onMouseLeave'>;
|
|
172
207
|
|
|
173
208
|
/**
|
|
174
209
|
* PopoverTrigger Props
|
|
@@ -194,7 +229,7 @@ export declare const renderPopover_unstable: (state: PopoverState) => JSX.Elemen
|
|
|
194
229
|
/**
|
|
195
230
|
* Render the final JSX of PopoverSurface
|
|
196
231
|
*/
|
|
197
|
-
export declare const renderPopoverSurface_unstable: (state: PopoverSurfaceState) => JSX.Element
|
|
232
|
+
export declare const renderPopoverSurface_unstable: (state: PopoverSurfaceState) => JSX.Element;
|
|
198
233
|
|
|
199
234
|
/**
|
|
200
235
|
* Render the final JSX of PopoverTrigger
|
|
File without changes
|
package/lib/Popover.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.js","sourceRoot":"","sources":["
|
|
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":["
|
|
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":["
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
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":["
|
|
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 {\n PositioningVirtualElement,\n PositioningShorthand,\n usePositioningMouseTarget,\n} from '@fluentui/react-positioning';\nimport type { PortalProps } from '@fluentui/react-portal';\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 * Display an arrow pointing to the target.\n *\n * @default false\n */\n withArrow?: 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' | 'onOpenChange' | 'openOnContext' | 'openOnHover' | 'trapFocus' | 'withArrow'\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: PositioningVirtualElement | 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 usePositioningMouseTarget>[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":["
|
|
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"]}
|
|
@@ -6,34 +6,36 @@ import { PopoverContext } from '../../popoverContext';
|
|
|
6
6
|
|
|
7
7
|
export const renderPopover_unstable = state => {
|
|
8
8
|
const {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
triggerRef,
|
|
9
|
+
appearance,
|
|
10
|
+
arrowRef,
|
|
12
11
|
contentRef,
|
|
12
|
+
inline,
|
|
13
|
+
mountNode,
|
|
13
14
|
openOnContext,
|
|
14
15
|
openOnHover,
|
|
15
|
-
|
|
16
|
-
arrowRef,
|
|
16
|
+
setOpen,
|
|
17
17
|
size,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
toggleOpen,
|
|
19
|
+
trapFocus,
|
|
20
|
+
triggerRef,
|
|
21
|
+
withArrow
|
|
21
22
|
} = state;
|
|
22
23
|
return /*#__PURE__*/React.createElement(PopoverContext.Provider, {
|
|
23
24
|
value: {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
triggerRef,
|
|
25
|
+
appearance,
|
|
26
|
+
arrowRef,
|
|
27
27
|
contentRef,
|
|
28
|
-
|
|
29
|
-
openOnContext,
|
|
28
|
+
inline,
|
|
30
29
|
mountNode,
|
|
31
|
-
|
|
30
|
+
openOnContext,
|
|
31
|
+
openOnHover,
|
|
32
|
+
setOpen,
|
|
33
|
+
toggleOpen,
|
|
34
|
+
triggerRef,
|
|
32
35
|
size,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
trapFocus
|
|
36
|
+
trapFocus,
|
|
37
|
+
withArrow
|
|
36
38
|
}
|
|
37
|
-
}, state.
|
|
39
|
+
}, state.popoverTrigger, state.open && state.popoverSurface);
|
|
38
40
|
};
|
|
39
41
|
//# sourceMappingURL=renderPopover.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
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,aANI;AAOJ,IAAA,WAPI;AAQJ,IAAA,OARI;AASJ,IAAA,IATI;AAUJ,IAAA,UAVI;AAWJ,IAAA,SAXI;AAYJ,IAAA,UAZI;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,aANK;AAOL,MAAA,WAPK;AAQL,MAAA,OARK;AASL,MAAA,UATK;AAUL,MAAA,UAVK;AAWL,MAAA,IAXK;AAYL,MAAA,SAZK;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 openOnContext,\n openOnHover,\n setOpen,\n size,\n toggleOpen,\n trapFocus,\n triggerRef,\n withArrow,\n } = state;\n\n return (\n <PopoverContext.Provider\n value={{\n appearance,\n arrowRef,\n contentRef,\n inline,\n mountNode,\n openOnContext,\n openOnHover,\n setOpen,\n toggleOpen,\n triggerRef,\n size,\n trapFocus,\n withArrow,\n }}\n >\n {state.popoverTrigger}\n {state.open && state.popoverSurface}\n </PopoverContext.Provider>\n );\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useControllableState, useEventCallback, useOnClickOutside, useOnScrollOutside } from '@fluentui/react-utilities';
|
|
3
3
|
import { useFluent } from '@fluentui/react-shared-contexts';
|
|
4
|
-
import {
|
|
4
|
+
import { usePositioning, resolvePositioningShorthand, mergeArrowOffset, usePositioningMouseTarget } from '@fluentui/react-positioning';
|
|
5
5
|
import { elementContains } from '@fluentui/react-portal';
|
|
6
|
+
import { useFocusFinders } from '@fluentui/react-tabster';
|
|
6
7
|
import { arrowHeights } from '../PopoverSurface/index';
|
|
7
8
|
/**
|
|
8
9
|
* Create the state required to render Popover.
|
|
@@ -14,15 +15,73 @@ import { arrowHeights } from '../PopoverSurface/index';
|
|
|
14
15
|
*/
|
|
15
16
|
|
|
16
17
|
export const usePopover_unstable = props => {
|
|
17
|
-
|
|
18
|
+
var _a;
|
|
19
|
+
|
|
20
|
+
const [contextTarget, setContextTarget] = usePositioningMouseTarget();
|
|
18
21
|
const initialState = {
|
|
19
22
|
size: 'medium',
|
|
20
23
|
contextTarget,
|
|
21
24
|
setContextTarget,
|
|
22
25
|
...props
|
|
23
26
|
};
|
|
24
|
-
const
|
|
25
|
-
|
|
27
|
+
const children = React.Children.toArray(props.children);
|
|
28
|
+
|
|
29
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
30
|
+
if (children.length === 0) {
|
|
31
|
+
// eslint-disable-next-line no-console
|
|
32
|
+
console.warn('Popover must contain at least one child');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (children.length > 2) {
|
|
36
|
+
// eslint-disable-next-line no-console
|
|
37
|
+
console.warn('Popover must contain at most two children');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let popoverTrigger = undefined;
|
|
42
|
+
let popoverSurface = undefined;
|
|
43
|
+
|
|
44
|
+
if (children.length === 2) {
|
|
45
|
+
popoverTrigger = children[0];
|
|
46
|
+
popoverSurface = children[1];
|
|
47
|
+
} else if (children.length === 1) {
|
|
48
|
+
popoverSurface = children[0];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const [open, setOpenState] = useOpenState(initialState);
|
|
52
|
+
const setOpenTimeoutRef = React.useRef(0);
|
|
53
|
+
const setOpen = useEventCallback((e, shouldOpen) => {
|
|
54
|
+
var _a;
|
|
55
|
+
|
|
56
|
+
clearTimeout(setOpenTimeoutRef.current);
|
|
57
|
+
|
|
58
|
+
if (!(e instanceof Event) && e.persist) {
|
|
59
|
+
// < React 17 still uses pooled synthetic events
|
|
60
|
+
e.persist();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (e.type === 'mouseleave') {
|
|
64
|
+
// FIXME leaking Node timeout type
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
66
|
+
// @ts-ignore
|
|
67
|
+
setOpenTimeoutRef.current = setTimeout(() => {
|
|
68
|
+
setOpenState(e, shouldOpen);
|
|
69
|
+
}, (_a = props.mouseLeaveDelay) !== null && _a !== void 0 ? _a : 500);
|
|
70
|
+
} else {
|
|
71
|
+
setOpenState(e, shouldOpen);
|
|
72
|
+
}
|
|
73
|
+
}); // Clear timeout on unmount
|
|
74
|
+
// Setting state after a component unmounts can cause memory leaks
|
|
75
|
+
|
|
76
|
+
React.useEffect(() => {
|
|
77
|
+
return () => {
|
|
78
|
+
clearTimeout(setOpenTimeoutRef.current);
|
|
79
|
+
};
|
|
80
|
+
}, []);
|
|
81
|
+
const toggleOpen = React.useCallback(e => {
|
|
82
|
+
setOpen(e, !open);
|
|
83
|
+
}, [setOpen, open]);
|
|
84
|
+
const positioningRefs = usePopoverRefs(initialState);
|
|
26
85
|
const {
|
|
27
86
|
targetDocument
|
|
28
87
|
} = useFluent();
|
|
@@ -30,23 +89,37 @@ export const usePopover_unstable = props => {
|
|
|
30
89
|
contains: elementContains,
|
|
31
90
|
element: targetDocument,
|
|
32
91
|
callback: ev => setOpen(ev, false),
|
|
33
|
-
refs: [
|
|
92
|
+
refs: [positioningRefs.triggerRef, positioningRefs.contentRef],
|
|
34
93
|
disabled: !open
|
|
35
|
-
});
|
|
94
|
+
}); // only close on scroll for context, or when closeOnScroll is specified
|
|
95
|
+
|
|
96
|
+
const closeOnScroll = initialState.openOnContext || initialState.closeOnScroll;
|
|
36
97
|
useOnScrollOutside({
|
|
37
98
|
contains: elementContains,
|
|
38
99
|
element: targetDocument,
|
|
39
100
|
callback: ev => setOpen(ev, false),
|
|
40
|
-
refs: [
|
|
41
|
-
disabled: !open || !
|
|
42
|
-
|
|
101
|
+
refs: [positioningRefs.triggerRef, positioningRefs.contentRef],
|
|
102
|
+
disabled: !open || !closeOnScroll
|
|
43
103
|
});
|
|
104
|
+
const {
|
|
105
|
+
findFirstFocusable
|
|
106
|
+
} = useFocusFinders();
|
|
107
|
+
React.useEffect(() => {
|
|
108
|
+
if (open && positioningRefs.contentRef.current) {
|
|
109
|
+
const firstFocusable = findFirstFocusable(positioningRefs.contentRef.current);
|
|
110
|
+
firstFocusable === null || firstFocusable === void 0 ? void 0 : firstFocusable.focus();
|
|
111
|
+
}
|
|
112
|
+
}, [findFirstFocusable, open, positioningRefs.contentRef]);
|
|
44
113
|
return { ...initialState,
|
|
45
|
-
...
|
|
114
|
+
...positioningRefs,
|
|
115
|
+
popoverTrigger,
|
|
116
|
+
popoverSurface,
|
|
46
117
|
open,
|
|
47
118
|
setOpen,
|
|
119
|
+
toggleOpen,
|
|
48
120
|
setContextTarget,
|
|
49
|
-
contextTarget
|
|
121
|
+
contextTarget,
|
|
122
|
+
inline: (_a = props.inline) !== null && _a !== void 0 ? _a : false
|
|
50
123
|
};
|
|
51
124
|
};
|
|
52
125
|
/**
|
|
@@ -95,26 +168,26 @@ function useOpenState(state) {
|
|
|
95
168
|
|
|
96
169
|
|
|
97
170
|
function usePopoverRefs(state) {
|
|
98
|
-
const
|
|
171
|
+
const positioningOptions = {
|
|
99
172
|
position: 'above',
|
|
100
173
|
align: 'center',
|
|
101
174
|
target: state.openOnContext ? state.contextTarget : undefined,
|
|
102
175
|
...resolvePositioningShorthand(state.positioning)
|
|
103
176
|
}; // no reason to render arrow when covering the target
|
|
104
177
|
|
|
105
|
-
if (
|
|
106
|
-
state.
|
|
178
|
+
if (positioningOptions.coverTarget) {
|
|
179
|
+
state.withArrow = false;
|
|
107
180
|
}
|
|
108
181
|
|
|
109
|
-
if (
|
|
110
|
-
|
|
182
|
+
if (state.withArrow) {
|
|
183
|
+
positioningOptions.offset = mergeArrowOffset(positioningOptions.offset, arrowHeights[state.size]);
|
|
111
184
|
}
|
|
112
185
|
|
|
113
186
|
const {
|
|
114
187
|
targetRef: triggerRef,
|
|
115
188
|
containerRef: contentRef,
|
|
116
189
|
arrowRef
|
|
117
|
-
} =
|
|
190
|
+
} = usePositioning(positioningOptions);
|
|
118
191
|
return {
|
|
119
192
|
triggerRef,
|
|
120
193
|
contentRef,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Popover/usePopover.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SACE,oBADF,EAEE,gBAFF,EAGE,iBAHF,EAIE,kBAJF,QAKO,2BALP;AAMA,SAAS,SAAT,QAA0B,iCAA1B;AACA,SACE,SADF,EAEE,2BAFF,EAGE,gBAHF,EAIE,oBAJF,QAKO,6BALP;AAMA,SAAS,eAAT,QAAgC,wBAAhC;AACA,SAAS,YAAT,QAA6B,yBAA7B;AAGA;;;;;;;AAOG;;AACH,OAAO,MAAM,mBAAmB,GAA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GAAG;AACzB,IAAA,QAAQ,EAAE,OADe;AAEzB,IAAA,KAAK,EAAE,QAFkB;AAGzB,IAAA,MAAM,EAAE,KAAK,CAAC,aAAN,GAAsB,KAAK,CAAC,aAA5B,GAA4C,SAH3B;AAIzB,OAAG,2BAA2B,CAAC,KAAK,CAAC,WAAP;AAJL,GAA3B,CAFmE,CASnE;;AACA,MAAI,kBAAkB,CAAC,WAAvB,EAAoC;AAClC,IAAA,KAAK,CAAC,SAAN,GAAkB,KAAlB;AACD;;AAED,MAAI,KAAK,CAAC,SAAV,EAAqB;AACnB,IAAA,kBAAkB,CAAC,MAAnB,GAA4B,gBAAgB,CAAC,kBAAkB,CAAC,MAApB,EAA4B,YAAY,CAAC,KAAK,CAAC,IAAP,CAAxC,CAA5C;AACD;;AAED,QAAM;AAAE,IAAA,SAAS,EAAE,UAAb;AAAyB,IAAA,YAAY,EAAE,UAAvC;AAAmD,IAAA;AAAnD,MAAgE,cAAc,CAAC,kBAAD,CAApF;AAEA,SAAO;AACL,IAAA,UADK;AAEL,IAAA,UAFK;AAGL,IAAA;AAHK,GAAP;AAKD","sourcesContent":["import * as React from 'react';\nimport {\n useControllableState,\n useEventCallback,\n useOnClickOutside,\n useOnScrollOutside,\n} from '@fluentui/react-utilities';\nimport { useFluent } from '@fluentui/react-shared-contexts';\nimport {\n usePositioning,\n resolvePositioningShorthand,\n mergeArrowOffset,\n usePositioningMouseTarget,\n} from '@fluentui/react-positioning';\nimport { elementContains } from '@fluentui/react-portal';\nimport { useFocusFinders } from '@fluentui/react-tabster';\nimport { arrowHeights } from '../PopoverSurface/index';\nimport type { OpenPopoverEvents, PopoverProps, PopoverState } from './Popover.types';\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 initialState = {\n size: 'medium',\n contextTarget,\n setContextTarget,\n ...props,\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 setOpenTimeoutRef = React.useRef(0);\n\n const setOpen = useEventCallback((e: OpenPopoverEvents, shouldOpen: boolean) => {\n clearTimeout(setOpenTimeoutRef.current);\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 setOpenTimeoutRef.current = setTimeout(() => {\n setOpenState(e, shouldOpen);\n }, props.mouseLeaveDelay ?? 500);\n } else {\n setOpenState(e, shouldOpen);\n }\n });\n\n // Clear timeout on unmount\n // Setting state after a component unmounts can cause memory leaks\n React.useEffect(() => {\n return () => {\n clearTimeout(setOpenTimeoutRef.current);\n };\n }, []);\n\n const toggleOpen = React.useCallback<PopoverState['toggleOpen']>(\n e => {\n setOpen(e, !open);\n },\n [setOpen, open],\n );\n\n const positioningRefs = usePopoverRefs(initialState);\n\n const { targetDocument } = useFluent();\n useOnClickOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => setOpen(ev, false),\n refs: [positioningRefs.triggerRef, positioningRefs.contentRef],\n disabled: !open,\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 const { findFirstFocusable } = useFocusFinders();\n\n React.useEffect(() => {\n if (open && positioningRefs.contentRef.current) {\n const firstFocusable = findFirstFocusable(positioningRefs.contentRef.current);\n firstFocusable?.focus();\n }\n }, [findFirstFocusable, open, positioningRefs.contentRef]);\n\n return {\n ...initialState,\n ...positioningRefs,\n popoverTrigger,\n popoverSurface,\n open,\n setOpen,\n toggleOpen,\n setContextTarget,\n contextTarget,\n inline: props.inline ?? false,\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 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(prevOpen => {\n // More than one event (mouse, focus, keyboard) can request the Popover to close\n // We assume the first event is the correct one\n if (prevOpen !== shouldOpen) {\n onOpenChange?.(e, { open: shouldOpen });\n }\n\n return shouldOpen;\n });\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 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 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"],"sourceRoot":"../src/"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["components/PopoverSurface/PopoverSurface.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,0BAAT,QAA2C,qBAA3C;AACA,SAAS,6BAAT,QAA8C,wBAA9C;AACA,SAAS,gCAAT,QAAiD,2BAAjD;AAIA;;AAEG;;AACH,OAAO,MAAM,cAAc,gBAA6C,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;AACtG,QAAM,KAAK,GAAG,0BAA0B,CAAC,KAAD,EAAQ,GAAR,CAAxC;AAEA,EAAA,gCAAgC,CAAC,KAAD,CAAhC;AACA,SAAO,6BAA6B,CAAC,KAAD,CAApC;AACD,CALuE,CAAjE;AAOP,cAAc,CAAC,WAAf,GAA6B,gBAA7B","sourcesContent":["import * as React from 'react';\nimport { usePopoverSurface_unstable } from './usePopoverSurface';\nimport { renderPopoverSurface_unstable } from './renderPopoverSurface';\nimport { usePopoverSurfaceStyles_unstable } from './usePopoverSurfaceStyles';\nimport type { PopoverSurfaceProps } from './PopoverSurface.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\n\n/**\n * PopoverSurface component renders react children in a positioned box\n */\nexport const PopoverSurface: ForwardRefComponent<PopoverSurfaceProps> = React.forwardRef((props, ref) => {\n const state = usePopoverSurface_unstable(props, ref);\n\n usePopoverSurfaceStyles_unstable(state);\n return renderPopoverSurface_unstable(state);\n});\n\nPopoverSurface.displayName = 'PopoverSurface';\n"],"sourceRoot":"../src/"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopoverSurface.types.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"PopoverSurface.types.js","sourceRoot":"../src/","sources":["components/PopoverSurface/PopoverSurface.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport type { PopoverContextValue } from '../../popoverContext';\n\n/**\n * PopoverSurface Props\n */\nexport type PopoverSurfaceProps = ComponentProps<PopoverSurfaceSlots>;\n\n/**\n * Names of the slots in PopoverSurfaceProps\n */\nexport type PopoverSurfaceSlots = {\n root: Slot<'div'>;\n};\n\n/**\n * PopoverSurface State\n */\nexport type PopoverSurfaceState = ComponentState<PopoverSurfaceSlots> &\n Pick<PopoverContextValue, 'appearance' | 'arrowRef' | 'inline' | 'mountNode' | 'size' | 'withArrow'> & {\n /**\n * CSS class for the arrow element\n */\n arrowClassName?: string;\n };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/PopoverSurface/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC","sourcesContent":["export * from './PopoverSurface';\nexport * from './PopoverSurface.types';\nexport * from './renderPopoverSurface';\nexport * from './usePopoverSurface';\nexport * from './usePopoverSurfaceStyles';\n"]}
|
|
@@ -9,18 +9,19 @@ export const renderPopoverSurface_unstable = state => {
|
|
|
9
9
|
const {
|
|
10
10
|
slots,
|
|
11
11
|
slotProps
|
|
12
|
-
} = getSlots(state);
|
|
12
|
+
} = getSlots(state);
|
|
13
|
+
const surface = /*#__PURE__*/React.createElement(slots.root, { ...slotProps.root
|
|
14
|
+
}, state.withArrow && /*#__PURE__*/React.createElement("div", {
|
|
15
|
+
ref: state.arrowRef,
|
|
16
|
+
className: state.arrowClassName
|
|
17
|
+
}), slotProps.root.children);
|
|
13
18
|
|
|
14
|
-
if (
|
|
15
|
-
return
|
|
19
|
+
if (state.inline) {
|
|
20
|
+
return surface;
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
return /*#__PURE__*/React.createElement(Portal, {
|
|
19
24
|
mountNode: state.mountNode
|
|
20
|
-
},
|
|
21
|
-
}, !state.noArrow && /*#__PURE__*/React.createElement("div", {
|
|
22
|
-
ref: state.arrowRef,
|
|
23
|
-
className: state.arrowClassName
|
|
24
|
-
}), slotProps.root.children));
|
|
25
|
+
}, surface);
|
|
25
26
|
};
|
|
26
27
|
//# sourceMappingURL=renderPopoverSurface.js.map
|