@fluentui/react-portal 9.3.22 → 9.3.23
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +28 -1
- package/CHANGELOG.md +13 -2
- package/dist/index.d.ts +4 -14
- package/lib/components/Portal/usePortal.js +1 -2
- package/lib/components/Portal/usePortal.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib-commonjs/components/Portal/usePortal.js +2 -3
- package/lib-commonjs/components/Portal/usePortal.js.map +1 -1
- package/lib-commonjs/index.js +7 -7
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +3 -3
- package/lib/virtualParent/elementContains.js +0 -28
- package/lib/virtualParent/elementContains.js.map +0 -1
- package/lib/virtualParent/getParent.js +0 -21
- package/lib/virtualParent/getParent.js.map +0 -1
- package/lib/virtualParent/index.js +0 -2
- package/lib/virtualParent/index.js.map +0 -1
- package/lib/virtualParent/isVirtualElement.js +0 -5
- package/lib/virtualParent/isVirtualElement.js.map +0 -1
- package/lib/virtualParent/setVirtualParent.js +0 -15
- package/lib/virtualParent/setVirtualParent.js.map +0 -1
- package/lib/virtualParent/types.js +0 -1
- package/lib/virtualParent/types.js.map +0 -1
- package/lib-commonjs/virtualParent/elementContains.js +0 -33
- package/lib-commonjs/virtualParent/elementContains.js.map +0 -1
- package/lib-commonjs/virtualParent/getParent.js +0 -28
- package/lib-commonjs/virtualParent/getParent.js.map +0 -1
- package/lib-commonjs/virtualParent/index.js +0 -7
- package/lib-commonjs/virtualParent/index.js.map +0 -1
- package/lib-commonjs/virtualParent/isVirtualElement.js +0 -15
- package/lib-commonjs/virtualParent/isVirtualElement.js.map +0 -1
- package/lib-commonjs/virtualParent/setVirtualParent.js +0 -25
- package/lib-commonjs/virtualParent/setVirtualParent.js.map +0 -1
- package/lib-commonjs/virtualParent/types.js +0 -4
- package/lib-commonjs/virtualParent/types.js.map +0 -1
package/CHANGELOG.json
CHANGED
@@ -2,7 +2,34 @@
|
|
2
2
|
"name": "@fluentui/react-portal",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
5
|
+
"date": "Wed, 11 Oct 2023 13:50:05 GMT",
|
6
|
+
"tag": "@fluentui/react-portal_v9.3.23",
|
7
|
+
"version": "9.3.23",
|
8
|
+
"comments": {
|
9
|
+
"patch": [
|
10
|
+
{
|
11
|
+
"author": "lingfan.gao@microsoft.com",
|
12
|
+
"package": "@fluentui/react-portal",
|
13
|
+
"commit": "97c3bc01d08b40f2fd0291fa193d95a621c9bdb8",
|
14
|
+
"comment": "refactor: consume virtual parent utilities from @fluentui/react-utilities"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"author": "beachball",
|
18
|
+
"package": "@fluentui/react-portal",
|
19
|
+
"comment": "Bump @fluentui/react-tabster to v9.13.6",
|
20
|
+
"commit": "b4466a0b9d3568e8e1ee1d814db5c8449dfd65b8"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"author": "beachball",
|
24
|
+
"package": "@fluentui/react-portal",
|
25
|
+
"comment": "Bump @fluentui/react-utilities to v9.15.0",
|
26
|
+
"commit": "b4466a0b9d3568e8e1ee1d814db5c8449dfd65b8"
|
27
|
+
}
|
28
|
+
]
|
29
|
+
}
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"date": "Mon, 09 Oct 2023 20:45:44 GMT",
|
6
33
|
"tag": "@fluentui/react-portal_v9.3.22",
|
7
34
|
"version": "9.3.22",
|
8
35
|
"comments": {
|
package/CHANGELOG.md
CHANGED
@@ -1,12 +1,23 @@
|
|
1
1
|
# Change Log - @fluentui/react-portal
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Wed, 11 Oct 2023 13:50:05 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
+
## [9.3.23](https://github.com/microsoft/fluentui/tree/@fluentui/react-portal_v9.3.23)
|
8
|
+
|
9
|
+
Wed, 11 Oct 2023 13:50:05 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-portal_v9.3.22..@fluentui/react-portal_v9.3.23)
|
11
|
+
|
12
|
+
### Patches
|
13
|
+
|
14
|
+
- refactor: consume virtual parent utilities from @fluentui/react-utilities ([PR #29286](https://github.com/microsoft/fluentui/pull/29286) by lingfan.gao@microsoft.com)
|
15
|
+
- Bump @fluentui/react-tabster to v9.13.6 ([PR #29262](https://github.com/microsoft/fluentui/pull/29262) by beachball)
|
16
|
+
- Bump @fluentui/react-utilities to v9.15.0 ([PR #29262](https://github.com/microsoft/fluentui/pull/29262) by beachball)
|
17
|
+
|
7
18
|
## [9.3.22](https://github.com/microsoft/fluentui/tree/@fluentui/react-portal_v9.3.22)
|
8
19
|
|
9
|
-
Mon, 09 Oct 2023 20:
|
20
|
+
Mon, 09 Oct 2023 20:45:44 GMT
|
10
21
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-portal_v9.3.21..@fluentui/react-portal_v9.3.22)
|
11
22
|
|
12
23
|
### Patches
|
package/dist/index.d.ts
CHANGED
@@ -1,12 +1,8 @@
|
|
1
|
+
import { elementContains } from '@fluentui/react-utilities';
|
1
2
|
import * as React_2 from 'react';
|
3
|
+
import { setVirtualParent } from '@fluentui/react-utilities';
|
2
4
|
|
3
|
-
|
4
|
-
* Similar functionality to `element.contains` DOM API for use without of order DOM elements that
|
5
|
-
* checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent
|
6
|
-
*
|
7
|
-
* @returns true if the child can find the parent in its virtual hierarchy
|
8
|
-
*/
|
9
|
-
export declare function elementContains(parent: Node | null, child: Node | null): boolean;
|
5
|
+
export { elementContains }
|
10
6
|
|
11
7
|
/**
|
12
8
|
* A portal provides a way to render children into a DOM node
|
@@ -43,13 +39,7 @@ export declare type PortalState = Pick<PortalProps, 'children'> & {
|
|
43
39
|
*/
|
44
40
|
export declare const renderPortal_unstable: (state: PortalState) => React_2.ReactElement;
|
45
41
|
|
46
|
-
|
47
|
-
* Sets the virtual parent of an element.
|
48
|
-
*
|
49
|
-
* @param child - Theme element to set the virtual parent
|
50
|
-
* @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship
|
51
|
-
*/
|
52
|
-
export declare function setVirtualParent(child: Node, parent?: Node): void;
|
42
|
+
export { setVirtualParent }
|
53
43
|
|
54
44
|
/**
|
55
45
|
* Create the state required to render Portal.
|
@@ -1,6 +1,5 @@
|
|
1
|
-
import { isHTMLElement } from '@fluentui/react-utilities';
|
1
|
+
import { isHTMLElement, setVirtualParent } from '@fluentui/react-utilities';
|
2
2
|
import * as React from 'react';
|
3
|
-
import { setVirtualParent } from '../../virtualParent/index';
|
4
3
|
import { usePortalMountNode } from './usePortalMountNode';
|
5
4
|
export function toMountNodeProps(mountNode) {
|
6
5
|
if (isHTMLElement(mountNode)) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["usePortal.ts"],"sourcesContent":["import { isHTMLElement } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport {
|
1
|
+
{"version":3,"sources":["usePortal.ts"],"sourcesContent":["import { isHTMLElement, setVirtualParent } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\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"],"names":["isHTMLElement","setVirtualParent","React","usePortalMountNode","toMountNodeProps","mountNode","element","usePortal_unstable","props","className","virtualParentRootRef","useRef","fallbackElement","disabled","state","children","useEffect","current","undefined"],"mappings":"AAAA,SAASA,aAAa,EAAEC,gBAAgB,QAAQ,4BAA4B;AAC5E,YAAYC,WAAW,QAAQ;AAE/B,SAASC,kBAAkB,QAAQ,uBAAuB;AAG1D,OAAO,SAASC,iBAAiBC,SAAmC;IAIlE,IAAIL,cAAcK,YAAY;QAC5B,OAAO;YAAEC,SAASD;QAAU;IAC9B;IAEA,IAAI,OAAOA,cAAc,UAAU;QACjC,IAAIA,cAAc,MAAM;YACtB,OAAO;gBAAEC,SAAS;YAAK;QACzB;QAEA,OAAOD;IACT;IAEA,OAAO,CAAC;AACV;AAEA;;;;;;CAMC,GACD,OAAO,MAAME,qBAAqB,CAACC;IACjC,MAAM,EAAEF,OAAO,EAAEG,SAAS,EAAE,GAAGL,iBAAiBI,MAAMH,SAAS;IAE/D,MAAMK,uBAAuBR,MAAMS,MAAM,CAAkB;IAC3D,MAAMC,kBAAkBT,mBAAmB;QAAEU,UAAU,CAAC,CAACP;QAASG;IAAU;IAE5E,MAAMK,QAAqB;QACzBC,UAAUP,MAAMO,QAAQ;QACxBV,WAAWC,oBAAAA,qBAAAA,UAAWM;QACtBF;IACF;IAEAR,MAAMc,SAAS,CAAC;QACd,IAAIF,MAAMJ,oBAAoB,CAACO,OAAO,IAAIH,MAAMT,SAAS,EAAE;YACzDJ,iBAAiBa,MAAMT,SAAS,EAAES,MAAMJ,oBAAoB,CAACO,OAAO;QACtE;QACA,OAAO;YACL,IAAIH,MAAMT,SAAS,EAAE;gBACnBJ,iBAAiBa,MAAMT,SAAS,EAAEa;YACpC;QACF;IACF,GAAG;QAACJ,MAAMJ,oBAAoB;QAAEI,MAAMT,SAAS;KAAC;IAEhD,OAAOS;AACT,EAAE"}
|
package/lib/index.js
CHANGED
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export {
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export { elementContains, setVirtualParent } from '@fluentui/react-utilities';\nexport { Portal, renderPortal_unstable, usePortal_unstable } from './components/Portal/index';\nexport type { PortalProps, PortalState } from './components/Portal/index';\n"],"names":["elementContains","setVirtualParent","Portal","renderPortal_unstable","usePortal_unstable"],"mappings":"AAAA,SAASA,eAAe,EAAEC,gBAAgB,QAAQ,4BAA4B;AAC9E,SAASC,MAAM,EAAEC,qBAAqB,EAAEC,kBAAkB,QAAQ,4BAA4B"}
|
@@ -19,7 +19,6 @@ _export(exports, {
|
|
19
19
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
20
20
|
const _reactutilities = require("@fluentui/react-utilities");
|
21
21
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
22
|
-
const _index = require("../../virtualParent/index");
|
23
22
|
const _usePortalMountNode = require("./usePortalMountNode");
|
24
23
|
function toMountNodeProps(mountNode) {
|
25
24
|
if ((0, _reactutilities.isHTMLElement)(mountNode)) {
|
@@ -51,11 +50,11 @@ const usePortal_unstable = (props)=>{
|
|
51
50
|
};
|
52
51
|
_react.useEffect(()=>{
|
53
52
|
if (state.virtualParentRootRef.current && state.mountNode) {
|
54
|
-
(0,
|
53
|
+
(0, _reactutilities.setVirtualParent)(state.mountNode, state.virtualParentRootRef.current);
|
55
54
|
}
|
56
55
|
return ()=>{
|
57
56
|
if (state.mountNode) {
|
58
|
-
(0,
|
57
|
+
(0, _reactutilities.setVirtualParent)(state.mountNode, undefined);
|
59
58
|
}
|
60
59
|
};
|
61
60
|
}, [
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["usePortal.js"],"sourcesContent":["import { isHTMLElement } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport {
|
1
|
+
{"version":3,"sources":["usePortal.js"],"sourcesContent":["import { isHTMLElement, setVirtualParent } from '@fluentui/react-utilities';\nimport * as React from 'react';\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 */ export const usePortal_unstable = (props)=>{\n const { element, className } = 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 }, [\n state.virtualParentRootRef,\n state.mountNode\n ]);\n return state;\n};\n"],"names":["toMountNodeProps","usePortal_unstable","mountNode","isHTMLElement","element","props","className","virtualParentRootRef","React","useRef","fallbackElement","usePortalMountNode","disabled","state","children","useEffect","current","setVirtualParent","undefined"],"mappings":";;;;;;;;;;;IAGgBA,gBAAgB;eAAhBA;;IAsBCC,kBAAkB;eAAlBA;;;;gCAzB+B;iEACzB;oCACY;AAC5B,SAASD,iBAAiBE,SAAS;IACtC,IAAIC,IAAAA,6BAAa,EAACD,YAAY;QAC1B,OAAO;YACHE,SAASF;QACb;IACJ;IACA,IAAI,OAAOA,cAAc,UAAU;QAC/B,IAAIA,cAAc,MAAM;YACpB,OAAO;gBACHE,SAAS;YACb;QACJ;QACA,OAAOF;IACX;IACA,OAAO,CAAC;AACZ;AAOW,MAAMD,qBAAqB,CAACI;IACnC,MAAM,EAAED,OAAO,EAAEE,SAAS,EAAE,GAAGN,iBAAiBK,MAAMH,SAAS;IAC/D,MAAMK,uBAAuBC,OAAMC,MAAM,CAAC;IAC1C,MAAMC,kBAAkBC,IAAAA,sCAAkB,EAAC;QACvCC,UAAU,CAAC,CAACR;QACZE;IACJ;IACA,MAAMO,QAAQ;QACVC,UAAUT,MAAMS,QAAQ;QACxBZ,WAAWE,YAAY,QAAQA,YAAY,KAAK,IAAIA,UAAUM;QAC9DH;IACJ;IACAC,OAAMO,SAAS,CAAC;QACZ,IAAIF,MAAMN,oBAAoB,CAACS,OAAO,IAAIH,MAAMX,SAAS,EAAE;YACvDe,IAAAA,gCAAgB,EAACJ,MAAMX,SAAS,EAAEW,MAAMN,oBAAoB,CAACS,OAAO;QACxE;QACA,OAAO;YACH,IAAIH,MAAMX,SAAS,EAAE;gBACjBe,IAAAA,gCAAgB,EAACJ,MAAMX,SAAS,EAAEgB;YACtC;QACJ;IACJ,GAAG;QACCL,MAAMN,oBAAoB;QAC1BM,MAAMX,SAAS;KAClB;IACD,OAAOW;AACX"}
|
package/lib-commonjs/index.js
CHANGED
@@ -9,6 +9,12 @@ function _export(target, all) {
|
|
9
9
|
});
|
10
10
|
}
|
11
11
|
_export(exports, {
|
12
|
+
elementContains: function() {
|
13
|
+
return _reactutilities.elementContains;
|
14
|
+
},
|
15
|
+
setVirtualParent: function() {
|
16
|
+
return _reactutilities.setVirtualParent;
|
17
|
+
},
|
12
18
|
Portal: function() {
|
13
19
|
return _index.Portal;
|
14
20
|
},
|
@@ -17,13 +23,7 @@ _export(exports, {
|
|
17
23
|
},
|
18
24
|
usePortal_unstable: function() {
|
19
25
|
return _index.usePortal_unstable;
|
20
|
-
},
|
21
|
-
elementContains: function() {
|
22
|
-
return _index1.elementContains;
|
23
|
-
},
|
24
|
-
setVirtualParent: function() {
|
25
|
-
return _index1.setVirtualParent;
|
26
26
|
}
|
27
27
|
});
|
28
|
+
const _reactutilities = require("@fluentui/react-utilities");
|
28
29
|
const _index = require("./components/Portal/index");
|
29
|
-
const _index1 = require("./virtualParent/index");
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.js"],"sourcesContent":["export {
|
1
|
+
{"version":3,"sources":["index.js"],"sourcesContent":["export { elementContains, setVirtualParent } from '@fluentui/react-utilities';\nexport { Portal, renderPortal_unstable, usePortal_unstable } from './components/Portal/index';\n"],"names":["elementContains","setVirtualParent","Portal","renderPortal_unstable","usePortal_unstable"],"mappings":";;;;;;;;;;;IAASA,eAAe;eAAfA,+BAAe;;IAAEC,gBAAgB;eAAhBA,gCAAgB;;IACjCC,MAAM;eAANA,aAAM;;IAAEC,qBAAqB;eAArBA,4BAAqB;;IAAEC,kBAAkB;eAAlBA,yBAAkB;;;gCADR;uBACgB"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-portal",
|
3
|
-
"version": "9.3.
|
3
|
+
"version": "9.3.23",
|
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",
|
@@ -33,8 +33,8 @@
|
|
33
33
|
},
|
34
34
|
"dependencies": {
|
35
35
|
"@fluentui/react-shared-contexts": "^9.10.0",
|
36
|
-
"@fluentui/react-tabster": "^9.13.
|
37
|
-
"@fluentui/react-utilities": "^9.
|
36
|
+
"@fluentui/react-tabster": "^9.13.6",
|
37
|
+
"@fluentui/react-utilities": "^9.15.0",
|
38
38
|
"@griffel/react": "^1.5.14",
|
39
39
|
"@swc/helpers": "^0.5.1",
|
40
40
|
"use-disposable": "^1.0.1"
|
@@ -1,28 +0,0 @@
|
|
1
|
-
import { getParent } from './getParent';
|
2
|
-
/**
|
3
|
-
* Similar functionality to `element.contains` DOM API for use without of order DOM elements that
|
4
|
-
* checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent
|
5
|
-
*
|
6
|
-
* @returns true if the child can find the parent in its virtual hierarchy
|
7
|
-
*/ export function elementContains(parent, child) {
|
8
|
-
if (!parent || !child) {
|
9
|
-
return false;
|
10
|
-
}
|
11
|
-
if (parent === child) {
|
12
|
-
return true;
|
13
|
-
} else {
|
14
|
-
// Tracks references of nodes that have been visited to prevent infinite loops
|
15
|
-
const set = new WeakSet();
|
16
|
-
while(child){
|
17
|
-
const nextParent = getParent(child, {
|
18
|
-
skipVirtual: set.has(child)
|
19
|
-
});
|
20
|
-
set.add(child);
|
21
|
-
if (nextParent === parent) {
|
22
|
-
return true;
|
23
|
-
}
|
24
|
-
child = nextParent;
|
25
|
-
}
|
26
|
-
}
|
27
|
-
return false;
|
28
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["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"],"names":["getParent","elementContains","parent","child","set","WeakSet","nextParent","skipVirtual","has","add"],"mappings":"AAAA,SAASA,SAAS,QAAQ,cAAc;AAExC;;;;;CAKC,GACD,OAAO,SAASC,gBAAgBC,MAAmB,EAAEC,KAAkB;IACrE,IAAI,CAACD,UAAU,CAACC,OAAO;QACrB,OAAO;IACT;IAEA,IAAID,WAAWC,OAAO;QACpB,OAAO;IACT,OAAO;QACL,8EAA8E;QAC9E,MAAMC,MAAM,IAAIC;QAEhB,MAAOF,MAAO;YACZ,MAAMG,aAA0BN,UAAUG,OAAO;gBAC/CI,aAAaH,IAAII,GAAG,CAACL;YACvB;YACAC,IAAIK,GAAG,CAACN;YAER,IAAIG,eAAeJ,QAAQ;gBACzB,OAAO;YACT;YAEAC,QAAQG;QACV;IACF;IAEA,OAAO;AACT"}
|
@@ -1,21 +0,0 @@
|
|
1
|
-
import { isVirtualElement } from './isVirtualElement';
|
2
|
-
/**
|
3
|
-
* Gets the virtual parent given the child element, if it exists.
|
4
|
-
*/ function getVirtualParent(child) {
|
5
|
-
return isVirtualElement(child) ? child._virtual.parent || null : null;
|
6
|
-
}
|
7
|
-
/**
|
8
|
-
* Gets the element which is the parent of a given element.
|
9
|
-
* This method prefers the virtual parent over real DOM parent when present.
|
10
|
-
*/ export function getParent(child, options = {}) {
|
11
|
-
if (!child) {
|
12
|
-
return null;
|
13
|
-
}
|
14
|
-
if (!options.skipVirtual) {
|
15
|
-
const virtualParent = getVirtualParent(child);
|
16
|
-
if (virtualParent) {
|
17
|
-
return virtualParent;
|
18
|
-
}
|
19
|
-
}
|
20
|
-
return (child === null || child === void 0 ? void 0 : child.parentNode) || null;
|
21
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["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"],"names":["isVirtualElement","getVirtualParent","child","_virtual","parent","getParent","options","skipVirtual","virtualParent","parentNode"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,qBAAqB;AAStD;;CAEC,GACD,SAASC,iBAAiBC,KAAW;IACnC,OAAOF,iBAAiBE,SAASA,MAAMC,QAAQ,CAACC,MAAM,IAAI,OAAO;AACnE;AAEA;;;CAGC,GACD,OAAO,SAASC,UAAUH,KAAkB,EAAEI,UAA4B,CAAC,CAAC;IAC1E,IAAI,CAACJ,OAAO;QACV,OAAO;IACT;IAEA,IAAI,CAACI,QAAQC,WAAW,EAAE;QACxB,MAAMC,gBAAgBP,iBAAiBC;QAEvC,IAAIM,eAAe;YACjB,OAAOA;QACT;IACF;IAEA,OAAON,CAAAA,kBAAAA,4BAAAA,MAAOO,UAAU,KAAI;AAC9B"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './elementContains';\nexport * from './setVirtualParent';\n"],"names":[],"mappings":"AAAA,cAAc,oBAAoB;AAClC,cAAc,qBAAqB"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["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"],"names":["isVirtualElement","element","_virtual"],"mappings":"AAEA;;CAEC,GACD,OAAO,SAASA,iBAAiBC,OAA8B;IAC7D,OAAOA,WAAW,CAAC,CAAC,AAAiBA,QAASC,QAAQ;AACxD"}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Sets the virtual parent of an element.
|
3
|
-
*
|
4
|
-
* @param child - Theme element to set the virtual parent
|
5
|
-
* @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship
|
6
|
-
*/ export function setVirtualParent(child, parent) {
|
7
|
-
if (!child) {
|
8
|
-
return;
|
9
|
-
}
|
10
|
-
const virtualChild = child;
|
11
|
-
if (!virtualChild._virtual) {
|
12
|
-
virtualChild._virtual = {};
|
13
|
-
}
|
14
|
-
virtualChild._virtual.parent = parent;
|
15
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["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"],"names":["setVirtualParent","child","parent","virtualChild","_virtual"],"mappings":"AAEA;;;;;CAKC,GACD,OAAO,SAASA,iBAAiBC,KAAW,EAAEC,MAAa;IACzD,IAAI,CAACD,OAAO;QACV;IACF;IAEA,MAAME,eAAeF;IAErB,IAAI,CAACE,aAAaC,QAAQ,EAAE;QAC1BD,aAAaC,QAAQ,GAAG,CAAC;IAC3B;IAEAD,aAAaC,QAAQ,CAACF,MAAM,GAAGA;AACjC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
export { };
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["types.ts"],"sourcesContent":["export interface VirtualElement extends Node {\n _virtual: {\n parent?: Node;\n };\n}\n"],"names":[],"mappings":"AAAA,WAIC"}
|
@@ -1,33 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
3
|
-
value: true
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "elementContains", {
|
6
|
-
enumerable: true,
|
7
|
-
get: function() {
|
8
|
-
return elementContains;
|
9
|
-
}
|
10
|
-
});
|
11
|
-
const _getParent = require("./getParent");
|
12
|
-
function elementContains(parent, child) {
|
13
|
-
if (!parent || !child) {
|
14
|
-
return false;
|
15
|
-
}
|
16
|
-
if (parent === child) {
|
17
|
-
return true;
|
18
|
-
} else {
|
19
|
-
// Tracks references of nodes that have been visited to prevent infinite loops
|
20
|
-
const set = new WeakSet();
|
21
|
-
while(child){
|
22
|
-
const nextParent = (0, _getParent.getParent)(child, {
|
23
|
-
skipVirtual: set.has(child)
|
24
|
-
});
|
25
|
-
set.add(child);
|
26
|
-
if (nextParent === parent) {
|
27
|
-
return true;
|
28
|
-
}
|
29
|
-
child = nextParent;
|
30
|
-
}
|
31
|
-
}
|
32
|
-
return false;
|
33
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["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 */ export 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"],"names":["elementContains","parent","child","set","WeakSet","nextParent","getParent","skipVirtual","has","add"],"mappings":";;;;+BAMoBA;;;eAAAA;;;2BANM;AAMf,SAASA,gBAAgBC,MAAM,EAAEC,KAAK;IAC7C,IAAI,CAACD,UAAU,CAACC,OAAO;QACnB,OAAO;IACX;IACA,IAAID,WAAWC,OAAO;QAClB,OAAO;IACX,OAAO;QACH,8EAA8E;QAC9E,MAAMC,MAAM,IAAIC;QAChB,MAAMF,MAAM;YACR,MAAMG,aAAaC,IAAAA,oBAAS,EAACJ,OAAO;gBAChCK,aAAaJ,IAAIK,GAAG,CAACN;YACzB;YACAC,IAAIM,GAAG,CAACP;YACR,IAAIG,eAAeJ,QAAQ;gBACvB,OAAO;YACX;YACAC,QAAQG;QACZ;IACJ;IACA,OAAO;AACX"}
|
@@ -1,28 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
3
|
-
value: true
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "getParent", {
|
6
|
-
enumerable: true,
|
7
|
-
get: function() {
|
8
|
-
return getParent;
|
9
|
-
}
|
10
|
-
});
|
11
|
-
const _isVirtualElement = require("./isVirtualElement");
|
12
|
-
/**
|
13
|
-
* Gets the virtual parent given the child element, if it exists.
|
14
|
-
*/ function getVirtualParent(child) {
|
15
|
-
return (0, _isVirtualElement.isVirtualElement)(child) ? child._virtual.parent || null : null;
|
16
|
-
}
|
17
|
-
function getParent(child, options = {}) {
|
18
|
-
if (!child) {
|
19
|
-
return null;
|
20
|
-
}
|
21
|
-
if (!options.skipVirtual) {
|
22
|
-
const virtualParent = getVirtualParent(child);
|
23
|
-
if (virtualParent) {
|
24
|
-
return virtualParent;
|
25
|
-
}
|
26
|
-
}
|
27
|
-
return (child === null || child === void 0 ? void 0 : child.parentNode) || null;
|
28
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["getParent.js"],"sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n/**\n * Gets the virtual parent given the child element, if it exists.\n */ function 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 */ export 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"],"names":["getParent","getVirtualParent","child","isVirtualElement","_virtual","parent","options","skipVirtual","virtualParent","parentNode"],"mappings":";;;;+BASoBA;;;eAAAA;;;kCATa;AACjC;;CAEC,GAAG,SAASC,iBAAiBC,KAAK;IAC/B,OAAOC,IAAAA,kCAAgB,EAACD,SAASA,MAAME,QAAQ,CAACC,MAAM,IAAI,OAAO;AACrE;AAIW,SAASL,UAAUE,KAAK,EAAEI,UAAU,CAAC,CAAC;IAC7C,IAAI,CAACJ,OAAO;QACR,OAAO;IACX;IACA,IAAI,CAACI,QAAQC,WAAW,EAAE;QACtB,MAAMC,gBAAgBP,iBAAiBC;QACvC,IAAIM,eAAe;YACf,OAAOA;QACX;IACJ;IACA,OAAO,AAACN,CAAAA,UAAU,QAAQA,UAAU,KAAK,IAAI,KAAK,IAAIA,MAAMO,UAAU,AAAD,KAAM;AAC/E"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["index.js"],"sourcesContent":["export * from './elementContains';\nexport * from './setVirtualParent';\n"],"names":[],"mappings":";;;;;uBAAc;uBACA"}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Determines whether or not an element has the virtual hierarchy extension.
|
3
|
-
*/ "use strict";
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
5
|
-
value: true
|
6
|
-
});
|
7
|
-
Object.defineProperty(exports, "isVirtualElement", {
|
8
|
-
enumerable: true,
|
9
|
-
get: function() {
|
10
|
-
return isVirtualElement;
|
11
|
-
}
|
12
|
-
});
|
13
|
-
function isVirtualElement(element) {
|
14
|
-
return element && !!element._virtual;
|
15
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["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"],"names":["isVirtualElement","element","_virtual"],"mappings":"AAAA;;CAEC;;;;+BAAmBA;;;eAAAA;;;AAAT,SAASA,iBAAiBC,OAAO;IACxC,OAAOA,WAAW,CAAC,CAACA,QAAQC,QAAQ;AACxC"}
|
@@ -1,25 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Sets the virtual parent of an element.
|
3
|
-
*
|
4
|
-
* @param child - Theme element to set the virtual parent
|
5
|
-
* @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship
|
6
|
-
*/ "use strict";
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
8
|
-
value: true
|
9
|
-
});
|
10
|
-
Object.defineProperty(exports, "setVirtualParent", {
|
11
|
-
enumerable: true,
|
12
|
-
get: function() {
|
13
|
-
return setVirtualParent;
|
14
|
-
}
|
15
|
-
});
|
16
|
-
function setVirtualParent(child, parent) {
|
17
|
-
if (!child) {
|
18
|
-
return;
|
19
|
-
}
|
20
|
-
const virtualChild = child;
|
21
|
-
if (!virtualChild._virtual) {
|
22
|
-
virtualChild._virtual = {};
|
23
|
-
}
|
24
|
-
virtualChild._virtual.parent = parent;
|
25
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["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"],"names":["setVirtualParent","child","parent","virtualChild","_virtual"],"mappings":"AAAA;;;;;CAKC;;;;+BAAmBA;;;eAAAA;;;AAAT,SAASA,iBAAiBC,KAAK,EAAEC,MAAM;IAC9C,IAAI,CAACD,OAAO;QACR;IACJ;IACA,MAAME,eAAeF;IACrB,IAAI,CAACE,aAAaC,QAAQ,EAAE;QACxBD,aAAaC,QAAQ,GAAG,CAAC;IAC7B;IACAD,aAAaC,QAAQ,CAACF,MAAM,GAAGA;AACnC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|