@fluentui/react-portal 9.3.10 → 9.3.11
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +40 -1
- package/CHANGELOG.md +15 -2
- package/lib/components/Portal/Portal.js.map +1 -1
- package/lib/components/Portal/renderPortal.js.map +1 -1
- package/lib/components/Portal/usePortal.js +1 -1
- package/lib/components/Portal/usePortal.js.map +1 -1
- package/lib/components/Portal/usePortalMountNode.js +3 -2
- package/lib/components/Portal/usePortalMountNode.js.map +1 -1
- package/lib/virtualParent/elementContains.js.map +1 -1
- package/lib/virtualParent/getParent.js +2 -1
- package/lib/virtualParent/getParent.js.map +1 -1
- package/lib/virtualParent/isVirtualElement.js.map +1 -1
- package/lib/virtualParent/setVirtualParent.js.map +1 -1
- package/lib-commonjs/Portal.js +2 -2
- package/lib-commonjs/Portal.js.map +1 -1
- package/lib-commonjs/components/Portal/Portal.js +5 -3
- package/lib-commonjs/components/Portal/Portal.js.map +1 -1
- package/lib-commonjs/components/Portal/Portal.types.js +2 -2
- package/lib-commonjs/components/Portal/Portal.types.js.map +1 -1
- package/lib-commonjs/components/Portal/index.js +5 -5
- package/lib-commonjs/components/Portal/index.js.map +1 -1
- package/lib-commonjs/components/Portal/renderPortal.js +7 -5
- package/lib-commonjs/components/Portal/renderPortal.js.map +1 -1
- package/lib-commonjs/components/Portal/usePortal.js +11 -7
- package/lib-commonjs/components/Portal/usePortal.js.map +1 -1
- package/lib-commonjs/components/Portal/usePortalMountNode.js +17 -14
- package/lib-commonjs/components/Portal/usePortalMountNode.js.map +1 -1
- package/lib-commonjs/components/Portal/usePortalMountNodeStyles.styles.js +4 -2
- package/lib-commonjs/components/Portal/usePortalMountNodeStyles.styles.js.map +1 -1
- package/lib-commonjs/index.js +15 -5
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/virtualParent/elementContains.js +3 -1
- package/lib-commonjs/virtualParent/elementContains.js.map +1 -1
- package/lib-commonjs/virtualParent/getParent.js +5 -2
- package/lib-commonjs/virtualParent/getParent.js.map +1 -1
- package/lib-commonjs/virtualParent/index.js +3 -3
- package/lib-commonjs/virtualParent/index.js.map +1 -1
- package/lib-commonjs/virtualParent/isVirtualElement.js +3 -1
- package/lib-commonjs/virtualParent/isVirtualElement.js.map +1 -1
- package/lib-commonjs/virtualParent/setVirtualParent.js +3 -1
- package/lib-commonjs/virtualParent/setVirtualParent.js.map +1 -1
- package/package.json +9 -9
package/CHANGELOG.json
CHANGED
@@ -2,7 +2,46 @@
|
|
2
2
|
"name": "@fluentui/react-portal",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "Tue,
|
5
|
+
"date": "Tue, 05 Sep 2023 13:23:03 GMT",
|
6
|
+
"tag": "@fluentui/react-portal_v9.3.11",
|
7
|
+
"version": "9.3.11",
|
8
|
+
"comments": {
|
9
|
+
"patch": [
|
10
|
+
{
|
11
|
+
"author": "bernardo.sunderhus@gmail.com",
|
12
|
+
"package": "@fluentui/react-portal",
|
13
|
+
"commit": "eea6d93a62249ba4fba3347fb291c67ee1a3fb24",
|
14
|
+
"comment": "bumps react peer dependencies to v16.14.0"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"author": "bernardo.sunderhus@gmail.com",
|
18
|
+
"package": "@fluentui/react-portal",
|
19
|
+
"commit": "b93c2ac22355b6cb6f33dd509c6cd9c21f4fffc8",
|
20
|
+
"comment": "bumps @swc/helpers version to 0.5.1"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"author": "beachball",
|
24
|
+
"package": "@fluentui/react-portal",
|
25
|
+
"comment": "Bump @fluentui/react-shared-contexts to v9.7.3",
|
26
|
+
"commit": "0bf811dbcaaa6b78743537d142fe4d348b457045"
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"author": "beachball",
|
30
|
+
"package": "@fluentui/react-portal",
|
31
|
+
"comment": "Bump @fluentui/react-tabster to v9.12.6",
|
32
|
+
"commit": "0bf811dbcaaa6b78743537d142fe4d348b457045"
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"author": "beachball",
|
36
|
+
"package": "@fluentui/react-portal",
|
37
|
+
"comment": "Bump @fluentui/react-utilities to v9.13.1",
|
38
|
+
"commit": "0bf811dbcaaa6b78743537d142fe4d348b457045"
|
39
|
+
}
|
40
|
+
]
|
41
|
+
}
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"date": "Tue, 29 Aug 2023 12:57:36 GMT",
|
6
45
|
"tag": "@fluentui/react-portal_v9.3.10",
|
7
46
|
"version": "9.3.10",
|
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 Tue,
|
3
|
+
This log was last generated on Tue, 05 Sep 2023 13:23:03 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
+
## [9.3.11](https://github.com/microsoft/fluentui/tree/@fluentui/react-portal_v9.3.11)
|
8
|
+
|
9
|
+
Tue, 05 Sep 2023 13:23:03 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-portal_v9.3.10..@fluentui/react-portal_v9.3.11)
|
11
|
+
|
12
|
+
### Patches
|
13
|
+
|
14
|
+
- bumps react peer dependencies to v16.14.0 ([PR #28959](https://github.com/microsoft/fluentui/pull/28959) by bernardo.sunderhus@gmail.com)
|
15
|
+
- bumps @swc/helpers version to 0.5.1 ([PR #28989](https://github.com/microsoft/fluentui/pull/28989) by bernardo.sunderhus@gmail.com)
|
16
|
+
- Bump @fluentui/react-shared-contexts to v9.7.3 ([PR #27840](https://github.com/microsoft/fluentui/pull/27840) by beachball)
|
17
|
+
- Bump @fluentui/react-tabster to v9.12.6 ([PR #27840](https://github.com/microsoft/fluentui/pull/27840) by beachball)
|
18
|
+
- Bump @fluentui/react-utilities to v9.13.1 ([PR #27840](https://github.com/microsoft/fluentui/pull/27840) by beachball)
|
19
|
+
|
7
20
|
## [9.3.10](https://github.com/microsoft/fluentui/tree/@fluentui/react-portal_v9.3.10)
|
8
21
|
|
9
|
-
Tue, 29 Aug 2023 12:
|
22
|
+
Tue, 29 Aug 2023 12:57:36 GMT
|
10
23
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-portal_v9.3.9..@fluentui/react-portal_v9.3.10)
|
11
24
|
|
12
25
|
### Patches
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["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"],"names":["React","usePortal_unstable","renderPortal_unstable","Portal","props","state","displayName"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,kBAAkB,QAAQ,cAAc;AACjD,SAASC,qBAAqB,QAAQ,iBAAiB;AAGvD;;;CAGC,GACD,OAAO,MAAMC,SAAgCC,CAAAA
|
1
|
+
{"version":3,"sources":["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"],"names":["React","usePortal_unstable","renderPortal_unstable","Portal","props","state","displayName"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,kBAAkB,QAAQ,cAAc;AACjD,SAASC,qBAAqB,QAAQ,iBAAiB;AAGvD;;;CAGC,GACD,OAAO,MAAMC,SAAgCC,CAAAA;IAC3C,MAAMC,QAAQJ,mBAAmBG;IAEjC,OAAOF,sBAAsBG;AAC/B,EAAE;AAEFF,OAAOG,WAAW,GAAG"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["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"],"names":["ReactDOM","React","renderPortal_unstable","state","span","hidden","ref","virtualParentRootRef","mountNode","createPortal","children"],"mappings":"AAAA,YAAYA,cAAc,YAAY;AACtC,YAAYC,WAAW,QAAQ;AAG/B;;CAEC,GACD,OAAO,MAAMC,wBAAwB,CAACC
|
1
|
+
{"version":3,"sources":["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"],"names":["ReactDOM","React","renderPortal_unstable","state","span","hidden","ref","virtualParentRootRef","mountNode","createPortal","children"],"mappings":"AAAA,YAAYA,cAAc,YAAY;AACtC,YAAYC,WAAW,QAAQ;AAG/B;;CAEC,GACD,OAAO,MAAMC,wBAAwB,CAACC;IACpC,qBACE,oBAACC;QAAKC,QAAAA;QAAOC,KAAKH,MAAMI,oBAAoB;OACzCJ,MAAMK,SAAS,kBAAIR,SAASS,YAAY,CAACN,MAAMO,QAAQ,EAAEP,MAAMK,SAAS;AAG/E,EAAE"}
|
@@ -25,7 +25,7 @@ export function toMountNodeProps(mountNode) {
|
|
25
25
|
*
|
26
26
|
* @param props - props from this instance of Portal
|
27
27
|
*/ export const usePortal_unstable = (props)=>{
|
28
|
-
const { element
|
28
|
+
const { element, className } = toMountNodeProps(props.mountNode);
|
29
29
|
const virtualParentRootRef = React.useRef(null);
|
30
30
|
const fallbackElement = usePortalMountNode({
|
31
31
|
disabled: !!element,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["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"],"names":["isHTMLElement","React","setVirtualParent","usePortalMountNode","toMountNodeProps","mountNode","element","usePortal_unstable","props","className","virtualParentRootRef","useRef","fallbackElement","disabled","state","children","useEffect","current","undefined"],"mappings":"AAAA,SAASA,aAAa,QAAQ,4BAA4B;AAC1D,YAAYC,WAAW,QAAQ;AAE/B,SAASC,gBAAgB,QAAQ,4BAA4B;AAC7D,SAASC,kBAAkB,QAAQ,uBAAuB;AAG1D,OAAO,SAASC,iBAAiBC,SAAmC
|
1
|
+
{"version":3,"sources":["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"],"names":["isHTMLElement","React","setVirtualParent","usePortalMountNode","toMountNodeProps","mountNode","element","usePortal_unstable","props","className","virtualParentRootRef","useRef","fallbackElement","disabled","state","children","useEffect","current","undefined"],"mappings":"AAAA,SAASA,aAAa,QAAQ,4BAA4B;AAC1D,YAAYC,WAAW,QAAQ;AAE/B,SAASC,gBAAgB,QAAQ,4BAA4B;AAC7D,SAASC,kBAAkB,QAAQ,uBAAuB;AAG1D,OAAO,SAASC,iBAAiBC,SAAmC;IAIlE,IAAIL,cAAcK,YAAY;QAC5B,OAAO;YAAEC,SAASD;QAAU;IAC9B;IAEA,IAAI,OAAOA,cAAc,UAAU;QACjC,IAAIA,cAAc,MAAM;YACtB,OAAO;gBAAEC,SAAS;YAAK;QACzB;QAEA,OAAOD;IACT;IAEA,OAAO,CAAC;AACV;AAEA;;;;;;CAMC,GACD,OAAO,MAAME,qBAAqB,CAACC;IACjC,MAAM,EAAEF,OAAO,EAAEG,SAAS,EAAE,GAAGL,iBAAiBI,MAAMH,SAAS;IAE/D,MAAMK,uBAAuBT,MAAMU,MAAM,CAAkB;IAC3D,MAAMC,kBAAkBT,mBAAmB;QAAEU,UAAU,CAAC,CAACP;QAASG;IAAU;IAE5E,MAAMK,QAAqB;QACzBC,UAAUP,MAAMO,QAAQ;QACxBV,WAAWC,oBAAAA,qBAAAA,UAAWM;QACtBF;IACF;IAEAT,MAAMe,SAAS,CAAC;QACd,IAAIF,MAAMJ,oBAAoB,CAACO,OAAO,IAAIH,MAAMT,SAAS,EAAE;YACzDH,iBAAiBY,MAAMT,SAAS,EAAES,MAAMJ,oBAAoB,CAACO,OAAO;QACtE;QACA,OAAO;YACL,IAAIH,MAAMT,SAAS,EAAE;gBACnBH,iBAAiBY,MAAMT,SAAS,EAAEa;YACpC;QACF;IACF,GAAG;QAACJ,MAAMJ,oBAAoB;QAAEI,MAAMT,SAAS;KAAC;IAEhD,OAAOS;AACT,EAAE"}
|
@@ -8,13 +8,14 @@ const useInsertionEffect = React['useInsertion' + 'Effect'];
|
|
8
8
|
/**
|
9
9
|
* Creates a new element on a "document.body" to mount portals.
|
10
10
|
*/ export const usePortalMountNode = (options)=>{
|
11
|
-
|
11
|
+
var _targetDocument;
|
12
|
+
const { targetDocument, dir } = useFluent();
|
12
13
|
const mountNode = usePortalMountNodeContext();
|
13
14
|
const focusVisibleRef = useFocusVisible();
|
14
15
|
const classes = usePortalMountNodeStylesStyles();
|
15
16
|
const themeClassName = useThemeClassName();
|
16
17
|
const className = mergeClasses(themeClassName, classes.root, options.className);
|
17
|
-
const targetNode = mountNode !== null && mountNode !== void 0 ? mountNode : targetDocument === null ||
|
18
|
+
const targetNode = mountNode !== null && mountNode !== void 0 ? mountNode : (_targetDocument = targetDocument) === null || _targetDocument === void 0 ? void 0 : _targetDocument.body;
|
18
19
|
const element = useDisposable(()=>{
|
19
20
|
if (targetNode === undefined || options.disabled) {
|
20
21
|
return [
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["usePortalMountNode.ts"],"sourcesContent":["import * as React from 'react';\nimport {\n useThemeClassName_unstable as useThemeClassName,\n useFluent_unstable as useFluent,\n usePortalMountNode as usePortalMountNodeContext,\n} from '@fluentui/react-shared-contexts';\nimport { mergeClasses } from '@griffel/react';\nimport { useFocusVisible } from '@fluentui/react-tabster';\nimport { useDisposable } from 'use-disposable';\n\nimport { usePortalMountNodeStylesStyles } from './usePortalMountNodeStyles.styles';\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\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 mountNode = usePortalMountNodeContext();\n\n const focusVisibleRef = useFocusVisible<HTMLDivElement>() as React.MutableRefObject<HTMLElement | null>;\n const classes = usePortalMountNodeStylesStyles();\n const themeClassName = useThemeClassName();\n\n const className = mergeClasses(themeClassName, classes.root, options.className);\n const targetNode: HTMLElement | ShadowRoot | undefined = mountNode ?? targetDocument?.body;\n\n const element = useDisposable(() => {\n if (targetNode === undefined || options.disabled) {\n return [null, () => null];\n }\n\n const newElement = targetNode.ownerDocument.createElement('div');\n targetNode.appendChild(newElement);\n return [newElement, () => newElement.remove()];\n }, [targetNode]);\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"],"names":["React","useThemeClassName_unstable","useThemeClassName","useFluent_unstable","useFluent","usePortalMountNode","usePortalMountNodeContext","mergeClasses","useFocusVisible","useDisposable","usePortalMountNodeStylesStyles","useInsertionEffect","options","targetDocument","dir","mountNode","focusVisibleRef","classes","themeClassName","className","root","targetNode","body","element","undefined","disabled","newElement","ownerDocument","createElement","appendChild","remove","classesToApply","split","filter","Boolean","classList","add","setAttribute","current","removeAttribute","useMemo"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SACEC,8BAA8BC,iBAAiB,EAC/CC,sBAAsBC,SAAS,EAC/BC,sBAAsBC,yBAAyB,QAC1C,kCAAkC;AACzC,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,eAAe,QAAQ,0BAA0B;AAC1D,SAASC,aAAa,QAAQ,iBAAiB;AAE/C,SAASC,8BAA8B,QAAQ,oCAAoC;AAEnF,MAAMC,qBAAqB,AAACX,KAAe,CAAC,iBAAiB,SAAS;AAWtE;;CAEC,GACD,OAAO,MAAMK,qBAAqB,CAACO
|
1
|
+
{"version":3,"sources":["usePortalMountNode.ts"],"sourcesContent":["import * as React from 'react';\nimport {\n useThemeClassName_unstable as useThemeClassName,\n useFluent_unstable as useFluent,\n usePortalMountNode as usePortalMountNodeContext,\n} from '@fluentui/react-shared-contexts';\nimport { mergeClasses } from '@griffel/react';\nimport { useFocusVisible } from '@fluentui/react-tabster';\nimport { useDisposable } from 'use-disposable';\n\nimport { usePortalMountNodeStylesStyles } from './usePortalMountNodeStyles.styles';\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\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 mountNode = usePortalMountNodeContext();\n\n const focusVisibleRef = useFocusVisible<HTMLDivElement>() as React.MutableRefObject<HTMLElement | null>;\n const classes = usePortalMountNodeStylesStyles();\n const themeClassName = useThemeClassName();\n\n const className = mergeClasses(themeClassName, classes.root, options.className);\n const targetNode: HTMLElement | ShadowRoot | undefined = mountNode ?? targetDocument?.body;\n\n const element = useDisposable(() => {\n if (targetNode === undefined || options.disabled) {\n return [null, () => null];\n }\n\n const newElement = targetNode.ownerDocument.createElement('div');\n targetNode.appendChild(newElement);\n return [newElement, () => newElement.remove()];\n }, [targetNode]);\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"],"names":["React","useThemeClassName_unstable","useThemeClassName","useFluent_unstable","useFluent","usePortalMountNode","usePortalMountNodeContext","mergeClasses","useFocusVisible","useDisposable","usePortalMountNodeStylesStyles","useInsertionEffect","options","targetDocument","dir","mountNode","focusVisibleRef","classes","themeClassName","className","root","targetNode","body","element","undefined","disabled","newElement","ownerDocument","createElement","appendChild","remove","classesToApply","split","filter","Boolean","classList","add","setAttribute","current","removeAttribute","useMemo"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SACEC,8BAA8BC,iBAAiB,EAC/CC,sBAAsBC,SAAS,EAC/BC,sBAAsBC,yBAAyB,QAC1C,kCAAkC;AACzC,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,eAAe,QAAQ,0BAA0B;AAC1D,SAASC,aAAa,QAAQ,iBAAiB;AAE/C,SAASC,8BAA8B,QAAQ,oCAAoC;AAEnF,MAAMC,qBAAqB,AAACX,KAAe,CAAC,iBAAiB,SAAS;AAWtE;;CAEC,GACD,OAAO,MAAMK,qBAAqB,CAACO;QASqCC;IARtE,MAAM,EAAEA,cAAc,EAAEC,GAAG,EAAE,GAAGV;IAChC,MAAMW,YAAYT;IAElB,MAAMU,kBAAkBR;IACxB,MAAMS,UAAUP;IAChB,MAAMQ,iBAAiBhB;IAEvB,MAAMiB,YAAYZ,aAAaW,gBAAgBD,QAAQG,IAAI,EAAER,QAAQO,SAAS;IAC9E,MAAME,aAAmDN,sBAAAA,uBAAAA,aAAaF,kBAAAA,4BAAAA,sCAAAA,gBAAgBS,IAAI;IAE1F,MAAMC,UAAUd,cAAc;QAC5B,IAAIY,eAAeG,aAAaZ,QAAQa,QAAQ,EAAE;YAChD,OAAO;gBAAC;gBAAM,IAAM;aAAK;QAC3B;QAEA,MAAMC,aAAaL,WAAWM,aAAa,CAACC,aAAa,CAAC;QAC1DP,WAAWQ,WAAW,CAACH;QACvB,OAAO;YAACA;YAAY,IAAMA,WAAWI,MAAM;SAAG;IAChD,GAAG;QAACT;KAAW;IAEf,IAAIV,oBAAoB;QACtB,sDAAsD;QACtDA,mBAAmB;YACjB,IAAI,CAACY,SAAS;gBACZ;YACF;YAEA,MAAMQ,iBAAiBZ,UAAUa,KAAK,CAAC,KAAKC,MAAM,CAACC;YAEnDX,QAAQY,SAAS,CAACC,GAAG,IAAIL;YACzBR,QAAQc,YAAY,CAAC,OAAOvB;YAC5BE,gBAAgBsB,OAAO,GAAGf;YAE1B,OAAO;gBACLA,QAAQY,SAAS,CAACL,MAAM,IAAIC;gBAC5BR,QAAQgB,eAAe,CAAC;YAC1B;QACF,GAAG;YAACpB;YAAWL;YAAKS;YAASP;SAAgB;IAC/C,OAAO;QACL,gDAAgD;QAChD,4EAA4E;QAC5E,yFAAyF;QACzF,iFAAiF;QACjF,sDAAsD;QACtDhB,MAAMwC,OAAO,CAAC;YACZ,IAAI,CAACjB,SAAS;gBACZ;YACF;YAEA,4BAA4B;YAC5BA,QAAQJ,SAAS,GAAGA;YACpBI,QAAQc,YAAY,CAAC,OAAOvB;YAC5BE,gBAAgBsB,OAAO,GAAGf;QAC5B,GAAG;YAACJ;YAAWL;YAAKS;YAASP;SAAgB;IAC/C;IAEA,OAAOO;AACT,EAAE"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["elementContains.ts"],"sourcesContent":["import { getParent } from './getParent';\n\n/**\n * Similar functionality to `element.contains` DOM API for use without of order DOM elements that\n * checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent\n *\n * @returns true if the child can find the parent in its virtual hierarchy\n */\nexport function elementContains(parent: Node | null, child: Node | null): boolean {\n if (!parent || !child) {\n return false;\n }\n\n if (parent === child) {\n return true;\n } else {\n // Tracks references of nodes that have been visited to prevent infinite loops\n const set = new WeakSet<Node>();\n\n while (child) {\n const nextParent: Node | null = getParent(child, {\n skipVirtual: set.has(child),\n });\n set.add(child);\n\n if (nextParent === parent) {\n return true;\n }\n\n child = nextParent;\n }\n }\n\n return false;\n}\n"],"names":["getParent","elementContains","parent","child","set","WeakSet","nextParent","skipVirtual","has","add"],"mappings":"AAAA,SAASA,SAAS,QAAQ,cAAc;AAExC;;;;;CAKC,GACD,OAAO,SAASC,gBAAgBC,MAAmB,EAAEC,KAAkB
|
1
|
+
{"version":3,"sources":["elementContains.ts"],"sourcesContent":["import { getParent } from './getParent';\n\n/**\n * Similar functionality to `element.contains` DOM API for use without of order DOM elements that\n * checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent\n *\n * @returns true if the child can find the parent in its virtual hierarchy\n */\nexport function elementContains(parent: Node | null, child: Node | null): boolean {\n if (!parent || !child) {\n return false;\n }\n\n if (parent === child) {\n return true;\n } else {\n // Tracks references of nodes that have been visited to prevent infinite loops\n const set = new WeakSet<Node>();\n\n while (child) {\n const nextParent: Node | null = getParent(child, {\n skipVirtual: set.has(child),\n });\n set.add(child);\n\n if (nextParent === parent) {\n return true;\n }\n\n child = nextParent;\n }\n }\n\n return false;\n}\n"],"names":["getParent","elementContains","parent","child","set","WeakSet","nextParent","skipVirtual","has","add"],"mappings":"AAAA,SAASA,SAAS,QAAQ,cAAc;AAExC;;;;;CAKC,GACD,OAAO,SAASC,gBAAgBC,MAAmB,EAAEC,KAAkB;IACrE,IAAI,CAACD,UAAU,CAACC,OAAO;QACrB,OAAO;IACT;IAEA,IAAID,WAAWC,OAAO;QACpB,OAAO;IACT,OAAO;QACL,8EAA8E;QAC9E,MAAMC,MAAM,IAAIC;QAEhB,MAAOF,MAAO;YACZ,MAAMG,aAA0BN,UAAUG,OAAO;gBAC/CI,aAAaH,IAAII,GAAG,CAACL;YACvB;YACAC,IAAIK,GAAG,CAACN;YAER,IAAIG,eAAeJ,QAAQ;gBACzB,OAAO;YACT;YAEAC,QAAQG;QACV;IACF;IAEA,OAAO;AACT"}
|
@@ -8,6 +8,7 @@ import { isVirtualElement } from './isVirtualElement';
|
|
8
8
|
* Gets the element which is the parent of a given element.
|
9
9
|
* This method prefers the virtual parent over real DOM parent when present.
|
10
10
|
*/ export function getParent(child, options = {}) {
|
11
|
+
var _child;
|
11
12
|
if (!child) {
|
12
13
|
return null;
|
13
14
|
}
|
@@ -17,5 +18,5 @@ import { isVirtualElement } from './isVirtualElement';
|
|
17
18
|
return virtualParent;
|
18
19
|
}
|
19
20
|
}
|
20
|
-
return (child === null ||
|
21
|
+
return ((_child = child) === null || _child === void 0 ? void 0 : _child.parentNode) || null;
|
21
22
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["getParent.ts"],"sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n\ntype GetParentOptions = {\n /**\n * Indicates if getParent() should ignore a virtual parent.\n */\n skipVirtual?: boolean;\n};\n\n/**\n * Gets the virtual parent given the child element, if it exists.\n */\nfunction getVirtualParent(child: Node): Node | null {\n return isVirtualElement(child) ? child._virtual.parent || null : null;\n}\n\n/**\n * Gets the element which is the parent of a given element.\n * This method prefers the virtual parent over real DOM parent when present.\n */\nexport function getParent(child: Node | null, options: GetParentOptions = {}): Node | null {\n if (!child) {\n return null;\n }\n\n if (!options.skipVirtual) {\n const virtualParent = getVirtualParent(child);\n\n if (virtualParent) {\n return virtualParent;\n }\n }\n\n return child?.parentNode || null;\n}\n"],"names":["isVirtualElement","getVirtualParent","child","_virtual","parent","getParent","options","skipVirtual","virtualParent","parentNode"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,qBAAqB;AAStD;;CAEC,GACD,SAASC,iBAAiBC,KAAW
|
1
|
+
{"version":3,"sources":["getParent.ts"],"sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n\ntype GetParentOptions = {\n /**\n * Indicates if getParent() should ignore a virtual parent.\n */\n skipVirtual?: boolean;\n};\n\n/**\n * Gets the virtual parent given the child element, if it exists.\n */\nfunction getVirtualParent(child: Node): Node | null {\n return isVirtualElement(child) ? child._virtual.parent || null : null;\n}\n\n/**\n * Gets the element which is the parent of a given element.\n * This method prefers the virtual parent over real DOM parent when present.\n */\nexport function getParent(child: Node | null, options: GetParentOptions = {}): Node | null {\n if (!child) {\n return null;\n }\n\n if (!options.skipVirtual) {\n const virtualParent = getVirtualParent(child);\n\n if (virtualParent) {\n return virtualParent;\n }\n }\n\n return child?.parentNode || null;\n}\n"],"names":["isVirtualElement","getVirtualParent","child","_virtual","parent","getParent","options","skipVirtual","virtualParent","parentNode"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,qBAAqB;AAStD;;CAEC,GACD,SAASC,iBAAiBC,KAAW;IACnC,OAAOF,iBAAiBE,SAASA,MAAMC,QAAQ,CAACC,MAAM,IAAI,OAAO;AACnE;AAEA;;;CAGC,GACD,OAAO,SAASC,UAAUH,KAAkB,EAAEI,UAA4B,CAAC,CAAC;QAanEJ;IAZP,IAAI,CAACA,OAAO;QACV,OAAO;IACT;IAEA,IAAI,CAACI,QAAQC,WAAW,EAAE;QACxB,MAAMC,gBAAgBP,iBAAiBC;QAEvC,IAAIM,eAAe;YACjB,OAAOA;QACT;IACF;IAEA,OAAON,EAAAA,SAAAA,mBAAAA,6BAAAA,OAAOO,UAAU,KAAI;AAC9B"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["isVirtualElement.ts"],"sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Determines whether or not an element has the virtual hierarchy extension.\n */\nexport function isVirtualElement(element: Node | VirtualElement): element is VirtualElement {\n return element && !!(<VirtualElement>element)._virtual;\n}\n"],"names":["isVirtualElement","element","_virtual"],"mappings":"AAEA;;CAEC,GACD,OAAO,SAASA,iBAAiBC,OAA8B
|
1
|
+
{"version":3,"sources":["isVirtualElement.ts"],"sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Determines whether or not an element has the virtual hierarchy extension.\n */\nexport function isVirtualElement(element: Node | VirtualElement): element is VirtualElement {\n return element && !!(<VirtualElement>element)._virtual;\n}\n"],"names":["isVirtualElement","element","_virtual"],"mappings":"AAEA;;CAEC,GACD,OAAO,SAASA,iBAAiBC,OAA8B;IAC7D,OAAOA,WAAW,CAAC,CAAC,AAAiBA,QAASC,QAAQ;AACxD"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["setVirtualParent.ts"],"sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Sets the virtual parent of an element.\n *\n * @param child - Theme element to set the virtual parent\n * @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship\n */\nexport function setVirtualParent(child: Node, parent?: Node): void {\n if (!child) {\n return;\n }\n\n const virtualChild = child as VirtualElement;\n\n if (!virtualChild._virtual) {\n virtualChild._virtual = {};\n }\n\n virtualChild._virtual.parent = parent;\n}\n"],"names":["setVirtualParent","child","parent","virtualChild","_virtual"],"mappings":"AAEA;;;;;CAKC,GACD,OAAO,SAASA,iBAAiBC,KAAW,EAAEC,MAAa
|
1
|
+
{"version":3,"sources":["setVirtualParent.ts"],"sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Sets the virtual parent of an element.\n *\n * @param child - Theme element to set the virtual parent\n * @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship\n */\nexport function setVirtualParent(child: Node, parent?: Node): void {\n if (!child) {\n return;\n }\n\n const virtualChild = child as VirtualElement;\n\n if (!virtualChild._virtual) {\n virtualChild._virtual = {};\n }\n\n virtualChild._virtual.parent = parent;\n}\n"],"names":["setVirtualParent","child","parent","virtualChild","_virtual"],"mappings":"AAEA;;;;;CAKC,GACD,OAAO,SAASA,iBAAiBC,KAAW,EAAEC,MAAa;IACzD,IAAI,CAACD,OAAO;QACV;IACF;IAEA,MAAME,eAAeF;IAErB,IAAI,CAACE,aAAaC,QAAQ,EAAE;QAC1BD,aAAaC,QAAQ,GAAG,CAAC;IAC3B;IAEAD,aAAaC,QAAQ,CAACF,MAAM,GAAGA;AACjC"}
|
package/lib-commonjs/Portal.js
CHANGED
@@ -2,5 +2,5 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
3
3
|
value: true
|
4
4
|
});
|
5
|
-
const
|
6
|
-
|
5
|
+
const _export_star = require("@swc/helpers/_/_export_star");
|
6
|
+
_export_star._(require("./components/Portal/index"), exports);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["Portal.js"],"sourcesContent":["export * from './components/Portal/index';\n"],"names":[],"mappings":";;;;;
|
1
|
+
{"version":3,"sources":["Portal.js"],"sourcesContent":["export * from './components/Portal/index';\n"],"names":[],"mappings":";;;;;uBAAc"}
|
@@ -4,10 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
});
|
5
5
|
Object.defineProperty(exports, "Portal", {
|
6
6
|
enumerable: true,
|
7
|
-
get: ()
|
7
|
+
get: function() {
|
8
|
+
return Portal;
|
9
|
+
}
|
8
10
|
});
|
9
|
-
const
|
10
|
-
const _react = /*#__PURE__*/
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
11
13
|
const _usePortal = require("./usePortal");
|
12
14
|
const _renderPortal = require("./renderPortal");
|
13
15
|
const Portal = (props)=>{
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["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 */ export const Portal = (props)=>{\n const state = usePortal_unstable(props);\n return renderPortal_unstable(state);\n};\nPortal.displayName = 'Portal';\n"],"names":["Portal","props","state","usePortal_unstable","renderPortal_unstable","displayName"],"mappings":";;;;+BAMiBA
|
1
|
+
{"version":3,"sources":["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 */ export const Portal = (props)=>{\n const state = usePortal_unstable(props);\n return renderPortal_unstable(state);\n};\nPortal.displayName = 'Portal';\n"],"names":["Portal","props","state","usePortal_unstable","renderPortal_unstable","displayName"],"mappings":";;;;+BAMiBA;;;eAAAA;;;;iEANM;2BACY;8BACG;AAI3B,MAAMA,SAAS,CAACC;IACvB,MAAMC,QAAQC,IAAAA,6BAAkB,EAACF;IACjC,OAAOG,IAAAA,mCAAqB,EAACF;AACjC;AACAF,OAAOK,WAAW,GAAG"}
|
@@ -2,5 +2,5 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
3
3
|
value: true
|
4
4
|
});
|
5
|
-
const
|
6
|
-
const _react = /*#__PURE__*/
|
5
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
6
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["Portal.types.js"],"sourcesContent":["import * as React from 'react';\n"],"names":[],"mappings":";;;;;
|
1
|
+
{"version":3,"sources":["Portal.types.js"],"sourcesContent":["import * as React from 'react';\n"],"names":[],"mappings":";;;;;iEAAuB"}
|
@@ -2,8 +2,8 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
3
3
|
value: true
|
4
4
|
});
|
5
|
-
const
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
const _export_star = require("@swc/helpers/_/_export_star");
|
6
|
+
_export_star._(require("./Portal"), exports);
|
7
|
+
_export_star._(require("./Portal.types"), exports);
|
8
|
+
_export_star._(require("./renderPortal"), exports);
|
9
|
+
_export_star._(require("./usePortal"), exports);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.js"],"sourcesContent":["export * from './Portal';\nexport * from './Portal.types';\nexport * from './renderPortal';\nexport * from './usePortal';\n"],"names":[],"mappings":";;;;;
|
1
|
+
{"version":3,"sources":["index.js"],"sourcesContent":["export * from './Portal';\nexport * from './Portal.types';\nexport * from './renderPortal';\nexport * from './usePortal';\n"],"names":[],"mappings":";;;;;uBAAc;uBACA;uBACA;uBACA"}
|
@@ -4,14 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
});
|
5
5
|
Object.defineProperty(exports, "renderPortal_unstable", {
|
6
6
|
enumerable: true,
|
7
|
-
get: ()
|
7
|
+
get: function() {
|
8
|
+
return renderPortal_unstable;
|
9
|
+
}
|
8
10
|
});
|
9
|
-
const
|
10
|
-
const
|
11
|
-
const _react = /*#__PURE__*/
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
+
const _reactdom = /*#__PURE__*/ _interop_require_wildcard._(require("react-dom"));
|
13
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
12
14
|
const renderPortal_unstable = (state)=>{
|
13
15
|
return /*#__PURE__*/ _react.createElement("span", {
|
14
16
|
hidden: true,
|
15
17
|
ref: state.virtualParentRootRef
|
16
|
-
}, state.mountNode && /*#__PURE__*/
|
18
|
+
}, state.mountNode && /*#__PURE__*/ _reactdom.createPortal(state.children, state.mountNode));
|
17
19
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["renderPortal.js"],"sourcesContent":["import * as ReactDOM from 'react-dom';\nimport * as React from 'react';\n/**\n * Render the final JSX of Portal\n */ export 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"],"names":["renderPortal_unstable","state","React","createElement","hidden","ref","virtualParentRootRef","mountNode","ReactDOM","createPortal","children"],"mappings":";;;;+BAIiBA
|
1
|
+
{"version":3,"sources":["renderPortal.js"],"sourcesContent":["import * as ReactDOM from 'react-dom';\nimport * as React from 'react';\n/**\n * Render the final JSX of Portal\n */ export 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"],"names":["renderPortal_unstable","state","React","createElement","hidden","ref","virtualParentRootRef","mountNode","ReactDOM","createPortal","children"],"mappings":";;;;+BAIiBA;;;eAAAA;;;;oEAJS;iEACH;AAGZ,MAAMA,wBAAwB,CAACC;IACtC,OAAO,WAAW,GAAGC,OAAMC,aAAa,CAAC,QAAQ;QAC7CC,QAAQ;QACRC,KAAKJ,MAAMK,oBAAoB;IACnC,GAAGL,MAAMM,SAAS,IAAI,WAAW,GAAGC,UAASC,YAAY,CAACR,MAAMS,QAAQ,EAAET,MAAMM,SAAS;AAC7F"}
|
@@ -9,16 +9,20 @@ function _export(target, all) {
|
|
9
9
|
});
|
10
10
|
}
|
11
11
|
_export(exports, {
|
12
|
-
toMountNodeProps: ()
|
13
|
-
|
12
|
+
toMountNodeProps: function() {
|
13
|
+
return toMountNodeProps;
|
14
|
+
},
|
15
|
+
usePortal_unstable: function() {
|
16
|
+
return usePortal_unstable;
|
17
|
+
}
|
14
18
|
});
|
15
|
-
const
|
16
|
-
const
|
17
|
-
const _react = /*#__PURE__*/
|
19
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
20
|
+
const _reactutilities = require("@fluentui/react-utilities");
|
21
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
18
22
|
const _index = require("../../virtualParent/index");
|
19
23
|
const _usePortalMountNode = require("./usePortalMountNode");
|
20
24
|
function toMountNodeProps(mountNode) {
|
21
|
-
if ((0,
|
25
|
+
if ((0, _reactutilities.isHTMLElement)(mountNode)) {
|
22
26
|
return {
|
23
27
|
element: mountNode
|
24
28
|
};
|
@@ -34,7 +38,7 @@ function toMountNodeProps(mountNode) {
|
|
34
38
|
return {};
|
35
39
|
}
|
36
40
|
const usePortal_unstable = (props)=>{
|
37
|
-
const { element
|
41
|
+
const { element, className } = toMountNodeProps(props.mountNode);
|
38
42
|
const virtualParentRootRef = _react.useRef(null);
|
39
43
|
const fallbackElement = (0, _usePortalMountNode.usePortalMountNode)({
|
40
44
|
disabled: !!element,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["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 */ export const usePortal_unstable = (props)=>{\n const { element
|
1
|
+
{"version":3,"sources":["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 */ export const usePortal_unstable = (props)=>{\n const { element, className } = toMountNodeProps(props.mountNode);\n const virtualParentRootRef = React.useRef(null);\n const fallbackElement = usePortalMountNode({\n disabled: !!element,\n className\n });\n const state = {\n children: props.children,\n mountNode: element !== null && element !== void 0 ? element : fallbackElement,\n virtualParentRootRef\n };\n React.useEffect(()=>{\n if (state.virtualParentRootRef.current && state.mountNode) {\n setVirtualParent(state.mountNode, state.virtualParentRootRef.current);\n }\n return ()=>{\n if (state.mountNode) {\n setVirtualParent(state.mountNode, undefined);\n }\n };\n }, [\n state.virtualParentRootRef,\n state.mountNode\n ]);\n return state;\n};\n"],"names":["toMountNodeProps","usePortal_unstable","mountNode","isHTMLElement","element","props","className","virtualParentRootRef","React","useRef","fallbackElement","usePortalMountNode","disabled","state","children","useEffect","current","setVirtualParent","undefined"],"mappings":";;;;;;;;;;;IAIgBA,gBAAgB;eAAhBA;;IAsBCC,kBAAkB;eAAlBA;;;;gCA1Ba;iEACP;uBACU;oCACE;AAC5B,SAASD,iBAAiBE,SAAS;IACtC,IAAIC,IAAAA,6BAAa,EAACD,YAAY;QAC1B,OAAO;YACHE,SAASF;QACb;IACJ;IACA,IAAI,OAAOA,cAAc,UAAU;QAC/B,IAAIA,cAAc,MAAM;YACpB,OAAO;gBACHE,SAAS;YACb;QACJ;QACA,OAAOF;IACX;IACA,OAAO,CAAC;AACZ;AAOW,MAAMD,qBAAqB,CAACI;IACnC,MAAM,EAAED,OAAO,EAAEE,SAAS,EAAE,GAAGN,iBAAiBK,MAAMH,SAAS;IAC/D,MAAMK,uBAAuBC,OAAMC,MAAM,CAAC;IAC1C,MAAMC,kBAAkBC,IAAAA,sCAAkB,EAAC;QACvCC,UAAU,CAAC,CAACR;QACZE;IACJ;IACA,MAAMO,QAAQ;QACVC,UAAUT,MAAMS,QAAQ;QACxBZ,WAAWE,YAAY,QAAQA,YAAY,KAAK,IAAIA,UAAUM;QAC9DH;IACJ;IACAC,OAAMO,SAAS,CAAC;QACZ,IAAIF,MAAMN,oBAAoB,CAACS,OAAO,IAAIH,MAAMX,SAAS,EAAE;YACvDe,IAAAA,uBAAgB,EAACJ,MAAMX,SAAS,EAAEW,MAAMN,oBAAoB,CAACS,OAAO;QACxE;QACA,OAAO;YACH,IAAIH,MAAMX,SAAS,EAAE;gBACjBe,IAAAA,uBAAgB,EAACJ,MAAMX,SAAS,EAAEgB;YACtC;QACJ;IACJ,GAAG;QACCL,MAAMN,oBAAoB;QAC1BM,MAAMX,SAAS;KAClB;IACD,OAAOW;AACX"}
|
@@ -4,25 +4,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
});
|
5
5
|
Object.defineProperty(exports, "usePortalMountNode", {
|
6
6
|
enumerable: true,
|
7
|
-
get: ()
|
7
|
+
get: function() {
|
8
|
+
return usePortalMountNode;
|
9
|
+
}
|
8
10
|
});
|
9
|
-
const
|
10
|
-
const _react = /*#__PURE__*/
|
11
|
-
const
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
13
|
+
const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
|
12
14
|
const _react1 = require("@griffel/react");
|
13
|
-
const
|
14
|
-
const
|
15
|
-
const
|
15
|
+
const _reacttabster = require("@fluentui/react-tabster");
|
16
|
+
const _usedisposable = require("use-disposable");
|
17
|
+
const _usePortalMountNodeStylesstyles = require("./usePortalMountNodeStyles.styles");
|
16
18
|
const useInsertionEffect = _react['useInsertion' + 'Effect'];
|
17
19
|
const usePortalMountNode = (options)=>{
|
18
|
-
|
19
|
-
const
|
20
|
-
const
|
21
|
-
const
|
22
|
-
const
|
20
|
+
var _targetDocument;
|
21
|
+
const { targetDocument, dir } = (0, _reactsharedcontexts.useFluent_unstable)();
|
22
|
+
const mountNode = (0, _reactsharedcontexts.usePortalMountNode)();
|
23
|
+
const focusVisibleRef = (0, _reacttabster.useFocusVisible)();
|
24
|
+
const classes = (0, _usePortalMountNodeStylesstyles.usePortalMountNodeStylesStyles)();
|
25
|
+
const themeClassName = (0, _reactsharedcontexts.useThemeClassName_unstable)();
|
23
26
|
const className = (0, _react1.mergeClasses)(themeClassName, classes.root, options.className);
|
24
|
-
const targetNode = mountNode !== null && mountNode !== void 0 ? mountNode : targetDocument === null ||
|
25
|
-
const element = (0,
|
27
|
+
const targetNode = mountNode !== null && mountNode !== void 0 ? mountNode : (_targetDocument = targetDocument) === null || _targetDocument === void 0 ? void 0 : _targetDocument.body;
|
28
|
+
const element = (0, _usedisposable.useDisposable)(()=>{
|
26
29
|
if (targetNode === undefined || options.disabled) {
|
27
30
|
return [
|
28
31
|
null,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["usePortalMountNode.js"],"sourcesContent":["import * as React from 'react';\nimport { useThemeClassName_unstable as useThemeClassName, useFluent_unstable as useFluent, usePortalMountNode as usePortalMountNodeContext } from '@fluentui/react-shared-contexts';\nimport { mergeClasses } from '@griffel/react';\nimport { useFocusVisible } from '@fluentui/react-tabster';\nimport { useDisposable } from 'use-disposable';\nimport { usePortalMountNodeStylesStyles } from './usePortalMountNodeStyles.styles';\nconst useInsertionEffect = React['useInsertion' + 'Effect'];\n/**\n * Creates a new element on a \"document.body\" to mount portals.\n */ export const usePortalMountNode = (options)=>{\n const { targetDocument
|
1
|
+
{"version":3,"sources":["usePortalMountNode.js"],"sourcesContent":["import * as React from 'react';\nimport { useThemeClassName_unstable as useThemeClassName, useFluent_unstable as useFluent, usePortalMountNode as usePortalMountNodeContext } from '@fluentui/react-shared-contexts';\nimport { mergeClasses } from '@griffel/react';\nimport { useFocusVisible } from '@fluentui/react-tabster';\nimport { useDisposable } from 'use-disposable';\nimport { usePortalMountNodeStylesStyles } from './usePortalMountNodeStyles.styles';\nconst useInsertionEffect = React['useInsertion' + 'Effect'];\n/**\n * Creates a new element on a \"document.body\" to mount portals.\n */ export const usePortalMountNode = (options)=>{\n var _targetDocument;\n const { targetDocument, dir } = useFluent();\n const mountNode = usePortalMountNodeContext();\n const focusVisibleRef = useFocusVisible();\n const classes = usePortalMountNodeStylesStyles();\n const themeClassName = useThemeClassName();\n const className = mergeClasses(themeClassName, classes.root, options.className);\n const targetNode = mountNode !== null && mountNode !== void 0 ? mountNode : (_targetDocument = targetDocument) === null || _targetDocument === void 0 ? void 0 : _targetDocument.body;\n const element = useDisposable(()=>{\n if (targetNode === undefined || options.disabled) {\n return [\n null,\n ()=>null\n ];\n }\n const newElement = targetNode.ownerDocument.createElement('div');\n targetNode.appendChild(newElement);\n return [\n newElement,\n ()=>newElement.remove()\n ];\n }, [\n targetNode\n ]);\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 }, [\n className,\n dir,\n element,\n focusVisibleRef\n ]);\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 }, [\n className,\n dir,\n element,\n focusVisibleRef\n ]);\n }\n return element;\n};\n"],"names":["usePortalMountNode","useInsertionEffect","React","options","_targetDocument","targetDocument","dir","useFluent","mountNode","usePortalMountNodeContext","focusVisibleRef","useFocusVisible","classes","usePortalMountNodeStylesStyles","themeClassName","useThemeClassName","className","mergeClasses","root","targetNode","body","element","useDisposable","undefined","disabled","newElement","ownerDocument","createElement","appendChild","remove","classesToApply","split","filter","Boolean","classList","add","setAttribute","current","removeAttribute","useMemo"],"mappings":";;;;+BASiBA;;;eAAAA;;;;iEATM;qCAC2H;wBACrH;8BACG;+BACF;gDACiB;AAC/C,MAAMC,qBAAqBC,MAAK,CAAC,iBAAiB,SAAS;AAGhD,MAAMF,qBAAqB,CAACG;IACnC,IAAIC;IACJ,MAAM,EAAEC,cAAc,EAAEC,GAAG,EAAE,GAAGC,IAAAA,uCAAS;IACzC,MAAMC,YAAYC,IAAAA,uCAAyB;IAC3C,MAAMC,kBAAkBC,IAAAA,6BAAe;IACvC,MAAMC,UAAUC,IAAAA,8DAA8B;IAC9C,MAAMC,iBAAiBC,IAAAA,+CAAiB;IACxC,MAAMC,YAAYC,IAAAA,oBAAY,EAACH,gBAAgBF,QAAQM,IAAI,EAAEf,QAAQa,SAAS;IAC9E,MAAMG,aAAaX,cAAc,QAAQA,cAAc,KAAK,IAAIA,YAAY,AAACJ,CAAAA,kBAAkBC,cAAa,MAAO,QAAQD,oBAAoB,KAAK,IAAI,KAAK,IAAIA,gBAAgBgB,IAAI;IACrL,MAAMC,UAAUC,IAAAA,4BAAa,EAAC;QAC1B,IAAIH,eAAeI,aAAapB,QAAQqB,QAAQ,EAAE;YAC9C,OAAO;gBACH;gBACA,IAAI;aACP;QACL;QACA,MAAMC,aAAaN,WAAWO,aAAa,CAACC,aAAa,CAAC;QAC1DR,WAAWS,WAAW,CAACH;QACvB,OAAO;YACHA;YACA,IAAIA,WAAWI,MAAM;SACxB;IACL,GAAG;QACCV;KACH;IACD,IAAIlB,oBAAoB;QACpB,sDAAsD;QACtDA,mBAAmB;YACf,IAAI,CAACoB,SAAS;gBACV;YACJ;YACA,MAAMS,iBAAiBd,UAAUe,KAAK,CAAC,KAAKC,MAAM,CAACC;YACnDZ,QAAQa,SAAS,CAACC,GAAG,IAAIL;YACzBT,QAAQe,YAAY,CAAC,OAAO9B;YAC5BI,gBAAgB2B,OAAO,GAAGhB;YAC1B,OAAO;gBACHA,QAAQa,SAAS,CAACL,MAAM,IAAIC;gBAC5BT,QAAQiB,eAAe,CAAC;YAC5B;QACJ,GAAG;YACCtB;YACAV;YACAe;YACAX;SACH;IACL,OAAO;QACH,gDAAgD;QAChD,4EAA4E;QAC5E,yFAAyF;QACzF,iFAAiF;QACjF,sDAAsD;QACtDR,OAAMqC,OAAO,CAAC;YACV,IAAI,CAAClB,SAAS;gBACV;YACJ;YACA,4BAA4B;YAC5BA,QAAQL,SAAS,GAAGA;YACpBK,QAAQe,YAAY,CAAC,OAAO9B;YAC5BI,gBAAgB2B,OAAO,GAAGhB;QAC9B,GAAG;YACCL;YACAV;YACAe;YACAX;SACH;IACL;IACA,OAAOW;AACX"}
|
@@ -4,10 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
});
|
5
5
|
Object.defineProperty(exports, "usePortalMountNodeStylesStyles", {
|
6
6
|
enumerable: true,
|
7
|
-
get: ()
|
7
|
+
get: function() {
|
8
|
+
return usePortalMountNodeStylesStyles;
|
9
|
+
}
|
8
10
|
});
|
9
11
|
const _react = require("@griffel/react");
|
10
|
-
const usePortalMountNodeStylesStyles = /*#__PURE__*/ (0, _react
|
12
|
+
const usePortalMountNodeStylesStyles = /*#__PURE__*/ (0, _react.__styles)({
|
11
13
|
root: {
|
12
14
|
qhf8xq: "f1euv43f",
|
13
15
|
Bhzewxz: "f15twtuk",
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["usePortalMountNodeStyles.styles.js"],"sourcesContent":["import { __styles } from '@griffel/react';\nexport const usePortalMountNodeStylesStyles = /*#__PURE__*/__styles({\n root: {\n qhf8xq: \"f1euv43f\",\n Bhzewxz: \"f15twtuk\",\n oyh7mz: [\"f1vgc2s3\", \"f1e31b4d\"],\n j35jbq: [\"f1e31b4d\", \"f1vgc2s3\"],\n Bj3rh1h: \"f494woh\"\n }\n}, {\n d: [\".f1euv43f{position:absolute;}\", \".f15twtuk{top:0;}\", \".f1vgc2s3{left:0;}\", \".f1e31b4d{right:0;}\", \".f494woh{z-index:1000000;}\"]\n});\n//# sourceMappingURL=usePortalMountNodeStyles.styles.js.map"],"names":["usePortalMountNodeStylesStyles","__styles","root","qhf8xq","Bhzewxz","oyh7mz","j35jbq","Bj3rh1h","d"],"mappings":";;;;+BACaA
|
1
|
+
{"version":3,"sources":["usePortalMountNodeStyles.styles.js"],"sourcesContent":["import { __styles } from '@griffel/react';\nexport const usePortalMountNodeStylesStyles = /*#__PURE__*/__styles({\n root: {\n qhf8xq: \"f1euv43f\",\n Bhzewxz: \"f15twtuk\",\n oyh7mz: [\"f1vgc2s3\", \"f1e31b4d\"],\n j35jbq: [\"f1e31b4d\", \"f1vgc2s3\"],\n Bj3rh1h: \"f494woh\"\n }\n}, {\n d: [\".f1euv43f{position:absolute;}\", \".f15twtuk{top:0;}\", \".f1vgc2s3{left:0;}\", \".f1e31b4d{right:0;}\", \".f494woh{z-index:1000000;}\"]\n});\n//# sourceMappingURL=usePortalMountNodeStyles.styles.js.map"],"names":["usePortalMountNodeStylesStyles","__styles","root","qhf8xq","Bhzewxz","oyh7mz","j35jbq","Bj3rh1h","d"],"mappings":";;;;+BACaA;;;eAAAA;;;uBADY;AAClB,MAAMA,iCAAiC,WAAW,GAAEC,IAAAA,eAAQ,EAAC;IAClEC,MAAM;QACJC,QAAQ;QACRC,SAAS;QACTC,QAAQ;YAAC;YAAY;SAAW;QAChCC,QAAQ;YAAC;YAAY;SAAW;QAChCC,SAAS;IACX;AACF,GAAG;IACDC,GAAG;QAAC;QAAiC;QAAqB;QAAsB;QAAuB;KAA6B;AACtI,IACA,2DAA2D"}
|
package/lib-commonjs/index.js
CHANGED
@@ -9,11 +9,21 @@ function _export(target, all) {
|
|
9
9
|
});
|
10
10
|
}
|
11
11
|
_export(exports, {
|
12
|
-
Portal: ()
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
Portal: function() {
|
13
|
+
return _index.Portal;
|
14
|
+
},
|
15
|
+
renderPortal_unstable: function() {
|
16
|
+
return _index.renderPortal_unstable;
|
17
|
+
},
|
18
|
+
usePortal_unstable: function() {
|
19
|
+
return _index.usePortal_unstable;
|
20
|
+
},
|
21
|
+
elementContains: function() {
|
22
|
+
return _index1.elementContains;
|
23
|
+
},
|
24
|
+
setVirtualParent: function() {
|
25
|
+
return _index1.setVirtualParent;
|
26
|
+
}
|
17
27
|
});
|
18
28
|
const _index = require("./components/Portal/index");
|
19
29
|
const _index1 = require("./virtualParent/index");
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.js"],"sourcesContent":["export { Portal, renderPortal_unstable, usePortal_unstable } from './components/Portal/index';\nexport { elementContains, setVirtualParent } from './virtualParent/index';\n"],"names":["Portal","renderPortal_unstable","usePortal_unstable","elementContains","setVirtualParent"],"mappings":";;;;;;;;;;;IAASA,MAAM,
|
1
|
+
{"version":3,"sources":["index.js"],"sourcesContent":["export { Portal, renderPortal_unstable, usePortal_unstable } from './components/Portal/index';\nexport { elementContains, setVirtualParent } from './virtualParent/index';\n"],"names":["Portal","renderPortal_unstable","usePortal_unstable","elementContains","setVirtualParent"],"mappings":";;;;;;;;;;;IAASA,MAAM;eAANA,aAAM;;IAAEC,qBAAqB;eAArBA,4BAAqB;;IAAEC,kBAAkB;eAAlBA,yBAAkB;;IACjDC,eAAe;eAAfA,uBAAe;;IAAEC,gBAAgB;eAAhBA,wBAAgB;;;uBADwB;wBAChB"}
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
});
|
5
5
|
Object.defineProperty(exports, "elementContains", {
|
6
6
|
enumerable: true,
|
7
|
-
get: ()
|
7
|
+
get: function() {
|
8
|
+
return elementContains;
|
9
|
+
}
|
8
10
|
});
|
9
11
|
const _getParent = require("./getParent");
|
10
12
|
function elementContains(parent, child) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["elementContains.js"],"sourcesContent":["import { getParent } from './getParent';\n/**\n * Similar functionality to `element.contains` DOM API for use without of order DOM elements that\n * checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent\n *\n * @returns true if the child can find the parent in its virtual hierarchy\n */ export function elementContains(parent, child) {\n if (!parent || !child) {\n return false;\n }\n if (parent === child) {\n return true;\n } else {\n // Tracks references of nodes that have been visited to prevent infinite loops\n const set = new WeakSet();\n while(child){\n const nextParent = getParent(child, {\n skipVirtual: set.has(child)\n });\n set.add(child);\n if (nextParent === parent) {\n return true;\n }\n child = nextParent;\n }\n }\n return false;\n}\n"],"names":["elementContains","parent","child","set","WeakSet","nextParent","getParent","skipVirtual","has","add"],"mappings":";;;;+BAMoBA
|
1
|
+
{"version":3,"sources":["elementContains.js"],"sourcesContent":["import { getParent } from './getParent';\n/**\n * Similar functionality to `element.contains` DOM API for use without of order DOM elements that\n * checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent\n *\n * @returns true if the child can find the parent in its virtual hierarchy\n */ export function elementContains(parent, child) {\n if (!parent || !child) {\n return false;\n }\n if (parent === child) {\n return true;\n } else {\n // Tracks references of nodes that have been visited to prevent infinite loops\n const set = new WeakSet();\n while(child){\n const nextParent = getParent(child, {\n skipVirtual: set.has(child)\n });\n set.add(child);\n if (nextParent === parent) {\n return true;\n }\n child = nextParent;\n }\n }\n return false;\n}\n"],"names":["elementContains","parent","child","set","WeakSet","nextParent","getParent","skipVirtual","has","add"],"mappings":";;;;+BAMoBA;;;eAAAA;;;2BANM;AAMf,SAASA,gBAAgBC,MAAM,EAAEC,KAAK;IAC7C,IAAI,CAACD,UAAU,CAACC,OAAO;QACnB,OAAO;IACX;IACA,IAAID,WAAWC,OAAO;QAClB,OAAO;IACX,OAAO;QACH,8EAA8E;QAC9E,MAAMC,MAAM,IAAIC;QAChB,MAAMF,MAAM;YACR,MAAMG,aAAaC,IAAAA,oBAAS,EAACJ,OAAO;gBAChCK,aAAaJ,IAAIK,GAAG,CAACN;YACzB;YACAC,IAAIM,GAAG,CAACP;YACR,IAAIG,eAAeJ,QAAQ;gBACvB,OAAO;YACX;YACAC,QAAQG;QACZ;IACJ;IACA,OAAO;AACX"}
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
});
|
5
5
|
Object.defineProperty(exports, "getParent", {
|
6
6
|
enumerable: true,
|
7
|
-
get: ()
|
7
|
+
get: function() {
|
8
|
+
return getParent;
|
9
|
+
}
|
8
10
|
});
|
9
11
|
const _isVirtualElement = require("./isVirtualElement");
|
10
12
|
/**
|
@@ -13,6 +15,7 @@ const _isVirtualElement = require("./isVirtualElement");
|
|
13
15
|
return (0, _isVirtualElement.isVirtualElement)(child) ? child._virtual.parent || null : null;
|
14
16
|
}
|
15
17
|
function getParent(child, options = {}) {
|
18
|
+
var _child;
|
16
19
|
if (!child) {
|
17
20
|
return null;
|
18
21
|
}
|
@@ -22,5 +25,5 @@ function getParent(child, options = {}) {
|
|
22
25
|
return virtualParent;
|
23
26
|
}
|
24
27
|
}
|
25
|
-
return (child === null ||
|
28
|
+
return ((_child = child) === null || _child === void 0 ? void 0 : _child.parentNode) || null;
|
26
29
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["getParent.js"],"sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n/**\n * Gets the virtual parent given the child element, if it exists.\n */ function getVirtualParent(child) {\n return isVirtualElement(child) ? child._virtual.parent || null : null;\n}\n/**\n * Gets the element which is the parent of a given element.\n * This method prefers the virtual parent over real DOM parent when present.\n */ export function getParent(child, options = {}) {\n if (!child) {\n return null;\n }\n if (!options.skipVirtual) {\n const virtualParent = getVirtualParent(child);\n if (virtualParent) {\n return virtualParent;\n }\n }\n return (child === null ||
|
1
|
+
{"version":3,"sources":["getParent.js"],"sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n/**\n * Gets the virtual parent given the child element, if it exists.\n */ function getVirtualParent(child) {\n return isVirtualElement(child) ? child._virtual.parent || null : null;\n}\n/**\n * Gets the element which is the parent of a given element.\n * This method prefers the virtual parent over real DOM parent when present.\n */ export function getParent(child, options = {}) {\n var _child;\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 = child) === null || _child === void 0 ? void 0 : _child.parentNode) || null;\n}\n"],"names":["getParent","getVirtualParent","child","isVirtualElement","_virtual","parent","options","_child","skipVirtual","virtualParent","parentNode"],"mappings":";;;;+BASoBA;;;eAAAA;;;kCATa;AACjC;;CAEC,GAAG,SAASC,iBAAiBC,KAAK;IAC/B,OAAOC,IAAAA,kCAAgB,EAACD,SAASA,MAAME,QAAQ,CAACC,MAAM,IAAI,OAAO;AACrE;AAIW,SAASL,UAAUE,KAAK,EAAEI,UAAU,CAAC,CAAC;IAC7C,IAAIC;IACJ,IAAI,CAACL,OAAO;QACR,OAAO;IACX;IACA,IAAI,CAACI,QAAQE,WAAW,EAAE;QACtB,MAAMC,gBAAgBR,iBAAiBC;QACvC,IAAIO,eAAe;YACf,OAAOA;QACX;IACJ;IACA,OAAO,AAAC,CAAA,AAACF,CAAAA,SAASL,KAAI,MAAO,QAAQK,WAAW,KAAK,IAAI,KAAK,IAAIA,OAAOG,UAAU,AAAD,KAAM;AAC5F"}
|
@@ -2,6 +2,6 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
3
3
|
value: true
|
4
4
|
});
|
5
|
-
const
|
6
|
-
|
7
|
-
|
5
|
+
const _export_star = require("@swc/helpers/_/_export_star");
|
6
|
+
_export_star._(require("./elementContains"), exports);
|
7
|
+
_export_star._(require("./setVirtualParent"), exports);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.js"],"sourcesContent":["export * from './elementContains';\nexport * from './setVirtualParent';\n"],"names":[],"mappings":";;;;;
|
1
|
+
{"version":3,"sources":["index.js"],"sourcesContent":["export * from './elementContains';\nexport * from './setVirtualParent';\n"],"names":[],"mappings":";;;;;uBAAc;uBACA"}
|
@@ -6,7 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
});
|
7
7
|
Object.defineProperty(exports, "isVirtualElement", {
|
8
8
|
enumerable: true,
|
9
|
-
get: ()
|
9
|
+
get: function() {
|
10
|
+
return isVirtualElement;
|
11
|
+
}
|
10
12
|
});
|
11
13
|
function isVirtualElement(element) {
|
12
14
|
return element && !!element._virtual;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["isVirtualElement.js"],"sourcesContent":["/**\n * Determines whether or not an element has the virtual hierarchy extension.\n */ export function isVirtualElement(element) {\n return element && !!element._virtual;\n}\n"],"names":["isVirtualElement","element","_virtual"],"mappings":"AAAA;;CAEC;;;;+BAAmBA
|
1
|
+
{"version":3,"sources":["isVirtualElement.js"],"sourcesContent":["/**\n * Determines whether or not an element has the virtual hierarchy extension.\n */ export function isVirtualElement(element) {\n return element && !!element._virtual;\n}\n"],"names":["isVirtualElement","element","_virtual"],"mappings":"AAAA;;CAEC;;;;+BAAmBA;;;eAAAA;;;AAAT,SAASA,iBAAiBC,OAAO;IACxC,OAAOA,WAAW,CAAC,CAACA,QAAQC,QAAQ;AACxC"}
|
@@ -9,7 +9,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
9
9
|
});
|
10
10
|
Object.defineProperty(exports, "setVirtualParent", {
|
11
11
|
enumerable: true,
|
12
|
-
get: ()
|
12
|
+
get: function() {
|
13
|
+
return setVirtualParent;
|
14
|
+
}
|
13
15
|
});
|
14
16
|
function setVirtualParent(child, parent) {
|
15
17
|
if (!child) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["setVirtualParent.js"],"sourcesContent":["/**\n * Sets the virtual parent of an element.\n *\n * @param child - Theme element to set the virtual parent\n * @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship\n */ export function setVirtualParent(child, parent) {\n if (!child) {\n return;\n }\n const virtualChild = child;\n if (!virtualChild._virtual) {\n virtualChild._virtual = {};\n }\n virtualChild._virtual.parent = parent;\n}\n"],"names":["setVirtualParent","child","parent","virtualChild","_virtual"],"mappings":"AAAA;;;;;CAKC;;;;+BAAmBA
|
1
|
+
{"version":3,"sources":["setVirtualParent.js"],"sourcesContent":["/**\n * Sets the virtual parent of an element.\n *\n * @param child - Theme element to set the virtual parent\n * @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship\n */ export function setVirtualParent(child, parent) {\n if (!child) {\n return;\n }\n const virtualChild = child;\n if (!virtualChild._virtual) {\n virtualChild._virtual = {};\n }\n virtualChild._virtual.parent = parent;\n}\n"],"names":["setVirtualParent","child","parent","virtualChild","_virtual"],"mappings":"AAAA;;;;;CAKC;;;;+BAAmBA;;;eAAAA;;;AAAT,SAASA,iBAAiBC,KAAK,EAAEC,MAAM;IAC9C,IAAI,CAACD,OAAO;QACR;IACJ;IACA,MAAME,eAAeF;IACrB,IAAI,CAACE,aAAaC,QAAQ,EAAE;QACxBD,aAAaC,QAAQ,GAAG,CAAC;IAC7B;IACAD,aAAaC,QAAQ,CAACF,MAAM,GAAGA;AACnC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-portal",
|
3
|
-
"version": "9.3.
|
3
|
+
"version": "9.3.11",
|
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",
|
@@ -32,18 +32,18 @@
|
|
32
32
|
"@fluentui/scripts-tasks": "*"
|
33
33
|
},
|
34
34
|
"dependencies": {
|
35
|
-
"@fluentui/react-shared-contexts": "^9.7.
|
36
|
-
"@fluentui/react-tabster": "^9.12.
|
37
|
-
"@fluentui/react-utilities": "^9.13.
|
35
|
+
"@fluentui/react-shared-contexts": "^9.7.3",
|
36
|
+
"@fluentui/react-tabster": "^9.12.6",
|
37
|
+
"@fluentui/react-utilities": "^9.13.1",
|
38
38
|
"@griffel/react": "^1.5.14",
|
39
|
-
"@swc/helpers": "^0.
|
39
|
+
"@swc/helpers": "^0.5.1",
|
40
40
|
"use-disposable": "^1.0.1"
|
41
41
|
},
|
42
42
|
"peerDependencies": {
|
43
|
-
"@types/react": ">=16.
|
44
|
-
"@types/react-dom": ">=16.
|
45
|
-
"react": ">=16.
|
46
|
-
"react-dom": ">=16.
|
43
|
+
"@types/react": ">=16.14.0 <19.0.0",
|
44
|
+
"@types/react-dom": ">=16.14.0 <19.0.0",
|
45
|
+
"react": ">=16.14.0 <19.0.0",
|
46
|
+
"react-dom": ">=16.14.0 <19.0.0"
|
47
47
|
},
|
48
48
|
"beachball": {
|
49
49
|
"disallowedChangeTypes": [
|