@fluentui/react-popover 0.0.0-nightlyff78d1e27a20220217.1 → 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +780 -20
- package/CHANGELOG.md +281 -82
- package/Spec.md +25 -5
- package/dist/{react-popover.d.ts → index.d.ts} +99 -53
- package/{lib → dist}/tsdoc-metadata.json +0 -0
- package/lib/components/Popover/Popover.js.map +1 -1
- package/lib/components/Popover/Popover.types.js.map +1 -1
- package/lib/components/Popover/constants.js +10 -0
- package/lib/components/Popover/constants.js.map +1 -0
- package/lib/components/Popover/renderPopover.js +23 -17
- package/lib/components/Popover/renderPopover.js.map +1 -1
- package/lib/components/Popover/usePopover.js +93 -18
- 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/renderPopoverSurface.js +9 -8
- package/lib/components/PopoverSurface/renderPopoverSurface.js.map +1 -1
- package/lib/components/PopoverSurface/usePopoverSurface.js +8 -16
- package/lib/components/PopoverSurface/usePopoverSurface.js.map +1 -1
- package/lib/components/PopoverSurface/usePopoverSurfaceStyles.js +24 -22
- 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/renderPopoverTrigger.js.map +1 -1
- package/lib/components/PopoverTrigger/usePopoverTrigger.js +4 -4
- 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 -1
- package/lib/popoverContext.js.map +1 -1
- package/lib-commonjs/components/Popover/Popover.js.map +1 -1
- package/lib-commonjs/components/Popover/constants.js +17 -0
- package/lib-commonjs/components/Popover/constants.js.map +1 -0
- package/lib-commonjs/components/Popover/renderPopover.js +23 -17
- package/lib-commonjs/components/Popover/renderPopover.js.map +1 -1
- package/lib-commonjs/components/Popover/usePopover.js +94 -17
- 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/renderPopoverSurface.js +9 -8
- package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/usePopoverSurface.js +7 -16
- package/lib-commonjs/components/PopoverSurface/usePopoverSurface.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.js +25 -23
- 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/renderPopoverTrigger.js.map +1 -1
- package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.js +4 -4
- 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 -2
- package/lib-commonjs/popoverContext.js.map +1 -1
- package/package.json +26 -28
- 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
@@ -15,7 +15,11 @@ const react_positioning_1 = /*#__PURE__*/require("@fluentui/react-positioning");
|
|
15
15
|
|
16
16
|
const react_portal_1 = /*#__PURE__*/require("@fluentui/react-portal");
|
17
17
|
|
18
|
+
const react_tabster_1 = /*#__PURE__*/require("@fluentui/react-tabster");
|
19
|
+
|
18
20
|
const index_1 = /*#__PURE__*/require("../PopoverSurface/index");
|
21
|
+
|
22
|
+
const constants_1 = /*#__PURE__*/require("./constants");
|
19
23
|
/**
|
20
24
|
* Create the state required to render Popover.
|
21
25
|
*
|
@@ -27,39 +31,111 @@ const index_1 = /*#__PURE__*/require("../PopoverSurface/index");
|
|
27
31
|
|
28
32
|
|
29
33
|
const usePopover_unstable = props => {
|
30
|
-
|
34
|
+
var _a;
|
35
|
+
|
36
|
+
const [contextTarget, setContextTarget] = react_positioning_1.usePositioningMouseTarget();
|
31
37
|
const initialState = {
|
32
38
|
size: 'medium',
|
33
39
|
contextTarget,
|
34
40
|
setContextTarget,
|
35
41
|
...props
|
36
42
|
};
|
37
|
-
const
|
38
|
-
|
43
|
+
const children = React.Children.toArray(props.children);
|
44
|
+
|
45
|
+
if (process.env.NODE_ENV !== 'production') {
|
46
|
+
if (children.length === 0) {
|
47
|
+
// eslint-disable-next-line no-console
|
48
|
+
console.warn('Popover must contain at least one child');
|
49
|
+
}
|
50
|
+
|
51
|
+
if (children.length > 2) {
|
52
|
+
// eslint-disable-next-line no-console
|
53
|
+
console.warn('Popover must contain at most two children');
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
let popoverTrigger = undefined;
|
58
|
+
let popoverSurface = undefined;
|
59
|
+
|
60
|
+
if (children.length === 2) {
|
61
|
+
popoverTrigger = children[0];
|
62
|
+
popoverSurface = children[1];
|
63
|
+
} else if (children.length === 1) {
|
64
|
+
popoverSurface = children[0];
|
65
|
+
}
|
66
|
+
|
67
|
+
const [open, setOpenState] = useOpenState(initialState);
|
68
|
+
const setOpenTimeoutRef = React.useRef(0);
|
69
|
+
const setOpen = react_utilities_1.useEventCallback((e, shouldOpen) => {
|
70
|
+
var _a;
|
71
|
+
|
72
|
+
clearTimeout(setOpenTimeoutRef.current);
|
73
|
+
|
74
|
+
if (!(e instanceof Event) && e.persist) {
|
75
|
+
// < React 17 still uses pooled synthetic events
|
76
|
+
e.persist();
|
77
|
+
}
|
78
|
+
|
79
|
+
if (e.type === 'mouseleave') {
|
80
|
+
// FIXME leaking Node timeout type
|
81
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
82
|
+
// @ts-ignore
|
83
|
+
setOpenTimeoutRef.current = setTimeout(() => {
|
84
|
+
setOpenState(e, shouldOpen);
|
85
|
+
}, (_a = props.mouseLeaveDelay) !== null && _a !== void 0 ? _a : 500);
|
86
|
+
} else {
|
87
|
+
setOpenState(e, shouldOpen);
|
88
|
+
}
|
89
|
+
}); // Clear timeout on unmount
|
90
|
+
// Setting state after a component unmounts can cause memory leaks
|
91
|
+
|
92
|
+
React.useEffect(() => {
|
93
|
+
return () => {
|
94
|
+
clearTimeout(setOpenTimeoutRef.current);
|
95
|
+
};
|
96
|
+
}, []);
|
97
|
+
const toggleOpen = React.useCallback(e => {
|
98
|
+
setOpen(e, !open);
|
99
|
+
}, [setOpen, open]);
|
100
|
+
const positioningRefs = usePopoverRefs(initialState);
|
39
101
|
const {
|
40
102
|
targetDocument
|
41
|
-
} = react_shared_contexts_1.
|
103
|
+
} = react_shared_contexts_1.useFluent_unstable();
|
42
104
|
react_utilities_1.useOnClickOutside({
|
43
105
|
contains: react_portal_1.elementContains,
|
44
106
|
element: targetDocument,
|
45
107
|
callback: ev => setOpen(ev, false),
|
46
|
-
refs: [
|
108
|
+
refs: [positioningRefs.triggerRef, positioningRefs.contentRef],
|
47
109
|
disabled: !open
|
48
|
-
});
|
110
|
+
}); // only close on scroll for context, or when closeOnScroll is specified
|
111
|
+
|
112
|
+
const closeOnScroll = initialState.openOnContext || initialState.closeOnScroll;
|
49
113
|
react_utilities_1.useOnScrollOutside({
|
50
114
|
contains: react_portal_1.elementContains,
|
51
115
|
element: targetDocument,
|
52
116
|
callback: ev => setOpen(ev, false),
|
53
|
-
refs: [
|
54
|
-
disabled: !open || !
|
55
|
-
|
117
|
+
refs: [positioningRefs.triggerRef, positioningRefs.contentRef],
|
118
|
+
disabled: !open || !closeOnScroll
|
56
119
|
});
|
120
|
+
const {
|
121
|
+
findFirstFocusable
|
122
|
+
} = react_tabster_1.useFocusFinders();
|
123
|
+
React.useEffect(() => {
|
124
|
+
if (open && positioningRefs.contentRef.current) {
|
125
|
+
const firstFocusable = findFirstFocusable(positioningRefs.contentRef.current);
|
126
|
+
firstFocusable === null || firstFocusable === void 0 ? void 0 : firstFocusable.focus();
|
127
|
+
}
|
128
|
+
}, [findFirstFocusable, open, positioningRefs.contentRef]);
|
57
129
|
return { ...initialState,
|
58
|
-
...
|
130
|
+
...positioningRefs,
|
131
|
+
popoverTrigger,
|
132
|
+
popoverSurface,
|
59
133
|
open,
|
60
134
|
setOpen,
|
135
|
+
toggleOpen,
|
61
136
|
setContextTarget,
|
62
|
-
contextTarget
|
137
|
+
contextTarget,
|
138
|
+
inline: (_a = props.inline) !== null && _a !== void 0 ? _a : false
|
63
139
|
};
|
64
140
|
};
|
65
141
|
|
@@ -110,26 +186,27 @@ function useOpenState(state) {
|
|
110
186
|
|
111
187
|
|
112
188
|
function usePopoverRefs(state) {
|
113
|
-
const
|
189
|
+
const positioningOptions = {
|
114
190
|
position: 'above',
|
115
191
|
align: 'center',
|
192
|
+
arrowPadding: 2 * constants_1.popoverSurfaceBorderRadius,
|
116
193
|
target: state.openOnContext ? state.contextTarget : undefined,
|
117
194
|
...react_positioning_1.resolvePositioningShorthand(state.positioning)
|
118
195
|
}; // no reason to render arrow when covering the target
|
119
196
|
|
120
|
-
if (
|
121
|
-
state.
|
197
|
+
if (positioningOptions.coverTarget) {
|
198
|
+
state.withArrow = false;
|
122
199
|
}
|
123
200
|
|
124
|
-
if (
|
125
|
-
|
201
|
+
if (state.withArrow) {
|
202
|
+
positioningOptions.offset = react_positioning_1.mergeArrowOffset(positioningOptions.offset, index_1.arrowHeights[state.size]);
|
126
203
|
}
|
127
204
|
|
128
205
|
const {
|
129
206
|
targetRef: triggerRef,
|
130
207
|
containerRef: contentRef,
|
131
208
|
arrowRef
|
132
|
-
} = react_positioning_1.
|
209
|
+
} = react_positioning_1.usePositioning(positioningOptions);
|
133
210
|
return {
|
134
211
|
triggerRef,
|
135
212
|
contentRef,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["components/Popover/usePopover.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AAMA,MAAA,uBAAA,gBAAA,OAAA,CAAA,iCAAA,CAAA;;AACA,MAAA,mBAAA,gBAAA,OAAA,CAAA,6BAAA,CAAA;;AAMA,MAAA,cAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AACA,MAAA,OAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;AAGA;;;;;;;AAOG;;;AACI,MAAM,mBAAmB,GAAI,KAAD,IAAsC;AACvE,QAAM,CAAC,aAAD,EAAgB,gBAAhB,IAAoC,mBAAA,CAAA,oBAAA,EAA1C;AACA,QAAM,YAAY,GAAG;AACnB,IAAA,IAAI,EAAE,QADa;AAEnB,IAAA,aAFmB;AAGnB,IAAA,gBAHmB;AAInB,OAAG;AAJgB,GAArB;AAOA,QAAM,CAAC,IAAD,EAAO,OAAP,IAAkB,YAAY,CAAC,YAAD,CAApC;AACA,QAAM,UAAU,GAAG,cAAc,CAAC,YAAD,CAAjC;AAEA,QAAM;AAAE,IAAA;AAAF,MAAqB,uBAAA,CAAA,SAAA,EAA3B;AACA,EAAA,iBAAA,CAAA,iBAAA,CAAkB;AAChB,IAAA,QAAQ,EAAE,cAAA,CAAA,eADM;AAEhB,IAAA,OAAO,EAAE,cAFO;AAGhB,IAAA,QAAQ,EAAE,EAAE,IAAI,OAAO,CAAC,EAAD,EAAK,KAAL,CAHP;A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AX,EAAoB;AAClB,IAAA,aAAa,CAAC,MAAd,GAAuB,mBAAA,CAAA,gBAAA,CAAiB,aAAa,CAAC,MAA/B,EAAuC,OAAA,CAAA,YAAA,CAAa,KAAK,CAAC,IAAnB,CAAvC,CAAvB;AACD;;AAED,QAAM;AAAE,IAAA,SAAS,EAAE,UAAb;AAAyB,IAAA,YAAY,EAAE,UAAvC;AAAmD,IAAA;AAAnD,MAAgE,mBAAA,CAAA,SAAA,CAAU,aAAV,CAAtE;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 usePopper,\n resolvePositioningShorthand,\n mergeArrowOffset,\n usePopperMouseTarget,\n} from '@fluentui/react-positioning';\nimport { elementContains } from '@fluentui/react-portal';\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] = usePopperMouseTarget();\n const initialState = {\n size: 'medium',\n contextTarget,\n setContextTarget,\n ...props,\n } as const;\n\n const [open, setOpen] = useOpenState(initialState);\n const popperRefs = usePopoverRefs(initialState);\n\n const { targetDocument } = useFluent();\n useOnClickOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => setOpen(ev, false),\n refs: [popperRefs.triggerRef, popperRefs.contentRef],\n disabled: !open,\n });\n useOnScrollOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => setOpen(ev, false),\n refs: [popperRefs.triggerRef, popperRefs.contentRef],\n disabled: !open || !initialState.openOnContext, // only close on scroll for context\n });\n\n return {\n ...initialState,\n ...popperRefs,\n open,\n setOpen,\n setContextTarget,\n contextTarget,\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'> & Pick<PopoverProps, 'positioning' | 'openOnContext' | 'noArrow'>,\n) {\n const popperOptions = {\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 (popperOptions.coverTarget) {\n state.noArrow = true;\n }\n\n if (!state.noArrow) {\n popperOptions.offset = mergeArrowOffset(popperOptions.offset, arrowHeights[state.size]);\n }\n\n const { targetRef: triggerRef, containerRef: contentRef, arrowRef } = usePopper(popperOptions);\n\n return {\n triggerRef,\n contentRef,\n arrowRef,\n } as const;\n}\n"],"sourceRoot":"../src/"}
|
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MACA;MACA,IAAI,QAAQ,KAAK,UAAjB,EAA6B;QAC3B,YAAY,KAAA,IAAZ,IAAA,YAAY,KAAA,KAAA,CAAZ,GAAY,KAAA,CAAZ,GAAA,YAAY,CAAG,CAAH,EAAM;UAAE,IAAI,EAAE;QAAR,CAAN,CAAZ;MACD;;MAED,OAAO,UAAP;IACD,CARW,CAAZ;EASD,CAnBa,EAoBd,CAAC,YAAD,EAAe,YAAf,EAA6B,gBAA7B,CApBc,CAAhB;EAuBA,OAAO,CAAC,IAAD,EAAO,OAAP,CAAP;AACD;AAED;;AAEG;;;AACH,SAAS,cAAT,CACE,KADF,EAEqE;EAEnE,MAAM,kBAAkB,GAAG;IACzB,QAAQ,EAAE,OADe;IAEzB,KAAK,EAAE,QAFkB;IAGzB,YAAY,EAAE,IAAI,WAAA,CAAA,0BAHO;IAIzB,MAAM,EAAE,KAAK,CAAC,aAAN,GAAsB,KAAK,CAAC,aAA5B,GAA4C,SAJ3B;IAKzB,GAAG,mBAAA,CAAA,2BAAA,CAA4B,KAAK,CAAC,WAAlC;EALsB,CAA3B,CAFmE,CAUnE;;EACA,IAAI,kBAAkB,CAAC,WAAvB,EAAoC;IAClC,KAAK,CAAC,SAAN,GAAkB,KAAlB;EACD;;EAED,IAAI,KAAK,CAAC,SAAV,EAAqB;IACnB,kBAAkB,CAAC,MAAnB,GAA4B,mBAAA,CAAA,gBAAA,CAAiB,kBAAkB,CAAC,MAApC,EAA4C,OAAA,CAAA,YAAA,CAAa,KAAK,CAAC,IAAnB,CAA5C,CAA5B;EACD;;EAED,MAAM;IAAE,SAAS,EAAE,UAAb;IAAyB,YAAY,EAAE,UAAvC;IAAmD;EAAnD,IAAgE,mBAAA,CAAA,cAAA,CAAe,kBAAf,CAAtE;EAEA,OAAO;IACL,UADK;IAEL,UAFK;IAGL;EAHK,CAAP;AAKD","sourcesContent":["import * as React from 'react';\nimport {\n useControllableState,\n useEventCallback,\n useOnClickOutside,\n useOnScrollOutside,\n} from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport {\n usePositioning,\n resolvePositioningShorthand,\n mergeArrowOffset,\n usePositioningMouseTarget,\n} 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';\nimport { popoverSurfaceBorderRadius } from './constants';\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 arrowPadding: 2 * popoverSurfaceBorderRadius,\n target: state.openOnContext ? state.contextTarget : undefined,\n ...resolvePositioningShorthand(state.positioning),\n };\n\n // no reason to render arrow when covering the target\n if (positioningOptions.coverTarget) {\n 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":["components/PopoverSurface/PopoverSurface.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,mBAAA,gBAAA,OAAA,CAAA,qBAAA,CAAA;;AACA,MAAA,sBAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AACA,MAAA,yBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAIA;;AAEG;;;AACU,OAAA,CAAA,cAAA,gBAA2D,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;
|
1
|
+
{"version":3,"sources":["components/PopoverSurface/PopoverSurface.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,mBAAA,gBAAA,OAAA,CAAA,qBAAA,CAAA;;AACA,MAAA,sBAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AACA,MAAA,yBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAIA;;AAEG;;;AACU,OAAA,CAAA,cAAA,gBAA2D,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;EACtG,MAAM,KAAK,GAAG,mBAAA,CAAA,0BAAA,CAA2B,KAA3B,EAAkC,GAAlC,CAAd;EAEA,yBAAA,CAAA,gCAAA,CAAiC,KAAjC;EACA,OAAO,sBAAA,CAAA,6BAAA,CAA8B,KAA9B,CAAP;AACD,CALuE,CAA3D;AAOb,OAAA,CAAA,cAAA,CAAe,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/"}
|
@@ -19,19 +19,20 @@ const renderPopoverSurface_unstable = state => {
|
|
19
19
|
const {
|
20
20
|
slots,
|
21
21
|
slotProps
|
22
|
-
} = react_utilities_1.getSlots(state);
|
22
|
+
} = react_utilities_1.getSlots(state);
|
23
|
+
const surface = React.createElement(slots.root, { ...slotProps.root
|
24
|
+
}, state.withArrow && React.createElement("div", {
|
25
|
+
ref: state.arrowRef,
|
26
|
+
className: state.arrowClassName
|
27
|
+
}), slotProps.root.children);
|
23
28
|
|
24
|
-
if (
|
25
|
-
return
|
29
|
+
if (state.inline) {
|
30
|
+
return surface;
|
26
31
|
}
|
27
32
|
|
28
33
|
return React.createElement(react_portal_1.Portal, {
|
29
34
|
mountNode: state.mountNode
|
30
|
-
},
|
31
|
-
}, !state.noArrow && React.createElement("div", {
|
32
|
-
ref: state.arrowRef,
|
33
|
-
className: state.arrowClassName
|
34
|
-
}), slotProps.root.children));
|
35
|
+
}, surface);
|
35
36
|
};
|
36
37
|
|
37
38
|
exports.renderPopoverSurface_unstable = renderPopoverSurface_unstable;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["components/PopoverSurface/renderPopoverSurface.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,cAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAGA;;AAEG;;;AACI,MAAM,6BAA6B,GAAI,KAAD,IAA+B;
|
1
|
+
{"version":3,"sources":["components/PopoverSurface/renderPopoverSurface.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,cAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAGA;;AAEG;;;AACI,MAAM,6BAA6B,GAAI,KAAD,IAA+B;EAC1E,MAAM;IAAE,KAAF;IAAS;EAAT,IAAuB,iBAAA,CAAA,QAAA,CAA8B,KAA9B,CAA7B;EAEA,MAAM,OAAO,GACX,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;EAAf,CAAX,EACG,KAAK,CAAC,SAAN,IAAmB,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;IAAK,GAAG,EAAE,KAAK,CAAC,QAAhB;IAA0B,SAAS,EAAE,KAAK,CAAC;EAA3C,CAAA,CADtB,EAEG,SAAS,CAAC,IAAV,CAAe,QAFlB,CADF;;EAOA,IAAI,KAAK,CAAC,MAAV,EAAkB;IAChB,OAAO,OAAP;EACD;;EAED,OAAO,KAAA,CAAA,aAAA,CAAC,cAAA,CAAA,MAAD,EAAO;IAAC,SAAS,EAAE,KAAK,CAAC;EAAlB,CAAP,EAAqC,OAArC,CAAP;AACD,CAfM;;AAAM,OAAA,CAAA,6BAAA,GAA6B,6BAA7B","sourcesContent":["import * as React from 'react';\nimport { Portal } from '@fluentui/react-portal';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { PopoverSurfaceSlots, PopoverSurfaceState } from './PopoverSurface.types';\n\n/**\n * Render the final JSX of PopoverSurface\n */\nexport const renderPopoverSurface_unstable = (state: PopoverSurfaceState) => {\n const { slots, slotProps } = getSlots<PopoverSurfaceSlots>(state);\n\n const surface = (\n <slots.root {...slotProps.root}>\n {state.withArrow && <div ref={state.arrowRef} className={state.arrowClassName} />}\n {slotProps.root.children}\n </slots.root>\n );\n\n if (state.inline) {\n return surface;\n }\n\n return <Portal mountNode={state.mountNode}>{surface}</Portal>;\n};\n"],"sourceRoot":"../src/"}
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.usePopoverSurface_unstable = void 0;
|
7
7
|
|
8
|
-
const React = /*#__PURE__*/require("react");
|
9
|
-
|
10
8
|
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
11
9
|
|
12
10
|
const react_tabster_1 = /*#__PURE__*/require("@fluentui/react-tabster");
|
@@ -25,26 +23,28 @@ const popoverContext_1 = /*#__PURE__*/require("../../popoverContext");
|
|
25
23
|
|
26
24
|
const usePopoverSurface_unstable = (props, ref) => {
|
27
25
|
const contentRef = popoverContext_1.usePopoverContext_unstable(context => context.contentRef);
|
28
|
-
const open = popoverContext_1.usePopoverContext_unstable(context => context.open);
|
29
26
|
const openOnHover = popoverContext_1.usePopoverContext_unstable(context => context.openOnHover);
|
30
27
|
const setOpen = popoverContext_1.usePopoverContext_unstable(context => context.setOpen);
|
31
28
|
const mountNode = popoverContext_1.usePopoverContext_unstable(context => context.mountNode);
|
32
29
|
const arrowRef = popoverContext_1.usePopoverContext_unstable(context => context.arrowRef);
|
33
30
|
const size = popoverContext_1.usePopoverContext_unstable(context => context.size);
|
34
|
-
const
|
31
|
+
const withArrow = popoverContext_1.usePopoverContext_unstable(context => context.withArrow);
|
35
32
|
const appearance = popoverContext_1.usePopoverContext_unstable(context => context.appearance);
|
36
33
|
const trapFocus = popoverContext_1.usePopoverContext_unstable(context => context.trapFocus);
|
34
|
+
const legacyTrapFocus = popoverContext_1.usePopoverContext_unstable(context => context.legacyTrapFocus);
|
35
|
+
const inline = popoverContext_1.usePopoverContext_unstable(context => context.inline);
|
37
36
|
const {
|
38
37
|
modalAttributes
|
39
38
|
} = react_tabster_1.useModalAttributes({
|
40
|
-
trapFocus
|
39
|
+
trapFocus,
|
40
|
+
legacyTrapFocus
|
41
41
|
});
|
42
42
|
const state = {
|
43
|
+
inline,
|
43
44
|
appearance,
|
44
|
-
|
45
|
+
withArrow,
|
45
46
|
size,
|
46
47
|
arrowRef,
|
47
|
-
open,
|
48
48
|
mountNode,
|
49
49
|
components: {
|
50
50
|
root: 'div'
|
@@ -91,15 +91,6 @@ const usePopoverSurface_unstable = (props, ref) => {
|
|
91
91
|
onKeyDownOriginal === null || onKeyDownOriginal === void 0 ? void 0 : onKeyDownOriginal(e);
|
92
92
|
};
|
93
93
|
|
94
|
-
const {
|
95
|
-
findFirstFocusable
|
96
|
-
} = react_tabster_1.useFocusFinders();
|
97
|
-
React.useEffect(() => {
|
98
|
-
if (state.open && contentRef.current) {
|
99
|
-
const firstFocusable = findFirstFocusable(contentRef.current);
|
100
|
-
firstFocusable === null || firstFocusable === void 0 ? void 0 : firstFocusable.focus();
|
101
|
-
}
|
102
|
-
}, [contentRef, findFirstFocusable, state.open]);
|
103
94
|
return state;
|
104
95
|
};
|
105
96
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["components/PopoverSurface/usePopoverSurface.ts"],"names":[],"mappings":";;;;;;;
|
1
|
+
{"version":3,"sources":["components/PopoverSurface/usePopoverSurface.ts"],"names":[],"mappings":";;;;;;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;;AACA,MAAA,gBAAA,gBAAA,OAAA,CAAA,sBAAA,CAAA;AAGA;;;;;;;;AAQG;;;AACI,MAAM,0BAA0B,GAAG,CACxC,KADwC,EAExC,GAFwC,KAGjB;EACvB,MAAM,UAAU,GAAG,gBAAA,CAAA,0BAAA,CAA2B,OAAO,IAAI,OAAO,CAAC,UAA9C,CAAnB;EACA,MAAM,WAAW,GAAG,gBAAA,CAAA,0BAAA,CAA2B,OAAO,IAAI,OAAO,CAAC,WAA9C,CAApB;EACA,MAAM,OAAO,GAAG,gBAAA,CAAA,0BAAA,CAA2B,OAAO,IAAI,OAAO,CAAC,OAA9C,CAAhB;EACA,MAAM,SAAS,GAAG,gBAAA,CAAA,0BAAA,CAA2B,OAAO,IAAI,OAAO,CAAC,SAA9C,CAAlB;EACA,MAAM,QAAQ,GAAG,gBAAA,CAAA,0BAAA,CAA2B,OAAO,IAAI,OAAO,CAAC,QAA9C,CAAjB;EACA,MAAM,IAAI,GAAG,gBAAA,CAAA,0BAAA,CAA2B,OAAO,IAAI,OAAO,CAAC,IAA9C,CAAb;EACA,MAAM,SAAS,GAAG,gBAAA,CAAA,0BAAA,CAA2B,OAAO,IAAI,OAAO,CAAC,SAA9C,CAAlB;EACA,MAAM,UAAU,GAAG,gBAAA,CAAA,0BAAA,CA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IAAN,CAAW,YAAX,GAA2B,CAAD,IAAwC;IAChE,IAAI,WAAJ,EAAiB;MACf,OAAO,CAAC,CAAD,EAAI,KAAJ,CAAP;IACD;;IAED,oBAAoB,KAAA,IAApB,IAAA,oBAAoB,KAAA,KAAA,CAApB,GAAoB,KAAA,CAApB,GAAA,oBAAoB,CAAG,CAAH,CAApB;EACD,CAND;;EAQA,KAAK,CAAC,IAAN,CAAW,SAAX,GAAwB,CAAD,IAA2C;WAAA,CAChE;IACA;;;IACA,IAAI,CAAC,CAAC,GAAF,KAAU,QAAV,KAAsB,CAAA,EAAA,GAAA,UAAU,CAAC,OAAX,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAkB,EAAA,CAAE,QAAF,CAAW,CAAC,CAAC,MAAb,CAAxC,CAAJ,EAAoF;MAClF,OAAO,CAAC,CAAD,EAAI,KAAJ,CAAP;IACD;;IAED,iBAAiB,KAAA,IAAjB,IAAA,iBAAiB,KAAA,KAAA,CAAjB,GAAiB,KAAA,CAAjB,GAAA,iBAAiB,CAAG,CAAH,CAAjB;EACD,CARD;;EAUA,OAAO,KAAP;AACD,CApEM;;AAAM,OAAA,CAAA,0BAAA,GAA0B,0BAA1B","sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, useMergedRefs } from '@fluentui/react-utilities';\nimport { useModalAttributes } from '@fluentui/react-tabster';\nimport { usePopoverContext_unstable } from '../../popoverContext';\nimport type { PopoverSurfaceProps, PopoverSurfaceState } from './PopoverSurface.types';\n\n/**\n * Create the state required to render PopoverSurface.\n *\n * The returned state can be modified with hooks such as usePopoverSurfaceStyles_unstable,\n * before being passed to renderPopoverSurface_unstable.\n *\n * @param props - props from this instance of PopoverSurface\n * @param ref - reference to root HTMLDivElement of PopoverSurface\n */\nexport const usePopoverSurface_unstable = (\n props: PopoverSurfaceProps,\n ref: React.Ref<HTMLDivElement>,\n): PopoverSurfaceState => {\n const contentRef = usePopoverContext_unstable(context => context.contentRef);\n const openOnHover = usePopoverContext_unstable(context => context.openOnHover);\n const setOpen = usePopoverContext_unstable(context => context.setOpen);\n const mountNode = usePopoverContext_unstable(context => context.mountNode);\n const arrowRef = usePopoverContext_unstable(context => context.arrowRef);\n const size = usePopoverContext_unstable(context => context.size);\n const withArrow = usePopoverContext_unstable(context => context.withArrow);\n const appearance = usePopoverContext_unstable(context => context.appearance);\n const trapFocus = usePopoverContext_unstable(context => context.trapFocus);\n const legacyTrapFocus = usePopoverContext_unstable(context => context.legacyTrapFocus);\n const inline = usePopoverContext_unstable(context => context.inline);\n const { modalAttributes } = useModalAttributes({ trapFocus, legacyTrapFocus });\n\n const state: PopoverSurfaceState = {\n inline,\n appearance,\n withArrow,\n size,\n arrowRef,\n mountNode,\n components: {\n root: 'div',\n },\n root: getNativeElementProps('div', {\n ref: useMergedRefs(ref, contentRef),\n role: trapFocus ? 'dialog' : 'complementary',\n 'aria-modal': trapFocus ? true : undefined,\n ...modalAttributes,\n ...props,\n }),\n };\n\n const {\n onMouseEnter: onMouseEnterOriginal,\n onMouseLeave: onMouseLeaveOriginal,\n onKeyDown: onKeyDownOriginal,\n } = state.root;\n state.root.onMouseEnter = (e: React.MouseEvent<HTMLDivElement>) => {\n if (openOnHover) {\n setOpen(e, true);\n }\n\n onMouseEnterOriginal?.(e);\n };\n\n state.root.onMouseLeave = (e: React.MouseEvent<HTMLDivElement>) => {\n if (openOnHover) {\n setOpen(e, false);\n }\n\n onMouseLeaveOriginal?.(e);\n };\n\n state.root.onKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n // only close if the event happened inside the current popover\n // If using a stack of inline popovers, the user should call `stopPropagation` to avoid dismissing the entire stack\n if (e.key === 'Escape' && contentRef.current?.contains(e.target as HTMLDivElement)) {\n setOpen(e, false);\n }\n\n onKeyDownOriginal?.(e);\n };\n\n return state;\n};\n"],"sourceRoot":"../src/"}
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.usePopoverSurfaceStyles_unstable = exports.arrowHeights = exports.
|
6
|
+
exports.usePopoverSurfaceStyles_unstable = exports.arrowHeights = exports.popoverSurfaceClassNames = void 0;
|
7
7
|
|
8
8
|
const react_1 = /*#__PURE__*/require("@griffel/react");
|
9
9
|
|
@@ -11,7 +11,9 @@ const react_positioning_1 = /*#__PURE__*/require("@fluentui/react-positioning");
|
|
11
11
|
|
12
12
|
const react_theme_1 = /*#__PURE__*/require("@fluentui/react-theme");
|
13
13
|
|
14
|
-
exports.
|
14
|
+
exports.popoverSurfaceClassNames = {
|
15
|
+
root: 'fui-PopoverSurface'
|
16
|
+
};
|
15
17
|
exports.arrowHeights = {
|
16
18
|
small: 6,
|
17
19
|
medium: 8,
|
@@ -25,10 +27,10 @@ const useStyles = /*#__PURE__*/react_1.__styles({
|
|
25
27
|
"root": {
|
26
28
|
"De3pzq": "fxugw4r",
|
27
29
|
"E5pizo": "f1hg901r",
|
28
|
-
"Bbmb7ep": ["
|
29
|
-
"Beyfa6y": ["
|
30
|
-
"B7oj6ja": ["
|
31
|
-
"Btl43ni": ["
|
30
|
+
"Bbmb7ep": ["f1aa9q02", "f16jpd5f"],
|
31
|
+
"Beyfa6y": ["f16jpd5f", "f1aa9q02"],
|
32
|
+
"B7oj6ja": ["f1jar5jt", "fyu767a"],
|
33
|
+
"Btl43ni": ["fyu767a", "f1jar5jt"],
|
32
34
|
"B4j52fo": "f5ogflp",
|
33
35
|
"Bekrc4i": ["f1hqa2wf", "finvdd3"],
|
34
36
|
"Bn0qgzm": "f1f09k3d",
|
@@ -81,21 +83,21 @@ const useStyles = /*#__PURE__*/react_1.__styles({
|
|
81
83
|
"De3pzq": "f1u2r49w",
|
82
84
|
"Bcdw1i0": "fd7fpy0",
|
83
85
|
"Bj3rh1h": "f1bsuimh",
|
84
|
-
"
|
85
|
-
"
|
86
|
-
"
|
87
|
-
"
|
88
|
-
"
|
89
|
-
"
|
90
|
-
"
|
91
|
-
"
|
92
|
-
"
|
93
|
-
"
|
94
|
-
"
|
95
|
-
"
|
96
|
-
"
|
97
|
-
"
|
98
|
-
"
|
86
|
+
"Ftih45": "f1wl9k8s",
|
87
|
+
"B1puzpu": "f1wkw4r9",
|
88
|
+
"Brfgrao": "f1j7ml58",
|
89
|
+
"Bcvre1j": "fyl8oag",
|
90
|
+
"Ccq8qp": "frdoeuz",
|
91
|
+
"Baz25je": "fb81m9q",
|
92
|
+
"cmx5o7": "f1ljr5q2",
|
93
|
+
"B4f6apu": "fyfemzf",
|
94
|
+
"m598lv": "focyt6c",
|
95
|
+
"Bk5zm6e": "fnhxbxj",
|
96
|
+
"y0oebl": "fdw6hkg",
|
97
|
+
"qa3bma": "f11yjt3y",
|
98
|
+
"Bqjgrrk": "f1172wan",
|
99
|
+
"Budzafs": ["f9e5op9", "f112wvtl"],
|
100
|
+
"Hv9wc6": "ftj5xct",
|
99
101
|
"hl6cv3": "f1773hnp",
|
100
102
|
"Bh2vraf": "f1n8855c",
|
101
103
|
"yayu3t": "f1v7783n",
|
@@ -106,7 +108,7 @@ const useStyles = /*#__PURE__*/react_1.__styles({
|
|
106
108
|
"Bwwlvwl": "fm1ycve"
|
107
109
|
}
|
108
110
|
}, {
|
109
|
-
"d": [".fxugw4r{background-color:var(--colorNeutralBackground1);}", ".f1hg901r{box-shadow:var(--shadow16);}", ".
|
111
|
+
"d": [".fxugw4r{background-color:var(--colorNeutralBackground1);}", ".f1hg901r{box-shadow:var(--shadow16);}", ".f1aa9q02{border-bottom-right-radius:var(--borderRadiusMedium);}", ".f16jpd5f{border-bottom-left-radius:var(--borderRadiusMedium);}", ".f1jar5jt{border-top-right-radius:var(--borderRadiusMedium);}", ".fyu767a{border-top-left-radius:var(--borderRadiusMedium);}", ".f5ogflp{border-top-width:1px;}", ".f1hqa2wf{border-right-width:1px;}", ".finvdd3{border-left-width:1px;}", ".f1f09k3d{border-bottom-width:1px;}", ".fzkkow9{border-top-style:solid;}", ".fcdblym{border-right-style:solid;}", ".fjik90z{border-left-style:solid;}", ".fg706s2{border-bottom-style:solid;}", ".fghlq4f{border-top-color:var(--colorTransparentStroke);}", ".f1gn591s{border-right-color:var(--colorTransparentStroke);}", ".fjscplz{border-left-color:var(--colorTransparentStroke);}", ".fb073pr{border-bottom-color:var(--colorTransparentStroke);}", ".f1c73kur{background-color:var(--colorNeutralForeground1);}", ".fqpbvvt{color:var(--colorNeutralForegroundInverted);}", ".ffp7eso{background-color:var(--colorBrandBackground);}", ".f1kcqot9{padding-top:12px;}", ".f11qrl6u{padding-right:12px;}", ".fjlbh76{padding-left:12px;}", ".fpe6lb7{padding-bottom:12px;}", ".fqag9an{padding-top:16px;}", ".f1gbmcue{padding-right:16px;}", ".f1rh9g5y{padding-left:16px;}", ".fp67ikv{padding-bottom:16px;}", ".fc7z3ec{padding-top:20px;}", ".fat0sn4{padding-right:20px;}", ".fekwl8i{padding-left:20px;}", ".fe2my4m{padding-bottom:20px;}", ".f1ekdpwm{width:8.484px;}", ".f83vc9z{height:8.484px;}", ".f1kmc0fn{width:11.312px;}", ".fb6lvc5{height:11.312px;}", ".f1euv43f{position:absolute;}", ".f1u2r49w{background-color:inherit;}", ".fd7fpy0{visibility:hidden;}", ".f1bsuimh{z-index:-1;}", ".f1wl9k8s::before{content:\"\";}", ".f1wkw4r9::before{visibility:visible;}", ".f1j7ml58::before{position:absolute;}", ".fyl8oag::before{box-sizing:border-box;}", ".frdoeuz::before{width:inherit;}", ".fb81m9q::before{height:inherit;}", ".f1ljr5q2::before{background-color:inherit;}", ".fyfemzf::before{border-right-width:1px;}", ".focyt6c::before{border-right-style:solid;}", ".fnhxbxj::before{border-right-color:var(--colorTransparentStroke);}", ".fdw6hkg::before{border-bottom-width:1px;}", ".f11yjt3y::before{border-bottom-style:solid;}", ".f1172wan::before{border-bottom-color:var(--colorTransparentStroke);}", ".f9e5op9::before{border-bottom-right-radius:var(--borderRadiusSmall);}", ".f112wvtl::before{border-bottom-left-radius:var(--borderRadiusSmall);}", ".ftj5xct::before{-webkit-transform:rotate(var(--angle)) translate(0, 50%) rotate(45deg);-moz-transform:rotate(var(--angle)) translate(0, 50%) rotate(45deg);-ms-transform:rotate(var(--angle)) translate(0, 50%) rotate(45deg);transform:rotate(var(--angle)) translate(0, 50%) rotate(45deg);}", "[data-popper-placement^=\"top\"] .f1773hnp{bottom:-1px;}", "[data-popper-placement^=\"top\"] .f1n8855c{--angle:0;}", "[data-popper-placement^=\"right\"] .f1v7783n{left:-1px;}", "[data-popper-placement^=\"right\"] .fsw6im5{--angle:90deg;}", "[data-popper-placement^=\"bottom\"] .fh2hsk5{top:-1px;}", "[data-popper-placement^=\"bottom\"] .f159pzir{--angle:180deg;}", "[data-popper-placement^=\"left\"] .f11yvu4{right:-1px;}", "[data-popper-placement^=\"left\"] .fm1ycve{--angle:270deg;}"]
|
110
112
|
});
|
111
113
|
/**
|
112
114
|
* Apply styling to the PopoverSurface slots based on the state
|
@@ -115,7 +117,7 @@ const useStyles = /*#__PURE__*/react_1.__styles({
|
|
115
117
|
|
116
118
|
const usePopoverSurfaceStyles_unstable = state => {
|
117
119
|
const styles = useStyles();
|
118
|
-
state.root.className = react_1.mergeClasses(exports.
|
120
|
+
state.root.className = react_1.mergeClasses(exports.popoverSurfaceClassNames.root, styles.root, state.size === 'small' && styles.smallPadding, state.size === 'medium' && styles.mediumPadding, state.size === 'large' && styles.largePadding, state.appearance === 'inverted' && styles.inverted, state.appearance === 'brand' && styles.brand, state.root.className);
|
119
121
|
state.arrowClassName = react_1.mergeClasses(styles.arrow, state.size === 'small' ? styles.smallArrow : styles.mediumLargeArrow);
|
120
122
|
return state;
|
121
123
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["components/PopoverSurface/usePopoverSurfaceStyles.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,OAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AACA,MAAA,mBAAA,gBAAA,OAAA,CAAA,6BAAA,CAAA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EAErB,MAAM,CAAC,IAFc,EAGrB,KAAK,CAAC,IAAN,KAAe,OAAf,IAA0B,MAAM,CAAC,YAHZ,EAIrB,KAAK,CAAC,IAAN,KAAe,QAAf,IAA2B,MAAM,CAAC,aAJb,EAKrB,KAAK,CAAC,IAAN,KAAe,OAAf,IAA0B,MAAM,CAAC,YALZ,EAMrB,KAAK,CAAC,UAAN,KAAqB,UAArB,IAAmC,MAAM,CAAC,QANrB,EAOrB,KAAK,CAAC,UAAN,KAAqB,OAArB,IAAgC,MAAM,CAAC,KAPlB,EAQrB,KAAK,CAAC,IAAN,CAAW,SARU,CAAvB;EAWA,KAAK,CAAC,cAAN,GAAuB,OAAA,CAAA,YAAA,CACrB,MAAM,CAAC,KADc,EAErB,KAAK,CAAC,IAAN,KAAe,OAAf,GAAyB,MAAM,CAAC,UAAhC,GAA6C,MAAM,CAAC,gBAF/B,CAAvB;EAKA,OAAO,KAAP;AACD,CAnBM;;AAAM,OAAA,CAAA,gCAAA,GAAgC,gCAAhC","sourcesContent":["import { shorthands, makeStyles, mergeClasses } from '@griffel/react';\nimport { createArrowHeightStyles, createArrowStyles } from '@fluentui/react-positioning';\nimport { tokens } from '@fluentui/react-theme';\nimport type { PopoverSize } from '../Popover/Popover.types';\nimport type { PopoverSurfaceSlots, PopoverSurfaceState } from './PopoverSurface.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\nexport const popoverSurfaceClassNames: SlotClassNames<PopoverSurfaceSlots> = {\n root: 'fui-PopoverSurface',\n};\n\nexport const arrowHeights: Record<PopoverSize, number> = {\n small: 6,\n medium: 8,\n large: 8,\n};\n\n/**\n * Styles for the root slot\n */\nconst useStyles = makeStyles({\n root: {\n backgroundColor: tokens.colorNeutralBackground1,\n boxShadow: tokens.shadow16,\n ...shorthands.borderRadius(tokens.borderRadiusMedium),\n ...shorthands.border('1px', 'solid', tokens.colorTransparentStroke),\n },\n\n inverted: {\n // TODO: neutral background inverted missing from superset and theme\n backgroundColor: tokens.colorNeutralForeground1,\n color: tokens.colorNeutralForegroundInverted,\n },\n\n brand: {\n backgroundColor: tokens.colorBrandBackground,\n // TODO: clarify with designers what foreground color should be with brand background,\n color: tokens.colorNeutralForegroundInverted,\n },\n\n smallPadding: {\n ...shorthands.padding('12px'),\n },\n\n mediumPadding: {\n ...shorthands.padding('16px'),\n },\n\n largePadding: {\n ...shorthands.padding('20px'),\n },\n\n smallArrow: createArrowHeightStyles(arrowHeights.small),\n mediumLargeArrow: createArrowHeightStyles(arrowHeights.medium),\n arrow: createArrowStyles({ arrowHeight: undefined }),\n});\n\n/**\n * Apply styling to the PopoverSurface slots based on the state\n */\nexport const usePopoverSurfaceStyles_unstable = (state: PopoverSurfaceState): PopoverSurfaceState => {\n const styles = useStyles();\n state.root.className = mergeClasses(\n popoverSurfaceClassNames.root,\n styles.root,\n state.size === 'small' && styles.smallPadding,\n state.size === 'medium' && styles.mediumPadding,\n state.size === 'large' && styles.largePadding,\n state.appearance === 'inverted' && styles.inverted,\n state.appearance === 'brand' && styles.brand,\n state.root.className,\n );\n\n state.arrowClassName = mergeClasses(\n styles.arrow,\n state.size === 'small' ? styles.smallArrow : styles.mediumLargeArrow,\n );\n\n return state;\n};\n"],"sourceRoot":"../src/"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["components/PopoverTrigger/PopoverTrigger.tsx"],"names":[],"mappings":";;;;;;;AACA,MAAA,mBAAA,gBAAA,OAAA,CAAA,qBAAA,CAAA;;AACA,MAAA,sBAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;AAIA;;AAEG;;;AACI,MAAM,cAAc,GAA2D,KAAK,IAAG;
|
1
|
+
{"version":3,"sources":["components/PopoverTrigger/PopoverTrigger.tsx"],"names":[],"mappings":";;;;;;;AACA,MAAA,mBAAA,gBAAA,OAAA,CAAA,qBAAA,CAAA;;AACA,MAAA,sBAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;AAIA;;AAEG;;;AACI,MAAM,cAAc,GAA2D,KAAK,IAAG;EAC5F,MAAM,KAAK,GAAG,mBAAA,CAAA,0BAAA,CAA2B,KAA3B,CAAd;EAEA,OAAO,sBAAA,CAAA,6BAAA,CAA8B,KAA9B,CAAP;AACD,CAJM;;AAAM,OAAA,CAAA,cAAA,GAAc,cAAd;AAMb,OAAA,CAAA,cAAA,CAAe,WAAf,GAA6B,gBAA7B;AACA,OAAA,CAAA,cAAA,CAAe,wBAAf,GAA0C,IAA1C","sourcesContent":["import * as React from 'react';\nimport { usePopoverTrigger_unstable } from './usePopoverTrigger';\nimport { renderPopoverTrigger_unstable } from './renderPopoverTrigger';\nimport type { FluentTriggerComponent } from '@fluentui/react-utilities';\nimport type { PopoverTriggerProps } from './PopoverTrigger.types';\n\n/**\n * Wraps a trigger element as an only child and adds the necessary event handling to open a popover.\n */\nexport const PopoverTrigger: React.FC<PopoverTriggerProps> & FluentTriggerComponent = props => {\n const state = usePopoverTrigger_unstable(props);\n\n return renderPopoverTrigger_unstable(state);\n};\n\nPopoverTrigger.displayName = 'PopoverTrigger';\nPopoverTrigger.isFluentTriggerComponent = true;\n"],"sourceRoot":"../src/"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["components/PopoverTrigger/renderPopoverTrigger.tsx"],"names":[],"mappings":";;;;;;AAEA;;AAEG;;AACI,MAAM,6BAA6B,GAAI,KAAD,IAA+B;
|
1
|
+
{"version":3,"sources":["components/PopoverTrigger/renderPopoverTrigger.tsx"],"names":[],"mappings":";;;;;;AAEA;;AAEG;;AACI,MAAM,6BAA6B,GAAI,KAAD,IAA+B;EAC1E,OAAO,KAAK,CAAC,QAAb;AACD,CAFM;;AAAM,OAAA,CAAA,6BAAA,GAA6B,6BAA7B","sourcesContent":["import type { PopoverTriggerState } from './PopoverTrigger.types';\n\n/**\n * Render the final JSX of PopoverTrigger\n */\nexport const renderPopoverTrigger_unstable = (state: PopoverTriggerState) => {\n return state.children;\n};\n"],"sourceRoot":"../src/"}
|
@@ -29,12 +29,12 @@ const usePopoverTrigger_unstable = props => {
|
|
29
29
|
children
|
30
30
|
} = props;
|
31
31
|
const child = React.isValidElement(children) ? react_utilities_1.getTriggerChild(children) : undefined;
|
32
|
-
const setOpen = popoverContext_1.usePopoverContext_unstable(context => context.setOpen);
|
33
32
|
const open = popoverContext_1.usePopoverContext_unstable(context => context.open);
|
33
|
+
const setOpen = popoverContext_1.usePopoverContext_unstable(context => context.setOpen);
|
34
|
+
const toggleOpen = popoverContext_1.usePopoverContext_unstable(context => context.toggleOpen);
|
34
35
|
const triggerRef = popoverContext_1.usePopoverContext_unstable(context => context.triggerRef);
|
35
36
|
const openOnHover = popoverContext_1.usePopoverContext_unstable(context => context.openOnHover);
|
36
37
|
const openOnContext = popoverContext_1.usePopoverContext_unstable(context => context.openOnContext);
|
37
|
-
const trapFocus = popoverContext_1.usePopoverContext_unstable(context => context.trapFocus);
|
38
38
|
const {
|
39
39
|
triggerAttributes
|
40
40
|
} = react_tabster_1.useModalAttributes();
|
@@ -48,7 +48,7 @@ const usePopoverTrigger_unstable = props => {
|
|
48
48
|
|
49
49
|
const onClick = e => {
|
50
50
|
if (!openOnContext) {
|
51
|
-
|
51
|
+
toggleOpen(e);
|
52
52
|
}
|
53
53
|
};
|
54
54
|
|
@@ -79,7 +79,7 @@ const usePopoverTrigger_unstable = props => {
|
|
79
79
|
|
80
80
|
return {
|
81
81
|
children: react_utilities_1.applyTriggerPropsToChildren(props.children, { ...triggerAttributes,
|
82
|
-
'aria-
|
82
|
+
'aria-expanded': `${open}`,
|
83
83
|
...(child === null || child === void 0 ? void 0 : child.props),
|
84
84
|
onClick: react_utilities_1.useMergedEventCallbacks((_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.onClick, onClick),
|
85
85
|
onMouseEnter: react_utilities_1.useMergedEventCallbacks((_b = child === null || child === void 0 ? void 0 : child.props) === null || _b === void 0 ? void 0 : _b.onMouseEnter, onMouseEnter),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["components/PopoverTrigger/usePopoverTrigger.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AAQA,MAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;;AACA,MAAA,gBAAA,gBAAA,OAAA,CAAA,sBAAA,CAAA;AAGA;;;;;;;AAOG;;;AACI,MAAM,0BAA0B,GAAI,KAAD,IAAoD;;;
|
1
|
+
{"version":3,"sources":["components/PopoverTrigger/usePopoverTrigger.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AAQA,MAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;;AACA,MAAA,gBAAA,gBAAA,OAAA,CAAA,sBAAA,CAAA;AAGA;;;;;;;AAOG;;;AACI,MAAM,0BAA0B,GAAI,KAAD,IAAoD;;;EAC5F,MAAM;IAAE;EAAF,IAAe,KAArB;EACA,MAAM,KAAK,GAAG,KAAK,CAAC,cAAN,CAAqB,QAArB,IACV,iBAAA,CAAA,eAAA,CAAmD,QAAnD,CADU,GAEV,SAFJ;EAIA,MAAM,IAAI,GAAG,gBAAA,CAAA,0BAAA,CAA2B,OAAO,IAAI,OAAO,CAAC,IAA9C,CAAb;EACA,MAAM,OAAO,GAAG,gBAAA,CAAA,0BAAA,CAA2B,OAAO,IAAI,OAAO,CAAC,OAA9C,CAAhB;EACA,MAAM,UAAU,GAAG,gBAAA,CAAA,0BAAA,CAA2B,OAAO,IAAI,OAAO,CAAC,UAA9C,CAAnB;EACA,MAAM,UAAU,GAAG,gBAAA,CAAA,0BAAA,CAA2B,OAAO,IAAI,OAAO,CAAC,UAA9C,CAAnB;EACA,MAAM,WAAW,GAAG,gBAAA,CAAA,0BAAA,CAA2B,OAAO,IAAI,OAA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AApD,CAPgE;MAQ9E,aAAa,EAAE,iBAAA,CAAA,uBAAA,CAAwB,CAAA,EAAA,GAAA,KAAK,KAAA,IAAL,IAAA,KAAK,KAAA,KAAA,CAAL,GAAK,KAAA,CAAL,GAAA,KAAK,CAAE,KAAP,MAAY,IAAZ,IAAY,EAAA,KAAA,KAAA,CAAZ,GAAY,KAAA,CAAZ,GAAY,EAAA,CAAE,aAAtC,EAAqD,aAArD,CAR+D;MAS9E,GAAG,EAAE,iBAAA,CAAA,aAAA,CAAc,UAAd,EAA0B,KAAK,KAAA,IAAL,IAAA,KAAK,KAAA,KAAA,CAAL,GAAK,KAAA,CAAL,GAAA,KAAK,CAAE,GAAjC;IATyE,CAAtE;EADL,CAAP;AAaD,CA/DM;;AAAM,OAAA,CAAA,0BAAA,GAA0B,0BAA1B","sourcesContent":["import * as React from 'react';\nimport {\n applyTriggerPropsToChildren,\n getTriggerChild,\n shouldPreventDefaultOnKeyDown,\n useMergedRefs,\n useMergedEventCallbacks,\n useEventCallback,\n} from '@fluentui/react-utilities';\nimport { useModalAttributes } from '@fluentui/react-tabster';\nimport { usePopoverContext_unstable } from '../../popoverContext';\nimport type { PopoverTriggerChildProps, PopoverTriggerProps, PopoverTriggerState } from './PopoverTrigger.types';\n\n/**\n * Create the state required to render PopoverTrigger.\n *\n * The returned state can be modified with hooks such as usePopoverTriggerStyles,\n * before being passed to renderPopoverTrigger_unstable.\n *\n * @param props - props from this instance of PopoverTrigger\n */\nexport const usePopoverTrigger_unstable = (props: PopoverTriggerProps): PopoverTriggerState => {\n const { children } = props;\n const child = React.isValidElement(children)\n ? getTriggerChild<Partial<PopoverTriggerChildProps>>(children)\n : undefined;\n\n const open = usePopoverContext_unstable(context => context.open);\n const setOpen = usePopoverContext_unstable(context => context.setOpen);\n const toggleOpen = usePopoverContext_unstable(context => context.toggleOpen);\n const triggerRef = usePopoverContext_unstable(context => context.triggerRef);\n const openOnHover = usePopoverContext_unstable(context => context.openOnHover);\n const openOnContext = usePopoverContext_unstable(context => context.openOnContext);\n const { triggerAttributes } = useModalAttributes();\n\n const onContextMenu = (e: React.MouseEvent<HTMLElement>) => {\n if (openOnContext) {\n e.preventDefault();\n setOpen(e, true);\n }\n };\n\n const onClick = (e: React.MouseEvent<HTMLElement>) => {\n if (!openOnContext) {\n toggleOpen(e);\n }\n };\n\n const onKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {\n if (shouldPreventDefaultOnKeyDown(e) && (e.key === ' ' || e.key === 'Enter')) {\n e.preventDefault();\n (e.target as HTMLElement)?.click();\n }\n\n if (e.key === 'Escape') {\n setOpen(e, false);\n }\n };\n\n const onMouseEnter = useEventCallback((e: React.MouseEvent<HTMLElement>) => {\n if (openOnHover) {\n setOpen(e, true);\n }\n });\n\n const onMouseLeave = (e: React.MouseEvent<HTMLElement>) => {\n if (openOnHover) {\n setOpen(e, false);\n }\n };\n\n return {\n children: applyTriggerPropsToChildren<PopoverTriggerChildProps>(props.children, {\n ...triggerAttributes,\n 'aria-expanded': `${open}`,\n ...child?.props,\n onClick: useMergedEventCallbacks(child?.props?.onClick, onClick),\n onMouseEnter: useMergedEventCallbacks(child?.props?.onMouseEnter, onMouseEnter),\n onKeyDown: useMergedEventCallbacks(child?.props?.onKeyDown, onKeyDown),\n onMouseLeave: useMergedEventCallbacks(child?.props?.onMouseLeave, onMouseLeave),\n onContextMenu: useMergedEventCallbacks(child?.props?.onContextMenu, onContextMenu),\n ref: useMergedRefs(triggerRef, child?.ref),\n }),\n };\n};\n"],"sourceRoot":"../src/"}
|