@fluentui/react-portal 0.0.0-nightly-20221228-0425.1 → 0.0.0-nightly-20221230-0421.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/CHANGELOG.json +9 -9
- package/CHANGELOG.md +7 -7
- 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 +4 -9
- 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 +0 -1
- package/lib/virtualParent/getParent.js.map +1 -1
- package/lib/virtualParent/getVirtualParent.js +0 -3
- 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-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 +4 -17
- 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 +0 -4
- package/lib-commonjs/virtualParent/getParent.js.map +1 -1
- package/lib-commonjs/virtualParent/getVirtualParent.js +0 -6
- 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 +5 -5
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": "Fri, 30 Dec 2022 04:28:24 GMT",
|
6
|
+
"tag": "@fluentui/react-portal_v0.0.0-nightly-20221230-0421.1",
|
7
|
+
"version": "0.0.0-nightly-20221230-0421.1",
|
8
8
|
"comments": {
|
9
9
|
"prerelease": [
|
10
10
|
{
|
@@ -16,20 +16,20 @@
|
|
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-20221230-0421.1",
|
20
|
+
"commit": "a38762f3d85d92ff20fe07b067fe74c91defe343"
|
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-20221230-0421.1",
|
26
|
+
"commit": "a38762f3d85d92ff20fe07b067fe74c91defe343"
|
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-20221230-0421.1",
|
32
|
+
"commit": "a38762f3d85d92ff20fe07b067fe74c91defe343"
|
33
33
|
}
|
34
34
|
]
|
35
35
|
}
|
package/CHANGELOG.md
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
# Change Log - @fluentui/react-portal
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Fri, 30 Dec 2022 04:28:24 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-20221230-0421.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-portal_v0.0.0-nightly-20221230-0421.1)
|
8
8
|
|
9
|
-
|
10
|
-
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-portal_v9.0.14..@fluentui/react-portal_v0.0.0-nightly-
|
9
|
+
Fri, 30 Dec 2022 04:28:24 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-portal_v9.0.14..@fluentui/react-portal_v0.0.0-nightly-20221230-0421.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-20221230-0421.1 ([commit](https://github.com/microsoft/fluentui/commit/a38762f3d85d92ff20fe07b067fe74c91defe343) by beachball)
|
16
|
+
- Bump @fluentui/react-tabster to v0.0.0-nightly-20221230-0421.1 ([commit](https://github.com/microsoft/fluentui/commit/a38762f3d85d92ff20fe07b067fe74c91defe343) by beachball)
|
17
|
+
- Bump @fluentui/react-utilities to v0.0.0-nightly-20221230-0421.1 ([commit](https://github.com/microsoft/fluentui/commit/a38762f3d85d92ff20fe07b067fe74c91defe343) by beachball)
|
18
18
|
|
19
19
|
## [9.0.14](https://github.com/microsoft/fluentui/tree/@fluentui/react-portal_v9.0.14)
|
20
20
|
|
@@ -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":"","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":"","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":"","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"]}
|
@@ -3,10 +3,9 @@ import { useThemeClassName_unstable as useThemeClassName, useFluent_unstable as
|
|
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
|
-
|
6
|
+
import { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
|
7
|
+
// String concatenation is used to prevent bundlers to complain with older versions of React
|
8
8
|
const useInsertionEffect = React['useInsertion' + 'Effect'] ? React['useInsertion' + 'Effect'] : useIsomorphicLayoutEffect;
|
9
|
-
|
10
9
|
const useStyles = /*#__PURE__*/__styles({
|
11
10
|
"root": {
|
12
11
|
"qhf8xq": "f10pi13n",
|
@@ -18,8 +17,6 @@ const useStyles = /*#__PURE__*/__styles({
|
|
18
17
|
/**
|
19
18
|
* Creates a new element on a document.body to mount portals
|
20
19
|
*/
|
21
|
-
|
22
|
-
|
23
20
|
export const usePortalMountNode = options => {
|
24
21
|
const {
|
25
22
|
targetDocument,
|
@@ -33,20 +30,18 @@ export const usePortalMountNode = options => {
|
|
33
30
|
if (targetDocument === undefined || options.disabled) {
|
34
31
|
return [null, () => null];
|
35
32
|
}
|
36
|
-
|
37
33
|
const newElement = targetDocument.createElement('div');
|
38
34
|
targetDocument.body.appendChild(newElement);
|
39
35
|
return [newElement, () => newElement.remove()];
|
40
|
-
}, [targetDocument]);
|
36
|
+
}, [targetDocument]);
|
37
|
+
// This useEffect call is intentional
|
41
38
|
// We don't want to re-create the portal element when its attributes change.
|
42
39
|
// This also should not be done in an effect because, changing the value of css variables
|
43
40
|
// after initial mount can trigger interesting CSS side effects like transitions.
|
44
|
-
|
45
41
|
useInsertionEffect(() => {
|
46
42
|
if (!element) {
|
47
43
|
return;
|
48
44
|
}
|
49
|
-
|
50
45
|
const classesToApply = className.split(' ').filter(Boolean);
|
51
46
|
element.classList.add(...classesToApply);
|
52
47
|
element.setAttribute('dir', dir);
|
@@ -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":"","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,MAA0B,EAAEC,KAAyB;EACnF,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,GAAuBJ,SAAS,CAACG,KAAK,CAAC;MAEvD,IAAIC,UAAU,KAAKF,MAAM,EAAE;QACzB,OAAO,IAAI;;MAGbC,KAAK,GAAGC,UAAU;;;EAItB,OAAO,KAAK;AACd","names":["getParent","elementContains","parent","child","nextParent"],"sourceRoot":"","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: HTMLElement | null, child: HTMLElement | 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: HTMLElement | null = getParent(child);\n\n if (nextParent === parent) {\n return true;\n }\n\n child = nextParent;\n }\n }\n\n return false;\n}\n"]}
|
@@ -3,7 +3,6 @@ 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
|
return child && getVirtualParent(child) || (child === null || child === void 0 ? void 0 : child.parentNode);
|
9
8
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"AAAA,SAASA,gBAAgB,QAAQ,oBAAoB;AAErD;;;;AAIA,OAAM,SAAUC,SAAS,CAACC,KAAyB;EACjD,OAAQA,KAAK,IAAIF,gBAAgB,CAACE,KAAK,CAAC,KAAMA,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEC,UAAiC;AACxF","names":["getVirtualParent","getParent","child","parentNode"],"sourceRoot":"","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: HTMLElement | null): HTMLElement | null {\n return (child && getVirtualParent(child)) || (child?.parentNode as HTMLElement | null);\n}\n"]}
|
@@ -2,14 +2,11 @@ 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
6
|
let parent;
|
8
|
-
|
9
7
|
if (isVirtualElement(child)) {
|
10
8
|
parent = child._virtual.parent;
|
11
9
|
}
|
12
|
-
|
13
10
|
return parent;
|
14
11
|
}
|
15
12
|
//# sourceMappingURL=getVirtualParent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"AAAA,SAASA,gBAAgB,QAAQ,oBAAoB;AACrD;;;AAGA,OAAM,SAAUC,gBAAgB,CAACC,KAAkB;EACjD,IAAIC,MAA+B;EACnC,IAAIH,gBAAgB,CAACE,KAAK,CAAC,EAAE;IAC3BC,MAAM,GAAGD,KAAK,CAACE,QAAQ,CAACD,MAAM;;EAEhC,OAAOA,MAAM;AACf","names":["isVirtualElement","getVirtualParent","child","parent","_virtual"],"sourceRoot":"","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: HTMLElement): HTMLElement | undefined {\n let parent: HTMLElement | undefined;\n if (isVirtualElement(child)) {\n parent = child._virtual.parent;\n }\n return parent;\n}\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"AAEA;;;AAGA,OAAM,SAAUA,gBAAgB,CAACC,OAAqC;EACpE,OAAOA,OAAO,IAAI,CAAC,CAAkBA,OAAQ,CAACC,QAAQ;AACxD","names":["isVirtualElement","element","_virtual"],"sourceRoot":"","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: HTMLElement | 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,KAAkB,EAAEC,MAAoB;EACvE,IAAI,CAACD,KAAK,EAAE;IACV;;EAGF,MAAME,YAAY,GAAmBF,KAAK;EAE1C,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":"","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: HTMLElement, parent?: HTMLElement): void {\n if (!child) {\n return;\n }\n\n const virtualChild = <VirtualElement>child;\n\n if (!virtualChild._virtual) {\n virtualChild._virtual = {};\n }\n\n virtualChild._virtual.parent = parent || undefined;\n}\n"]}
|
package/lib-commonjs/Portal.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../packages/react-components/react-portal/src/Portal.ts"],"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAAA","names":["tslib_1"],"sourceRoot":"","sources":["../../../../../../../packages/react-components/react-portal/src/Portal.ts"],"sourcesContent":["export * from './components/Portal/index';\n"]}
|
@@ -4,21 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.Portal = void 0;
|
7
|
-
|
8
7
|
const usePortal_1 = /*#__PURE__*/require("./usePortal");
|
9
|
-
|
10
8
|
const renderPortal_1 = /*#__PURE__*/require("./renderPortal");
|
11
9
|
/**
|
12
10
|
* A portal provides a way to render children into a DOM node
|
13
11
|
* that exists outside the DOM hierarchy of the parent component.
|
14
12
|
*/
|
15
|
-
|
16
|
-
|
17
13
|
const Portal = props => {
|
18
14
|
const state = usePortal_1.usePortal_unstable(props);
|
19
15
|
return renderPortal_1.renderPortal_unstable(state);
|
20
16
|
};
|
21
|
-
|
22
17
|
exports.Portal = Portal;
|
23
18
|
exports.Portal.displayName = 'Portal';
|
24
19
|
//# sourceMappingURL=Portal.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAEA;AACA;AAGA;;;;AAIO,MAAMA,MAAM,GAA0BC,KAAK,IAAG;EACnD,MAAMC,KAAK,GAAGC,8BAAkB,CAACF,KAAK,CAAC;EAEvC,OAAOG,oCAAqB,CAACF,KAAK,CAAC;AACrC,CAAC;AAJYG,cAAM;AAMnBA,cAAM,CAACC,WAAW,GAAG,QAAQ","names":["Portal","props","state","usePortal_1","renderPortal_1","exports","displayName"],"sourceRoot":"","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":"","names":[],"sourceRoot":"","sources":[],"sourcesContent":[]}
|
@@ -3,14 +3,9 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
|
7
6
|
const tslib_1 = /*#__PURE__*/require("tslib");
|
8
|
-
|
9
7
|
tslib_1.__exportStar(require("./Portal"), exports);
|
10
|
-
|
11
8
|
tslib_1.__exportStar(require("./Portal.types"), exports);
|
12
|
-
|
13
9
|
tslib_1.__exportStar(require("./renderPortal"), exports);
|
14
|
-
|
15
10
|
tslib_1.__exportStar(require("./usePortal"), exports);
|
16
11
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../packages/react-components/react-portal/src/components/Portal/index.ts"],"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAAA;AACAA;AACAA;AACAA","names":["tslib_1"],"sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-portal/src/components/Portal/index.ts"],"sourcesContent":["export * from './Portal';\nexport * from './Portal.types';\nexport * from './renderPortal';\nexport * from './usePortal';\n"]}
|
@@ -4,21 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.renderPortal_unstable = void 0;
|
7
|
-
|
8
7
|
const ReactDOM = /*#__PURE__*/require("react-dom");
|
9
|
-
|
10
8
|
const React = /*#__PURE__*/require("react");
|
11
9
|
/**
|
12
10
|
* Render the final JSX of Portal
|
13
11
|
*/
|
14
|
-
|
15
|
-
|
16
12
|
const renderPortal_unstable = state => {
|
17
13
|
return React.createElement("span", {
|
18
14
|
hidden: true,
|
19
15
|
ref: state.virtualParentRootRef
|
20
16
|
}, state.mountNode && ReactDOM.createPortal(state.children, state.mountNode));
|
21
17
|
};
|
22
|
-
|
23
18
|
exports.renderPortal_unstable = renderPortal_unstable;
|
24
19
|
//# sourceMappingURL=renderPortal.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AAGA;;;AAGO,MAAMA,qBAAqB,GAAIC,KAAkB,IAAwB;EAC9E,OACEC;IAAMC,MAAM;IAACC,GAAG,EAAEH,KAAK,CAACI;EAAoB,GACzCJ,KAAK,CAACK,SAAS,IAAIC,QAAQ,CAACC,YAAY,CAACP,KAAK,CAACQ,QAAQ,EAAER,KAAK,CAACK,SAAS,CAAC,CACrE;AAEX,CAAC;AANYI,6BAAqB","names":["renderPortal_unstable","state","React","hidden","ref","virtualParentRootRef","mountNode","ReactDOM","createPortal","children","exports"],"sourceRoot":"","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"]}
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.usePortal_unstable = void 0;
|
7
|
-
|
8
7
|
const React = /*#__PURE__*/require("react");
|
9
|
-
|
10
8
|
const usePortalMountNode_1 = /*#__PURE__*/require("./usePortalMountNode");
|
11
|
-
|
12
9
|
const index_1 = /*#__PURE__*/require("../../virtualParent/index");
|
13
10
|
/**
|
14
11
|
* Create the state required to render Portal.
|
@@ -17,8 +14,6 @@ const index_1 = /*#__PURE__*/require("../../virtualParent/index");
|
|
17
14
|
*
|
18
15
|
* @param props - props from this instance of Portal
|
19
16
|
*/
|
20
|
-
|
21
|
-
|
22
17
|
const usePortal_unstable = props => {
|
23
18
|
const {
|
24
19
|
children,
|
@@ -40,6 +35,5 @@ const usePortal_unstable = props => {
|
|
40
35
|
}, [state.virtualParentRootRef, state.mountNode]);
|
41
36
|
return state;
|
42
37
|
};
|
43
|
-
|
44
38
|
exports.usePortal_unstable = usePortal_unstable;
|
45
39
|
//# sourceMappingURL=usePortal.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AACA;AAGA;;;;;;;AAOO,MAAMA,kBAAkB,GAAIC,KAAkB,IAAiB;EACpE,MAAM;IAAEC,QAAQ;IAAEC;EAAS,CAAE,GAAGF,KAAK;EAErC,MAAMG,oBAAoB,GAAGC,KAAK,CAACC,MAAM,CAAkB,IAAI,CAAC;EAChE,MAAMC,iBAAiB,GAAGC,uCAAkB,CAAC;IAAEC,QAAQ,EAAE,CAAC,CAACN;EAAS,CAAE,CAAC;EAEvE,MAAMO,KAAK,GAAgB;IACzBR,QAAQ;IACRC,SAAS,EAAEA,SAAS,aAATA,SAAS,cAATA,SAAS,GAAII,iBAAiB;IACzCH;GACD;EAEDC,KAAK,CAACM,SAAS,CAAC,MAAK;IACnB,IAAID,KAAK,CAACN,oBAAoB,CAACQ,OAAO,IAAIF,KAAK,CAACP,SAAS,EAAE;MACzDU,wBAAgB,CAACH,KAAK,CAACP,SAAS,EAAEO,KAAK,CAACN,oBAAoB,CAACQ,OAAO,CAAC;;EAEzE,CAAC,EAAE,CAACF,KAAK,CAACN,oBAAoB,EAAEM,KAAK,CAACP,SAAS,CAAC,CAAC;EAEjD,OAAOO,KAAK;AACd,CAAC;AAnBYI,0BAAkB","names":["usePortal_unstable","props","children","mountNode","virtualParentRootRef","React","useRef","fallbackMountNode","usePortalMountNode_1","disabled","state","useEffect","current","index_1","exports"],"sourceRoot":"","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"]}
|
@@ -4,22 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.usePortalMountNode = void 0;
|
7
|
-
|
8
7
|
const React = /*#__PURE__*/require("react");
|
9
|
-
|
10
8
|
const react_shared_contexts_1 = /*#__PURE__*/require("@fluentui/react-shared-contexts");
|
11
|
-
|
12
9
|
const react_1 = /*#__PURE__*/require("@griffel/react");
|
13
|
-
|
14
10
|
const react_tabster_1 = /*#__PURE__*/require("@fluentui/react-tabster");
|
15
|
-
|
16
11
|
const use_disposable_1 = /*#__PURE__*/require("use-disposable");
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
12
|
+
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
13
|
+
// String concatenation is used to prevent bundlers to complain with older versions of React
|
21
14
|
const useInsertionEffect = React['useInsertion' + 'Effect'] ? React['useInsertion' + 'Effect'] : react_utilities_1.useIsomorphicLayoutEffect;
|
22
|
-
|
23
15
|
const useStyles = /*#__PURE__*/react_1.__styles({
|
24
16
|
"root": {
|
25
17
|
"qhf8xq": "f10pi13n",
|
@@ -31,8 +23,6 @@ const useStyles = /*#__PURE__*/react_1.__styles({
|
|
31
23
|
/**
|
32
24
|
* Creates a new element on a document.body to mount portals
|
33
25
|
*/
|
34
|
-
|
35
|
-
|
36
26
|
const usePortalMountNode = options => {
|
37
27
|
const {
|
38
28
|
targetDocument,
|
@@ -46,20 +36,18 @@ const usePortalMountNode = options => {
|
|
46
36
|
if (targetDocument === undefined || options.disabled) {
|
47
37
|
return [null, () => null];
|
48
38
|
}
|
49
|
-
|
50
39
|
const newElement = targetDocument.createElement('div');
|
51
40
|
targetDocument.body.appendChild(newElement);
|
52
41
|
return [newElement, () => newElement.remove()];
|
53
|
-
}, [targetDocument]);
|
42
|
+
}, [targetDocument]);
|
43
|
+
// This useEffect call is intentional
|
54
44
|
// We don't want to re-create the portal element when its attributes change.
|
55
45
|
// This also should not be done in an effect because, changing the value of css variables
|
56
46
|
// after initial mount can trigger interesting CSS side effects like transitions.
|
57
|
-
|
58
47
|
useInsertionEffect(() => {
|
59
48
|
if (!element) {
|
60
49
|
return;
|
61
50
|
}
|
62
|
-
|
63
51
|
const classesToApply = className.split(' ').filter(Boolean);
|
64
52
|
element.classList.add(...classesToApply);
|
65
53
|
element.setAttribute('dir', dir);
|
@@ -71,6 +59,5 @@ const usePortalMountNode = options => {
|
|
71
59
|
}, [className, dir, element, focusVisibleRef]);
|
72
60
|
return element;
|
73
61
|
};
|
74
|
-
|
75
62
|
exports.usePortalMountNode = usePortalMountNode;
|
76
63
|
//# sourceMappingURL=usePortalMountNode.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AAIA;AACA;AACA;AACA;AAEA;AACA,MAAMA,kBAAkB,GAAIC,KAAe,CAAC,cAAc,GAAG,QAAQ,CAAC,GACjEA,KAAe,CAAC,cAAc,GAAG,QAAQ,CAAC,GAC3CC,2CAAyB;AAS7B,MAAMC,SAAS,gBAAGC,gBAAU;EAAA;IAAA;IAAA;EAAA;AAAA;EAAA;AAAA,EAK1B;AAEF;;;AAGO,MAAMC,kBAAkB,GAAIC,OAAkC,IAAwB;EAC3F,MAAM;IAAEC,cAAc;IAAEC;EAAG,CAAE,GAAGC,0CAAS,EAAE;EAC3C,MAAMC,eAAe,GAAGC,+BAAe,EAAgE;EACvG,MAAMC,OAAO,GAAGT,SAAS,EAAE;EAC3B,MAAMU,cAAc,GAAGJ,kDAAiB,EAAE;EAE1C,MAAMK,SAAS,GAAGV,oBAAY,CAACS,cAAc,EAAED,OAAO,CAACG,IAAI,CAAC;EAE5D,MAAMC,OAAO,GAAGC,8BAAa,CAAC,MAAK;IACjC,IAAIV,cAAc,KAAKW,SAAS,IAAIZ,OAAO,CAACa,QAAQ,EAAE;MACpD,OAAO,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC;;IAG3B,MAAMC,UAAU,GAAGb,cAAc,CAACc,aAAa,CAAC,KAAK,CAAC;IACtDd,cAAc,CAACe,IAAI,CAACC,WAAW,CAACH,UAAU,CAAC;IAC3C,OAAO,CAACA,UAAU,EAAE,MAAMA,UAAU,CAACI,MAAM,EAAE,CAAC;EAChD,CAAC,EAAE,CAACjB,cAAc,CAAC,CAAC;EAEpB;EACA;EACA;EACA;EACAP,kBAAkB,CAAC,MAAK;IACtB,IAAI,CAACgB,OAAO,EAAE;MACZ;;IAGF,MAAMS,cAAc,GAAGX,SAAS,CAACY,KAAK,CAAC,GAAG,CAAC,CAACC,MAAM,CAACC,OAAO,CAAC;IAE3DZ,OAAO,CAACa,SAAS,CAACC,GAAG,CAAC,GAAGL,cAAc,CAAC;IACxCT,OAAO,CAACe,YAAY,CAAC,KAAK,EAAEvB,GAAG,CAAC;IAChCE,eAAe,CAACsB,OAAO,GAAGhB,OAAO;IAEjC,OAAO,MAAK;MACVA,OAAO,CAACa,SAAS,CAACL,MAAM,CAAC,GAAGC,cAAc,CAAC;MAC3CT,OAAO,CAACiB,eAAe,CAAC,KAAK,CAAC;IAChC,CAAC;EACH,CAAC,EAAE,CAACnB,SAAS,EAAEN,GAAG,EAAEQ,OAAO,EAAEN,eAAe,CAAC,CAAC;EAE9C,OAAOM,OAAO;AAChB,CAAC;AAxCYkB,0BAAkB","names":["useInsertionEffect","React","react_utilities_1","useStyles","react_1","usePortalMountNode","options","targetDocument","dir","react_shared_contexts_1","focusVisibleRef","react_tabster_1","classes","themeClassName","className","root","element","use_disposable_1","undefined","disabled","newElement","createElement","body","appendChild","remove","classesToApply","split","filter","Boolean","classList","add","setAttribute","current","removeAttribute","exports"],"sourceRoot":"","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"]}
|
package/lib-commonjs/index.js
CHANGED
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.setVirtualParent = exports.elementContains = exports.usePortal_unstable = exports.renderPortal_unstable = exports.Portal = void 0;
|
7
|
-
|
8
7
|
var index_1 = /*#__PURE__*/require("./components/Portal/index");
|
9
|
-
|
10
8
|
Object.defineProperty(exports, "Portal", {
|
11
9
|
enumerable: true,
|
12
10
|
get: function () {
|
@@ -25,9 +23,7 @@ Object.defineProperty(exports, "usePortal_unstable", {
|
|
25
23
|
return index_1.usePortal_unstable;
|
26
24
|
}
|
27
25
|
});
|
28
|
-
|
29
26
|
var index_2 = /*#__PURE__*/require("./virtualParent/index");
|
30
|
-
|
31
27
|
Object.defineProperty(exports, "elementContains", {
|
32
28
|
enumerable: true,
|
33
29
|
get: function () {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AAASA;EAAAC;EAAAC;IAAA,qBAAM;EAAA;AAAA;AAAEF;EAAAC;EAAAC;IAAA,oCAAqB;EAAA;AAAA;AAAEF;EAAAC;EAAAC;IAAA,iCAAkB;EAAA;AAAA;AAE1D;AAASF;EAAAC;EAAAC;IAAA,8BAAe;EAAA;AAAA;AAAEF;EAAAC;EAAAC;IAAA,+BAAgB;EAAA;AAAA","names":["Object","enumerable","get"],"sourceRoot":"","sources":["../../../../../../../packages/react-components/react-portal/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"]}
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.elementContains = void 0;
|
7
|
-
|
8
7
|
const getParent_1 = /*#__PURE__*/require("./getParent");
|
9
8
|
/**
|
10
9
|
* Similar functionality to `element.contains` DOM API for use with out of order DOM elements that
|
@@ -12,29 +11,22 @@ const getParent_1 = /*#__PURE__*/require("./getParent");
|
|
12
11
|
*
|
13
12
|
* @returns true if the child can find the parent in its virtual hierarchy
|
14
13
|
*/
|
15
|
-
|
16
|
-
|
17
14
|
function elementContains(parent, child) {
|
18
15
|
if (!parent || !child) {
|
19
16
|
return false;
|
20
17
|
}
|
21
|
-
|
22
18
|
if (parent === child) {
|
23
19
|
return true;
|
24
20
|
} else {
|
25
21
|
while (child) {
|
26
22
|
const nextParent = getParent_1.getParent(child);
|
27
|
-
|
28
23
|
if (nextParent === parent) {
|
29
24
|
return true;
|
30
25
|
}
|
31
|
-
|
32
26
|
child = nextParent;
|
33
27
|
}
|
34
28
|
}
|
35
|
-
|
36
29
|
return false;
|
37
30
|
}
|
38
|
-
|
39
31
|
exports.elementContains = elementContains;
|
40
32
|
//# sourceMappingURL=elementContains.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;;;;;;AAMA,SAAgBA,eAAe,CAACC,MAA0B,EAAEC,KAAyB;EACnF,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,GAAuBC,qBAAS,CAACF,KAAK,CAAC;MAEvD,IAAIC,UAAU,KAAKF,MAAM,EAAE;QACzB,OAAO,IAAI;;MAGbC,KAAK,GAAGC,UAAU;;;EAItB,OAAO,KAAK;AACd;AApBAE","names":["elementContains","parent","child","nextParent","getParent_1","exports"],"sourceRoot":"","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: HTMLElement | null, child: HTMLElement | 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: HTMLElement | null = getParent(child);\n\n if (nextParent === parent) {\n return true;\n }\n\n child = nextParent;\n }\n }\n\n return false;\n}\n"]}
|
@@ -4,17 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.getParent = void 0;
|
7
|
-
|
8
7
|
const getVirtualParent_1 = /*#__PURE__*/require("./getVirtualParent");
|
9
8
|
/**
|
10
9
|
* Gets the element which is the parent of a given element.
|
11
10
|
* This method prefers the virtual parent over real DOM parent when present.
|
12
11
|
*/
|
13
|
-
|
14
|
-
|
15
12
|
function getParent(child) {
|
16
13
|
return child && getVirtualParent_1.getVirtualParent(child) || (child === null || child === void 0 ? void 0 : child.parentNode);
|
17
14
|
}
|
18
|
-
|
19
15
|
exports.getParent = getParent;
|
20
16
|
//# sourceMappingURL=getParent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AAEA;;;;AAIA,SAAgBA,SAAS,CAACC,KAAyB;EACjD,OAAQA,KAAK,IAAIC,mCAAgB,CAACD,KAAK,CAAC,KAAMA,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEE,UAAiC;AACxF;AAFAC","names":["getParent","child","getVirtualParent_1","parentNode","exports"],"sourceRoot":"","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: HTMLElement | null): HTMLElement | null {\n return (child && getVirtualParent(child)) || (child?.parentNode as HTMLElement | null);\n}\n"]}
|
@@ -4,22 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.getVirtualParent = void 0;
|
7
|
-
|
8
7
|
const isVirtualElement_1 = /*#__PURE__*/require("./isVirtualElement");
|
9
8
|
/**
|
10
9
|
* Gets the virtual parent given the child element, if it exists.
|
11
10
|
*/
|
12
|
-
|
13
|
-
|
14
11
|
function getVirtualParent(child) {
|
15
12
|
let parent;
|
16
|
-
|
17
13
|
if (isVirtualElement_1.isVirtualElement(child)) {
|
18
14
|
parent = child._virtual.parent;
|
19
15
|
}
|
20
|
-
|
21
16
|
return parent;
|
22
17
|
}
|
23
|
-
|
24
18
|
exports.getVirtualParent = getVirtualParent;
|
25
19
|
//# sourceMappingURL=getVirtualParent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;;;AAGA,SAAgBA,gBAAgB,CAACC,KAAkB;EACjD,IAAIC,MAA+B;EACnC,IAAIC,mCAAgB,CAACF,KAAK,CAAC,EAAE;IAC3BC,MAAM,GAAGD,KAAK,CAACG,QAAQ,CAACF,MAAM;;EAEhC,OAAOA,MAAM;AACf;AANAG","names":["getVirtualParent","child","parent","isVirtualElement_1","_virtual","exports"],"sourceRoot":"","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: HTMLElement): HTMLElement | undefined {\n let parent: HTMLElement | undefined;\n if (isVirtualElement(child)) {\n parent = child._virtual.parent;\n }\n return parent;\n}\n"]}
|
@@ -3,16 +3,10 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
|
7
6
|
const tslib_1 = /*#__PURE__*/require("tslib");
|
8
|
-
|
9
7
|
tslib_1.__exportStar(require("./elementContains"), exports);
|
10
|
-
|
11
8
|
tslib_1.__exportStar(require("./getParent"), exports);
|
12
|
-
|
13
9
|
tslib_1.__exportStar(require("./getVirtualParent"), exports);
|
14
|
-
|
15
10
|
tslib_1.__exportStar(require("./isVirtualElement"), exports);
|
16
|
-
|
17
11
|
tslib_1.__exportStar(require("./setVirtualParent"), exports);
|
18
12
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/index.ts"],"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAAA;AACAA;AACAA;AACAA;AACAA","names":["tslib_1"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/index.ts"],"sourcesContent":["export * from './elementContains';\nexport * from './getParent';\nexport * from './getVirtualParent';\nexport * from './isVirtualElement';\nexport * from './setVirtualParent';\n"]}
|
@@ -7,10 +7,8 @@ exports.isVirtualElement = void 0;
|
|
7
7
|
/**
|
8
8
|
* Determines whether or not an element has the virtual hierarchy extension.
|
9
9
|
*/
|
10
|
-
|
11
10
|
function isVirtualElement(element) {
|
12
11
|
return element && !!element._virtual;
|
13
12
|
}
|
14
|
-
|
15
13
|
exports.isVirtualElement = isVirtualElement;
|
16
14
|
//# sourceMappingURL=isVirtualElement.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAEA;;;AAGA,SAAgBA,gBAAgB,CAACC,OAAqC;EACpE,OAAOA,OAAO,IAAI,CAAC,CAAkBA,OAAQ,CAACC,QAAQ;AACxD;AAFAC","names":["isVirtualElement","element","_virtual","exports"],"sourceRoot":"","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: HTMLElement | VirtualElement): element is VirtualElement {\n return element && !!(<VirtualElement>element)._virtual;\n}\n"]}
|
@@ -10,20 +10,15 @@ exports.setVirtualParent = void 0;
|
|
10
10
|
* @param child - Theme element to set the virtual parent
|
11
11
|
* @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship
|
12
12
|
*/
|
13
|
-
|
14
13
|
function setVirtualParent(child, parent) {
|
15
14
|
if (!child) {
|
16
15
|
return;
|
17
16
|
}
|
18
|
-
|
19
17
|
const virtualChild = child;
|
20
|
-
|
21
18
|
if (!virtualChild._virtual) {
|
22
19
|
virtualChild._virtual = {};
|
23
20
|
}
|
24
|
-
|
25
21
|
virtualChild._virtual.parent = parent || undefined;
|
26
22
|
}
|
27
|
-
|
28
23
|
exports.setVirtualParent = setVirtualParent;
|
29
24
|
//# sourceMappingURL=setVirtualParent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAEA;;;;;;AAMA,SAAgBA,gBAAgB,CAACC,KAAkB,EAAEC,MAAoB;EACvE,IAAI,CAACD,KAAK,EAAE;IACV;;EAGF,MAAME,YAAY,GAAmBF,KAAK;EAE1C,IAAI,CAACE,YAAY,CAACC,QAAQ,EAAE;IAC1BD,YAAY,CAACC,QAAQ,GAAG,EAAE;;EAG5BD,YAAY,CAACC,QAAQ,CAACF,MAAM,GAAGA,MAAM,IAAIG,SAAS;AACpD;AAZAC","names":["setVirtualParent","child","parent","virtualChild","_virtual","undefined","exports"],"sourceRoot":"","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: HTMLElement, parent?: HTMLElement): void {\n if (!child) {\n return;\n }\n\n const virtualChild = <VirtualElement>child;\n\n if (!virtualChild._virtual) {\n virtualChild._virtual = {};\n }\n\n virtualChild._virtual.parent = parent || undefined;\n}\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"","names":[],"sourceRoot":"","sources":[],"sourcesContent":[]}
|
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-20221230-0421.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",
|
@@ -27,12 +27,12 @@
|
|
27
27
|
"devDependencies": {
|
28
28
|
"@fluentui/eslint-plugin": "*",
|
29
29
|
"@fluentui/react-conformance": "*",
|
30
|
-
"@fluentui/scripts": "
|
30
|
+
"@fluentui/scripts": "*"
|
31
31
|
},
|
32
32
|
"dependencies": {
|
33
|
-
"@fluentui/react-shared-contexts": "0.0.0-nightly-
|
34
|
-
"@fluentui/react-tabster": "0.0.0-nightly-
|
35
|
-
"@fluentui/react-utilities": "0.0.0-nightly-
|
33
|
+
"@fluentui/react-shared-contexts": "0.0.0-nightly-20221230-0421.1",
|
34
|
+
"@fluentui/react-tabster": "0.0.0-nightly-20221230-0421.1",
|
35
|
+
"@fluentui/react-utilities": "0.0.0-nightly-20221230-0421.1",
|
36
36
|
"@griffel/react": "^1.4.2",
|
37
37
|
"tslib": "^2.1.0",
|
38
38
|
"use-disposable": "^1.0.1"
|