@fluentui/react-portal 9.2.1 → 9.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. package/.swcrc +30 -0
  2. package/CHANGELOG.json +40 -1
  3. package/CHANGELOG.md +15 -2
  4. package/lib/Portal.js.map +1 -1
  5. package/lib/components/Portal/Portal.js +1 -0
  6. package/lib/components/Portal/Portal.js.map +1 -1
  7. package/lib/components/Portal/Portal.types.js +1 -1
  8. package/lib/components/Portal/Portal.types.js.map +1 -1
  9. package/lib/components/Portal/index.js.map +1 -1
  10. package/lib/components/Portal/renderPortal.js.map +1 -1
  11. package/lib/components/Portal/usePortal.js.map +1 -1
  12. package/lib/components/Portal/usePortalMountNode.js.map +1 -1
  13. package/lib/index.js.map +1 -1
  14. package/lib/virtualParent/elementContains.js.map +1 -1
  15. package/lib/virtualParent/getParent.js.map +1 -1
  16. package/lib/virtualParent/index.js.map +1 -1
  17. package/lib/virtualParent/isVirtualElement.js +1 -2
  18. package/lib/virtualParent/isVirtualElement.js.map +1 -1
  19. package/lib/virtualParent/setVirtualParent.js +1 -2
  20. package/lib/virtualParent/setVirtualParent.js.map +1 -1
  21. package/lib/virtualParent/types.js.map +1 -1
  22. package/lib-commonjs/Portal.js +5 -4
  23. package/lib-commonjs/Portal.js.map +1 -1
  24. package/lib-commonjs/components/Portal/Portal.js +14 -14
  25. package/lib-commonjs/components/Portal/Portal.js.map +1 -1
  26. package/lib-commonjs/components/Portal/Portal.types.js +5 -2
  27. package/lib-commonjs/components/Portal/Portal.types.js.map +1 -1
  28. package/lib-commonjs/components/Portal/index.js +8 -7
  29. package/lib-commonjs/components/Portal/index.js.map +1 -1
  30. package/lib-commonjs/components/Portal/renderPortal.js +15 -15
  31. package/lib-commonjs/components/Portal/renderPortal.js.map +1 -1
  32. package/lib-commonjs/components/Portal/usePortal.js +56 -55
  33. package/lib-commonjs/components/Portal/usePortal.js.map +1 -1
  34. package/lib-commonjs/components/Portal/usePortalMountNode.js +86 -68
  35. package/lib-commonjs/components/Portal/usePortalMountNode.js.map +1 -1
  36. package/lib-commonjs/index.js +17 -34
  37. package/lib-commonjs/index.js.map +1 -1
  38. package/lib-commonjs/virtualParent/elementContains.js +26 -30
  39. package/lib-commonjs/virtualParent/elementContains.js.map +1 -1
  40. package/lib-commonjs/virtualParent/getParent.js +19 -22
  41. package/lib-commonjs/virtualParent/getParent.js.map +1 -1
  42. package/lib-commonjs/virtualParent/index.js +6 -5
  43. package/lib-commonjs/virtualParent/index.js.map +1 -1
  44. package/lib-commonjs/virtualParent/isVirtualElement.js +11 -10
  45. package/lib-commonjs/virtualParent/isVirtualElement.js.map +1 -1
  46. package/lib-commonjs/virtualParent/setVirtualParent.js +18 -17
  47. package/lib-commonjs/virtualParent/setVirtualParent.js.map +1 -1
  48. package/lib-commonjs/virtualParent/types.js +3 -2
  49. package/lib-commonjs/virtualParent/types.js.map +1 -1
  50. package/package.json +7 -6
  51. package/lib-amd/components/Portal/Portal.js +0 -16
  52. package/lib-amd/components/Portal/Portal.js.map +0 -1
  53. package/lib-amd/components/Portal/Portal.types.js +0 -5
  54. package/lib-amd/components/Portal/Portal.types.js.map +0 -1
  55. package/lib-amd/components/Portal/index.js +0 -9
  56. package/lib-amd/components/Portal/index.js.map +0 -1
  57. package/lib-amd/components/Portal/renderPortal.js +0 -13
  58. package/lib-amd/components/Portal/renderPortal.js.map +0 -1
  59. package/lib-amd/components/Portal/usePortal.js +0 -48
  60. package/lib-amd/components/Portal/usePortal.js.map +0 -1
  61. package/lib-amd/components/Portal/usePortalMountNode.js +0 -67
  62. package/lib-amd/components/Portal/usePortalMountNode.js.map +0 -1
  63. package/lib-amd/index.js +0 -11
  64. package/lib-amd/index.js.map +0 -1
  65. package/lib-amd/virtualParent/elementContains.js +0 -36
  66. package/lib-amd/virtualParent/elementContains.js.map +0 -1
  67. package/lib-amd/virtualParent/getParent.js +0 -30
  68. package/lib-amd/virtualParent/getParent.js.map +0 -1
  69. package/lib-amd/virtualParent/index.js +0 -7
  70. package/lib-amd/virtualParent/index.js.map +0 -1
  71. package/lib-amd/virtualParent/isVirtualElement.js +0 -13
  72. package/lib-amd/virtualParent/isVirtualElement.js.map +0 -1
  73. package/lib-amd/virtualParent/setVirtualParent.js +0 -23
  74. package/lib-amd/virtualParent/setVirtualParent.js.map +0 -1
  75. package/lib-amd/virtualParent/types.js +0 -5
  76. package/lib-amd/virtualParent/types.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"names":["react_utilities_1","require","React","index_1","usePortalMountNode_1","toMountNodeProps","mountNode","isHTMLElement","element","exports","usePortal_unstable","props","className","virtualParentRootRef","useRef","fallbackElement","usePortalMountNode","disabled","state","children","useEffect","current","setVirtualParent","undefined"],"sources":["../src/packages/react-components/react-portal/src/components/Portal/usePortal.ts"],"sourcesContent":["import { isHTMLElement } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { setVirtualParent } from '../../virtualParent/index';\nimport { usePortalMountNode } from './usePortalMountNode';\nimport type { PortalProps, PortalState } from './Portal.types';\n\nexport function toMountNodeProps(mountNode: PortalProps['mountNode']): {\n element?: HTMLElement | null;\n className?: string;\n} {\n if (isHTMLElement(mountNode)) {\n return { element: mountNode };\n }\n\n if (typeof mountNode === 'object') {\n if (mountNode === null) {\n return { element: null };\n }\n\n return mountNode;\n }\n\n return {};\n}\n\n/**\n * Create the state required to render Portal.\n *\n * The returned state can be modified with hooks such as usePortalStyles, before being passed to renderPortal_unstable.\n *\n * @param props - props from this instance of Portal\n */\nexport const usePortal_unstable = (props: PortalProps): PortalState => {\n const { element, className } = toMountNodeProps(props.mountNode);\n\n const virtualParentRootRef = React.useRef<HTMLSpanElement>(null);\n const fallbackElement = usePortalMountNode({ disabled: !!element, className });\n\n const state: PortalState = {\n children: props.children,\n mountNode: element ?? fallbackElement,\n virtualParentRootRef,\n };\n\n React.useEffect(() => {\n if (state.virtualParentRootRef.current && state.mountNode) {\n setVirtualParent(state.mountNode, state.virtualParentRootRef.current);\n }\n return () => {\n if (state.mountNode) {\n setVirtualParent(state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AAEY,KAAK,CAACL,oBAAoB,CAACQ,OAAO,CAAC;;IAEvE,OAAO,MAAK;MACV,IAAIH,KAAK,CAACZ,SAAS,EAAE;QACnBH,OAAA,CAAAmB,gBAAgB,CAACJ,KAAK,CAACZ,SAAS,EAAEiB,SAAS,CAAC;;IAEhD,CAAC;EACH,CAAC,EAAE,CAACL,KAAK,CAACL,oBAAoB,EAAEK,KAAK,CAACZ,SAAS,CAAC,CAAC;EAEjD,OAAOY,KAAK;AACd,CAAC;AAxBYT,OAAA,CAAAC,kBAAkB,GAAAA,kBAAA"}
