@fluentui/react-portal 9.2.1 → 9.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.swcrc +30 -0
- package/CHANGELOG.json +40 -1
- package/CHANGELOG.md +15 -2
- package/lib/Portal.js.map +1 -1
- package/lib/components/Portal/Portal.js +1 -0
- 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.map +1 -1
- package/lib/components/Portal/renderPortal.js.map +1 -1
- package/lib/components/Portal/usePortal.js.map +1 -1
- package/lib/components/Portal/usePortalMountNode.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/virtualParent/elementContains.js.map +1 -1
- package/lib/virtualParent/getParent.js.map +1 -1
- package/lib/virtualParent/index.js.map +1 -1
- package/lib/virtualParent/isVirtualElement.js +1 -2
- package/lib/virtualParent/isVirtualElement.js.map +1 -1
- package/lib/virtualParent/setVirtualParent.js +1 -2
- package/lib/virtualParent/setVirtualParent.js.map +1 -1
- package/lib/virtualParent/types.js.map +1 -1
- package/lib-commonjs/Portal.js +5 -4
- 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 +5 -2
- package/lib-commonjs/components/Portal/Portal.types.js.map +1 -1
- package/lib-commonjs/components/Portal/index.js +8 -7
- 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 +56 -55
- package/lib-commonjs/components/Portal/usePortal.js.map +1 -1
- package/lib-commonjs/components/Portal/usePortalMountNode.js +86 -68
- package/lib-commonjs/components/Portal/usePortalMountNode.js.map +1 -1
- package/lib-commonjs/index.js +17 -34
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/virtualParent/elementContains.js +26 -30
- package/lib-commonjs/virtualParent/elementContains.js.map +1 -1
- package/lib-commonjs/virtualParent/getParent.js +19 -22
- package/lib-commonjs/virtualParent/getParent.js.map +1 -1
- package/lib-commonjs/virtualParent/index.js +6 -5
- package/lib-commonjs/virtualParent/index.js.map +1 -1
- package/lib-commonjs/virtualParent/isVirtualElement.js +11 -10
- package/lib-commonjs/virtualParent/isVirtualElement.js.map +1 -1
- package/lib-commonjs/virtualParent/setVirtualParent.js +18 -17
- package/lib-commonjs/virtualParent/setVirtualParent.js.map +1 -1
- package/lib-commonjs/virtualParent/types.js +3 -2
- package/lib-commonjs/virtualParent/types.js.map +1 -1
- package/package.json +7 -6
- package/lib-amd/components/Portal/Portal.js +0 -16
- package/lib-amd/components/Portal/Portal.js.map +0 -1
- package/lib-amd/components/Portal/Portal.types.js +0 -5
- package/lib-amd/components/Portal/Portal.types.js.map +0 -1
- package/lib-amd/components/Portal/index.js +0 -9
- package/lib-amd/components/Portal/index.js.map +0 -1
- package/lib-amd/components/Portal/renderPortal.js +0 -13
- package/lib-amd/components/Portal/renderPortal.js.map +0 -1
- package/lib-amd/components/Portal/usePortal.js +0 -48
- package/lib-amd/components/Portal/usePortal.js.map +0 -1
- package/lib-amd/components/Portal/usePortalMountNode.js +0 -67
- package/lib-amd/components/Portal/usePortalMountNode.js.map +0 -1
- package/lib-amd/index.js +0 -11
- package/lib-amd/index.js.map +0 -1
- package/lib-amd/virtualParent/elementContains.js +0 -36
- package/lib-amd/virtualParent/elementContains.js.map +0 -1
- package/lib-amd/virtualParent/getParent.js +0 -30
- package/lib-amd/virtualParent/getParent.js.map +0 -1
- package/lib-amd/virtualParent/index.js +0 -7
- package/lib-amd/virtualParent/index.js.map +0 -1
- package/lib-amd/virtualParent/isVirtualElement.js +0 -13
- package/lib-amd/virtualParent/isVirtualElement.js.map +0 -1
- package/lib-amd/virtualParent/setVirtualParent.js +0 -23
- package/lib-amd/virtualParent/setVirtualParent.js.map +0 -1
- package/lib-amd/virtualParent/types.js +0 -5
- package/lib-amd/virtualParent/types.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../../lib/components/Portal/usePortal.js"],"sourcesContent":["import { isHTMLElement } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport { setVirtualParent } from '../../virtualParent/index';\nimport { usePortalMountNode } from './usePortalMountNode';\nexport function toMountNodeProps(mountNode) {\n if (isHTMLElement(mountNode)) {\n return {\n element: mountNode\n };\n }\n if (typeof mountNode === 'object') {\n if (mountNode === null) {\n return {\n element: null\n };\n }\n return mountNode;\n }\n return {};\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 => {\n const {\n element,\n className\n } = toMountNodeProps(props.mountNode);\n const virtualParentRootRef = React.useRef(null);\n const fallbackElement = usePortalMountNode({\n disabled: !!element,\n className\n });\n const state = {\n children: props.children,\n mountNode: element !== null && element !== void 0 ? element : fallbackElement,\n virtualParentRootRef\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 return state;\n};\n//# sourceMappingURL=usePortal.js.map"],"names":["toMountNodeProps","usePortal_unstable","mountNode","isHTMLElement","element","props","className","virtualParentRootRef","React","useRef","fallbackElement","usePortalMountNode","disabled","state","children","useEffect","current","setVirtualParent","undefined"],"mappings":";;;;;;;;;;;IAIgBA,gBAAgB,MAAhBA;IAuBHC,kBAAkB,MAAlBA;;;gCA3BiB;6DACP;uBACU;oCACE;AAC5B,SAASD,iBAAiBE,SAAS,EAAE;IAC1C,IAAIC,IAAAA,6BAAa,EAACD,YAAY;QAC5B,OAAO;YACLE,SAASF;QACX;IACF,CAAC;IACD,IAAI,OAAOA,cAAc,UAAU;QACjC,IAAIA,cAAc,IAAI,EAAE;YACtB,OAAO;gBACLE,SAAS,IAAI;YACf;QACF,CAAC;QACD,OAAOF;IACT,CAAC;IACD,OAAO,CAAC;AACV;AAQO,MAAMD,qBAAqBI,CAAAA,QAAS;IACzC,MAAM,EACJD,QAAO,EACPE,UAAS,EACV,GAAGN,iBAAiBK,MAAMH,SAAS;IACpC,MAAMK,uBAAuBC,OAAMC,MAAM,CAAC,IAAI;IAC9C,MAAMC,kBAAkBC,IAAAA,sCAAkB,EAAC;QACzCC,UAAU,CAAC,CAACR;QACZE;IACF;IACA,MAAMO,QAAQ;QACZC,UAAUT,MAAMS,QAAQ;QACxBZ,WAAWE,YAAY,IAAI,IAAIA,YAAY,KAAK,IAAIA,UAAUM,eAAe;QAC7EH;IACF;IACAC,OAAMO,SAAS,CAAC,IAAM;QACpB,IAAIF,MAAMN,oBAAoB,CAACS,OAAO,IAAIH,MAAMX,SAAS,EAAE;YACzDe,IAAAA,uBAAgB,EAACJ,MAAMX,SAAS,EAAEW,MAAMN,oBAAoB,CAACS,OAAO;QACtE,CAAC;QACD,OAAO,IAAM;YACX,IAAIH,MAAMX,SAAS,EAAE;gBACnBe,IAAAA,uBAAgB,EAACJ,MAAMX,SAAS,EAAEgB;YACpC,CAAC;QACH;IACF,GAAG;QAACL,MAAMN,oBAAoB;QAAEM,MAAMX,SAAS;KAAC;IAChD,OAAOW;AACT,GACA,qCAAqC"}
|
@@ -1,75 +1,93 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "usePortalMountNode", {
|
6
|
+
enumerable: true,
|
7
|
+
get: ()=>usePortalMountNode
|
5
8
|
});
|
6
|
-
|
7
|
-
const
|
8
|
-
const
|
9
|
-
const
|
10
|
-
const
|
11
|
-
const
|
12
|
-
const useInsertionEffect =
|
13
|
-
const useStyles = /*#__PURE__*/
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
9
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
10
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
11
|
+
const _reactSharedContexts = require("@fluentui/react-shared-contexts");
|
12
|
+
const _react1 = require("@griffel/react");
|
13
|
+
const _reactTabster = require("@fluentui/react-tabster");
|
14
|
+
const _useDisposable = require("use-disposable");
|
15
|
+
const useInsertionEffect = _react['useInsertion' + 'Effect'];
|
16
|
+
const useStyles = /*#__PURE__*/ (0, _react1["__styles"])({
|
17
|
+
root: {
|
18
|
+
qhf8xq: "f10pi13n",
|
19
|
+
Bj3rh1h: "f494woh"
|
20
|
+
}
|
18
21
|
}, {
|
19
|
-
|
22
|
+
d: [
|
23
|
+
".f10pi13n{position:relative;}",
|
24
|
+
".f494woh{z-index:1000000;}"
|
25
|
+
]
|
20
26
|
});
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
const
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
27
|
+
const usePortalMountNode = (options)=>{
|
28
|
+
const { targetDocument , dir } = (0, _reactSharedContexts.useFluent_unstable)();
|
29
|
+
const focusVisibleRef = (0, _reactTabster.useFocusVisible)();
|
30
|
+
const classes = useStyles();
|
31
|
+
const themeClassName = (0, _reactSharedContexts.useThemeClassName_unstable)();
|
32
|
+
const className = (0, _react1.mergeClasses)(themeClassName, classes.root, options.className);
|
33
|
+
const element = (0, _useDisposable.useDisposable)(()=>{
|
34
|
+
if (targetDocument === undefined || options.disabled) {
|
35
|
+
return [
|
36
|
+
null,
|
37
|
+
()=>null
|
38
|
+
];
|
39
|
+
}
|
40
|
+
const newElement = targetDocument.createElement('div');
|
41
|
+
targetDocument.body.appendChild(newElement);
|
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
|
+
]);
|
36
89
|
}
|
37
|
-
|
38
|
-
|
39
|
-
|
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;
|
90
|
+
return element;
|
91
|
+
}; //# sourceMappingURL=usePortalMountNode.js.map
|
92
|
+
|
75
93
|
//# sourceMappingURL=usePortalMountNode.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../../lib/components/Portal/usePortalMountNode.js"],"sourcesContent":["import * as React from 'react';\nimport { useThemeClassName_unstable as useThemeClassName, useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { __styles, mergeClasses } from '@griffel/react';\nimport { useFocusVisible } from '@fluentui/react-tabster';\nimport { useDisposable } from 'use-disposable';\nconst useInsertionEffect = React['useInsertion' + 'Effect'];\nconst useStyles = /*#__PURE__*/__styles({\n root: {\n qhf8xq: \"f10pi13n\",\n Bj3rh1h: \"f494woh\"\n }\n}, {\n d: [\".f10pi13n{position:relative;}\", \".f494woh{z-index:1000000;}\"]\n});\n/**\n * Creates a new element on a \"document.body\" to mount portals.\n */\nexport const usePortalMountNode = options => {\n const {\n targetDocument,\n dir\n } = useFluent();\n const focusVisibleRef = useFocusVisible();\n const classes = useStyles();\n const themeClassName = useThemeClassName();\n const className = mergeClasses(themeClassName, classes.root, options.className);\n const element = useDisposable(() => {\n if (targetDocument === undefined || options.disabled) {\n return [null, () => null];\n }\n const newElement = targetDocument.createElement('div');\n targetDocument.body.appendChild(newElement);\n return [newElement, () => newElement.remove()];\n }, [targetDocument]);\n if (useInsertionEffect) {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useInsertionEffect(() => {\n if (!element) {\n return;\n }\n const classesToApply = className.split(' ').filter(Boolean);\n element.classList.add(...classesToApply);\n element.setAttribute('dir', dir);\n focusVisibleRef.current = element;\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 // Force replace all classes\n element.className = className;\n element.setAttribute('dir', dir);\n focusVisibleRef.current = element;\n }, [className, dir, element, focusVisibleRef]);\n }\n return element;\n};\n//# sourceMappingURL=usePortalMountNode.js.map"],"names":["usePortalMountNode","useInsertionEffect","React","useStyles","__styles","root","qhf8xq","Bj3rh1h","d","options","targetDocument","dir","useFluent","focusVisibleRef","useFocusVisible","classes","themeClassName","useThemeClassName","className","mergeClasses","element","useDisposable","undefined","disabled","newElement","createElement","body","appendChild","remove","classesToApply","split","filter","Boolean","classList","add","setAttribute","current","removeAttribute","useMemo"],"mappings":";;;;+BAiBaA;;aAAAA;;;6DAjBU;qCAC0E;wBAC1D;8BACP;+BACF;AAC9B,MAAMC,qBAAqBC,MAAK,CAAC,iBAAiB,SAAS;AAC3D,MAAMC,YAAY,WAAW,GAAEC,IAAAA,mBAAQ,EAAC;IACtCC,MAAM;QACJC,QAAQ;QACRC,SAAS;IACX;AACF,GAAG;IACDC,GAAG;QAAC;QAAiC;KAA6B;AACpE;AAIO,MAAMR,qBAAqBS,CAAAA,UAAW;IAC3C,MAAM,EACJC,eAAc,EACdC,IAAG,EACJ,GAAGC,IAAAA,uCAAS;IACb,MAAMC,kBAAkBC,IAAAA,6BAAe;IACvC,MAAMC,UAAUZ;IAChB,MAAMa,iBAAiBC,IAAAA,+CAAiB;IACxC,MAAMC,YAAYC,IAAAA,oBAAY,EAACH,gBAAgBD,QAAQV,IAAI,EAAEI,QAAQS,SAAS;IAC9E,MAAME,UAAUC,IAAAA,4BAAa,EAAC,IAAM;QAClC,IAAIX,mBAAmBY,aAAab,QAAQc,QAAQ,EAAE;YACpD,OAAO;gBAAC,IAAI;gBAAE,IAAM,IAAI;aAAC;QAC3B,CAAC;QACD,MAAMC,aAAad,eAAee,aAAa,CAAC;QAChDf,eAAegB,IAAI,CAACC,WAAW,CAACH;QAChC,OAAO;YAACA;YAAY,IAAMA,WAAWI,MAAM;SAAG;IAChD,GAAG;QAAClB;KAAe;IACnB,IAAIT,oBAAoB;QACtB,sDAAsD;QACtDA,mBAAmB,IAAM;YACvB,IAAI,CAACmB,SAAS;gBACZ;YACF,CAAC;YACD,MAAMS,iBAAiBX,UAAUY,KAAK,CAAC,KAAKC,MAAM,CAACC;YACnDZ,QAAQa,SAAS,CAACC,GAAG,IAAIL;YACzBT,QAAQe,YAAY,CAAC,OAAOxB;YAC5BE,gBAAgBuB,OAAO,GAAGhB;YAC1B,OAAO,IAAM;gBACXA,QAAQa,SAAS,CAACL,MAAM,IAAIC;gBAC5BT,QAAQiB,eAAe,CAAC;YAC1B;QACF,GAAG;YAACnB;YAAWP;YAAKS;YAASP;SAAgB;IAC/C,OAAO;QACL,gDAAgD;QAChD,4EAA4E;QAC5E,yFAAyF;QACzF,iFAAiF;QACjF,sDAAsD;QACtDX,OAAMoC,OAAO,CAAC,IAAM;YAClB,IAAI,CAAClB,SAAS;gBACZ;YACF,CAAC;YACD,4BAA4B;YAC5BA,QAAQF,SAAS,GAAGA;YACpBE,QAAQe,YAAY,CAAC,OAAOxB;YAC5BE,gBAAgBuB,OAAO,GAAGhB;QAC5B,GAAG;YAACF;YAAWP;YAAKS;YAASP;SAAgB;IAC/C,CAAC;IACD,OAAOO;AACT,GACA,8CAA8C"}
|
package/lib-commonjs/index.js
CHANGED
@@ -1,39 +1,22 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
5
|
-
});
|
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
|
-
}
|
3
|
+
value: true
|
19
4
|
});
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
}
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
});
|
33
|
-
Object.defineProperty(exports, "setVirtualParent", {
|
34
|
-
enumerable: true,
|
35
|
-
get: function () {
|
36
|
-
return index_2.setVirtualParent;
|
37
|
-
}
|
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
|
+
Portal: ()=>_index.Portal,
|
13
|
+
renderPortal_unstable: ()=>_index.renderPortal_unstable,
|
14
|
+
usePortal_unstable: ()=>_index.usePortal_unstable,
|
15
|
+
elementContains: ()=>_index1.elementContains,
|
16
|
+
setVirtualParent: ()=>_index1.setVirtualParent
|
38
17
|
});
|
18
|
+
const _index = require("./components/Portal/index");
|
19
|
+
const _index1 = require("./virtualParent/index");
|
20
|
+
//# sourceMappingURL=index.js.map
|
21
|
+
|
39
22
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../lib/index.js"],"sourcesContent":["export { Portal, renderPortal_unstable, usePortal_unstable } from './components/Portal/index';\nexport { elementContains, setVirtualParent } from './virtualParent/index';\n//# sourceMappingURL=index.js.map"],"names":["Portal","renderPortal_unstable","usePortal_unstable","elementContains","setVirtualParent"],"mappings":";;;;;;;;;;;IAASA,MAAM,MAANA,aAAM;IAAEC,qBAAqB,MAArBA,4BAAqB;IAAEC,kBAAkB,MAAlBA,yBAAkB;IACjDC,eAAe,MAAfA,uBAAe;IAAEC,gBAAgB,MAAhBA,wBAAgB;;uBADwB;wBAChB;CAClD,iCAAiC"}
|
@@ -1,37 +1,33 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "elementContains", {
|
6
|
+
enumerable: true,
|
7
|
+
get: ()=>elementContains
|
5
8
|
});
|
6
|
-
|
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
|
-
*/
|
9
|
+
const _getParent = require("./getParent");
|
14
10
|
function elementContains(parent, child) {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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) {
|
11
|
+
if (!parent || !child) {
|
12
|
+
return false;
|
13
|
+
}
|
14
|
+
if (parent === child) {
|
29
15
|
return true;
|
30
|
-
|
31
|
-
|
16
|
+
} else {
|
17
|
+
// Tracks references of nodes that have been visited to prevent infinite loops
|
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
|
+
}
|
32
29
|
}
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
exports.elementContains = elementContains;
|
30
|
+
return false;
|
31
|
+
} //# sourceMappingURL=elementContains.js.map
|
32
|
+
|
37
33
|
//# sourceMappingURL=elementContains.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../lib/virtualParent/elementContains.js"],"sourcesContent":["import { getParent } from './getParent';\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, child) {\n if (!parent || !child) {\n return false;\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();\n while (child) {\n const nextParent = getParent(child, {\n skipVirtual: set.has(child)\n });\n set.add(child);\n if (nextParent === parent) {\n return true;\n }\n child = nextParent;\n }\n }\n return false;\n}\n//# sourceMappingURL=elementContains.js.map"],"names":["elementContains","parent","child","set","WeakSet","nextParent","getParent","skipVirtual","has","add"],"mappings":";;;;+BAOgBA;;aAAAA;;2BAPU;AAOnB,SAASA,gBAAgBC,MAAM,EAAEC,KAAK,EAAE;IAC7C,IAAI,CAACD,UAAU,CAACC,OAAO;QACrB,OAAO,KAAK;IACd,CAAC;IACD,IAAID,WAAWC,OAAO;QACpB,OAAO,IAAI;IACb,OAAO;QACL,8EAA8E;QAC9E,MAAMC,MAAM,IAAIC;QAChB,MAAOF,MAAO;YACZ,MAAMG,aAAaC,IAAAA,oBAAS,EAACJ,OAAO;gBAClCK,aAAaJ,IAAIK,GAAG,CAACN;YACvB;YACAC,IAAIM,GAAG,CAACP;YACR,IAAIG,eAAeJ,QAAQ;gBACzB,OAAO,IAAI;YACb,CAAC;YACDC,QAAQG;QACV;IACF,CAAC;IACD,OAAO,KAAK;AACd,EACA,2CAA2C"}
|
@@ -1,31 +1,28 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "getParent", {
|
6
|
+
enumerable: true,
|
7
|
+
get: ()=>getParent
|
5
8
|
});
|
6
|
-
|
7
|
-
const isVirtualElement_1 = /*#__PURE__*/require("./isVirtualElement");
|
9
|
+
const _isVirtualElement = require("./isVirtualElement");
|
8
10
|
/**
|
9
11
|
* Gets the virtual parent given the child element, if it exists.
|
10
|
-
*/
|
11
|
-
|
12
|
-
return isVirtualElement_1.isVirtualElement(child) ? child._virtual.parent || null : null;
|
12
|
+
*/ function getVirtualParent(child) {
|
13
|
+
return (0, _isVirtualElement.isVirtualElement)(child) ? child._virtual.parent || null : null;
|
13
14
|
}
|
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
|
-
*/
|
18
15
|
function getParent(child, options = {}) {
|
19
|
-
|
20
|
-
|
21
|
-
}
|
22
|
-
if (!options.skipVirtual) {
|
23
|
-
const virtualParent = getVirtualParent(child);
|
24
|
-
if (virtualParent) {
|
25
|
-
return virtualParent;
|
16
|
+
if (!child) {
|
17
|
+
return null;
|
26
18
|
}
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
19
|
+
if (!options.skipVirtual) {
|
20
|
+
const virtualParent = getVirtualParent(child);
|
21
|
+
if (virtualParent) {
|
22
|
+
return virtualParent;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
return (child === null || child === void 0 ? void 0 : child.parentNode) || null;
|
26
|
+
} //# sourceMappingURL=getParent.js.map
|
27
|
+
|
31
28
|
//# sourceMappingURL=getParent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../lib/virtualParent/getParent.js"],"sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n/**\n * Gets the virtual parent given the child element, if it exists.\n */\nfunction getVirtualParent(child) {\n return isVirtualElement(child) ? child._virtual.parent || null : null;\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, options = {}) {\n if (!child) {\n return null;\n }\n if (!options.skipVirtual) {\n const virtualParent = getVirtualParent(child);\n if (virtualParent) {\n return virtualParent;\n }\n }\n return (child === null || child === void 0 ? void 0 : child.parentNode) || null;\n}\n//# sourceMappingURL=getParent.js.map"],"names":["getParent","getVirtualParent","child","isVirtualElement","_virtual","parent","options","skipVirtual","virtualParent","parentNode"],"mappings":";;;;+BAWgBA;;aAAAA;;kCAXiB;AACjC;;CAEC,GACD,SAASC,iBAAiBC,KAAK,EAAE;IAC/B,OAAOC,IAAAA,kCAAgB,EAACD,SAASA,MAAME,QAAQ,CAACC,MAAM,IAAI,IAAI,GAAG,IAAI;AACvE;AAKO,SAASL,UAAUE,KAAK,EAAEI,UAAU,CAAC,CAAC,EAAE;IAC7C,IAAI,CAACJ,OAAO;QACV,OAAO,IAAI;IACb,CAAC;IACD,IAAI,CAACI,QAAQC,WAAW,EAAE;QACxB,MAAMC,gBAAgBP,iBAAiBC;QACvC,IAAIM,eAAe;YACjB,OAAOA;QACT,CAAC;IACH,CAAC;IACD,OAAO,AAACN,CAAAA,UAAU,IAAI,IAAIA,UAAU,KAAK,IAAI,KAAK,IAAIA,MAAMO,UAAU,AAAD,KAAM,IAAI;AACjF,EACA,qCAAqC"}
|
@@ -1,9 +1,10 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
5
4
|
});
|
6
|
-
const
|
7
|
-
|
8
|
-
|
5
|
+
const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
|
6
|
+
_exportStar(require("./elementContains"), exports);
|
7
|
+
_exportStar(require("./setVirtualParent"), exports);
|
8
|
+
//# sourceMappingURL=index.js.map
|
9
|
+
|
9
10
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../lib/virtualParent/index.js"],"sourcesContent":["export * from './elementContains';\nexport * from './setVirtualParent';\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;;oBAAc;oBACA;CACd,iCAAiC"}
|
@@ -1,14 +1,15 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.isVirtualElement = void 0;
|
7
1
|
/**
|
8
2
|
* Determines whether or not an element has the virtual hierarchy extension.
|
9
|
-
*/
|
3
|
+
*/ "use strict";
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
5
|
+
value: true
|
6
|
+
});
|
7
|
+
Object.defineProperty(exports, "isVirtualElement", {
|
8
|
+
enumerable: true,
|
9
|
+
get: ()=>isVirtualElement
|
10
|
+
});
|
10
11
|
function isVirtualElement(element) {
|
11
|
-
|
12
|
-
}
|
13
|
-
|
12
|
+
return element && !!element._virtual;
|
13
|
+
} //# sourceMappingURL=isVirtualElement.js.map
|
14
|
+
|
14
15
|
//# sourceMappingURL=isVirtualElement.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../lib/virtualParent/isVirtualElement.js"],"sourcesContent":["/**\n * Determines whether or not an element has the virtual hierarchy extension.\n */export function isVirtualElement(element) {\n return element && !!element._virtual;\n}\n//# sourceMappingURL=isVirtualElement.js.map"],"names":["isVirtualElement","element","_virtual"],"mappings":"AAAA;;CAEC;;;;+BAAkBA;;aAAAA;;AAAT,SAASA,iBAAiBC,OAAO,EAAE;IAC3C,OAAOA,WAAW,CAAC,CAACA,QAAQC,QAAQ;AACtC,EACA,4CAA4C"}
|
@@ -1,24 +1,25 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.setVirtualParent = void 0;
|
7
1
|
/**
|
8
2
|
* Sets the virtual parent of an element.
|
9
3
|
*
|
10
4
|
* @param child - Theme element to set the virtual parent
|
11
5
|
* @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship
|
12
|
-
*/
|
6
|
+
*/ "use strict";
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
8
|
+
value: true
|
9
|
+
});
|
10
|
+
Object.defineProperty(exports, "setVirtualParent", {
|
11
|
+
enumerable: true,
|
12
|
+
get: ()=>setVirtualParent
|
13
|
+
});
|
13
14
|
function setVirtualParent(child, parent) {
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
}
|
23
|
-
|
15
|
+
if (!child) {
|
16
|
+
return;
|
17
|
+
}
|
18
|
+
const virtualChild = child;
|
19
|
+
if (!virtualChild._virtual) {
|
20
|
+
virtualChild._virtual = {};
|
21
|
+
}
|
22
|
+
virtualChild._virtual.parent = parent;
|
23
|
+
} //# sourceMappingURL=setVirtualParent.js.map
|
24
|
+
|
24
25
|
//# sourceMappingURL=setVirtualParent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../lib/virtualParent/setVirtualParent.js"],"sourcesContent":["/**\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 */export function setVirtualParent(child, parent) {\n if (!child) {\n return;\n }\n const virtualChild = child;\n if (!virtualChild._virtual) {\n virtualChild._virtual = {};\n }\n virtualChild._virtual.parent = parent;\n}\n//# sourceMappingURL=setVirtualParent.js.map"],"names":["setVirtualParent","child","parent","virtualChild","_virtual"],"mappings":"AAAA;;;;;CAKC;;;;+BAAkBA;;aAAAA;;AAAT,SAASA,iBAAiBC,KAAK,EAAEC,MAAM,EAAE;IACjD,IAAI,CAACD,OAAO;QACV;IACF,CAAC;IACD,MAAME,eAAeF;IACrB,IAAI,CAACE,aAAaC,QAAQ,EAAE;QAC1BD,aAAaC,QAAQ,GAAG,CAAC;IAC3B,CAAC;IACDD,aAAaC,QAAQ,CAACF,MAAM,GAAGA;AACjC,EACA,4CAA4C"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../lib/virtualParent/types.js"],"sourcesContent":["export {};\n//# sourceMappingURL=types.js.map"],"names":[],"mappings":";;;;CACA,iCAAiC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-portal",
|
3
|
-
"version": "9.2.
|
3
|
+
"version": "9.2.2",
|
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",
|
@@ -22,7 +22,7 @@
|
|
22
22
|
"test": "jest --passWithNoTests",
|
23
23
|
"storybook": "start-storybook",
|
24
24
|
"type-check": "tsc -b tsconfig.json",
|
25
|
-
"generate-api": "
|
25
|
+
"generate-api": "just-scripts generate-api"
|
26
26
|
},
|
27
27
|
"devDependencies": {
|
28
28
|
"@fluentui/eslint-plugin": "*",
|
@@ -31,11 +31,11 @@
|
|
31
31
|
"@fluentui/scripts-tasks": "*"
|
32
32
|
},
|
33
33
|
"dependencies": {
|
34
|
-
"@fluentui/react-shared-contexts": "^9.3.
|
35
|
-
"@fluentui/react-tabster": "^9.6.
|
36
|
-
"@fluentui/react-utilities": "^9.7.
|
34
|
+
"@fluentui/react-shared-contexts": "^9.3.2",
|
35
|
+
"@fluentui/react-tabster": "^9.6.1",
|
36
|
+
"@fluentui/react-utilities": "^9.7.2",
|
37
37
|
"@griffel/react": "^1.5.2",
|
38
|
-
"
|
38
|
+
"@swc/helpers": "^0.4.14",
|
39
39
|
"use-disposable": "^1.0.1"
|
40
40
|
},
|
41
41
|
"peerDependencies": {
|
@@ -53,6 +53,7 @@
|
|
53
53
|
"exports": {
|
54
54
|
".": {
|
55
55
|
"types": "./dist/index.d.ts",
|
56
|
+
"node": "./lib-commonjs/index.js",
|
56
57
|
"import": "./lib/index.js",
|
57
58
|
"require": "./lib-commonjs/index.js"
|
58
59
|
},
|
@@ -1,16 +0,0 @@
|
|
1
|
-
define(["require", "exports", "./usePortal", "./renderPortal"], function (require, exports, usePortal_1, renderPortal_1) {
|
2
|
-
"use strict";
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
exports.Portal = void 0;
|
5
|
-
/**
|
6
|
-
* A portal provides a way to render children into a DOM node
|
7
|
-
* that exists outside the DOM hierarchy of the parent component.
|
8
|
-
*/
|
9
|
-
var Portal = function (props) {
|
10
|
-
var state = usePortal_1.usePortal_unstable(props);
|
11
|
-
return renderPortal_1.renderPortal_unstable(state);
|
12
|
-
};
|
13
|
-
exports.Portal = Portal;
|
14
|
-
exports.Portal.displayName = 'Portal';
|
15
|
-
});
|
16
|
-
//# sourceMappingURL=Portal.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"Portal.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-portal/src/components/Portal/Portal.tsx"],"names":[],"mappings":";;;;IAMA;;;OAGG;IACI,IAAM,MAAM,GAA0B,UAAA,KAAK;QAChD,IAAM,KAAK,GAAG,8BAAkB,CAAC,KAAK,CAAC,CAAC;QAExC,OAAO,oCAAqB,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC,CAAC;IAJW,QAAA,MAAM,UAIjB;IAEF,cAAM,CAAC,WAAW,GAAG,QAAQ,CAAC","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"]}
|