@fluentui/react-portal 9.0.14 → 9.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +75 -1
- package/CHANGELOG.md +25 -2
- package/dist/index.d.ts +2 -2
- package/lib/components/Portal/Portal.js +0 -1
- package/lib/components/Portal/Portal.js.map +1 -1
- package/lib/components/Portal/renderPortal.js +0 -1
- package/lib/components/Portal/renderPortal.js.map +1 -1
- package/lib/components/Portal/usePortal.js +0 -1
- package/lib/components/Portal/usePortal.js.map +1 -1
- package/lib/components/Portal/usePortalMountNode.js +23 -29
- package/lib/components/Portal/usePortalMountNode.js.map +1 -1
- package/lib/virtualParent/elementContains.js +0 -5
- package/lib/virtualParent/elementContains.js.map +1 -1
- package/lib/virtualParent/getParent.js +2 -2
- package/lib/virtualParent/getParent.js.map +1 -1
- package/lib/virtualParent/getVirtualParent.js +1 -8
- package/lib/virtualParent/getVirtualParent.js.map +1 -1
- package/lib/virtualParent/isVirtualElement.js.map +1 -1
- package/lib/virtualParent/setVirtualParent.js +0 -3
- package/lib/virtualParent/setVirtualParent.js.map +1 -1
- package/lib/virtualParent/types.js.map +1 -1
- package/lib-amd/components/Portal/usePortalMountNode.js +20 -21
- package/lib-amd/components/Portal/usePortalMountNode.js.map +1 -1
- package/lib-amd/virtualParent/elementContains.js.map +1 -1
- package/lib-amd/virtualParent/getParent.js +2 -1
- package/lib-amd/virtualParent/getParent.js.map +1 -1
- package/lib-amd/virtualParent/getVirtualParent.js +1 -5
- package/lib-amd/virtualParent/getVirtualParent.js.map +1 -1
- package/lib-amd/virtualParent/isVirtualElement.js.map +1 -1
- package/lib-amd/virtualParent/setVirtualParent.js.map +1 -1
- package/lib-amd/virtualParent/types.js.map +1 -1
- package/lib-commonjs/Portal.js +0 -2
- package/lib-commonjs/Portal.js.map +1 -1
- package/lib-commonjs/components/Portal/Portal.js +0 -5
- package/lib-commonjs/components/Portal/Portal.js.map +1 -1
- package/lib-commonjs/components/Portal/Portal.types.js.map +1 -1
- package/lib-commonjs/components/Portal/index.js +0 -5
- package/lib-commonjs/components/Portal/index.js.map +1 -1
- package/lib-commonjs/components/Portal/renderPortal.js +0 -5
- package/lib-commonjs/components/Portal/renderPortal.js.map +1 -1
- package/lib-commonjs/components/Portal/usePortal.js +0 -6
- package/lib-commonjs/components/Portal/usePortal.js.map +1 -1
- package/lib-commonjs/components/Portal/usePortalMountNode.js +23 -34
- package/lib-commonjs/components/Portal/usePortalMountNode.js.map +1 -1
- package/lib-commonjs/index.js +0 -4
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/virtualParent/elementContains.js +0 -8
- package/lib-commonjs/virtualParent/elementContains.js.map +1 -1
- package/lib-commonjs/virtualParent/getParent.js +2 -5
- package/lib-commonjs/virtualParent/getParent.js.map +1 -1
- package/lib-commonjs/virtualParent/getVirtualParent.js +1 -11
- package/lib-commonjs/virtualParent/getVirtualParent.js.map +1 -1
- package/lib-commonjs/virtualParent/index.js +0 -6
- package/lib-commonjs/virtualParent/index.js.map +1 -1
- package/lib-commonjs/virtualParent/isVirtualElement.js +0 -2
- package/lib-commonjs/virtualParent/isVirtualElement.js.map +1 -1
- package/lib-commonjs/virtualParent/setVirtualParent.js +0 -5
- package/lib-commonjs/virtualParent/setVirtualParent.js.map +1 -1
- package/lib-commonjs/virtualParent/types.js.map +1 -1
- package/package.json +7 -6
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"setVirtualParent.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/setVirtualParent.ts"],"names":[],"mappings":";;;;IAEA;;;;;OAKG;IACH,SAAgB,gBAAgB,CAAC,
|
1
|
+
{"version":3,"file":"setVirtualParent.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/setVirtualParent.ts"],"names":[],"mappings":";;;;IAEA;;;;;OAKG;IACH,SAAgB,gBAAgB,CAAC,KAAW,EAAE,MAAa;QACzD,IAAI,CAAC,KAAK,EAAE;YACV,OAAO;SACR;QAED,IAAM,YAAY,GAAG,KAAuB,CAAC;QAE7C,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE;YAC1B,YAAY,CAAC,QAAQ,GAAG,EAAE,CAAC;SAC5B;QAED,YAAY,CAAC,QAAQ,CAAC,MAAM,GAAG,MAAM,IAAI,SAAS,CAAC;IACrD,CAAC;IAZD,4CAYC","sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Sets the virtual parent of an element.\n *\n * @param child - Theme element to set the virtual parent\n * @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship\n */\nexport function setVirtualParent(child: Node, parent?: Node): void {\n if (!child) {\n return;\n }\n\n const virtualChild = child as VirtualElement;\n\n if (!virtualChild._virtual) {\n virtualChild._virtual = {};\n }\n\n virtualChild._virtual.parent = parent || undefined;\n}\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface VirtualElement extends
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface VirtualElement extends Node {\n _virtual: {\n parent?: Node;\n };\n}\n"]}
|
package/lib-commonjs/Portal.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-portal/src/Portal.ts"],"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/Portal.ts"],"sourcesContent":["export * from './components/Portal/index';\n"]}
|
@@ -4,21 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.Portal = void 0;
|
7
|
-
|
8
7
|
const usePortal_1 = /*#__PURE__*/require("./usePortal");
|
9
|
-
|
10
8
|
const renderPortal_1 = /*#__PURE__*/require("./renderPortal");
|
11
9
|
/**
|
12
10
|
* A portal provides a way to render children into a DOM node
|
13
11
|
* that exists outside the DOM hierarchy of the parent component.
|
14
12
|
*/
|
15
|
-
|
16
|
-
|
17
13
|
const Portal = props => {
|
18
14
|
const state = usePortal_1.usePortal_unstable(props);
|
19
15
|
return renderPortal_1.renderPortal_unstable(state);
|
20
16
|
};
|
21
|
-
|
22
17
|
exports.Portal = Portal;
|
23
18
|
exports.Portal.displayName = 'Portal';
|
24
19
|
//# sourceMappingURL=Portal.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAEA;AACA;AAGA;;;;AAIO,MAAMA,MAAM,GAA0BC,KAAK,IAAG;EACnD,MAAMC,KAAK,GAAGC,8BAAkB,CAACF,KAAK,CAAC;EAEvC,OAAOG,oCAAqB,CAACF,KAAK,CAAC;AACrC,CAAC;AAJYG,cAAM;AAMnBA,cAAM,CAACC,WAAW,GAAG,QAAQ","names":["Portal","props","state","usePortal_1","renderPortal_1","exports","displayName"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/components/Portal/Portal.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { usePortal_unstable } from './usePortal';\nimport { renderPortal_unstable } from './renderPortal';\nimport type { PortalProps } from './Portal.types';\n\n/**\n * A portal provides a way to render children into a DOM node\n * that exists outside the DOM hierarchy of the parent component.\n */\nexport const Portal: React.FC<PortalProps> = props => {\n const state = usePortal_unstable(props);\n\n return renderPortal_unstable(state);\n};\n\nPortal.displayName = 'Portal';\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"","names":[],"sourceRoot":"../src/","sources":[],"sourcesContent":[]}
|
@@ -3,14 +3,9 @@
|
|
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("./Portal"), exports);
|
10
|
-
|
11
8
|
tslib_1.__exportStar(require("./Portal.types"), exports);
|
12
|
-
|
13
9
|
tslib_1.__exportStar(require("./renderPortal"), exports);
|
14
|
-
|
15
10
|
tslib_1.__exportStar(require("./usePortal"), exports);
|
16
11
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-portal/src/components/Portal/index.ts"],"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAAA;AACAA;AACAA;AACAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/components/Portal/index.ts"],"sourcesContent":["export * from './Portal';\nexport * from './Portal.types';\nexport * from './renderPortal';\nexport * from './usePortal';\n"]}
|
@@ -4,21 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.renderPortal_unstable = void 0;
|
7
|
-
|
8
7
|
const ReactDOM = /*#__PURE__*/require("react-dom");
|
9
|
-
|
10
8
|
const React = /*#__PURE__*/require("react");
|
11
9
|
/**
|
12
10
|
* Render the final JSX of Portal
|
13
11
|
*/
|
14
|
-
|
15
|
-
|
16
12
|
const renderPortal_unstable = state => {
|
17
13
|
return React.createElement("span", {
|
18
14
|
hidden: true,
|
19
15
|
ref: state.virtualParentRootRef
|
20
16
|
}, state.mountNode && ReactDOM.createPortal(state.children, state.mountNode));
|
21
17
|
};
|
22
|
-
|
23
18
|
exports.renderPortal_unstable = renderPortal_unstable;
|
24
19
|
//# sourceMappingURL=renderPortal.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AAGA;;;AAGO,MAAMA,qBAAqB,GAAIC,KAAkB,IAAwB;EAC9E,OACEC;IAAMC,MAAM;IAACC,GAAG,EAAEH,KAAK,CAACI;EAAoB,GACzCJ,KAAK,CAACK,SAAS,IAAIC,QAAQ,CAACC,YAAY,CAACP,KAAK,CAACQ,QAAQ,EAAER,KAAK,CAACK,SAAS,CAAC,CACrE;AAEX,CAAC;AANYI,6BAAqB","names":["renderPortal_unstable","state","React","hidden","ref","virtualParentRootRef","mountNode","ReactDOM","createPortal","children","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/components/Portal/renderPortal.tsx"],"sourcesContent":["import * as ReactDOM from 'react-dom';\nimport * as React from 'react';\nimport type { PortalState } from './Portal.types';\n\n/**\n * Render the final JSX of Portal\n */\nexport const renderPortal_unstable = (state: PortalState): React.ReactElement => {\n return (\n <span hidden ref={state.virtualParentRootRef}>\n {state.mountNode && ReactDOM.createPortal(state.children, state.mountNode)}\n </span>\n );\n};\n"]}
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.usePortal_unstable = void 0;
|
7
|
-
|
8
7
|
const React = /*#__PURE__*/require("react");
|
9
|
-
|
10
8
|
const usePortalMountNode_1 = /*#__PURE__*/require("./usePortalMountNode");
|
11
|
-
|
12
9
|
const index_1 = /*#__PURE__*/require("../../virtualParent/index");
|
13
10
|
/**
|
14
11
|
* Create the state required to render Portal.
|
@@ -17,8 +14,6 @@ const index_1 = /*#__PURE__*/require("../../virtualParent/index");
|
|
17
14
|
*
|
18
15
|
* @param props - props from this instance of Portal
|
19
16
|
*/
|
20
|
-
|
21
|
-
|
22
17
|
const usePortal_unstable = props => {
|
23
18
|
const {
|
24
19
|
children,
|
@@ -40,6 +35,5 @@ const usePortal_unstable = props => {
|
|
40
35
|
}, [state.virtualParentRootRef, state.mountNode]);
|
41
36
|
return state;
|
42
37
|
};
|
43
|
-
|
44
38
|
exports.usePortal_unstable = usePortal_unstable;
|
45
39
|
//# sourceMappingURL=usePortal.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AACA;AAGA;;;;;;;AAOO,MAAMA,kBAAkB,GAAIC,KAAkB,IAAiB;EACpE,MAAM;IAAEC,QAAQ;IAAEC;EAAS,CAAE,GAAGF,KAAK;EAErC,MAAMG,oBAAoB,GAAGC,KAAK,CAACC,MAAM,CAAkB,IAAI,CAAC;EAChE,MAAMC,iBAAiB,GAAGC,uCAAkB,CAAC;IAAEC,QAAQ,EAAE,CAAC,CAACN;EAAS,CAAE,CAAC;EAEvE,MAAMO,KAAK,GAAgB;IACzBR,QAAQ;IACRC,SAAS,EAAEA,SAAS,aAATA,SAAS,cAATA,SAAS,GAAII,iBAAiB;IACzCH;GACD;EAEDC,KAAK,CAACM,SAAS,CAAC,MAAK;IACnB,IAAID,KAAK,CAACN,oBAAoB,CAACQ,OAAO,IAAIF,KAAK,CAACP,SAAS,EAAE;MACzDU,wBAAgB,CAACH,KAAK,CAACP,SAAS,EAAEO,KAAK,CAACN,oBAAoB,CAACQ,OAAO,CAAC;;EAEzE,CAAC,EAAE,CAACF,KAAK,CAACN,oBAAoB,EAAEM,KAAK,CAACP,SAAS,CAAC,CAAC;EAEjD,OAAOO,KAAK;AACd,CAAC;AAnBYI,0BAAkB","names":["usePortal_unstable","props","children","mountNode","virtualParentRootRef","React","useRef","fallbackMountNode","usePortalMountNode_1","disabled","state","useEffect","current","index_1","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/components/Portal/usePortal.ts"],"sourcesContent":["import * as React from 'react';\nimport { usePortalMountNode } from './usePortalMountNode';\nimport { setVirtualParent } from '../../virtualParent/index';\nimport type { PortalProps, PortalState } from './Portal.types';\n\n/**\n * Create the state required to render Portal.\n *\n * The returned state can be modified with hooks such as usePortalStyles, before being passed to renderPortal_unstable.\n *\n * @param props - props from this instance of Portal\n */\nexport const usePortal_unstable = (props: PortalProps): PortalState => {\n const { children, mountNode } = props;\n\n const virtualParentRootRef = React.useRef<HTMLSpanElement>(null);\n const fallbackMountNode = usePortalMountNode({ disabled: !!mountNode });\n\n const state: PortalState = {\n children,\n mountNode: mountNode ?? fallbackMountNode,\n virtualParentRootRef,\n };\n\n React.useEffect(() => {\n if (state.virtualParentRootRef.current && state.mountNode) {\n setVirtualParent(state.mountNode, state.virtualParentRootRef.current);\n }\n }, [state.virtualParentRootRef, state.mountNode]);\n\n return state;\n};\n"]}
|
@@ -4,28 +4,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.usePortalMountNode = void 0;
|
7
|
-
|
8
7
|
const React = /*#__PURE__*/require("react");
|
9
|
-
|
10
8
|
const react_shared_contexts_1 = /*#__PURE__*/require("@fluentui/react-shared-contexts");
|
11
|
-
|
12
9
|
const react_1 = /*#__PURE__*/require("@griffel/react");
|
13
|
-
|
14
10
|
const react_tabster_1 = /*#__PURE__*/require("@fluentui/react-tabster");
|
15
|
-
|
11
|
+
const use_disposable_1 = /*#__PURE__*/require("use-disposable");
|
12
|
+
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
13
|
+
// String concatenation is used to prevent bundlers to complain with older versions of React
|
14
|
+
const useInsertionEffect = React['useInsertion' + 'Effect'] ? React['useInsertion' + 'Effect'] : react_utilities_1.useIsomorphicLayoutEffect;
|
16
15
|
const useStyles = /*#__PURE__*/react_1.__styles({
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
root: {
|
17
|
+
qhf8xq: "f10pi13n",
|
18
|
+
Bj3rh1h: "f494woh"
|
20
19
|
}
|
21
20
|
}, {
|
22
|
-
|
21
|
+
d: [".f10pi13n{position:relative;}", ".f494woh{z-index:1000000;}"]
|
23
22
|
});
|
24
23
|
/**
|
25
24
|
* Creates a new element on a document.body to mount portals
|
26
25
|
*/
|
27
|
-
|
28
|
-
|
29
26
|
const usePortalMountNode = options => {
|
30
27
|
const {
|
31
28
|
targetDocument,
|
@@ -35,40 +32,32 @@ const usePortalMountNode = options => {
|
|
35
32
|
const classes = useStyles();
|
36
33
|
const themeClassName = react_shared_contexts_1.useThemeClassName_unstable();
|
37
34
|
const className = react_1.mergeClasses(themeClassName, classes.root);
|
38
|
-
const element =
|
35
|
+
const element = use_disposable_1.useDisposable(() => {
|
39
36
|
if (targetDocument === undefined || options.disabled) {
|
40
|
-
return null;
|
37
|
+
return [null, () => null];
|
41
38
|
}
|
42
|
-
|
43
39
|
const newElement = targetDocument.createElement('div');
|
44
40
|
targetDocument.body.appendChild(newElement);
|
45
|
-
return newElement;
|
46
|
-
}, [targetDocument
|
41
|
+
return [newElement, () => newElement.remove()];
|
42
|
+
}, [targetDocument]);
|
43
|
+
// This useEffect call is intentional
|
47
44
|
// We don't want to re-create the portal element when its attributes change.
|
48
45
|
// This also should not be done in an effect because, changing the value of css variables
|
49
46
|
// after initial mount can trigger interesting CSS side effects like transitions.
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
const classesToApply = className.split(' ').filter(Boolean);
|
54
|
-
element.classList.add(...classesToApply);
|
55
|
-
element.setAttribute('dir', dir);
|
56
|
-
focusVisibleRef.current = element;
|
57
|
-
return () => {
|
58
|
-
element.classList.remove(...classesToApply);
|
59
|
-
element.removeAttribute('dir');
|
60
|
-
};
|
47
|
+
useInsertionEffect(() => {
|
48
|
+
if (!element) {
|
49
|
+
return;
|
61
50
|
}
|
62
|
-
|
63
|
-
|
51
|
+
const classesToApply = className.split(' ').filter(Boolean);
|
52
|
+
element.classList.add(...classesToApply);
|
53
|
+
element.setAttribute('dir', dir);
|
54
|
+
focusVisibleRef.current = element;
|
64
55
|
return () => {
|
65
|
-
|
66
|
-
|
67
|
-
(_a = element === null || element === void 0 ? void 0 : element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(element);
|
56
|
+
element.classList.remove(...classesToApply);
|
57
|
+
element.removeAttribute('dir');
|
68
58
|
};
|
69
|
-
}, [element]);
|
59
|
+
}, [className, dir, element, focusVisibleRef]);
|
70
60
|
return element;
|
71
61
|
};
|
72
|
-
|
73
62
|
exports.usePortalMountNode = usePortalMountNode;
|
74
63
|
//# sourceMappingURL=usePortalMountNode.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AAIA;AACA;AACA;AACA;AAEA;AACA,MAAMA,kBAAkB,GAAIC,KAAe,CAAC,cAAc,GAAG,QAAQ,CAAC,GACjEA,KAAe,CAAC,cAAc,GAAG,QAAQ,CAAC,GAC3CC,2CAAyB;AAS7B,MAAMC,SAAS,gBAAGC,gBAAU;EAAA;IAAA;IAAA;EAAA;AAAA;EAAA;AAAA,EAK1B;AAEF;;;AAGO,MAAMC,kBAAkB,GAAIC,OAAkC,IAAwB;EAC3F,MAAM;IAAEC,cAAc;IAAEC;EAAG,CAAE,GAAGC,0CAAS,EAAE;EAC3C,MAAMC,eAAe,GAAGC,+BAAe,EAAgE;EACvG,MAAMC,OAAO,GAAGT,SAAS,EAAE;EAC3B,MAAMU,cAAc,GAAGJ,kDAAiB,EAAE;EAE1C,MAAMK,SAAS,GAAGV,oBAAY,CAACS,cAAc,EAAED,OAAO,CAACG,IAAI,CAAC;EAE5D,MAAMC,OAAO,GAAGC,8BAAa,CAAC,MAAK;IACjC,IAAIV,cAAc,KAAKW,SAAS,IAAIZ,OAAO,CAACa,QAAQ,EAAE;MACpD,OAAO,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC;;IAG3B,MAAMC,UAAU,GAAGb,cAAc,CAACc,aAAa,CAAC,KAAK,CAAC;IACtDd,cAAc,CAACe,IAAI,CAACC,WAAW,CAACH,UAAU,CAAC;IAC3C,OAAO,CAACA,UAAU,EAAE,MAAMA,UAAU,CAACI,MAAM,EAAE,CAAC;EAChD,CAAC,EAAE,CAACjB,cAAc,CAAC,CAAC;EAEpB;EACA;EACA;EACA;EACAP,kBAAkB,CAAC,MAAK;IACtB,IAAI,CAACgB,OAAO,EAAE;MACZ;;IAGF,MAAMS,cAAc,GAAGX,SAAS,CAACY,KAAK,CAAC,GAAG,CAAC,CAACC,MAAM,CAACC,OAAO,CAAC;IAE3DZ,OAAO,CAACa,SAAS,CAACC,GAAG,CAAC,GAAGL,cAAc,CAAC;IACxCT,OAAO,CAACe,YAAY,CAAC,KAAK,EAAEvB,GAAG,CAAC;IAChCE,eAAe,CAACsB,OAAO,GAAGhB,OAAO;IAEjC,OAAO,MAAK;MACVA,OAAO,CAACa,SAAS,CAACL,MAAM,CAAC,GAAGC,cAAc,CAAC;MAC3CT,OAAO,CAACiB,eAAe,CAAC,KAAK,CAAC;IAChC,CAAC;EACH,CAAC,EAAE,CAACnB,SAAS,EAAEN,GAAG,EAAEQ,OAAO,EAAEN,eAAe,CAAC,CAAC;EAE9C,OAAOM,OAAO;AAChB,CAAC;AAxCYkB,0BAAkB","names":["useInsertionEffect","React","react_utilities_1","useStyles","react_1","usePortalMountNode","options","targetDocument","dir","react_shared_contexts_1","focusVisibleRef","react_tabster_1","classes","themeClassName","className","root","element","use_disposable_1","undefined","disabled","newElement","createElement","body","appendChild","remove","classesToApply","split","filter","Boolean","classList","add","setAttribute","current","removeAttribute","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/components/Portal/usePortalMountNode.ts"],"sourcesContent":["import * as React from 'react';\nimport {\n useThemeClassName_unstable as useThemeClassName,\n useFluent_unstable as useFluent,\n} from '@fluentui/react-shared-contexts';\nimport { makeStyles, mergeClasses } from '@griffel/react';\nimport { useFocusVisible } from '@fluentui/react-tabster';\nimport { useDisposable } from 'use-disposable';\nimport { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\n\n// String concatenation is used to prevent bundlers to complain with older versions of React\nconst useInsertionEffect = (React as never)['useInsertion' + 'Effect']\n ? (React as never)['useInsertion' + 'Effect']\n : useIsomorphicLayoutEffect;\n\nexport type UsePortalMountNodeOptions = {\n /**\n * Since hooks cannot be called conditionally use this flag to disable creating the node\n */\n disabled?: boolean;\n};\n\nconst useStyles = makeStyles({\n root: {\n position: 'relative',\n zIndex: 1000000,\n },\n});\n\n/**\n * Creates a new element on a document.body to mount portals\n */\nexport const usePortalMountNode = (options: UsePortalMountNodeOptions): HTMLElement | null => {\n const { targetDocument, dir } = useFluent();\n const focusVisibleRef = useFocusVisible<HTMLDivElement>() as React.MutableRefObject<HTMLElement | null>;\n const classes = useStyles();\n const themeClassName = useThemeClassName();\n\n const className = mergeClasses(themeClassName, classes.root);\n\n const element = useDisposable(() => {\n if (targetDocument === undefined || options.disabled) {\n return [null, () => null];\n }\n\n const newElement = targetDocument.createElement('div');\n targetDocument.body.appendChild(newElement);\n return [newElement, () => newElement.remove()];\n }, [targetDocument]);\n\n // This useEffect call is intentional\n // We don't want to re-create the portal element when its attributes change.\n // This also should not be done in an effect because, changing the value of css variables\n // after initial mount can trigger interesting CSS side effects like transitions.\n useInsertionEffect(() => {\n if (!element) {\n return;\n }\n\n const classesToApply = className.split(' ').filter(Boolean);\n\n element.classList.add(...classesToApply);\n element.setAttribute('dir', dir);\n focusVisibleRef.current = element;\n\n return () => {\n element.classList.remove(...classesToApply);\n element.removeAttribute('dir');\n };\n }, [className, dir, element, focusVisibleRef]);\n\n return element;\n};\n"]}
|
package/lib-commonjs/index.js
CHANGED
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.setVirtualParent = exports.elementContains = exports.usePortal_unstable = exports.renderPortal_unstable = exports.Portal = void 0;
|
7
|
-
|
8
7
|
var index_1 = /*#__PURE__*/require("./components/Portal/index");
|
9
|
-
|
10
8
|
Object.defineProperty(exports, "Portal", {
|
11
9
|
enumerable: true,
|
12
10
|
get: function () {
|
@@ -25,9 +23,7 @@ Object.defineProperty(exports, "usePortal_unstable", {
|
|
25
23
|
return index_1.usePortal_unstable;
|
26
24
|
}
|
27
25
|
});
|
28
|
-
|
29
26
|
var index_2 = /*#__PURE__*/require("./virtualParent/index");
|
30
|
-
|
31
27
|
Object.defineProperty(exports, "elementContains", {
|
32
28
|
enumerable: true,
|
33
29
|
get: function () {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AAASA;EAAAC;EAAAC;IAAA,qBAAM;EAAA;AAAA;AAAEF;EAAAC;EAAAC;IAAA,oCAAqB;EAAA;AAAA;AAAEF;EAAAC;EAAAC;IAAA,iCAAkB;EAAA;AAAA;AAE1D;AAASF;EAAAC;EAAAC;IAAA,8BAAe;EAAA;AAAA;AAAEF;EAAAC;EAAAC;IAAA,+BAAgB;EAAA;AAAA","names":["Object","enumerable","get"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/index.ts"],"sourcesContent":["export { Portal, renderPortal_unstable, usePortal_unstable } from './components/Portal/index';\nexport type { PortalProps, PortalState } from './components/Portal/index';\nexport { elementContains, setVirtualParent } from './virtualParent/index';\n"]}
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.elementContains = void 0;
|
7
|
-
|
8
7
|
const getParent_1 = /*#__PURE__*/require("./getParent");
|
9
8
|
/**
|
10
9
|
* Similar functionality to `element.contains` DOM API for use with out of order DOM elements that
|
@@ -12,29 +11,22 @@ const getParent_1 = /*#__PURE__*/require("./getParent");
|
|
12
11
|
*
|
13
12
|
* @returns true if the child can find the parent in its virtual hierarchy
|
14
13
|
*/
|
15
|
-
|
16
|
-
|
17
14
|
function elementContains(parent, child) {
|
18
15
|
if (!parent || !child) {
|
19
16
|
return false;
|
20
17
|
}
|
21
|
-
|
22
18
|
if (parent === child) {
|
23
19
|
return true;
|
24
20
|
} else {
|
25
21
|
while (child) {
|
26
22
|
const nextParent = getParent_1.getParent(child);
|
27
|
-
|
28
23
|
if (nextParent === parent) {
|
29
24
|
return true;
|
30
25
|
}
|
31
|
-
|
32
26
|
child = nextParent;
|
33
27
|
}
|
34
28
|
}
|
35
|
-
|
36
29
|
return false;
|
37
30
|
}
|
38
|
-
|
39
31
|
exports.elementContains = elementContains;
|
40
32
|
//# sourceMappingURL=elementContains.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;;;;;;AAMA,SAAgBA,eAAe,CAACC,MAAmB,EAAEC,KAAkB;EACrE,IAAI,CAACD,MAAM,IAAI,CAACC,KAAK,EAAE;IACrB,OAAO,KAAK;;EAGd,IAAID,MAAM,KAAKC,KAAK,EAAE;IACpB,OAAO,IAAI;GACZ,MAAM;IACL,OAAOA,KAAK,EAAE;MACZ,MAAMC,UAAU,GAAGC,qBAAS,CAACF,KAAK,CAAC;MAEnC,IAAIC,UAAU,KAAKF,MAAM,EAAE;QACzB,OAAO,IAAI;;MAGbC,KAAK,GAAGC,UAAU;;;EAItB,OAAO,KAAK;AACd;AApBAE","names":["elementContains","parent","child","nextParent","getParent_1","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/virtualParent/elementContains.ts"],"sourcesContent":["import { getParent } from './getParent';\n/**\n * Similar functionality to `element.contains` DOM API for use with out of order DOM elements that\n * checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent\n *\n * @returns true if the child can find the parent in its virtual hierarchy\n */\nexport function elementContains(parent: Node | null, child: Node | null): boolean {\n if (!parent || !child) {\n return false;\n }\n\n if (parent === child) {\n return true;\n } else {\n while (child) {\n const nextParent = getParent(child);\n\n if (nextParent === parent) {\n return true;\n }\n\n child = nextParent;\n }\n }\n\n return false;\n}\n"]}
|
@@ -4,17 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.getParent = void 0;
|
7
|
-
|
8
7
|
const getVirtualParent_1 = /*#__PURE__*/require("./getVirtualParent");
|
9
8
|
/**
|
10
9
|
* Gets the element which is the parent of a given element.
|
11
10
|
* This method prefers the virtual parent over real DOM parent when present.
|
12
11
|
*/
|
13
|
-
|
14
|
-
|
15
12
|
function getParent(child) {
|
16
|
-
|
13
|
+
var _a;
|
14
|
+
return (_a = child && getVirtualParent_1.getVirtualParent(child) || (child === null || child === void 0 ? void 0 : child.parentNode)) !== null && _a !== void 0 ? _a : null;
|
17
15
|
}
|
18
|
-
|
19
16
|
exports.getParent = getParent;
|
20
17
|
//# sourceMappingURL=getParent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AAEA;;;;AAIA,SAAgBA,SAAS,CAACC,KAAkB;;EAC1C,OAAO,MAAEA,KAAK,IAAIC,mCAAgB,CAACD,KAAK,CAAC,KAAKA,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEE,UAAU,CAAC,mCAAI,IAAI;AAC1E;AAFAC","names":["getParent","child","getVirtualParent_1","parentNode","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/virtualParent/getParent.ts"],"sourcesContent":["import { getVirtualParent } from './getVirtualParent';\n\n/**\n * Gets the element which is the parent of a given element.\n * This method prefers the virtual parent over real DOM parent when present.\n */\nexport function getParent(child: Node | null): Node | null {\n return ((child && getVirtualParent(child)) || child?.parentNode) ?? null;\n}\n"]}
|
@@ -4,22 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.getVirtualParent = void 0;
|
7
|
-
|
8
7
|
const isVirtualElement_1 = /*#__PURE__*/require("./isVirtualElement");
|
9
8
|
/**
|
10
9
|
* Gets the virtual parent given the child element, if it exists.
|
11
10
|
*/
|
12
|
-
|
13
|
-
|
14
11
|
function getVirtualParent(child) {
|
15
|
-
|
16
|
-
|
17
|
-
if (isVirtualElement_1.isVirtualElement(child)) {
|
18
|
-
parent = child._virtual.parent;
|
19
|
-
}
|
20
|
-
|
21
|
-
return parent;
|
12
|
+
return isVirtualElement_1.isVirtualElement(child) ? child._virtual.parent : undefined;
|
22
13
|
}
|
23
|
-
|
24
14
|
exports.getVirtualParent = getVirtualParent;
|
25
15
|
//# sourceMappingURL=getVirtualParent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;;;AAGA,SAAgBA,gBAAgB,CAACC,KAAW;EAC1C,OAAOC,mCAAgB,CAACD,KAAK,CAAC,GAAGA,KAAK,CAACE,QAAQ,CAACC,MAAM,GAAGC,SAAS;AACpE;AAFAC","names":["getVirtualParent","child","isVirtualElement_1","_virtual","parent","undefined","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/virtualParent/getVirtualParent.ts"],"sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n/**\n * Gets the virtual parent given the child element, if it exists.\n */\nexport function getVirtualParent(child: Node): Node | undefined {\n return isVirtualElement(child) ? child._virtual.parent : undefined;\n}\n"]}
|
@@ -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("./elementContains"), exports);
|
10
|
-
|
11
8
|
tslib_1.__exportStar(require("./getParent"), exports);
|
12
|
-
|
13
9
|
tslib_1.__exportStar(require("./getVirtualParent"), exports);
|
14
|
-
|
15
10
|
tslib_1.__exportStar(require("./isVirtualElement"), exports);
|
16
|
-
|
17
11
|
tslib_1.__exportStar(require("./setVirtualParent"), exports);
|
18
12
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-portal/src/virtualParent/index.ts"],"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAAA;AACAA;AACAA;AACAA;AACAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/virtualParent/index.ts"],"sourcesContent":["export * from './elementContains';\nexport * from './getParent';\nexport * from './getVirtualParent';\nexport * from './isVirtualElement';\nexport * from './setVirtualParent';\n"]}
|
@@ -7,10 +7,8 @@ exports.isVirtualElement = void 0;
|
|
7
7
|
/**
|
8
8
|
* Determines whether or not an element has the virtual hierarchy extension.
|
9
9
|
*/
|
10
|
-
|
11
10
|
function isVirtualElement(element) {
|
12
11
|
return element && !!element._virtual;
|
13
12
|
}
|
14
|
-
|
15
13
|
exports.isVirtualElement = isVirtualElement;
|
16
14
|
//# sourceMappingURL=isVirtualElement.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAEA;;;AAGA,SAAgBA,gBAAgB,CAACC,OAA8B;EAC7D,OAAOA,OAAO,IAAI,CAAC,CAAkBA,OAAQ,CAACC,QAAQ;AACxD;AAFAC","names":["isVirtualElement","element","_virtual","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/virtualParent/isVirtualElement.ts"],"sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Determines whether or not an element has the virtual hierarchy extension.\n */\nexport function isVirtualElement(element: Node | VirtualElement): element is VirtualElement {\n return element && !!(<VirtualElement>element)._virtual;\n}\n"]}
|
@@ -10,20 +10,15 @@ exports.setVirtualParent = void 0;
|
|
10
10
|
* @param child - Theme element to set the virtual parent
|
11
11
|
* @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship
|
12
12
|
*/
|
13
|
-
|
14
13
|
function setVirtualParent(child, parent) {
|
15
14
|
if (!child) {
|
16
15
|
return;
|
17
16
|
}
|
18
|
-
|
19
17
|
const virtualChild = child;
|
20
|
-
|
21
18
|
if (!virtualChild._virtual) {
|
22
19
|
virtualChild._virtual = {};
|
23
20
|
}
|
24
|
-
|
25
21
|
virtualChild._virtual.parent = parent || undefined;
|
26
22
|
}
|
27
|
-
|
28
23
|
exports.setVirtualParent = setVirtualParent;
|
29
24
|
//# sourceMappingURL=setVirtualParent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAEA;;;;;;AAMA,SAAgBA,gBAAgB,CAACC,KAAW,EAAEC,MAAa;EACzD,IAAI,CAACD,KAAK,EAAE;IACV;;EAGF,MAAME,YAAY,GAAGF,KAAuB;EAE5C,IAAI,CAACE,YAAY,CAACC,QAAQ,EAAE;IAC1BD,YAAY,CAACC,QAAQ,GAAG,EAAE;;EAG5BD,YAAY,CAACC,QAAQ,CAACF,MAAM,GAAGA,MAAM,IAAIG,SAAS;AACpD;AAZAC","names":["setVirtualParent","child","parent","virtualChild","_virtual","undefined","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/virtualParent/setVirtualParent.ts"],"sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Sets the virtual parent of an element.\n *\n * @param child - Theme element to set the virtual parent\n * @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship\n */\nexport function setVirtualParent(child: Node, parent?: Node): void {\n if (!child) {\n return;\n }\n\n const virtualChild = child as VirtualElement;\n\n if (!virtualChild._virtual) {\n virtualChild._virtual = {};\n }\n\n virtualChild._virtual.parent = parent || undefined;\n}\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"","names":[],"sourceRoot":"../src/","sources":[],"sourcesContent":[]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-portal",
|
3
|
-
"version": "9.0
|
3
|
+
"version": "9.1.0",
|
4
4
|
"description": "A utility component that creates portals compatible with Fluent UI",
|
5
5
|
"main": "lib-commonjs/index.js",
|
6
6
|
"module": "lib/index.js",
|
@@ -27,14 +27,15 @@
|
|
27
27
|
"devDependencies": {
|
28
28
|
"@fluentui/eslint-plugin": "*",
|
29
29
|
"@fluentui/react-conformance": "*",
|
30
|
-
"@fluentui/scripts": "
|
30
|
+
"@fluentui/scripts": "*"
|
31
31
|
},
|
32
32
|
"dependencies": {
|
33
33
|
"@fluentui/react-shared-contexts": "^9.1.4",
|
34
|
-
"@fluentui/react-tabster": "^9.3.
|
35
|
-
"@fluentui/react-utilities": "^9.
|
36
|
-
"@griffel/react": "^1.
|
37
|
-
"tslib": "^2.1.0"
|
34
|
+
"@fluentui/react-tabster": "^9.3.6",
|
35
|
+
"@fluentui/react-utilities": "^9.4.0",
|
36
|
+
"@griffel/react": "^1.5.2",
|
37
|
+
"tslib": "^2.1.0",
|
38
|
+
"use-disposable": "^1.0.1"
|
38
39
|
},
|
39
40
|
"peerDependencies": {
|
40
41
|
"@types/react": ">=16.8.0 <19.0.0",
|