1
+ {"version":3,"sources":["../../../lib/components/Portal/usePortal.js"],"sourcesContent":["import { isHTMLElement } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport { setVirtualParent } from '../../virtualParent/index';\nimport { usePortalMountNode } from './usePortalMountNode';\nexport function toMountNodeProps(mountNode) {\n if (isHTMLElement(mountNode)) {\n return {\n element: mountNode\n };\n }\n if (typeof mountNode === 'object') {\n if (mountNode === null) {\n return {\n element: null\n };\n }\n return mountNode;\n }\n return {};\n}\n/**\n * Create the state required to render Portal.\n *\n * The returned state can be modified with hooks such as usePortalStyles, before being passed to renderPortal_unstable.\n *\n * @param props - props from this instance of Portal\n */\nexport const usePortal_unstable = props => {\n const {\n element,\n className\n } = toMountNodeProps(props.mountNode);\n const virtualParentRootRef = React.useRef(null);\n const fallbackElement = usePortalMountNode({\n disabled: !!element,\n className\n });\n const state = {\n children: props.children,\n mountNode: element !== null && element !== void 0 ? element : fallbackElement,\n virtualParentRootRef\n };\n React.useEffect(() => {\n if (state.virtualParentRootRef.current && state.mountNode) {\n setVirtualParent(state.mountNode, state.virtualParentRootRef.current);\n }\n return () => {\n if (state.mountNode) {\n setVirtualParent(state.mountNode, undefined);\n }\n };\n }, [state.virtualParentRootRef, state.mountNode]);\n return state;\n};\n//# sourceMappingURL=usePortal.js.map"],"names":["toMountNodeProps","usePortal_unstable","mountNode","isHTMLElement","element","props","className","virtualParentRootRef","React","useRef","fallbackElement","usePortalMountNode","disabled","state","children","useEffect","current","setVirtualParent","undefined"],"mappings":";;;;;;;;;;;IAIgBA,gBAAgB,MAAhBA;IAuBHC,kBAAkB,MAAlBA;;;gCA3BiB;6DACP;uBACU;oCACE;AAC5B,SAASD,iBAAiBE,SAAS,EAAE;IAC1C,IAAIC,IAAAA,6BAAa,EAACD,YAAY;QAC5B,OAAO;YACLE,SAASF;QACX;IACF,CAAC;IACD,IAAI,OAAOA,cAAc,UAAU;QACjC,IAAIA,cAAc,IAAI,EAAE;YACtB,OAAO;gBACLE,SAAS,IAAI;YACf;QACF,CAAC;QACD,OAAOF;IACT,CAAC;IACD,OAAO,CAAC;AACV;AAQO,MAAMD,qBAAqBI,CAAAA,QAAS;IACzC,MAAM,EACJD,QAAO,EACPE,UAAS,EACV,GAAGN,iBAAiBK,MAAMH,SAAS;IACpC,MAAMK,uBAAuBC,OAAMC,MAAM,CAAC,IAAI;IAC9C,MAAMC,kBAAkBC,IAAAA,sCAAkB,EAAC;QACzCC,UAAU,CAAC,CAACR;QACZE;IACF;IACA,MAAMO,QAAQ;QACZC,UAAUT,MAAMS,QAAQ;QACxBZ,WAAWE,YAAY,IAAI,IAAIA,YAAY,KAAK,IAAIA,UAAUM,eAAe;QAC7EH;IACF;IACAC,OAAMO,SAAS,CAAC,IAAM;QACpB,IAAIF,MAAMN,oBAAoB,CAACS,OAAO,IAAIH,MAAMX,SAAS,EAAE;YACzDe,IAAAA,uBAAgB,EAACJ,MAAMX,SAAS,EAAEW,MAAMN,oBAAoB,CAACS,OAAO;QACtE,CAAC;QACD,OAAO,IAAM;YACX,IAAIH,MAAMX,SAAS,EAAE;gBACnBe,IAAAA,uBAAgB,EAACJ,MAAMX,SAAS,EAAEgB;YACpC,CAAC;QACH;IACF,GAAG;QAACL,MAAMN,oBAAoB;QAAEM,MAAMX,SAAS;KAAC;IAChD,OAAOW;AACT,GACA,qCAAqC"}
@@ -1,75 +1,93 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "usePortalMountNode", {
6
+ enumerable: true,
7
+ get: ()=>usePortalMountNode
5
8
  });
