@fluentui/react-portal 9.2.1 → 9.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
package/.swcrc ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/swcrc",
3
+ "exclude": [
4
+ "/testing",
5
+ "/**/*.cy.ts",
6
+ "/**/*.cy.tsx",
7
+ "/**/*.spec.ts",
8
+ "/**/*.spec.tsx",
9
+ "/**/*.test.ts",
10
+ "/**/*.test.tsx"
11
+ ],
12
+ "jsc": {
13
+ "parser": {
14
+ "syntax": "typescript",
15
+ "tsx": true,
16
+ "decorators": false,
17
+ "dynamicImport": false
18
+ },
19
+ "externalHelpers": true,
20
+ "transform": {
21
+ "react": {
22
+ "runtime": "classic",
23
+ "useSpread": true
24
+ }
25
+ },
26
+ "target": "es2019"
27
+ },
28
+ "minify": false,
29
+ "sourceMaps": true
30
+ }
package/CHANGELOG.json CHANGED
@@ -2,7 +2,46 @@
2
2
  "name": "@fluentui/react-portal",
3
3
  "entries": [
4
4
  {
5
- "date": "Thu, 16 Mar 2023 14:33:33 GMT",
5
+ "date": "Tue, 21 Mar 2023 21:18:56 GMT",
6
+ "tag": "@fluentui/react-portal_v9.2.2",
7
+ "version": "9.2.2",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "tristan.watanabe@gmail.com",
12
+ "package": "@fluentui/react-portal",
13
+ "commit": "2fac1a139149bd13b76b1306207bc988dca9c72c",
14
+ "comment": "chore: migrate to swc transpilation approach."
15
+ },
16
+ {
17
+ "author": "tristan.watanabe@gmail.com",
18
+ "package": "@fluentui/react-portal",
19
+ "commit": "ead1c6d4c2ac3f3596b62b8cbc07b0a03041f11f",
20
+ "comment": "fix: add node field to package.json exports map."
21
+ },
22
+ {
23
+ "author": "beachball",
24
+ "package": "@fluentui/react-portal",
25
+ "comment": "Bump @fluentui/react-shared-contexts to v9.3.2",
26
+ "commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
27
+ },
28
+ {
29
+ "author": "beachball",
30
+ "package": "@fluentui/react-portal",
31
+ "comment": "Bump @fluentui/react-tabster to v9.6.1",
32
+ "commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
33
+ },
34
+ {
35
+ "author": "beachball",
36
+ "package": "@fluentui/react-portal",
37
+ "comment": "Bump @fluentui/react-utilities to v9.7.2",
38
+ "commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
39
+ }
40
+ ]
41
+ }
42
+ },
43
+ {
44
+ "date": "Thu, 16 Mar 2023 14:36:59 GMT",
6
45
  "tag": "@fluentui/react-portal_v9.2.1",
7
46
  "version": "9.2.1",
8
47
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,25 @@
1
1
  # Change Log - @fluentui/react-portal
2
2
 
3
- This log was last generated on Thu, 16 Mar 2023 14:33:33 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 21 Mar 2023 21:18:56 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.2.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-portal_v9.2.2)
8
+
9
+ Tue, 21 Mar 2023 21:18:56 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-portal_v9.2.1..@fluentui/react-portal_v9.2.2)
11
+
12
+ ### Patches
13
+
14
+ - chore: migrate to swc transpilation approach. ([PR #27250](https://github.com/microsoft/fluentui/pull/27250) by tristan.watanabe@gmail.com)
15
+ - fix: add node field to package.json exports map. ([PR #27154](https://github.com/microsoft/fluentui/pull/27154) by tristan.watanabe@gmail.com)
16
+ - Bump @fluentui/react-shared-contexts to v9.3.2 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
17
+ - Bump @fluentui/react-tabster to v9.6.1 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
18
+ - Bump @fluentui/react-utilities to v9.7.2 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
19
+
7
20
  ## [9.2.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-portal_v9.2.1)
8
21
 
9
- Thu, 16 Mar 2023 14:33:33 GMT
22
+ Thu, 16 Mar 2023 14:36:59 GMT
10
23
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-portal_v9.2.0..@fluentui/react-portal_v9.2.1)
11
24
 
12
25
  ### Patches
package/lib/Portal.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Portal.js","sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/Portal.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC","sourcesContent":["export * from './components/Portal/index';\n"]}
1
+ {"version":3,"names":[],"sources":["../src/Portal.ts"],"sourcesContent":["export * from './components/Portal/index';\n"],"mappings":"AAAA,cAAc"}
@@ -1,3 +1,4 @@
1
+ import * as React from 'react';
1
2
  import { usePortal_unstable } from './usePortal';
2
3
  import { renderPortal_unstable } from './renderPortal';
3
4
  /**
@@ -1 +1 @@
1
- {"version":3,"names":["usePortal_unstable","renderPortal_unstable","Portal","props","state","displayName"],"sources":["../src/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"],"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"}
1
+ {"version":3,"names":["React","usePortal_unstable","renderPortal_unstable","Portal","props","state","displayName"],"sources":["../../../src/components/Portal/Portal.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { usePortal_unstable } from './usePortal';\nimport { renderPortal_unstable } from './renderPortal';\nimport type { PortalProps } from './Portal.types';\n\n/**\n * A portal provides a way to render children into a DOM node\n * that exists outside the DOM hierarchy of the parent component.\n */\nexport const Portal: React.FC<PortalProps> = props => {\n const state = usePortal_unstable(props);\n\n return renderPortal_unstable(state);\n};\n\nPortal.displayName = 'Portal';\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAEvB,SAASC,kBAAkB,QAAQ;AACnC,SAASC,qBAAqB,QAAQ;AAGtC;;;;AAIA,OAAO,MAAMC,MAAA,GAAgCC,KAAA,IAAS;EACpD,MAAMC,KAAA,GAAQJ,kBAAA,CAAmBG,KAAA;EAEjC,OAAOF,qBAAA,CAAsBG,KAAA;AAC/B;AAEAF,MAAA,CAAOG,WAAW,GAAG"}
@@ -1,2 +1,2 @@
1
- export {};
1
+ import * as React from 'react';
2
2
  //# sourceMappingURL=Portal.types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Portal.types.js","sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/components/Portal/Portal.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\n\nexport type PortalProps = {\n /**\n * React children\n */\n children?: React.ReactNode;\n\n /**\n * Where the portal children are mounted on DOM\n *\n * @default a new element on document.body without any styling\n */\n mountNode?: HTMLElement | null | { element?: HTMLElement | null; className?: string };\n};\n\nexport type PortalState = Pick<PortalProps, 'children'> & {\n mountNode: HTMLElement | null | undefined;\n\n /**\n * Ref to the root span element as virtual parent\n */\n virtualParentRootRef: React.MutableRefObject<HTMLSpanElement | null>;\n};\n"]}
1
+ {"version":3,"names":["React"],"sources":["../../../src/components/Portal/Portal.types.ts"],"sourcesContent":["import * as React from 'react';\n\nexport type PortalProps = {\n /**\n * React children\n */\n children?: React.ReactNode;\n\n /**\n * Where the portal children are mounted on DOM\n *\n * @default a new element on document.body without any styling\n */\n mountNode?: HTMLElement | null | { element?: HTMLElement | null; className?: string };\n};\n\nexport type PortalState = Pick<PortalProps, 'children'> & {\n mountNode: HTMLElement | null | undefined;\n\n /**\n * Ref to the root span element as virtual parent\n */\n virtualParentRootRef: React.MutableRefObject<HTMLSpanElement | null>;\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/components/Portal/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC","sourcesContent":["export * from './Portal';\nexport * from './Portal.types';\nexport * from './renderPortal';\nexport * from './usePortal';\n"]}
1
+ {"version":3,"names":[],"sources":["../../../src/components/Portal/index.ts"],"sourcesContent":["export * from './Portal';\nexport * from './Portal.types';\nexport * from './renderPortal';\nexport * from './usePortal';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"names":["ReactDOM","React","renderPortal_unstable","state","createElement","hidden","ref","virtualParentRootRef","mountNode","createPortal","children"],"sources":["../src/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"],"mappings":"AAAA,OAAO,KAAKA,QAAQ,MAAM,WAAW;AACrC,OAAO,KAAKC,KAAK,MAAM,OAAO;AAG9B;;;AAGA,OAAO,MAAMC,qBAAqB,GAAIC,KAAkB,IAAwB;EAC9E,oBACEF,KAAA,CAAAG,aAAA;IAAMC,MAAM;IAACC,GAAG,EAAEH,KAAK,CAACI;EAAoB,GACzCJ,KAAK,CAACK,SAAS,iBAAIR,QAAQ,CAACS,YAAY,CAACN,KAAK,CAACO,QAAQ,EAAEP,KAAK,CAACK,SAAS,CAAC,CACrE;AAEX,CAAC"}
1
+ {"version":3,"names":["ReactDOM","React","renderPortal_unstable","state","createElement","hidden","ref","virtualParentRootRef","mountNode","createPortal","children"],"sources":["../../../src/components/Portal/renderPortal.tsx"],"sourcesContent":["import * as ReactDOM from 'react-dom';\nimport * as React from 'react';\nimport type { PortalState } from './Portal.types';\n\n/**\n * Render the final JSX of Portal\n */\nexport const renderPortal_unstable = (state: PortalState): React.ReactElement => {\n return (\n <span hidden ref={state.virtualParentRootRef}>\n {state.mountNode && ReactDOM.createPortal(state.children, state.mountNode)}\n </span>\n );\n};\n"],"mappings":"AAAA,YAAYA,QAAA,MAAc;AAC1B,YAAYC,KAAA,MAAW;AAGvB;;;AAGA,OAAO,MAAMC,qBAAA,GAAyBC,KAAA,IAA2C;EAC/E,oBACEF,KAAA,CAAAG,aAAA,CAAC;IAAKC,MAAA,MAAM;IAACC,GAAA,EAAKH,KAAA,CAAMI;KACrBJ,KAAA,CAAMK,SAAS,iBAAIR,QAAA,CAASS,YAAY,CAACN,KAAA,CAAMO,QAAQ,EAAEP,KAAA,CAAMK,SAAS;AAG/E"}
@@ -1 +1 @@
1
- {"version":3,"names":["isHTMLElement","React","setVirtualParent","usePortalMountNode","toMountNodeProps","mountNode","element","usePortal_unstable","props","className","virtualParentRootRef","useRef","fallbackElement","disabled","state","children","useEffect","current","undefined"],"sources":["../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.mountNode, undefined);\n }\n };\n }, [state.virtualParentRootRef, state.mountNode]);\n\n return state;\n};\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,2BAA2B;AACzD,OAAO,KAAKC,KAAK,MAAM,OAAO;AAE9B,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5D,SAASC,kBAAkB,QAAQ,sBAAsB;AAGzD,OAAM,SAAUC,gBAAgBA,CAACC,SAAmC;EAIlE,IAAIL,aAAa,CAACK,SAAS,CAAC,EAAE;IAC5B,OAAO;MAAEC,OAAO,EAAED;IAAS,CAAE;;EAG/B,IAAI,OAAOA,SAAS,KAAK,QAAQ,EAAE;IACjC,IAAIA,SAAS,KAAK,IAAI,EAAE;MACtB,OAAO;QAAEC,OAAO,EAAE;MAAI,CAAE;;IAG1B,OAAOD,SAAS;;EAGlB,OAAO,EAAE;AACX;AAEA;;;;;;;AAOA,OAAO,MAAME,kBAAkB,GAAIC,KAAkB,IAAiB;EACpE,MAAM;IAAEF,OAAO;IAAEG;EAAS,CAAE,GAAGL,gBAAgB,CAACI,KAAK,CAACH,SAAS,CAAC;EAEhE,MAAMK,oBAAoB,GAAGT,KAAK,CAACU,MAAM,CAAkB,IAAI,CAAC;EAChE,MAAMC,eAAe,GAAGT,kBAAkB,CAAC;IAAEU,QAAQ,EAAE,CAAC,CAACP,OAAO;IAAEG;EAAS,CAAE,CAAC;EAE9E,MAAMK,KAAK,GAAgB;IACzBC,QAAQ,EAAEP,KAAK,CAACO,QAAQ;IACxBV,SAAS,EAAEC,OAAO,aAAPA,OAAO,cAAPA,OAAO,GAAIM,eAAe;IACrCF;GACD;EAEDT,KAAK,CAACe,SAAS,CAAC,MAAK;IACnB,IAAIF,KAAK,CAACJ,oBAAoB,CAACO,OAAO,IAAIH,KAAK,CAACT,SAAS,EAAE;MACzDH,gBAAgB,CAACY,KAAK,CAACT,SAAS,EAAES,KAAK,CAACJ,oBAAoB,CAACO,OAAO,CAAC;;IAEvE,OAAO,MAAK;MACV,IAAIH,KAAK,CAACT,SAAS,EAAE;QACnBH,gBAAgB,CAACY,KAAK,CAACT,SAAS,EAAEa,SAAS,CAAC;;IAEhD,CAAC;EACH,CAAC,EAAE,CAACJ,KAAK,CAACJ,oBAAoB,EAAEI,KAAK,CAACT,SAAS,CAAC,CAAC;EAEjD,OAAOS,KAAK;AACd,CAAC"}
1
+ {"version":3,"names":["isHTMLElement","React","setVirtualParent","usePortalMountNode","toMountNodeProps","mountNode","element","usePortal_unstable","props","className","virtualParentRootRef","useRef","fallbackElement","disabled","state","children","useEffect","current","undefined"],"sources":["../../../src/components/Portal/usePortal.ts"],"sourcesContent":["import { isHTMLElement } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { setVirtualParent } from '../../virtualParent/index';\nimport { usePortalMountNode } from './usePortalMountNode';\nimport type { PortalProps, PortalState } from './Portal.types';\n\nexport function toMountNodeProps(mountNode: PortalProps['mountNode']): {\n element?: HTMLElement | null;\n className?: string;\n} {\n if (isHTMLElement(mountNode)) {\n return { element: mountNode };\n }\n\n if (typeof mountNode === 'object') {\n if (mountNode === null) {\n return { element: null };\n }\n\n return mountNode;\n }\n\n return {};\n}\n\n/**\n * Create the state required to render Portal.\n *\n * The returned state can be modified with hooks such as usePortalStyles, before being passed to renderPortal_unstable.\n *\n * @param props - props from this instance of Portal\n */\nexport const usePortal_unstable = (props: PortalProps): PortalState => {\n const { element, className } = toMountNodeProps(props.mountNode);\n\n const virtualParentRootRef = React.useRef<HTMLSpanElement>(null);\n const fallbackElement = usePortalMountNode({ disabled: !!element, className });\n\n const state: PortalState = {\n children: props.children,\n mountNode: element ?? fallbackElement,\n virtualParentRootRef,\n };\n\n React.useEffect(() => {\n if (state.virtualParentRootRef.current && state.mountNode) {\n setVirtualParent(state.mountNode, state.virtualParentRootRef.current);\n }\n return () => {\n if (state.mountNode) {\n setVirtualParent(state.mountNode, undefined);\n }\n };\n }, [state.virtualParentRootRef, state.mountNode]);\n\n return state;\n};\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ;AAC9B,YAAYC,KAAA,MAAW;AAEvB,SAASC,gBAAgB,QAAQ;AACjC,SAASC,kBAAkB,QAAQ;AAGnC,OAAO,SAASC,iBAAiBC,SAAmC,EAGlE;EACA,IAAIL,aAAA,CAAcK,SAAA,GAAY;IAC5B,OAAO;MAAEC,OAAA,EAASD;IAAU;EAC9B;EAEA,IAAI,OAAOA,SAAA,KAAc,UAAU;IACjC,IAAIA,SAAA,KAAc,IAAI,EAAE;MACtB,OAAO;QAAEC,OAAA,EAAS;MAAK;IACzB;IAEA,OAAOD,SAAA;EACT;EAEA,OAAO,CAAC;AACV;AAEA;;;;;;;AAOA,OAAO,MAAME,kBAAA,GAAsBC,KAAA,IAAoC;EACrE,MAAM;IAAEF,OAAA;IAASG;EAAS,CAAE,GAAGL,gBAAA,CAAiBI,KAAA,CAAMH,SAAS;EAE/D,MAAMK,oBAAA,GAAuBT,KAAA,CAAMU,MAAM,CAAkB,IAAI;EAC/D,MAAMC,eAAA,GAAkBT,kBAAA,CAAmB;IAAEU,QAAA,EAAU,CAAC,CAACP,OAAA;IAASG;EAAU;EAE5E,MAAMK,KAAA,GAAqB;IACzBC,QAAA,EAAUP,KAAA,CAAMO,QAAQ;IACxBV,SAAA,EAAWC,OAAA,aAAAA,OAAA,cAAAA,OAAA,GAAWM,eAAe;IACrCF;EACF;EAEAT,KAAA,CAAMe,SAAS,CAAC,MAAM;IACpB,IAAIF,KAAA,CAAMJ,oBAAoB,CAACO,OAAO,IAAIH,KAAA,CAAMT,SAAS,EAAE;MACzDH,gBAAA,CAAiBY,KAAA,CAAMT,SAAS,EAAES,KAAA,CAAMJ,oBAAoB,CAACO,OAAO;IACtE;IACA,OAAO,MAAM;MACX,IAAIH,KAAA,CAAMT,SAAS,EAAE;QACnBH,gBAAA,CAAiBY,KAAA,CAAMT,SAAS,EAAEa,SAAA;MACpC;IACF;EACF,GAAG,CAACJ,KAAA,CAAMJ,oBAAoB,EAAEI,KAAA,CAAMT,SAAS,CAAC;EAEhD,OAAOS,KAAA;AACT"}
@@ -1 +1 @@
1
- {"version":3,"names":["React","useThemeClassName_unstable","useThemeClassName","useFluent_unstable","useFluent","__styles","mergeClasses","useFocusVisible","useDisposable","useInsertionEffect","useStyles","root","qhf8xq","Bj3rh1h","d","usePortalMountNode","options","targetDocument","dir","focusVisibleRef","classes","themeClassName","className","element","undefined","disabled","newElement","createElement","body","appendChild","remove","classesToApply","split","filter","Boolean","classList","add","setAttribute","current","removeAttribute","useMemo"],"sources":["../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 }\n\n return element;\n};\n"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SACEC,0BAA0B,IAAIC,iBAAiB,EAC/CC,kBAAkB,IAAIC,SAAS,QAC1B,iCAAiC;AACxC,SAAAC,QAAA,EAAqBC,YAAY,QAAQ,gBAAgB;AACzD,SAASC,eAAe,QAAQ,yBAAyB;AACzD,SAASC,aAAa,QAAQ,gBAAgB;AAE9C,MAAMC,kBAAkB,GAAIT,KAAe,CAAC,cAAc,GAAG,QAAQ,CAA6C;AAWlH,MAAMU,SAAS,gBAAGL,QAAA;EAAAM,IAAA;IAAAC,MAAA;IAAAC,OAAA;EAAA;AAAA;EAAAC,CAAA;AAAA,EAKhB;AAEF;;;AAGA,OAAO,MAAMC,kBAAkB,GAAIC,OAAkC,IAAwB;EAC3F,MAAM;IAAEC,cAAc;IAAEC;EAAG,CAAE,GAAGd,SAAS,EAAE;EAC3C,MAAMe,eAAe,GAAGZ,eAAe,EAAgE;EACvG,MAAMa,OAAO,GAAGV,SAAS,EAAE;EAC3B,MAAMW,cAAc,GAAGnB,iBAAiB,EAAE;EAE1C,MAAMoB,SAAS,GAAGhB,YAAY,CAACe,cAAc,EAAED,OAAO,CAACT,IAAI,EAAEK,OAAO,CAACM,SAAS,CAAC;EAE/E,MAAMC,OAAO,GAAGf,aAAa,CAAC,MAAK;IACjC,IAAIS,cAAc,KAAKO,SAAS,IAAIR,OAAO,CAACS,QAAQ,EAAE;MACpD,OAAO,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC;;IAG3B,MAAMC,UAAU,GAAGT,cAAc,CAACU,aAAa,CAAC,KAAK,CAAC;IACtDV,cAAc,CAACW,IAAI,CAACC,WAAW,CAACH,UAAU,CAAC;IAC3C,OAAO,CAACA,UAAU,EAAE,MAAMA,UAAU,CAACI,MAAM,EAAE,CAAC;EAChD,CAAC,EAAE,CAACb,cAAc,CAAC,CAAC;EAEpB,IAAIR,kBAAkB,EAAE;IACtB;IACAA,kBAAkB,CAAC,MAAK;MACtB,IAAI,CAACc,OAAO,EAAE;QACZ;;MAGF,MAAMQ,cAAc,GAAGT,SAAS,CAACU,KAAK,CAAC,GAAG,CAAC,CAACC,MAAM,CAACC,OAAO,CAAC;MAE3DX,OAAO,CAACY,SAAS,CAACC,GAAG,CAAC,GAAGL,cAAc,CAAC;MACxCR,OAAO,CAACc,YAAY,CAAC,KAAK,EAAEnB,GAAG,CAAC;MAChCC,eAAe,CAACmB,OAAO,GAAGf,OAAO;MAEjC,OAAO,MAAK;QACVA,OAAO,CAACY,SAAS,CAACL,MAAM,CAAC,GAAGC,cAAc,CAAC;QAC3CR,OAAO,CAACgB,eAAe,CAAC,KAAK,CAAC;MAChC,CAAC;IACH,CAAC,EAAE,CAACjB,SAAS,EAAEJ,GAAG,EAAEK,OAAO,EAAEJ,eAAe,CAAC,CAAC;GAC/C,MAAM;IACL;IACA;IACA;IACA;IACA;IACAnB,KAAK,CAACwC,OAAO,CAAC,MAAK;MACjB,IAAI,CAACjB,OAAO,EAAE;QACZ;;MAGF;MACAA,OAAO,CAACD,SAAS,GAAGA,SAAS;MAC7BC,OAAO,CAACc,YAAY,CAAC,KAAK,EAAEnB,GAAG,CAAC;MAChCC,eAAe,CAACmB,OAAO,GAAGf,OAAO;IACnC,CAAC,EAAE,CAACD,SAAS,EAAEJ,GAAG,EAAEK,OAAO,EAAEJ,eAAe,CAAC,CAAC;;EAGhD,OAAOI,OAAO;AAChB,CAAC"}
1
+ {"version":3,"names":["React","useThemeClassName_unstable","useThemeClassName","useFluent_unstable","useFluent","__styles","mergeClasses","useFocusVisible","useDisposable","useInsertionEffect","useStyles","root","qhf8xq","Bj3rh1h","d","usePortalMountNode","options","targetDocument","dir","focusVisibleRef","classes","themeClassName","className","element","undefined","disabled","newElement","createElement","body","appendChild","remove","classesToApply","split","filter","Boolean","classList","add","setAttribute","current","removeAttribute","useMemo"],"sources":["../../../src/components/Portal/usePortalMountNode.ts"],"sourcesContent":["import * as React from 'react';\nimport {\n useThemeClassName_unstable as useThemeClassName,\n useFluent_unstable as useFluent,\n} from '@fluentui/react-shared-contexts';\nimport { makeStyles, mergeClasses } from '@griffel/react';\nimport { useFocusVisible } from '@fluentui/react-tabster';\nimport { useDisposable } from 'use-disposable';\n\nconst useInsertionEffect = (React as never)['useInsertion' + 'Effect'] as typeof React.useLayoutEffect | undefined;\n\nexport type UsePortalMountNodeOptions = {\n /**\n * Since hooks cannot be called conditionally use this flag to disable creating the node\n */\n disabled?: boolean;\n\n className?: string;\n};\n\nconst useStyles = makeStyles({\n root: {\n position: 'relative',\n zIndex: 1000000,\n },\n});\n\n/**\n * Creates a new element on a \"document.body\" to mount portals.\n */\nexport const usePortalMountNode = (options: UsePortalMountNodeOptions): HTMLElement | null => {\n const { targetDocument, dir } = useFluent();\n const focusVisibleRef = useFocusVisible<HTMLDivElement>() as React.MutableRefObject<HTMLElement | null>;\n const classes = useStyles();\n const themeClassName = useThemeClassName();\n\n const className = mergeClasses(themeClassName, classes.root, options.className);\n\n const element = useDisposable(() => {\n if (targetDocument === undefined || options.disabled) {\n return [null, () => null];\n }\n\n const newElement = targetDocument.createElement('div');\n targetDocument.body.appendChild(newElement);\n return [newElement, () => newElement.remove()];\n }, [targetDocument]);\n\n if (useInsertionEffect) {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useInsertionEffect(() => {\n if (!element) {\n return;\n }\n\n const classesToApply = className.split(' ').filter(Boolean);\n\n element.classList.add(...classesToApply);\n element.setAttribute('dir', dir);\n focusVisibleRef.current = element;\n\n return () => {\n element.classList.remove(...classesToApply);\n element.removeAttribute('dir');\n };\n }, [className, dir, element, focusVisibleRef]);\n } else {\n // This useMemo call is intentional for React 17\n // We don't want to re-create the portal element when its attributes change.\n // This also should not be done in an effect because, changing the value of css variables\n // after initial mount can trigger interesting CSS side effects like transitions.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useMemo(() => {\n if (!element) {\n return;\n }\n\n // Force replace all classes\n element.className = className;\n element.setAttribute('dir', dir);\n focusVisibleRef.current = element;\n }, [className, dir, element, focusVisibleRef]);\n }\n\n return element;\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SACEC,0BAAA,IAA8BC,iBAAiB,EAC/CC,kBAAA,IAAsBC,SAAS,QAC1B;AACP,SAAAC,QAAA,EAAqBC,YAAY,QAAQ;AACzC,SAASC,eAAe,QAAQ;AAChC,SAASC,aAAa,QAAQ;AAE9B,MAAMC,kBAAA,GAAqBT,KAAgB,CAAC,iBAAiB,SAAS;AAWtE,MAAMU,SAAA,gBAAYL,QAAA;EAAAM,IAAA;IAAAC,MAAA;IAAAC,OAAA;EAAA;AAAA;EAAAC,CAAA;AAAA,EAKlB;AAEA;;;AAGA,OAAO,MAAMC,kBAAA,GAAsBC,OAAA,IAA2D;EAC5F,MAAM;IAAEC,cAAA;IAAgBC;EAAG,CAAE,GAAGd,SAAA;EAChC,MAAMe,eAAA,GAAkBZ,eAAA;EACxB,MAAMa,OAAA,GAAUV,SAAA;EAChB,MAAMW,cAAA,GAAiBnB,iBAAA;EAEvB,MAAMoB,SAAA,GAAYhB,YAAA,CAAae,cAAA,EAAgBD,OAAA,CAAQT,IAAI,EAAEK,OAAA,CAAQM,SAAS;EAE9E,MAAMC,OAAA,GAAUf,aAAA,CAAc,MAAM;IAClC,IAAIS,cAAA,KAAmBO,SAAA,IAAaR,OAAA,CAAQS,QAAQ,EAAE;MACpD,OAAO,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC;IAC3B;IAEA,MAAMC,UAAA,GAAaT,cAAA,CAAeU,aAAa,CAAC;IAChDV,cAAA,CAAeW,IAAI,CAACC,WAAW,CAACH,UAAA;IAChC,OAAO,CAACA,UAAA,EAAY,MAAMA,UAAA,CAAWI,MAAM,GAAG;EAChD,GAAG,CAACb,cAAA,CAAe;EAEnB,IAAIR,kBAAA,EAAoB;IACtB;IACAA,kBAAA,CAAmB,MAAM;MACvB,IAAI,CAACc,OAAA,EAAS;QACZ;MACF;MAEA,MAAMQ,cAAA,GAAiBT,SAAA,CAAUU,KAAK,CAAC,KAAKC,MAAM,CAACC,OAAA;MAEnDX,OAAA,CAAQY,SAAS,CAACC,GAAG,IAAIL,cAAA;MACzBR,OAAA,CAAQc,YAAY,CAAC,OAAOnB,GAAA;MAC5BC,eAAA,CAAgBmB,OAAO,GAAGf,OAAA;MAE1B,OAAO,MAAM;QACXA,OAAA,CAAQY,SAAS,CAACL,MAAM,IAAIC,cAAA;QAC5BR,OAAA,CAAQgB,eAAe,CAAC;MAC1B;IACF,GAAG,CAACjB,SAAA,EAAWJ,GAAA,EAAKK,OAAA,EAASJ,eAAA,CAAgB;EAC/C,OAAO;IACL;IACA;IACA;IACA;IACA;IACAnB,KAAA,CAAMwC,OAAO,CAAC,MAAM;MAClB,IAAI,CAACjB,OAAA,EAAS;QACZ;MACF;MAEA;MACAA,OAAA,CAAQD,SAAS,GAAGA,SAAA;MACpBC,OAAA,CAAQc,YAAY,CAAC,OAAOnB,GAAA;MAC5BC,eAAA,CAAgBmB,OAAO,GAAGf,OAAA;IAC5B,GAAG,CAACD,SAAA,EAAWJ,GAAA,EAAKK,OAAA,EAASJ,eAAA,CAAgB;EAC/C;EAEA,OAAOI,OAAA;AACT"}
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE9F,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC","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"]}
1
+ {"version":3,"names":["Portal","renderPortal_unstable","usePortal_unstable","elementContains","setVirtualParent"],"sources":["../src/index.ts"],"sourcesContent":["export { Portal, renderPortal_unstable, usePortal_unstable } from './components/Portal/index';\nexport type { PortalProps, PortalState } from './components/Portal/index';\nexport { elementContains, setVirtualParent } from './virtualParent/index';\n"],"mappings":"AAAA,SAASA,MAAM,EAAEC,qBAAqB,EAAEC,kBAAkB,QAAQ;AAElE,SAASC,eAAe,EAAEC,gBAAgB,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"names":["getParent","elementContains","parent","child","set","WeakSet","nextParent","skipVirtual","has","add"],"sources":["../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,SAASA,SAAS,QAAQ,aAAa;AAEvC;;;;;;AAMA,OAAM,SAAUC,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,GAAgBN,SAAS,CAACG,KAAK,EAAE;QAC/CI,WAAW,EAAEH,GAAG,CAACI,GAAG,CAACL,KAAK;OAC3B,CAAC;MACFC,GAAG,CAACK,GAAG,CAACN,KAAK,CAAC;MAEd,IAAIG,UAAU,KAAKJ,MAAM,EAAE;QACzB,OAAO,IAAI;;MAGbC,KAAK,GAAGG,UAAU;;;EAItB,OAAO,KAAK;AACd"}
1
+ {"version":3,"names":["getParent","elementContains","parent","child","set","WeakSet","nextParent","skipVirtual","has","add"],"sources":["../../src/virtualParent/elementContains.ts"],"sourcesContent":["import { getParent } from './getParent';\n\n/**\n * Similar functionality to `element.contains` DOM API for use without of order DOM elements that\n * checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent\n *\n * @returns true if the child can find the parent in its virtual hierarchy\n */\nexport function elementContains(parent: Node | null, child: Node | null): boolean {\n if (!parent || !child) {\n return false;\n }\n\n if (parent === child) {\n return true;\n } else {\n // Tracks references of nodes that have been visited to prevent infinite loops\n const set = new WeakSet<Node>();\n\n while (child) {\n const nextParent: Node | null = getParent(child, {\n skipVirtual: set.has(child),\n });\n set.add(child);\n\n if (nextParent === parent) {\n return true;\n }\n\n child = nextParent;\n }\n }\n\n return false;\n}\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ;AAE1B;;;;;;AAMA,OAAO,SAASC,gBAAgBC,MAAmB,EAAEC,KAAkB,EAAW;EAChF,IAAI,CAACD,MAAA,IAAU,CAACC,KAAA,EAAO;IACrB,OAAO,KAAK;EACd;EAEA,IAAID,MAAA,KAAWC,KAAA,EAAO;IACpB,OAAO,IAAI;EACb,OAAO;IACL;IACA,MAAMC,GAAA,GAAM,IAAIC,OAAA;IAEhB,OAAOF,KAAA,EAAO;MACZ,MAAMG,UAAA,GAA0BN,SAAA,CAAUG,KAAA,EAAO;QAC/CI,WAAA,EAAaH,GAAA,CAAII,GAAG,CAACL,KAAA;MACvB;MACAC,GAAA,CAAIK,GAAG,CAACN,KAAA;MAER,IAAIG,UAAA,KAAeJ,MAAA,EAAQ;QACzB,OAAO,IAAI;MACb;MAEAC,KAAA,GAAQG,UAAA;IACV;EACF;EAEA,OAAO,KAAK;AACd"}
@@ -1 +1 @@
1
- {"version":3,"names":["isVirtualElement","getVirtualParent","child","_virtual","parent","getParent","options","skipVirtual","virtualParent","parentNode"],"sources":["../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,SAASA,gBAAgB,QAAQ,oBAAoB;AASrD;;;AAGA,SAASC,gBAAgBA,CAACC,KAAW;EACnC,OAAOF,gBAAgB,CAACE,KAAK,CAAC,GAAGA,KAAK,CAACC,QAAQ,CAACC,MAAM,IAAI,IAAI,GAAG,IAAI;AACvE;AAEA;;;;AAIA,OAAM,SAAUC,SAASA,CAACH,KAAkB,EAAEI,OAAA,GAA4B,EAAE;EAC1E,IAAI,CAACJ,KAAK,EAAE;IACV,OAAO,IAAI;;EAGb,IAAI,CAACI,OAAO,CAACC,WAAW,EAAE;IACxB,MAAMC,aAAa,GAAGP,gBAAgB,CAACC,KAAK,CAAC;IAE7C,IAAIM,aAAa,EAAE;MACjB,OAAOA,aAAa;;;EAIxB,OAAO,CAAAN,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEO,UAAU,KAAI,IAAI;AAClC"}
1
+ {"version":3,"names":["isVirtualElement","getVirtualParent","child","_virtual","parent","getParent","options","skipVirtual","virtualParent","parentNode"],"sources":["../../src/virtualParent/getParent.ts"],"sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n\ntype GetParentOptions = {\n /**\n * Indicates if getParent() should ignore a virtual parent.\n */\n skipVirtual?: boolean;\n};\n\n/**\n * Gets the virtual parent given the child element, if it exists.\n */\nfunction getVirtualParent(child: Node): Node | null {\n return isVirtualElement(child) ? child._virtual.parent || null : null;\n}\n\n/**\n * Gets the element which is the parent of a given element.\n * This method prefers the virtual parent over real DOM parent when present.\n */\nexport function getParent(child: Node | null, options: GetParentOptions = {}): Node | null {\n if (!child) {\n return null;\n }\n\n if (!options.skipVirtual) {\n const virtualParent = getVirtualParent(child);\n\n if (virtualParent) {\n return virtualParent;\n }\n }\n\n return child?.parentNode || null;\n}\n"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ;AASjC;;;AAGA,SAASC,iBAAiBC,KAAW,EAAe;EAClD,OAAOF,gBAAA,CAAiBE,KAAA,IAASA,KAAA,CAAMC,QAAQ,CAACC,MAAM,IAAI,IAAI,GAAG,IAAI;AACvE;AAEA;;;;AAIA,OAAO,SAASC,UAAUH,KAAkB,EAAEI,OAAA,GAA4B,CAAC,CAAC,EAAe;EACzF,IAAI,CAACJ,KAAA,EAAO;IACV,OAAO,IAAI;EACb;EAEA,IAAI,CAACI,OAAA,CAAQC,WAAW,EAAE;IACxB,MAAMC,aAAA,GAAgBP,gBAAA,CAAiBC,KAAA;IAEvC,IAAIM,aAAA,EAAe;MACjB,OAAOA,aAAA;IACT;EACF;EAEA,OAAO,CAAAN,KAAA,aAAAA,KAAA,uBAAAA,KAAA,CAAOO,UAAU,KAAI,IAAI;AAClC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/virtualParent/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from './elementContains';\nexport * from './setVirtualParent';\n"]}
1
+ {"version":3,"names":[],"sources":["../../src/virtualParent/index.ts"],"sourcesContent":["export * from './elementContains';\nexport * from './setVirtualParent';\n"],"mappings":"AAAA,cAAc;AACd,cAAc"}
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * Determines whether or not an element has the virtual hierarchy extension.
3
- */
4
- export function isVirtualElement(element) {
3
+ */export function isVirtualElement(element) {
5
4
  return element && !!element._virtual;
6
5
  }
7
6
  //# sourceMappingURL=isVirtualElement.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["isVirtualElement","element","_virtual"],"sources":["../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,OAAM,SAAUA,gBAAgBA,CAACC,OAA8B;EAC7D,OAAOA,OAAO,IAAI,CAAC,CAAkBA,OAAQ,CAACC,QAAQ;AACxD"}
1
+ {"version":3,"names":["isVirtualElement","element","_virtual"],"sources":["../../src/virtualParent/isVirtualElement.ts"],"sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Determines whether or not an element has the virtual hierarchy extension.\n */\nexport function isVirtualElement(element: Node | VirtualElement): element is VirtualElement {\n return element && !!(<VirtualElement>element)._virtual;\n}\n"],"mappings":"AAEA;;GAGA,OAAO,SAASA,iBAAiBC,OAA8B,EAA6B;EAC1F,OAAOA,OAAA,IAAW,CAAC,CAACA,OAAiB,CAASC,QAAQ;AACxD"}
@@ -3,8 +3,7 @@
3
3
  *
4
4
  * @param child - Theme element to set the virtual parent
5
5
  * @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship
6
- */
7
- export function setVirtualParent(child, parent) {
6
+ */export function setVirtualParent(child, parent) {
8
7
  if (!child) {
9
8
  return;
10
9
  }
@@ -1 +1 @@
1
- {"version":3,"names":["setVirtualParent","child","parent","virtualChild","_virtual"],"sources":["../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,OAAM,SAAUA,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"}
1
+ {"version":3,"names":["setVirtualParent","child","parent","virtualChild","_virtual"],"sources":["../../src/virtualParent/setVirtualParent.ts"],"sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Sets the virtual parent of an element.\n *\n * @param child - Theme element to set the virtual parent\n * @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship\n */\nexport function setVirtualParent(child: Node, parent?: Node): void {\n if (!child) {\n return;\n }\n\n const virtualChild = child as VirtualElement;\n\n if (!virtualChild._virtual) {\n virtualChild._virtual = {};\n }\n\n virtualChild._virtual.parent = parent;\n}\n"],"mappings":"AAEA;;;;;GAMA,OAAO,SAASA,iBAAiBC,KAAW,EAAEC,MAAa,EAAQ;EACjE,IAAI,CAACD,KAAA,EAAO;IACV;EACF;EAEA,MAAME,YAAA,GAAeF,KAAA;EAErB,IAAI,CAACE,YAAA,CAAaC,QAAQ,EAAE;IAC1BD,YAAA,CAAaC,QAAQ,GAAG,CAAC;EAC3B;EAEAD,YAAA,CAAaC,QAAQ,CAACF,MAAM,GAAGA,MAAA;AACjC"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/virtualParent/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface VirtualElement extends Node {\n _virtual: {\n parent?: Node;\n };\n}\n"]}
1
+ {"version":3,"names":[],"sources":["../../src/virtualParent/types.ts"],"sourcesContent":["export interface VirtualElement extends Node {\n _virtual: {\n parent?: Node;\n };\n}\n"],"mappings":"AAAA"}
@@ -1,8 +1,9 @@
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("./components/Portal/index"), exports);
5
+ const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
6
+ _exportStar(require("./components/Portal/index"), exports);
7
+ //# sourceMappingURL=Portal.js.map
8
+
8
9
  //# sourceMappingURL=Portal.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["tslib_1","__exportStar","require","exports"],"sources":["../src/packages/react-components/react-portal/src/Portal.ts"],"sourcesContent":["export * from './components/Portal/index';\n"],"mappings":";;;;;;AAAAA,OAAA,CAAAC,YAAA,CAAAC,OAAA,+BAAAC,OAAA"}
1
+ {"version":3,"sources":["../lib/Portal.js"],"sourcesContent":["export * from './components/Portal/index';\n//# sourceMappingURL=Portal.js.map"],"names":[],"mappings":";;;;;oBAAc;CACd,kCAAkC"}
@@ -1,19 +1,19 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "Portal", {
6
+ enumerable: true,
7
+ get: ()=>Portal
5
8
  });
6
- exports.Portal = void 0;
7
- const usePortal_1 = /*#__PURE__*/require("./usePortal");
8
- const renderPortal_1 = /*#__PURE__*/require("./renderPortal");
9
- /**
10
- * A portal provides a way to render children into a DOM node
11
- * that exists outside the DOM hierarchy of the parent component.
12
- */
13
- const Portal = props => {
14
- const state = usePortal_1.usePortal_unstable(props);
15
- return renderPortal_1.renderPortal_unstable(state);
9
+ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
+ const _usePortal = require("./usePortal");
12
+ const _renderPortal = require("./renderPortal");
13
+ const Portal = (props)=>{
14
+ const state = (0, _usePortal.usePortal_unstable)(props);
15
+ return (0, _renderPortal.renderPortal_unstable)(state);
16
16
  };
17
- exports.Portal = Portal;
18
- exports.Portal.displayName = 'Portal';
17
+ Portal.displayName = 'Portal'; //# sourceMappingURL=Portal.js.map
18
+
19
19
  //# sourceMappingURL=Portal.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["usePortal_1","require","renderPortal_1","Portal","props","state","usePortal_unstable","renderPortal_unstable","exports","displayName"],"sources":["../src/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"],"mappings":";;;;;;AAEA,MAAAA,WAAA,gBAAAC,OAAA;AACA,MAAAC,cAAA,gBAAAD,OAAA;AAGA;;;;AAIO,MAAME,MAAM,GAA0BC,KAAK,IAAG;EACnD,MAAMC,KAAK,GAAGL,WAAA,CAAAM,kBAAkB,CAACF,KAAK,CAAC;EAEvC,OAAOF,cAAA,CAAAK,qBAAqB,CAACF,KAAK,CAAC;AACrC,CAAC;AAJYG,OAAA,CAAAL,MAAM,GAAAA,MAAA;AAMnBK,OAAA,CAAAL,MAAM,CAACM,WAAW,GAAG,QAAQ"}
1
+ {"version":3,"sources":["../../../lib/components/Portal/Portal.js"],"sourcesContent":["import * as React from 'react';\nimport { usePortal_unstable } from './usePortal';\nimport { renderPortal_unstable } from './renderPortal';\n/**\n * A portal provides a way to render children into a DOM node\n * that exists outside the DOM hierarchy of the parent component.\n */\nexport const Portal = props => {\n const state = usePortal_unstable(props);\n return renderPortal_unstable(state);\n};\nPortal.displayName = 'Portal';\n//# sourceMappingURL=Portal.js.map"],"names":["Portal","props","state","usePortal_unstable","renderPortal_unstable","displayName"],"mappings":";;;;+BAOaA;;aAAAA;;;6DAPU;2BACY;8BACG;AAK/B,MAAMA,SAASC,CAAAA,QAAS;IAC7B,MAAMC,QAAQC,IAAAA,6BAAkB,EAACF;IACjC,OAAOG,IAAAA,mCAAqB,EAACF;AAC/B;AACAF,OAAOK,WAAW,GAAG,UACrB,kCAAkC"}
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
5
+ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
6
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
7
+ //# sourceMappingURL=Portal.types.js.map
8
+
6
9
  //# sourceMappingURL=Portal.types.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["../src/packages/react-components/react-portal/src/components/Portal/Portal.types.ts"],"sourcesContent":["import * as React from 'react';\n\nexport type PortalProps = {\n /**\n * React children\n */\n children?: React.ReactNode;\n\n /**\n * Where the portal children are mounted on DOM\n *\n * @default a new element on document.body without any styling\n */\n mountNode?: HTMLElement | null | { element?: HTMLElement | null; className?: string };\n};\n\nexport type PortalState = Pick<PortalProps, 'children'> & {\n mountNode: HTMLElement | null | undefined;\n\n /**\n * Ref to the root span element as virtual parent\n */\n virtualParentRootRef: React.MutableRefObject<HTMLSpanElement | null>;\n};\n"],"mappings":""}
1
+ {"version":3,"sources":["../../../lib/components/Portal/Portal.types.js"],"sourcesContent":["import * as React from 'react';\n//# sourceMappingURL=Portal.types.js.map"],"names":[],"mappings":";;;;;6DAAuB;CACvB,wCAAwC"}
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- const tslib_1 = /*#__PURE__*/require("tslib");
7
- tslib_1.__exportStar(require("./Portal"), exports);
8
- tslib_1.__exportStar(require("./Portal.types"), exports);
9
- tslib_1.__exportStar(require("./renderPortal"), exports);
10
- tslib_1.__exportStar(require("./usePortal"), exports);
5
+ const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
6
+ _exportStar(require("./Portal"), exports);
7
+ _exportStar(require("./Portal.types"), exports);
8
+ _exportStar(require("./renderPortal"), exports);
9
+ _exportStar(require("./usePortal"), exports);
10
+ //# sourceMappingURL=index.js.map
11
+
11
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["tslib_1","__exportStar","require","exports"],"sources":["../src/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"],"mappings":";;;;;;AAAAA,OAAA,CAAAC,YAAA,CAAAC,OAAA,cAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,oBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,oBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,iBAAAC,OAAA"}
1
+ {"version":3,"sources":["../../../lib/components/Portal/index.js"],"sourcesContent":["export * from './Portal';\nexport * from './Portal.types';\nexport * from './renderPortal';\nexport * from './usePortal';\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;;oBAAc;oBACA;oBACA;oBACA;CACd,iCAAiC"}
@@ -1,19 +1,19 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "renderPortal_unstable", {
6
+ enumerable: true,
7
+ get: ()=>renderPortal_unstable
5
8
  });
6
- exports.renderPortal_unstable = void 0;
7
- const ReactDOM = /*#__PURE__*/require("react-dom");
8
- const React = /*#__PURE__*/require("react");
9
- /**
10
- * Render the final JSX of Portal
11
- */
12
- const renderPortal_unstable = state => {
13
- return React.createElement("span", {
14
- hidden: true,
15
- ref: state.virtualParentRootRef
16
- }, state.mountNode && ReactDOM.createPortal(state.children, state.mountNode));
17
- };
18
- exports.renderPortal_unstable = renderPortal_unstable;
9
+ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
+ const _reactDom = /*#__PURE__*/ _interopRequireWildcard(require("react-dom"));
11
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
12
+ const renderPortal_unstable = (state)=>{
13
+ return /*#__PURE__*/ _react.createElement("span", {
14
+ hidden: true,
15
+ ref: state.virtualParentRootRef
16
+ }, state.mountNode && /*#__PURE__*/ _reactDom.createPortal(state.children, state.mountNode));
17
+ }; //# sourceMappingURL=renderPortal.js.map
18
+
19
19
  //# sourceMappingURL=renderPortal.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["ReactDOM","require","React","renderPortal_unstable","state","createElement","hidden","ref","virtualParentRootRef","mountNode","createPortal","children","exports"],"sources":["../src/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"],"mappings":";;;;;;AAAA,MAAAA,QAAA,gBAAAC,OAAA;AACA,MAAAC,KAAA,gBAAAD,OAAA;AAGA;;;AAGO,MAAME,qBAAqB,GAAIC,KAAkB,IAAwB;EAC9E,OACEF,KAAA,CAAAG,aAAA;IAAMC,MAAM;IAACC,GAAG,EAAEH,KAAK,CAACI;EAAoB,GACzCJ,KAAK,CAACK,SAAS,IAAIT,QAAQ,CAACU,YAAY,CAACN,KAAK,CAACO,QAAQ,EAAEP,KAAK,CAACK,SAAS,CAAC,CACrE;AAEX,CAAC;AANYG,OAAA,CAAAT,qBAAqB,GAAAA,qBAAA"}
1
+ {"version":3,"sources":["../../../lib/components/Portal/renderPortal.js"],"sourcesContent":["import * as ReactDOM from 'react-dom';\nimport * as React from 'react';\n/**\n * Render the final JSX of Portal\n */\nexport const renderPortal_unstable = state => {\n return /*#__PURE__*/React.createElement(\"span\", {\n hidden: true,\n ref: state.virtualParentRootRef\n }, state.mountNode && /*#__PURE__*/ReactDOM.createPortal(state.children, state.mountNode));\n};\n//# sourceMappingURL=renderPortal.js.map"],"names":["renderPortal_unstable","state","React","createElement","hidden","ref","virtualParentRootRef","mountNode","ReactDOM","createPortal","children"],"mappings":";;;;+BAKaA;;aAAAA;;;gEALa;6DACH;AAIhB,MAAMA,wBAAwBC,CAAAA,QAAS;IAC5C,OAAO,WAAW,GAAEC,OAAMC,aAAa,CAAC,QAAQ;QAC9CC,QAAQ,IAAI;QACZC,KAAKJ,MAAMK,oBAAoB;IACjC,GAAGL,MAAMM,SAAS,IAAI,WAAW,GAAEC,UAASC,YAAY,CAACR,MAAMS,QAAQ,EAAET,MAAMM,SAAS;AAC1F,GACA,wCAAwC"}
@@ -1,63 +1,64 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ toMountNodeProps: ()=>toMountNodeProps,
13
+ usePortal_unstable: ()=>usePortal_unstable
5
14
  });
6
- exports.usePortal_unstable = exports.toMountNodeProps = void 0;
7
- const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
8
- const React = /*#__PURE__*/require("react");
9
- const index_1 = /*#__PURE__*/require("../../virtualParent/index");
10
- const usePortalMountNode_1 = /*#__PURE__*/require("./usePortalMountNode");
15
+ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
16
+ const _reactUtilities = require("@fluentui/react-utilities");
17
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
18
+ const _index = require("../../virtualParent/index");
19
+ const _usePortalMountNode = require("./usePortalMountNode");
11
20
  function toMountNodeProps(mountNode) {
12
- if (react_utilities_1.isHTMLElement(mountNode)) {
13
- return {
14
- element: mountNode
15
- };
16
- }
17
- if (typeof mountNode === 'object') {
18
- if (mountNode === null) {
19
- return {
20
- element: null
21
- };
21
+ if ((0, _reactUtilities.isHTMLElement)(mountNode)) {
22
+ return {
23
+ element: mountNode
24
+ };
22
25
  }
23
- return mountNode;
24
- }
25
- return {};
26
- }
27
- exports.toMountNodeProps = toMountNodeProps;
28
- /**
29
- * Create the state required to render Portal.
30
- *
31
- * The returned state can be modified with hooks such as usePortalStyles, before being passed to renderPortal_unstable.
32
- *
33
- * @param props - props from this instance of Portal
34
- */
35
- const usePortal_unstable = props => {
36
- const {
37
- element,
38
- className
39
- } = toMountNodeProps(props.mountNode);
40
- const virtualParentRootRef = React.useRef(null);
41
- const fallbackElement = usePortalMountNode_1.usePortalMountNode({
42
- disabled: !!element,
43
- className
44
- });
45
- const state = {
46
- children: props.children,
47
- mountNode: element !== null && element !== void 0 ? element : fallbackElement,
48
- virtualParentRootRef
49
- };
50
- React.useEffect(() => {
51
- if (state.virtualParentRootRef.current && state.mountNode) {
52
- index_1.setVirtualParent(state.mountNode, state.virtualParentRootRef.current);
26
+ if (typeof mountNode === 'object') {
27
+ if (mountNode === null) {
28
+ return {
29
+ element: null
30
+ };
31
+ }
32
+ return mountNode;
53
33
  }
54
- return () => {
55
- if (state.mountNode) {
56
- index_1.setVirtualParent(state.mountNode, undefined);
57
- }
34
+ return {};
35
+ }
36
+ const usePortal_unstable = (props)=>{
37
+ const { element , className } = toMountNodeProps(props.mountNode);
38
+ const virtualParentRootRef = _react.useRef(null);
39
+ const fallbackElement = (0, _usePortalMountNode.usePortalMountNode)({
40
+ disabled: !!element,
41
+ className
42
+ });
43
+ const state = {
44
+ children: props.children,
45
+ mountNode: element !== null && element !== void 0 ? element : fallbackElement,
46
+ virtualParentRootRef
58
47
  };
59
- }, [state.virtualParentRootRef, state.mountNode]);
60
- return state;
61
- };
62
- exports.usePortal_unstable = usePortal_unstable;
48
+ _react.useEffect(()=>{
49
+ if (state.virtualParentRootRef.current && state.mountNode) {
50
+ (0, _index.setVirtualParent)(state.mountNode, state.virtualParentRootRef.current);
51
+ }
52
+ return ()=>{
53
+ if (state.mountNode) {
54
+ (0, _index.setVirtualParent)(state.mountNode, undefined);
55
+ }
56
+ };
57
+ }, [
58
+ state.virtualParentRootRef,
59
+ state.mountNode
60
+ ]);
61
+ return state;
62
+ }; //# sourceMappingURL=usePortal.js.map
63
+
63
64
  //# sourceMappingURL=usePortal.js.map