@fluentui/react-portal 0.0.0-nightly-20230317-1454.1 → 0.0.0-nightly-20230321-0440.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/CHANGELOG.json +9 -9
- package/CHANGELOG.md +7 -7
- package/lib/Portal.js +1 -1
- package/lib/Portal.js.map +1 -1
- package/lib/components/Portal/Portal.js +3 -4
- package/lib/components/Portal/Portal.js.map +1 -1
- package/lib/components/Portal/Portal.types.js +1 -1
- package/lib/components/Portal/Portal.types.js.map +1 -1
- package/lib/components/Portal/index.js +4 -4
- package/lib/components/Portal/index.js.map +1 -1
- package/lib/components/Portal/renderPortal.js +2 -2
- package/lib/components/Portal/renderPortal.js.map +1 -1
- package/lib/components/Portal/usePortal.js +6 -6
- package/lib/components/Portal/usePortal.js.map +1 -1
- package/lib/components/Portal/usePortalMountNode.js +11 -11
- package/lib/components/Portal/usePortalMountNode.js.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/virtualParent/elementContains.js +1 -1
- 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/index.js +2 -2
- package/lib/virtualParent/index.js.map +1 -1
- package/lib/virtualParent/isVirtualElement.js +2 -1
- package/lib/virtualParent/isVirtualElement.js.map +1 -1
- package/lib/virtualParent/setVirtualParent.js +2 -1
- package/lib/virtualParent/setVirtualParent.js.map +1 -1
- package/lib/virtualParent/types.js.map +1 -1
- package/lib-commonjs/Portal.js +4 -5
- package/lib-commonjs/Portal.js.map +1 -1
- package/lib-commonjs/components/Portal/Portal.js +14 -14
- package/lib-commonjs/components/Portal/Portal.js.map +1 -1
- package/lib-commonjs/components/Portal/Portal.types.js +2 -5
- package/lib-commonjs/components/Portal/Portal.types.js.map +1 -1
- package/lib-commonjs/components/Portal/index.js +7 -8
- package/lib-commonjs/components/Portal/index.js.map +1 -1
- package/lib-commonjs/components/Portal/renderPortal.js +15 -15
- package/lib-commonjs/components/Portal/renderPortal.js.map +1 -1
- package/lib-commonjs/components/Portal/usePortal.js +55 -56
- package/lib-commonjs/components/Portal/usePortal.js.map +1 -1
- package/lib-commonjs/components/Portal/usePortalMountNode.js +68 -86
- package/lib-commonjs/components/Portal/usePortalMountNode.js.map +1 -1
- package/lib-commonjs/index.js +34 -17
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/virtualParent/elementContains.js +30 -26
- package/lib-commonjs/virtualParent/elementContains.js.map +1 -1
- package/lib-commonjs/virtualParent/getParent.js +22 -19
- package/lib-commonjs/virtualParent/getParent.js.map +1 -1
- package/lib-commonjs/virtualParent/index.js +5 -6
- package/lib-commonjs/virtualParent/index.js.map +1 -1
- package/lib-commonjs/virtualParent/isVirtualElement.js +10 -11
- package/lib-commonjs/virtualParent/isVirtualElement.js.map +1 -1
- package/lib-commonjs/virtualParent/setVirtualParent.js +17 -18
- package/lib-commonjs/virtualParent/setVirtualParent.js.map +1 -1
- package/lib-commonjs/virtualParent/types.js +2 -3
- package/lib-commonjs/virtualParent/types.js.map +1 -1
- package/package.json +8 -7
- package/.swcrc +0 -39
@@ -1,64 +1,63 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
-
});
|
5
|
-
function _export(target, all) {
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
7
|
-
enumerable: true,
|
8
|
-
get: all[name]
|
9
|
-
});
|
10
|
-
}
|
11
|
-
_export(exports, {
|
12
|
-
toMountNodeProps: ()=>toMountNodeProps,
|
13
|
-
usePortal_unstable: ()=>usePortal_unstable
|
4
|
+
value: true
|
14
5
|
});
|
15
|
-
|
16
|
-
const
|
17
|
-
const
|
18
|
-
const
|
19
|
-
const
|
6
|
+
exports.usePortal_unstable = exports.toMountNodeProps = void 0;
|
7
|
+
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
8
|
+
const React = /*#__PURE__*/require("react");
|
9
|
+
const index_1 = /*#__PURE__*/require("../../virtualParent/index");
|
10
|
+
const usePortalMountNode_1 = /*#__PURE__*/require("./usePortalMountNode");
|
20
11
|
function toMountNodeProps(mountNode) {
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
}
|
32
|
-
return mountNode;
|
12
|
+
if (react_utilities_1.isHTMLElement(mountNode)) {
|
13
|
+
return {
|
14
|
+
element: mountNode
|
15
|
+
};
|
16
|
+
}
|
17
|
+
if (typeof mountNode === 'object') {
|
18
|
+
if (mountNode === null) {
|
19
|
+
return {
|
20
|
+
element: null
|
21
|
+
};
|
33
22
|
}
|
34
|
-
return
|
23
|
+
return mountNode;
|
24
|
+
}
|
25
|
+
return {};
|
35
26
|
}
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
27
|
+
exports.toMountNodeProps = toMountNodeProps;
|
28
|
+
/**
|
29
|
+
* Create the state required to render Portal.
|
30
|
+
*
|
31
|
+
* The returned state can be modified with hooks such as usePortalStyles, before being passed to renderPortal_unstable.
|
32
|
+
*
|
33
|
+
* @param props - props from this instance of Portal
|
34
|
+
*/
|
35
|
+
const usePortal_unstable = props => {
|
36
|
+
const {
|
37
|
+
element,
|
38
|
+
className
|
39
|
+
} = toMountNodeProps(props.mountNode);
|
40
|
+
const virtualParentRootRef = React.useRef(null);
|
41
|
+
const fallbackElement = usePortalMountNode_1.usePortalMountNode({
|
42
|
+
disabled: !!element,
|
43
|
+
className
|
44
|
+
});
|
45
|
+
const state = {
|
46
|
+
children: props.children,
|
47
|
+
mountNode: element !== null && element !== void 0 ? element : fallbackElement,
|
48
|
+
virtualParentRootRef
|
49
|
+
};
|
50
|
+
React.useEffect(() => {
|
51
|
+
if (state.virtualParentRootRef.current && state.mountNode) {
|
52
|
+
index_1.setVirtualParent(state.mountNode, state.virtualParentRootRef.current);
|
53
|
+
}
|
54
|
+
return () => {
|
55
|
+
if (state.mountNode) {
|
56
|
+
index_1.setVirtualParent(state.mountNode, undefined);
|
57
|
+
}
|
47
58
|
};
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
return ()=>{
|
53
|
-
if (state.mountNode) {
|
54
|
-
(0, _index.setVirtualParent)(state.mountNode, undefined);
|
55
|
-
}
|
56
|
-
};
|
57
|
-
}, [
|
58
|
-
state.virtualParentRootRef,
|
59
|
-
state.mountNode
|
60
|
-
]);
|
61
|
-
return state;
|
62
|
-
}; //# sourceMappingURL=usePortal.js.map
|
63
|
-
|
59
|
+
}, [state.virtualParentRootRef, state.mountNode]);
|
60
|
+
return state;
|
61
|
+
};
|
62
|
+
exports.usePortal_unstable = usePortal_unstable;
|
64
63
|
//# sourceMappingURL=usePortal.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"names":["react_utilities_1","require","React","index_1","usePortalMountNode_1","toMountNodeProps","mountNode","isHTMLElement","element","exports","usePortal_unstable","props","className","virtualParentRootRef","useRef","fallbackElement","usePortalMountNode","disabled","state","children","useEffect","current","setVirtualParent","undefined"],"sources":["../../../../../../../../../packages/react-components/react-portal/src/components/Portal/usePortal.ts"],"sourcesContent":["import { isHTMLElement } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { setVirtualParent } from '../../virtualParent/index';\nimport { usePortalMountNode } from './usePortalMountNode';\nimport type { PortalProps, PortalState } from './Portal.types';\n\nexport function toMountNodeProps(mountNode: PortalProps['mountNode']): {\n element?: HTMLElement | null;\n className?: string;\n} {\n if (isHTMLElement(mountNode)) {\n return { element: mountNode };\n }\n\n if (typeof mountNode === 'object') {\n if (mountNode === null) {\n return { element: null };\n }\n\n return mountNode;\n }\n\n return {};\n}\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 { element, className } = toMountNodeProps(props.mountNode);\n\n const virtualParentRootRef = React.useRef<HTMLSpanElement>(null);\n const fallbackElement = usePortalMountNode({ disabled: !!element, className });\n\n const state: PortalState = {\n children: props.children,\n mountNode: element ?? fallbackElement,\n virtualParentRootRef,\n };\n\n React.useEffect(() => {\n if (state.virtualParentRootRef.current && state.mountNode) {\n setVirtualParent(state.mountNode, state.virtualParentRootRef.current);\n }\n return () => {\n if (state.mountNode) {\n setVirtualParent(state.mountNode, undefined);\n }\n };\n }, [state.virtualParentRootRef, state.mountNode]);\n\n return state;\n};\n"],"mappings":";;;;;;AAAA,MAAAA,iBAAA,gBAAAC,OAAA;AACA,MAAAC,KAAA,gBAAAD,OAAA;AAEA,MAAAE,OAAA,gBAAAF,OAAA;AACA,MAAAG,oBAAA,gBAAAH,OAAA;AAGA,SAAgBI,gBAAgBA,CAACC,SAAmC;EAIlE,IAAIN,iBAAA,CAAAO,aAAa,CAACD,SAAS,CAAC,EAAE;IAC5B,OAAO;MAAEE,OAAO,EAAEF;IAAS,CAAE;;EAG/B,IAAI,OAAOA,SAAS,KAAK,QAAQ,EAAE;IACjC,IAAIA,SAAS,KAAK,IAAI,EAAE;MACtB,OAAO;QAAEE,OAAO,EAAE;MAAI,CAAE;;IAG1B,OAAOF,SAAS;;EAGlB,OAAO,EAAE;AACX;AAjBAG,OAAA,CAAAJ,gBAAA,GAAAA,gBAAA;AAmBA;;;;;;;AAOO,MAAMK,kBAAkB,GAAIC,KAAkB,IAAiB;EACpE,MAAM;IAAEH,OAAO;IAAEI;EAAS,CAAE,GAAGP,gBAAgB,CAACM,KAAK,CAACL,SAAS,CAAC;EAEhE,MAAMO,oBAAoB,GAAGX,KAAK,CAACY,MAAM,CAAkB,IAAI,CAAC;EAChE,MAAMC,eAAe,GAAGX,oBAAA,CAAAY,kBAAkB,CAAC;IAAEC,QAAQ,EAAE,CAAC,CAACT,OAAO;IAAEI;EAAS,CAAE,CAAC;EAE9E,MAAMM,KAAK,GAAgB;IACzBC,QAAQ,EAAER,KAAK,CAACQ,QAAQ;IACxBb,SAAS,EAAEE,OAAO,aAAPA,OAAO,cAAPA,OAAO,GAAIO,eAAe;IACrCF;GACD;EAEDX,KAAK,CAACkB,SAAS,CAAC,MAAK;IACnB,IAAIF,KAAK,CAACL,oBAAoB,CAACQ,OAAO,IAAIH,KAAK,CAACZ,SAAS,EAAE;MACzDH,OAAA,CAAAmB,gBAAgB,CAACJ,KAAK,CAACZ,SAAS,EAAEY,KAAK,CAACL,oBAAoB,CAACQ,OAAO,CAAC;;IAEvE,OAAO,MAAK;MACV,IAAIH,KAAK,CAACZ,SAAS,EAAE;QACnBH,OAAA,CAAAmB,gBAAgB,CAACJ,KAAK,CAACZ,SAAS,EAAEiB,SAAS,CAAC;;IAEhD,CAAC;EACH,CAAC,EAAE,CAACL,KAAK,CAACL,oBAAoB,EAAEK,KAAK,CAACZ,SAAS,CAAC,CAAC;EAEjD,OAAOY,KAAK;AACd,CAAC;AAxBYT,OAAA,CAAAC,kBAAkB,GAAAA,kBAAA"}
|
@@ -1,93 +1,75 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "usePortalMountNode", {
|
6
|
-
enumerable: true,
|
7
|
-
get: ()=>usePortalMountNode
|
4
|
+
value: true
|
8
5
|
});
|
9
|
-
|
10
|
-
const
|
11
|
-
const
|
12
|
-
const
|
13
|
-
const
|
14
|
-
const
|
15
|
-
const useInsertionEffect =
|
16
|
-
const useStyles = /*#__PURE__*/
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
6
|
+
exports.usePortalMountNode = void 0;
|
7
|
+
const React = /*#__PURE__*/require("react");
|
8
|
+
const react_shared_contexts_1 = /*#__PURE__*/require("@fluentui/react-shared-contexts");
|
9
|
+
const react_1 = /*#__PURE__*/require("@griffel/react");
|
10
|
+
const react_tabster_1 = /*#__PURE__*/require("@fluentui/react-tabster");
|
11
|
+
const use_disposable_1 = /*#__PURE__*/require("use-disposable");
|
12
|
+
const useInsertionEffect = React['useInsertion' + 'Effect'];
|
13
|
+
const useStyles = /*#__PURE__*/react_1.__styles({
|
14
|
+
root: {
|
15
|
+
qhf8xq: "f10pi13n",
|
16
|
+
Bj3rh1h: "f494woh"
|
17
|
+
}
|
21
18
|
}, {
|
22
|
-
|
23
|
-
".f10pi13n{position:relative;}",
|
24
|
-
".f494woh{z-index:1000000;}"
|
25
|
-
]
|
19
|
+
d: [".f10pi13n{position:relative;}", ".f494woh{z-index:1000000;}"]
|
26
20
|
});
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
return [
|
43
|
-
newElement,
|
44
|
-
()=>newElement.remove()
|
45
|
-
];
|
46
|
-
}, [
|
47
|
-
targetDocument
|
48
|
-
]);
|
49
|
-
if (useInsertionEffect) {
|
50
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
51
|
-
useInsertionEffect(()=>{
|
52
|
-
if (!element) {
|
53
|
-
return;
|
54
|
-
}
|
55
|
-
const classesToApply = className.split(" ").filter(Boolean);
|
56
|
-
element.classList.add(...classesToApply);
|
57
|
-
element.setAttribute("dir", dir);
|
58
|
-
focusVisibleRef.current = element;
|
59
|
-
return ()=>{
|
60
|
-
element.classList.remove(...classesToApply);
|
61
|
-
element.removeAttribute("dir");
|
62
|
-
};
|
63
|
-
}, [
|
64
|
-
className,
|
65
|
-
dir,
|
66
|
-
element,
|
67
|
-
focusVisibleRef
|
68
|
-
]);
|
69
|
-
} else {
|
70
|
-
// This useMemo call is intentional for React 17
|
71
|
-
// We don't want to re-create the portal element when its attributes change.
|
72
|
-
// This also should not be done in an effect because, changing the value of css variables
|
73
|
-
// after initial mount can trigger interesting CSS side effects like transitions.
|
74
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
75
|
-
_react.useMemo(()=>{
|
76
|
-
if (!element) {
|
77
|
-
return;
|
78
|
-
}
|
79
|
-
// Force replace all classes
|
80
|
-
element.className = className;
|
81
|
-
element.setAttribute("dir", dir);
|
82
|
-
focusVisibleRef.current = element;
|
83
|
-
}, [
|
84
|
-
className,
|
85
|
-
dir,
|
86
|
-
element,
|
87
|
-
focusVisibleRef
|
88
|
-
]);
|
21
|
+
/**
|
22
|
+
* Creates a new element on a "document.body" to mount portals.
|
23
|
+
*/
|
24
|
+
const usePortalMountNode = options => {
|
25
|
+
const {
|
26
|
+
targetDocument,
|
27
|
+
dir
|
28
|
+
} = react_shared_contexts_1.useFluent_unstable();
|
29
|
+
const focusVisibleRef = react_tabster_1.useFocusVisible();
|
30
|
+
const classes = useStyles();
|
31
|
+
const themeClassName = react_shared_contexts_1.useThemeClassName_unstable();
|
32
|
+
const className = react_1.mergeClasses(themeClassName, classes.root, options.className);
|
33
|
+
const element = use_disposable_1.useDisposable(() => {
|
34
|
+
if (targetDocument === undefined || options.disabled) {
|
35
|
+
return [null, () => null];
|
89
36
|
}
|
90
|
-
|
91
|
-
|
92
|
-
|
37
|
+
const newElement = targetDocument.createElement('div');
|
38
|
+
targetDocument.body.appendChild(newElement);
|
39
|
+
return [newElement, () => newElement.remove()];
|
40
|
+
}, [targetDocument]);
|
41
|
+
if (useInsertionEffect) {
|
42
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
43
|
+
useInsertionEffect(() => {
|
44
|
+
if (!element) {
|
45
|
+
return;
|
46
|
+
}
|
47
|
+
const classesToApply = className.split(' ').filter(Boolean);
|
48
|
+
element.classList.add(...classesToApply);
|
49
|
+
element.setAttribute('dir', dir);
|
50
|
+
focusVisibleRef.current = element;
|
51
|
+
return () => {
|
52
|
+
element.classList.remove(...classesToApply);
|
53
|
+
element.removeAttribute('dir');
|
54
|
+
};
|
55
|
+
}, [className, dir, element, focusVisibleRef]);
|
56
|
+
} else {
|
57
|
+
// This useMemo call is intentional for React 17
|
58
|
+
// We don't want to re-create the portal element when its attributes change.
|
59
|
+
// This also should not be done in an effect because, changing the value of css variables
|
60
|
+
// after initial mount can trigger interesting CSS side effects like transitions.
|
61
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
62
|
+
React.useMemo(() => {
|
63
|
+
if (!element) {
|
64
|
+
return;
|
65
|
+
}
|
66
|
+
// Force replace all classes
|
67
|
+
element.className = className;
|
68
|
+
element.setAttribute('dir', dir);
|
69
|
+
focusVisibleRef.current = element;
|
70
|
+
}, [className, dir, element, focusVisibleRef]);
|
71
|
+
}
|
72
|
+
return element;
|
73
|
+
};
|
74
|
+
exports.usePortalMountNode = usePortalMountNode;
|
93
75
|
//# sourceMappingURL=usePortalMountNode.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"names":["React","require","react_shared_contexts_1","react_1","react_tabster_1","use_disposable_1","useInsertionEffect","useStyles","__styles","root","qhf8xq","Bj3rh1h","d","usePortalMountNode","options","targetDocument","dir","useFluent_unstable","focusVisibleRef","useFocusVisible","classes","themeClassName","useThemeClassName_unstable","className","mergeClasses","element","useDisposable","undefined","disabled","newElement","createElement","body","appendChild","remove","classesToApply","split","filter","Boolean","classList","add","setAttribute","current","removeAttribute","useMemo","exports"],"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';\n\nconst useInsertionEffect = (React as never)['useInsertion' + 'Effect'] as typeof React.useLayoutEffect | undefined;\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 className?: string;\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, options.className);\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 if (useInsertionEffect) {\n // eslint-disable-next-line react-hooks/rules-of-hooks\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 } else {\n // This useMemo call is intentional for React 17\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 // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useMemo(() => {\n if (!element) {\n return;\n }\n\n // Force replace all classes\n element.className = className;\n element.setAttribute('dir', dir);\n focusVisibleRef.current = element;\n }, [className, dir, element, focusVisibleRef]);\n }\n\n return element;\n};\n"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AACA,MAAAC,uBAAA,gBAAAD,OAAA;AAIA,MAAAE,OAAA,gBAAAF,OAAA;AACA,MAAAG,eAAA,gBAAAH,OAAA;AACA,MAAAI,gBAAA,gBAAAJ,OAAA;AAEA,MAAMK,kBAAkB,GAAIN,KAAe,CAAC,cAAc,GAAG,QAAQ,CAA6C;AAWlH,MAAMO,SAAS,gBAAGJ,OAAA,CAAAK,QAAU;EAAAC,IAAA;IAAAC,MAAA;IAAAC,OAAA;EAAA;AAAA;EAAAC,CAAA;AAAA,EAK1B;AAEF;;;AAGO,MAAMC,kBAAkB,GAAIC,OAAkC,IAAwB;EAC3F,MAAM;IAAEC,cAAc;IAAEC;EAAG,CAAE,GAAGd,uBAAA,CAAAe,kBAAS,EAAE;EAC3C,MAAMC,eAAe,GAAGd,eAAA,CAAAe,eAAe,EAAgE;EACvG,MAAMC,OAAO,GAAGb,SAAS,EAAE;EAC3B,MAAMc,cAAc,GAAGnB,uBAAA,CAAAoB,0BAAiB,EAAE;EAE1C,MAAMC,SAAS,GAAGpB,OAAA,CAAAqB,YAAY,CAACH,cAAc,EAAED,OAAO,CAACX,IAAI,EAAEK,OAAO,CAACS,SAAS,CAAC;EAE/E,MAAME,OAAO,GAAGpB,gBAAA,CAAAqB,aAAa,CAAC,MAAK;IACjC,IAAIX,cAAc,KAAKY,SAAS,IAAIb,OAAO,CAACc,QAAQ,EAAE;MACpD,OAAO,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC;;IAG3B,MAAMC,UAAU,GAAGd,cAAc,CAACe,aAAa,CAAC,KAAK,CAAC;IACtDf,cAAc,CAACgB,IAAI,CAACC,WAAW,CAACH,UAAU,CAAC;IAC3C,OAAO,CAACA,UAAU,EAAE,MAAMA,UAAU,CAACI,MAAM,EAAE,CAAC;EAChD,CAAC,EAAE,CAAClB,cAAc,CAAC,CAAC;EAEpB,IAAIT,kBAAkB,EAAE;IACtB;IACAA,kBAAkB,CAAC,MAAK;MACtB,IAAI,CAACmB,OAAO,EAAE;QACZ;;MAGF,MAAMS,cAAc,GAAGX,SAAS,CAACY,KAAK,CAAC,GAAG,CAAC,CAACC,MAAM,CAACC,OAAO,CAAC;MAE3DZ,OAAO,CAACa,SAAS,CAACC,GAAG,CAAC,GAAGL,cAAc,CAAC;MACxCT,OAAO,CAACe,YAAY,CAAC,KAAK,EAAExB,GAAG,CAAC;MAChCE,eAAe,CAACuB,OAAO,GAAGhB,OAAO;MAEjC,OAAO,MAAK;QACVA,OAAO,CAACa,SAAS,CAACL,MAAM,CAAC,GAAGC,cAAc,CAAC;QAC3CT,OAAO,CAACiB,eAAe,CAAC,KAAK,CAAC;MAChC,CAAC;IACH,CAAC,EAAE,CAACnB,SAAS,EAAEP,GAAG,EAAES,OAAO,EAAEP,eAAe,CAAC,CAAC;GAC/C,MAAM;IACL;IACA;IACA;IACA;IACA;IACAlB,KAAK,CAAC2C,OAAO,CAAC,MAAK;MACjB,IAAI,CAAClB,OAAO,EAAE;QACZ;;MAGF;MACAA,OAAO,CAACF,SAAS,GAAGA,SAAS;MAC7BE,OAAO,CAACe,YAAY,CAAC,KAAK,EAAExB,GAAG,CAAC;MAChCE,eAAe,CAACuB,OAAO,GAAGhB,OAAO;IACnC,CAAC,EAAE,CAACF,SAAS,EAAEP,GAAG,EAAES,OAAO,EAAEP,eAAe,CAAC,CAAC;;EAGhD,OAAOO,OAAO;AAChB,CAAC;AAvDYmB,OAAA,CAAA/B,kBAAkB,GAAAA,kBAAA"}
|
package/lib-commonjs/index.js
CHANGED
@@ -1,22 +1,39 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
+
value: true
|
4
5
|
});
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
6
|
+
exports.setVirtualParent = exports.elementContains = exports.usePortal_unstable = exports.renderPortal_unstable = exports.Portal = void 0;
|
7
|
+
var index_1 = /*#__PURE__*/require("./components/Portal/index");
|
8
|
+
Object.defineProperty(exports, "Portal", {
|
9
|
+
enumerable: true,
|
10
|
+
get: function () {
|
11
|
+
return index_1.Portal;
|
12
|
+
}
|
13
|
+
});
|
14
|
+
Object.defineProperty(exports, "renderPortal_unstable", {
|
15
|
+
enumerable: true,
|
16
|
+
get: function () {
|
17
|
+
return index_1.renderPortal_unstable;
|
18
|
+
}
|
19
|
+
});
|
20
|
+
Object.defineProperty(exports, "usePortal_unstable", {
|
21
|
+
enumerable: true,
|
22
|
+
get: function () {
|
23
|
+
return index_1.usePortal_unstable;
|
24
|
+
}
|
25
|
+
});
|
26
|
+
var index_2 = /*#__PURE__*/require("./virtualParent/index");
|
27
|
+
Object.defineProperty(exports, "elementContains", {
|
28
|
+
enumerable: true,
|
29
|
+
get: function () {
|
30
|
+
return index_2.elementContains;
|
31
|
+
}
|
32
|
+
});
|
33
|
+
Object.defineProperty(exports, "setVirtualParent", {
|
34
|
+
enumerable: true,
|
35
|
+
get: function () {
|
36
|
+
return index_2.setVirtualParent;
|
37
|
+
}
|
17
38
|
});
|
18
|
-
const _index = require("./components/Portal/index");
|
19
|
-
const _index1 = require("./virtualParent/index");
|
20
|
-
//# sourceMappingURL=index.js.map
|
21
|
-
|
22
39
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"names":["index_1","require","Object","defineProperty","exports","enumerable","get","Portal","renderPortal_unstable","usePortal_unstable","index_2","elementContains","setVirtualParent"],"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"],"mappings":";;;;;;AAAA,IAAAA,OAAA,gBAAAC,OAAA;AAASC,MAAA,CAAAC,cAAA,CAAAC,OAAA;EAAAC,UAAA;EAAAC,GAAA,WAAAA,CAAA;IAAA,OAAAN,OAAA,CAAAO,MAAM;EAAA;AAAA;AAAEL,MAAA,CAAAC,cAAA,CAAAC,OAAA;EAAAC,UAAA;EAAAC,GAAA,WAAAA,CAAA;IAAA,OAAAN,OAAA,CAAAQ,qBAAqB;EAAA;AAAA;AAAEN,MAAA,CAAAC,cAAA,CAAAC,OAAA;EAAAC,UAAA;EAAAC,GAAA,WAAAA,CAAA;IAAA,OAAAN,OAAA,CAAAS,kBAAkB;EAAA;AAAA;AAE1D,IAAAC,OAAA,gBAAAT,OAAA;AAASC,MAAA,CAAAC,cAAA,CAAAC,OAAA;EAAAC,UAAA;EAAAC,GAAA,WAAAA,CAAA;IAAA,OAAAI,OAAA,CAAAC,eAAe;EAAA;AAAA;AAAET,MAAA,CAAAC,cAAA,CAAAC,OAAA;EAAAC,UAAA;EAAAC,GAAA,WAAAA,CAAA;IAAA,OAAAI,OAAA,CAAAE,gBAAgB;EAAA;AAAA"}
|
@@ -1,33 +1,37 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "elementContains", {
|
6
|
-
enumerable: true,
|
7
|
-
get: ()=>elementContains
|
4
|
+
value: true
|
8
5
|
});
|
9
|
-
|
6
|
+
exports.elementContains = void 0;
|
7
|
+
const getParent_1 = /*#__PURE__*/require("./getParent");
|
8
|
+
/**
|
9
|
+
* Similar functionality to `element.contains` DOM API for use without of order DOM elements that
|
10
|
+
* checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent
|
11
|
+
*
|
12
|
+
* @returns true if the child can find the parent in its virtual hierarchy
|
13
|
+
*/
|
10
14
|
function elementContains(parent, child) {
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
+
if (!parent || !child) {
|
16
|
+
return false;
|
17
|
+
}
|
18
|
+
if (parent === child) {
|
19
|
+
return true;
|
20
|
+
} else {
|
21
|
+
// Tracks references of nodes that have been visited to prevent infinite loops
|
22
|
+
const set = new WeakSet();
|
23
|
+
while (child) {
|
24
|
+
const nextParent = getParent_1.getParent(child, {
|
25
|
+
skipVirtual: set.has(child)
|
26
|
+
});
|
27
|
+
set.add(child);
|
28
|
+
if (nextParent === parent) {
|
15
29
|
return true;
|
16
|
-
|
17
|
-
|
18
|
-
const set = new WeakSet();
|
19
|
-
while(child){
|
20
|
-
const nextParent = (0, _getParent.getParent)(child, {
|
21
|
-
skipVirtual: set.has(child)
|
22
|
-
});
|
23
|
-
set.add(child);
|
24
|
-
if (nextParent === parent) {
|
25
|
-
return true;
|
26
|
-
}
|
27
|
-
child = nextParent;
|
28
|
-
}
|
30
|
+
}
|
31
|
+
child = nextParent;
|
29
32
|
}
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
+
}
|
34
|
+
return false;
|
35
|
+
}
|
36
|
+
exports.elementContains = elementContains;
|
33
37
|
//# sourceMappingURL=elementContains.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"names":["getParent_1","require","elementContains","parent","child","set","WeakSet","nextParent","getParent","skipVirtual","has","add","exports"],"sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/elementContains.ts"],"sourcesContent":["import { getParent } from './getParent';\n\n/**\n * Similar functionality to `element.contains` DOM API for use without 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 // Tracks references of nodes that have been visited to prevent infinite loops\n const set = new WeakSet<Node>();\n\n while (child) {\n const nextParent: Node | null = getParent(child, {\n skipVirtual: set.has(child),\n });\n set.add(child);\n\n if (nextParent === parent) {\n return true;\n }\n\n child = nextParent;\n }\n }\n\n return false;\n}\n"],"mappings":";;;;;;AAAA,MAAAA,WAAA,gBAAAC,OAAA;AAEA;;;;;;AAMA,SAAgBC,eAAeA,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;IACA,MAAMC,GAAG,GAAG,IAAIC,OAAO,EAAQ;IAE/B,OAAOF,KAAK,EAAE;MACZ,MAAMG,UAAU,GAAgBP,WAAA,CAAAQ,SAAS,CAACJ,KAAK,EAAE;QAC/CK,WAAW,EAAEJ,GAAG,CAACK,GAAG,CAACN,KAAK;OAC3B,CAAC;MACFC,GAAG,CAACM,GAAG,CAACP,KAAK,CAAC;MAEd,IAAIG,UAAU,KAAKJ,MAAM,EAAE;QACzB,OAAO,IAAI;;MAGbC,KAAK,GAAGG,UAAU;;;EAItB,OAAO,KAAK;AACd;AA1BAK,OAAA,CAAAV,eAAA,GAAAA,eAAA"}
|
@@ -1,28 +1,31 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "getParent", {
|
6
|
-
enumerable: true,
|
7
|
-
get: ()=>getParent
|
4
|
+
value: true
|
8
5
|
});
|
9
|
-
|
6
|
+
exports.getParent = void 0;
|
7
|
+
const isVirtualElement_1 = /*#__PURE__*/require("./isVirtualElement");
|
10
8
|
/**
|
11
9
|
* Gets the virtual parent given the child element, if it exists.
|
12
|
-
*/
|
13
|
-
|
10
|
+
*/
|
11
|
+
function getVirtualParent(child) {
|
12
|
+
return isVirtualElement_1.isVirtualElement(child) ? child._virtual.parent || null : null;
|
14
13
|
}
|
14
|
+
/**
|
15
|
+
* Gets the element which is the parent of a given element.
|
16
|
+
* This method prefers the virtual parent over real DOM parent when present.
|
17
|
+
*/
|
15
18
|
function getParent(child, options = {}) {
|
16
|
-
|
17
|
-
|
19
|
+
if (!child) {
|
20
|
+
return null;
|
21
|
+
}
|
22
|
+
if (!options.skipVirtual) {
|
23
|
+
const virtualParent = getVirtualParent(child);
|
24
|
+
if (virtualParent) {
|
25
|
+
return virtualParent;
|
18
26
|
}
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
}
|
24
|
-
}
|
25
|
-
return child?.parentNode || null;
|
26
|
-
} //# sourceMappingURL=getParent.js.map
|
27
|
-
|
27
|
+
}
|
28
|
+
return (child === null || child === void 0 ? void 0 : child.parentNode) || null;
|
29
|
+
}
|
30
|
+
exports.getParent = getParent;
|
28
31
|
//# sourceMappingURL=getParent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"names":["isVirtualElement_1","require","getVirtualParent","child","isVirtualElement","_virtual","parent","getParent","options","skipVirtual","virtualParent","parentNode","exports"],"sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/getParent.ts"],"sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n\ntype GetParentOptions = {\n /**\n * Indicates if getParent() should ignore a virtual parent.\n */\n skipVirtual?: boolean;\n};\n\n/**\n * Gets the virtual parent given the child element, if it exists.\n */\nfunction getVirtualParent(child: Node): Node | null {\n return isVirtualElement(child) ? child._virtual.parent || null : null;\n}\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, options: GetParentOptions = {}): Node | null {\n if (!child) {\n return null;\n }\n\n if (!options.skipVirtual) {\n const virtualParent = getVirtualParent(child);\n\n if (virtualParent) {\n return virtualParent;\n }\n }\n\n return child?.parentNode || null;\n}\n"],"mappings":";;;;;;AAAA,MAAAA,kBAAA,gBAAAC,OAAA;AASA;;;AAGA,SAASC,gBAAgBA,CAACC,KAAW;EACnC,OAAOH,kBAAA,CAAAI,gBAAgB,CAACD,KAAK,CAAC,GAAGA,KAAK,CAACE,QAAQ,CAACC,MAAM,IAAI,IAAI,GAAG,IAAI;AACvE;AAEA;;;;AAIA,SAAgBC,SAASA,CAACJ,KAAkB,EAAEK,OAAA,GAA4B,EAAE;EAC1E,IAAI,CAACL,KAAK,EAAE;IACV,OAAO,IAAI;;EAGb,IAAI,CAACK,OAAO,CAACC,WAAW,EAAE;IACxB,MAAMC,aAAa,GAAGR,gBAAgB,CAACC,KAAK,CAAC;IAE7C,IAAIO,aAAa,EAAE;MACjB,OAAOA,aAAa;;;EAIxB,OAAO,CAAAP,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEQ,UAAU,KAAI,IAAI;AAClC;AAdAC,OAAA,CAAAL,SAAA,GAAAA,SAAA"}
|
@@ -1,10 +1,9 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
+
value: true
|
4
5
|
});
|
5
|
-
const
|
6
|
-
|
7
|
-
|
8
|
-
//# sourceMappingURL=index.js.map
|
9
|
-
|
6
|
+
const tslib_1 = /*#__PURE__*/require("tslib");
|
7
|
+
tslib_1.__exportStar(require("./elementContains"), exports);
|
8
|
+
tslib_1.__exportStar(require("./setVirtualParent"), exports);
|
10
9
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"names":["tslib_1","__exportStar","require","exports"],"sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/index.ts"],"sourcesContent":["export * from './elementContains';\nexport * from './setVirtualParent';\n"],"mappings":";;;;;;AAAAA,OAAA,CAAAC,YAAA,CAAAC,OAAA,uBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,wBAAAC,OAAA"}
|
@@ -1,15 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
*/ "use strict";
|
1
|
+
"use strict";
|
2
|
+
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
5
|
-
|
6
|
-
});
|
7
|
-
Object.defineProperty(exports, "isVirtualElement", {
|
8
|
-
enumerable: true,
|
9
|
-
get: ()=>isVirtualElement
|
4
|
+
value: true
|
10
5
|
});
|
6
|
+
exports.isVirtualElement = void 0;
|
7
|
+
/**
|
8
|
+
* Determines whether or not an element has the virtual hierarchy extension.
|
9
|
+
*/
|
11
10
|
function isVirtualElement(element) {
|
12
|
-
|
13
|
-
}
|
14
|
-
|
11
|
+
return element && !!element._virtual;
|
12
|
+
}
|
13
|
+
exports.isVirtualElement = isVirtualElement;
|
15
14
|
//# sourceMappingURL=isVirtualElement.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"names":["isVirtualElement","element","_virtual","exports"],"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"],"mappings":";;;;;;AAEA;;;AAGA,SAAgBA,gBAAgBA,CAACC,OAA8B;EAC7D,OAAOA,OAAO,IAAI,CAAC,CAAkBA,OAAQ,CAACC,QAAQ;AACxD;AAFAC,OAAA,CAAAH,gBAAA,GAAAA,gBAAA"}
|