6
- exports.usePortalMountNode = void 0;
7
- const React = /*#__PURE__*/require("react");
8
- const react_shared_contexts_1 = /*#__PURE__*/require("@fluentui/react-shared-contexts");
9
- const react_1 = /*#__PURE__*/require("@griffel/react");
10
- const react_tabster_1 = /*#__PURE__*/require("@fluentui/react-tabster");
11
- const use_disposable_1 = /*#__PURE__*/require("use-disposable");
12
- const useInsertionEffect = React['useInsertion' + 'Effect'];
13
- const useStyles = /*#__PURE__*/react_1.__styles({
14
- root: {
15
- qhf8xq: "f10pi13n",
16
- Bj3rh1h: "f494woh"
17
- }
9
+ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
+ const _reactSharedContexts = require("@fluentui/react-shared-contexts");
12
+ const _react1 = require("@griffel/react");
13
+ const _reactTabster = require("@fluentui/react-tabster");
14
+ const _useDisposable = require("use-disposable");
15
+ const useInsertionEffect = _react['useInsertion' + 'Effect'];
16
+ const useStyles = /*#__PURE__*/ (0, _react1["__styles"])({
17
+ root: {
18
+ qhf8xq: "f10pi13n",
19
+ Bj3rh1h: "f494woh"
20
+ }
18
21
  }, {
19
- d: [".f10pi13n{position:relative;}", ".f494woh{z-index:1000000;}"]
22
+ d: [
23
+ ".f10pi13n{position:relative;}",
24
+ ".f494woh{z-index:1000000;}"
25
+ ]
20
26
  });
21
- /**
22
- * Creates a new element on a "document.body" to mount portals.
23
- */
24
- const usePortalMountNode = options => {
25
- const {
26
- targetDocument,
27
- dir
28
- } = react_shared_contexts_1.useFluent_unstable();
29
- const focusVisibleRef = react_tabster_1.useFocusVisible();
30
- const classes = useStyles();
31
- const themeClassName = react_shared_contexts_1.useThemeClassName_unstable();
32
- const className = react_1.mergeClasses(themeClassName, classes.root, options.className);
33
- const element = use_disposable_1.useDisposable(() => {
34
- if (targetDocument === undefined || options.disabled) {
35
- return [null, () => null];
27
+ const usePortalMountNode = (options)=>{
28
+ const { targetDocument , dir } = (0, _reactSharedContexts.useFluent_unstable)();
29
+ const focusVisibleRef = (0, _reactTabster.useFocusVisible)();
30
+ const classes = useStyles();
31
+ const themeClassName = (0, _reactSharedContexts.useThemeClassName_unstable)();
32
+ const className = (0, _react1.mergeClasses)(themeClassName, classes.root, options.className);
33
+ const element = (0, _useDisposable.useDisposable)(()=>{
34
+ if (targetDocument === undefined || options.disabled) {
35
+ return [
36
+ null,
37
+ ()=>null
38
+ ];
39
+ }
40
+ const newElement = targetDocument.createElement('div');
41
+ targetDocument.body.appendChild(newElement);
42
+ return [
43
+ newElement,
44
+ ()=>newElement.remove()
45
+ ];
46
+ }, [
47
+ targetDocument
48
+ ]);
49
+ if (useInsertionEffect) {
50
+ // eslint-disable-next-line react-hooks/rules-of-hooks
51
+ useInsertionEffect(()=>{
52
+ if (!element) {
53
+ return;
54
+ }
55
+ const classesToApply = className.split(' ').filter(Boolean);
56
+ element.classList.add(...classesToApply);
57
+ element.setAttribute('dir', dir);
58
+ focusVisibleRef.current = element;
59
+ return ()=>{
60
+ element.classList.remove(...classesToApply);
61
+ element.removeAttribute('dir');
62
+ };
63
+ }, [
64
+ className,
65
+ dir,
66
+ element,
67
+ focusVisibleRef
68
+ ]);
69
+ } else {
70
+ // This useMemo call is intentional for React 17
71
+ // We don't want to re-create the portal element when its attributes change.
72
+ // This also should not be done in an effect because, changing the value of css variables
73
+ // after initial mount can trigger interesting CSS side effects like transitions.
74
+ // eslint-disable-next-line react-hooks/rules-of-hooks
75
+ _react.useMemo(()=>{
76
+ if (!element) {
77
+ return;
78
+ }
79
+ // Force replace all classes
80
+ element.className = className;
81
+ element.setAttribute('dir', dir);
82
+ focusVisibleRef.current = element;
83
+ }, [
84
+ className,
85
+ dir,
86
+ element,
87
+ focusVisibleRef
88
+ ]);
36
89
  }
37
- const newElement = targetDocument.createElement('div');
38
- targetDocument.body.appendChild(newElement);
39
- return [newElement, () => newElement.remove()];
40
- }, [targetDocument]);
41
- if (useInsertionEffect) {
42
- // eslint-disable-next-line react-hooks/rules-of-hooks
43
- useInsertionEffect(() => {
44
- if (!element) {
45
- return;
46
- }
47
- const classesToApply = className.split(' ').filter(Boolean);
48
- element.classList.add(...classesToApply);
49
- element.setAttribute('dir', dir);
50
- focusVisibleRef.current = element;
51
- return () => {
52
- element.classList.remove(...classesToApply);
53
- element.removeAttribute('dir');
54
- };
55
- }, [className, dir, element, focusVisibleRef]);
56
- } else {
57
- // This useMemo call is intentional for React 17
58
- // We don't want to re-create the portal element when its attributes change.
59
- // This also should not be done in an effect because, changing the value of css variables
60
- // after initial mount can trigger interesting CSS side effects like transitions.
61
- // eslint-disable-next-line react-hooks/rules-of-hooks
62
- React.useMemo(() => {
63
- if (!element) {
64
- return;
65
- }
66
- // Force replace all classes
67
- element.className = className;
68
- element.setAttribute('dir', dir);
69
- focusVisibleRef.current = element;
70
- }, [className, dir, element, focusVisibleRef]);
71
- }
72
- return element;
73
- };
74
- exports.usePortalMountNode = usePortalMountNode;
90
+ return element;
91
+ }; //# sourceMappingURL=usePortalMountNode.js.map
92
+
75
93
  //# sourceMappingURL=usePortalMountNode.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","require","react_shared_contexts_1","react_1","react_tabster_1","use_disposable_1","useInsertionEffect","useStyles","__styles","root","qhf8xq","Bj3rh1h","d","usePortalMountNode","options","targetDocument","dir","useFluent_unstable","focusVisibleRef","useFocusVisible","classes","themeClassName","useThemeClassName_unstable","className","mergeClasses","element","useDisposable","undefined","disabled","newElement","createElement","body","appendChild","remove","classesToApply","split","filter","Boolean","classList","add","setAttribute","current","removeAttribute","useMemo","exports"],"sources":["../src/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';\n\nconst useInsertionEffect = (React as never)['useInsertion' + 'Effect'] as typeof React.useLayoutEffect | undefined;\n\nexport type UsePortalMountNodeOptions = {\n /**\n * Since hooks cannot be called conditionally use this flag to disable creating the node\n */\n disabled?: boolean;\n\n className?: string;\n};\n\nconst useStyles = makeStyles({\n root: {\n position: 'relative',\n zIndex: 1000000,\n },\n});\n\n/**\n * Creates a new element on a \"document.body\" to mount portals.\n */\nexport const usePortalMountNode = (options: UsePortalMountNodeOptions): HTMLElement | null => {\n const { targetDocument, dir } = useFluent();\n const focusVisibleRef = useFocusVisible<HTMLDivElement>() as React.MutableRefObject<HTMLElement | null>;\n const classes = useStyles();\n const themeClassName = useThemeClassName();\n\n const className = mergeClasses(themeClassName, classes.root, options.className);\n\n const element = useDisposable(() => {\n if (targetDocument === undefined || options.disabled) {\n return [null, () => null];\n }\n\n const newElement = targetDocument.createElement('div');\n targetDocument.body.appendChild(newElement);\n return [newElement, () => newElement.remove()];\n }, [targetDocument]);\n\n if (useInsertionEffect) {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useInsertionEffect(() => {\n if (!element) {\n return;\n }\n\n const classesToApply = className.split(' ').filter(Boolean);\n\n element.classList.add(...classesToApply);\n element.setAttribute('dir', dir);\n focusVisibleRef.current = element;\n\n return () => {\n element.classList.remove(...classesToApply);\n element.removeAttribute('dir');\n };\n }, [className, dir, element, focusVisibleRef]);\n } else {\n // This useMemo call is intentional for React 17\n // We don't want to re-create the portal element when its attributes change.\n // This also should not be done in an effect because, changing the value of css variables\n // after initial mount can trigger interesting CSS side effects like transitions.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useMemo(() => {\n if (!element) {\n return;\n }\n\n // Force replace all classes\n element.className = className;\n element.setAttribute('dir', dir);\n focusVisibleRef.current = element;\n }, [className, dir, element, focusVisibleRef]);\n }\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tB;IACAA,kBAAkB,CAAC,MAAK;MACtB,IAAI,CAACmB,OAAO,EAAE;QACZ;;MAGF,MAAMS,cAAc,GAAGX,SAAS,CAACY,KAAK,CAAC,GAAG,CAAC,CAACC,MAAM,CAACC,OAAO,CAAC;MAE3DZ,OAAO,CAACa,SAAS,CAACC,GAAG,CAAC,GAAGL,cAAc,CAAC;MACxCT,OAAO,CAACe,YAAY,CAAC,KAAK,EAAExB,GAAG,CAAC;MAChCE,eAAe,CAACuB,OAAO,GAAGhB,OAAO;MAEjC,OAAO,MAAK;QACVA,OAAO,CAACa,SAAS,CAACL,MAAM,CAAC,GAAGC,cAAc,CAAC;QAC3CT,OAAO,CAACiB,eAAe,CAAC,KAAK,CAAC;MAChC,CAAC;IACH,CAAC,EAAE,CAACnB,SAAS,EAAEP,GAAG,EAAES,OAAO,EAAEP,eAAe,CAAC,CAAC;GAC/C,MAAM;IACL;IACA;IACA;IACA;IACA;IACAlB,KAAK,CAAC2C,OAAO,CAAC,MAAK;MACjB,IAAI,CAAClB,OAAO,EAAE;QACZ;;MAGF;MACAA,OAAO,CAACF,SAAS,GAAGA,SAAS;MAC7BE,OAAO,CAACe,YAAY,CAAC,KAAK,EAAExB,GAAG,CAAC;MAChCE,eAAe,CAACuB,OAAO,GAAGhB,OAAO;IACnC,CAAC,EAAE,CAACF,SAAS,EAAEP,GAAG,EAAES,OAAO,EAAEP,eAAe,CAAC,CAAC;;EAGhD,OAAOO,OAAO;AAChB,CAAC;AAvDYmB,OAAA,CAAA/B,kBAAkB,GAAAA,kBAAA"}
1
+ {"version":3,"sources":["../../../lib/components/Portal/usePortalMountNode.js"],"sourcesContent":["import * as React from 'react';\nimport { useThemeClassName_unstable as useThemeClassName, useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { __styles, mergeClasses } from '@griffel/react';\nimport { useFocusVisible } from '@fluentui/react-tabster';\nimport { useDisposable } from 'use-disposable';\nconst useInsertionEffect = React['useInsertion' + 'Effect'];\nconst useStyles = /*#__PURE__*/__styles({\n root: {\n qhf8xq: \"f10pi13n\",\n Bj3rh1h: \"f494woh\"\n }\n}, {\n d: [\".f10pi13n{position:relative;}\", \".f494woh{z-index:1000000;}\"]\n});\n/**\n * Creates a new element on a \"document.body\" to mount portals.\n */\nexport const usePortalMountNode = options => {\n const {\n targetDocument,\n dir\n } = useFluent();\n const focusVisibleRef = useFocusVisible();\n const classes = useStyles();\n const themeClassName = useThemeClassName();\n const className = mergeClasses(themeClassName, classes.root, options.className);\n const element = useDisposable(() => {\n if (targetDocument === undefined || options.disabled) {\n return [null, () => null];\n }\n const newElement = targetDocument.createElement('div');\n targetDocument.body.appendChild(newElement);\n return [newElement, () => newElement.remove()];\n }, [targetDocument]);\n if (useInsertionEffect) {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useInsertionEffect(() => {\n if (!element) {\n return;\n }\n const classesToApply = className.split(' ').filter(Boolean);\n element.classList.add(...classesToApply);\n element.setAttribute('dir', dir);\n focusVisibleRef.current = element;\n return () => {\n element.classList.remove(...classesToApply);\n element.removeAttribute('dir');\n };\n }, [className, dir, element, focusVisibleRef]);\n } else {\n // This useMemo call is intentional for React 17\n // We don't want to re-create the portal element when its attributes change.\n // This also should not be done in an effect because, changing the value of css variables\n // after initial mount can trigger interesting CSS side effects like transitions.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useMemo(() => {\n if (!element) {\n return;\n }\n // Force replace all classes\n element.className = className;\n element.setAttribute('dir', dir);\n focusVisibleRef.current = element;\n }, [className, dir, element, focusVisibleRef]);\n }\n return element;\n};\n//# sourceMappingURL=usePortalMountNode.js.map"],"names":["usePortalMountNode","useInsertionEffect","React","useStyles","__styles","root","qhf8xq","Bj3rh1h","d","options","targetDocument","dir","useFluent","focusVisibleRef","useFocusVisible","classes","themeClassName","useThemeClassName","className","mergeClasses","element","useDisposable","undefined","disabled","newElement","createElement","body","appendChild","remove","classesToApply","split","filter","Boolean","classList","add","setAttribute","current","removeAttribute","useMemo"],"mappings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YAACnB;YAAWP;YAAKS;YAASP;SAAgB;IAC/C,OAAO;QACL,gDAAgD;QAChD,4EAA4E;QAC5E,yFAAyF;QACzF,iFAAiF;QACjF,sDAAsD;QACtDX,OAAMoC,OAAO,CAAC,IAAM;YAClB,IAAI,CAAClB,SAAS;gBACZ;YACF,CAAC;YACD,4BAA4B;YAC5BA,QAAQF,SAAS,GAAGA;YACpBE,QAAQe,YAAY,CAAC,OAAOxB;YAC5BE,gBAAgBuB,OAAO,GAAGhB;QAC5B,GAAG;YAACF;YAAWP;YAAKS;YAASP;SAAgB;IAC/C,CAAC;IACD,OAAOO;AACT,GACA,8CAA8C"}
@@ -1,39 +1,22 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.setVirtualParent = exports.elementContains = exports.usePortal_unstable = exports.renderPortal_unstable = exports.Portal = void 0;
7
- var index_1 = /*#__PURE__*/require("./components/Portal/index");
8
- Object.defineProperty(exports, "Portal", {
9
- enumerable: true,
10
- get: function () {
11
- return index_1.Portal;
12
- }
13
- });
14
- Object.defineProperty(exports, "renderPortal_unstable", {
15
- enumerable: true,
16
- get: function () {
17
- return index_1.renderPortal_unstable;
18
- }
3
+ value: true
19
4
  });
20
- Object.defineProperty(exports, "usePortal_unstable", {
21
- enumerable: true,
22
- get: function () {
23
- return index_1.usePortal_unstable;
24
- }
25
- });
26
- var index_2 = /*#__PURE__*/require("./virtualParent/index");
27
- Object.defineProperty(exports, "elementContains", {
28
- enumerable: true,
29
- get: function () {
30
- return index_2.elementContains;
31
- }
32
- });
33
- Object.defineProperty(exports, "setVirtualParent", {
34
- enumerable: true,
35
- get: function () {
36
- return index_2.setVirtualParent;
37
- }
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ Portal: ()=>_index.Portal,
13
+ renderPortal_unstable: ()=>_index.renderPortal_unstable,
14
+ usePortal_unstable: ()=>_index.usePortal_unstable,
15
+ elementContains: ()=>_index1.elementContains,
16
+ setVirtualParent: ()=>_index1.setVirtualParent
38
17
  });
18
+ const _index = require("./components/Portal/index");
19
+ const _index1 = require("./virtualParent/index");
20
+ //# sourceMappingURL=index.js.map
21
+
39
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["index_1","require","Object","defineProperty","exports","enumerable","get","Portal","renderPortal_unstable","usePortal_unstable","index_2","elementContains","setVirtualParent"],"sources":["../src/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"],"mappings":";;;;;;AAAA,IAAAA,OAAA,gBAAAC,OAAA;AAASC,MAAA,CAAAC,cAAA,CAAAC,OAAA;EAAAC,UAAA;EAAAC,GAAA,WAAAA,CAAA;IAAA,OAAAN,OAAA,CAAAO,MAAM;EAAA;AAAA;AAAEL,MAAA,CAAAC,cAAA,CAAAC,OAAA;EAAAC,UAAA;EAAAC,GAAA,WAAAA,CAAA;IAAA,OAAAN,OAAA,CAAAQ,qBAAqB;EAAA;AAAA;AAAEN,MAAA,CAAAC,cAAA,CAAAC,OAAA;EAAAC,UAAA;EAAAC,GAAA,WAAAA,CAAA;IAAA,OAAAN,OAAA,CAAAS,kBAAkB;EAAA;AAAA;AAE1D,IAAAC,OAAA,gBAAAT,OAAA;AAASC,MAAA,CAAAC,cAAA,CAAAC,OAAA;EAAAC,UAAA;EAAAC,GAAA,WAAAA,CAAA;IAAA,OAAAI,OAAA,CAAAC,eAAe;EAAA;AAAA;AAAET,MAAA,CAAAC,cAAA,CAAAC,OAAA;EAAAC,UAAA;EAAAC,GAAA,WAAAA,CAAA;IAAA,OAAAI,OAAA,CAAAE,gBAAgB;EAAA;AAAA"}
1
+ {"version":3,"sources":["../lib/index.js"],"sourcesContent":["export { Portal, renderPortal_unstable, usePortal_unstable } from './components/Portal/index';\nexport { elementContains, setVirtualParent } from './virtualParent/index';\n//# sourceMappingURL=index.js.map"],"names":["Portal","renderPortal_unstable","usePortal_unstable","elementContains","setVirtualParent"],"mappings":";;;;;;;;;;;IAASA,MAAM,MAANA,aAAM;IAAEC,qBAAqB,MAArBA,4BAAqB;IAAEC,kBAAkB,MAAlBA,yBAAkB;IACjDC,eAAe,MAAfA,uBAAe;IAAEC,gBAAgB,MAAhBA,wBAAgB;;uBADwB;wBAChB;CAClD,iCAAiC"}
@@ -1,37 +1,33 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "elementContains", {
6
+ enumerable: true,
7
+ get: ()=>elementContains
5
8
  });
6
- exports.elementContains = void 0;
7
- const getParent_1 = /*#__PURE__*/require("./getParent");
8
- /**
9
- * Similar functionality to `element.contains` DOM API for use without of order DOM elements that
10
- * checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent
11
- *
12
- * @returns true if the child can find the parent in its virtual hierarchy
13
- */
9
+ const _getParent = require("./getParent");
14
10
  function elementContains(parent, child) {
15
- if (!parent || !child) {
16
- return false;
17
- }
18
- if (parent === child) {
19
- return true;
20
- } else {
21
- // Tracks references of nodes that have been visited to prevent infinite loops
22
- const set = new WeakSet();
23
- while (child) {
24
- const nextParent = getParent_1.getParent(child, {
25
- skipVirtual: set.has(child)
26
- });
27
- set.add(child);
28
- if (nextParent === parent) {
11
+ if (!parent || !child) {
12
+ return false;
13
+ }
14
+ if (parent === child) {
29
15
  return true;
30
- }
31
- child = nextParent;
16
+ } else {
17
+ // Tracks references of nodes that have been visited to prevent infinite loops
18
+ const set = new WeakSet();
19
+ while(child){
20
+ const nextParent = (0, _getParent.getParent)(child, {
21
+ skipVirtual: set.has(child)
22
+ });
23
+ set.add(child);
24
+ if (nextParent === parent) {
25
+ return true;
26
+ }
27
+ child = nextParent;
28
+ }
32
29
  }
33
- }
34
- return false;
35
- }
36
- exports.elementContains = elementContains;
30
+ return false;
31
+ } //# sourceMappingURL=elementContains.js.map
32
+
37
33
  //# sourceMappingURL=elementContains.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getParent_1","require","elementContains","parent","child","set","WeakSet","nextParent","getParent","skipVirtual","has","add","exports"],"sources":["../src/packages/react-components/react-portal/src/virtualParent/elementContains.ts"],"sourcesContent":["import { getParent } from './getParent';\n\n/**\n * Similar functionality to `element.contains` DOM API for use without of order DOM elements that\n * checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent\n *\n * @returns true if the child can find the parent in its virtual hierarchy\n */\nexport function elementContains(parent: Node | null, child: Node | null): boolean {\n if (!parent || !child) {\n return false;\n }\n\n if (parent === child) {\n return true;\n } else {\n // Tracks references of nodes that have been visited to prevent infinite loops\n const set = new WeakSet<Node>();\n\n while (child) {\n const nextParent: Node | null = getParent(child, {\n skipVirtual: set.has(child),\n });\n set.add(child);\n\n if (nextParent === parent) {\n return true;\n }\n\n child = nextParent;\n }\n }\n\n return false;\n}\n"],"mappings":";;;;;;AAAA,MAAAA,WAAA,gBAAAC,OAAA;AAEA;;;;;;AAMA,SAAgBC,eAAeA,CAACC,MAAmB,EAAEC,KAAkB;EACrE,IAAI,CAACD,MAAM,IAAI,CAACC,KAAK,EAAE;IACrB,OAAO,KAAK;;EAGd,IAAID,MAAM,KAAKC,KAAK,EAAE;IACpB,OAAO,IAAI;GACZ,MAAM;IACL;IACA,MAAMC,GAAG,GAAG,IAAIC,OAAO,EAAQ;IAE/B,OAAOF,KAAK,EAAE;MACZ,MAAMG,UAAU,GAAgBP,WAAA,CAAAQ,SAAS,CAACJ,KAAK,EAAE;QAC/CK,WAAW,EAAEJ,GAAG,CAACK,GAAG,CAACN,KAAK;OAC3B,CAAC;MACFC,GAAG,CAACM,GAAG,CAACP,KAAK,CAAC;MAEd,IAAIG,UAAU,KAAKJ,MAAM,EAAE;QACzB,OAAO,IAAI;;MAGbC,KAAK,GAAGG,UAAU;;;EAItB,OAAO,KAAK;AACd;AA1BAK,OAAA,CAAAV,eAAA,GAAAA,eAAA"}
1
+ {"version":3,"sources":["../../lib/virtualParent/elementContains.js"],"sourcesContent":["import { getParent } from './getParent';\n/**\n * Similar functionality to `element.contains` DOM API for use without of order DOM elements that\n * checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent\n *\n * @returns true if the child can find the parent in its virtual hierarchy\n */\nexport function elementContains(parent, child) {\n if (!parent || !child) {\n return false;\n }\n if (parent === child) {\n return true;\n } else {\n // Tracks references of nodes that have been visited to prevent infinite loops\n const set = new WeakSet();\n while (child) {\n const nextParent = getParent(child, {\n skipVirtual: set.has(child)\n });\n set.add(child);\n if (nextParent === parent) {\n return true;\n }\n child = nextParent;\n }\n }\n return false;\n}\n//# sourceMappingURL=elementContains.js.map"],"names":["elementContains","parent","child","set","WeakSet","nextParent","getParent","skipVirtual","has","add"],"mappings":";;;;+BAOgBA;;aAAAA;;2BAPU;AAOnB,SAASA,gBAAgBC,MAAM,EAAEC,KAAK,EAAE;IAC7C,IAAI,CAACD,UAAU,CAACC,OAAO;QACrB,OAAO,KAAK;IACd,CAAC;IACD,IAAID,WAAWC,OAAO;QACpB,OAAO,IAAI;IACb,OAAO;QACL,8EAA8E;QAC9E,MAAMC,MAAM,IAAIC;QAChB,MAAOF,MAAO;YACZ,MAAMG,aAAaC,IAAAA,oBAAS,EAACJ,OAAO;gBAClCK,aAAaJ,IAAIK,GAAG,CAACN;YACvB;YACAC,IAAIM,GAAG,CAACP;YACR,IAAIG,eAAeJ,QAAQ;gBACzB,OAAO,IAAI;YACb,CAAC;YACDC,QAAQG;QACV;IACF,CAAC;IACD,OAAO,KAAK;AACd,EACA,2CAA2C"}
@@ -1,31 +1,28 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "getParent", {
6
+ enumerable: true,
7
+ get: ()=>getParent
5
8
  });
