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