@fluentui/react-popover 0.0.0-nightlya372ad979820211103.1 → 0.0.0-nightlya54302c0b220211124.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +113 -32
- package/CHANGELOG.md +34 -15
- package/dist/react-popover.d.ts +2 -0
- package/lib/common/isConformant.js +1 -1
- package/lib/common/isConformant.js.map +1 -1
- package/lib/common/mockUsePopoverContext.js +7 -14
- package/lib/common/mockUsePopoverContext.js.map +1 -1
- package/lib/components/Popover/Popover.js +2 -2
- package/lib/components/Popover/Popover.js.map +1 -1
- package/lib/components/Popover/renderPopover.js +27 -25
- package/lib/components/Popover/renderPopover.js.map +1 -1
- package/lib/components/Popover/usePopover.js +39 -51
- package/lib/components/Popover/usePopover.js.map +1 -1
- package/lib/components/PopoverSurface/PopoverSurface.js +2 -2
- package/lib/components/PopoverSurface/PopoverSurface.js.map +1 -1
- package/lib/components/PopoverSurface/renderPopoverSurface.js +6 -7
- package/lib/components/PopoverSurface/renderPopoverSurface.js.map +1 -1
- package/lib/components/PopoverSurface/usePopoverSurface.js +41 -55
- package/lib/components/PopoverSurface/usePopoverSurface.js.map +1 -1
- package/lib/components/PopoverSurface/usePopoverSurfaceStyles.d.ts +1 -0
- package/lib/components/PopoverSurface/usePopoverSurfaceStyles.js +16 -8
- package/lib/components/PopoverSurface/usePopoverSurfaceStyles.js.map +1 -1
- package/lib/components/PopoverTrigger/PopoverTrigger.js +2 -2
- package/lib/components/PopoverTrigger/PopoverTrigger.js.map +1 -1
- package/lib/components/PopoverTrigger/renderPopoverTrigger.js +1 -1
- package/lib/components/PopoverTrigger/renderPopoverTrigger.js.map +1 -1
- package/lib/components/PopoverTrigger/usePopoverTrigger.js +25 -33
- package/lib/components/PopoverTrigger/usePopoverTrigger.js.map +1 -1
- package/lib/popoverContext.js +3 -7
- package/lib/popoverContext.js.map +1 -1
- package/lib-commonjs/Popover.js +1 -1
- package/lib-commonjs/PopoverSurface.js +1 -1
- package/lib-commonjs/PopoverTrigger.js +1 -1
- package/lib-commonjs/common/isConformant.js +3 -3
- package/lib-commonjs/common/isConformant.js.map +1 -1
- package/lib-commonjs/common/mockUsePopoverContext.js +8 -16
- package/lib-commonjs/common/mockUsePopoverContext.js.map +1 -1
- package/lib-commonjs/components/Popover/Popover.js +4 -4
- package/lib-commonjs/components/Popover/Popover.js.map +1 -1
- package/lib-commonjs/components/Popover/index.js +1 -1
- package/lib-commonjs/components/Popover/renderPopover.js +29 -27
- package/lib-commonjs/components/Popover/renderPopover.js.map +1 -1
- package/lib-commonjs/components/Popover/usePopover.js +45 -58
- package/lib-commonjs/components/Popover/usePopover.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/PopoverSurface.js +6 -6
- package/lib-commonjs/components/PopoverSurface/PopoverSurface.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/index.js +1 -1
- package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.js +10 -12
- package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/usePopoverSurface.js +44 -59
- package/lib-commonjs/components/PopoverSurface/usePopoverSurface.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.d.ts +1 -0
- package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.js +18 -9
- package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.js.map +1 -1
- package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.js +4 -4
- package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.js.map +1 -1
- package/lib-commonjs/components/PopoverTrigger/index.js +1 -1
- package/lib-commonjs/components/PopoverTrigger/renderPopoverTrigger.js +1 -1
- package/lib-commonjs/components/PopoverTrigger/renderPopoverTrigger.js.map +1 -1
- package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.js +29 -38
- package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.js.map +1 -1
- package/lib-commonjs/index.js +1 -1
- package/lib-commonjs/popoverContext.js +3 -7
- package/lib-commonjs/popoverContext.js.map +1 -1
- package/package.json +11 -12
@@ -5,41 +5,43 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.renderPopover = void 0;
|
7
7
|
|
8
|
-
|
8
|
+
const React = /*#__PURE__*/require("react");
|
9
9
|
|
10
|
-
|
10
|
+
const popoverContext_1 = /*#__PURE__*/require("../../popoverContext");
|
11
11
|
/**
|
12
12
|
* Render the final JSX of Popover
|
13
13
|
*/
|
14
14
|
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
16
|
+
const renderPopover = state => {
|
17
|
+
const {
|
18
|
+
open,
|
19
|
+
setOpen,
|
20
|
+
triggerRef,
|
21
|
+
contentRef,
|
22
|
+
openOnContext,
|
23
|
+
openOnHover,
|
24
|
+
mountNode,
|
25
|
+
arrowRef,
|
26
|
+
size,
|
27
|
+
noArrow,
|
28
|
+
appearance,
|
29
|
+
trapFocus
|
30
|
+
} = state;
|
29
31
|
return React.createElement(popoverContext_1.PopoverContext.Provider, {
|
30
32
|
value: {
|
31
|
-
open
|
32
|
-
setOpen
|
33
|
-
triggerRef
|
34
|
-
contentRef
|
35
|
-
openOnHover
|
36
|
-
openOnContext
|
37
|
-
mountNode
|
38
|
-
arrowRef
|
39
|
-
size
|
40
|
-
noArrow
|
41
|
-
appearance
|
42
|
-
trapFocus
|
33
|
+
open,
|
34
|
+
setOpen,
|
35
|
+
triggerRef,
|
36
|
+
contentRef,
|
37
|
+
openOnHover,
|
38
|
+
openOnContext,
|
39
|
+
mountNode,
|
40
|
+
arrowRef,
|
41
|
+
size,
|
42
|
+
noArrow,
|
43
|
+
appearance,
|
44
|
+
trapFocus
|
43
45
|
}
|
44
46
|
}, state.children);
|
45
47
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Popover/renderPopover.tsx"],"names":[],"mappings":";;;;;;;AAAA,
|
1
|
+
{"version":3,"sources":["../../../src/components/Popover/renderPopover.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,gBAAA,gBAAA,OAAA,CAAA,sBAAA,CAAA;AAGA;;AAEG;;;AACI,MAAM,aAAa,GAAI,KAAD,IAAwB;AACnD,QAAM;AACJ,IAAA,IADI;AAEJ,IAAA,OAFI;AAGJ,IAAA,UAHI;AAIJ,IAAA,UAJI;AAKJ,IAAA,aALI;AAMJ,IAAA,WANI;AAOJ,IAAA,SAPI;AAQJ,IAAA,QARI;AASJ,IAAA,IATI;AAUJ,IAAA,OAVI;AAWJ,IAAA,UAXI;AAYJ,IAAA;AAZI,MAaF,KAbJ;AAeA,SACE,KAAA,CAAA,aAAA,CAAC,gBAAA,CAAA,cAAA,CAAe,QAAhB,EAAwB;AACtB,IAAA,KAAK,EAAE;AACL,MAAA,IADK;AAEL,MAAA,OAFK;AAGL,MAAA,UAHK;AAIL,MAAA,UAJK;AAKL,MAAA,WALK;AAML,MAAA,aANK;AAOL,MAAA,SAPK;AAQL,MAAA,QARK;AASL,MAAA,IATK;AAUL,MAAA,OAVK;AAWL,MAAA,UAXK;AAYL,MAAA;AAZK;AADe,GAAxB,EAgBG,KAAK,CAAC,QAhBT,CADF;AAoBD,CApCM;;AAAM,OAAA,CAAA,aAAA,GAAa,aAAb","sourceRoot":""}
|
@@ -5,19 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.usePopover = void 0;
|
7
7
|
|
8
|
-
|
8
|
+
const React = /*#__PURE__*/require("react");
|
9
9
|
|
10
|
-
|
10
|
+
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
11
11
|
|
12
|
-
|
12
|
+
const react_shared_contexts_1 = /*#__PURE__*/require("@fluentui/react-shared-contexts");
|
13
13
|
|
14
|
-
|
14
|
+
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
|
-
|
19
|
-
|
20
|
-
var index_1 = /*#__PURE__*/require("../PopoverSurface/index");
|
18
|
+
const index_1 = /*#__PURE__*/require("../PopoverSurface/index");
|
21
19
|
/**
|
22
20
|
* Create the state required to render Popover.
|
23
21
|
*
|
@@ -28,47 +26,40 @@ var index_1 = /*#__PURE__*/require("../PopoverSurface/index");
|
|
28
26
|
*/
|
29
27
|
|
30
28
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
setContextTarget = _a[1];
|
35
|
-
|
36
|
-
var initialState = tslib_1.__assign({
|
29
|
+
const usePopover = props => {
|
30
|
+
const [contextTarget, setContextTarget] = react_positioning_1.usePopperMouseTarget();
|
31
|
+
const initialState = {
|
37
32
|
size: 'medium',
|
38
|
-
contextTarget
|
39
|
-
setContextTarget
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
var targetDocument = react_shared_contexts_1.useFluent().targetDocument;
|
33
|
+
contextTarget,
|
34
|
+
setContextTarget,
|
35
|
+
...props
|
36
|
+
};
|
37
|
+
const [open, setOpen] = useOpenState(initialState);
|
38
|
+
const popperRefs = usePopoverRefs(initialState);
|
39
|
+
const {
|
40
|
+
targetDocument
|
41
|
+
} = react_shared_contexts_1.useFluent();
|
48
42
|
react_utilities_1.useOnClickOutside({
|
49
43
|
contains: react_portal_1.elementContains,
|
50
44
|
element: targetDocument,
|
51
|
-
callback:
|
52
|
-
return setOpen(ev, false);
|
53
|
-
},
|
45
|
+
callback: ev => setOpen(ev, false),
|
54
46
|
refs: [popperRefs.triggerRef, popperRefs.contentRef],
|
55
47
|
disabled: !open
|
56
48
|
});
|
57
49
|
react_utilities_1.useOnScrollOutside({
|
58
50
|
contains: react_portal_1.elementContains,
|
59
51
|
element: targetDocument,
|
60
|
-
callback:
|
61
|
-
return setOpen(ev, false);
|
62
|
-
},
|
52
|
+
callback: ev => setOpen(ev, false),
|
63
53
|
refs: [popperRefs.triggerRef, popperRefs.contentRef],
|
64
54
|
disabled: !open || !initialState.openOnContext
|
65
55
|
});
|
66
|
-
return
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
56
|
+
return { ...initialState,
|
57
|
+
...popperRefs,
|
58
|
+
open,
|
59
|
+
setOpen,
|
60
|
+
setContextTarget,
|
61
|
+
contextTarget
|
62
|
+
};
|
72
63
|
};
|
73
64
|
|
74
65
|
exports.usePopover = usePopover;
|
@@ -77,23 +68,19 @@ exports.usePopover = usePopover;
|
|
77
68
|
*/
|
78
69
|
|
79
70
|
function useOpenState(state) {
|
80
|
-
|
71
|
+
const onOpenChange = react_utilities_1.useEventCallback((e, data) => {
|
81
72
|
var _a;
|
82
73
|
|
83
74
|
return (_a = state.onOpenChange) === null || _a === void 0 ? void 0 : _a.call(state, e, data);
|
84
75
|
});
|
85
|
-
|
86
|
-
var _a = react_utilities_1.useControllableState({
|
76
|
+
const [open, setOpenState] = react_utilities_1.useControllableState({
|
87
77
|
state: state.open,
|
88
78
|
defaultState: state.defaultOpen,
|
89
79
|
initialState: false
|
90
|
-
})
|
91
|
-
open = _a[0],
|
92
|
-
setOpenState = _a[1];
|
93
|
-
|
80
|
+
});
|
94
81
|
state.open = open !== undefined ? open : state.open;
|
95
|
-
|
96
|
-
|
82
|
+
const setContextTarget = state.setContextTarget;
|
83
|
+
const setOpen = React.useCallback((e, shouldOpen) => {
|
97
84
|
if (shouldOpen && e.type === 'contextmenu') {
|
98
85
|
setContextTarget(e);
|
99
86
|
}
|
@@ -102,7 +89,7 @@ function useOpenState(state) {
|
|
102
89
|
setContextTarget(undefined);
|
103
90
|
}
|
104
91
|
|
105
|
-
setOpenState(
|
92
|
+
setOpenState(prevOpen => {
|
106
93
|
// More than one event (mouse, focus, keyboard) can request the Popover to close
|
107
94
|
// We assume the first event is the correct one
|
108
95
|
if (prevOpen !== shouldOpen) {
|
@@ -122,12 +109,12 @@ function useOpenState(state) {
|
|
122
109
|
|
123
110
|
|
124
111
|
function usePopoverRefs(state) {
|
125
|
-
|
112
|
+
const popperOptions = {
|
126
113
|
position: 'above',
|
127
114
|
align: 'center',
|
128
|
-
target: state.openOnContext ? state.contextTarget : undefined
|
129
|
-
|
130
|
-
|
115
|
+
target: state.openOnContext ? state.contextTarget : undefined,
|
116
|
+
...react_positioning_1.resolvePositioningShorthand(state.positioning)
|
117
|
+
}; // no reason to render arrow when covering the target
|
131
118
|
|
132
119
|
if (popperOptions.coverTarget) {
|
133
120
|
state.noArrow = true;
|
@@ -137,15 +124,15 @@ function usePopoverRefs(state) {
|
|
137
124
|
popperOptions.offset = react_positioning_1.mergeArrowOffset(popperOptions.offset, index_1.arrowHeights[state.size]);
|
138
125
|
}
|
139
126
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
127
|
+
const {
|
128
|
+
targetRef: triggerRef,
|
129
|
+
containerRef: contentRef,
|
130
|
+
arrowRef
|
131
|
+
} = react_positioning_1.usePopper(popperOptions);
|
145
132
|
return {
|
146
|
-
triggerRef
|
147
|
-
contentRef
|
148
|
-
arrowRef
|
133
|
+
triggerRef,
|
134
|
+
contentRef,
|
135
|
+
arrowRef
|
149
136
|
};
|
150
137
|
}
|
151
138
|
//# sourceMappingURL=usePopover.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Popover/usePopover.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"sources":["../../../src/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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
const React = /*#__PURE__*/require("react");
|
9
9
|
|
10
|
-
|
10
|
+
const usePopoverSurface_1 = /*#__PURE__*/require("./usePopoverSurface");
|
11
11
|
|
12
|
-
|
12
|
+
const renderPopoverSurface_1 = /*#__PURE__*/require("./renderPopoverSurface");
|
13
13
|
|
14
|
-
|
14
|
+
const usePopoverSurfaceStyles_1 = /*#__PURE__*/require("./usePopoverSurfaceStyles");
|
15
15
|
/**
|
16
16
|
* PopoverSurface component renders react children in a positioned box
|
17
17
|
*/
|
18
18
|
|
19
19
|
|
20
|
-
exports.PopoverSurface = /*#__PURE__*/React.forwardRef(
|
21
|
-
|
20
|
+
exports.PopoverSurface = /*#__PURE__*/React.forwardRef((props, ref) => {
|
21
|
+
const state = usePopoverSurface_1.usePopoverSurface(props, ref);
|
22
22
|
usePopoverSurfaceStyles_1.usePopoverSurfaceStyles(state);
|
23
23
|
return renderPopoverSurface_1.renderPopoverSurface(state);
|
24
24
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PopoverSurface/PopoverSurface.tsx"],"names":[],"mappings":";;;;;;;AAAA,
|
1
|
+
{"version":3,"sources":["../../../src/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;AACtG,QAAM,KAAK,GAAG,mBAAA,CAAA,iBAAA,CAAkB,KAAlB,EAAyB,GAAzB,CAAd;AAEA,EAAA,yBAAA,CAAA,uBAAA,CAAwB,KAAxB;AACA,SAAO,sBAAA,CAAA,oBAAA,CAAqB,KAArB,CAAP;AACD,CALuE,CAA3D;AAOb,OAAA,CAAA,cAAA,CAAe,WAAf,GAA6B,gBAA7B","sourceRoot":""}
|
@@ -5,25 +5,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.renderPopoverSurface = void 0;
|
7
7
|
|
8
|
-
|
8
|
+
const React = /*#__PURE__*/require("react");
|
9
9
|
|
10
|
-
|
10
|
+
const react_portal_1 = /*#__PURE__*/require("@fluentui/react-portal");
|
11
11
|
|
12
|
-
|
12
|
+
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
var usePopoverSurface_1 = /*#__PURE__*/require("./usePopoverSurface");
|
14
|
+
const usePopoverSurface_1 = /*#__PURE__*/require("./usePopoverSurface");
|
17
15
|
/**
|
18
16
|
* Render the final JSX of PopoverSurface
|
19
17
|
*/
|
20
18
|
|
21
19
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
const renderPopoverSurface = state => {
|
21
|
+
const {
|
22
|
+
slots,
|
23
|
+
slotProps
|
24
|
+
} = react_utilities_1.getSlots(state, usePopoverSurface_1.popoverSurfaceSlots); // TODO should hidden Popovers be supported ?
|
27
25
|
|
28
26
|
if (!state.open) {
|
29
27
|
return null;
|
@@ -31,7 +29,7 @@ var renderPopoverSurface = function (state) {
|
|
31
29
|
|
32
30
|
return React.createElement(react_portal_1.Portal, {
|
33
31
|
mountNode: state.mountNode
|
34
|
-
}, React.createElement(slots.root,
|
32
|
+
}, React.createElement(slots.root, Object.assign({}, slotProps.root), !state.noArrow && React.createElement("div", {
|
35
33
|
ref: state.arrowRef,
|
36
34
|
className: state.arrowClassName
|
37
35
|
}), slotProps.root.children));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PopoverSurface/renderPopoverSurface.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"sources":["../../../src/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;;AAEA,MAAA,mBAAA,gBAAA,OAAA,CAAA,qBAAA,CAAA;AAEA;;AAEG;;;AACI,MAAM,oBAAoB,GAAI,KAAD,IAA+B;AACjE,QAAM;AAAE,IAAA,KAAF;AAAS,IAAA;AAAT,MAAuB,iBAAA,CAAA,QAAA,CAA8B,KAA9B,EAAqC,mBAAA,CAAA,mBAArC,CAA7B,CADiE,CAGjE;;AACA,MAAI,CAAC,KAAK,CAAC,IAAX,EAAiB;AACf,WAAO,IAAP;AACD;;AAED,SACE,KAAA,CAAA,aAAA,CAAC,cAAA,CAAA,MAAD,EAAO;AAAC,IAAA,SAAS,EAAE,KAAK,CAAC;AAAlB,GAAP,EACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,MAAA,CAAA,MAAA,CAAA,EAAA,EAAK,SAAS,CAAC,IAAf,CAAX,EACG,CAAC,KAAK,CAAC,OAAP,IAAkB,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAK,IAAA,GAAG,EAAE,KAAK,CAAC,QAAhB;AAA0B,IAAA,SAAS,EAAE,KAAK,CAAC;AAA3C,GAAA,CADrB,EAEG,SAAS,CAAC,IAAV,CAAe,QAFlB,CADF,CADF;AAQD,CAhBM;;AAAM,OAAA,CAAA,oBAAA,GAAoB,oBAApB","sourceRoot":""}
|
@@ -5,15 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.usePopoverSurface = exports.popoverSurfaceSlots = void 0;
|
7
7
|
|
8
|
-
|
8
|
+
const React = /*#__PURE__*/require("react");
|
9
9
|
|
10
|
-
|
10
|
+
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
11
11
|
|
12
|
-
|
12
|
+
const react_tabster_1 = /*#__PURE__*/require("@fluentui/react-tabster");
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
var popoverContext_1 = /*#__PURE__*/require("../../popoverContext");
|
14
|
+
const popoverContext_1 = /*#__PURE__*/require("../../popoverContext");
|
17
15
|
|
18
16
|
exports.popoverSurfaceSlots = ['root'];
|
19
17
|
/**
|
@@ -26,61 +24,46 @@ exports.popoverSurfaceSlots = ['root'];
|
|
26
24
|
* @param ref - reference to root HTMLDivElement of PopoverSurface
|
27
25
|
*/
|
28
26
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
});
|
45
|
-
var arrowRef = popoverContext_1.usePopoverContext(function (context) {
|
46
|
-
return context.arrowRef;
|
47
|
-
});
|
48
|
-
var size = popoverContext_1.usePopoverContext(function (context) {
|
49
|
-
return context.size;
|
50
|
-
});
|
51
|
-
var noArrow = popoverContext_1.usePopoverContext(function (context) {
|
52
|
-
return context.noArrow;
|
53
|
-
});
|
54
|
-
var appearance = popoverContext_1.usePopoverContext(function (context) {
|
55
|
-
return context.appearance;
|
56
|
-
});
|
57
|
-
var trapFocus = popoverContext_1.usePopoverContext(function (context) {
|
58
|
-
return context.trapFocus;
|
27
|
+
const usePopoverSurface = (props, ref) => {
|
28
|
+
const contentRef = popoverContext_1.usePopoverContext(context => context.contentRef);
|
29
|
+
const open = popoverContext_1.usePopoverContext(context => context.open);
|
30
|
+
const openOnHover = popoverContext_1.usePopoverContext(context => context.openOnHover);
|
31
|
+
const setOpen = popoverContext_1.usePopoverContext(context => context.setOpen);
|
32
|
+
const mountNode = popoverContext_1.usePopoverContext(context => context.mountNode);
|
33
|
+
const arrowRef = popoverContext_1.usePopoverContext(context => context.arrowRef);
|
34
|
+
const size = popoverContext_1.usePopoverContext(context => context.size);
|
35
|
+
const noArrow = popoverContext_1.usePopoverContext(context => context.noArrow);
|
36
|
+
const appearance = popoverContext_1.usePopoverContext(context => context.appearance);
|
37
|
+
const trapFocus = popoverContext_1.usePopoverContext(context => context.trapFocus);
|
38
|
+
const {
|
39
|
+
modalAttributes
|
40
|
+
} = react_tabster_1.useModalAttributes({
|
41
|
+
trapFocus
|
59
42
|
});
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
arrowRef: arrowRef,
|
68
|
-
open: open,
|
69
|
-
mountNode: mountNode,
|
43
|
+
const state = {
|
44
|
+
appearance,
|
45
|
+
noArrow,
|
46
|
+
size,
|
47
|
+
arrowRef,
|
48
|
+
open,
|
49
|
+
mountNode,
|
70
50
|
components: {
|
71
51
|
root: 'div'
|
72
52
|
},
|
73
|
-
root: react_utilities_1.getNativeElementProps('div',
|
53
|
+
root: react_utilities_1.getNativeElementProps('div', {
|
74
54
|
ref: react_utilities_1.useMergedRefs(ref, contentRef),
|
75
|
-
role: 'dialog'
|
76
|
-
|
55
|
+
role: 'dialog',
|
56
|
+
...modalAttributes,
|
57
|
+
...props
|
58
|
+
})
|
77
59
|
};
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
60
|
+
const {
|
61
|
+
onMouseEnter: onMouseEnterOriginal,
|
62
|
+
onMouseLeave: onMouseLeaveOriginal,
|
63
|
+
onKeyDown: onKeyDownOriginal
|
64
|
+
} = state.root;
|
82
65
|
|
83
|
-
state.root.onMouseEnter =
|
66
|
+
state.root.onMouseEnter = e => {
|
84
67
|
if (openOnHover) {
|
85
68
|
setOpen(e, true);
|
86
69
|
}
|
@@ -88,7 +71,7 @@ var usePopoverSurface = function (props, ref) {
|
|
88
71
|
onMouseEnterOriginal === null || onMouseEnterOriginal === void 0 ? void 0 : onMouseEnterOriginal(e);
|
89
72
|
};
|
90
73
|
|
91
|
-
state.root.onMouseLeave =
|
74
|
+
state.root.onMouseLeave = e => {
|
92
75
|
if (openOnHover) {
|
93
76
|
setOpen(e, false);
|
94
77
|
}
|
@@ -96,7 +79,7 @@ var usePopoverSurface = function (props, ref) {
|
|
96
79
|
onMouseLeaveOriginal === null || onMouseLeaveOriginal === void 0 ? void 0 : onMouseLeaveOriginal(e);
|
97
80
|
};
|
98
81
|
|
99
|
-
state.root.onKeyDown =
|
82
|
+
state.root.onKeyDown = e => {
|
100
83
|
var _a; // only close if the event happened inside the current popover
|
101
84
|
// If using a stack of inline popovers, the user should call `stopPropagation` to avoid dismissing the entire stack
|
102
85
|
|
@@ -108,10 +91,12 @@ var usePopoverSurface = function (props, ref) {
|
|
108
91
|
onKeyDownOriginal === null || onKeyDownOriginal === void 0 ? void 0 : onKeyDownOriginal(e);
|
109
92
|
};
|
110
93
|
|
111
|
-
|
112
|
-
|
94
|
+
const {
|
95
|
+
findFirstFocusable
|
96
|
+
} = react_tabster_1.useFocusFinders();
|
97
|
+
React.useEffect(() => {
|
113
98
|
if (state.open && contentRef.current) {
|
114
|
-
|
99
|
+
const firstFocusable = findFirstFocusable(contentRef.current);
|
115
100
|
firstFocusable === null || firstFocusable === void 0 ? void 0 : firstFocusable.focus();
|
116
101
|
}
|
117
102
|
}, [contentRef, findFirstFocusable, state.open]);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PopoverSurface/usePopoverSurface.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"sources":["../../../src/components/PopoverSurface/usePopoverSurface.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;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,OAAA,CAAA,mBAAA,GAAwD,CAAC,MAAD,CAAxD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,EAAoF;AAClF,MAAA,OAAO,CAAC,CAAD,EAAI,KAAJ,CAAP;AACD;;AAED,IAAA,iBAAiB,KAAA,IAAjB,IAAA,iBAAiB,KAAA,KAAA,CAAjB,GAAiB,KAAA,CAAjB,GAAA,iBAAiB,CAAG,CAAH,CAAjB;AACD,GARD;;AAUA,QAAM;AAAE,IAAA;AAAF,MAAyB,eAAA,CAAA,eAAA,EAA/B;AAEA,EAAA,KAAK,CAAC,SAAN,CAAgB,MAAK;AACnB,QAAI,KAAK,CAAC,IAAN,IAAc,UAAU,CAAC,OAA7B,EAAsC;AACpC,YAAM,cAAc,GAAG,kBAAkB,CAAC,UAAU,CAAC,OAAZ,CAAzC;AACA,MAAA,cAAc,KAAA,IAAd,IAAA,cAAc,KAAA,KAAA,CAAd,GAAc,KAAA,CAAd,GAAA,cAAc,CAAE,KAAhB,EAAA;AACD;AACF,GALD,EAKG,CAAC,UAAD,EAAa,kBAAb,EAAiC,KAAK,CAAC,IAAvC,CALH;AAMA,SAAO,KAAP;AACD,CAvEM;;AAAM,OAAA,CAAA,iBAAA,GAAiB,iBAAjB","sourceRoot":""}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import type { PopoverSize } from '../Popover/Popover.types';
|
2
2
|
import type { PopoverSurfaceState } from './PopoverSurface.types';
|
3
|
+
export declare const popoverSurfaceClassName = "fui-PopoverSurface";
|
3
4
|
export declare const arrowHeights: Record<PopoverSize, number>;
|
4
5
|
/**
|
5
6
|
* Apply styling to the PopoverSurface slots based on the state
|