6
- exports.getParent = void 0;
7
- const isVirtualElement_1 = /*#__PURE__*/require("./isVirtualElement");
9
+ const _isVirtualElement = require("./isVirtualElement");
8
10
  /**
9
11
  * Gets the virtual parent given the child element, if it exists.
10
- */
11
- function getVirtualParent(child) {
12
- return isVirtualElement_1.isVirtualElement(child) ? child._virtual.parent || null : null;
12
+ */ function getVirtualParent(child) {
13
+ return (0, _isVirtualElement.isVirtualElement)(child) ? child._virtual.parent || null : null;
13
14
  }
14
- /**
15
- * Gets the element which is the parent of a given element.
16
- * This method prefers the virtual parent over real DOM parent when present.
17
- */
18
15
  function getParent(child, options = {}) {
19
- if (!child) {
20
- return null;
21
- }
22
- if (!options.skipVirtual) {
23
- const virtualParent = getVirtualParent(child);
24
- if (virtualParent) {
25
- return virtualParent;
16
+ if (!child) {
17
+ return null;
26
18
  }
27
- }
28
- return (child === null || child === void 0 ? void 0 : child.parentNode) || null;
29
- }
30
- exports.getParent = getParent;
19
+ if (!options.skipVirtual) {
20
+ const virtualParent = getVirtualParent(child);
21
+ if (virtualParent) {
22
+ return virtualParent;
23
+ }
24
+ }
25
+ return (child === null || child === void 0 ? void 0 : child.parentNode) || null;
26
+ } //# sourceMappingURL=getParent.js.map
27
+
31
28
  //# sourceMappingURL=getParent.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["isVirtualElement_1","require","getVirtualParent","child","isVirtualElement","_virtual","parent","getParent","options","skipVirtual","virtualParent","parentNode","exports"],"sources":["../src/packages/react-components/react-portal/src/virtualParent/getParent.ts"],"sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n\ntype GetParentOptions = {\n /**\n * Indicates if getParent() should ignore a virtual parent.\n */\n skipVirtual?: boolean;\n};\n\n/**\n * Gets the virtual parent given the child element, if it exists.\n */\nfunction getVirtualParent(child: Node): Node | null {\n return isVirtualElement(child) ? child._virtual.parent || null : null;\n}\n\n/**\n * Gets the element which is the parent of a given element.\n * This method prefers the virtual parent over real DOM parent when present.\n */\nexport function getParent(child: Node | null, options: GetParentOptions = {}): Node | null {\n if (!child) {\n return null;\n }\n\n if (!options.skipVirtual) {\n const virtualParent = getVirtualParent(child);\n\n if (virtualParent) {\n return virtualParent;\n }\n }\n\n return child?.parentNode || null;\n}\n"],"mappings":";;;;;;AAAA,MAAAA,kBAAA,gBAAAC,OAAA;AASA;;;AAGA,SAASC,gBAAgBA,CAACC,KAAW;EACnC,OAAOH,kBAAA,CAAAI,gBAAgB,CAACD,KAAK,CAAC,GAAGA,KAAK,CAACE,QAAQ,CAACC,MAAM,IAAI,IAAI,GAAG,IAAI;AACvE;AAEA;;;;AAIA,SAAgBC,SAASA,CAACJ,KAAkB,EAAEK,OAAA,GAA4B,EAAE;EAC1E,IAAI,CAACL,KAAK,EAAE;IACV,OAAO,IAAI;;EAGb,IAAI,CAACK,OAAO,CAACC,WAAW,EAAE;IACxB,MAAMC,aAAa,GAAGR,gBAAgB,CAACC,KAAK,CAAC;IAE7C,IAAIO,aAAa,EAAE;MACjB,OAAOA,aAAa;;;EAIxB,OAAO,CAAAP,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEQ,UAAU,KAAI,IAAI;AAClC;AAdAC,OAAA,CAAAL,SAAA,GAAAA,SAAA"}
1
+ {"version":3,"sources":["../../lib/virtualParent/getParent.js"],"sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n/**\n * Gets the virtual parent given the child element, if it exists.\n */\nfunction getVirtualParent(child) {\n return isVirtualElement(child) ? child._virtual.parent || null : null;\n}\n/**\n * Gets the element which is the parent of a given element.\n * This method prefers the virtual parent over real DOM parent when present.\n */\nexport function getParent(child, options = {}) {\n if (!child) {\n return null;\n }\n if (!options.skipVirtual) {\n const virtualParent = getVirtualParent(child);\n if (virtualParent) {\n return virtualParent;\n }\n }\n return (child === null || child === void 0 ? void 0 : child.parentNode) || null;\n}\n//# sourceMappingURL=getParent.js.map"],"names":["getParent","getVirtualParent","child","isVirtualElement","_virtual","parent","options","skipVirtual","virtualParent","parentNode"],"mappings":";;;;+BAWgBA;;aAAAA;;kCAXiB;AACjC;;CAEC,GACD,SAASC,iBAAiBC,KAAK,EAAE;IAC/B,OAAOC,IAAAA,kCAAgB,EAACD,SAASA,MAAME,QAAQ,CAACC,MAAM,IAAI,IAAI,GAAG,IAAI;AACvE;AAKO,SAASL,UAAUE,KAAK,EAAEI,UAAU,CAAC,CAAC,EAAE;IAC7C,IAAI,CAACJ,OAAO;QACV,OAAO,IAAI;IACb,CAAC;IACD,IAAI,CAACI,QAAQC,WAAW,EAAE;QACxB,MAAMC,gBAAgBP,iBAAiBC;QACvC,IAAIM,eAAe;YACjB,OAAOA;QACT,CAAC;IACH,CAAC;IACD,OAAO,AAACN,CAAAA,UAAU,IAAI,IAAIA,UAAU,KAAK,IAAI,KAAK,IAAIA,MAAMO,UAAU,AAAD,KAAM,IAAI;AACjF,EACA,qCAAqC"}
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- const tslib_1 = /*#__PURE__*/require("tslib");
7
- tslib_1.__exportStar(require("./elementContains"), exports);
8
- tslib_1.__exportStar(require("./setVirtualParent"), exports);
5
+ const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
6
+ _exportStar(require("./elementContains"), exports);
7
+ _exportStar(require("./setVirtualParent"), exports);
8
+ //# sourceMappingURL=index.js.map
9
+
9
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["tslib_1","__exportStar","require","exports"],"sources":["../src/packages/react-components/react-portal/src/virtualParent/index.ts"],"sourcesContent":["export * from './elementContains';\nexport * from './setVirtualParent';\n"],"mappings":";;;;;;AAAAA,OAAA,CAAAC,YAAA,CAAAC,OAAA,uBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,wBAAAC,OAAA"}
1
+ {"version":3,"sources":["../../lib/virtualParent/index.js"],"sourcesContent":["export * from './elementContains';\nexport * from './setVirtualParent';\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;;oBAAc;oBACA;CACd,iCAAiC"}
@@ -1,14 +1,15 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isVirtualElement = void 0;
7
1
  /**
8
2
  * Determines whether or not an element has the virtual hierarchy extension.
9
- */
3
+ */ "use strict";
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ Object.defineProperty(exports, "isVirtualElement", {
8
+ enumerable: true,
9
+ get: ()=>isVirtualElement
10
+ });
10
11
  function isVirtualElement(element) {
11
- return element && !!element._virtual;
12
- }
13
- exports.isVirtualElement = isVirtualElement;
12
+ return element && !!element._virtual;
13
+ } //# sourceMappingURL=isVirtualElement.js.map
14
+
14
15
  //# sourceMappingURL=isVirtualElement.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["isVirtualElement","element","_virtual","exports"],"sources":["../src/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: Node | VirtualElement): element is VirtualElement {\n return element && !!(<VirtualElement>element)._virtual;\n}\n"],"mappings":";;;;;;AAEA;;;AAGA,SAAgBA,gBAAgBA,CAACC,OAA8B;EAC7D,OAAOA,OAAO,IAAI,CAAC,CAAkBA,OAAQ,CAACC,QAAQ;AACxD;AAFAC,OAAA,CAAAH,gBAAA,GAAAA,gBAAA"}
