@fluentui/react-portal 9.2.1 → 9.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.swcrc +30 -0
- package/CHANGELOG.json +40 -1
- package/CHANGELOG.md +15 -2
- package/lib/Portal.js.map +1 -1
- package/lib/components/Portal/Portal.js +1 -0
- package/lib/components/Portal/Portal.js.map +1 -1
- package/lib/components/Portal/Portal.types.js +1 -1
- package/lib/components/Portal/Portal.types.js.map +1 -1
- package/lib/components/Portal/index.js.map +1 -1
- package/lib/components/Portal/renderPortal.js.map +1 -1
- package/lib/components/Portal/usePortal.js.map +1 -1
- package/lib/components/Portal/usePortalMountNode.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/virtualParent/elementContains.js.map +1 -1
- package/lib/virtualParent/getParent.js.map +1 -1
- package/lib/virtualParent/index.js.map +1 -1
- package/lib/virtualParent/isVirtualElement.js +1 -2
- package/lib/virtualParent/isVirtualElement.js.map +1 -1
- package/lib/virtualParent/setVirtualParent.js +1 -2
- package/lib/virtualParent/setVirtualParent.js.map +1 -1
- package/lib/virtualParent/types.js.map +1 -1
- package/lib-commonjs/Portal.js +5 -4
- package/lib-commonjs/Portal.js.map +1 -1
- package/lib-commonjs/components/Portal/Portal.js +14 -14
- package/lib-commonjs/components/Portal/Portal.js.map +1 -1
- package/lib-commonjs/components/Portal/Portal.types.js +5 -2
- package/lib-commonjs/components/Portal/Portal.types.js.map +1 -1
- package/lib-commonjs/components/Portal/index.js +8 -7
- package/lib-commonjs/components/Portal/index.js.map +1 -1
- package/lib-commonjs/components/Portal/renderPortal.js +15 -15
- package/lib-commonjs/components/Portal/renderPortal.js.map +1 -1
- package/lib-commonjs/components/Portal/usePortal.js +56 -55
- package/lib-commonjs/components/Portal/usePortal.js.map +1 -1
- package/lib-commonjs/components/Portal/usePortalMountNode.js +86 -68
- package/lib-commonjs/components/Portal/usePortalMountNode.js.map +1 -1
- package/lib-commonjs/index.js +17 -34
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/virtualParent/elementContains.js +26 -30
- package/lib-commonjs/virtualParent/elementContains.js.map +1 -1
- package/lib-commonjs/virtualParent/getParent.js +19 -22
- package/lib-commonjs/virtualParent/getParent.js.map +1 -1
- package/lib-commonjs/virtualParent/index.js +6 -5
- package/lib-commonjs/virtualParent/index.js.map +1 -1
- package/lib-commonjs/virtualParent/isVirtualElement.js +11 -10
- package/lib-commonjs/virtualParent/isVirtualElement.js.map +1 -1
- package/lib-commonjs/virtualParent/setVirtualParent.js +18 -17
- package/lib-commonjs/virtualParent/setVirtualParent.js.map +1 -1
- package/lib-commonjs/virtualParent/types.js +3 -2
- package/lib-commonjs/virtualParent/types.js.map +1 -1
- package/package.json +7 -6
- package/lib-amd/components/Portal/Portal.js +0 -16
- package/lib-amd/components/Portal/Portal.js.map +0 -1
- package/lib-amd/components/Portal/Portal.types.js +0 -5
- package/lib-amd/components/Portal/Portal.types.js.map +0 -1
- package/lib-amd/components/Portal/index.js +0 -9
- package/lib-amd/components/Portal/index.js.map +0 -1
- package/lib-amd/components/Portal/renderPortal.js +0 -13
- package/lib-amd/components/Portal/renderPortal.js.map +0 -1
- package/lib-amd/components/Portal/usePortal.js +0 -48
- package/lib-amd/components/Portal/usePortal.js.map +0 -1
- package/lib-amd/components/Portal/usePortalMountNode.js +0 -67
- package/lib-amd/components/Portal/usePortalMountNode.js.map +0 -1
- package/lib-amd/index.js +0 -11
- package/lib-amd/index.js.map +0 -1
- package/lib-amd/virtualParent/elementContains.js +0 -36
- package/lib-amd/virtualParent/elementContains.js.map +0 -1
- package/lib-amd/virtualParent/getParent.js +0 -30
- package/lib-amd/virtualParent/getParent.js.map +0 -1
- package/lib-amd/virtualParent/index.js +0 -7
- package/lib-amd/virtualParent/index.js.map +0 -1
- package/lib-amd/virtualParent/isVirtualElement.js +0 -13
- package/lib-amd/virtualParent/isVirtualElement.js.map +0 -1
- package/lib-amd/virtualParent/setVirtualParent.js +0 -23
- package/lib-amd/virtualParent/setVirtualParent.js.map +0 -1
- package/lib-amd/virtualParent/types.js +0 -5
- package/lib-amd/virtualParent/types.js.map +0 -1
package/.swcrc
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://json.schemastore.org/swcrc",
|
3
|
+
"exclude": [
|
4
|
+
"/testing",
|
5
|
+
"/**/*.cy.ts",
|
6
|
+
"/**/*.cy.tsx",
|
7
|
+
"/**/*.spec.ts",
|
8
|
+
"/**/*.spec.tsx",
|
9
|
+
"/**/*.test.ts",
|
10
|
+
"/**/*.test.tsx"
|
11
|
+
],
|
12
|
+
"jsc": {
|
13
|
+
"parser": {
|
14
|
+
"syntax": "typescript",
|
15
|
+
"tsx": true,
|
16
|
+
"decorators": false,
|
17
|
+
"dynamicImport": false
|
18
|
+
},
|
19
|
+
"externalHelpers": true,
|
20
|
+
"transform": {
|
21
|
+
"react": {
|
22
|
+
"runtime": "classic",
|
23
|
+
"useSpread": true
|
24
|
+
}
|
25
|
+
},
|
26
|
+
"target": "es2019"
|
27
|
+
},
|
28
|
+
"minify": false,
|
29
|
+
"sourceMaps": true
|
30
|
+
}
|
package/CHANGELOG.json
CHANGED
@@ -2,7 +2,46 @@
|
|
2
2
|
"name": "@fluentui/react-portal",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
5
|
+
"date": "Tue, 21 Mar 2023 21:18:56 GMT",
|
6
|
+
"tag": "@fluentui/react-portal_v9.2.2",
|
7
|
+
"version": "9.2.2",
|
8
|
+
"comments": {
|
9
|
+
"patch": [
|
10
|
+
{
|
11
|
+
"author": "tristan.watanabe@gmail.com",
|
12
|
+
"package": "@fluentui/react-portal",
|
13
|
+
"commit": "2fac1a139149bd13b76b1306207bc988dca9c72c",
|
14
|
+
"comment": "chore: migrate to swc transpilation approach."
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"author": "tristan.watanabe@gmail.com",
|
18
|
+
"package": "@fluentui/react-portal",
|
19
|
+
"commit": "ead1c6d4c2ac3f3596b62b8cbc07b0a03041f11f",
|
20
|
+
"comment": "fix: add node field to package.json exports map."
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"author": "beachball",
|
24
|
+
"package": "@fluentui/react-portal",
|
25
|
+
"comment": "Bump @fluentui/react-shared-contexts to v9.3.2",
|
26
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"author": "beachball",
|
30
|
+
"package": "@fluentui/react-portal",
|
31
|
+
"comment": "Bump @fluentui/react-tabster to v9.6.1",
|
32
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"author": "beachball",
|
36
|
+
"package": "@fluentui/react-portal",
|
37
|
+
"comment": "Bump @fluentui/react-utilities to v9.7.2",
|
38
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
39
|
+
}
|
40
|
+
]
|
41
|
+
}
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"date": "Thu, 16 Mar 2023 14:36:59 GMT",
|
6
45
|
"tag": "@fluentui/react-portal_v9.2.1",
|
7
46
|
"version": "9.2.1",
|
8
47
|
"comments": {
|
package/CHANGELOG.md
CHANGED
@@ -1,12 +1,25 @@
|
|
1
1
|
# Change Log - @fluentui/react-portal
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Tue, 21 Mar 2023 21:18:56 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
+
## [9.2.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-portal_v9.2.2)
|
8
|
+
|
9
|
+
Tue, 21 Mar 2023 21:18:56 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-portal_v9.2.1..@fluentui/react-portal_v9.2.2)
|
11
|
+
|
12
|
+
### Patches
|
13
|
+
|
14
|
+
- chore: migrate to swc transpilation approach. ([PR #27250](https://github.com/microsoft/fluentui/pull/27250) by tristan.watanabe@gmail.com)
|
15
|
+
- fix: add node field to package.json exports map. ([PR #27154](https://github.com/microsoft/fluentui/pull/27154) by tristan.watanabe@gmail.com)
|
16
|
+
- Bump @fluentui/react-shared-contexts to v9.3.2 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
17
|
+
- Bump @fluentui/react-tabster to v9.6.1 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
18
|
+
- Bump @fluentui/react-utilities to v9.7.2 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
19
|
+
|
7
20
|
## [9.2.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-portal_v9.2.1)
|
8
21
|
|
9
|
-
Thu, 16 Mar 2023 14:
|
22
|
+
Thu, 16 Mar 2023 14:36:59 GMT
|
10
23
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-portal_v9.2.0..@fluentui/react-portal_v9.2.1)
|
11
24
|
|
12
25
|
### Patches
|
package/lib/Portal.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":[],"sources":["../src/Portal.ts"],"sourcesContent":["export * from './components/Portal/index';\n"],"mappings":"AAAA,cAAc"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["usePortal_unstable","renderPortal_unstable","Portal","props","state","displayName"],"sources":["
|
1
|
+
{"version":3,"names":["React","usePortal_unstable","renderPortal_unstable","Portal","props","state","displayName"],"sources":["../../../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"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAEvB,SAASC,kBAAkB,QAAQ;AACnC,SAASC,qBAAqB,QAAQ;AAGtC;;;;AAIA,OAAO,MAAMC,MAAA,GAAgCC,KAAA,IAAS;EACpD,MAAMC,KAAA,GAAQJ,kBAAA,CAAmBG,KAAA;EAEjC,OAAOF,qBAAA,CAAsBG,KAAA;AAC/B;AAEAF,MAAA,CAAOG,WAAW,GAAG"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
|
1
|
+
import * as React from 'react';
|
2
2
|
//# sourceMappingURL=Portal.types.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["React"],"sources":["../../../src/components/Portal/Portal.types.ts"],"sourcesContent":["import * as React from 'react';\n\nexport type PortalProps = {\n /**\n * React children\n */\n children?: React.ReactNode;\n\n /**\n * Where the portal children are mounted on DOM\n *\n * @default a new element on document.body without any styling\n */\n mountNode?: HTMLElement | null | { element?: HTMLElement | null; className?: string };\n};\n\nexport type PortalState = Pick<PortalProps, 'children'> & {\n mountNode: HTMLElement | null | undefined;\n\n /**\n * Ref to the root span element as virtual parent\n */\n virtualParentRootRef: React.MutableRefObject<HTMLSpanElement | null>;\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/components/Portal/index.ts"],"sourcesContent":["export * from './Portal';\nexport * from './Portal.types';\nexport * from './renderPortal';\nexport * from './usePortal';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["ReactDOM","React","renderPortal_unstable","state","createElement","hidden","ref","virtualParentRootRef","mountNode","createPortal","children"],"sources":["
|
1
|
+
{"version":3,"names":["ReactDOM","React","renderPortal_unstable","state","createElement","hidden","ref","virtualParentRootRef","mountNode","createPortal","children"],"sources":["../../../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"],"mappings":"AAAA,YAAYA,QAAA,MAAc;AAC1B,YAAYC,KAAA,MAAW;AAGvB;;;AAGA,OAAO,MAAMC,qBAAA,GAAyBC,KAAA,IAA2C;EAC/E,oBACEF,KAAA,CAAAG,aAAA,CAAC;IAAKC,MAAA,MAAM;IAACC,GAAA,EAAKH,KAAA,CAAMI;KACrBJ,KAAA,CAAMK,SAAS,iBAAIR,QAAA,CAASS,YAAY,CAACN,KAAA,CAAMO,QAAQ,EAAEP,KAAA,CAAMK,SAAS;AAG/E"}
|
@@ -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":["
|
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 +1 @@
|
|
1
|
-
{"version":3,"names":["React","useThemeClassName_unstable","useThemeClassName","useFluent_unstable","useFluent","__styles","mergeClasses","useFocusVisible","useDisposable","useInsertionEffect","useStyles","root","qhf8xq","Bj3rh1h","d","usePortalMountNode","options","targetDocument","dir","focusVisibleRef","classes","themeClassName","className","element","undefined","disabled","newElement","createElement","body","appendChild","remove","classesToApply","split","filter","Boolean","classList","add","setAttribute","current","removeAttribute","useMemo"],"sources":["
|
1
|
+
{"version":3,"names":["React","useThemeClassName_unstable","useThemeClassName","useFluent_unstable","useFluent","__styles","mergeClasses","useFocusVisible","useDisposable","useInsertionEffect","useStyles","root","qhf8xq","Bj3rh1h","d","usePortalMountNode","options","targetDocument","dir","focusVisibleRef","classes","themeClassName","className","element","undefined","disabled","newElement","createElement","body","appendChild","remove","classesToApply","split","filter","Boolean","classList","add","setAttribute","current","removeAttribute","useMemo"],"sources":["../../../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';\n\nconst useInsertionEffect = (React as never)['useInsertion' + 'Effect'] as typeof React.useLayoutEffect | undefined;\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 className?: string;\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, options.className);\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 if (useInsertionEffect) {\n // eslint-disable-next-line react-hooks/rules-of-hooks\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 } 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\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\n return element;\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SACEC,0BAAA,IAA8BC,iBAAiB,EAC/CC,kBAAA,IAAsBC,SAAS,QAC1B;AACP,SAAAC,QAAA,EAAqBC,YAAY,QAAQ;AACzC,SAASC,eAAe,QAAQ;AAChC,SAASC,aAAa,QAAQ;AAE9B,MAAMC,kBAAA,GAAqBT,KAAgB,CAAC,iBAAiB,SAAS;AAWtE,MAAMU,SAAA,gBAAYL,QAAA;EAAAM,IAAA;IAAAC,MAAA;IAAAC,OAAA;EAAA;AAAA;EAAAC,CAAA;AAAA,EAKlB;AAEA;;;AAGA,OAAO,MAAMC,kBAAA,GAAsBC,OAAA,IAA2D;EAC5F,MAAM;IAAEC,cAAA;IAAgBC;EAAG,CAAE,GAAGd,SAAA;EAChC,MAAMe,eAAA,GAAkBZ,eAAA;EACxB,MAAMa,OAAA,GAAUV,SAAA;EAChB,MAAMW,cAAA,GAAiBnB,iBAAA;EAEvB,MAAMoB,SAAA,GAAYhB,YAAA,CAAae,cAAA,EAAgBD,OAAA,CAAQT,IAAI,EAAEK,OAAA,CAAQM,SAAS;EAE9E,MAAMC,OAAA,GAAUf,aAAA,CAAc,MAAM;IAClC,IAAIS,cAAA,KAAmBO,SAAA,IAAaR,OAAA,CAAQS,QAAQ,EAAE;MACpD,OAAO,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC;IAC3B;IAEA,MAAMC,UAAA,GAAaT,cAAA,CAAeU,aAAa,CAAC;IAChDV,cAAA,CAAeW,IAAI,CAACC,WAAW,CAACH,UAAA;IAChC,OAAO,CAACA,UAAA,EAAY,MAAMA,UAAA,CAAWI,MAAM,GAAG;EAChD,GAAG,CAACb,cAAA,CAAe;EAEnB,IAAIR,kBAAA,EAAoB;IACtB;IACAA,kBAAA,CAAmB,MAAM;MACvB,IAAI,CAACc,OAAA,EAAS;QACZ;MACF;MAEA,MAAMQ,cAAA,GAAiBT,SAAA,CAAUU,KAAK,CAAC,KAAKC,MAAM,CAACC,OAAA;MAEnDX,OAAA,CAAQY,SAAS,CAACC,GAAG,IAAIL,cAAA;MACzBR,OAAA,CAAQc,YAAY,CAAC,OAAOnB,GAAA;MAC5BC,eAAA,CAAgBmB,OAAO,GAAGf,OAAA;MAE1B,OAAO,MAAM;QACXA,OAAA,CAAQY,SAAS,CAACL,MAAM,IAAIC,cAAA;QAC5BR,OAAA,CAAQgB,eAAe,CAAC;MAC1B;IACF,GAAG,CAACjB,SAAA,EAAWJ,GAAA,EAAKK,OAAA,EAASJ,eAAA,CAAgB;EAC/C,OAAO;IACL;IACA;IACA;IACA;IACA;IACAnB,KAAA,CAAMwC,OAAO,CAAC,MAAM;MAClB,IAAI,CAACjB,OAAA,EAAS;QACZ;MACF;MAEA;MACAA,OAAA,CAAQD,SAAS,GAAGA,SAAA;MACpBC,OAAA,CAAQc,YAAY,CAAC,OAAOnB,GAAA;MAC5BC,eAAA,CAAgBmB,OAAO,GAAGf,OAAA;IAC5B,GAAG,CAACD,SAAA,EAAWJ,GAAA,EAAKK,OAAA,EAASJ,eAAA,CAAgB;EAC/C;EAEA,OAAOI,OAAA;AACT"}
|
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["Portal","renderPortal_unstable","usePortal_unstable","elementContains","setVirtualParent"],"sources":["../src/index.ts"],"sourcesContent":["export { Portal, renderPortal_unstable, usePortal_unstable } from './components/Portal/index';\nexport type { PortalProps, PortalState } from './components/Portal/index';\nexport { elementContains, setVirtualParent } from './virtualParent/index';\n"],"mappings":"AAAA,SAASA,MAAM,EAAEC,qBAAqB,EAAEC,kBAAkB,QAAQ;AAElE,SAASC,eAAe,EAAEC,gBAAgB,QAAQ"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["getParent","elementContains","parent","child","set","WeakSet","nextParent","skipVirtual","has","add"],"sources":["
|
1
|
+
{"version":3,"names":["getParent","elementContains","parent","child","set","WeakSet","nextParent","skipVirtual","has","add"],"sources":["../../src/virtualParent/elementContains.ts"],"sourcesContent":["import { getParent } from './getParent';\n\n/**\n * Similar functionality to `element.contains` DOM API for use without of order DOM elements that\n * checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent\n *\n * @returns true if the child can find the parent in its virtual hierarchy\n */\nexport function elementContains(parent: Node | null, child: Node | null): boolean {\n if (!parent || !child) {\n return false;\n }\n\n if (parent === child) {\n return true;\n } else {\n // Tracks references of nodes that have been visited to prevent infinite loops\n const set = new WeakSet<Node>();\n\n while (child) {\n const nextParent: Node | null = getParent(child, {\n skipVirtual: set.has(child),\n });\n set.add(child);\n\n if (nextParent === parent) {\n return true;\n }\n\n child = nextParent;\n }\n }\n\n return false;\n}\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ;AAE1B;;;;;;AAMA,OAAO,SAASC,gBAAgBC,MAAmB,EAAEC,KAAkB,EAAW;EAChF,IAAI,CAACD,MAAA,IAAU,CAACC,KAAA,EAAO;IACrB,OAAO,KAAK;EACd;EAEA,IAAID,MAAA,KAAWC,KAAA,EAAO;IACpB,OAAO,IAAI;EACb,OAAO;IACL;IACA,MAAMC,GAAA,GAAM,IAAIC,OAAA;IAEhB,OAAOF,KAAA,EAAO;MACZ,MAAMG,UAAA,GAA0BN,SAAA,CAAUG,KAAA,EAAO;QAC/CI,WAAA,EAAaH,GAAA,CAAII,GAAG,CAACL,KAAA;MACvB;MACAC,GAAA,CAAIK,GAAG,CAACN,KAAA;MAER,IAAIG,UAAA,KAAeJ,MAAA,EAAQ;QACzB,OAAO,IAAI;MACb;MAEAC,KAAA,GAAQG,UAAA;IACV;EACF;EAEA,OAAO,KAAK;AACd"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["isVirtualElement","getVirtualParent","child","_virtual","parent","getParent","options","skipVirtual","virtualParent","parentNode"],"sources":["
|
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 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":[],"sources":["../../src/virtualParent/index.ts"],"sourcesContent":["export * from './elementContains';\nexport * from './setVirtualParent';\n"],"mappings":"AAAA,cAAc;AACd,cAAc"}
|
@@ -1,7 +1,6 @@
|
|
1
1
|
/**
|
2
2
|
* Determines whether or not an element has the virtual hierarchy extension.
|
3
|
-
*/
|
4
|
-
export function isVirtualElement(element) {
|
3
|
+
*/export function isVirtualElement(element) {
|
5
4
|
return element && !!element._virtual;
|
6
5
|
}
|
7
6
|
//# sourceMappingURL=isVirtualElement.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["isVirtualElement","element","_virtual"],"sources":["
|
1
|
+
{"version":3,"names":["isVirtualElement","element","_virtual"],"sources":["../../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"],"mappings":"AAEA;;GAGA,OAAO,SAASA,iBAAiBC,OAA8B,EAA6B;EAC1F,OAAOA,OAAA,IAAW,CAAC,CAACA,OAAiB,CAASC,QAAQ;AACxD"}
|
@@ -3,8 +3,7 @@
|
|
3
3
|
*
|
4
4
|
* @param child - Theme element to set the virtual parent
|
5
5
|
* @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship
|
6
|
-
*/
|
7
|
-
export function setVirtualParent(child, parent) {
|
6
|
+
*/export function setVirtualParent(child, parent) {
|
8
7
|
if (!child) {
|
9
8
|
return;
|
10
9
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["setVirtualParent","child","parent","virtualChild","_virtual"],"sources":["
|
1
|
+
{"version":3,"names":["setVirtualParent","child","parent","virtualChild","_virtual"],"sources":["../../src/virtualParent/setVirtualParent.ts"],"sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Sets the virtual parent of an element.\n *\n * @param child - Theme element to set the virtual parent\n * @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship\n */\nexport function setVirtualParent(child: Node, parent?: Node): void {\n if (!child) {\n return;\n }\n\n const virtualChild = child as VirtualElement;\n\n if (!virtualChild._virtual) {\n virtualChild._virtual = {};\n }\n\n virtualChild._virtual.parent = parent;\n}\n"],"mappings":"AAEA;;;;;GAMA,OAAO,SAASA,iBAAiBC,KAAW,EAAEC,MAAa,EAAQ;EACjE,IAAI,CAACD,KAAA,EAAO;IACV;EACF;EAEA,MAAME,YAAA,GAAeF,KAAA;EAErB,IAAI,CAACE,YAAA,CAAaC,QAAQ,EAAE;IAC1BD,YAAA,CAAaC,QAAQ,GAAG,CAAC;EAC3B;EAEAD,YAAA,CAAaC,QAAQ,CAACF,MAAM,GAAGA,MAAA;AACjC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":[],"sources":["../../src/virtualParent/types.ts"],"sourcesContent":["export interface VirtualElement extends Node {\n _virtual: {\n parent?: Node;\n };\n}\n"],"mappings":"AAAA"}
|
package/lib-commonjs/Portal.js
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
5
4
|
});
|
6
|
-
const
|
7
|
-
|
5
|
+
const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
|
6
|
+
_exportStar(require("./components/Portal/index"), exports);
|
7
|
+
//# sourceMappingURL=Portal.js.map
|
8
|
+
|
8
9
|
//# sourceMappingURL=Portal.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../lib/Portal.js"],"sourcesContent":["export * from './components/Portal/index';\n//# sourceMappingURL=Portal.js.map"],"names":[],"mappings":";;;;;oBAAc;CACd,kCAAkC"}
|
@@ -1,19 +1,19 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "Portal", {
|
6
|
+
enumerable: true,
|
7
|
+
get: ()=>Portal
|
5
8
|
});
|
6
|
-
|
7
|
-
const
|
8
|
-
const
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
const Portal = props => {
|
14
|
-
const state = usePortal_1.usePortal_unstable(props);
|
15
|
-
return renderPortal_1.renderPortal_unstable(state);
|
9
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
10
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
11
|
+
const _usePortal = require("./usePortal");
|
12
|
+
const _renderPortal = require("./renderPortal");
|
13
|
+
const Portal = (props)=>{
|
14
|
+
const state = (0, _usePortal.usePortal_unstable)(props);
|
15
|
+
return (0, _renderPortal.renderPortal_unstable)(state);
|
16
16
|
};
|
17
|
-
|
18
|
-
|
17
|
+
Portal.displayName = 'Portal'; //# sourceMappingURL=Portal.js.map
|
18
|
+
|
19
19
|
//# sourceMappingURL=Portal.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
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,6 +1,9 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
5
4
|
});
|
5
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
6
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
7
|
+
//# sourceMappingURL=Portal.types.js.map
|
8
|
+
|
6
9
|
//# sourceMappingURL=Portal.types.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
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,11 +1,12 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
5
4
|
});
|
6
|
-
const
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
|
6
|
+
_exportStar(require("./Portal"), exports);
|
7
|
+
_exportStar(require("./Portal.types"), exports);
|
8
|
+
_exportStar(require("./renderPortal"), exports);
|
9
|
+
_exportStar(require("./usePortal"), exports);
|
10
|
+
//# sourceMappingURL=index.js.map
|
11
|
+
|
11
12
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
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,19 +1,19 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "renderPortal_unstable", {
|
6
|
+
enumerable: true,
|
7
|
+
get: ()=>renderPortal_unstable
|
5
8
|
});
|
6
|
-
|
7
|
-
const
|
8
|
-
const
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
}, state.mountNode && ReactDOM.createPortal(state.children, state.mountNode));
|
17
|
-
};
|
18
|
-
exports.renderPortal_unstable = renderPortal_unstable;
|
9
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
10
|
+
const _reactDom = /*#__PURE__*/ _interopRequireWildcard(require("react-dom"));
|
11
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
12
|
+
const renderPortal_unstable = (state)=>{
|
13
|
+
return /*#__PURE__*/ _react.createElement("span", {
|
14
|
+
hidden: true,
|
15
|
+
ref: state.virtualParentRootRef
|
16
|
+
}, state.mountNode && /*#__PURE__*/ _reactDom.createPortal(state.children, state.mountNode));
|
17
|
+
}; //# sourceMappingURL=renderPortal.js.map
|
18
|
+
|
19
19
|
//# sourceMappingURL=renderPortal.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
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"}
|
@@ -1,63 +1,64 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
function _export(target, all) {
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
7
|
+
enumerable: true,
|
8
|
+
get: all[name]
|
9
|
+
});
|
10
|
+
}
|
11
|
+
_export(exports, {
|
12
|
+
toMountNodeProps: ()=>toMountNodeProps,
|
13
|
+
usePortal_unstable: ()=>usePortal_unstable
|
5
14
|
});
|
6
|
-
|
7
|
-
const
|
8
|
-
const
|
9
|
-
const
|
10
|
-
const
|
15
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
16
|
+
const _reactUtilities = require("@fluentui/react-utilities");
|
17
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
18
|
+
const _index = require("../../virtualParent/index");
|
19
|
+
const _usePortalMountNode = require("./usePortalMountNode");
|
11
20
|
function toMountNodeProps(mountNode) {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
}
|
17
|
-
if (typeof mountNode === 'object') {
|
18
|
-
if (mountNode === null) {
|
19
|
-
return {
|
20
|
-
element: null
|
21
|
-
};
|
21
|
+
if ((0, _reactUtilities.isHTMLElement)(mountNode)) {
|
22
|
+
return {
|
23
|
+
element: mountNode
|
24
|
+
};
|
22
25
|
}
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
*
|
31
|
-
* The returned state can be modified with hooks such as usePortalStyles, before being passed to renderPortal_unstable.
|
32
|
-
*
|
33
|
-
* @param props - props from this instance of Portal
|
34
|
-
*/
|
35
|
-
const usePortal_unstable = props => {
|
36
|
-
const {
|
37
|
-
element,
|
38
|
-
className
|
39
|
-
} = toMountNodeProps(props.mountNode);
|
40
|
-
const virtualParentRootRef = React.useRef(null);
|
41
|
-
const fallbackElement = usePortalMountNode_1.usePortalMountNode({
|
42
|
-
disabled: !!element,
|
43
|
-
className
|
44
|
-
});
|
45
|
-
const state = {
|
46
|
-
children: props.children,
|
47
|
-
mountNode: element !== null && element !== void 0 ? element : fallbackElement,
|
48
|
-
virtualParentRootRef
|
49
|
-
};
|
50
|
-
React.useEffect(() => {
|
51
|
-
if (state.virtualParentRootRef.current && state.mountNode) {
|
52
|
-
index_1.setVirtualParent(state.mountNode, state.virtualParentRootRef.current);
|
26
|
+
if (typeof mountNode === 'object') {
|
27
|
+
if (mountNode === null) {
|
28
|
+
return {
|
29
|
+
element: null
|
30
|
+
};
|
31
|
+
}
|
32
|
+
return mountNode;
|
53
33
|
}
|
54
|
-
return
|
55
|
-
|
56
|
-
|
57
|
-
|
34
|
+
return {};
|
35
|
+
}
|
36
|
+
const usePortal_unstable = (props)=>{
|
37
|
+
const { element , className } = toMountNodeProps(props.mountNode);
|
38
|
+
const virtualParentRootRef = _react.useRef(null);
|
39
|
+
const fallbackElement = (0, _usePortalMountNode.usePortalMountNode)({
|
40
|
+
disabled: !!element,
|
41
|
+
className
|
42
|
+
});
|
43
|
+
const state = {
|
44
|
+
children: props.children,
|
45
|
+
mountNode: element !== null && element !== void 0 ? element : fallbackElement,
|
46
|
+
virtualParentRootRef
|
58
47
|
};
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
48
|
+
_react.useEffect(()=>{
|
49
|
+
if (state.virtualParentRootRef.current && state.mountNode) {
|
50
|
+
(0, _index.setVirtualParent)(state.mountNode, state.virtualParentRootRef.current);
|
51
|
+
}
|
52
|
+
return ()=>{
|
53
|
+
if (state.mountNode) {
|
54
|
+
(0, _index.setVirtualParent)(state.mountNode, undefined);
|
55
|
+
}
|
56
|
+
};
|
57
|
+
}, [
|
58
|
+
state.virtualParentRootRef,
|
59
|
+
state.mountNode
|
60
|
+
]);
|
61
|
+
return state;
|
62
|
+
}; //# sourceMappingURL=usePortal.js.map
|
63
|
+
|
63
64
|
//# sourceMappingURL=usePortal.js.map
|