@fluentui/react-popover 9.3.4 → 9.3.6
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 +111 -1
- package/CHANGELOG.md +31 -2
- package/lib/components/Popover/Popover.js +0 -1
- package/lib/components/Popover/Popover.js.map +1 -1
- package/lib/components/Popover/renderPopover.js +0 -1
- package/lib/components/Popover/renderPopover.js.map +1 -1
- package/lib/components/Popover/usePopover.js +8 -26
- package/lib/components/Popover/usePopover.js.map +1 -1
- package/lib/components/PopoverSurface/PopoverSurface.js +0 -1
- package/lib/components/PopoverSurface/PopoverSurface.js.map +1 -1
- package/lib/components/PopoverSurface/renderPopoverSurface.js +2 -4
- package/lib/components/PopoverSurface/renderPopoverSurface.js.map +1 -1
- package/lib/components/PopoverSurface/usePopoverSurface.js +2 -11
- package/lib/components/PopoverSurface/usePopoverSurface.js.map +1 -1
- package/lib/components/PopoverSurface/usePopoverSurfaceStyles.js +80 -83
- package/lib/components/PopoverSurface/usePopoverSurfaceStyles.js.map +1 -1
- package/lib/components/PopoverTrigger/PopoverTrigger.js +2 -3
- package/lib/components/PopoverTrigger/PopoverTrigger.js.map +1 -1
- package/lib/components/PopoverTrigger/renderPopoverTrigger.js.map +1 -1
- package/lib/components/PopoverTrigger/usePopoverTrigger.js +6 -11
- package/lib/components/PopoverTrigger/usePopoverTrigger.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/popoverContext.js.map +1 -1
- package/lib-commonjs/Popover.js +0 -2
- package/lib-commonjs/Popover.js.map +1 -1
- package/lib-commonjs/PopoverSurface.js +0 -2
- package/lib-commonjs/PopoverSurface.js.map +1 -1
- package/lib-commonjs/PopoverTrigger.js +0 -2
- package/lib-commonjs/PopoverTrigger.js.map +1 -1
- package/lib-commonjs/components/Popover/Popover.js +0 -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/constants.js +0 -1
- package/lib-commonjs/components/Popover/constants.js.map +1 -1
- package/lib-commonjs/components/Popover/index.js +0 -5
- package/lib-commonjs/components/Popover/index.js.map +1 -1
- package/lib-commonjs/components/Popover/renderPopover.js +0 -5
- package/lib-commonjs/components/Popover/renderPopover.js.map +1 -1
- package/lib-commonjs/components/Popover/usePopover.js +8 -36
- package/lib-commonjs/components/Popover/usePopover.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/PopoverSurface.js +0 -6
- 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 +0 -6
- package/lib-commonjs/components/PopoverSurface/index.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.js +2 -9
- package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/usePopoverSurface.js +2 -16
- package/lib-commonjs/components/PopoverSurface/usePopoverSurface.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.js +80 -88
- package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.js.map +1 -1
- package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.js +2 -7
- 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 +0 -5
- package/lib-commonjs/components/PopoverTrigger/index.js.map +1 -1
- package/lib-commonjs/components/PopoverTrigger/renderPopoverTrigger.js +0 -2
- package/lib-commonjs/components/PopoverTrigger/renderPopoverTrigger.js.map +1 -1
- package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.js +6 -18
- package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.js.map +1 -1
- package/lib-commonjs/index.js +0 -8
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/popoverContext.js +0 -4
- package/lib-commonjs/popoverContext.js.map +1 -1
- package/package.json +12 -12
|
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.usePopover_unstable = void 0;
|
|
7
|
-
|
|
8
7
|
const React = /*#__PURE__*/require("react");
|
|
9
|
-
|
|
10
8
|
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
|
11
|
-
|
|
12
9
|
const react_shared_contexts_1 = /*#__PURE__*/require("@fluentui/react-shared-contexts");
|
|
13
|
-
|
|
14
10
|
const react_positioning_1 = /*#__PURE__*/require("@fluentui/react-positioning");
|
|
15
|
-
|
|
16
11
|
const react_portal_1 = /*#__PURE__*/require("@fluentui/react-portal");
|
|
17
|
-
|
|
18
12
|
const react_tabster_1 = /*#__PURE__*/require("@fluentui/react-tabster");
|
|
19
|
-
|
|
20
13
|
const index_1 = /*#__PURE__*/require("../PopoverSurface/index");
|
|
21
|
-
|
|
22
14
|
const constants_1 = /*#__PURE__*/require("./constants");
|
|
23
15
|
/**
|
|
24
16
|
* Create the state required to render Popover.
|
|
@@ -28,11 +20,8 @@ const constants_1 = /*#__PURE__*/require("./constants");
|
|
|
28
20
|
*
|
|
29
21
|
* @param props - props from this instance of Popover
|
|
30
22
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
23
|
const usePopover_unstable = props => {
|
|
34
24
|
var _a;
|
|
35
|
-
|
|
36
25
|
const [contextTarget, setContextTarget] = react_positioning_1.usePositioningMouseTarget();
|
|
37
26
|
const initialState = {
|
|
38
27
|
size: 'medium',
|
|
@@ -41,41 +30,33 @@ const usePopover_unstable = props => {
|
|
|
41
30
|
...props
|
|
42
31
|
};
|
|
43
32
|
const children = React.Children.toArray(props.children);
|
|
44
|
-
|
|
45
33
|
if (process.env.NODE_ENV !== 'production') {
|
|
46
34
|
if (children.length === 0) {
|
|
47
35
|
// eslint-disable-next-line no-console
|
|
48
36
|
console.warn('Popover must contain at least one child');
|
|
49
37
|
}
|
|
50
|
-
|
|
51
38
|
if (children.length > 2) {
|
|
52
39
|
// eslint-disable-next-line no-console
|
|
53
40
|
console.warn('Popover must contain at most two children');
|
|
54
41
|
}
|
|
55
42
|
}
|
|
56
|
-
|
|
57
43
|
let popoverTrigger = undefined;
|
|
58
44
|
let popoverSurface = undefined;
|
|
59
|
-
|
|
60
45
|
if (children.length === 2) {
|
|
61
46
|
popoverTrigger = children[0];
|
|
62
47
|
popoverSurface = children[1];
|
|
63
48
|
} else if (children.length === 1) {
|
|
64
49
|
popoverSurface = children[0];
|
|
65
50
|
}
|
|
66
|
-
|
|
67
51
|
const [open, setOpenState] = useOpenState(initialState);
|
|
68
52
|
const setOpenTimeoutRef = React.useRef(0);
|
|
69
53
|
const setOpen = react_utilities_1.useEventCallback((e, shouldOpen) => {
|
|
70
54
|
var _a;
|
|
71
|
-
|
|
72
55
|
clearTimeout(setOpenTimeoutRef.current);
|
|
73
|
-
|
|
74
56
|
if (!(e instanceof Event) && e.persist) {
|
|
75
57
|
// < React 17 still uses pooled synthetic events
|
|
76
58
|
e.persist();
|
|
77
59
|
}
|
|
78
|
-
|
|
79
60
|
if (e.type === 'mouseleave') {
|
|
80
61
|
// FIXME leaking Node timeout type
|
|
81
62
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -86,9 +67,9 @@ const usePopover_unstable = props => {
|
|
|
86
67
|
} else {
|
|
87
68
|
setOpenState(e, shouldOpen);
|
|
88
69
|
}
|
|
89
|
-
});
|
|
70
|
+
});
|
|
71
|
+
// Clear timeout on unmount
|
|
90
72
|
// Setting state after a component unmounts can cause memory leaks
|
|
91
|
-
|
|
92
73
|
React.useEffect(() => {
|
|
93
74
|
return () => {
|
|
94
75
|
clearTimeout(setOpenTimeoutRef.current);
|
|
@@ -107,8 +88,8 @@ const usePopover_unstable = props => {
|
|
|
107
88
|
callback: ev => setOpen(ev, false),
|
|
108
89
|
refs: [positioningRefs.triggerRef, positioningRefs.contentRef],
|
|
109
90
|
disabled: !open
|
|
110
|
-
});
|
|
111
|
-
|
|
91
|
+
});
|
|
92
|
+
// only close on scroll for context, or when closeOnScroll is specified
|
|
112
93
|
const closeOnScroll = initialState.openOnContext || initialState.closeOnScroll;
|
|
113
94
|
react_utilities_1.useOnScrollOutside({
|
|
114
95
|
contains: react_portal_1.elementContains,
|
|
@@ -122,14 +103,14 @@ const usePopover_unstable = props => {
|
|
|
122
103
|
} = react_tabster_1.useFocusFinders();
|
|
123
104
|
React.useEffect(() => {
|
|
124
105
|
var _a;
|
|
125
|
-
|
|
126
106
|
if (open && positioningRefs.contentRef.current) {
|
|
127
107
|
const containerTabIndex = (_a = positioningRefs.contentRef.current.getAttribute('tabIndex')) !== null && _a !== void 0 ? _a : undefined;
|
|
128
108
|
const firstFocusable = isNaN(containerTabIndex) ? findFirstFocusable(positioningRefs.contentRef.current) : positioningRefs.contentRef.current;
|
|
129
109
|
firstFocusable === null || firstFocusable === void 0 ? void 0 : firstFocusable.focus();
|
|
130
110
|
}
|
|
131
111
|
}, [findFirstFocusable, open, positioningRefs.contentRef]);
|
|
132
|
-
return {
|
|
112
|
+
return {
|
|
113
|
+
...initialState,
|
|
133
114
|
...positioningRefs,
|
|
134
115
|
popoverTrigger,
|
|
135
116
|
popoverSurface,
|
|
@@ -141,16 +122,13 @@ const usePopover_unstable = props => {
|
|
|
141
122
|
inline: (_a = props.inline) !== null && _a !== void 0 ? _a : false
|
|
142
123
|
};
|
|
143
124
|
};
|
|
144
|
-
|
|
145
125
|
exports.usePopover_unstable = usePopover_unstable;
|
|
146
126
|
/**
|
|
147
127
|
* Creates and manages the Popover open state
|
|
148
128
|
*/
|
|
149
|
-
|
|
150
129
|
function useOpenState(state) {
|
|
151
130
|
const onOpenChange = react_utilities_1.useEventCallback((e, data) => {
|
|
152
131
|
var _a;
|
|
153
|
-
|
|
154
132
|
return (_a = state.onOpenChange) === null || _a === void 0 ? void 0 : _a.call(state, e, data);
|
|
155
133
|
});
|
|
156
134
|
const [open, setOpenState] = react_utilities_1.useControllableState({
|
|
@@ -164,11 +142,9 @@ function useOpenState(state) {
|
|
|
164
142
|
if (shouldOpen && e.type === 'contextmenu') {
|
|
165
143
|
setContextTarget(e);
|
|
166
144
|
}
|
|
167
|
-
|
|
168
145
|
if (!shouldOpen) {
|
|
169
146
|
setContextTarget(undefined);
|
|
170
147
|
}
|
|
171
|
-
|
|
172
148
|
setOpenState(shouldOpen);
|
|
173
149
|
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(e, {
|
|
174
150
|
open: shouldOpen
|
|
@@ -179,8 +155,6 @@ function useOpenState(state) {
|
|
|
179
155
|
/**
|
|
180
156
|
* Creates and sets the necessary trigger, target and content refs used by Popover
|
|
181
157
|
*/
|
|
182
|
-
|
|
183
|
-
|
|
184
158
|
function usePopoverRefs(state) {
|
|
185
159
|
const positioningOptions = {
|
|
186
160
|
position: 'above',
|
|
@@ -188,16 +162,14 @@ function usePopoverRefs(state) {
|
|
|
188
162
|
arrowPadding: 2 * constants_1.popoverSurfaceBorderRadius,
|
|
189
163
|
target: state.openOnContext ? state.contextTarget : undefined,
|
|
190
164
|
...react_positioning_1.resolvePositioningShorthand(state.positioning)
|
|
191
|
-
};
|
|
192
|
-
|
|
165
|
+
};
|
|
166
|
+
// no reason to render arrow when covering the target
|
|
193
167
|
if (positioningOptions.coverTarget) {
|
|
194
168
|
state.withArrow = false;
|
|
195
169
|
}
|
|
196
|
-
|
|
197
170
|
if (state.withArrow) {
|
|
198
171
|
positioningOptions.offset = react_positioning_1.mergeArrowOffset(positioningOptions.offset, index_1.arrowHeights[state.size]);
|
|
199
172
|
}
|
|
200
|
-
|
|
201
173
|
const {
|
|
202
174
|
targetRef: triggerRef,
|
|
203
175
|
containerRef: contentRef,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-popover/src/components/Popover/usePopover.ts"],"names":[],"mappings":";;;;;;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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 containerTabIndex = positioningRefs.contentRef.current.getAttribute('tabIndex') ?? undefined;\n const firstFocusable = isNaN(containerTabIndex)\n ? findFirstFocusable(positioningRefs.contentRef.current)\n : 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(shouldOpen);\n onOpenChange?.(e, { open: shouldOpen });\n },\n [setOpenState, onOpenChange, setContextTarget],\n );\n\n return [open, setOpen] as const;\n}\n\n/**\n * Creates and sets the necessary trigger, target and content refs used by Popover\n */\nfunction usePopoverRefs(\n state: Pick<PopoverState, 'size' | 'contextTarget'> &\n Pick<PopoverProps, 'positioning' | 'openOnContext' | 'withArrow'>,\n) {\n const positioningOptions = {\n position: 'above' as const,\n align: 'center' as const,\n arrowPadding: 2 * popoverSurfaceBorderRadius,\n target: state.openOnContext ? state.contextTarget : undefined,\n ...resolvePositioningShorthand(state.positioning),\n };\n\n // no reason to render arrow when covering the target\n if (positioningOptions.coverTarget) {\n 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
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AAMA;AACA;AAMA;AACA;AACA;AAEA;AAEA;;;;;;;;AAQO,MAAMA,mBAAmB,GAAIC,KAAmB,IAAkB;;EACvE,MAAM,CAACC,aAAa,EAAEC,gBAAgB,CAAC,GAAGC,6CAAyB,EAAE;EACrE,MAAMC,YAAY,GAAG;IACnBC,IAAI,EAAE,QAAQ;IACdJ,aAAa;IACbC,gBAAgB;IAChB,GAAGF;GACK;EA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AAE,GAAG7E,kCAAc,CAACgE,kBAAkB,CAAC;EAExG,OAAO;IACLnB,UAAU;IACVC,UAAU;IACV+B;GACQ;AACZ","names":["usePopover_unstable","props","contextTarget","setContextTarget","react_positioning_1","initialState","size","children","React","Children","toArray","process","env","NODE_ENV","length","console","warn","popoverTrigger","undefined","popoverSurface","open","setOpenState","useOpenState","setOpenTimeoutRef","useRef","setOpen","react_utilities_1","e","shouldOpen","clearTimeout","current","Event","persist","type","setTimeout","mouseLeaveDelay","useEffect","toggleOpen","useCallback","positioningRefs","usePopoverRefs","targetDocument","react_shared_contexts_1","contains","react_portal_1","element","callback","ev","refs","triggerRef","contentRef","disabled","closeOnScroll","openOnContext","findFirstFocusable","react_tabster_1","containerTabIndex","getAttribute","firstFocusable","isNaN","focus","inline","exports","state","onOpenChange","data","defaultState","defaultOpen","positioningOptions","position","align","arrowPadding","constants_1","target","positioning","coverTarget","withArrow","offset","index_1","targetRef","containerRef","arrowRef"],"sourceRoot":"../src/","sources":["packages/react-components/react-popover/src/components/Popover/usePopover.ts"],"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 containerTabIndex = positioningRefs.contentRef.current.getAttribute('tabIndex') ?? undefined;\n const firstFocusable = isNaN(containerTabIndex)\n ? findFirstFocusable(positioningRefs.contentRef.current)\n : 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(shouldOpen);\n onOpenChange?.(e, { open: shouldOpen });\n },\n [setOpenState, onOpenChange, setContextTarget],\n );\n\n return [open, setOpen] as const;\n}\n\n/**\n * Creates and sets the necessary trigger, target and content refs used by Popover\n */\nfunction usePopoverRefs(\n state: Pick<PopoverState, 'size' | 'contextTarget'> &\n Pick<PopoverProps, 'positioning' | 'openOnContext' | 'withArrow'>,\n) {\n const positioningOptions = {\n position: 'above' as const,\n align: 'center' as const,\n arrowPadding: 2 * popoverSurfaceBorderRadius,\n target: state.openOnContext ? state.contextTarget : undefined,\n ...resolvePositioningShorthand(state.positioning),\n };\n\n // no reason to render arrow when covering the target\n if (positioningOptions.coverTarget) {\n 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"]}
|
|
@@ -4,19 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.PopoverSurface = void 0;
|
|
7
|
-
|
|
8
7
|
const React = /*#__PURE__*/require("react");
|
|
9
|
-
|
|
10
8
|
const usePopoverSurface_1 = /*#__PURE__*/require("./usePopoverSurface");
|
|
11
|
-
|
|
12
9
|
const renderPopoverSurface_1 = /*#__PURE__*/require("./renderPopoverSurface");
|
|
13
|
-
|
|
14
10
|
const usePopoverSurfaceStyles_1 = /*#__PURE__*/require("./usePopoverSurfaceStyles");
|
|
15
11
|
/**
|
|
16
12
|
* PopoverSurface component renders react children in a positioned box
|
|
17
13
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
14
|
exports.PopoverSurface = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
21
15
|
const state = usePopoverSurface_1.usePopoverSurface_unstable(props, ref);
|
|
22
16
|
usePopoverSurfaceStyles_1.usePopoverSurfaceStyles_unstable(state);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AACA;AACA;AAIA;;;AAGaA,sBAAc,gBAA6CC,KAAK,CAACC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAI;EACtG,MAAMC,KAAK,GAAGC,8CAA0B,CAACH,KAAK,EAAEC,GAAG,CAAC;EAEpDG,0DAAgC,CAACF,KAAK,CAAC;EACvC,OAAOG,oDAA6B,CAACH,KAAK,CAAC;AAC7C,CAAC,CAAC;AAEFL,sBAAc,CAACS,WAAW,GAAG,gBAAgB","names":["exports","React","forwardRef","props","ref","state","usePopoverSurface_1","usePopoverSurfaceStyles_1","renderPopoverSurface_1","displayName"],"sourceRoot":"../src/","sources":["packages/react-components/react-popover/src/components/PopoverSurface/PopoverSurface.tsx"],"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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"mappings":"","names":[],"sourceRoot":"../src/","sources":[],"sourcesContent":[]}
|
|
@@ -3,16 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
6
|
const tslib_1 = /*#__PURE__*/require("tslib");
|
|
8
|
-
|
|
9
7
|
tslib_1.__exportStar(require("./PopoverSurface"), exports);
|
|
10
|
-
|
|
11
8
|
tslib_1.__exportStar(require("./PopoverSurface.types"), exports);
|
|
12
|
-
|
|
13
9
|
tslib_1.__exportStar(require("./renderPopoverSurface"), exports);
|
|
14
|
-
|
|
15
10
|
tslib_1.__exportStar(require("./usePopoverSurface"), exports);
|
|
16
|
-
|
|
17
11
|
tslib_1.__exportStar(require("./usePopoverSurfaceStyles"), exports);
|
|
18
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-popover/src/components/PopoverSurface/index.ts"],"
|
|
1
|
+
{"version":3,"mappings":";;;;;;AAAAA;AACAA;AACAA;AACAA;AACAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-popover/src/components/PopoverSurface/index.ts"],"sourcesContent":["export * from './PopoverSurface';\nexport * from './PopoverSurface.types';\nexport * from './renderPopoverSurface';\nexport * from './usePopoverSurface';\nexport * from './usePopoverSurfaceStyles';\n"]}
|
|
@@ -4,36 +4,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.renderPopoverSurface_unstable = void 0;
|
|
7
|
-
|
|
8
7
|
const React = /*#__PURE__*/require("react");
|
|
9
|
-
|
|
10
8
|
const react_portal_1 = /*#__PURE__*/require("@fluentui/react-portal");
|
|
11
|
-
|
|
12
9
|
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
|
13
10
|
/**
|
|
14
11
|
* Render the final JSX of PopoverSurface
|
|
15
12
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
13
|
const renderPopoverSurface_unstable = state => {
|
|
19
14
|
const {
|
|
20
15
|
slots,
|
|
21
16
|
slotProps
|
|
22
17
|
} = react_utilities_1.getSlots(state);
|
|
23
|
-
const surface = React.createElement(slots.root, {
|
|
18
|
+
const surface = React.createElement(slots.root, {
|
|
19
|
+
...slotProps.root
|
|
24
20
|
}, state.withArrow && React.createElement("div", {
|
|
25
21
|
ref: state.arrowRef,
|
|
26
22
|
className: state.arrowClassName
|
|
27
23
|
}), slotProps.root.children);
|
|
28
|
-
|
|
29
24
|
if (state.inline) {
|
|
30
25
|
return surface;
|
|
31
26
|
}
|
|
32
|
-
|
|
33
27
|
return React.createElement(react_portal_1.Portal, {
|
|
34
28
|
mountNode: state.mountNode
|
|
35
29
|
}, surface);
|
|
36
30
|
};
|
|
37
|
-
|
|
38
31
|
exports.renderPopoverSurface_unstable = renderPopoverSurface_unstable;
|
|
39
32
|
//# sourceMappingURL=renderPopoverSurface.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AACA;AAGA;;;AAGO,MAAMA,6BAA6B,GAAIC,KAA0B,IAAI;EAC1E,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAE,GAAGC,0BAAQ,CAAsBH,KAAK,CAAC;EAEjE,MAAMI,OAAO,GACXC,oBAACJ,KAAK,CAACK,IAAI;IAAA,GAAKJ,SAAS,CAACI;EAAI,GAC3BN,KAAK,CAACO,SAAS,IAAIF;IAAKG,GAAG,EAAER,KAAK,CAACS,QAAQ;IAAEC,SAAS,EAAEV,KAAK,CAACW;EAAc,EAAI,EAChFT,SAAS,CAACI,IAAI,CAACM,QAAQ,CAE3B;EAED,IAAIZ,KAAK,CAACa,MAAM,EAAE;IAChB,OAAOT,OAAO;;EAGhB,OAAOC,oBAACS,qBAAM;IAACC,SAAS,EAAEf,KAAK,CAACe;EAAS,GAAGX,OAAO,CAAU;AAC/D,CAAC;AAfYY,qCAA6B","names":["renderPopoverSurface_unstable","state","slots","slotProps","react_utilities_1","surface","React","root","withArrow","ref","arrowRef","className","arrowClassName","children","inline","react_portal_1","mountNode","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-popover/src/components/PopoverSurface/renderPopoverSurface.tsx"],"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"]}
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.usePopoverSurface_unstable = void 0;
|
|
7
|
-
|
|
8
7
|
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
|
9
|
-
|
|
10
8
|
const react_tabster_1 = /*#__PURE__*/require("@fluentui/react-tabster");
|
|
11
|
-
|
|
12
9
|
const popoverContext_1 = /*#__PURE__*/require("../../popoverContext");
|
|
13
10
|
/**
|
|
14
11
|
* Create the state required to render PopoverSurface.
|
|
@@ -19,8 +16,6 @@ const popoverContext_1 = /*#__PURE__*/require("../../popoverContext");
|
|
|
19
16
|
* @param props - props from this instance of PopoverSurface
|
|
20
17
|
* @param ref - reference to root HTMLDivElement of PopoverSurface
|
|
21
18
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
19
|
const usePopoverSurface_unstable = (props, ref) => {
|
|
25
20
|
const contentRef = popoverContext_1.usePopoverContext_unstable(context => context.contentRef);
|
|
26
21
|
const openOnHover = popoverContext_1.usePopoverContext_unstable(context => context.openOnHover);
|
|
@@ -62,37 +57,28 @@ const usePopoverSurface_unstable = (props, ref) => {
|
|
|
62
57
|
onMouseLeave: onMouseLeaveOriginal,
|
|
63
58
|
onKeyDown: onKeyDownOriginal
|
|
64
59
|
} = state.root;
|
|
65
|
-
|
|
66
60
|
state.root.onMouseEnter = e => {
|
|
67
61
|
if (openOnHover) {
|
|
68
62
|
setOpen(e, true);
|
|
69
63
|
}
|
|
70
|
-
|
|
71
64
|
onMouseEnterOriginal === null || onMouseEnterOriginal === void 0 ? void 0 : onMouseEnterOriginal(e);
|
|
72
65
|
};
|
|
73
|
-
|
|
74
66
|
state.root.onMouseLeave = e => {
|
|
75
67
|
if (openOnHover) {
|
|
76
68
|
setOpen(e, false);
|
|
77
69
|
}
|
|
78
|
-
|
|
79
70
|
onMouseLeaveOriginal === null || onMouseLeaveOriginal === void 0 ? void 0 : onMouseLeaveOriginal(e);
|
|
80
71
|
};
|
|
81
|
-
|
|
82
72
|
state.root.onKeyDown = e => {
|
|
83
|
-
var _a;
|
|
73
|
+
var _a;
|
|
74
|
+
// only close if the event happened inside the current popover
|
|
84
75
|
// If using a stack of inline popovers, the user should call `stopPropagation` to avoid dismissing the entire stack
|
|
85
|
-
|
|
86
|
-
|
|
87
76
|
if (e.key === 'Escape' && ((_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target))) {
|
|
88
77
|
setOpen(e, false);
|
|
89
78
|
}
|
|
90
|
-
|
|
91
79
|
onKeyDownOriginal === null || onKeyDownOriginal === void 0 ? void 0 : onKeyDownOriginal(e);
|
|
92
80
|
};
|
|
93
|
-
|
|
94
81
|
return state;
|
|
95
82
|
};
|
|
96
|
-
|
|
97
83
|
exports.usePopoverSurface_unstable = usePopoverSurface_unstable;
|
|
98
84
|
//# sourceMappingURL=usePopoverSurface.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"mappings":";;;;;;AACA;AACA;AACA;AAGA;;;;;;;;;AASO,MAAMA,0BAA0B,GAAG,CACxCC,KAA0B,EAC1BC,GAA8B,KACP;EACvB,MAAMC,UAAU,GAAGC,2CAA0B,CAACC,OAAO,IAAIA,OAAO,CAACF,UAAU,CAAC;EAC5E,MAAMG,WAAW,GAAGF,2CAA0B,CAACC,OAAO,IAAIA,OAAO,CAACC,WAAW,CAAC;EAC9E,MAAMC,OAAO,GAAGH,2CAA0B,CAACC,OAAO,IAAIA,OAAO,CAACE,OAAO,CAAC;EACtE,MAAMC,SAAS,GAAGJ,2CAA0B,CAACC,OAAO,IAAIA,OAAO,CAACG,SAAS,CAAC;EAC1E,MAAMC,QAAQ,GAAGL,2CAA0B,CA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AACuB,CAAC,EAAE,IAAI,CAAC;;IAGlBL,oBAAoB,aAApBA,oBAAoB,uBAApBA,oBAAoB,CAAGK,CAAC,CAAC;EAC3B,CAAC;EAEDZ,KAAK,CAACE,IAAI,CAACM,YAAY,GAAII,CAAmC,IAAI;IAChE,IAAIxB,WAAW,EAAE;MACfC,OAAO,CAACuB,CAAC,EAAE,KAAK,CAAC;;IAGnBH,oBAAoB,aAApBA,oBAAoB,uBAApBA,oBAAoB,CAAGG,CAAC,CAAC;EAC3B,CAAC;EAEDZ,KAAK,CAACE,IAAI,CAACQ,SAAS,GAAIE,CAAsC,IAAI;;IAChE;IACA;IACA,IAAIA,CAAC,CAACC,GAAG,KAAK,QAAQ,KAAI,gBAAU,CAACC,OAAO,0CAAEC,QAAQ,CAACH,CAAC,CAACI,MAAwB,CAAC,GAAE;MAClF3B,OAAO,CAACuB,CAAC,EAAE,KAAK,CAAC;;IAGnBD,iBAAiB,aAAjBA,iBAAiB,uBAAjBA,iBAAiB,CAAGC,CAAC,CAAC;EACxB,CAAC;EAED,OAAOZ,KAAK;AACd,CAAC;AApEYiB,kCAA0B","names":["usePopoverSurface_unstable","props","ref","contentRef","popoverContext_1","context","openOnHover","setOpen","mountNode","arrowRef","size","withArrow","appearance","trapFocus","legacyTrapFocus","inline","modalAttributes","react_tabster_1","state","components","root","react_utilities_1","role","undefined","onMouseEnter","onMouseEnterOriginal","onMouseLeave","onMouseLeaveOriginal","onKeyDown","onKeyDownOriginal","e","key","current","contains","target","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-popover/src/components/PopoverSurface/usePopoverSurface.ts"],"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' : 'group',\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"]}
|