1
+ {"version":3,"sources":["../../lib/virtualParent/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//# sourceMappingURL=isVirtualElement.js.map"],"names":["isVirtualElement","element","_virtual"],"mappings":"AAAA;;CAEC;;;;+BAAkBA;;aAAAA;;AAAT,SAASA,iBAAiBC,OAAO,EAAE;IAC3C,OAAOA,WAAW,CAAC,CAACA,QAAQC,QAAQ;AACtC,EACA,4CAA4C"}
@@ -1,24 +1,25 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.setVirtualParent = void 0;
7
1
  /**
8
2
  * Sets the virtual parent of an element.
9
3
  *
10
4
  * @param child - Theme element to set the virtual parent
11
5
  * @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship
12
- */
6
+ */ "use strict";
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ Object.defineProperty(exports, "setVirtualParent", {
11
+ enumerable: true,
12
+ get: ()=>setVirtualParent
13
+ });
13
14
  function setVirtualParent(child, parent) {
14
- if (!child) {
15
- return;
16
- }
17
- const virtualChild = child;
18
- if (!virtualChild._virtual) {
19
- virtualChild._virtual = {};
20
- }
21
- virtualChild._virtual.parent = parent;
22
- }
23
- exports.setVirtualParent = setVirtualParent;
15
+ if (!child) {
16
+ return;
17
+ }
18
+ const virtualChild = child;
19
+ if (!virtualChild._virtual) {
20
+ virtualChild._virtual = {};
21
+ }
22
+ virtualChild._virtual.parent = parent;
23
+ } //# sourceMappingURL=setVirtualParent.js.map
24
+
24
25
  //# sourceMappingURL=setVirtualParent.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["setVirtualParent","child","parent","virtualChild","_virtual","exports"],"sources":["../src/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: Node, parent?: Node): void {\n if (!child) {\n return;\n }\n\n const virtualChild = child as VirtualElement;\n\n if (!virtualChild._virtual) {\n virtualChild._virtual = {};\n }\n\n virtualChild._virtual.parent = parent;\n}\n"],"mappings":";;;;;;AAEA;;;;;;AAMA,SAAgBA,gBAAgBA,CAACC,KAAW,EAAEC,MAAa;EACzD,IAAI,CAACD,KAAK,EAAE;IACV;;EAGF,MAAME,YAAY,GAAGF,KAAuB;EAE5C,IAAI,CAACE,YAAY,CAACC,QAAQ,EAAE;IAC1BD,YAAY,CAACC,QAAQ,GAAG,EAAE;;EAG5BD,YAAY,CAACC,QAAQ,CAACF,MAAM,GAAGA,MAAM;AACvC;AAZAG,OAAA,CAAAL,gBAAA,GAAAA,gBAAA"}
