@fluentui/react-portal 0.0.0-nightly-20230317-1454.1 → 0.0.0-nightly-20230322-0439.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.swcrc +2 -11
- package/CHANGELOG.json +48 -9
- package/CHANGELOG.md +20 -7
- package/lib/Portal.js +1 -1
- package/lib/components/Portal/Portal.js +4 -4
- package/lib/components/Portal/Portal.types.js +1 -1
- package/lib/components/Portal/index.js +4 -4
- package/lib/components/Portal/renderPortal.js +2 -2
- package/lib/components/Portal/usePortal.js +6 -6
- package/lib/components/Portal/usePortal.js.map +1 -1
- package/lib/components/Portal/usePortalMountNode.js +11 -11
- package/lib/index.js +2 -2
- package/lib/virtualParent/elementContains.js +1 -1
- package/lib/virtualParent/getParent.js +2 -2
- package/lib/virtualParent/getParent.js.map +1 -1
- package/lib/virtualParent/index.js +2 -2
- package/lib-commonjs/Portal.js.map +1 -1
- package/lib-commonjs/components/Portal/Portal.js +1 -1
- 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.map +1 -1
- package/lib-commonjs/components/Portal/renderPortal.js.map +1 -1
- package/lib-commonjs/components/Portal/usePortal.js +2 -2
- package/lib-commonjs/components/Portal/usePortal.js.map +1 -1
- package/lib-commonjs/components/Portal/usePortalMountNode.js +6 -6
- package/lib-commonjs/components/Portal/usePortalMountNode.js.map +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/virtualParent/elementContains.js.map +1 -1
- package/lib-commonjs/virtualParent/getParent.js +1 -1
- package/lib-commonjs/virtualParent/getParent.js.map +1 -1
- package/lib-commonjs/virtualParent/index.js.map +1 -1
- package/package.json +7 -6
package/.swcrc
CHANGED
@@ -1,15 +1,5 @@
|
|
1
1
|
{
|
2
2
|
"$schema": "https://json.schemastore.org/swcrc",
|
3
|
-
"env": {
|
4
|
-
"targets": {
|
5
|
-
"chrome": "84",
|
6
|
-
"edge": "84",
|
7
|
-
"firefox": "75",
|
8
|
-
"opera": "73",
|
9
|
-
"safari": "14.1"
|
10
|
-
},
|
11
|
-
"bugfixes": true
|
12
|
-
},
|
13
3
|
"exclude": [
|
14
4
|
"/testing",
|
15
5
|
"/**/*.cy.ts",
|
@@ -32,7 +22,8 @@
|
|
32
22
|
"runtime": "classic",
|
33
23
|
"useSpread": true
|
34
24
|
}
|
35
|
-
}
|
25
|
+
},
|
26
|
+
"target": "es2019"
|
36
27
|
},
|
37
28
|
"minify": false,
|
38
29
|
"sourceMaps": true
|
package/CHANGELOG.json
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
"name": "@fluentui/react-portal",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
6
|
-
"tag": "@fluentui/react-portal_v0.0.0-nightly-
|
7
|
-
"version": "0.0.0-nightly-
|
5
|
+
"date": "Wed, 22 Mar 2023 04:46:47 GMT",
|
6
|
+
"tag": "@fluentui/react-portal_v0.0.0-nightly-20230322-0439.1",
|
7
|
+
"version": "0.0.0-nightly-20230322-0439.1",
|
8
8
|
"comments": {
|
9
9
|
"prerelease": [
|
10
10
|
{
|
@@ -16,20 +16,59 @@
|
|
16
16
|
{
|
17
17
|
"author": "beachball",
|
18
18
|
"package": "@fluentui/react-portal",
|
19
|
-
"comment": "Bump @fluentui/react-shared-contexts to v0.0.0-nightly-
|
20
|
-
"commit": "
|
19
|
+
"comment": "Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20230322-0439.1",
|
20
|
+
"commit": "49dde84493fc2c3e96abac5ce918169c9668ba66"
|
21
21
|
},
|
22
22
|
{
|
23
23
|
"author": "beachball",
|
24
24
|
"package": "@fluentui/react-portal",
|
25
|
-
"comment": "Bump @fluentui/react-tabster to v0.0.0-nightly-
|
26
|
-
"commit": "
|
25
|
+
"comment": "Bump @fluentui/react-tabster to v0.0.0-nightly-20230322-0439.1",
|
26
|
+
"commit": "49dde84493fc2c3e96abac5ce918169c9668ba66"
|
27
27
|
},
|
28
28
|
{
|
29
29
|
"author": "beachball",
|
30
30
|
"package": "@fluentui/react-portal",
|
31
|
-
"comment": "Bump @fluentui/react-utilities to v0.0.0-nightly-
|
32
|
-
"commit": "
|
31
|
+
"comment": "Bump @fluentui/react-utilities to v0.0.0-nightly-20230322-0439.1",
|
32
|
+
"commit": "49dde84493fc2c3e96abac5ce918169c9668ba66"
|
33
|
+
}
|
34
|
+
]
|
35
|
+
}
|
36
|
+
},
|
37
|
+
{
|
38
|
+
"date": "Tue, 21 Mar 2023 21:23:43 GMT",
|
39
|
+
"tag": "@fluentui/react-portal_v9.2.2",
|
40
|
+
"version": "9.2.2",
|
41
|
+
"comments": {
|
42
|
+
"patch": [
|
43
|
+
{
|
44
|
+
"author": "tristan.watanabe@gmail.com",
|
45
|
+
"package": "@fluentui/react-portal",
|
46
|
+
"commit": "2fac1a139149bd13b76b1306207bc988dca9c72c",
|
47
|
+
"comment": "chore: migrate to swc transpilation approach."
|
48
|
+
},
|
49
|
+
{
|
50
|
+
"author": "tristan.watanabe@gmail.com",
|
51
|
+
"package": "@fluentui/react-portal",
|
52
|
+
"commit": "ead1c6d4c2ac3f3596b62b8cbc07b0a03041f11f",
|
53
|
+
"comment": "fix: add node field to package.json exports map."
|
54
|
+
},
|
55
|
+
{
|
56
|
+
"author": "beachball",
|
57
|
+
"package": "@fluentui/react-portal",
|
58
|
+
"comment": "Bump @fluentui/react-shared-contexts to v9.3.2",
|
59
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
60
|
+
},
|
61
|
+
{
|
62
|
+
"author": "beachball",
|
63
|
+
"package": "@fluentui/react-portal",
|
64
|
+
"comment": "Bump @fluentui/react-tabster to v9.6.1",
|
65
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
66
|
+
},
|
67
|
+
{
|
68
|
+
"author": "beachball",
|
69
|
+
"package": "@fluentui/react-portal",
|
70
|
+
"comment": "Bump @fluentui/react-utilities to v9.7.2",
|
71
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
33
72
|
}
|
34
73
|
]
|
35
74
|
}
|
package/CHANGELOG.md
CHANGED
@@ -1,20 +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 Wed, 22 Mar 2023 04:46:47 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
-
## [0.0.0-nightly-
|
7
|
+
## [0.0.0-nightly-20230322-0439.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-portal_v0.0.0-nightly-20230322-0439.1)
|
8
8
|
|
9
|
-
|
10
|
-
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-portal_v9.2.
|
9
|
+
Wed, 22 Mar 2023 04:46:47 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-portal_v9.2.2..@fluentui/react-portal_v0.0.0-nightly-20230322-0439.1)
|
11
11
|
|
12
12
|
### Changes
|
13
13
|
|
14
14
|
- Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/not available) by fluentui-internal@service.microsoft.com)
|
15
|
-
- Bump @fluentui/react-shared-contexts to v0.0.0-nightly-
|
16
|
-
- Bump @fluentui/react-tabster to v0.0.0-nightly-
|
17
|
-
- Bump @fluentui/react-utilities to v0.0.0-nightly-
|
15
|
+
- Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20230322-0439.1 ([commit](https://github.com/microsoft/fluentui/commit/49dde84493fc2c3e96abac5ce918169c9668ba66) by beachball)
|
16
|
+
- Bump @fluentui/react-tabster to v0.0.0-nightly-20230322-0439.1 ([commit](https://github.com/microsoft/fluentui/commit/49dde84493fc2c3e96abac5ce918169c9668ba66) by beachball)
|
17
|
+
- Bump @fluentui/react-utilities to v0.0.0-nightly-20230322-0439.1 ([commit](https://github.com/microsoft/fluentui/commit/49dde84493fc2c3e96abac5ce918169c9668ba66) by beachball)
|
18
|
+
|
19
|
+
## [9.2.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-portal_v9.2.2)
|
20
|
+
|
21
|
+
Tue, 21 Mar 2023 21:23:43 GMT
|
22
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-portal_v9.2.1..@fluentui/react-portal_v9.2.2)
|
23
|
+
|
24
|
+
### Patches
|
25
|
+
|
26
|
+
- chore: migrate to swc transpilation approach. ([PR #27250](https://github.com/microsoft/fluentui/pull/27250) by tristan.watanabe@gmail.com)
|
27
|
+
- fix: add node field to package.json exports map. ([PR #27154](https://github.com/microsoft/fluentui/pull/27154) by tristan.watanabe@gmail.com)
|
28
|
+
- Bump @fluentui/react-shared-contexts to v9.3.2 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
29
|
+
- Bump @fluentui/react-tabster to v9.6.1 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
30
|
+
- Bump @fluentui/react-utilities to v9.7.2 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
18
31
|
|
19
32
|
## [9.2.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-portal_v9.2.1)
|
20
33
|
|
package/lib/Portal.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export * from
|
1
|
+
export * from './components/Portal/index';
|
2
2
|
//# sourceMappingURL=Portal.js.map
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import * as React from
|
2
|
-
import { usePortal_unstable } from
|
3
|
-
import { renderPortal_unstable } from
|
1
|
+
import * as React from 'react';
|
2
|
+
import { usePortal_unstable } from './usePortal';
|
3
|
+
import { renderPortal_unstable } from './renderPortal';
|
4
4
|
/**
|
5
5
|
* A portal provides a way to render children into a DOM node
|
6
6
|
* that exists outside the DOM hierarchy of the parent component.
|
@@ -9,5 +9,5 @@ export const Portal = props => {
|
|
9
9
|
const state = usePortal_unstable(props);
|
10
10
|
return renderPortal_unstable(state);
|
11
11
|
};
|
12
|
-
Portal.displayName =
|
12
|
+
Portal.displayName = 'Portal';
|
13
13
|
//# sourceMappingURL=Portal.js.map
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import * as React from
|
1
|
+
import * as React from 'react';
|
2
2
|
//# sourceMappingURL=Portal.types.js.map
|
@@ -1,5 +1,5 @@
|
|
1
|
-
export * from
|
2
|
-
export * from
|
3
|
-
export * from
|
4
|
-
export * from
|
1
|
+
export * from './Portal';
|
2
|
+
export * from './Portal.types';
|
3
|
+
export * from './renderPortal';
|
4
|
+
export * from './usePortal';
|
5
5
|
//# sourceMappingURL=index.js.map
|
@@ -1,14 +1,14 @@
|
|
1
|
-
import { isHTMLElement } from
|
2
|
-
import * as React from
|
3
|
-
import { setVirtualParent } from
|
4
|
-
import { usePortalMountNode } from
|
1
|
+
import { isHTMLElement } from '@fluentui/react-utilities';
|
2
|
+
import * as React from 'react';
|
3
|
+
import { setVirtualParent } from '../../virtualParent/index';
|
4
|
+
import { usePortalMountNode } from './usePortalMountNode';
|
5
5
|
export function toMountNodeProps(mountNode) {
|
6
6
|
if (isHTMLElement(mountNode)) {
|
7
7
|
return {
|
8
8
|
element: mountNode
|
9
9
|
};
|
10
10
|
}
|
11
|
-
if (typeof mountNode ===
|
11
|
+
if (typeof mountNode === 'object') {
|
12
12
|
if (mountNode === null) {
|
13
13
|
return {
|
14
14
|
element: null
|
@@ -37,7 +37,7 @@ export const usePortal_unstable = props => {
|
|
37
37
|
});
|
38
38
|
const state = {
|
39
39
|
children: props.children,
|
40
|
-
mountNode: element
|
40
|
+
mountNode: element !== null && element !== void 0 ? element : fallbackElement,
|
41
41
|
virtualParentRootRef
|
42
42
|
};
|
43
43
|
React.useEffect(() => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["isHTMLElement","React","setVirtualParent","usePortalMountNode","toMountNodeProps","mountNode","element","usePortal_unstable","props","className","virtualParentRootRef","useRef","fallbackElement","disabled","state","children","useEffect","current","undefined"],"sources":["../../../src/components/Portal/usePortal.ts"],"sourcesContent":["import { isHTMLElement } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { setVirtualParent } from '../../virtualParent/index';\nimport { usePortalMountNode } from './usePortalMountNode';\nimport type { PortalProps, PortalState } from './Portal.types';\n\nexport function toMountNodeProps(mountNode: PortalProps['mountNode']): {\n element?: HTMLElement | null;\n className?: string;\n} {\n if (isHTMLElement(mountNode)) {\n return { element: mountNode };\n }\n\n if (typeof mountNode === 'object') {\n if (mountNode === null) {\n return { element: null };\n }\n\n return mountNode;\n }\n\n return {};\n}\n\n/**\n * Create the state required to render Portal.\n *\n * The returned state can be modified with hooks such as usePortalStyles, before being passed to renderPortal_unstable.\n *\n * @param props - props from this instance of Portal\n */\nexport const usePortal_unstable = (props: PortalProps): PortalState => {\n const { element, className } = toMountNodeProps(props.mountNode);\n\n const virtualParentRootRef = React.useRef<HTMLSpanElement>(null);\n const fallbackElement = usePortalMountNode({ disabled: !!element, className });\n\n const state: PortalState = {\n children: props.children,\n mountNode: element ?? fallbackElement,\n virtualParentRootRef,\n };\n\n React.useEffect(() => {\n if (state.virtualParentRootRef.current && state.mountNode) {\n setVirtualParent(state.mountNode, state.virtualParentRootRef.current);\n }\n return () => {\n if (state.mountNode) {\n setVirtualParent(state.mountNode, undefined);\n }\n };\n }, [state.virtualParentRootRef, state.mountNode]);\n\n return state;\n};\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ;AAC9B,YAAYC,KAAA,MAAW;AAEvB,SAASC,gBAAgB,QAAQ;AACjC,SAASC,kBAAkB,QAAQ;AAGnC,OAAO,SAASC,iBAAiBC,SAAmC,EAGlE;EACA,IAAIL,aAAA,CAAcK,SAAA,GAAY;IAC5B,OAAO;MAAEC,OAAA,EAASD;IAAU;EAC9B;EAEA,IAAI,OAAOA,SAAA,KAAc,UAAU;IACjC,IAAIA,SAAA,KAAc,IAAI,EAAE;MACtB,OAAO;QAAEC,OAAA,EAAS;MAAK;IACzB;IAEA,OAAOD,SAAA;EACT;EAEA,OAAO,CAAC;AACV;AAEA;;;;;;;AAOA,OAAO,MAAME,kBAAA,GAAsBC,KAAA,IAAoC;EACrE,MAAM;IAAEF,OAAA;IAASG;EAAS,CAAE,GAAGL,gBAAA,CAAiBI,KAAA,CAAMH,SAAS;EAE/D,MAAMK,oBAAA,GAAuBT,KAAA,CAAMU,MAAM,CAAkB,IAAI;EAC/D,MAAMC,eAAA,GAAkBT,kBAAA,CAAmB;IAAEU,QAAA,EAAU,CAAC,CAACP,OAAA;IAASG;EAAU;EAE5E,MAAMK,KAAA,GAAqB;IACzBC,QAAA,EAAUP,KAAA,CAAMO,QAAQ;IACxBV,SAAA,EAAWC,OAAA,
|
1
|
+
{"version":3,"names":["isHTMLElement","React","setVirtualParent","usePortalMountNode","toMountNodeProps","mountNode","element","usePortal_unstable","props","className","virtualParentRootRef","useRef","fallbackElement","disabled","state","children","useEffect","current","undefined"],"sources":["../../../src/components/Portal/usePortal.ts"],"sourcesContent":["import { isHTMLElement } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { setVirtualParent } from '../../virtualParent/index';\nimport { usePortalMountNode } from './usePortalMountNode';\nimport type { PortalProps, PortalState } from './Portal.types';\n\nexport function toMountNodeProps(mountNode: PortalProps['mountNode']): {\n element?: HTMLElement | null;\n className?: string;\n} {\n if (isHTMLElement(mountNode)) {\n return { element: mountNode };\n }\n\n if (typeof mountNode === 'object') {\n if (mountNode === null) {\n return { element: null };\n }\n\n return mountNode;\n }\n\n return {};\n}\n\n/**\n * Create the state required to render Portal.\n *\n * The returned state can be modified with hooks such as usePortalStyles, before being passed to renderPortal_unstable.\n *\n * @param props - props from this instance of Portal\n */\nexport const usePortal_unstable = (props: PortalProps): PortalState => {\n const { element, className } = toMountNodeProps(props.mountNode);\n\n const virtualParentRootRef = React.useRef<HTMLSpanElement>(null);\n const fallbackElement = usePortalMountNode({ disabled: !!element, className });\n\n const state: PortalState = {\n children: props.children,\n mountNode: element ?? fallbackElement,\n virtualParentRootRef,\n };\n\n React.useEffect(() => {\n if (state.virtualParentRootRef.current && state.mountNode) {\n setVirtualParent(state.mountNode, state.virtualParentRootRef.current);\n }\n return () => {\n if (state.mountNode) {\n setVirtualParent(state.mountNode, undefined);\n }\n };\n }, [state.virtualParentRootRef, state.mountNode]);\n\n return state;\n};\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ;AAC9B,YAAYC,KAAA,MAAW;AAEvB,SAASC,gBAAgB,QAAQ;AACjC,SAASC,kBAAkB,QAAQ;AAGnC,OAAO,SAASC,iBAAiBC,SAAmC,EAGlE;EACA,IAAIL,aAAA,CAAcK,SAAA,GAAY;IAC5B,OAAO;MAAEC,OAAA,EAASD;IAAU;EAC9B;EAEA,IAAI,OAAOA,SAAA,KAAc,UAAU;IACjC,IAAIA,SAAA,KAAc,IAAI,EAAE;MACtB,OAAO;QAAEC,OAAA,EAAS;MAAK;IACzB;IAEA,OAAOD,SAAA;EACT;EAEA,OAAO,CAAC;AACV;AAEA;;;;;;;AAOA,OAAO,MAAME,kBAAA,GAAsBC,KAAA,IAAoC;EACrE,MAAM;IAAEF,OAAA;IAASG;EAAS,CAAE,GAAGL,gBAAA,CAAiBI,KAAA,CAAMH,SAAS;EAE/D,MAAMK,oBAAA,GAAuBT,KAAA,CAAMU,MAAM,CAAkB,IAAI;EAC/D,MAAMC,eAAA,GAAkBT,kBAAA,CAAmB;IAAEU,QAAA,EAAU,CAAC,CAACP,OAAA;IAASG;EAAU;EAE5E,MAAMK,KAAA,GAAqB;IACzBC,QAAA,EAAUP,KAAA,CAAMO,QAAQ;IACxBV,SAAA,EAAWC,OAAA,aAAAA,OAAA,cAAAA,OAAA,GAAWM,eAAe;IACrCF;EACF;EAEAT,KAAA,CAAMe,SAAS,CAAC,MAAM;IACpB,IAAIF,KAAA,CAAMJ,oBAAoB,CAACO,OAAO,IAAIH,KAAA,CAAMT,SAAS,EAAE;MACzDH,gBAAA,CAAiBY,KAAA,CAAMT,SAAS,EAAES,KAAA,CAAMJ,oBAAoB,CAACO,OAAO;IACtE;IACA,OAAO,MAAM;MACX,IAAIH,KAAA,CAAMT,SAAS,EAAE;QACnBH,gBAAA,CAAiBY,KAAA,CAAMT,SAAS,EAAEa,SAAA;MACpC;IACF;EACF,GAAG,CAACJ,KAAA,CAAMJ,oBAAoB,EAAEI,KAAA,CAAMT,SAAS,CAAC;EAEhD,OAAOS,KAAA;AACT"}
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import * as React from
|
2
|
-
import { useThemeClassName_unstable as useThemeClassName, useFluent_unstable as useFluent } from
|
3
|
-
import { __styles, mergeClasses } from
|
4
|
-
import { useFocusVisible } from
|
5
|
-
import { useDisposable } from
|
6
|
-
const useInsertionEffect = React[
|
1
|
+
import * as React from 'react';
|
2
|
+
import { useThemeClassName_unstable as useThemeClassName, useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
|
3
|
+
import { __styles, mergeClasses } from '@griffel/react';
|
4
|
+
import { useFocusVisible } from '@fluentui/react-tabster';
|
5
|
+
import { useDisposable } from 'use-disposable';
|
6
|
+
const useInsertionEffect = React['useInsertion' + 'Effect'];
|
7
7
|
const useStyles = /*#__PURE__*/__styles({
|
8
8
|
root: {
|
9
9
|
qhf8xq: "f10pi13n",
|
@@ -28,7 +28,7 @@ export const usePortalMountNode = options => {
|
|
28
28
|
if (targetDocument === undefined || options.disabled) {
|
29
29
|
return [null, () => null];
|
30
30
|
}
|
31
|
-
const newElement = targetDocument.createElement(
|
31
|
+
const newElement = targetDocument.createElement('div');
|
32
32
|
targetDocument.body.appendChild(newElement);
|
33
33
|
return [newElement, () => newElement.remove()];
|
34
34
|
}, [targetDocument]);
|
@@ -38,13 +38,13 @@ export const usePortalMountNode = options => {
|
|
38
38
|
if (!element) {
|
39
39
|
return;
|
40
40
|
}
|
41
|
-
const classesToApply = className.split(
|
41
|
+
const classesToApply = className.split(' ').filter(Boolean);
|
42
42
|
element.classList.add(...classesToApply);
|
43
|
-
element.setAttribute(
|
43
|
+
element.setAttribute('dir', dir);
|
44
44
|
focusVisibleRef.current = element;
|
45
45
|
return () => {
|
46
46
|
element.classList.remove(...classesToApply);
|
47
|
-
element.removeAttribute(
|
47
|
+
element.removeAttribute('dir');
|
48
48
|
};
|
49
49
|
}, [className, dir, element, focusVisibleRef]);
|
50
50
|
} else {
|
@@ -59,7 +59,7 @@ export const usePortalMountNode = options => {
|
|
59
59
|
}
|
60
60
|
// Force replace all classes
|
61
61
|
element.className = className;
|
62
|
-
element.setAttribute(
|
62
|
+
element.setAttribute('dir', dir);
|
63
63
|
focusVisibleRef.current = element;
|
64
64
|
}, [className, dir, element, focusVisibleRef]);
|
65
65
|
}
|
package/lib/index.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
export { Portal, renderPortal_unstable, usePortal_unstable } from
|
2
|
-
export { elementContains, setVirtualParent } from
|
1
|
+
export { Portal, renderPortal_unstable, usePortal_unstable } from './components/Portal/index';
|
2
|
+
export { elementContains, setVirtualParent } from './virtualParent/index';
|
3
3
|
//# sourceMappingURL=index.js.map
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { getParent } from
|
1
|
+
import { getParent } from './getParent';
|
2
2
|
/**
|
3
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
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { isVirtualElement } from
|
1
|
+
import { isVirtualElement } from './isVirtualElement';
|
2
2
|
/**
|
3
3
|
* Gets the virtual parent given the child element, if it exists.
|
4
4
|
*/
|
@@ -19,6 +19,6 @@ export function getParent(child, options = {}) {
|
|
19
19
|
return virtualParent;
|
20
20
|
}
|
21
21
|
}
|
22
|
-
return child
|
22
|
+
return (child === null || child === void 0 ? void 0 : child.parentNode) || null;
|
23
23
|
}
|
24
24
|
//# sourceMappingURL=getParent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["isVirtualElement","getVirtualParent","child","_virtual","parent","getParent","options","skipVirtual","virtualParent","parentNode"],"sources":["../../src/virtualParent/getParent.ts"],"sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n\ntype GetParentOptions = {\n /**\n * Indicates if getParent() should ignore a virtual parent.\n */\n skipVirtual?: boolean;\n};\n\n/**\n * Gets the virtual parent given the child element, if it exists.\n */\nfunction getVirtualParent(child: Node): Node | null {\n return isVirtualElement(child) ? child._virtual.parent || null : null;\n}\n\n/**\n * Gets the element which is the parent of a given element.\n * This method prefers the virtual parent over real DOM parent when present.\n */\nexport function getParent(child: Node | null, options: GetParentOptions = {}): Node | null {\n if (!child) {\n return null;\n }\n\n if (!options.skipVirtual) {\n const virtualParent = getVirtualParent(child);\n\n if (virtualParent) {\n return virtualParent;\n }\n }\n\n return child?.parentNode || null;\n}\n"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ;AASjC;;;AAGA,SAASC,iBAAiBC,KAAW,EAAe;EAClD,OAAOF,gBAAA,CAAiBE,KAAA,IAASA,KAAA,CAAMC,QAAQ,CAACC,MAAM,IAAI,IAAI,GAAG,IAAI;AACvE;AAEA;;;;AAIA,OAAO,SAASC,UAAUH,KAAkB,EAAEI,OAAA,GAA4B,CAAC,CAAC,EAAe;EACzF,IAAI,CAACJ,KAAA,EAAO;IACV,OAAO,IAAI;EACb;EAEA,IAAI,CAACI,OAAA,CAAQC,WAAW,EAAE;IACxB,MAAMC,aAAA,GAAgBP,gBAAA,CAAiBC,KAAA;IAEvC,IAAIM,aAAA,EAAe;MACjB,OAAOA,aAAA;IACT;EACF;EAEA,
|
1
|
+
{"version":3,"names":["isVirtualElement","getVirtualParent","child","_virtual","parent","getParent","options","skipVirtual","virtualParent","parentNode"],"sources":["../../src/virtualParent/getParent.ts"],"sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n\ntype GetParentOptions = {\n /**\n * Indicates if getParent() should ignore a virtual parent.\n */\n skipVirtual?: boolean;\n};\n\n/**\n * Gets the virtual parent given the child element, if it exists.\n */\nfunction getVirtualParent(child: Node): Node | null {\n return isVirtualElement(child) ? child._virtual.parent || null : null;\n}\n\n/**\n * Gets the element which is the parent of a given element.\n * This method prefers the virtual parent over real DOM parent when present.\n */\nexport function getParent(child: Node | null, options: GetParentOptions = {}): Node | null {\n if (!child) {\n return null;\n }\n\n if (!options.skipVirtual) {\n const virtualParent = getVirtualParent(child);\n\n if (virtualParent) {\n return virtualParent;\n }\n }\n\n return child?.parentNode || null;\n}\n"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ;AASjC;;;AAGA,SAASC,iBAAiBC,KAAW,EAAe;EAClD,OAAOF,gBAAA,CAAiBE,KAAA,IAASA,KAAA,CAAMC,QAAQ,CAACC,MAAM,IAAI,IAAI,GAAG,IAAI;AACvE;AAEA;;;;AAIA,OAAO,SAASC,UAAUH,KAAkB,EAAEI,OAAA,GAA4B,CAAC,CAAC,EAAe;EACzF,IAAI,CAACJ,KAAA,EAAO;IACV,OAAO,IAAI;EACb;EAEA,IAAI,CAACI,OAAA,CAAQC,WAAW,EAAE;IACxB,MAAMC,aAAA,GAAgBP,gBAAA,CAAiBC,KAAA;IAEvC,IAAIM,aAAA,EAAe;MACjB,OAAOA,aAAA;IACT;EACF;EAEA,OAAO,CAAAN,KAAA,aAAAA,KAAA,uBAAAA,KAAA,CAAOO,UAAU,KAAI,IAAI;AAClC"}
|
@@ -1,3 +1,3 @@
|
|
1
|
-
export * from
|
2
|
-
export * from
|
1
|
+
export * from './elementContains';
|
2
|
+
export * from './setVirtualParent';
|
3
3
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../lib/Portal.js"],"sourcesContent":["export * from
|
1
|
+
{"version":3,"sources":["../lib/Portal.js"],"sourcesContent":["export * from './components/Portal/index';\n//# sourceMappingURL=Portal.js.map"],"names":[],"mappings":";;;;;oBAAc;CACd,kCAAkC"}
|
@@ -14,6 +14,6 @@ const Portal = (props)=>{
|
|
14
14
|
const state = (0, _usePortal.usePortal_unstable)(props);
|
15
15
|
return (0, _renderPortal.renderPortal_unstable)(state);
|
16
16
|
};
|
17
|
-
Portal.displayName =
|
17
|
+
Portal.displayName = 'Portal'; //# sourceMappingURL=Portal.js.map
|
18
18
|
|
19
19
|
//# sourceMappingURL=Portal.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../lib/components/Portal/Portal.js"],"sourcesContent":["import * as React from
|
1
|
+
{"version":3,"sources":["../../../lib/components/Portal/Portal.js"],"sourcesContent":["import * as React from 'react';\nimport { usePortal_unstable } from './usePortal';\nimport { renderPortal_unstable } from './renderPortal';\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 = props => {\n const state = usePortal_unstable(props);\n return renderPortal_unstable(state);\n};\nPortal.displayName = 'Portal';\n//# sourceMappingURL=Portal.js.map"],"names":["Portal","props","state","usePortal_unstable","renderPortal_unstable","displayName"],"mappings":";;;;+BAOaA;;aAAAA;;;6DAPU;2BACY;8BACG;AAK/B,MAAMA,SAASC,CAAAA,QAAS;IAC7B,MAAMC,QAAQC,IAAAA,6BAAkB,EAACF;IACjC,OAAOG,IAAAA,mCAAqB,EAACF;AAC/B;AACAF,OAAOK,WAAW,GAAG,UACrB,kCAAkC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../lib/components/Portal/Portal.types.js"],"sourcesContent":["import * as React from
|
1
|
+
{"version":3,"sources":["../../../lib/components/Portal/Portal.types.js"],"sourcesContent":["import * as React from 'react';\n//# sourceMappingURL=Portal.types.js.map"],"names":[],"mappings":";;;;;6DAAuB;CACvB,wCAAwC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../lib/components/Portal/index.js"],"sourcesContent":["export * from
|
1
|
+
{"version":3,"sources":["../../../lib/components/Portal/index.js"],"sourcesContent":["export * from './Portal';\nexport * from './Portal.types';\nexport * from './renderPortal';\nexport * from './usePortal';\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;;oBAAc;oBACA;oBACA;oBACA;CACd,iCAAiC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../lib/components/Portal/renderPortal.js"],"sourcesContent":["import * as ReactDOM from
|
1
|
+
{"version":3,"sources":["../../../lib/components/Portal/renderPortal.js"],"sourcesContent":["import * as ReactDOM from 'react-dom';\nimport * as React from 'react';\n/**\n * Render the final JSX of Portal\n */\nexport const renderPortal_unstable = state => {\n return /*#__PURE__*/React.createElement(\"span\", {\n hidden: true,\n ref: state.virtualParentRootRef\n }, state.mountNode && /*#__PURE__*/ReactDOM.createPortal(state.children, state.mountNode));\n};\n//# sourceMappingURL=renderPortal.js.map"],"names":["renderPortal_unstable","state","React","createElement","hidden","ref","virtualParentRootRef","mountNode","ReactDOM","createPortal","children"],"mappings":";;;;+BAKaA;;aAAAA;;;gEALa;6DACH;AAIhB,MAAMA,wBAAwBC,CAAAA,QAAS;IAC5C,OAAO,WAAW,GAAEC,OAAMC,aAAa,CAAC,QAAQ;QAC9CC,QAAQ,IAAI;QACZC,KAAKJ,MAAMK,oBAAoB;IACjC,GAAGL,MAAMM,SAAS,IAAI,WAAW,GAAEC,UAASC,YAAY,CAACR,MAAMS,QAAQ,EAAET,MAAMM,SAAS;AAC1F,GACA,wCAAwC"}
|
@@ -23,7 +23,7 @@ function toMountNodeProps(mountNode) {
|
|
23
23
|
element: mountNode
|
24
24
|
};
|
25
25
|
}
|
26
|
-
if (typeof mountNode ===
|
26
|
+
if (typeof mountNode === 'object') {
|
27
27
|
if (mountNode === null) {
|
28
28
|
return {
|
29
29
|
element: null
|
@@ -42,7 +42,7 @@ const usePortal_unstable = (props)=>{
|
|
42
42
|
});
|
43
43
|
const state = {
|
44
44
|
children: props.children,
|
45
|
-
mountNode: element
|
45
|
+
mountNode: element !== null && element !== void 0 ? element : fallbackElement,
|
46
46
|
virtualParentRootRef
|
47
47
|
};
|
48
48
|
_react.useEffect(()=>{
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../lib/components/Portal/usePortal.js"],"sourcesContent":["import { isHTMLElement } from
|
1
|
+
{"version":3,"sources":["../../../lib/components/Portal/usePortal.js"],"sourcesContent":["import { isHTMLElement } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport { setVirtualParent } from '../../virtualParent/index';\nimport { usePortalMountNode } from './usePortalMountNode';\nexport function toMountNodeProps(mountNode) {\n if (isHTMLElement(mountNode)) {\n return {\n element: mountNode\n };\n }\n if (typeof mountNode === 'object') {\n if (mountNode === null) {\n return {\n element: null\n };\n }\n return mountNode;\n }\n return {};\n}\n/**\n * Create the state required to render Portal.\n *\n * The returned state can be modified with hooks such as usePortalStyles, before being passed to renderPortal_unstable.\n *\n * @param props - props from this instance of Portal\n */\nexport const usePortal_unstable = props => {\n const {\n element,\n className\n } = toMountNodeProps(props.mountNode);\n const virtualParentRootRef = React.useRef(null);\n const fallbackElement = usePortalMountNode({\n disabled: !!element,\n className\n });\n const state = {\n children: props.children,\n mountNode: element !== null && element !== void 0 ? element : fallbackElement,\n virtualParentRootRef\n };\n React.useEffect(() => {\n if (state.virtualParentRootRef.current && state.mountNode) {\n setVirtualParent(state.mountNode, state.virtualParentRootRef.current);\n }\n return () => {\n if (state.mountNode) {\n setVirtualParent(state.mountNode, undefined);\n }\n };\n }, [state.virtualParentRootRef, state.mountNode]);\n return state;\n};\n//# sourceMappingURL=usePortal.js.map"],"names":["toMountNodeProps","usePortal_unstable","mountNode","isHTMLElement","element","props","className","virtualParentRootRef","React","useRef","fallbackElement","usePortalMountNode","disabled","state","children","useEffect","current","setVirtualParent","undefined"],"mappings":";;;;;;;;;;;IAIgBA,gBAAgB,MAAhBA;IAuBHC,kBAAkB,MAAlBA;;;gCA3BiB;6DACP;uBACU;oCACE;AAC5B,SAASD,iBAAiBE,SAAS,EAAE;IAC1C,IAAIC,IAAAA,6BAAa,EAACD,YAAY;QAC5B,OAAO;YACLE,SAASF;QACX;IACF,CAAC;IACD,IAAI,OAAOA,cAAc,UAAU;QACjC,IAAIA,cAAc,IAAI,EAAE;YACtB,OAAO;gBACLE,SAAS,IAAI;YACf;QACF,CAAC;QACD,OAAOF;IACT,CAAC;IACD,OAAO,CAAC;AACV;AAQO,MAAMD,qBAAqBI,CAAAA,QAAS;IACzC,MAAM,EACJD,QAAO,EACPE,UAAS,EACV,GAAGN,iBAAiBK,MAAMH,SAAS;IACpC,MAAMK,uBAAuBC,OAAMC,MAAM,CAAC,IAAI;IAC9C,MAAMC,kBAAkBC,IAAAA,sCAAkB,EAAC;QACzCC,UAAU,CAAC,CAACR;QACZE;IACF;IACA,MAAMO,QAAQ;QACZC,UAAUT,MAAMS,QAAQ;QACxBZ,WAAWE,YAAY,IAAI,IAAIA,YAAY,KAAK,IAAIA,UAAUM,eAAe;QAC7EH;IACF;IACAC,OAAMO,SAAS,CAAC,IAAM;QACpB,IAAIF,MAAMN,oBAAoB,CAACS,OAAO,IAAIH,MAAMX,SAAS,EAAE;YACzDe,IAAAA,uBAAgB,EAACJ,MAAMX,SAAS,EAAEW,MAAMN,oBAAoB,CAACS,OAAO;QACtE,CAAC;QACD,OAAO,IAAM;YACX,IAAIH,MAAMX,SAAS,EAAE;gBACnBe,IAAAA,uBAAgB,EAACJ,MAAMX,SAAS,EAAEgB;YACpC,CAAC;QACH;IACF,GAAG;QAACL,MAAMN,oBAAoB;QAAEM,MAAMX,SAAS;KAAC;IAChD,OAAOW;AACT,GACA,qCAAqC"}
|
@@ -12,7 +12,7 @@ const _reactSharedContexts = require("@fluentui/react-shared-contexts");
|
|
12
12
|
const _react1 = require("@griffel/react");
|
13
13
|
const _reactTabster = require("@fluentui/react-tabster");
|
14
14
|
const _useDisposable = require("use-disposable");
|
15
|
-
const useInsertionEffect = _react[
|
15
|
+
const useInsertionEffect = _react['useInsertion' + 'Effect'];
|
16
16
|
const useStyles = /*#__PURE__*/ (0, _react1["__styles"])({
|
17
17
|
root: {
|
18
18
|
qhf8xq: "f10pi13n",
|
@@ -37,7 +37,7 @@ const usePortalMountNode = (options)=>{
|
|
37
37
|
()=>null
|
38
38
|
];
|
39
39
|
}
|
40
|
-
const newElement = targetDocument.createElement(
|
40
|
+
const newElement = targetDocument.createElement('div');
|
41
41
|
targetDocument.body.appendChild(newElement);
|
42
42
|
return [
|
43
43
|
newElement,
|
@@ -52,13 +52,13 @@ const usePortalMountNode = (options)=>{
|
|
52
52
|
if (!element) {
|
53
53
|
return;
|
54
54
|
}
|
55
|
-
const classesToApply = className.split(
|
55
|
+
const classesToApply = className.split(' ').filter(Boolean);
|
56
56
|
element.classList.add(...classesToApply);
|
57
|
-
element.setAttribute(
|
57
|
+
element.setAttribute('dir', dir);
|
58
58
|
focusVisibleRef.current = element;
|
59
59
|
return ()=>{
|
60
60
|
element.classList.remove(...classesToApply);
|
61
|
-
element.removeAttribute(
|
61
|
+
element.removeAttribute('dir');
|
62
62
|
};
|
63
63
|
}, [
|
64
64
|
className,
|
@@ -78,7 +78,7 @@ const usePortalMountNode = (options)=>{
|
|
78
78
|
}
|
79
79
|
// Force replace all classes
|
80
80
|
element.className = className;
|
81
|
-
element.setAttribute(
|
81
|
+
element.setAttribute('dir', dir);
|
82
82
|
focusVisibleRef.current = element;
|
83
83
|
}, [
|
84
84
|
className,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../lib/components/Portal/usePortalMountNode.js"],"sourcesContent":["import * as React from
|
1
|
+
{"version":3,"sources":["../../../lib/components/Portal/usePortalMountNode.js"],"sourcesContent":["import * as React from 'react';\nimport { useThemeClassName_unstable as useThemeClassName, useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { __styles, mergeClasses } from '@griffel/react';\nimport { useFocusVisible } from '@fluentui/react-tabster';\nimport { useDisposable } from 'use-disposable';\nconst useInsertionEffect = React['useInsertion' + 'Effect'];\nconst useStyles = /*#__PURE__*/__styles({\n root: {\n qhf8xq: \"f10pi13n\",\n Bj3rh1h: \"f494woh\"\n }\n}, {\n d: [\".f10pi13n{position:relative;}\", \".f494woh{z-index:1000000;}\"]\n});\n/**\n * Creates a new element on a \"document.body\" to mount portals.\n */\nexport const usePortalMountNode = options => {\n const {\n targetDocument,\n dir\n } = useFluent();\n const focusVisibleRef = useFocusVisible();\n const classes = useStyles();\n const themeClassName = useThemeClassName();\n const className = mergeClasses(themeClassName, classes.root, options.className);\n const element = useDisposable(() => {\n if (targetDocument === undefined || options.disabled) {\n return [null, () => null];\n }\n const newElement = targetDocument.createElement('div');\n targetDocument.body.appendChild(newElement);\n return [newElement, () => newElement.remove()];\n }, [targetDocument]);\n if (useInsertionEffect) {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useInsertionEffect(() => {\n if (!element) {\n return;\n }\n const classesToApply = className.split(' ').filter(Boolean);\n element.classList.add(...classesToApply);\n element.setAttribute('dir', dir);\n focusVisibleRef.current = element;\n return () => {\n element.classList.remove(...classesToApply);\n element.removeAttribute('dir');\n };\n }, [className, dir, element, focusVisibleRef]);\n } else {\n // This useMemo call is intentional for React 17\n // We don't want to re-create the portal element when its attributes change.\n // This also should not be done in an effect because, changing the value of css variables\n // after initial mount can trigger interesting CSS side effects like transitions.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useMemo(() => {\n if (!element) {\n return;\n }\n // Force replace all classes\n element.className = className;\n element.setAttribute('dir', dir);\n focusVisibleRef.current = element;\n }, [className, dir, element, focusVisibleRef]);\n }\n return element;\n};\n//# sourceMappingURL=usePortalMountNode.js.map"],"names":["usePortalMountNode","useInsertionEffect","React","useStyles","__styles","root","qhf8xq","Bj3rh1h","d","options","targetDocument","dir","useFluent","focusVisibleRef","useFocusVisible","classes","themeClassName","useThemeClassName","className","mergeClasses","element","useDisposable","undefined","disabled","newElement","createElement","body","appendChild","remove","classesToApply","split","filter","Boolean","classList","add","setAttribute","current","removeAttribute","useMemo"],"mappings":";;;;+BAiBaA;;aAAAA;;;6DAjBU;qCAC0E;wBAC1D;8BACP;+BACF;AAC9B,MAAMC,qBAAqBC,MAAK,CAAC,iBAAiB,SAAS;AAC3D,MAAMC,YAAY,WAAW,GAAEC,IAAAA,mBAAQ,EAAC;IACtCC,MAAM;QACJC,QAAQ;QACRC,SAAS;IACX;AACF,GAAG;IACDC,GAAG;QAAC;QAAiC;KAA6B;AACpE;AAIO,MAAMR,qBAAqBS,CAAAA,UAAW;IAC3C,MAAM,EACJC,eAAc,EACdC,IAAG,EACJ,GAAGC,IAAAA,uCAAS;IACb,MAAMC,kBAAkBC,IAAAA,6BAAe;IACvC,MAAMC,UAAUZ;IAChB,MAAMa,iBAAiBC,IAAAA,+CAAiB;IACxC,MAAMC,YAAYC,IAAAA,oBAAY,EAACH,gBAAgBD,QAAQV,IAAI,EAAEI,QAAQS,SAAS;IAC9E,MAAME,UAAUC,IAAAA,4BAAa,EAAC,IAAM;QAClC,IAAIX,mBAAmBY,aAAab,QAAQc,QAAQ,EAAE;YACpD,OAAO;gBAAC,IAAI;gBAAE,IAAM,IAAI;aAAC;QAC3B,CAAC;QACD,MAAMC,aAAad,eAAee,aAAa,CAAC;QAChDf,eAAegB,IAAI,CAACC,WAAW,CAACH;QAChC,OAAO;YAACA;YAAY,IAAMA,WAAWI,MAAM;SAAG;IAChD,GAAG;QAAClB;KAAe;IACnB,IAAIT,oBAAoB;QACtB,sDAAsD;QACtDA,mBAAmB,IAAM;YACvB,IAAI,CAACmB,SAAS;gBACZ;YACF,CAAC;YACD,MAAMS,iBAAiBX,UAAUY,KAAK,CAAC,KAAKC,MAAM,CAACC;YACnDZ,QAAQa,SAAS,CAACC,GAAG,IAAIL;YACzBT,QAAQe,YAAY,CAAC,OAAOxB;YAC5BE,gBAAgBuB,OAAO,GAAGhB;YAC1B,OAAO,IAAM;gBACXA,QAAQa,SAAS,CAACL,MAAM,IAAIC;gBAC5BT,QAAQiB,eAAe,CAAC;YAC1B;QACF,GAAG;YAACnB;YAAWP;YAAKS;YAASP;SAAgB;IAC/C,OAAO;QACL,gDAAgD;QAChD,4EAA4E;QAC5E,yFAAyF;QACzF,iFAAiF;QACjF,sDAAsD;QACtDX,OAAMoC,OAAO,CAAC,IAAM;YAClB,IAAI,CAAClB,SAAS;gBACZ;YACF,CAAC;YACD,4BAA4B;YAC5BA,QAAQF,SAAS,GAAGA;YACpBE,QAAQe,YAAY,CAAC,OAAOxB;YAC5BE,gBAAgBuB,OAAO,GAAGhB;QAC5B,GAAG;YAACF;YAAWP;YAAKS;YAASP;SAAgB;IAC/C,CAAC;IACD,OAAOO;AACT,GACA,8CAA8C"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../lib/index.js"],"sourcesContent":["export { Portal, renderPortal_unstable, usePortal_unstable } from
|
1
|
+
{"version":3,"sources":["../lib/index.js"],"sourcesContent":["export { Portal, renderPortal_unstable, usePortal_unstable } from './components/Portal/index';\nexport { elementContains, setVirtualParent } from './virtualParent/index';\n//# sourceMappingURL=index.js.map"],"names":["Portal","renderPortal_unstable","usePortal_unstable","elementContains","setVirtualParent"],"mappings":";;;;;;;;;;;IAASA,MAAM,MAANA,aAAM;IAAEC,qBAAqB,MAArBA,4BAAqB;IAAEC,kBAAkB,MAAlBA,yBAAkB;IACjDC,eAAe,MAAfA,uBAAe;IAAEC,gBAAgB,MAAhBA,wBAAgB;;uBADwB;wBAChB;CAClD,iCAAiC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../lib/virtualParent/elementContains.js"],"sourcesContent":["import { getParent } from
|
1
|
+
{"version":3,"sources":["../../lib/virtualParent/elementContains.js"],"sourcesContent":["import { getParent } from './getParent';\n/**\n * Similar functionality to `element.contains` DOM API for use without of order DOM elements that\n * checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent\n *\n * @returns true if the child can find the parent in its virtual hierarchy\n */\nexport function elementContains(parent, child) {\n if (!parent || !child) {\n return false;\n }\n if (parent === child) {\n return true;\n } else {\n // Tracks references of nodes that have been visited to prevent infinite loops\n const set = new WeakSet();\n while (child) {\n const nextParent = getParent(child, {\n skipVirtual: set.has(child)\n });\n set.add(child);\n if (nextParent === parent) {\n return true;\n }\n child = nextParent;\n }\n }\n return false;\n}\n//# sourceMappingURL=elementContains.js.map"],"names":["elementContains","parent","child","set","WeakSet","nextParent","getParent","skipVirtual","has","add"],"mappings":";;;;+BAOgBA;;aAAAA;;2BAPU;AAOnB,SAASA,gBAAgBC,MAAM,EAAEC,KAAK,EAAE;IAC7C,IAAI,CAACD,UAAU,CAACC,OAAO;QACrB,OAAO,KAAK;IACd,CAAC;IACD,IAAID,WAAWC,OAAO;QACpB,OAAO,IAAI;IACb,OAAO;QACL,8EAA8E;QAC9E,MAAMC,MAAM,IAAIC;QAChB,MAAOF,MAAO;YACZ,MAAMG,aAAaC,IAAAA,oBAAS,EAACJ,OAAO;gBAClCK,aAAaJ,IAAIK,GAAG,CAACN;YACvB;YACAC,IAAIM,GAAG,CAACP;YACR,IAAIG,eAAeJ,QAAQ;gBACzB,OAAO,IAAI;YACb,CAAC;YACDC,QAAQG;QACV;IACF,CAAC;IACD,OAAO,KAAK;AACd,EACA,2CAA2C"}
|
@@ -22,7 +22,7 @@ function getParent(child, options = {}) {
|
|
22
22
|
return virtualParent;
|
23
23
|
}
|
24
24
|
}
|
25
|
-
return child
|
25
|
+
return (child === null || child === void 0 ? void 0 : child.parentNode) || null;
|
26
26
|
} //# sourceMappingURL=getParent.js.map
|
27
27
|
|
28
28
|
//# sourceMappingURL=getParent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../lib/virtualParent/getParent.js"],"sourcesContent":["import { isVirtualElement } from
|
1
|
+
{"version":3,"sources":["../../lib/virtualParent/getParent.js"],"sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n/**\n * Gets the virtual parent given the child element, if it exists.\n */\nfunction getVirtualParent(child) {\n return isVirtualElement(child) ? child._virtual.parent || null : null;\n}\n/**\n * Gets the element which is the parent of a given element.\n * This method prefers the virtual parent over real DOM parent when present.\n */\nexport function getParent(child, options = {}) {\n if (!child) {\n return null;\n }\n if (!options.skipVirtual) {\n const virtualParent = getVirtualParent(child);\n if (virtualParent) {\n return virtualParent;\n }\n }\n return (child === null || child === void 0 ? void 0 : child.parentNode) || null;\n}\n//# sourceMappingURL=getParent.js.map"],"names":["getParent","getVirtualParent","child","isVirtualElement","_virtual","parent","options","skipVirtual","virtualParent","parentNode"],"mappings":";;;;+BAWgBA;;aAAAA;;kCAXiB;AACjC;;CAEC,GACD,SAASC,iBAAiBC,KAAK,EAAE;IAC/B,OAAOC,IAAAA,kCAAgB,EAACD,SAASA,MAAME,QAAQ,CAACC,MAAM,IAAI,IAAI,GAAG,IAAI;AACvE;AAKO,SAASL,UAAUE,KAAK,EAAEI,UAAU,CAAC,CAAC,EAAE;IAC7C,IAAI,CAACJ,OAAO;QACV,OAAO,IAAI;IACb,CAAC;IACD,IAAI,CAACI,QAAQC,WAAW,EAAE;QACxB,MAAMC,gBAAgBP,iBAAiBC;QACvC,IAAIM,eAAe;YACjB,OAAOA;QACT,CAAC;IACH,CAAC;IACD,OAAO,AAACN,CAAAA,UAAU,IAAI,IAAIA,UAAU,KAAK,IAAI,KAAK,IAAIA,MAAMO,UAAU,AAAD,KAAM,IAAI;AACjF,EACA,qCAAqC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../lib/virtualParent/index.js"],"sourcesContent":["export * from
|
1
|
+
{"version":3,"sources":["../../lib/virtualParent/index.js"],"sourcesContent":["export * from './elementContains';\nexport * from './setVirtualParent';\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;;oBAAc;oBACA;CACd,iCAAiC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-portal",
|
3
|
-
"version": "0.0.0-nightly-
|
3
|
+
"version": "0.0.0-nightly-20230322-0439.1",
|
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,12 +31,12 @@
|
|
31
31
|
"@fluentui/scripts-tasks": "*"
|
32
32
|
},
|
33
33
|
"dependencies": {
|
34
|
-
"@fluentui/react-shared-contexts": "0.0.0-nightly-
|
35
|
-
"@fluentui/react-tabster": "0.0.0-nightly-
|
36
|
-
"@fluentui/react-utilities": "0.0.0-nightly-
|
34
|
+
"@fluentui/react-shared-contexts": "0.0.0-nightly-20230322-0439.1",
|
35
|
+
"@fluentui/react-tabster": "0.0.0-nightly-20230322-0439.1",
|
36
|
+
"@fluentui/react-utilities": "0.0.0-nightly-20230322-0439.1",
|
37
37
|
"@griffel/react": "^1.5.2",
|
38
|
-
"
|
39
|
-
"
|
38
|
+
"@swc/helpers": "^0.4.14",
|
39
|
+
"use-disposable": "^1.0.1"
|
40
40
|
},
|
41
41
|
"peerDependencies": {
|
42
42
|
"@types/react": ">=16.8.0 <19.0.0",
|
@@ -48,6 +48,7 @@
|
|
48
48
|
"exports": {
|
49
49
|
".": {
|
50
50
|
"types": "./dist/index.d.ts",
|
51
|
+
"node": "./lib-commonjs/index.js",
|
51
52
|
"import": "./lib/index.js",
|
52
53
|
"require": "./lib-commonjs/index.js"
|
53
54
|
},
|