@fluentui/react-popover 9.0.0-beta.1 → 9.0.0-beta.5
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +287 -1
- package/CHANGELOG.md +72 -2
- package/dist/react-popover.d.ts +7 -3
- package/lib/components/Popover/Popover.js +2 -2
- package/lib/components/Popover/Popover.js.map +1 -1
- package/lib/components/Popover/Popover.types.d.ts +5 -3
- 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/components/Popover/Popover.js +4 -4
- package/lib-commonjs/components/Popover/Popover.js.map +1 -1
- package/lib-commonjs/components/Popover/Popover.types.d.ts +5 -3
- 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 +13 -13
- package/lib/common/isConformant.d.ts +0 -4
- package/lib/common/isConformant.js +0 -13
- package/lib/common/isConformant.js.map +0 -1
- package/lib/common/mockUsePopoverContext.d.ts +0 -7
- package/lib/common/mockUsePopoverContext.js +0 -38
- package/lib/common/mockUsePopoverContext.js.map +0 -1
- package/lib-commonjs/common/isConformant.d.ts +0 -4
- package/lib-commonjs/common/isConformant.js +0 -24
- package/lib-commonjs/common/isConformant.js.map +0 -1
- package/lib-commonjs/common/mockUsePopoverContext.d.ts +0 -7
- package/lib-commonjs/common/mockUsePopoverContext.js +0 -49
- package/lib-commonjs/common/mockUsePopoverContext.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PopoverTrigger/usePopoverTrigger.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"sources":["../../../src/components/PopoverTrigger/usePopoverTrigger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,aAAT,EAAwB,gBAAxB,EAA0C,6BAA1C,QAA+E,2BAA/E;AACA,SAAS,kBAAT,QAAmC,yBAAnC;AACA,SAAS,iBAAT,QAAkC,sBAAlC;AAGA;;;;;;;AAOG;;AACH,OAAO,MAAM,iBAAiB,GAAI,KAAD,IAAoD;AACnF,QAAM,OAAO,GAAG,iBAAiB,CAAC,OAAO,IAAI,OAAO,CAAC,OAApB,CAAjC;AACA,QAAM,IAAI,GAAG,iBAAiB,CAAC,OAAO,IAAI,OAAO,CAAC,IAApB,CAA9B;AACA,QAAM,UAAU,GAAG,iBAAiB,CAAC,OAAO,IAAI,OAAO,CAAC,UAApB,CAApC;AACA,QAAM,WAAW,GAAG,iBAAiB,CAAC,OAAO,IAAI,OAAO,CAAC,WAApB,CAArC;AACA,QAAM,aAAa,GAAG,iBAAiB,CAAC,OAAO,IAAI,OAAO,CAAC,aAApB,CAAvC;AACA,QAAM,SAAS,GAAG,iBAAiB,CAAC,OAAO,IAAI,OAAO,CAAC,SAApB,CAAnC;AACA,QAAM;AAAE,IAAA;AAAF,MAAwB,kBAAkB,EAAhD;AAEA,QAAM,aAAa,GAAG,gBAAgB,CAAE,CAAD,IAAqC;;;AAC1E,QAAI,aAAJ,EAAmB;AACjB,MAAA,CAAC,CAAC,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IAAA,QAAQ,eAAE,KAAK,CAAC,YAAN,CAAmB,KAAnB,EAA0B,EAClC,GAAG,iBAD+B;AAElC,uBAAiB,SAAS,GAAG,QAAH,GAAc,MAFN;AAGlC,SAAG,KAAK,CAAC,KAHyB;AAIlC,MAAA,OAJkC;AAKlC,MAAA,YALkC;AAMlC,MAAA,SANkC;AAOlC,MAAA,YAPkC;AAQlC,MAAA,aARkC;AASlC,MAAA,GAAG,EAAE,aAAa,CAAG,KAAuE,CAAC,GAA3E,EAAgF,UAAhF;AATgB,KAA1B;AADL,GAAP;AAaD,CAlEM","sourceRoot":""}
|
package/lib/popoverContext.js
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
import { createContext, useContextSelector } from '@fluentui/react-context-selector';
|
2
|
-
export
|
2
|
+
export const PopoverContext = /*#__PURE__*/createContext({
|
3
3
|
open: false,
|
4
|
-
setOpen:
|
5
|
-
return null;
|
6
|
-
},
|
4
|
+
setOpen: () => null,
|
7
5
|
triggerRef: {
|
8
6
|
current: null
|
9
7
|
},
|
@@ -18,7 +16,5 @@ export var PopoverContext = /*#__PURE__*/createContext({
|
|
18
16
|
size: 'medium',
|
19
17
|
trapFocus: false
|
20
18
|
});
|
21
|
-
export
|
22
|
-
return useContextSelector(PopoverContext, selector);
|
23
|
-
};
|
19
|
+
export const usePopoverContext = selector => useContextSelector(PopoverContext, selector);
|
24
20
|
//# sourceMappingURL=popoverContext.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/popoverContext.ts"],"names":[],"mappings":"AAAA,SAAS,aAAT,EAAwB,kBAAxB,QAAkD,kCAAlD;AAIA,OAAO,
|
1
|
+
{"version":3,"sources":["../src/popoverContext.ts"],"names":[],"mappings":"AAAA,SAAS,aAAT,EAAwB,kBAAxB,QAAkD,kCAAlD;AAIA,OAAO,MAAM,cAAc,gBAAiC,aAAa,CAAsB;AAC7F,EAAA,IAAI,EAAE,KADuF;AAE7F,EAAA,OAAO,EAAE,MAAM,IAF8E;AAG7F,EAAA,UAAU,EAAE;AAAE,IAAA,OAAO,EAAE;AAAX,GAHiF;AAI7F,EAAA,UAAU,EAAE;AAAE,IAAA,OAAO,EAAE;AAAX,GAJiF;AAK7F,EAAA,QAAQ,EAAE;AAAE,IAAA,OAAO,EAAE;AAAX,GALmF;AAM7F,EAAA,aAAa,EAAE,KAN8E;AAO7F,EAAA,WAAW,EAAE,KAPgF;AAQ7F,EAAA,IAAI,EAAE,QARuF;AAS7F,EAAA,SAAS,EAAE;AATkF,CAAtB,CAAlE;AA+BP,OAAO,MAAM,iBAAiB,GAAO,QAAJ,IAC/B,kBAAkB,CAAC,cAAD,EAAiB,QAAjB,CADb","sourceRoot":""}
|
package/lib-commonjs/Popover.js
CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
|
7
|
-
|
7
|
+
const tslib_1 = /*#__PURE__*/require("tslib");
|
8
8
|
|
9
9
|
tslib_1.__exportStar(require("./components/Popover/index"), exports);
|
10
10
|
//# sourceMappingURL=Popover.js.map
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
|
7
|
-
|
7
|
+
const tslib_1 = /*#__PURE__*/require("tslib");
|
8
8
|
|
9
9
|
tslib_1.__exportStar(require("./components/PopoverSurface/index"), exports);
|
10
10
|
//# sourceMappingURL=PopoverSurface.js.map
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
|
7
|
-
|
7
|
+
const tslib_1 = /*#__PURE__*/require("tslib");
|
8
8
|
|
9
9
|
tslib_1.__exportStar(require("./components/PopoverTrigger/index"), exports);
|
10
10
|
//# sourceMappingURL=PopoverTrigger.js.map
|
@@ -5,16 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.Popover = void 0;
|
7
7
|
|
8
|
-
|
8
|
+
const usePopover_1 = /*#__PURE__*/require("./usePopover");
|
9
9
|
|
10
|
-
|
10
|
+
const renderPopover_1 = /*#__PURE__*/require("./renderPopover");
|
11
11
|
/**
|
12
12
|
* Wrapper component that manages state for a PopoverTrigger and a PopoverSurface components.
|
13
13
|
*/
|
14
14
|
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
const Popover = props => {
|
17
|
+
const state = usePopover_1.usePopover(props);
|
18
18
|
return renderPopover_1.renderPopover(state);
|
19
19
|
};
|
20
20
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Popover/Popover.tsx"],"names":[],"mappings":";;;;;;;AACA,
|
1
|
+
{"version":3,"sources":["../../../src/components/Popover/Popover.tsx"],"names":[],"mappings":";;;;;;;AACA,MAAA,YAAA,gBAAA,OAAA,CAAA,cAAA,CAAA;;AACA,MAAA,eAAA,gBAAA,OAAA,CAAA,iBAAA,CAAA;AAGA;;AAEG;;;AACI,MAAM,OAAO,GAA2B,KAAK,IAAG;AACrD,QAAM,KAAK,GAAG,YAAA,CAAA,UAAA,CAAW,KAAX,CAAd;AAEA,SAAO,eAAA,CAAA,aAAA,CAAc,KAAd,CAAP;AACD,CAJM;;AAAM,OAAA,CAAA,OAAA,GAAO,OAAP;AAMb,OAAA,CAAA,OAAA,CAAQ,WAAR,GAAsB,SAAtB","sourceRoot":""}
|
@@ -55,8 +55,8 @@ export declare type PopoverCommons = Pick<PortalProps, 'mountNode'> & {
|
|
55
55
|
*/
|
56
56
|
export declare type PopoverProps = Partial<PopoverCommons> & {
|
57
57
|
/**
|
58
|
-
* Can contain two children including {@link PopoverTrigger} and {@link
|
59
|
-
* Alternatively can only contain {@link
|
58
|
+
* Can contain two children including {@link PopoverTrigger} and {@link PopoverSurface}.
|
59
|
+
* Alternatively can only contain {@link PopoverSurface} if using a custom `target`.
|
60
60
|
*/
|
61
61
|
children: [JSX.Element, JSX.Element] | JSX.Element;
|
62
62
|
};
|
@@ -93,7 +93,9 @@ export declare type PopoverState = PopoverCommons & Pick<PopoverProps, 'children
|
|
93
93
|
/**
|
94
94
|
* Data attached to open/close events
|
95
95
|
*/
|
96
|
-
export declare type OnOpenChangeData =
|
96
|
+
export declare type OnOpenChangeData = {
|
97
|
+
open: boolean;
|
98
|
+
};
|
97
99
|
/**
|
98
100
|
* The supported events that will trigger open/close of the menu
|
99
101
|
*/
|
@@ -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/us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AV,CAAtE;AAEA,SAAO;AACL,IAAA,UADK;AAEL,IAAA,UAFK;AAGL,IAAA;AAHK,GAAP;AAKD","sourceRoot":""}
|
@@ -5,20 +5,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.PopoverSurface = void 0;
|
7
7
|
|
8
|
-
|
8
|
+
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":""}
|