1
+ {"version":3,"sources":["../../lib/virtualParent/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//# sourceMappingURL=setVirtualParent.js.map"],"names":["setVirtualParent","child","parent","virtualChild","_virtual"],"mappings":"AAAA;;;;;CAKC;;;;+BAAkBA;;aAAAA;;AAAT,SAASA,iBAAiBC,KAAK,EAAEC,MAAM,EAAE;IACjD,IAAI,CAACD,OAAO;QACV;IACF,CAAC;IACD,MAAME,eAAeF;IACrB,IAAI,CAACE,aAAaC,QAAQ,EAAE;QAC1BD,aAAaC,QAAQ,GAAG,CAAC;IAC3B,CAAC;IACDD,aAAaC,QAAQ,CAACF,MAAM,GAAGA;AACjC,EACA,4CAA4C"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
5
+ //# sourceMappingURL=types.js.map
6
+
6
7
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["../src/packages/react-components/react-portal/src/virtualParent/types.ts"],"sourcesContent":["export interface VirtualElement extends Node {\n _virtual: {\n parent?: Node;\n };\n}\n"],"mappings":""}
1
+ {"version":3,"sources":["../../lib/virtualParent/types.js"],"sourcesContent":["export {};\n//# sourceMappingURL=types.js.map"],"names":[],"mappings":";;;;CACA,iCAAiC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-portal",
3
- "version": "9.2.1",
3
+ "version": "9.2.2",
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",
@@ -22,7 +22,7 @@
22
22
  "test": "jest --passWithNoTests",
23
23
  "storybook": "start-storybook",
24
24
  "type-check": "tsc -b tsconfig.json",
25
- "generate-api": "tsc -p ./tsconfig.lib.json --emitDeclarationOnly && just-scripts api-extractor"
25
+ "generate-api": "just-scripts generate-api"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@fluentui/eslint-plugin": "*",
@@ -31,11 +31,11 @@
31
31
  "@fluentui/scripts-tasks": "*"
32
32
  },
