@fluentui/react-portal 9.0.14 → 9.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +75 -1
- package/CHANGELOG.md +25 -2
- package/dist/index.d.ts +2 -2
- package/lib/components/Portal/Portal.js +0 -1
- package/lib/components/Portal/Portal.js.map +1 -1
- package/lib/components/Portal/renderPortal.js +0 -1
- package/lib/components/Portal/renderPortal.js.map +1 -1
- package/lib/components/Portal/usePortal.js +0 -1
- package/lib/components/Portal/usePortal.js.map +1 -1
- package/lib/components/Portal/usePortalMountNode.js +23 -29
- package/lib/components/Portal/usePortalMountNode.js.map +1 -1
- package/lib/virtualParent/elementContains.js +0 -5
- package/lib/virtualParent/elementContains.js.map +1 -1
- package/lib/virtualParent/getParent.js +2 -2
- package/lib/virtualParent/getParent.js.map +1 -1
- package/lib/virtualParent/getVirtualParent.js +1 -8
- package/lib/virtualParent/getVirtualParent.js.map +1 -1
- package/lib/virtualParent/isVirtualElement.js.map +1 -1
- package/lib/virtualParent/setVirtualParent.js +0 -3
- package/lib/virtualParent/setVirtualParent.js.map +1 -1
- package/lib/virtualParent/types.js.map +1 -1
- package/lib-amd/components/Portal/usePortalMountNode.js +20 -21
- package/lib-amd/components/Portal/usePortalMountNode.js.map +1 -1
- package/lib-amd/virtualParent/elementContains.js.map +1 -1
- package/lib-amd/virtualParent/getParent.js +2 -1
- package/lib-amd/virtualParent/getParent.js.map +1 -1
- package/lib-amd/virtualParent/getVirtualParent.js +1 -5
- package/lib-amd/virtualParent/getVirtualParent.js.map +1 -1
- package/lib-amd/virtualParent/isVirtualElement.js.map +1 -1
- package/lib-amd/virtualParent/setVirtualParent.js.map +1 -1
- package/lib-amd/virtualParent/types.js.map +1 -1
- package/lib-commonjs/Portal.js +0 -2
- package/lib-commonjs/Portal.js.map +1 -1
- package/lib-commonjs/components/Portal/Portal.js +0 -5
- package/lib-commonjs/components/Portal/Portal.js.map +1 -1
- package/lib-commonjs/components/Portal/Portal.types.js.map +1 -1
- package/lib-commonjs/components/Portal/index.js +0 -5
- package/lib-commonjs/components/Portal/index.js.map +1 -1
- package/lib-commonjs/components/Portal/renderPortal.js +0 -5
- package/lib-commonjs/components/Portal/renderPortal.js.map +1 -1
- package/lib-commonjs/components/Portal/usePortal.js +0 -6
- package/lib-commonjs/components/Portal/usePortal.js.map +1 -1
- package/lib-commonjs/components/Portal/usePortalMountNode.js +23 -34
- package/lib-commonjs/components/Portal/usePortalMountNode.js.map +1 -1
- package/lib-commonjs/index.js +0 -4
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/virtualParent/elementContains.js +0 -8
- package/lib-commonjs/virtualParent/elementContains.js.map +1 -1
- package/lib-commonjs/virtualParent/getParent.js +2 -5
- package/lib-commonjs/virtualParent/getParent.js.map +1 -1
- package/lib-commonjs/virtualParent/getVirtualParent.js +1 -11
- package/lib-commonjs/virtualParent/getVirtualParent.js.map +1 -1
- package/lib-commonjs/virtualParent/index.js +0 -6
- package/lib-commonjs/virtualParent/index.js.map +1 -1
- package/lib-commonjs/virtualParent/isVirtualElement.js +0 -2
- package/lib-commonjs/virtualParent/isVirtualElement.js.map +1 -1
- package/lib-commonjs/virtualParent/setVirtualParent.js +0 -5
- package/lib-commonjs/virtualParent/setVirtualParent.js.map +1 -1
- package/lib-commonjs/virtualParent/types.js.map +1 -1
- package/package.json +7 -6
package/CHANGELOG.json
CHANGED
@@ -2,7 +2,81 @@
|
|
2
2
|
"name": "@fluentui/react-portal",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
5
|
+
"date": "Mon, 09 Jan 2023 14:31:46 GMT",
|
6
|
+
"tag": "@fluentui/react-portal_v9.1.0",
|
7
|
+
"version": "9.1.0",
|
8
|
+
"comments": {
|
9
|
+
"minor": [
|
10
|
+
{
|
11
|
+
"author": "email not defined",
|
12
|
+
"package": "@fluentui/react-portal",
|
13
|
+
"commit": "a62c525a002fe1eed5c40aec4c041d1f850b7beb",
|
14
|
+
"comment": "feat: elementContains supports Node types"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"author": "beachball",
|
18
|
+
"package": "@fluentui/react-portal",
|
19
|
+
"comment": "Bump @fluentui/react-tabster to v9.3.6",
|
20
|
+
"commit": "26f0364b3837056ee8e0df42a7932c298c68290e"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"author": "beachball",
|
24
|
+
"package": "@fluentui/react-portal",
|
25
|
+
"comment": "Bump @fluentui/react-utilities to v9.4.0",
|
26
|
+
"commit": "26f0364b3837056ee8e0df42a7932c298c68290e"
|
27
|
+
}
|
28
|
+
]
|
29
|
+
}
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"date": "Wed, 04 Jan 2023 01:40:17 GMT",
|
33
|
+
"tag": "@fluentui/react-portal_v9.0.15",
|
34
|
+
"version": "9.0.15",
|
35
|
+
"comments": {
|
36
|
+
"none": [
|
37
|
+
{
|
38
|
+
"author": "martinhochel@microsoft.com",
|
39
|
+
"package": "@fluentui/react-portal",
|
40
|
+
"commit": "194b0cf0cc27c1c1233aa945f09b3ad29778d8ca",
|
41
|
+
"comment": "chore(scripts): use for @fluentui/scripts version within all package.json"
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"author": "martinhochel@microsoft.com",
|
45
|
+
"package": "@fluentui/react-portal",
|
46
|
+
"commit": "4ec2b998b294d6d9c3196d3d82893bdd97d0c105",
|
47
|
+
"comment": "chore(scripts): move index.ts to to follow sub-folder domain packaging"
|
48
|
+
}
|
49
|
+
],
|
50
|
+
"patch": [
|
51
|
+
{
|
52
|
+
"author": "lingfangao@hotmail.com",
|
53
|
+
"package": "@fluentui/react-portal",
|
54
|
+
"commit": "7cfaf78c93f1408c633c612939bf1a1305d7fc76",
|
55
|
+
"comment": "fix: Portals should render correctly in strict mode"
|
56
|
+
},
|
57
|
+
{
|
58
|
+
"author": "olfedias@microsoft.com",
|
59
|
+
"package": "@fluentui/react-portal",
|
60
|
+
"commit": "2c38f1e4ae07b2b60df596efe11015a68f166dbf",
|
61
|
+
"comment": "chore: Update Griffel to latest version"
|
62
|
+
},
|
63
|
+
{
|
64
|
+
"author": "beachball",
|
65
|
+
"package": "@fluentui/react-portal",
|
66
|
+
"comment": "Bump @fluentui/react-tabster to v9.3.5",
|
67
|
+
"commit": "3e322d15529451be153e97298873253e21af4082"
|
68
|
+
},
|
69
|
+
{
|
70
|
+
"author": "beachball",
|
71
|
+
"package": "@fluentui/react-portal",
|
72
|
+
"comment": "Bump @fluentui/react-utilities to v9.3.1",
|
73
|
+
"commit": "3e322d15529451be153e97298873253e21af4082"
|
74
|
+
}
|
75
|
+
]
|
76
|
+
}
|
77
|
+
},
|
78
|
+
{
|
79
|
+
"date": "Wed, 21 Dec 2022 10:20:33 GMT",
|
6
80
|
"tag": "@fluentui/react-portal_v9.0.14",
|
7
81
|
"version": "9.0.14",
|
8
82
|
"comments": {
|
package/CHANGELOG.md
CHANGED
@@ -1,12 +1,35 @@
|
|
1
1
|
# Change Log - @fluentui/react-portal
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Mon, 09 Jan 2023 14:31:46 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
+
## [9.1.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-portal_v9.1.0)
|
8
|
+
|
9
|
+
Mon, 09 Jan 2023 14:31:46 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-portal_v9.0.15..@fluentui/react-portal_v9.1.0)
|
11
|
+
|
12
|
+
### Minor changes
|
13
|
+
|
14
|
+
- feat: elementContains supports Node types ([PR #26158](https://github.com/microsoft/fluentui/pull/26158) by email not defined)
|
15
|
+
- Bump @fluentui/react-tabster to v9.3.6 ([PR #26257](https://github.com/microsoft/fluentui/pull/26257) by beachball)
|
16
|
+
- Bump @fluentui/react-utilities to v9.4.0 ([PR #26257](https://github.com/microsoft/fluentui/pull/26257) by beachball)
|
17
|
+
|
18
|
+
## [9.0.15](https://github.com/microsoft/fluentui/tree/@fluentui/react-portal_v9.0.15)
|
19
|
+
|
20
|
+
Wed, 04 Jan 2023 01:40:17 GMT
|
21
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-portal_v9.0.14..@fluentui/react-portal_v9.0.15)
|
22
|
+
|
23
|
+
### Patches
|
24
|
+
|
25
|
+
- fix: Portals should render correctly in strict mode ([PR #25956](https://github.com/microsoft/fluentui/pull/25956) by lingfangao@hotmail.com)
|
26
|
+
- chore: Update Griffel to latest version ([PR #26045](https://github.com/microsoft/fluentui/pull/26045) by olfedias@microsoft.com)
|
27
|
+
- Bump @fluentui/react-tabster to v9.3.5 ([PR #26114](https://github.com/microsoft/fluentui/pull/26114) by beachball)
|
28
|
+
- Bump @fluentui/react-utilities to v9.3.1 ([PR #26114](https://github.com/microsoft/fluentui/pull/26114) by beachball)
|
29
|
+
|
7
30
|
## [9.0.14](https://github.com/microsoft/fluentui/tree/@fluentui/react-portal_v9.0.14)
|
8
31
|
|
9
|
-
Wed, 21 Dec 2022 10:
|
32
|
+
Wed, 21 Dec 2022 10:20:33 GMT
|
10
33
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-portal_v9.0.13..@fluentui/react-portal_v9.0.14)
|
11
34
|
|
12
35
|
### Patches
|
package/dist/index.d.ts
CHANGED
@@ -6,7 +6,7 @@ import * as React_2 from 'react';
|
|
6
6
|
*
|
7
7
|
* @returns true if the child can find the parent in its virtual hierarchy
|
8
8
|
*/
|
9
|
-
export declare function elementContains(parent:
|
9
|
+
export declare function elementContains(parent: Node | null, child: Node | null): boolean;
|
10
10
|
|
11
11
|
/**
|
12
12
|
* A portal provides a way to render children into a DOM node
|
@@ -45,7 +45,7 @@ export declare const renderPortal_unstable: (state: PortalState) => React_2.Reac
|
|
45
45
|
* @param child - Theme element to set the virtual parent
|
46
46
|
* @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship
|
47
47
|
*/
|
48
|
-
export declare function setVirtualParent(child:
|
48
|
+
export declare function setVirtualParent(child: Node, parent?: Node): void;
|
49
49
|
|
50
50
|
/**
|
51
51
|
* Create the state required to render Portal.
|
@@ -4,7 +4,6 @@ import { renderPortal_unstable } from './renderPortal';
|
|
4
4
|
* A portal provides a way to render children into a DOM node
|
5
5
|
* that exists outside the DOM hierarchy of the parent component.
|
6
6
|
*/
|
7
|
-
|
8
7
|
export const Portal = props => {
|
9
8
|
const state = usePortal_unstable(props);
|
10
9
|
return renderPortal_unstable(state);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"AAEA,SAASA,kBAAkB,QAAQ,aAAa;AAChD,SAASC,qBAAqB,QAAQ,gBAAgB;AAGtD;;;;AAIA,OAAO,MAAMC,MAAM,GAA0BC,KAAK,IAAG;EACnD,MAAMC,KAAK,GAAGJ,kBAAkB,CAACG,KAAK,CAAC;EAEvC,OAAOF,qBAAqB,CAACG,KAAK,CAAC;AACrC,CAAC;AAEDF,MAAM,CAACG,WAAW,GAAG,QAAQ","names":["usePortal_unstable","renderPortal_unstable","Portal","props","state","displayName"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/components/Portal/Portal.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { usePortal_unstable } from './usePortal';\nimport { renderPortal_unstable } from './renderPortal';\nimport type { PortalProps } from './Portal.types';\n\n/**\n * A portal provides a way to render children into a DOM node\n * that exists outside the DOM hierarchy of the parent component.\n */\nexport const Portal: React.FC<PortalProps> = props => {\n const state = usePortal_unstable(props);\n\n return renderPortal_unstable(state);\n};\n\nPortal.displayName = 'Portal';\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"AAAA,OAAO,KAAKA,QAAQ,MAAM,WAAW;AACrC,OAAO,KAAKC,KAAK,MAAM,OAAO;AAG9B;;;AAGA,OAAO,MAAMC,qBAAqB,GAAIC,KAAkB,IAAwB;EAC9E,oBACEF;IAAMG,MAAM;IAACC,GAAG,EAAEF,KAAK,CAACG;EAAoB,GACzCH,KAAK,CAACI,SAAS,iBAAIP,QAAQ,CAACQ,YAAY,CAACL,KAAK,CAACM,QAAQ,EAAEN,KAAK,CAACI,SAAS,CAAC,CACrE;AAEX,CAAC","names":["ReactDOM","React","renderPortal_unstable","state","hidden","ref","virtualParentRootRef","mountNode","createPortal","children"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/components/Portal/renderPortal.tsx"],"sourcesContent":["import * as ReactDOM from 'react-dom';\nimport * as React from 'react';\nimport type { PortalState } from './Portal.types';\n\n/**\n * Render the final JSX of Portal\n */\nexport const renderPortal_unstable = (state: PortalState): React.ReactElement => {\n return (\n <span hidden ref={state.virtualParentRootRef}>\n {state.mountNode && ReactDOM.createPortal(state.children, state.mountNode)}\n </span>\n );\n};\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
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;;EAEzE,CAAC,EAAE,CAACF,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"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/components/Portal/usePortal.ts"],"sourcesContent":["import * as React from 'react';\nimport { usePortalMountNode } from './usePortalMountNode';\nimport { setVirtualParent } from '../../virtualParent/index';\nimport type { PortalProps, PortalState } from './Portal.types';\n\n/**\n * Create the state required to render Portal.\n *\n * The returned state can be modified with hooks such as usePortalStyles, before being passed to renderPortal_unstable.\n *\n * @param props - props from this instance of Portal\n */\nexport const usePortal_unstable = (props: PortalProps): PortalState => {\n const { children, mountNode } = props;\n\n const virtualParentRootRef = React.useRef<HTMLSpanElement>(null);\n const fallbackMountNode = usePortalMountNode({ disabled: !!mountNode });\n\n const state: PortalState = {\n children,\n mountNode: mountNode ?? fallbackMountNode,\n virtualParentRootRef,\n };\n\n React.useEffect(() => {\n if (state.virtualParentRootRef.current && state.mountNode) {\n setVirtualParent(state.mountNode, state.virtualParentRootRef.current);\n }\n }, [state.virtualParentRootRef, state.mountNode]);\n\n return state;\n};\n"]}
|
@@ -2,20 +2,21 @@ import * as React from 'react';
|
|
2
2
|
import { useThemeClassName_unstable as useThemeClassName, useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
|
3
3
|
import { __styles, mergeClasses } from '@griffel/react';
|
4
4
|
import { useFocusVisible } from '@fluentui/react-tabster';
|
5
|
-
|
5
|
+
import { useDisposable } from 'use-disposable';
|
6
|
+
import { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
|
7
|
+
// String concatenation is used to prevent bundlers to complain with older versions of React
|
8
|
+
const useInsertionEffect = React['useInsertion' + 'Effect'] ? React['useInsertion' + 'Effect'] : useIsomorphicLayoutEffect;
|
6
9
|
const useStyles = /*#__PURE__*/__styles({
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
+
root: {
|
11
|
+
qhf8xq: "f10pi13n",
|
12
|
+
Bj3rh1h: "f494woh"
|
10
13
|
}
|
11
14
|
}, {
|
12
|
-
|
15
|
+
d: [".f10pi13n{position:relative;}", ".f494woh{z-index:1000000;}"]
|
13
16
|
});
|
14
17
|
/**
|
15
18
|
* Creates a new element on a document.body to mount portals
|
16
19
|
*/
|
17
|
-
|
18
|
-
|
19
20
|
export const usePortalMountNode = options => {
|
20
21
|
const {
|
21
22
|
targetDocument,
|
@@ -25,38 +26,31 @@ export const usePortalMountNode = options => {
|
|
25
26
|
const classes = useStyles();
|
26
27
|
const themeClassName = useThemeClassName();
|
27
28
|
const className = mergeClasses(themeClassName, classes.root);
|
28
|
-
const element =
|
29
|
+
const element = useDisposable(() => {
|
29
30
|
if (targetDocument === undefined || options.disabled) {
|
30
|
-
return null;
|
31
|
+
return [null, () => null];
|
31
32
|
}
|
32
|
-
|
33
33
|
const newElement = targetDocument.createElement('div');
|
34
34
|
targetDocument.body.appendChild(newElement);
|
35
|
-
return newElement;
|
36
|
-
}, [targetDocument
|
35
|
+
return [newElement, () => newElement.remove()];
|
36
|
+
}, [targetDocument]);
|
37
|
+
// This useEffect call is intentional
|
37
38
|
// We don't want to re-create the portal element when its attributes change.
|
38
39
|
// This also should not be done in an effect because, changing the value of css variables
|
39
40
|
// after initial mount can trigger interesting CSS side effects like transitions.
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
const classesToApply = className.split(' ').filter(Boolean);
|
44
|
-
element.classList.add(...classesToApply);
|
45
|
-
element.setAttribute('dir', dir);
|
46
|
-
focusVisibleRef.current = element;
|
47
|
-
return () => {
|
48
|
-
element.classList.remove(...classesToApply);
|
49
|
-
element.removeAttribute('dir');
|
50
|
-
};
|
41
|
+
useInsertionEffect(() => {
|
42
|
+
if (!element) {
|
43
|
+
return;
|
51
44
|
}
|
52
|
-
|
53
|
-
|
45
|
+
const classesToApply = className.split(' ').filter(Boolean);
|
46
|
+
element.classList.add(...classesToApply);
|
47
|
+
element.setAttribute('dir', dir);
|
48
|
+
focusVisibleRef.current = element;
|
54
49
|
return () => {
|
55
|
-
|
56
|
-
|
57
|
-
(_a = element === null || element === void 0 ? void 0 : element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(element);
|
50
|
+
element.classList.remove(...classesToApply);
|
51
|
+
element.removeAttribute('dir');
|
58
52
|
};
|
59
|
-
}, [element]);
|
53
|
+
}, [className, dir, element, focusVisibleRef]);
|
60
54
|
return element;
|
61
55
|
};
|
62
56
|
//# sourceMappingURL=usePortalMountNode.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SACEC,0BAA0B,IAAIC,iBAAiB,EAC/CC,kBAAkB,IAAIC,SAAS,QAC1B,iCAAiC;AACxC,mBAAqBC,YAAY,QAAQ,gBAAgB;AACzD,SAASC,eAAe,QAAQ,yBAAyB;AACzD,SAASC,aAAa,QAAQ,gBAAgB;AAC9C,SAASC,yBAAyB,QAAQ,2BAA2B;AAErE;AACA,MAAMC,kBAAkB,GAAIT,KAAe,CAAC,cAAc,GAAG,QAAQ,CAAC,GACjEA,KAAe,CAAC,cAAc,GAAG,QAAQ,CAAC,GAC3CQ,yBAAyB;AAS7B,MAAME,SAAS,gBAAG;EAAA;IAAA;IAAA;EAAA;AAAA;EAAA;AAAA,EAKhB;AAEF;;;AAGA,OAAO,MAAMC,kBAAkB,GAAIC,OAAkC,IAAwB;EAC3F,MAAM;IAAEC,cAAc;IAAEC;EAAG,CAAE,GAAGV,SAAS,EAAE;EAC3C,MAAMW,eAAe,GAAGT,eAAe,EAAgE;EACvG,MAAMU,OAAO,GAAGN,SAAS,EAAE;EAC3B,MAAMO,cAAc,GAAGf,iBAAiB,EAAE;EAE1C,MAAMgB,SAAS,GAAGb,YAAY,CAACY,cAAc,EAAED,OAAO,CAACG,IAAI,CAAC;EAE5D,MAAMC,OAAO,GAAGb,aAAa,CAAC,MAAK;IACjC,IAAIM,cAAc,KAAKQ,SAAS,IAAIT,OAAO,CAACU,QAAQ,EAAE;MACpD,OAAO,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC;;IAG3B,MAAMC,UAAU,GAAGV,cAAc,CAACW,aAAa,CAAC,KAAK,CAAC;IACtDX,cAAc,CAACY,IAAI,CAACC,WAAW,CAACH,UAAU,CAAC;IAC3C,OAAO,CAACA,UAAU,EAAE,MAAMA,UAAU,CAACI,MAAM,EAAE,CAAC;EAChD,CAAC,EAAE,CAACd,cAAc,CAAC,CAAC;EAEpB;EACA;EACA;EACA;EACAJ,kBAAkB,CAAC,MAAK;IACtB,IAAI,CAACW,OAAO,EAAE;MACZ;;IAGF,MAAMQ,cAAc,GAAGV,SAAS,CAACW,KAAK,CAAC,GAAG,CAAC,CAACC,MAAM,CAACC,OAAO,CAAC;IAE3DX,OAAO,CAACY,SAAS,CAACC,GAAG,CAAC,GAAGL,cAAc,CAAC;IACxCR,OAAO,CAACc,YAAY,CAAC,KAAK,EAAEpB,GAAG,CAAC;IAChCC,eAAe,CAACoB,OAAO,GAAGf,OAAO;IAEjC,OAAO,MAAK;MACVA,OAAO,CAACY,SAAS,CAACL,MAAM,CAAC,GAAGC,cAAc,CAAC;MAC3CR,OAAO,CAACgB,eAAe,CAAC,KAAK,CAAC;IAChC,CAAC;EACH,CAAC,EAAE,CAAClB,SAAS,EAAEJ,GAAG,EAAEM,OAAO,EAAEL,eAAe,CAAC,CAAC;EAE9C,OAAOK,OAAO;AAChB,CAAC","names":["React","useThemeClassName_unstable","useThemeClassName","useFluent_unstable","useFluent","mergeClasses","useFocusVisible","useDisposable","useIsomorphicLayoutEffect","useInsertionEffect","useStyles","usePortalMountNode","options","targetDocument","dir","focusVisibleRef","classes","themeClassName","className","root","element","undefined","disabled","newElement","createElement","body","appendChild","remove","classesToApply","split","filter","Boolean","classList","add","setAttribute","current","removeAttribute"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/components/Portal/usePortalMountNode.ts"],"sourcesContent":["import * as React from 'react';\nimport {\n useThemeClassName_unstable as useThemeClassName,\n useFluent_unstable as useFluent,\n} from '@fluentui/react-shared-contexts';\nimport { makeStyles, mergeClasses } from '@griffel/react';\nimport { useFocusVisible } from '@fluentui/react-tabster';\nimport { useDisposable } from 'use-disposable';\nimport { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\n\n// String concatenation is used to prevent bundlers to complain with older versions of React\nconst useInsertionEffect = (React as never)['useInsertion' + 'Effect']\n ? (React as never)['useInsertion' + 'Effect']\n : useIsomorphicLayoutEffect;\n\nexport type UsePortalMountNodeOptions = {\n /**\n * Since hooks cannot be called conditionally use this flag to disable creating the node\n */\n disabled?: boolean;\n};\n\nconst useStyles = makeStyles({\n root: {\n position: 'relative',\n zIndex: 1000000,\n },\n});\n\n/**\n * Creates a new element on a document.body to mount portals\n */\nexport const usePortalMountNode = (options: UsePortalMountNodeOptions): HTMLElement | null => {\n const { targetDocument, dir } = useFluent();\n const focusVisibleRef = useFocusVisible<HTMLDivElement>() as React.MutableRefObject<HTMLElement | null>;\n const classes = useStyles();\n const themeClassName = useThemeClassName();\n\n const className = mergeClasses(themeClassName, classes.root);\n\n const element = useDisposable(() => {\n if (targetDocument === undefined || options.disabled) {\n return [null, () => null];\n }\n\n const newElement = targetDocument.createElement('div');\n targetDocument.body.appendChild(newElement);\n return [newElement, () => newElement.remove()];\n }, [targetDocument]);\n\n // This useEffect call is intentional\n // We don't want to re-create the portal element when its attributes change.\n // This also should not be done in an effect because, changing the value of css variables\n // after initial mount can trigger interesting CSS side effects like transitions.\n useInsertionEffect(() => {\n if (!element) {\n return;\n }\n\n const classesToApply = className.split(' ').filter(Boolean);\n\n element.classList.add(...classesToApply);\n element.setAttribute('dir', dir);\n focusVisibleRef.current = element;\n\n return () => {\n element.classList.remove(...classesToApply);\n element.removeAttribute('dir');\n };\n }, [className, dir, element, focusVisibleRef]);\n\n return element;\n};\n"]}
|
@@ -5,26 +5,21 @@ import { getParent } from './getParent';
|
|
5
5
|
*
|
6
6
|
* @returns true if the child can find the parent in its virtual hierarchy
|
7
7
|
*/
|
8
|
-
|
9
8
|
export function elementContains(parent, child) {
|
10
9
|
if (!parent || !child) {
|
11
10
|
return false;
|
12
11
|
}
|
13
|
-
|
14
12
|
if (parent === child) {
|
15
13
|
return true;
|
16
14
|
} else {
|
17
15
|
while (child) {
|
18
16
|
const nextParent = getParent(child);
|
19
|
-
|
20
17
|
if (nextParent === parent) {
|
21
18
|
return true;
|
22
19
|
}
|
23
|
-
|
24
20
|
child = nextParent;
|
25
21
|
}
|
26
22
|
}
|
27
|
-
|
28
23
|
return false;
|
29
24
|
}
|
30
25
|
//# sourceMappingURL=elementContains.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"AAAA,SAASA,SAAS,QAAQ,aAAa;AACvC;;;;;;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,OAAOA,KAAK,EAAE;MACZ,MAAMC,UAAU,GAAGJ,SAAS,CAACG,KAAK,CAAC;MAEnC,IAAIC,UAAU,KAAKF,MAAM,EAAE;QACzB,OAAO,IAAI;;MAGbC,KAAK,GAAGC,UAAU;;;EAItB,OAAO,KAAK;AACd","names":["getParent","elementContains","parent","child","nextParent"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/virtualParent/elementContains.ts"],"sourcesContent":["import { getParent } from './getParent';\n/**\n * Similar functionality to `element.contains` DOM API for use with out of order DOM elements that\n * checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent\n *\n * @returns true if the child can find the parent in its virtual hierarchy\n */\nexport function elementContains(parent: Node | null, child: Node | null): boolean {\n if (!parent || !child) {\n return false;\n }\n\n if (parent === child) {\n return true;\n } else {\n while (child) {\n const nextParent = getParent(child);\n\n if (nextParent === parent) {\n return true;\n }\n\n child = nextParent;\n }\n }\n\n return false;\n}\n"]}
|
@@ -3,8 +3,8 @@ import { getVirtualParent } from './getVirtualParent';
|
|
3
3
|
* Gets the element which is the parent of a given element.
|
4
4
|
* This method prefers the virtual parent over real DOM parent when present.
|
5
5
|
*/
|
6
|
-
|
7
6
|
export function getParent(child) {
|
8
|
-
|
7
|
+
var _a;
|
8
|
+
return (_a = child && getVirtualParent(child) || (child === null || child === void 0 ? void 0 : child.parentNode)) !== null && _a !== void 0 ? _a : null;
|
9
9
|
}
|
10
10
|
//# sourceMappingURL=getParent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"AAAA,SAASA,gBAAgB,QAAQ,oBAAoB;AAErD;;;;AAIA,OAAM,SAAUC,SAAS,CAACC,KAAkB;;EAC1C,OAAO,MAAEA,KAAK,IAAIF,gBAAgB,CAACE,KAAK,CAAC,KAAKA,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEC,UAAU,CAAC,mCAAI,IAAI;AAC1E","names":["getVirtualParent","getParent","child","parentNode"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/virtualParent/getParent.ts"],"sourcesContent":["import { getVirtualParent } from './getVirtualParent';\n\n/**\n * Gets the element which is the parent of a given element.\n * This method prefers the virtual parent over real DOM parent when present.\n */\nexport function getParent(child: Node | null): Node | null {\n return ((child && getVirtualParent(child)) || child?.parentNode) ?? null;\n}\n"]}
|
@@ -2,14 +2,7 @@ import { isVirtualElement } from './isVirtualElement';
|
|
2
2
|
/**
|
3
3
|
* Gets the virtual parent given the child element, if it exists.
|
4
4
|
*/
|
5
|
-
|
6
5
|
export function getVirtualParent(child) {
|
7
|
-
|
8
|
-
|
9
|
-
if (isVirtualElement(child)) {
|
10
|
-
parent = child._virtual.parent;
|
11
|
-
}
|
12
|
-
|
13
|
-
return parent;
|
6
|
+
return isVirtualElement(child) ? child._virtual.parent : undefined;
|
14
7
|
}
|
15
8
|
//# sourceMappingURL=getVirtualParent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
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 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"AAEA;;;AAGA,OAAM,SAAUA,gBAAgB,CAACC,OAA8B;EAC7D,OAAOA,OAAO,IAAI,CAAC,CAAkBA,OAAQ,CAACC,QAAQ;AACxD","names":["isVirtualElement","element","_virtual"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/virtualParent/isVirtualElement.ts"],"sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Determines whether or not an element has the virtual hierarchy extension.\n */\nexport function isVirtualElement(element: Node | VirtualElement): element is VirtualElement {\n return element && !!(<VirtualElement>element)._virtual;\n}\n"]}
|
@@ -8,13 +8,10 @@ export function setVirtualParent(child, parent) {
|
|
8
8
|
if (!child) {
|
9
9
|
return;
|
10
10
|
}
|
11
|
-
|
12
11
|
const virtualChild = child;
|
13
|
-
|
14
12
|
if (!virtualChild._virtual) {
|
15
13
|
virtualChild._virtual = {};
|
16
14
|
}
|
17
|
-
|
18
15
|
virtualChild._virtual.parent = parent || undefined;
|
19
16
|
}
|
20
17
|
//# sourceMappingURL=setVirtualParent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
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,IAAIG,SAAS;AACpD","names":["setVirtualParent","child","parent","virtualChild","_virtual","undefined"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/virtualParent/setVirtualParent.ts"],"sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Sets the virtual parent of an element.\n *\n * @param child - Theme element to set the virtual parent\n * @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship\n */\nexport function setVirtualParent(child: Node, parent?: Node): void {\n if (!child) {\n return;\n }\n\n const virtualChild = child as VirtualElement;\n\n if (!virtualChild._virtual) {\n virtualChild._virtual = {};\n }\n\n virtualChild._virtual.parent = parent || undefined;\n}\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/virtualParent/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface VirtualElement extends
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/virtualParent/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface VirtualElement extends Node {\n _virtual: {\n parent?: Node;\n };\n}\n"]}
|
@@ -1,7 +1,11 @@
|
|
1
|
-
define(["require", "exports", "react", "@fluentui/react-shared-contexts", "@griffel/react", "@fluentui/react-tabster"], function (require, exports, React, react_shared_contexts_1, react_1, react_tabster_1) {
|
1
|
+
define(["require", "exports", "react", "@fluentui/react-shared-contexts", "@griffel/react", "@fluentui/react-tabster", "use-disposable", "@fluentui/react-utilities"], function (require, exports, React, react_shared_contexts_1, react_1, react_tabster_1, use_disposable_1, react_utilities_1) {
|
2
2
|
"use strict";
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4
4
|
exports.usePortalMountNode = void 0;
|
5
|
+
// String concatenation is used to prevent bundlers to complain with older versions of React
|
6
|
+
var useInsertionEffect = React['useInsertion' + 'Effect']
|
7
|
+
? React['useInsertion' + 'Effect']
|
8
|
+
: react_utilities_1.useIsomorphicLayoutEffect;
|
5
9
|
var useStyles = react_1.makeStyles({
|
6
10
|
root: {
|
7
11
|
position: 'relative',
|
@@ -17,38 +21,33 @@ define(["require", "exports", "react", "@fluentui/react-shared-contexts", "@grif
|
|
17
21
|
var classes = useStyles();
|
18
22
|
var themeClassName = react_shared_contexts_1.useThemeClassName_unstable();
|
19
23
|
var className = react_1.mergeClasses(themeClassName, classes.root);
|
20
|
-
var element =
|
24
|
+
var element = use_disposable_1.useDisposable(function () {
|
21
25
|
if (targetDocument === undefined || options.disabled) {
|
22
|
-
return null;
|
26
|
+
return [null, function () { return null; }];
|
23
27
|
}
|
24
28
|
var newElement = targetDocument.createElement('div');
|
25
29
|
targetDocument.body.appendChild(newElement);
|
26
|
-
return newElement;
|
27
|
-
}, [targetDocument
|
28
|
-
// This
|
30
|
+
return [newElement, function () { return newElement.remove(); }];
|
31
|
+
}, [targetDocument]);
|
32
|
+
// This useEffect call is intentional
|
29
33
|
// We don't want to re-create the portal element when its attributes change.
|
30
34
|
// This also should not be done in an effect because, changing the value of css variables
|
31
35
|
// after initial mount can trigger interesting CSS side effects like transitions.
|
32
|
-
|
36
|
+
useInsertionEffect(function () {
|
33
37
|
var _a;
|
34
|
-
if (element) {
|
35
|
-
|
36
|
-
(_a = element.classList).add.apply(_a, classesToApply_1);
|
37
|
-
element.setAttribute('dir', dir);
|
38
|
-
focusVisibleRef.current = element;
|
39
|
-
return function () {
|
40
|
-
var _a;
|
41
|
-
(_a = element.classList).remove.apply(_a, classesToApply_1);
|
42
|
-
element.removeAttribute('dir');
|
43
|
-
};
|
38
|
+
if (!element) {
|
39
|
+
return;
|
44
40
|
}
|
45
|
-
|
46
|
-
|
41
|
+
var classesToApply = className.split(' ').filter(Boolean);
|
42
|
+
(_a = element.classList).add.apply(_a, classesToApply);
|
43
|
+
element.setAttribute('dir', dir);
|
44
|
+
focusVisibleRef.current = element;
|
47
45
|
return function () {
|
48
46
|
var _a;
|
49
|
-
(_a = element
|
47
|
+
(_a = element.classList).remove.apply(_a, classesToApply);
|
48
|
+
element.removeAttribute('dir');
|
50
49
|
};
|
51
|
-
}, [element]);
|
50
|
+
}, [className, dir, element, focusVisibleRef]);
|
52
51
|
return element;
|
53
52
|
};
|
54
53
|
exports.usePortalMountNode = usePortalMountNode;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"usePortalMountNode.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-portal/src/components/Portal/usePortalMountNode.ts"],"names":[],"mappings":";;;;
|
1
|
+
{"version":3,"file":"usePortalMountNode.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-portal/src/components/Portal/usePortalMountNode.ts"],"names":[],"mappings":";;;;IAUA,4FAA4F;IAC5F,IAAM,kBAAkB,GAAI,KAAe,CAAC,cAAc,GAAG,QAAQ,CAAC;QACpE,CAAC,CAAE,KAAe,CAAC,cAAc,GAAG,QAAQ,CAAC;QAC7C,CAAC,CAAC,2CAAyB,CAAC;IAS9B,IAAM,SAAS,GAAG,kBAAU,CAAC;QAC3B,IAAI,EAAE;YACJ,QAAQ,EAAE,UAAU;YACpB,MAAM,EAAE,OAAO;SAChB;KACF,CAAC,CAAC;IAEH;;OAEG;IACI,IAAM,kBAAkB,GAAG,UAAC,OAAkC;QAC7D,IAAA,KAA0B,0CAAS,EAAE,EAAnC,cAAc,oBAAA,EAAE,GAAG,SAAgB,CAAC;QAC5C,IAAM,eAAe,GAAG,+BAAe,EAAgE,CAAC;QACxG,IAAM,OAAO,GAAG,SAAS,EAAE,CAAC;QAC5B,IAAM,cAAc,GAAG,kDAAiB,EAAE,CAAC;QAE3C,IAAM,SAAS,GAAG,oBAAY,CAAC,cAAc,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QAE7D,IAAM,OAAO,GAAG,8BAAa,CAAC;YAC5B,IAAI,cAAc,KAAK,SAAS,IAAI,OAAO,CAAC,QAAQ,EAAE;gBACpD,OAAO,CAAC,IAAI,EAAE,cAAM,OAAA,IAAI,EAAJ,CAAI,CAAC,CAAC;aAC3B;YAED,IAAM,UAAU,GAAG,cAAc,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YACvD,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;YAC5C,OAAO,CAAC,UAAU,EAAE,cAAM,OAAA,UAAU,CAAC,MAAM,EAAE,EAAnB,CAAmB,CAAC,CAAC;QACjD,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;QAErB,qCAAqC;QACrC,4EAA4E;QAC5E,yFAAyF;QACzF,iFAAiF;QACjF,kBAAkB,CAAC;;YACjB,IAAI,CAAC,OAAO,EAAE;gBACZ,OAAO;aACR;YAED,IAAM,cAAc,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAE5D,CAAA,KAAA,OAAO,CAAC,SAAS,CAAA,CAAC,GAAG,WAAI,cAAc,EAAE;YACzC,OAAO,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YACjC,eAAe,CAAC,OAAO,GAAG,OAAO,CAAC;YAElC,OAAO;;gBACL,CAAA,KAAA,OAAO,CAAC,SAAS,CAAA,CAAC,MAAM,WAAI,cAAc,EAAE;gBAC5C,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;YACjC,CAAC,CAAC;QACJ,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC;QAE/C,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;IAxCW,QAAA,kBAAkB,sBAwC7B","sourcesContent":["import * as React from 'react';\nimport {\n useThemeClassName_unstable as useThemeClassName,\n useFluent_unstable as useFluent,\n} from '@fluentui/react-shared-contexts';\nimport { makeStyles, mergeClasses } from '@griffel/react';\nimport { useFocusVisible } from '@fluentui/react-tabster';\nimport { useDisposable } from 'use-disposable';\nimport { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\n\n// String concatenation is used to prevent bundlers to complain with older versions of React\nconst useInsertionEffect = (React as never)['useInsertion' + 'Effect']\n ? (React as never)['useInsertion' + 'Effect']\n : useIsomorphicLayoutEffect;\n\nexport type UsePortalMountNodeOptions = {\n /**\n * Since hooks cannot be called conditionally use this flag to disable creating the node\n */\n disabled?: boolean;\n};\n\nconst useStyles = makeStyles({\n root: {\n position: 'relative',\n zIndex: 1000000,\n },\n});\n\n/**\n * Creates a new element on a document.body to mount portals\n */\nexport const usePortalMountNode = (options: UsePortalMountNodeOptions): HTMLElement | null => {\n const { targetDocument, dir } = useFluent();\n const focusVisibleRef = useFocusVisible<HTMLDivElement>() as React.MutableRefObject<HTMLElement | null>;\n const classes = useStyles();\n const themeClassName = useThemeClassName();\n\n const className = mergeClasses(themeClassName, classes.root);\n\n const element = useDisposable(() => {\n if (targetDocument === undefined || options.disabled) {\n return [null, () => null];\n }\n\n const newElement = targetDocument.createElement('div');\n targetDocument.body.appendChild(newElement);\n return [newElement, () => newElement.remove()];\n }, [targetDocument]);\n\n // This useEffect call is intentional\n // We don't want to re-create the portal element when its attributes change.\n // This also should not be done in an effect because, changing the value of css variables\n // after initial mount can trigger interesting CSS side effects like transitions.\n useInsertionEffect(() => {\n if (!element) {\n return;\n }\n\n const classesToApply = className.split(' ').filter(Boolean);\n\n element.classList.add(...classesToApply);\n element.setAttribute('dir', dir);\n focusVisibleRef.current = element;\n\n return () => {\n element.classList.remove(...classesToApply);\n element.removeAttribute('dir');\n };\n }, [className, dir, element, focusVisibleRef]);\n\n return element;\n};\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"elementContains.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/elementContains.ts"],"names":[],"mappings":";;;;IACA;;;;;OAKG;IACH,SAAgB,eAAe,CAAC,
|
1
|
+
{"version":3,"file":"elementContains.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/elementContains.ts"],"names":[],"mappings":";;;;IACA;;;;;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,OAAO,KAAK,EAAE;gBACZ,IAAM,UAAU,GAAG,qBAAS,CAAC,KAAK,CAAC,CAAC;gBAEpC,IAAI,UAAU,KAAK,MAAM,EAAE;oBACzB,OAAO,IAAI,CAAC;iBACb;gBAED,KAAK,GAAG,UAAU,CAAC;aACpB;SACF;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IApBD,0CAoBC","sourcesContent":["import { getParent } from './getParent';\n/**\n * Similar functionality to `element.contains` DOM API for use with out of order DOM elements that\n * checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent\n *\n * @returns true if the child can find the parent in its virtual hierarchy\n */\nexport function elementContains(parent: Node | null, child: Node | null): boolean {\n if (!parent || !child) {\n return false;\n }\n\n if (parent === child) {\n return true;\n } else {\n while (child) {\n const nextParent = getParent(child);\n\n if (nextParent === parent) {\n return true;\n }\n\n child = nextParent;\n }\n }\n\n return false;\n}\n"]}
|
@@ -7,7 +7,8 @@ define(["require", "exports", "./getVirtualParent"], function (require, exports,
|
|
7
7
|
* This method prefers the virtual parent over real DOM parent when present.
|
8
8
|
*/
|
9
9
|
function getParent(child) {
|
10
|
-
|
10
|
+
var _a;
|
11
|
+
return (_a = ((child && getVirtualParent_1.getVirtualParent(child)) || (child === null || child === void 0 ? void 0 : child.parentNode))) !== null && _a !== void 0 ? _a : null;
|
11
12
|
}
|
12
13
|
exports.getParent = getParent;
|
13
14
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getParent.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/getParent.ts"],"names":[],"mappings":";;;;IAEA;;;OAGG;IACH,SAAgB,SAAS,CAAC,
|
1
|
+
{"version":3,"file":"getParent.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/getParent.ts"],"names":[],"mappings":";;;;IAEA;;;OAGG;IACH,SAAgB,SAAS,CAAC,KAAkB;;QAC1C,OAAO,MAAA,CAAC,CAAC,KAAK,IAAI,mCAAgB,CAAC,KAAK,CAAC,CAAC,KAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,CAAA,CAAC,mCAAI,IAAI,CAAC;IAC3E,CAAC;IAFD,8BAEC","sourcesContent":["import { getVirtualParent } from './getVirtualParent';\n\n/**\n * Gets the element which is the parent of a given element.\n * This method prefers the virtual parent over real DOM parent when present.\n */\nexport function getParent(child: Node | null): Node | null {\n return ((child && getVirtualParent(child)) || child?.parentNode) ?? null;\n}\n"]}
|
@@ -6,11 +6,7 @@ define(["require", "exports", "./isVirtualElement"], function (require, exports,
|
|
6
6
|
* Gets the virtual parent given the child element, if it exists.
|
7
7
|
*/
|
8
8
|
function getVirtualParent(child) {
|
9
|
-
|
10
|
-
if (isVirtualElement_1.isVirtualElement(child)) {
|
11
|
-
parent = child._virtual.parent;
|
12
|
-
}
|
13
|
-
return parent;
|
9
|
+
return isVirtualElement_1.isVirtualElement(child) ? child._virtual.parent : undefined;
|
14
10
|
}
|
15
11
|
exports.getVirtualParent = getVirtualParent;
|
16
12
|
});
|
@@ -1 +1 @@
|
|
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,
|
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 +1 @@
|
|
1
|
-
{"version":3,"file":"isVirtualElement.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/isVirtualElement.ts"],"names":[],"mappings":";;;;IAEA;;OAEG;IACH,SAAgB,gBAAgB,CAAC,
|
1
|
+
{"version":3,"file":"isVirtualElement.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/isVirtualElement.ts"],"names":[],"mappings":";;;;IAEA;;OAEG;IACH,SAAgB,gBAAgB,CAAC,OAA8B;QAC7D,OAAO,OAAO,IAAI,CAAC,CAAkB,OAAQ,CAAC,QAAQ,CAAC;IACzD,CAAC;IAFD,4CAEC","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"]}
|