@fluentui/react-portal 9.1.2 → 9.1.4
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +57 -1
- package/CHANGELOG.md +23 -2
- package/dist/index.d.ts +1 -1
- package/lib/components/Portal/usePortal.js +5 -0
- package/lib/components/Portal/usePortal.js.map +1 -1
- package/lib/virtualParent/elementContains.js +7 -2
- package/lib/virtualParent/elementContains.js.map +1 -1
- package/lib/virtualParent/getParent.js +18 -4
- package/lib/virtualParent/getParent.js.map +1 -1
- package/lib/virtualParent/index.js +0 -3
- package/lib/virtualParent/index.js.map +1 -1
- package/lib/virtualParent/setVirtualParent.js +1 -1
- package/lib/virtualParent/setVirtualParent.js.map +1 -1
- package/lib-amd/components/Portal/usePortal.js +5 -0
- package/lib-amd/components/Portal/usePortal.js.map +1 -1
- package/lib-amd/virtualParent/elementContains.js +7 -2
- package/lib-amd/virtualParent/elementContains.js.map +1 -1
- package/lib-amd/virtualParent/getParent.js +19 -4
- package/lib-amd/virtualParent/getParent.js.map +1 -1
- package/lib-amd/virtualParent/index.js +1 -4
- package/lib-amd/virtualParent/index.js.map +1 -1
- package/lib-amd/virtualParent/setVirtualParent.js +1 -1
- package/lib-amd/virtualParent/setVirtualParent.js.map +1 -1
- package/lib-commonjs/components/Portal/usePortal.js +5 -0
- package/lib-commonjs/components/Portal/usePortal.js.map +1 -1
- package/lib-commonjs/virtualParent/elementContains.js +7 -2
- package/lib-commonjs/virtualParent/elementContains.js.map +1 -1
- package/lib-commonjs/virtualParent/getParent.js +18 -4
- package/lib-commonjs/virtualParent/getParent.js.map +1 -1
- package/lib-commonjs/virtualParent/index.js +0 -3
- package/lib-commonjs/virtualParent/index.js.map +1 -1
- package/lib-commonjs/virtualParent/setVirtualParent.js +1 -1
- package/lib-commonjs/virtualParent/setVirtualParent.js.map +1 -1
- package/package.json +4 -4
- package/lib/virtualParent/getVirtualParent.js +0 -8
- package/lib/virtualParent/getVirtualParent.js.map +0 -1
- package/lib-amd/virtualParent/getVirtualParent.js +0 -13
- package/lib-amd/virtualParent/getVirtualParent.js.map +0 -1
- package/lib-commonjs/virtualParent/getVirtualParent.js +0 -15
- package/lib-commonjs/virtualParent/getVirtualParent.js.map +0 -1
package/CHANGELOG.json
CHANGED
@@ -2,7 +2,63 @@
|
|
2
2
|
"name": "@fluentui/react-portal",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
5
|
+
"date": "Thu, 26 Jan 2023 13:27:47 GMT",
|
6
|
+
"tag": "@fluentui/react-portal_v9.1.4",
|
7
|
+
"version": "9.1.4",
|
8
|
+
"comments": {
|
9
|
+
"none": [
|
10
|
+
{
|
11
|
+
"author": "miroslav.stastny@microsoft.com",
|
12
|
+
"package": "@fluentui/react-portal",
|
13
|
+
"commit": "6f29c8f65b2db6125efbd2a7ec2d7abdd0f44601",
|
14
|
+
"comment": "Lint based re-format"
|
15
|
+
}
|
16
|
+
],
|
17
|
+
"patch": [
|
18
|
+
{
|
19
|
+
"author": "olfedias@microsoft.com",
|
20
|
+
"package": "@fluentui/react-portal",
|
21
|
+
"commit": "17ce027879486fa8d2a775864cb119fb194fab8b",
|
22
|
+
"comment": "fix: update elementContains() to handle circular references"
|
23
|
+
},
|
24
|
+
{
|
25
|
+
"author": "beachball",
|
26
|
+
"package": "@fluentui/react-portal",
|
27
|
+
"comment": "Bump @fluentui/react-shared-contexts to v9.2.0",
|
28
|
+
"commit": "403e1370f1effca7d3db131eda381abf31cf66b1"
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"author": "beachball",
|
32
|
+
"package": "@fluentui/react-portal",
|
33
|
+
"comment": "Bump @fluentui/react-tabster to v9.4.1",
|
34
|
+
"commit": "403e1370f1effca7d3db131eda381abf31cf66b1"
|
35
|
+
},
|
36
|
+
{
|
37
|
+
"author": "beachball",
|
38
|
+
"package": "@fluentui/react-portal",
|
39
|
+
"comment": "Bump @fluentui/react-utilities to v9.5.0",
|
40
|
+
"commit": "403e1370f1effca7d3db131eda381abf31cf66b1"
|
41
|
+
}
|
42
|
+
]
|
43
|
+
}
|
44
|
+
},
|
45
|
+
{
|
46
|
+
"date": "Mon, 23 Jan 2023 16:43:11 GMT",
|
47
|
+
"tag": "@fluentui/react-portal_v9.1.3",
|
48
|
+
"version": "9.1.3",
|
49
|
+
"comments": {
|
50
|
+
"patch": [
|
51
|
+
{
|
52
|
+
"author": "arthurd@microsoft.com",
|
53
|
+
"package": "@fluentui/react-portal",
|
54
|
+
"commit": "f6440277702514c86bd2a640a7706940ffcbe7d0",
|
55
|
+
"comment": "clean up parent reference to avoid memory leaks"
|
56
|
+
}
|
57
|
+
]
|
58
|
+
}
|
59
|
+
},
|
60
|
+
{
|
61
|
+
"date": "Wed, 18 Jan 2023 16:32:55 GMT",
|
6
62
|
"tag": "@fluentui/react-portal_v9.1.2",
|
7
63
|
"version": "9.1.2",
|
8
64
|
"comments": {
|
package/CHANGELOG.md
CHANGED
@@ -1,12 +1,33 @@
|
|
1
1
|
# Change Log - @fluentui/react-portal
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Thu, 26 Jan 2023 13:27:47 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
+
## [9.1.4](https://github.com/microsoft/fluentui/tree/@fluentui/react-portal_v9.1.4)
|
8
|
+
|
9
|
+
Thu, 26 Jan 2023 13:27:47 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-portal_v9.1.3..@fluentui/react-portal_v9.1.4)
|
11
|
+
|
12
|
+
### Patches
|
13
|
+
|
14
|
+
- fix: update elementContains() to handle circular references ([PR #26483](https://github.com/microsoft/fluentui/pull/26483) by olfedias@microsoft.com)
|
15
|
+
- Bump @fluentui/react-shared-contexts to v9.2.0 ([PR #26496](https://github.com/microsoft/fluentui/pull/26496) by beachball)
|
16
|
+
- Bump @fluentui/react-tabster to v9.4.1 ([PR #26496](https://github.com/microsoft/fluentui/pull/26496) by beachball)
|
17
|
+
- Bump @fluentui/react-utilities to v9.5.0 ([PR #26496](https://github.com/microsoft/fluentui/pull/26496) by beachball)
|
18
|
+
|
19
|
+
## [9.1.3](https://github.com/microsoft/fluentui/tree/@fluentui/react-portal_v9.1.3)
|
20
|
+
|
21
|
+
Mon, 23 Jan 2023 16:43:11 GMT
|
22
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-portal_v9.1.2..@fluentui/react-portal_v9.1.3)
|
23
|
+
|
24
|
+
### Patches
|
25
|
+
|
26
|
+
- clean up parent reference to avoid memory leaks ([PR #26435](https://github.com/microsoft/fluentui/pull/26435) by arthurd@microsoft.com)
|
27
|
+
|
7
28
|
## [9.1.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-portal_v9.1.2)
|
8
29
|
|
9
|
-
Wed, 18 Jan 2023 16:
|
30
|
+
Wed, 18 Jan 2023 16:32:55 GMT
|
10
31
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-portal_v9.1.1..@fluentui/react-portal_v9.1.2)
|
11
32
|
|
12
33
|
### Patches
|
package/dist/index.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import * as React_2 from 'react';
|
2
2
|
|
3
3
|
/**
|
4
|
-
* Similar functionality to `element.contains` DOM API for use
|
4
|
+
* Similar functionality to `element.contains` DOM API for use without of order DOM elements that
|
5
5
|
* checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent
|
6
6
|
*
|
7
7
|
* @returns true if the child can find the parent in its virtual hierarchy
|
@@ -26,6 +26,11 @@ export const usePortal_unstable = props => {
|
|
26
26
|
if (state.virtualParentRootRef.current && state.mountNode) {
|
27
27
|
setVirtualParent(state.mountNode, state.virtualParentRootRef.current);
|
28
28
|
}
|
29
|
+
return () => {
|
30
|
+
if (state.mountNode) {
|
31
|
+
setVirtualParent(state.mountNode, undefined);
|
32
|
+
}
|
33
|
+
};
|
29
34
|
}, [state.virtualParentRootRef, state.mountNode]);
|
30
35
|
return state;
|
31
36
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,kBAAkB,QAAQ,sBAAsB;AACzD,SAASC,gBAAgB,QAAQ,2BAA2B;AAG5D;;;;;;;AAOA,OAAO,MAAMC,kBAAkB,GAAIC,KAAkB,IAAiB;EACpE,MAAM;IAAEC,QAAQ;IAAEC;EAAS,CAAE,GAAGF,KAAK;EAErC,MAAMG,oBAAoB,GAAGP,KAAK,CAACQ,MAAM,CAAkB,IAAI,CAAC;EAChE,MAAMC,iBAAiB,GAAGR,kBAAkB,CAAC;IAAES,QAAQ,EAAE,CAAC,CAACJ;EAAS,CAAE,CAAC;EAEvE,MAAMK,KAAK,GAAgB;IACzBN,QAAQ;IACRC,SAAS,EAAEA,SAAS,aAATA,SAAS,cAATA,SAAS,GAAIG,iBAAiB;IACzCF;GACD;EAEDP,KAAK,CAACY,SAAS,CAAC,MAAK;IACnB,IAAID,KAAK,CAACJ,oBAAoB,CAACM,OAAO,IAAIF,KAAK,CAACL,SAAS,EAAE;MACzDJ,gBAAgB,CAACS,KAAK,CAACL,SAAS,EAAEK,KAAK,CAACJ,oBAAoB,CAACM,OAAO,CAAC;;
|
1
|
+
{"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,kBAAkB,QAAQ,sBAAsB;AACzD,SAASC,gBAAgB,QAAQ,2BAA2B;AAG5D;;;;;;;AAOA,OAAO,MAAMC,kBAAkB,GAAIC,KAAkB,IAAiB;EACpE,MAAM;IAAEC,QAAQ;IAAEC;EAAS,CAAE,GAAGF,KAAK;EAErC,MAAMG,oBAAoB,GAAGP,KAAK,CAACQ,MAAM,CAAkB,IAAI,CAAC;EAChE,MAAMC,iBAAiB,GAAGR,kBAAkB,CAAC;IAAES,QAAQ,EAAE,CAAC,CAACJ;EAAS,CAAE,CAAC;EAEvE,MAAMK,KAAK,GAAgB;IACzBN,QAAQ;IACRC,SAAS,EAAEA,SAAS,aAATA,SAAS,cAATA,SAAS,GAAIG,iBAAiB;IACzCF;GACD;EAEDP,KAAK,CAACY,SAAS,CAAC,MAAK;IACnB,IAAID,KAAK,CAACJ,oBAAoB,CAACM,OAAO,IAAIF,KAAK,CAACL,SAAS,EAAE;MACzDJ,gBAAgB,CAACS,KAAK,CAACL,SAAS,EAAEK,KAAK,CAACJ,oBAAoB,CAACM,OAAO,CAAC;;IAEvE,OAAO,MAAK;MACV,IAAIF,KAAK,CAACL,SAAS,EAAE;QACnBJ,gBAAgB,CAACS,KAAK,CAACL,SAAS,EAAEQ,SAAS,CAAC;;IAEhD,CAAC;EACH,CAAC,EAAE,CAACH,KAAK,CAACJ,oBAAoB,EAAEI,KAAK,CAACL,SAAS,CAAC,CAAC;EAEjD,OAAOK,KAAK;AACd,CAAC","names":["React","usePortalMountNode","setVirtualParent","usePortal_unstable","props","children","mountNode","virtualParentRootRef","useRef","fallbackMountNode","disabled","state","useEffect","current","undefined"],"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 return () => {\n if (state.mountNode) {\n setVirtualParent(state.mountNode, undefined);\n }\n };\n }, [state.virtualParentRootRef, state.mountNode]);\n\n return state;\n};\n"]}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { getParent } from './getParent';
|
2
2
|
/**
|
3
|
-
* Similar functionality to `element.contains` DOM API for use
|
3
|
+
* Similar functionality to `element.contains` DOM API for use without of order DOM elements that
|
4
4
|
* checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent
|
5
5
|
*
|
6
6
|
* @returns true if the child can find the parent in its virtual hierarchy
|
@@ -12,8 +12,13 @@ export function elementContains(parent, child) {
|
|
12
12
|
if (parent === child) {
|
13
13
|
return true;
|
14
14
|
} else {
|
15
|
+
// Tracks references of nodes that have been visited to prevent infinite loops
|
16
|
+
const set = new WeakSet();
|
15
17
|
while (child) {
|
16
|
-
const nextParent = getParent(child
|
18
|
+
const nextParent = getParent(child, {
|
19
|
+
skipVirtual: set.has(child)
|
20
|
+
});
|
21
|
+
set.add(child);
|
17
22
|
if (nextParent === parent) {
|
18
23
|
return true;
|
19
24
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"mappings":"AAAA,SAASA,SAAS,QAAQ,aAAa;
|
1
|
+
{"version":3,"mappings":"AAAA,SAASA,SAAS,QAAQ,aAAa;AAEvC;;;;;;AAMA,OAAM,SAAUC,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;IACA,MAAMC,GAAG,GAAG,IAAIC,OAAO,EAAQ;IAE/B,OAAOF,KAAK,EAAE;MACZ,MAAMG,UAAU,GAAgBN,SAAS,CAACG,KAAK,EAAE;QAC/CI,WAAW,EAAEH,GAAG,CAACI,GAAG,CAACL,KAAK;OAC3B,CAAC;MACFC,GAAG,CAACK,GAAG,CAACN,KAAK,CAAC;MAEd,IAAIG,UAAU,KAAKJ,MAAM,EAAE;QACzB,OAAO,IAAI;;MAGbC,KAAK,GAAGG,UAAU;;;EAItB,OAAO,KAAK;AACd","names":["getParent","elementContains","parent","child","set","WeakSet","nextParent","skipVirtual","has","add"],"sourceRoot":"../src/","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"]}
|
@@ -1,10 +1,24 @@
|
|
1
|
-
import {
|
1
|
+
import { isVirtualElement } from './isVirtualElement';
|
2
|
+
/**
|
3
|
+
* Gets the virtual parent given the child element, if it exists.
|
4
|
+
*/
|
5
|
+
function getVirtualParent(child) {
|
6
|
+
return isVirtualElement(child) ? child._virtual.parent || null : null;
|
7
|
+
}
|
2
8
|
/**
|
3
9
|
* Gets the element which is the parent of a given element.
|
4
10
|
* This method prefers the virtual parent over real DOM parent when present.
|
5
11
|
*/
|
6
|
-
export function getParent(child) {
|
7
|
-
|
8
|
-
|
12
|
+
export function getParent(child, options = {}) {
|
13
|
+
if (!child) {
|
14
|
+
return null;
|
15
|
+
}
|
16
|
+
if (!options.skipVirtual) {
|
17
|
+
const virtualParent = getVirtualParent(child);
|
18
|
+
if (virtualParent) {
|
19
|
+
return virtualParent;
|
20
|
+
}
|
21
|
+
}
|
22
|
+
return (child === null || child === void 0 ? void 0 : child.parentNode) || null;
|
9
23
|
}
|
10
24
|
//# sourceMappingURL=getParent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"mappings":"AAAA,SAASA,gBAAgB,QAAQ,oBAAoB;
|
1
|
+
{"version":3,"mappings":"AAAA,SAASA,gBAAgB,QAAQ,oBAAoB;AASrD;;;AAGA,SAASC,gBAAgB,CAACC,KAAW;EACnC,OAAOF,gBAAgB,CAACE,KAAK,CAAC,GAAGA,KAAK,CAACC,QAAQ,CAACC,MAAM,IAAI,IAAI,GAAG,IAAI;AACvE;AAEA;;;;AAIA,OAAM,SAAUC,SAAS,CAACH,KAAkB,EAAEI,UAA4B,EAAE;EAC1E,IAAI,CAACJ,KAAK,EAAE;IACV,OAAO,IAAI;;EAGb,IAAI,CAACI,OAAO,CAACC,WAAW,EAAE;IACxB,MAAMC,aAAa,GAAGP,gBAAgB,CAACC,KAAK,CAAC;IAE7C,IAAIM,aAAa,EAAE;MACjB,OAAOA,aAAa;;;EAIxB,OAAO,MAAK,aAALN,KAAK,uBAALA,KAAK,CAAEO,UAAU,KAAI,IAAI;AAClC","names":["isVirtualElement","getVirtualParent","child","_virtual","parent","getParent","options","skipVirtual","virtualParent","parentNode"],"sourceRoot":"../src/","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"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/virtualParent/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/virtualParent/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from './elementContains';\nexport * from './setVirtualParent';\n"]}
|
@@ -12,6 +12,6 @@ export function setVirtualParent(child, parent) {
|
|
12
12
|
if (!virtualChild._virtual) {
|
13
13
|
virtualChild._virtual = {};
|
14
14
|
}
|
15
|
-
virtualChild._virtual.parent = parent
|
15
|
+
virtualChild._virtual.parent = parent;
|
16
16
|
}
|
17
17
|
//# sourceMappingURL=setVirtualParent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"mappings":"AAEA;;;;;;AAMA,OAAM,SAAUA,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
|
1
|
+
{"version":3,"mappings":"AAEA;;;;;;AAMA,OAAM,SAAUA,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;AACvC","names":["setVirtualParent","child","parent","virtualChild","_virtual"],"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;\n}\n"]}
|
@@ -22,6 +22,11 @@ define(["require", "exports", "react", "./usePortalMountNode", "../../virtualPar
|
|
22
22
|
if (state.virtualParentRootRef.current && state.mountNode) {
|
23
23
|
index_1.setVirtualParent(state.mountNode, state.virtualParentRootRef.current);
|
24
24
|
}
|
25
|
+
return function () {
|
26
|
+
if (state.mountNode) {
|
27
|
+
index_1.setVirtualParent(state.mountNode, undefined);
|
28
|
+
}
|
29
|
+
};
|
25
30
|
}, [state.virtualParentRootRef, state.mountNode]);
|
26
31
|
return state;
|
27
32
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"usePortal.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-portal/src/components/Portal/usePortal.ts"],"names":[],"mappings":";;;;IAKA;;;;;;OAMG;IACI,IAAM,kBAAkB,GAAG,UAAC,KAAkB;QAC3C,IAAA,QAAQ,GAAgB,KAAK,SAArB,EAAE,SAAS,GAAK,KAAK,UAAV,CAAW;QAEtC,IAAM,oBAAoB,GAAG,KAAK,CAAC,MAAM,CAAkB,IAAI,CAAC,CAAC;QACjE,IAAM,iBAAiB,GAAG,uCAAkB,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;QAExE,IAAM,KAAK,GAAgB;YACzB,QAAQ,UAAA;YACR,SAAS,EAAE,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,iBAAiB;YACzC,oBAAoB,sBAAA;SACrB,CAAC;QAEF,KAAK,CAAC,SAAS,CAAC;YACd,IAAI,KAAK,CAAC,oBAAoB,CAAC,OAAO,IAAI,KAAK,CAAC,SAAS,EAAE;gBACzD,wBAAgB,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;aACvE;
|
1
|
+
{"version":3,"file":"usePortal.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-portal/src/components/Portal/usePortal.ts"],"names":[],"mappings":";;;;IAKA;;;;;;OAMG;IACI,IAAM,kBAAkB,GAAG,UAAC,KAAkB;QAC3C,IAAA,QAAQ,GAAgB,KAAK,SAArB,EAAE,SAAS,GAAK,KAAK,UAAV,CAAW;QAEtC,IAAM,oBAAoB,GAAG,KAAK,CAAC,MAAM,CAAkB,IAAI,CAAC,CAAC;QACjE,IAAM,iBAAiB,GAAG,uCAAkB,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;QAExE,IAAM,KAAK,GAAgB;YACzB,QAAQ,UAAA;YACR,SAAS,EAAE,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,iBAAiB;YACzC,oBAAoB,sBAAA;SACrB,CAAC;QAEF,KAAK,CAAC,SAAS,CAAC;YACd,IAAI,KAAK,CAAC,oBAAoB,CAAC,OAAO,IAAI,KAAK,CAAC,SAAS,EAAE;gBACzD,wBAAgB,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;aACvE;YACD,OAAO;gBACL,IAAI,KAAK,CAAC,SAAS,EAAE;oBACnB,wBAAgB,CAAC,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;iBAC9C;YACH,CAAC,CAAC;QACJ,CAAC,EAAE,CAAC,KAAK,CAAC,oBAAoB,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;QAElD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IAxBW,QAAA,kBAAkB,sBAwB7B","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 return () => {\n if (state.mountNode) {\n setVirtualParent(state.mountNode, undefined);\n }\n };\n }, [state.virtualParentRootRef, state.mountNode]);\n\n return state;\n};\n"]}
|
@@ -3,7 +3,7 @@ define(["require", "exports", "./getParent"], function (require, exports, getPar
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4
4
|
exports.elementContains = void 0;
|
5
5
|
/**
|
6
|
-
* Similar functionality to `element.contains` DOM API for use
|
6
|
+
* Similar functionality to `element.contains` DOM API for use without of order DOM elements that
|
7
7
|
* checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent
|
8
8
|
*
|
9
9
|
* @returns true if the child can find the parent in its virtual hierarchy
|
@@ -16,8 +16,13 @@ define(["require", "exports", "./getParent"], function (require, exports, getPar
|
|
16
16
|
return true;
|
17
17
|
}
|
18
18
|
else {
|
19
|
+
// Tracks references of nodes that have been visited to prevent infinite loops
|
20
|
+
var set = new WeakSet();
|
19
21
|
while (child) {
|
20
|
-
var nextParent = getParent_1.getParent(child
|
22
|
+
var nextParent = getParent_1.getParent(child, {
|
23
|
+
skipVirtual: set.has(child),
|
24
|
+
});
|
25
|
+
set.add(child);
|
21
26
|
if (nextParent === parent) {
|
22
27
|
return true;
|
23
28
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"elementContains.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/elementContains.ts"],"names":[],"mappings":";;;;
|
1
|
+
{"version":3,"file":"elementContains.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/elementContains.ts"],"names":[],"mappings":";;;;IAEA;;;;;OAKG;IACH,SAAgB,eAAe,CAAC,MAAmB,EAAE,KAAkB;QACrE,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,EAAE;YACrB,OAAO,KAAK,CAAC;SACd;QAED,IAAI,MAAM,KAAK,KAAK,EAAE;YACpB,OAAO,IAAI,CAAC;SACb;aAAM;YACL,8EAA8E;YAC9E,IAAM,GAAG,GAAG,IAAI,OAAO,EAAQ,CAAC;YAEhC,OAAO,KAAK,EAAE;gBACZ,IAAM,UAAU,GAAgB,qBAAS,CAAC,KAAK,EAAE;oBAC/C,WAAW,EAAE,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC;iBAC5B,CAAC,CAAC;gBACH,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBAEf,IAAI,UAAU,KAAK,MAAM,EAAE;oBACzB,OAAO,IAAI,CAAC;iBACb;gBAED,KAAK,GAAG,UAAU,CAAC;aACpB;SACF;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IA1BD,0CA0BC","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"]}
|
@@ -1,14 +1,29 @@
|
|
1
|
-
define(["require", "exports", "./
|
1
|
+
define(["require", "exports", "./isVirtualElement"], function (require, exports, isVirtualElement_1) {
|
2
2
|
"use strict";
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4
4
|
exports.getParent = void 0;
|
5
|
+
/**
|
6
|
+
* Gets the virtual parent given the child element, if it exists.
|
7
|
+
*/
|
8
|
+
function getVirtualParent(child) {
|
9
|
+
return isVirtualElement_1.isVirtualElement(child) ? child._virtual.parent || null : null;
|
10
|
+
}
|
5
11
|
/**
|
6
12
|
* Gets the element which is the parent of a given element.
|
7
13
|
* This method prefers the virtual parent over real DOM parent when present.
|
8
14
|
*/
|
9
|
-
function getParent(child) {
|
10
|
-
|
11
|
-
|
15
|
+
function getParent(child, options) {
|
16
|
+
if (options === void 0) { options = {}; }
|
17
|
+
if (!child) {
|
18
|
+
return null;
|
19
|
+
}
|
20
|
+
if (!options.skipVirtual) {
|
21
|
+
var virtualParent = getVirtualParent(child);
|
22
|
+
if (virtualParent) {
|
23
|
+
return virtualParent;
|
24
|
+
}
|
25
|
+
}
|
26
|
+
return (child === null || child === void 0 ? void 0 : child.parentNode) || null;
|
12
27
|
}
|
13
28
|
exports.getParent = getParent;
|
14
29
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getParent.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/getParent.ts"],"names":[],"mappings":";;;;
|
1
|
+
{"version":3,"file":"getParent.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/getParent.ts"],"names":[],"mappings":";;;;IASA;;OAEG;IACH,SAAS,gBAAgB,CAAC,KAAW;QACnC,OAAO,mCAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACxE,CAAC;IAED;;;OAGG;IACH,SAAgB,SAAS,CAAC,KAAkB,EAAE,OAA8B;QAA9B,wBAAA,EAAA,YAA8B;QAC1E,IAAI,CAAC,KAAK,EAAE;YACV,OAAO,IAAI,CAAC;SACb;QAED,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE;YACxB,IAAM,aAAa,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;YAE9C,IAAI,aAAa,EAAE;gBACjB,OAAO,aAAa,CAAC;aACtB;SACF;QAED,OAAO,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,KAAI,IAAI,CAAC;IACnC,CAAC;IAdD,8BAcC","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"]}
|
@@ -1,10 +1,7 @@
|
|
1
|
-
define(["require", "exports", "tslib", "./elementContains", "./
|
1
|
+
define(["require", "exports", "tslib", "./elementContains", "./setVirtualParent"], function (require, exports, tslib_1, elementContains_1, setVirtualParent_1) {
|
2
2
|
"use strict";
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4
4
|
tslib_1.__exportStar(elementContains_1, exports);
|
5
|
-
tslib_1.__exportStar(getParent_1, exports);
|
6
|
-
tslib_1.__exportStar(getVirtualParent_1, exports);
|
7
|
-
tslib_1.__exportStar(isVirtualElement_1, exports);
|
8
5
|
tslib_1.__exportStar(setVirtualParent_1, exports);
|
9
6
|
});
|
10
7
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/index.ts"],"names":[],"mappings":";;;IAAA,iDAAkC;IAClC,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/index.ts"],"names":[],"mappings":";;;IAAA,iDAAkC;IAClC,kDAAmC","sourcesContent":["export * from './elementContains';\nexport * from './setVirtualParent';\n"]}
|
@@ -16,7 +16,7 @@ define(["require", "exports"], function (require, exports) {
|
|
16
16
|
if (!virtualChild._virtual) {
|
17
17
|
virtualChild._virtual = {};
|
18
18
|
}
|
19
|
-
virtualChild._virtual.parent = parent
|
19
|
+
virtualChild._virtual.parent = parent;
|
20
20
|
}
|
21
21
|
exports.setVirtualParent = setVirtualParent;
|
22
22
|
});
|
@@ -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,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,
|
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,CAAC;IACxC,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;\n}\n"]}
|
@@ -32,6 +32,11 @@ const usePortal_unstable = props => {
|
|
32
32
|
if (state.virtualParentRootRef.current && state.mountNode) {
|
33
33
|
index_1.setVirtualParent(state.mountNode, state.virtualParentRootRef.current);
|
34
34
|
}
|
35
|
+
return () => {
|
36
|
+
if (state.mountNode) {
|
37
|
+
index_1.setVirtualParent(state.mountNode, undefined);
|
38
|
+
}
|
39
|
+
};
|
35
40
|
}, [state.virtualParentRootRef, state.mountNode]);
|
36
41
|
return state;
|
37
42
|
};
|
@@ -1 +1 @@
|
|
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;;
|
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;;IAEvE,OAAO,MAAK;MACV,IAAIF,KAAK,CAACP,SAAS,EAAE;QACnBU,wBAAgB,CAACH,KAAK,CAACP,SAAS,EAAEW,SAAS,CAAC;;IAEhD,CAAC;EACH,CAAC,EAAE,CAACJ,KAAK,CAACN,oBAAoB,EAAEM,KAAK,CAACP,SAAS,CAAC,CAAC;EAEjD,OAAOO,KAAK;AACd,CAAC;AAxBYK,0BAAkB","names":["usePortal_unstable","props","children","mountNode","virtualParentRootRef","React","useRef","fallbackMountNode","usePortalMountNode_1","disabled","state","useEffect","current","index_1","undefined","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 return () => {\n if (state.mountNode) {\n setVirtualParent(state.mountNode, undefined);\n }\n };\n }, [state.virtualParentRootRef, state.mountNode]);\n\n return state;\n};\n"]}
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.elementContains = void 0;
|
7
7
|
const getParent_1 = /*#__PURE__*/require("./getParent");
|
8
8
|
/**
|
9
|
-
* Similar functionality to `element.contains` DOM API for use
|
9
|
+
* Similar functionality to `element.contains` DOM API for use without of order DOM elements that
|
10
10
|
* checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent
|
11
11
|
*
|
12
12
|
* @returns true if the child can find the parent in its virtual hierarchy
|
@@ -18,8 +18,13 @@ function elementContains(parent, child) {
|
|
18
18
|
if (parent === child) {
|
19
19
|
return true;
|
20
20
|
} else {
|
21
|
+
// Tracks references of nodes that have been visited to prevent infinite loops
|
22
|
+
const set = new WeakSet();
|
21
23
|
while (child) {
|
22
|
-
const nextParent = getParent_1.getParent(child
|
24
|
+
const nextParent = getParent_1.getParent(child, {
|
25
|
+
skipVirtual: set.has(child)
|
26
|
+
});
|
27
|
+
set.add(child);
|
23
28
|
if (nextParent === parent) {
|
24
29
|
return true;
|
25
30
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"mappings":";;;;;;AAAA;
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AAEA;;;;;;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;IACA,MAAMC,GAAG,GAAG,IAAIC,OAAO,EAAQ;IAE/B,OAAOF,KAAK,EAAE;MACZ,MAAMG,UAAU,GAAgBC,qBAAS,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","names":["elementContains","parent","child","set","WeakSet","nextParent","getParent_1","skipVirtual","has","add","exports"],"sourceRoot":"../src/","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"]}
|
@@ -4,14 +4,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.getParent = void 0;
|
7
|
-
const
|
7
|
+
const isVirtualElement_1 = /*#__PURE__*/require("./isVirtualElement");
|
8
|
+
/**
|
9
|
+
* Gets the virtual parent given the child element, if it exists.
|
10
|
+
*/
|
11
|
+
function getVirtualParent(child) {
|
12
|
+
return isVirtualElement_1.isVirtualElement(child) ? child._virtual.parent || null : null;
|
13
|
+
}
|
8
14
|
/**
|
9
15
|
* Gets the element which is the parent of a given element.
|
10
16
|
* This method prefers the virtual parent over real DOM parent when present.
|
11
17
|
*/
|
12
|
-
function getParent(child) {
|
13
|
-
|
14
|
-
|
18
|
+
function getParent(child, options = {}) {
|
19
|
+
if (!child) {
|
20
|
+
return null;
|
21
|
+
}
|
22
|
+
if (!options.skipVirtual) {
|
23
|
+
const virtualParent = getVirtualParent(child);
|
24
|
+
if (virtualParent) {
|
25
|
+
return virtualParent;
|
26
|
+
}
|
27
|
+
}
|
28
|
+
return (child === null || child === void 0 ? void 0 : child.parentNode) || null;
|
15
29
|
}
|
16
30
|
exports.getParent = getParent;
|
17
31
|
//# sourceMappingURL=getParent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"mappings":";;;;;;AAAA;AAEA;;;;AAIA,
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AASA;;;AAGA,SAASA,gBAAgB,CAACC,KAAW;EACnC,OAAOC,mCAAgB,CAACD,KAAK,CAAC,GAAGA,KAAK,CAACE,QAAQ,CAACC,MAAM,IAAI,IAAI,GAAG,IAAI;AACvE;AAEA;;;;AAIA,SAAgBC,SAAS,CAACJ,KAAkB,EAAEK,UAA4B,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,MAAK,aAALP,KAAK,uBAALA,KAAK,CAAEQ,UAAU,KAAI,IAAI;AAClC;AAdAC","names":["getVirtualParent","child","isVirtualElement_1","_virtual","parent","getParent","options","skipVirtual","virtualParent","parentNode","exports"],"sourceRoot":"../src/","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"]}
|
@@ -5,8 +5,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
const tslib_1 = /*#__PURE__*/require("tslib");
|
7
7
|
tslib_1.__exportStar(require("./elementContains"), exports);
|
8
|
-
tslib_1.__exportStar(require("./getParent"), exports);
|
9
|
-
tslib_1.__exportStar(require("./getVirtualParent"), exports);
|
10
|
-
tslib_1.__exportStar(require("./isVirtualElement"), exports);
|
11
8
|
tslib_1.__exportStar(require("./setVirtualParent"), exports);
|
12
9
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"mappings":";;;;;;AAAAA;AACAA
|
1
|
+
{"version":3,"mappings":";;;;;;AAAAA;AACAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/virtualParent/index.ts"],"sourcesContent":["export * from './elementContains';\nexport * from './setVirtualParent';\n"]}
|
@@ -18,7 +18,7 @@ function setVirtualParent(child, parent) {
|
|
18
18
|
if (!virtualChild._virtual) {
|
19
19
|
virtualChild._virtual = {};
|
20
20
|
}
|
21
|
-
virtualChild._virtual.parent = parent
|
21
|
+
virtualChild._virtual.parent = parent;
|
22
22
|
}
|
23
23
|
exports.setVirtualParent = setVirtualParent;
|
24
24
|
//# sourceMappingURL=setVirtualParent.js.map
|
@@ -1 +1 @@
|
|
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
|
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;AACvC;AAZAG","names":["setVirtualParent","child","parent","virtualChild","_virtual","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;\n}\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-portal",
|
3
|
-
"version": "9.1.
|
3
|
+
"version": "9.1.4",
|
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",
|
@@ -31,9 +31,9 @@
|
|
31
31
|
"@fluentui/scripts-tasks": "*"
|
32
32
|
},
|
33
33
|
"dependencies": {
|
34
|
-
"@fluentui/react-shared-contexts": "^9.
|
35
|
-
"@fluentui/react-tabster": "^9.4.
|
36
|
-
"@fluentui/react-utilities": "^9.
|
34
|
+
"@fluentui/react-shared-contexts": "^9.2.0",
|
35
|
+
"@fluentui/react-tabster": "^9.4.1",
|
36
|
+
"@fluentui/react-utilities": "^9.5.0",
|
37
37
|
"@griffel/react": "^1.5.2",
|
38
38
|
"tslib": "^2.1.0",
|
39
39
|
"use-disposable": "^1.0.1"
|
@@ -1,8 +0,0 @@
|
|
1
|
-
import { isVirtualElement } from './isVirtualElement';
|
2
|
-
/**
|
3
|
-
* Gets the virtual parent given the child element, if it exists.
|
4
|
-
*/
|
5
|
-
export function getVirtualParent(child) {
|
6
|
-
return isVirtualElement(child) ? child._virtual.parent : undefined;
|
7
|
-
}
|
8
|
-
//# sourceMappingURL=getVirtualParent.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"mappings":"AAAA,SAASA,gBAAgB,QAAQ,oBAAoB;AACrD;;;AAGA,OAAM,SAAUC,gBAAgB,CAACC,KAAW;EAC1C,OAAOF,gBAAgB,CAACE,KAAK,CAAC,GAAGA,KAAK,CAACC,QAAQ,CAACC,MAAM,GAAGC,SAAS;AACpE","names":["isVirtualElement","getVirtualParent","child","_virtual","parent","undefined"],"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"]}
|
@@ -1,13 +0,0 @@
|
|
1
|
-
define(["require", "exports", "./isVirtualElement"], function (require, exports, isVirtualElement_1) {
|
2
|
-
"use strict";
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
exports.getVirtualParent = void 0;
|
5
|
-
/**
|
6
|
-
* Gets the virtual parent given the child element, if it exists.
|
7
|
-
*/
|
8
|
-
function getVirtualParent(child) {
|
9
|
-
return isVirtualElement_1.isVirtualElement(child) ? child._virtual.parent : undefined;
|
10
|
-
}
|
11
|
-
exports.getVirtualParent = getVirtualParent;
|
12
|
-
});
|
13
|
-
//# sourceMappingURL=getVirtualParent.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"getVirtualParent.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/getVirtualParent.ts"],"names":[],"mappings":";;;;IACA;;OAEG;IACH,SAAgB,gBAAgB,CAAC,KAAW;QAC1C,OAAO,mCAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IACrE,CAAC;IAFD,4CAEC","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"]}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.getVirtualParent = void 0;
|
7
|
-
const isVirtualElement_1 = /*#__PURE__*/require("./isVirtualElement");
|
8
|
-
/**
|
9
|
-
* Gets the virtual parent given the child element, if it exists.
|
10
|
-
*/
|
11
|
-
function getVirtualParent(child) {
|
12
|
-
return isVirtualElement_1.isVirtualElement(child) ? child._virtual.parent : undefined;
|
13
|
-
}
|
14
|
-
exports.getVirtualParent = getVirtualParent;
|
15
|
-
//# sourceMappingURL=getVirtualParent.js.map
|
@@ -1 +0,0 @@
|
|
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"]}
|