33
33
  "dependencies": {
34
- "@fluentui/react-shared-contexts": "^9.3.1",
35
- "@fluentui/react-tabster": "^9.6.0",
36
- "@fluentui/react-utilities": "^9.7.1",
34
+ "@fluentui/react-shared-contexts": "^9.3.2",
35
+ "@fluentui/react-tabster": "^9.6.1",
36
+ "@fluentui/react-utilities": "^9.7.2",
37
37
  "@griffel/react": "^1.5.2",
38
- "tslib": "^2.1.0",
38
+ "@swc/helpers": "^0.4.14",
39
39
  "use-disposable": "^1.0.1"
40
40
  },
41
41
  "peerDependencies": {
@@ -53,6 +53,7 @@
53
53
  "exports": {
54
54
  ".": {
55
55
  "types": "./dist/index.d.ts",
56
+ "node": "./lib-commonjs/index.js",
56
57
  "import": "./lib/index.js",
57
58
  "require": "./lib-commonjs/index.js"
58
59
  },
@@ -1,16 +0,0 @@
1
- define(["require", "exports", "./usePortal", "./renderPortal"], function (require, exports, usePortal_1, renderPortal_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.Portal = void 0;
5
- /**
6
- * A portal provides a way to render children into a DOM node
7
- * that exists outside the DOM hierarchy of the parent component.
8
- */
9
- var Portal = function (props) {
10
- var state = usePortal_1.usePortal_unstable(props);
11
- return renderPortal_1.renderPortal_unstable(state);
12
- };
13
- exports.Portal = Portal;
14
- exports.Portal.displayName = 'Portal';
15
- });
16
- //# sourceMappingURL=Portal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Portal.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-portal/src/components/Portal/Portal.tsx"],"names":[],"mappings":";;;;IAMA;;;OAGG;IACI,IAAM,MAAM,GAA0B,UAAA,KAAK;QAChD,IAAM,KAAK,GAAG,8BAAkB,CAAC,KAAK,CAAC,CAAC;QAExC,OAAO,oCAAqB,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC,CAAC;IAJW,QAAA,MAAM,UAIjB;IAEF,cAAM,CAAC,WAAW,GAAG,QAAQ,CAAC","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"]}