@fluentui/react-popover 0.0.0-nightly-20230317-0436.1 → 0.0.0-nightly-20230317-1454.1
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/.swcrc +39 -0
- package/CHANGELOG.json +23 -23
- package/CHANGELOG.md +14 -14
- package/lib/Popover.js +1 -1
- package/lib/Popover.js.map +1 -1
- package/lib/PopoverSurface.js +1 -1
- package/lib/PopoverSurface.js.map +1 -1
- package/lib/PopoverTrigger.js +1 -1
- package/lib/PopoverTrigger.js.map +1 -1
- package/lib/components/Popover/Popover.js +4 -3
- package/lib/components/Popover/Popover.js.map +1 -1
- package/lib/components/Popover/Popover.types.js +1 -1
- package/lib/components/Popover/Popover.types.js.map +1 -1
- package/lib/components/Popover/constants.js +1 -2
- package/lib/components/Popover/constants.js.map +1 -1
- package/lib/components/Popover/index.js +4 -4
- package/lib/components/Popover/index.js.map +1 -1
- package/lib/components/Popover/renderPopover.js +2 -2
- package/lib/components/Popover/renderPopover.js.map +1 -1
- package/lib/components/Popover/usePopover.js +22 -28
- package/lib/components/Popover/usePopover.js.map +1 -1
- package/lib/components/PopoverSurface/PopoverSurface.js +6 -6
- package/lib/components/PopoverSurface/PopoverSurface.js.map +1 -1
- package/lib/components/PopoverSurface/PopoverSurface.types.js.map +1 -1
- package/lib/components/PopoverSurface/index.js +5 -5
- package/lib/components/PopoverSurface/index.js.map +1 -1
- package/lib/components/PopoverSurface/renderPopoverSurface.js +4 -6
- package/lib/components/PopoverSurface/renderPopoverSurface.js.map +1 -1
- package/lib/components/PopoverSurface/usePopoverSurface.js +12 -12
- package/lib/components/PopoverSurface/usePopoverSurface.js.map +1 -1
- package/lib/components/PopoverSurface/usePopoverSurfaceStyles.js +6 -6
- package/lib/components/PopoverSurface/usePopoverSurfaceStyles.js.map +1 -1
- package/lib/components/PopoverTrigger/PopoverTrigger.js +4 -3
- package/lib/components/PopoverTrigger/PopoverTrigger.js.map +1 -1
- package/lib/components/PopoverTrigger/PopoverTrigger.types.js +1 -1
- package/lib/components/PopoverTrigger/PopoverTrigger.types.js.map +1 -1
- package/lib/components/PopoverTrigger/index.js +4 -4
- package/lib/components/PopoverTrigger/index.js.map +1 -1
- package/lib/components/PopoverTrigger/renderPopoverTrigger.js +1 -2
- package/lib/components/PopoverTrigger/renderPopoverTrigger.js.map +1 -1
- package/lib/components/PopoverTrigger/usePopoverTrigger.js +16 -15
- 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 +2 -2
- package/lib/popoverContext.js.map +1 -1
- package/lib-commonjs/Popover.js +5 -4
- package/lib-commonjs/Popover.js.map +1 -1
- package/lib-commonjs/PopoverSurface.js +5 -4
- package/lib-commonjs/PopoverSurface.js.map +1 -1
- package/lib-commonjs/PopoverTrigger.js +5 -4
- package/lib-commonjs/PopoverTrigger.js.map +1 -1
- package/lib-commonjs/components/Popover/Popover.js +14 -13
- package/lib-commonjs/components/Popover/Popover.js.map +1 -1
- package/lib-commonjs/components/Popover/Popover.types.js +5 -2
- package/lib-commonjs/components/Popover/Popover.types.js.map +1 -1
- package/lib-commonjs/components/Popover/constants.js +10 -8
- package/lib-commonjs/components/Popover/constants.js.map +1 -1
- package/lib-commonjs/components/Popover/index.js +8 -7
- package/lib-commonjs/components/Popover/index.js.map +1 -1
- package/lib-commonjs/components/Popover/renderPopover.js +31 -47
- package/lib-commonjs/components/Popover/renderPopover.js.map +1 -1
- package/lib-commonjs/components/Popover/usePopover.js +173 -173
- package/lib-commonjs/components/Popover/usePopover.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/PopoverSurface.js +19 -20
- package/lib-commonjs/components/PopoverSurface/PopoverSurface.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/PopoverSurface.types.js +3 -2
- package/lib-commonjs/components/PopoverSurface/PopoverSurface.types.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/index.js +9 -8
- package/lib-commonjs/components/PopoverSurface/index.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.js +23 -28
- package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/usePopoverSurface.js +69 -81
- package/lib-commonjs/components/PopoverSurface/usePopoverSurface.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.js +243 -113
- package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.js.map +1 -1
- package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.js +15 -14
- package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.js.map +1 -1
- package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.types.js +5 -2
- package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.types.js.map +1 -1
- package/lib-commonjs/components/PopoverTrigger/index.js +8 -7
- package/lib-commonjs/components/PopoverTrigger/index.js.map +1 -1
- package/lib-commonjs/components/PopoverTrigger/renderPopoverTrigger.js +12 -11
- package/lib-commonjs/components/PopoverTrigger/renderPopoverTrigger.js.map +1 -1
- package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.js +71 -80
- package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.js.map +1 -1
- package/lib-commonjs/index.js +30 -92
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/popoverContext.js +34 -25
- package/lib-commonjs/popoverContext.js.map +1 -1
- package/package.json +13 -13
@@ -1,25 +1,24 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "PopoverSurface", {
|
6
|
+
enumerable: true,
|
7
|
+
get: ()=>PopoverSurface
|
5
8
|
});
|
6
|
-
|
7
|
-
const
|
8
|
-
const
|
9
|
-
const
|
10
|
-
const
|
11
|
-
const
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
const {
|
19
|
-
usePopoverSurfaceStyles_unstable: useCustomStyles
|
20
|
-
} = react_shared_contexts_1.useCustomStyleHooks_unstable();
|
21
|
-
useCustomStyles(state);
|
22
|
-
return renderPopoverSurface_1.renderPopoverSurface_unstable(state);
|
9
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
10
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
11
|
+
const _usePopoverSurface = require("./usePopoverSurface");
|
12
|
+
const _renderPopoverSurface = require("./renderPopoverSurface");
|
13
|
+
const _usePopoverSurfaceStyles = require("./usePopoverSurfaceStyles");
|
14
|
+
const _reactSharedContexts = require("@fluentui/react-shared-contexts");
|
15
|
+
const PopoverSurface = /*#__PURE__*/ _react.forwardRef((props, ref)=>{
|
16
|
+
const state = (0, _usePopoverSurface.usePopoverSurface_unstable)(props, ref);
|
17
|
+
(0, _usePopoverSurfaceStyles.usePopoverSurfaceStyles_unstable)(state);
|
18
|
+
const { usePopoverSurfaceStyles_unstable: useCustomStyles } = (0, _reactSharedContexts.useCustomStyleHooks_unstable)();
|
19
|
+
useCustomStyles(state);
|
20
|
+
return (0, _renderPopoverSurface.renderPopoverSurface_unstable)(state);
|
23
21
|
});
|
24
|
-
|
22
|
+
PopoverSurface.displayName = "PopoverSurface"; //# sourceMappingURL=PopoverSurface.js.map
|
23
|
+
|
25
24
|
//# sourceMappingURL=PopoverSurface.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../../lib/components/PopoverSurface/PopoverSurface.js"],"sourcesContent":["import * as React from \"react\";\nimport { usePopoverSurface_unstable } from \"./usePopoverSurface\";\nimport { renderPopoverSurface_unstable } from \"./renderPopoverSurface\";\nimport { usePopoverSurfaceStyles_unstable } from \"./usePopoverSurfaceStyles\";\nimport { useCustomStyleHooks_unstable } from \"@fluentui/react-shared-contexts\";\n/**\n * PopoverSurface component renders react children in a positioned box\n */\nexport const PopoverSurface = /*#__PURE__*/React.forwardRef((props, ref) => {\n const state = usePopoverSurface_unstable(props, ref);\n usePopoverSurfaceStyles_unstable(state);\n const {\n usePopoverSurfaceStyles_unstable: useCustomStyles\n } = useCustomStyleHooks_unstable();\n useCustomStyles(state);\n return renderPopoverSurface_unstable(state);\n});\nPopoverSurface.displayName = \"PopoverSurface\";\n//# sourceMappingURL=PopoverSurface.js.map"],"names":["PopoverSurface","React","forwardRef","props","ref","state","usePopoverSurface_unstable","usePopoverSurfaceStyles_unstable","useCustomStyles","useCustomStyleHooks_unstable","renderPopoverSurface_unstable","displayName"],"mappings":";;;;+BAQaA;;aAAAA;;;6DARU;mCACoB;sCACG;yCACG;qCACJ;AAItC,MAAMA,iBAAiB,WAAW,GAAEC,OAAMC,UAAU,CAAC,CAACC,OAAOC,MAAQ;IAC1E,MAAMC,QAAQC,IAAAA,6CAA0B,EAACH,OAAOC;IAChDG,IAAAA,yDAAgC,EAACF;IACjC,MAAM,EACJE,kCAAkCC,gBAAe,EAClD,GAAGC,IAAAA,iDAA4B;IAChCD,gBAAgBH;IAChB,OAAOK,IAAAA,mDAA6B,EAACL;AACvC;AACAL,eAAeW,WAAW,GAAG,kBAC7B,0CAA0C"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../../lib/components/PopoverSurface/PopoverSurface.types.js"],"sourcesContent":["export {};\n//# sourceMappingURL=PopoverSurface.types.js.map"],"names":[],"mappings":";;;;CACA,gDAAgD"}
|
@@ -1,12 +1,13 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
5
4
|
});
|
6
|
-
const
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
|
6
|
+
_exportStar(require("./PopoverSurface"), exports);
|
7
|
+
_exportStar(require("./PopoverSurface.types"), exports);
|
8
|
+
_exportStar(require("./renderPopoverSurface"), exports);
|
9
|
+
_exportStar(require("./usePopoverSurface"), exports);
|
10
|
+
_exportStar(require("./usePopoverSurfaceStyles"), exports);
|
11
|
+
//# sourceMappingURL=index.js.map
|
12
|
+
|
12
13
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../../lib/components/PopoverSurface/index.js"],"sourcesContent":["export * from \"./PopoverSurface\";\nexport * from \"./PopoverSurface.types\";\nexport * from \"./renderPopoverSurface\";\nexport * from \"./usePopoverSurface\";\nexport * from \"./usePopoverSurfaceStyles\";\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;;oBAAc;oBACA;oBACA;oBACA;oBACA;CACd,iCAAiC"}
|
@@ -1,32 +1,27 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "renderPopoverSurface_unstable", {
|
6
|
+
enumerable: true,
|
7
|
+
get: ()=>renderPopoverSurface_unstable
|
5
8
|
});
|
6
|
-
|
7
|
-
const
|
8
|
-
const
|
9
|
-
const
|
10
|
-
|
11
|
-
|
12
|
-
*/
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
if (state.inline) {
|
25
|
-
return surface;
|
26
|
-
}
|
27
|
-
return React.createElement(react_portal_1.Portal, {
|
28
|
-
mountNode: state.mountNode
|
29
|
-
}, surface);
|
30
|
-
};
|
31
|
-
exports.renderPopoverSurface_unstable = renderPopoverSurface_unstable;
|
9
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
10
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
11
|
+
const _reactPortal = require("@fluentui/react-portal");
|
12
|
+
const _reactUtilities = require("@fluentui/react-utilities");
|
13
|
+
const renderPopoverSurface_unstable = (state)=>{
|
14
|
+
const { slots , slotProps } = (0, _reactUtilities.getSlots)(state);
|
15
|
+
const surface = /*#__PURE__*/ _react.createElement(slots.root, slotProps.root, state.withArrow && /*#__PURE__*/ _react.createElement("div", {
|
16
|
+
ref: state.arrowRef,
|
17
|
+
className: state.arrowClassName
|
18
|
+
}), slotProps.root.children);
|
19
|
+
if (state.inline) {
|
20
|
+
return surface;
|
21
|
+
}
|
22
|
+
return /*#__PURE__*/ _react.createElement(_reactPortal.Portal, {
|
23
|
+
mountNode: state.mountNode
|
24
|
+
}, surface);
|
25
|
+
}; //# sourceMappingURL=renderPopoverSurface.js.map
|
26
|
+
|
32
27
|
//# sourceMappingURL=renderPopoverSurface.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../../lib/components/PopoverSurface/renderPopoverSurface.js"],"sourcesContent":["import * as React from \"react\";\nimport { Portal } from \"@fluentui/react-portal\";\nimport { getSlots } from \"@fluentui/react-utilities\";\n/**\n * Render the final JSX of PopoverSurface\n */\nexport const renderPopoverSurface_unstable = state => {\n const {\n slots,\n slotProps\n } = getSlots(state);\n const surface = /*#__PURE__*/React.createElement(slots.root, slotProps.root, state.withArrow && /*#__PURE__*/React.createElement(\"div\", {\n ref: state.arrowRef,\n className: state.arrowClassName\n }), slotProps.root.children);\n if (state.inline) {\n return surface;\n }\n return /*#__PURE__*/React.createElement(Portal, {\n mountNode: state.mountNode\n }, surface);\n};\n//# sourceMappingURL=renderPopoverSurface.js.map"],"names":["renderPopoverSurface_unstable","state","slots","slotProps","getSlots","surface","React","createElement","root","withArrow","ref","arrowRef","className","arrowClassName","children","inline","Portal","mountNode"],"mappings":";;;;+BAMaA;;aAAAA;;;6DANU;6BACA;gCACE;AAIlB,MAAMA,gCAAgCC,CAAAA,QAAS;IACpD,MAAM,EACJC,MAAK,EACLC,UAAS,EACV,GAAGC,IAAAA,wBAAQ,EAACH;IACb,MAAMI,UAAU,WAAW,GAAEC,OAAMC,aAAa,CAACL,MAAMM,IAAI,EAAEL,UAAUK,IAAI,EAAEP,MAAMQ,SAAS,IAAI,WAAW,GAAEH,OAAMC,aAAa,CAAC,OAAO;QACtIG,KAAKT,MAAMU,QAAQ;QACnBC,WAAWX,MAAMY,cAAc;IACjC,IAAIV,UAAUK,IAAI,CAACM,QAAQ;IAC3B,IAAIb,MAAMc,MAAM,EAAE;QAChB,OAAOV;IACT,CAAC;IACD,OAAO,WAAW,GAAEC,OAAMC,aAAa,CAACS,mBAAM,EAAE;QAC9CC,WAAWhB,MAAMgB,SAAS;IAC5B,GAAGZ;AACL,GACA,gDAAgD"}
|
@@ -1,85 +1,73 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "usePopoverSurface_unstable", {
|
6
|
+
enumerable: true,
|
7
|
+
get: ()=>usePopoverSurface_unstable
|
5
8
|
});
|
6
|
-
|
7
|
-
const
|
8
|
-
const
|
9
|
-
const
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
const
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
onKeyDown
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
}
|
71
|
-
onMouseLeaveOriginal === null || onMouseLeaveOriginal === void 0 ? void 0 : onMouseLeaveOriginal(e);
|
72
|
-
};
|
73
|
-
state.root.onKeyDown = e => {
|
74
|
-
var _a;
|
75
|
-
// only close if the event happened inside the current popover
|
76
|
-
// If using a stack of inline popovers, the user should call `stopPropagation` to avoid dismissing the entire stack
|
77
|
-
if (e.key === 'Escape' && ((_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target))) {
|
78
|
-
setOpen(e, false);
|
79
|
-
}
|
80
|
-
onKeyDownOriginal === null || onKeyDownOriginal === void 0 ? void 0 : onKeyDownOriginal(e);
|
81
|
-
};
|
82
|
-
return state;
|
83
|
-
};
|
84
|
-
exports.usePopoverSurface_unstable = usePopoverSurface_unstable;
|
9
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
10
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
11
|
+
const _reactUtilities = require("@fluentui/react-utilities");
|
12
|
+
const _reactTabster = require("@fluentui/react-tabster");
|
13
|
+
const _popoverContext = require("../../popoverContext");
|
14
|
+
const usePopoverSurface_unstable = (props, ref)=>{
|
15
|
+
const contentRef = (0, _popoverContext.usePopoverContext_unstable)((context)=>context.contentRef);
|
16
|
+
const openOnHover = (0, _popoverContext.usePopoverContext_unstable)((context)=>context.openOnHover);
|
17
|
+
const setOpen = (0, _popoverContext.usePopoverContext_unstable)((context)=>context.setOpen);
|
18
|
+
const mountNode = (0, _popoverContext.usePopoverContext_unstable)((context)=>context.mountNode);
|
19
|
+
const arrowRef = (0, _popoverContext.usePopoverContext_unstable)((context)=>context.arrowRef);
|
20
|
+
const size = (0, _popoverContext.usePopoverContext_unstable)((context)=>context.size);
|
21
|
+
const withArrow = (0, _popoverContext.usePopoverContext_unstable)((context)=>context.withArrow);
|
22
|
+
const appearance = (0, _popoverContext.usePopoverContext_unstable)((context)=>context.appearance);
|
23
|
+
const trapFocus = (0, _popoverContext.usePopoverContext_unstable)((context)=>context.trapFocus);
|
24
|
+
const inertTrapFocus = (0, _popoverContext.usePopoverContext_unstable)((context)=>context.inertTrapFocus);
|
25
|
+
const inline = (0, _popoverContext.usePopoverContext_unstable)((context)=>context.inline);
|
26
|
+
const { modalAttributes } = (0, _reactTabster.useModalAttributes)({
|
27
|
+
trapFocus,
|
28
|
+
legacyTrapFocus: !inertTrapFocus,
|
29
|
+
alwaysFocusable: !trapFocus
|
30
|
+
});
|
31
|
+
const state = {
|
32
|
+
inline,
|
33
|
+
appearance,
|
34
|
+
withArrow,
|
35
|
+
size,
|
36
|
+
arrowRef,
|
37
|
+
mountNode,
|
38
|
+
components: {
|
39
|
+
root: "div"
|
40
|
+
},
|
41
|
+
root: (0, _reactUtilities.getNativeElementProps)("div", {
|
42
|
+
ref: (0, _reactUtilities.useMergedRefs)(ref, contentRef),
|
43
|
+
role: trapFocus ? "dialog" : "group",
|
44
|
+
"aria-modal": trapFocus ? true : undefined,
|
45
|
+
...modalAttributes,
|
46
|
+
...props
|
47
|
+
})
|
48
|
+
};
|
49
|
+
const { onMouseEnter: onMouseEnterOriginal , onMouseLeave: onMouseLeaveOriginal , onKeyDown: onKeyDownOriginal } = state.root;
|
50
|
+
state.root.onMouseEnter = (e)=>{
|
51
|
+
if (openOnHover) {
|
52
|
+
setOpen(e, true);
|
53
|
+
}
|
54
|
+
onMouseEnterOriginal?.(e);
|
55
|
+
};
|
56
|
+
state.root.onMouseLeave = (e)=>{
|
57
|
+
if (openOnHover) {
|
58
|
+
setOpen(e, false);
|
59
|
+
}
|
60
|
+
onMouseLeaveOriginal?.(e);
|
61
|
+
};
|
62
|
+
state.root.onKeyDown = (e)=>{
|
63
|
+
// only close if the event happened inside the current popover
|
64
|
+
// If using a stack of inline popovers, the user should call `stopPropagation` to avoid dismissing the entire stack
|
65
|
+
if (e.key === "Escape" && contentRef.current?.contains(e.target)) {
|
66
|
+
setOpen(e, false);
|
67
|
+
}
|
68
|
+
onKeyDownOriginal?.(e);
|
69
|
+
};
|
70
|
+
return state;
|
71
|
+
}; //# sourceMappingURL=usePopoverSurface.js.map
|
72
|
+
|
85
73
|
//# sourceMappingURL=usePopoverSurface.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../../lib/components/PopoverSurface/usePopoverSurface.js"],"sourcesContent":["import * as React from \"react\";\nimport { getNativeElementProps, useMergedRefs } from \"@fluentui/react-utilities\";\nimport { useModalAttributes } from \"@fluentui/react-tabster\";\nimport { usePopoverContext_unstable } from \"../../popoverContext\";\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 = (props, ref) => {\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 inertTrapFocus = usePopoverContext_unstable(context => context.inertTrapFocus);\n const inline = usePopoverContext_unstable(context => context.inline);\n const {\n modalAttributes\n } = useModalAttributes({\n trapFocus,\n legacyTrapFocus: !inertTrapFocus,\n alwaysFocusable: !trapFocus\n });\n const state = {\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 const {\n onMouseEnter: onMouseEnterOriginal,\n onMouseLeave: onMouseLeaveOriginal,\n onKeyDown: onKeyDownOriginal\n } = state.root;\n state.root.onMouseEnter = e => {\n if (openOnHover) {\n setOpen(e, true);\n }\n onMouseEnterOriginal?.(e);\n };\n state.root.onMouseLeave = e => {\n if (openOnHover) {\n setOpen(e, false);\n }\n onMouseLeaveOriginal?.(e);\n };\n state.root.onKeyDown = e => {\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)) {\n setOpen(e, false);\n }\n onKeyDownOriginal?.(e);\n };\n return state;\n};\n//# sourceMappingURL=usePopoverSurface.js.map"],"names":["usePopoverSurface_unstable","props","ref","contentRef","usePopoverContext_unstable","context","openOnHover","setOpen","mountNode","arrowRef","size","withArrow","appearance","trapFocus","inertTrapFocus","inline","modalAttributes","useModalAttributes","legacyTrapFocus","alwaysFocusable","state","components","root","getNativeElementProps","useMergedRefs","role","undefined","onMouseEnter","onMouseEnterOriginal","onMouseLeave","onMouseLeaveOriginal","onKeyDown","onKeyDownOriginal","e","key","current","contains","target"],"mappings":";;;;+BAaaA;;aAAAA;;;6DAbU;gCAC8B;8BAClB;gCACQ;AAUpC,MAAMA,6BAA6B,CAACC,OAAOC,MAAQ;IACxD,MAAMC,aAAaC,IAAAA,0CAA0B,EAACC,CAAAA,UAAWA,QAAQF,UAAU;IAC3E,MAAMG,cAAcF,IAAAA,0CAA0B,EAACC,CAAAA,UAAWA,QAAQC,WAAW;IAC7E,MAAMC,UAAUH,IAAAA,0CAA0B,EAACC,CAAAA,UAAWA,QAAQE,OAAO;IACrE,MAAMC,YAAYJ,IAAAA,0CAA0B,EAACC,CAAAA,UAAWA,QAAQG,SAAS;IACzE,MAAMC,WAAWL,IAAAA,0CAA0B,EAACC,CAAAA,UAAWA,QAAQI,QAAQ;IACvE,MAAMC,OAAON,IAAAA,0CAA0B,EAACC,CAAAA,UAAWA,QAAQK,IAAI;IAC/D,MAAMC,YAAYP,IAAAA,0CAA0B,EAACC,CAAAA,UAAWA,QAAQM,SAAS;IACzE,MAAMC,aAAaR,IAAAA,0CAA0B,EAACC,CAAAA,UAAWA,QAAQO,UAAU;IAC3E,MAAMC,YAAYT,IAAAA,0CAA0B,EAACC,CAAAA,UAAWA,QAAQQ,SAAS;IACzE,MAAMC,iBAAiBV,IAAAA,0CAA0B,EAACC,CAAAA,UAAWA,QAAQS,cAAc;IACnF,MAAMC,SAASX,IAAAA,0CAA0B,EAACC,CAAAA,UAAWA,QAAQU,MAAM;IACnE,MAAM,EACJC,gBAAe,EAChB,GAAGC,IAAAA,gCAAkB,EAAC;QACrBJ;QACAK,iBAAiB,CAACJ;QAClBK,iBAAiB,CAACN;IACpB;IACA,MAAMO,QAAQ;QACZL;QACAH;QACAD;QACAD;QACAD;QACAD;QACAa,YAAY;YACVC,MAAM;QACR;QACAA,MAAMC,IAAAA,qCAAqB,EAAC,OAAO;YACjCrB,KAAKsB,IAAAA,6BAAa,EAACtB,KAAKC;YACxBsB,MAAMZ,YAAY,WAAW,OAAO;YACpC,cAAcA,YAAY,IAAI,GAAGa,SAAS;YAC1C,GAAGV,eAAe;YAClB,GAAGf,KAAK;QACV;IACF;IACA,MAAM,EACJ0B,cAAcC,qBAAoB,EAClCC,cAAcC,qBAAoB,EAClCC,WAAWC,kBAAiB,EAC7B,GAAGZ,MAAME,IAAI;IACdF,MAAME,IAAI,CAACK,YAAY,GAAGM,CAAAA,IAAK;QAC7B,IAAI3B,aAAa;YACfC,QAAQ0B,GAAG,IAAI;QACjB,CAAC;QACDL,uBAAuBK;IACzB;IACAb,MAAME,IAAI,CAACO,YAAY,GAAGI,CAAAA,IAAK;QAC7B,IAAI3B,aAAa;YACfC,QAAQ0B,GAAG,KAAK;QAClB,CAAC;QACDH,uBAAuBG;IACzB;IACAb,MAAME,IAAI,CAACS,SAAS,GAAGE,CAAAA,IAAK;QAC1B,8DAA8D;QAC9D,mHAAmH;QACnH,IAAIA,EAAEC,GAAG,KAAK,YAAY/B,WAAWgC,OAAO,EAAEC,SAASH,EAAEI,MAAM,GAAG;YAChE9B,QAAQ0B,GAAG,KAAK;QAClB,CAAC;QACDD,oBAAoBC;IACtB;IACA,OAAOb;AACT,GACA,6CAA6C"}
|