@fluentui/react-popover 9.0.0-nightly.f81b28ceb3.1 → 9.0.0-rc.11
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +935 -25
- package/CHANGELOG.md +297 -80
- package/Spec.md +20 -0
- package/dist/{react-popover.d.ts → index.d.ts} +117 -71
- 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 +5 -5
- 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 +30 -26
- package/lib/components/Popover/renderPopover.js.map +1 -1
- package/lib/components/Popover/usePopover.js +118 -56
- package/lib/components/Popover/usePopover.js.map +1 -1
- package/lib/components/PopoverSurface/PopoverSurface.js +7 -7
- 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 +13 -13
- package/lib/components/PopoverSurface/renderPopoverSurface.js.map +1 -1
- package/lib/components/PopoverSurface/usePopoverSurface.js +40 -64
- package/lib/components/PopoverSurface/usePopoverSurface.js.map +1 -1
- package/lib/components/PopoverSurface/usePopoverSurfaceStyles.js +36 -22
- package/lib/components/PopoverSurface/usePopoverSurfaceStyles.js.map +1 -1
- package/lib/components/PopoverTrigger/PopoverTrigger.js +6 -5
- 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 +1 -1
- package/lib/components/PopoverTrigger/renderPopoverTrigger.js.map +1 -1
- package/lib/components/PopoverTrigger/usePopoverTrigger.js +40 -55
- 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 +7 -9
- package/lib/popoverContext.js.map +1 -1
- package/lib-commonjs/Popover.js +1 -1
- package/lib-commonjs/Popover.js.map +1 -1
- package/lib-commonjs/PopoverSurface.js +1 -1
- package/lib-commonjs/PopoverSurface.js.map +1 -1
- package/lib-commonjs/PopoverTrigger.js +1 -1
- package/lib-commonjs/PopoverTrigger.js.map +1 -1
- package/lib-commonjs/components/Popover/Popover.js +5 -5
- 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 +1 -1
- package/lib-commonjs/components/Popover/index.js.map +1 -1
- package/lib-commonjs/components/Popover/renderPopover.js +34 -30
- package/lib-commonjs/components/Popover/renderPopover.js.map +1 -1
- package/lib-commonjs/components/Popover/usePopover.js +125 -63
- package/lib-commonjs/components/Popover/usePopover.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/PopoverSurface.js +8 -8
- 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 +1 -1
- package/lib-commonjs/components/PopoverSurface/index.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.js +18 -20
- package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/usePopoverSurface.js +44 -70
- package/lib-commonjs/components/PopoverSurface/usePopoverSurface.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.js +40 -24
- package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.js.map +1 -1
- package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.js +6 -5
- 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 +1 -1
- package/lib-commonjs/components/PopoverTrigger/index.js.map +1 -1
- package/lib-commonjs/components/PopoverTrigger/renderPopoverTrigger.js +3 -3
- package/lib-commonjs/components/PopoverTrigger/renderPopoverTrigger.js.map +1 -1
- package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.js +45 -61
- 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 +9 -11
- package/lib-commonjs/popoverContext.js.map +1 -1
- package/package.json +23 -27
- package/lib/Popover.d.ts +0 -1
- package/lib/PopoverSurface.d.ts +0 -1
- package/lib/PopoverTrigger.d.ts +0 -1
- package/lib/common/isConformant.d.ts +0 -4
- package/lib/common/isConformant.js +0 -13
- package/lib/common/isConformant.js.map +0 -1
- package/lib/common/mockUsePopoverContext.d.ts +0 -7
- package/lib/common/mockUsePopoverContext.js +0 -38
- package/lib/common/mockUsePopoverContext.js.map +0 -1
- package/lib/components/Popover/Popover.d.ts +0 -6
- package/lib/components/Popover/Popover.types.d.ts +0 -100
- 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 -13
- package/lib/components/PopoverSurface/usePopoverSurfaceStyles.d.ts +0 -7
- package/lib/components/PopoverTrigger/PopoverTrigger.d.ts +0 -6
- package/lib/components/PopoverTrigger/PopoverTrigger.types.d.ts +0 -11
- 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/common/isConformant.d.ts +0 -4
- package/lib-commonjs/common/isConformant.js +0 -24
- package/lib-commonjs/common/isConformant.js.map +0 -1
- package/lib-commonjs/common/mockUsePopoverContext.d.ts +0 -7
- package/lib-commonjs/common/mockUsePopoverContext.js +0 -49
- package/lib-commonjs/common/mockUsePopoverContext.js.map +0 -1
- package/lib-commonjs/components/Popover/Popover.d.ts +0 -6
- package/lib-commonjs/components/Popover/Popover.types.d.ts +0 -100
- 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 -13
- package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.d.ts +0 -7
- package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.d.ts +0 -6
- package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.types.d.ts +0 -11
- 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,95 +1,127 @@
|
|
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
|
+
import type { FluentTriggerComponent } from '@fluentui/react-utilities';
|
5
6
|
import type { ForwardRefComponent } from '@fluentui/react-utilities';
|
6
|
-
import
|
7
|
-
import type { PopperVirtualElement } from '@fluentui/react-positioning';
|
7
|
+
import { JSXElementConstructor } from 'react';
|
8
8
|
import type { PortalProps } from '@fluentui/react-portal';
|
9
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';
|
10
13
|
import * as React_2 from 'react';
|
11
|
-
import
|
14
|
+
import { ReactElement } from 'react';
|
15
|
+
import type { Slot } from '@fluentui/react-utilities';
|
16
|
+
import type { SlotClassNames } from '@fluentui/react-utilities';
|
17
|
+
import type { usePositioningMouseTarget } from '@fluentui/react-positioning';
|
12
18
|
|
13
19
|
export declare const arrowHeights: Record<PopoverSize, number>;
|
14
20
|
|
15
21
|
/**
|
16
22
|
* Data attached to open/close events
|
17
23
|
*/
|
18
|
-
export declare type OnOpenChangeData =
|
24
|
+
export declare type OnOpenChangeData = {
|
25
|
+
open: boolean;
|
26
|
+
};
|
19
27
|
|
20
28
|
/**
|
21
29
|
* The supported events that will trigger open/close of the menu
|
22
30
|
*/
|
23
|
-
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>;
|
24
32
|
|
25
33
|
/**
|
26
34
|
* Wrapper component that manages state for a PopoverTrigger and a PopoverSurface components.
|
27
35
|
*/
|
28
36
|
export declare const Popover: React_2.FC<PopoverProps>;
|
29
37
|
|
30
|
-
|
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
|
-
*
|
48
|
+
* A popover can appear styled with brand or inverted.
|
49
|
+
* When not specified, the default style is used.
|
33
50
|
*/
|
34
|
-
|
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
|
-
*
|
89
|
+
* Controls the opening of the Popover
|
90
|
+
*
|
91
|
+
* @default false
|
46
92
|
*/
|
47
|
-
|
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
|
-
*
|
101
|
+
* Flag to open the Popover by hovering the trigger
|
102
|
+
*
|
103
|
+
* @default false
|
54
104
|
*/
|
55
|
-
|
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
122
|
};
|
75
123
|
|
76
|
-
export declare const
|
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
|
-
};
|
124
|
+
export declare const PopoverProvider: Provider<PopoverContextValue> & FC<ProviderProps<PopoverContextValue>>;
|
93
125
|
|
94
126
|
/**
|
95
127
|
* Determines popover padding and arrow size
|
@@ -99,32 +131,38 @@ export declare type PopoverSize = 'small' | 'medium' | 'large';
|
|
99
131
|
/**
|
100
132
|
* Popover State
|
101
133
|
*/
|
102
|
-
export declare type PopoverState =
|
134
|
+
export declare type PopoverState = Pick<PopoverProps, 'appearance' | 'mountNode' | 'noArrow' | 'onOpenChange' | 'openOnContext' | 'openOnHover' | 'trapFocus'> & Required<Pick<PopoverProps, 'inline' | 'open'>> & Pick<PopoverProps, 'children'> & {
|
103
135
|
/**
|
104
|
-
*
|
105
|
-
*/
|
106
|
-
setOpen: (e: OpenPopoverEvents, open: boolean) => void;
|
107
|
-
/**
|
108
|
-
* Ref of the PopoverTrigger
|
136
|
+
* Ref of the pointing arrow
|
109
137
|
*/
|
110
|
-
|
138
|
+
arrowRef: React_2.MutableRefObject<HTMLDivElement | null>;
|
111
139
|
/**
|
112
140
|
* Ref of the PopoverSurface
|
113
141
|
*/
|
114
142
|
contentRef: React_2.MutableRefObject<HTMLElement | null>;
|
115
|
-
/**
|
116
|
-
* Ref of the pointing arrow
|
117
|
-
*/
|
118
|
-
arrowRef: React_2.MutableRefObject<HTMLDivElement | null>;
|
119
143
|
/**
|
120
144
|
* Anchors the popper to the mouse click for context events
|
121
145
|
*/
|
122
|
-
contextTarget:
|
146
|
+
contextTarget: PositioningVirtualElement | undefined;
|
147
|
+
popoverSurface: React_2.ReactElement | undefined;
|
148
|
+
popoverTrigger: React_2.ReactElement | undefined;
|
123
149
|
/**
|
124
150
|
* A callback to set the target of the popper to the mouse click for context events
|
125
151
|
*/
|
126
|
-
setContextTarget: ReturnType<typeof
|
152
|
+
setContextTarget: ReturnType<typeof usePositioningMouseTarget>[1];
|
153
|
+
/**
|
154
|
+
* Callback to open/close the Popover
|
155
|
+
*/
|
156
|
+
setOpen: (e: OpenPopoverEvents, open: boolean) => void;
|
127
157
|
size: NonNullable<PopoverProps['size']>;
|
158
|
+
/**
|
159
|
+
* Callback to toggle the open state of the Popover
|
160
|
+
*/
|
161
|
+
toggleOpen: (e: OpenPopoverEvents) => void;
|
162
|
+
/**
|
163
|
+
* Ref of the PopoverTrigger
|
164
|
+
*/
|
165
|
+
triggerRef: React_2.MutableRefObject<HTMLElement | null>;
|
128
166
|
};
|
129
167
|
|
130
168
|
/**
|
@@ -132,6 +170,8 @@ export declare type PopoverState = PopoverCommons & Pick<PopoverProps, 'children
|
|
132
170
|
*/
|
133
171
|
export declare const PopoverSurface: ForwardRefComponent<PopoverSurfaceProps>;
|
134
172
|
|
173
|
+
export declare const popoverSurfaceClassNames: SlotClassNames<PopoverSurfaceSlots>;
|
174
|
+
|
135
175
|
/**
|
136
176
|
* PopoverSurface Props
|
137
177
|
*/
|
@@ -141,15 +181,13 @@ export declare type PopoverSurfaceProps = ComponentProps<PopoverSurfaceSlots>;
|
|
141
181
|
* Names of the slots in PopoverSurfaceProps
|
142
182
|
*/
|
143
183
|
export declare type PopoverSurfaceSlots = {
|
144
|
-
root:
|
184
|
+
root: Slot<'div'>;
|
145
185
|
};
|
146
186
|
|
147
|
-
export declare const popoverSurfaceSlots: Array<keyof PopoverSurfaceSlots>;
|
148
|
-
|
149
187
|
/**
|
150
188
|
* PopoverSurface State
|
151
189
|
*/
|
152
|
-
export declare type PopoverSurfaceState = ComponentState<PopoverSurfaceSlots> & Pick<PopoverContextValue, '
|
190
|
+
export declare type PopoverSurfaceState = ComponentState<PopoverSurfaceSlots> & Pick<PopoverContextValue, 'appearance' | 'arrowRef' | 'inline' | 'mountNode' | 'noArrow' | 'size'> & {
|
153
191
|
/**
|
154
192
|
* CSS class for the arrow element
|
155
193
|
*/
|
@@ -159,71 +197,79 @@ export declare type PopoverSurfaceState = ComponentState<PopoverSurfaceSlots> &
|
|
159
197
|
/**
|
160
198
|
* Wraps a trigger element as an only child and adds the necessary event handling to open a popover.
|
161
199
|
*/
|
162
|
-
export declare const PopoverTrigger: React_2.FC<PopoverTriggerProps
|
200
|
+
export declare const PopoverTrigger: React_2.FC<PopoverTriggerProps> & FluentTriggerComponent;
|
201
|
+
|
202
|
+
export declare type PopoverTriggerChildProps = {
|
203
|
+
ref?: React_2.Ref<never>;
|
204
|
+
} & Pick<React_2.HTMLAttributes<HTMLElement>, 'aria-haspopup' | 'onClick' | 'onContextMenu' | 'onKeyDown' | 'onMouseEnter' | 'onMouseLeave'>;
|
163
205
|
|
164
206
|
/**
|
165
207
|
* PopoverTrigger Props
|
166
208
|
*/
|
167
209
|
export declare type PopoverTriggerProps = {
|
168
|
-
children: React_2.ReactElement
|
210
|
+
children: (React_2.ReactElement & {
|
211
|
+
ref?: React_2.Ref<unknown>;
|
212
|
+
}) | ((props: PopoverTriggerChildProps) => React_2.ReactElement | null);
|
169
213
|
};
|
170
214
|
|
171
215
|
/**
|
172
216
|
* PopoverTrigger State
|
173
217
|
*/
|
174
|
-
export declare type PopoverTriggerState =
|
218
|
+
export declare type PopoverTriggerState = {
|
219
|
+
children: React_2.ReactElement | null;
|
220
|
+
};
|
175
221
|
|
176
222
|
/**
|
177
223
|
* Render the final JSX of Popover
|
178
224
|
*/
|
179
|
-
export declare const
|
225
|
+
export declare const renderPopover_unstable: (state: PopoverState) => JSX.Element;
|
180
226
|
|
181
227
|
/**
|
182
228
|
* Render the final JSX of PopoverSurface
|
183
229
|
*/
|
184
|
-
export declare const
|
230
|
+
export declare const renderPopoverSurface_unstable: (state: PopoverSurfaceState) => JSX.Element;
|
185
231
|
|
186
232
|
/**
|
187
233
|
* Render the final JSX of PopoverTrigger
|
188
234
|
*/
|
189
|
-
export declare const
|
235
|
+
export declare const renderPopoverTrigger_unstable: (state: PopoverTriggerState) => ReactElement<any, string | JSXElementConstructor<any>> | null;
|
190
236
|
|
191
237
|
/**
|
192
238
|
* Create the state required to render Popover.
|
193
239
|
*
|
194
240
|
* The returned state can be modified with hooks such as usePopoverStyles,
|
195
|
-
* before being passed to
|
241
|
+
* before being passed to renderPopover_unstable.
|
196
242
|
*
|
197
243
|
* @param props - props from this instance of Popover
|
198
244
|
*/
|
199
|
-
export declare const
|
245
|
+
export declare const usePopover_unstable: (props: PopoverProps) => PopoverState;
|
200
246
|
|
201
|
-
export declare const
|
247
|
+
export declare const usePopoverContext_unstable: <T>(selector: ContextSelector<PopoverContextValue, T>) => T;
|
202
248
|
|
203
249
|
/**
|
204
250
|
* Create the state required to render PopoverSurface.
|
205
251
|
*
|
206
|
-
* The returned state can be modified with hooks such as
|
207
|
-
* before being passed to
|
252
|
+
* The returned state can be modified with hooks such as usePopoverSurfaceStyles_unstable,
|
253
|
+
* before being passed to renderPopoverSurface_unstable.
|
208
254
|
*
|
209
255
|
* @param props - props from this instance of PopoverSurface
|
210
256
|
* @param ref - reference to root HTMLDivElement of PopoverSurface
|
211
257
|
*/
|
212
|
-
export declare const
|
258
|
+
export declare const usePopoverSurface_unstable: (props: PopoverSurfaceProps, ref: React_2.Ref<HTMLDivElement>) => PopoverSurfaceState;
|
213
259
|
|
214
260
|
/**
|
215
261
|
* Apply styling to the PopoverSurface slots based on the state
|
216
262
|
*/
|
217
|
-
export declare const
|
263
|
+
export declare const usePopoverSurfaceStyles_unstable: (state: PopoverSurfaceState) => PopoverSurfaceState;
|
218
264
|
|
219
265
|
/**
|
220
266
|
* Create the state required to render PopoverTrigger.
|
221
267
|
*
|
222
268
|
* The returned state can be modified with hooks such as usePopoverTriggerStyles,
|
223
|
-
* before being passed to
|
269
|
+
* before being passed to renderPopoverTrigger_unstable.
|
224
270
|
*
|
225
271
|
* @param props - props from this instance of PopoverTrigger
|
226
272
|
*/
|
227
|
-
export declare const
|
273
|
+
export declare const usePopoverTrigger_unstable: (props: PopoverTriggerProps) => PopoverTriggerState;
|
228
274
|
|
229
275
|
export { }
|
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,12 +1,12 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
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
|
8
|
-
|
9
|
-
return
|
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":["
|
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 * 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: 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"]}
|
@@ -4,34 +4,38 @@ import { PopoverContext } from '../../popoverContext';
|
|
4
4
|
* Render the final JSX of Popover
|
5
5
|
*/
|
6
6
|
|
7
|
-
export
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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.
|
39
|
+
}, state.popoverTrigger, state.open && state.popoverSurface);
|
36
40
|
};
|
37
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,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/"}
|