@fluentui/react-portal 9.0.9 → 9.0.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. package/CHANGELOG.json +69 -1
  2. package/CHANGELOG.md +25 -2
  3. package/lib/Portal.js.map +1 -1
  4. package/lib/components/Portal/Portal.js.map +1 -1
  5. package/lib/components/Portal/Portal.types.js.map +1 -1
  6. package/lib/components/Portal/index.js.map +1 -1
  7. package/lib/components/Portal/renderPortal.js.map +1 -1
  8. package/lib/components/Portal/usePortal.js.map +1 -1
  9. package/lib/components/Portal/usePortalMountNode.js.map +1 -1
  10. package/lib/index.js.map +1 -1
  11. package/lib/virtualParent/elementContains.js.map +1 -1
  12. package/lib/virtualParent/getParent.js.map +1 -1
  13. package/lib/virtualParent/getVirtualParent.js.map +1 -1
  14. package/lib/virtualParent/index.js.map +1 -1
  15. package/lib/virtualParent/isVirtualElement.js.map +1 -1
  16. package/lib/virtualParent/setVirtualParent.js.map +1 -1
  17. package/lib/virtualParent/types.js.map +1 -1
  18. package/lib-amd/components/Portal/Portal.js +16 -0
  19. package/lib-amd/components/Portal/Portal.js.map +1 -0
  20. package/lib-amd/components/Portal/Portal.types.js +5 -0
  21. package/lib-amd/components/Portal/Portal.types.js.map +1 -0
  22. package/lib-amd/components/Portal/index.js +9 -0
  23. package/lib-amd/components/Portal/index.js.map +1 -0
  24. package/lib-amd/components/Portal/renderPortal.js +13 -0
  25. package/lib-amd/components/Portal/renderPortal.js.map +1 -0
  26. package/lib-amd/components/Portal/usePortal.js +30 -0
  27. package/lib-amd/components/Portal/usePortal.js.map +1 -0
  28. package/lib-amd/components/Portal/usePortalMountNode.js +56 -0
  29. package/lib-amd/components/Portal/usePortalMountNode.js.map +1 -0
  30. package/lib-amd/index.js +11 -0
  31. package/lib-amd/index.js.map +1 -0
  32. package/lib-amd/virtualParent/elementContains.js +31 -0
  33. package/lib-amd/virtualParent/elementContains.js.map +1 -0
  34. package/lib-amd/virtualParent/getParent.js +14 -0
  35. package/lib-amd/virtualParent/getParent.js.map +1 -0
  36. package/lib-amd/virtualParent/getVirtualParent.js +17 -0
  37. package/lib-amd/virtualParent/getVirtualParent.js.map +1 -0
  38. package/lib-amd/virtualParent/index.js +10 -0
  39. package/lib-amd/virtualParent/index.js.map +1 -0
  40. package/lib-amd/virtualParent/isVirtualElement.js +13 -0
  41. package/lib-amd/virtualParent/isVirtualElement.js.map +1 -0
  42. package/lib-amd/virtualParent/setVirtualParent.js +23 -0
  43. package/lib-amd/virtualParent/setVirtualParent.js.map +1 -0
  44. package/lib-amd/virtualParent/types.js +5 -0
  45. package/lib-amd/virtualParent/types.js.map +1 -0
  46. package/lib-commonjs/Portal.js.map +1 -1
  47. package/lib-commonjs/components/Portal/Portal.js.map +1 -1
  48. package/lib-commonjs/components/Portal/index.js.map +1 -1
  49. package/lib-commonjs/components/Portal/renderPortal.js.map +1 -1
  50. package/lib-commonjs/components/Portal/usePortal.js.map +1 -1
  51. package/lib-commonjs/components/Portal/usePortalMountNode.js.map +1 -1
  52. package/lib-commonjs/index.js.map +1 -1
  53. package/lib-commonjs/virtualParent/elementContains.js.map +1 -1
  54. package/lib-commonjs/virtualParent/getParent.js.map +1 -1
  55. package/lib-commonjs/virtualParent/getVirtualParent.js.map +1 -1
  56. package/lib-commonjs/virtualParent/index.js.map +1 -1
  57. package/lib-commonjs/virtualParent/isVirtualElement.js.map +1 -1
  58. package/lib-commonjs/virtualParent/setVirtualParent.js.map +1 -1
  59. package/package.json +10 -10
  60. package/Spec.md +0 -254
package/CHANGELOG.json CHANGED
@@ -2,7 +2,75 @@
2
2
  "name": "@fluentui/react-portal",
3
3
  "entries": [
4
4
  {
5
- "date": "Wed, 02 Nov 2022 11:54:58 GMT",
5
+ "date": "Thu, 17 Nov 2022 23:02:40 GMT",
6
+ "tag": "@fluentui/react-portal_v9.0.11",
7
+ "version": "9.0.11",
8
+ "comments": {
9
+ "none": [
10
+ {
11
+ "author": "martinhochel@microsoft.com",
12
+ "package": "@fluentui/react-portal",
13
+ "commit": "ea768501802d65d63ddc63fff3816fb6b5008ae4",
14
+ "comment": "chore: update package scaffold"
15
+ }
16
+ ],
17
+ "patch": [
18
+ {
19
+ "author": "beachball",
20
+ "package": "@fluentui/react-portal",
21
+ "comment": "Bump @fluentui/react-tabster to v9.3.1",
22
+ "commit": "94e156be5d3b5790d82dccf08c32672733fb9335"
23
+ },
24
+ {
25
+ "author": "beachball",
26
+ "package": "@fluentui/react-portal",
27
+ "comment": "Bump @fluentui/react-utilities to v9.2.2",
28
+ "commit": "94e156be5d3b5790d82dccf08c32672733fb9335"
29
+ }
30
+ ]
31
+ }
32
+ },
33
+ {
34
+ "date": "Fri, 11 Nov 2022 14:57:31 GMT",
35
+ "tag": "@fluentui/react-portal_v9.0.10",
36
+ "version": "9.0.10",
37
+ "comments": {
38
+ "patch": [
39
+ {
40
+ "author": "martinhochel@microsoft.com",
41
+ "package": "@fluentui/react-portal",
42
+ "commit": "b3907043bd8d7b650c55e8e7c3119b14f2606c38",
43
+ "comment": "fix: create valid export maps"
44
+ },
45
+ {
46
+ "author": "tristan.watanabe@gmail.com",
47
+ "package": "@fluentui/react-portal",
48
+ "commit": "792bd72b19e360afe9ac8e9da298dc3d85776c74",
49
+ "comment": "chore: Migrate to new package structure."
50
+ },
51
+ {
52
+ "author": "beachball",
53
+ "package": "@fluentui/react-portal",
54
+ "comment": "Bump @fluentui/react-shared-contexts to v9.1.1",
55
+ "commit": "b4c9a0ae8d7444bf746f1307ab01e2dc16310720"
56
+ },
57
+ {
58
+ "author": "beachball",
59
+ "package": "@fluentui/react-portal",
60
+ "comment": "Bump @fluentui/react-tabster to v9.3.0",
61
+ "commit": "b4c9a0ae8d7444bf746f1307ab01e2dc16310720"
62
+ },
63
+ {
64
+ "author": "beachball",
65
+ "package": "@fluentui/react-portal",
66
+ "comment": "Bump @fluentui/react-utilities to v9.2.1",
67
+ "commit": "b4c9a0ae8d7444bf746f1307ab01e2dc16310720"
68
+ }
69
+ ]
70
+ }
71
+ },
72
+ {
73
+ "date": "Wed, 02 Nov 2022 11:57:57 GMT",
6
74
  "tag": "@fluentui/react-portal_v9.0.9",
7
75
  "version": "9.0.9",
8
76
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,35 @@
1
1
  # Change Log - @fluentui/react-portal
2
2
 
3
- This log was last generated on Wed, 02 Nov 2022 11:54:58 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 17 Nov 2022 23:02:40 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.0.11](https://github.com/microsoft/fluentui/tree/@fluentui/react-portal_v9.0.11)
8
+
9
+ Thu, 17 Nov 2022 23:02:40 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-portal_v9.0.10..@fluentui/react-portal_v9.0.11)
11
+
12
+ ### Patches
13
+
14
+ - Bump @fluentui/react-tabster to v9.3.1 ([PR #25683](https://github.com/microsoft/fluentui/pull/25683) by beachball)
15
+ - Bump @fluentui/react-utilities to v9.2.2 ([PR #25683](https://github.com/microsoft/fluentui/pull/25683) by beachball)
16
+
17
+ ## [9.0.10](https://github.com/microsoft/fluentui/tree/@fluentui/react-portal_v9.0.10)
18
+
19
+ Fri, 11 Nov 2022 14:57:31 GMT
20
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-portal_v9.0.9..@fluentui/react-portal_v9.0.10)
21
+
22
+ ### Patches
23
+
24
+ - fix: create valid export maps ([PR #25558](https://github.com/microsoft/fluentui/pull/25558) by martinhochel@microsoft.com)
25
+ - chore: Migrate to new package structure. ([PR #25481](https://github.com/microsoft/fluentui/pull/25481) by tristan.watanabe@gmail.com)
26
+ - Bump @fluentui/react-shared-contexts to v9.1.1 ([PR #25615](https://github.com/microsoft/fluentui/pull/25615) by beachball)
27
+ - Bump @fluentui/react-tabster to v9.3.0 ([PR #25615](https://github.com/microsoft/fluentui/pull/25615) by beachball)
28
+ - Bump @fluentui/react-utilities to v9.2.1 ([PR #25615](https://github.com/microsoft/fluentui/pull/25615) by beachball)
29
+
7
30
  ## [9.0.9](https://github.com/microsoft/fluentui/tree/@fluentui/react-portal_v9.0.9)
8
31
 
9
- Wed, 02 Nov 2022 11:54:58 GMT
32
+ Wed, 02 Nov 2022 11:57:57 GMT
10
33
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-portal_v9.0.8..@fluentui/react-portal_v9.0.9)
11
34
 
12
35
  ### Patches
package/lib/Portal.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Portal.js","sourceRoot":"../src/","sources":["Portal.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC","sourcesContent":["export * from './components/Portal/index';\n"]}
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 +1 @@
1
- {"version":3,"sources":["components/Portal/Portal.tsx"],"names":[],"mappings":"AAEA,SAAS,kBAAT,QAAmC,aAAnC;AACA,SAAS,qBAAT,QAAsC,gBAAtC;AAGA;;;AAGG;;AACH,OAAO,MAAM,MAAM,GAA0B,KAAK,IAAG;EACnD,MAAM,KAAK,GAAG,kBAAkB,CAAC,KAAD,CAAhC;EAEA,OAAO,qBAAqB,CAAC,KAAD,CAA5B;AACD,CAJM;AAMP,MAAM,CAAC,WAAP,GAAqB,QAArB","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"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-portal/src/components/Portal/Portal.tsx"],"names":[],"mappings":"AAEA,SAAS,kBAAT,QAAmC,aAAnC;AACA,SAAS,qBAAT,QAAsC,gBAAtC;AAGA;;;AAGG;;AACH,OAAO,MAAM,MAAM,GAA0B,KAAK,IAAG;EACnD,MAAM,KAAK,GAAG,kBAAkB,CAAC,KAAD,CAAhC;EAEA,OAAO,qBAAqB,CAAC,KAAD,CAA5B;AACD,CAJM;AAMP,MAAM,CAAC,WAAP,GAAqB,QAArB","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"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"file":"Portal.types.js","sourceRoot":"../src/","sources":["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;\n};\n\nexport type PortalState = Pick<PortalProps, 'children'> &\n Required<Pick<PortalProps, 'mountNode'>> & {\n /**\n * Ref to the root span element as virtual parent\n */\n virtualParentRootRef: React.MutableRefObject<HTMLSpanElement | null>;\n };\n"]}
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;\n};\n\nexport type PortalState = Pick<PortalProps, 'children'> &\n Required<Pick<PortalProps, 'mountNode'>> & {\n /**\n * Ref to the root span element as virtual parent\n */\n virtualParentRootRef: React.MutableRefObject<HTMLSpanElement | null>;\n };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["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,"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 +1 @@
1
- {"version":3,"sources":["components/Portal/renderPortal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAZ,MAA0B,WAA1B;AACA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAGA;;AAEG;;AACH,OAAO,MAAM,qBAAqB,GAAI,KAAD,IAA2C;EAC9E,oBACE,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA;IAAM,MAAM,EAAA,IAAZ;IAAa,GAAG,EAAE,KAAK,CAAC;EAAxB,CAAA,EACG,KAAK,CAAC,SAAN,iBAAmB,QAAQ,CAAC,YAAT,CAAsB,KAAK,CAAC,QAA5B,EAAsC,KAAK,CAAC,SAA5C,CADtB,CADF;AAKD,CANM","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"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-portal/src/components/Portal/renderPortal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAZ,MAA0B,WAA1B;AACA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAGA;;AAEG;;AACH,OAAO,MAAM,qBAAqB,GAAI,KAAD,IAA2C;EAC9E,oBACE,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA;IAAM,MAAM,EAAA,IAAZ;IAAa,GAAG,EAAE,KAAK,CAAC;EAAxB,CAAA,EACG,KAAK,CAAC,SAAN,iBAAmB,QAAQ,CAAC,YAAT,CAAsB,KAAK,CAAC,QAA5B,EAAsC,KAAK,CAAC,SAA5C,CADtB,CADF;AAKD,CANM","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"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["components/Portal/usePortal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,kBAAT,QAAmC,sBAAnC;AACA,SAAS,gBAAT,QAAiC,2BAAjC;AAGA;;;;;;AAMG;;AACH,OAAO,MAAM,kBAAkB,GAAI,KAAD,IAAoC;EACpE,MAAM;IAAE,QAAF;IAAY;EAAZ,IAA0B,KAAhC;EAEA,MAAM,oBAAoB,GAAG,KAAK,CAAC,MAAN,CAA8B,IAA9B,CAA7B;EACA,MAAM,iBAAiB,GAAG,kBAAkB,CAAC;IAAE,QAAQ,EAAE,CAAC,CAAC;EAAd,CAAD,CAA5C;EAEA,MAAM,KAAK,GAAgB;IACzB,QADyB;IAEzB,SAAS,EAAE,SAAS,KAAA,IAAT,IAAA,SAAS,KAAA,KAAA,CAAT,GAAA,SAAA,GAAa,iBAFC;IAGzB;EAHyB,CAA3B;EAMA,KAAK,CAAC,SAAN,CAAgB,MAAK;IACnB,IAAI,KAAK,CAAC,oBAAN,CAA2B,OAA3B,IAAsC,KAAK,CAAC,SAAhD,EAA2D;MACzD,gBAAgB,CAAC,KAAK,CAAC,SAAP,EAAkB,KAAK,CAAC,oBAAN,CAA2B,OAA7C,CAAhB;IACD;EACF,CAJD,EAIG,CAAC,KAAK,CAAC,oBAAP,EAA6B,KAAK,CAAC,SAAnC,CAJH;EAMA,OAAO,KAAP;AACD,CAnBM","sourcesContent":["import * as React from 'react';\nimport { usePortalMountNode } from './usePortalMountNode';\nimport { setVirtualParent } from '../../virtualParent/index';\nimport type { PortalProps, PortalState } from './Portal.types';\n\n/**\n * Create the state required to render Portal.\n *\n * The returned state can be modified with hooks such as usePortalStyles, before being passed to renderPortal_unstable.\n *\n * @param props - props from this instance of Portal\n */\nexport const usePortal_unstable = (props: PortalProps): PortalState => {\n const { children, mountNode } = props;\n\n const virtualParentRootRef = React.useRef<HTMLSpanElement>(null);\n const fallbackMountNode = usePortalMountNode({ disabled: !!mountNode });\n\n const state: PortalState = {\n children,\n mountNode: mountNode ?? fallbackMountNode,\n virtualParentRootRef,\n };\n\n React.useEffect(() => {\n if (state.virtualParentRootRef.current && state.mountNode) {\n setVirtualParent(state.mountNode, state.virtualParentRootRef.current);\n }\n }, [state.virtualParentRootRef, state.mountNode]);\n\n return state;\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-portal/src/components/Portal/usePortal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,kBAAT,QAAmC,sBAAnC;AACA,SAAS,gBAAT,QAAiC,2BAAjC;AAGA;;;;;;AAMG;;AACH,OAAO,MAAM,kBAAkB,GAAI,KAAD,IAAoC;EACpE,MAAM;IAAE,QAAF;IAAY;EAAZ,IAA0B,KAAhC;EAEA,MAAM,oBAAoB,GAAG,KAAK,CAAC,MAAN,CAA8B,IAA9B,CAA7B;EACA,MAAM,iBAAiB,GAAG,kBAAkB,CAAC;IAAE,QAAQ,EAAE,CAAC,CAAC;EAAd,CAAD,CAA5C;EAEA,MAAM,KAAK,GAAgB;IACzB,QADyB;IAEzB,SAAS,EAAE,SAAS,KAAA,IAAT,IAAA,SAAS,KAAA,KAAA,CAAT,GAAA,SAAA,GAAa,iBAFC;IAGzB;EAHyB,CAA3B;EAMA,KAAK,CAAC,SAAN,CAAgB,MAAK;IACnB,IAAI,KAAK,CAAC,oBAAN,CAA2B,OAA3B,IAAsC,KAAK,CAAC,SAAhD,EAA2D;MACzD,gBAAgB,CAAC,KAAK,CAAC,SAAP,EAAkB,KAAK,CAAC,oBAAN,CAA2B,OAA7C,CAAhB;IACD;EACF,CAJD,EAIG,CAAC,KAAK,CAAC,oBAAP,EAA6B,KAAK,CAAC,SAAnC,CAJH;EAMA,OAAO,KAAP;AACD,CAnBM","sourcesContent":["import * as React from 'react';\nimport { usePortalMountNode } from './usePortalMountNode';\nimport { setVirtualParent } from '../../virtualParent/index';\nimport type { PortalProps, PortalState } from './Portal.types';\n\n/**\n * Create the state required to render Portal.\n *\n * The returned state can be modified with hooks such as usePortalStyles, before being passed to renderPortal_unstable.\n *\n * @param props - props from this instance of Portal\n */\nexport const usePortal_unstable = (props: PortalProps): PortalState => {\n const { children, mountNode } = props;\n\n const virtualParentRootRef = React.useRef<HTMLSpanElement>(null);\n const fallbackMountNode = usePortalMountNode({ disabled: !!mountNode });\n\n const state: PortalState = {\n children,\n mountNode: mountNode ?? fallbackMountNode,\n virtualParentRootRef,\n };\n\n React.useEffect(() => {\n if (state.virtualParentRootRef.current && state.mountNode) {\n setVirtualParent(state.mountNode, state.virtualParentRootRef.current);\n }\n }, [state.virtualParentRootRef, state.mountNode]);\n\n return state;\n};\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["components/Portal/usePortalMountNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SACE,0BAA0B,IAAI,iBADhC,EAEE,kBAAkB,IAAI,SAFxB,QAGO,iCAHP;AAIA,mBAAqB,YAArB,QAAyC,gBAAzC;AACA,SAAS,eAAT,QAAgC,yBAAhC;;AASA,MAAM,SAAS,gBAAG;EAAA;IAAA;IAAA;EAAA;AAAA;EAAA;AAAA,EAAlB;AAOA;;AAEG;;;AACH,OAAO,MAAM,kBAAkB,GAAI,OAAD,IAA2D;EAC3F,MAAM;IAAE,cAAF;IAAkB;EAAlB,IAA0B,SAAS,EAAzC;EACA,MAAM,eAAe,GAAG,eAAe,EAAvC;EAEA,MAAM,OAAO,GAAG,SAAS,EAAzB;EACA,MAAM,cAAc,GAAG,iBAAiB,EAAxC;EAEA,MAAM,SAAS,GAAG,YAAY,CAAC,cAAD,EAAiB,OAAO,CAAC,IAAzB,CAA9B;EAEA,MAAM,OAAO,GAAG,KAAK,CAAC,OAAN,CAAc,MAAK;IACjC,IAAI,cAAc,KAAK,SAAnB,IAAgC,OAAO,CAAC,QAA5C,EAAsD;MACpD,OAAO,IAAP;IACD;;IAED,MAAM,UAAU,GAAG,cAAc,CAAC,aAAf,CAA6B,KAA7B,CAAnB;IACA,cAAc,CAAC,IAAf,CAAoB,WAApB,CAAgC,UAAhC;IAEA,OAAO,UAAP;EACD,CATe,EASb,CAAC,cAAD,EAAiB,OAAO,CAAC,QAAzB,CATa,CAAhB,CAT2F,CAoB3F;EACA;EACA;EACA;;EACA,KAAK,CAAC,OAAN,CAAc,MAAK;IACjB,IAAI,OAAJ,EAAa;MACX,MAAM,cAAc,GAAG,SAAS,CAAC,KAAV,CAAgB,GAAhB,EAAqB,MAArB,CAA4B,OAA5B,CAAvB;MAEA,OAAO,CAAC,SAAR,CAAkB,GAAlB,CAAsB,GAAG,cAAzB;MACA,OAAO,CAAC,YAAR,CAAqB,KAArB,EAA4B,GAA5B;MACA,eAAe,CAAC,OAAhB,GAA0B,OAA1B;MAEA,OAAO,MAAK;QACV,OAAO,CAAC,SAAR,CAAkB,MAAlB,CAAyB,GAAG,cAA5B;QACA,OAAO,CAAC,eAAR,CAAwB,KAAxB;MACD,CAHD;IAID;EACF,CAbD,EAaG,CAAC,SAAD,EAAY,GAAZ,EAAiB,OAAjB,EAA0B,eAA1B,CAbH;EAeA,KAAK,CAAC,SAAN,CAAgB,MAAK;IACnB,OAAO,MAAK;;;MACV,CAAA,EAAA,GAAA,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,aAAT,MAAsB,IAAtB,IAAsB,EAAA,KAAA,KAAA,CAAtB,GAAsB,KAAA,CAAtB,GAAsB,EAAA,CAAE,WAAF,CAAc,OAAd,CAAtB;IACD,CAFD;EAGD,CAJD,EAIG,CAAC,OAAD,CAJH;EAMA,OAAO,OAAP;AACD,CA9CM","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';\n\nexport type UsePortalMountNodeOptions = {\n /**\n * Since hooks cannot be called conditionally use this flag to disable creating the node\n */\n disabled?: boolean;\n};\n\nconst useStyles = makeStyles({\n root: {\n position: 'relative',\n zIndex: 1000000,\n },\n});\n\n/**\n * Creates a new element on a document.body to mount portals\n */\nexport const usePortalMountNode = (options: UsePortalMountNodeOptions): HTMLElement | null => {\n const { targetDocument, dir } = useFluent();\n const focusVisibleRef = useFocusVisible<HTMLDivElement>() as React.MutableRefObject<HTMLElement | null>;\n\n const classes = useStyles();\n const themeClassName = useThemeClassName();\n\n const className = mergeClasses(themeClassName, classes.root);\n\n const element = React.useMemo(() => {\n if (targetDocument === undefined || options.disabled) {\n return null;\n }\n\n const newElement = targetDocument.createElement('div');\n targetDocument.body.appendChild(newElement);\n\n return newElement;\n }, [targetDocument, options.disabled]);\n\n // This useMemo call is intentional\n // We don't want to re-create the portal element when its attributes change.\n // This also should not be done in an effect because, changing the value of css variables\n // after initial mount can trigger interesting CSS side effects like transitions.\n React.useMemo(() => {\n if (element) {\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 }\n }, [className, dir, element, focusVisibleRef]);\n\n React.useEffect(() => {\n return () => {\n element?.parentElement?.removeChild(element);\n };\n }, [element]);\n\n return element;\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-portal/src/components/Portal/usePortalMountNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SACE,0BAA0B,IAAI,iBADhC,EAEE,kBAAkB,IAAI,SAFxB,QAGO,iCAHP;AAIA,mBAAqB,YAArB,QAAyC,gBAAzC;AACA,SAAS,eAAT,QAAgC,yBAAhC;;AASA,MAAM,SAAS,gBAAG;EAAA;IAAA;IAAA;EAAA;AAAA;EAAA;AAAA,EAAlB;AAOA;;AAEG;;;AACH,OAAO,MAAM,kBAAkB,GAAI,OAAD,IAA2D;EAC3F,MAAM;IAAE,cAAF;IAAkB;EAAlB,IAA0B,SAAS,EAAzC;EACA,MAAM,eAAe,GAAG,eAAe,EAAvC;EAEA,MAAM,OAAO,GAAG,SAAS,EAAzB;EACA,MAAM,cAAc,GAAG,iBAAiB,EAAxC;EAEA,MAAM,SAAS,GAAG,YAAY,CAAC,cAAD,EAAiB,OAAO,CAAC,IAAzB,CAA9B;EAEA,MAAM,OAAO,GAAG,KAAK,CAAC,OAAN,CAAc,MAAK;IACjC,IAAI,cAAc,KAAK,SAAnB,IAAgC,OAAO,CAAC,QAA5C,EAAsD;MACpD,OAAO,IAAP;IACD;;IAED,MAAM,UAAU,GAAG,cAAc,CAAC,aAAf,CAA6B,KAA7B,CAAnB;IACA,cAAc,CAAC,IAAf,CAAoB,WAApB,CAAgC,UAAhC;IAEA,OAAO,UAAP;EACD,CATe,EASb,CAAC,cAAD,EAAiB,OAAO,CAAC,QAAzB,CATa,CAAhB,CAT2F,CAoB3F;EACA;EACA;EACA;;EACA,KAAK,CAAC,OAAN,CAAc,MAAK;IACjB,IAAI,OAAJ,EAAa;MACX,MAAM,cAAc,GAAG,SAAS,CAAC,KAAV,CAAgB,GAAhB,EAAqB,MAArB,CAA4B,OAA5B,CAAvB;MAEA,OAAO,CAAC,SAAR,CAAkB,GAAlB,CAAsB,GAAG,cAAzB;MACA,OAAO,CAAC,YAAR,CAAqB,KAArB,EAA4B,GAA5B;MACA,eAAe,CAAC,OAAhB,GAA0B,OAA1B;MAEA,OAAO,MAAK;QACV,OAAO,CAAC,SAAR,CAAkB,MAAlB,CAAyB,GAAG,cAA5B;QACA,OAAO,CAAC,eAAR,CAAwB,KAAxB;MACD,CAHD;IAID;EACF,CAbD,EAaG,CAAC,SAAD,EAAY,GAAZ,EAAiB,OAAjB,EAA0B,eAA1B,CAbH;EAeA,KAAK,CAAC,SAAN,CAAgB,MAAK;IACnB,OAAO,MAAK;;;MACV,CAAA,EAAA,GAAA,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,aAAT,MAAsB,IAAtB,IAAsB,EAAA,KAAA,KAAA,CAAtB,GAAsB,KAAA,CAAtB,GAAsB,EAAA,CAAE,WAAF,CAAc,OAAd,CAAtB;IACD,CAFD;EAGD,CAJD,EAIG,CAAC,OAAD,CAJH;EAMA,OAAO,OAAP;AACD,CA9CM","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';\n\nexport type UsePortalMountNodeOptions = {\n /**\n * Since hooks cannot be called conditionally use this flag to disable creating the node\n */\n disabled?: boolean;\n};\n\nconst useStyles = makeStyles({\n root: {\n position: 'relative',\n zIndex: 1000000,\n },\n});\n\n/**\n * Creates a new element on a document.body to mount portals\n */\nexport const usePortalMountNode = (options: UsePortalMountNodeOptions): HTMLElement | null => {\n const { targetDocument, dir } = useFluent();\n const focusVisibleRef = useFocusVisible<HTMLDivElement>() as React.MutableRefObject<HTMLElement | null>;\n\n const classes = useStyles();\n const themeClassName = useThemeClassName();\n\n const className = mergeClasses(themeClassName, classes.root);\n\n const element = React.useMemo(() => {\n if (targetDocument === undefined || options.disabled) {\n return null;\n }\n\n const newElement = targetDocument.createElement('div');\n targetDocument.body.appendChild(newElement);\n\n return newElement;\n }, [targetDocument, options.disabled]);\n\n // This useMemo call is intentional\n // We don't want to re-create the portal element when its attributes change.\n // This also should not be done in an effect because, changing the value of css variables\n // after initial mount can trigger interesting CSS side effects like transitions.\n React.useMemo(() => {\n if (element) {\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 }\n }, [className, dir, element, focusVisibleRef]);\n\n React.useEffect(() => {\n return () => {\n element?.parentElement?.removeChild(element);\n };\n }, [element]);\n\n return element;\n};\n"],"sourceRoot":"../src/"}
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["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,"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 +1 @@
1
- {"version":3,"sources":["virtualParent/elementContains.ts"],"names":[],"mappings":"AAAA,SAAS,SAAT,QAA0B,aAA1B;AACA;;;;;AAKG;;AACH,OAAM,SAAU,eAAV,CAA0B,MAA1B,EAAsD,KAAtD,EAA+E;EACnF,IAAI,CAAC,MAAD,IAAW,CAAC,KAAhB,EAAuB;IACrB,OAAO,KAAP;EACD;;EAED,IAAI,MAAM,KAAK,KAAf,EAAsB;IACpB,OAAO,IAAP;EACD,CAFD,MAEO;IACL,OAAO,KAAP,EAAc;MACZ,MAAM,UAAU,GAAuB,SAAS,CAAC,KAAD,CAAhD;;MAEA,IAAI,UAAU,KAAK,MAAnB,EAA2B;QACzB,OAAO,IAAP;MACD;;MAED,KAAK,GAAG,UAAR;IACD;EACF;;EAED,OAAO,KAAP;AACD","sourcesContent":["import { getParent } from './getParent';\n/**\n * Similar functionality to `element.contains` DOM API for use with out of order DOM elements that\n * checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent\n *\n * @returns true if the child can find the parent in its virtual hierarchy\n */\nexport function elementContains(parent: HTMLElement | null, child: HTMLElement | null): boolean {\n if (!parent || !child) {\n return false;\n }\n\n if (parent === child) {\n return true;\n } else {\n while (child) {\n const nextParent: HTMLElement | null = getParent(child);\n\n if (nextParent === parent) {\n return true;\n }\n\n child = nextParent;\n }\n }\n\n return false;\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-portal/src/virtualParent/elementContains.ts"],"names":[],"mappings":"AAAA,SAAS,SAAT,QAA0B,aAA1B;AACA;;;;;AAKG;;AACH,OAAM,SAAU,eAAV,CAA0B,MAA1B,EAAsD,KAAtD,EAA+E;EACnF,IAAI,CAAC,MAAD,IAAW,CAAC,KAAhB,EAAuB;IACrB,OAAO,KAAP;EACD;;EAED,IAAI,MAAM,KAAK,KAAf,EAAsB;IACpB,OAAO,IAAP;EACD,CAFD,MAEO;IACL,OAAO,KAAP,EAAc;MACZ,MAAM,UAAU,GAAuB,SAAS,CAAC,KAAD,CAAhD;;MAEA,IAAI,UAAU,KAAK,MAAnB,EAA2B;QACzB,OAAO,IAAP;MACD;;MAED,KAAK,GAAG,UAAR;IACD;EACF;;EAED,OAAO,KAAP;AACD","sourcesContent":["import { getParent } from './getParent';\n/**\n * Similar functionality to `element.contains` DOM API for use with out of order DOM elements that\n * checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent\n *\n * @returns true if the child can find the parent in its virtual hierarchy\n */\nexport function elementContains(parent: HTMLElement | null, child: HTMLElement | null): boolean {\n if (!parent || !child) {\n return false;\n }\n\n if (parent === child) {\n return true;\n } else {\n while (child) {\n const nextParent: HTMLElement | null = getParent(child);\n\n if (nextParent === parent) {\n return true;\n }\n\n child = nextParent;\n }\n }\n\n return false;\n}\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["virtualParent/getParent.ts"],"names":[],"mappings":"AAAA,SAAS,gBAAT,QAAiC,oBAAjC;AAEA;;;AAGG;;AACH,OAAM,SAAU,SAAV,CAAoB,KAApB,EAA6C;EACjD,OAAQ,KAAK,IAAI,gBAAgB,CAAC,KAAD,CAA1B,KAAuC,KAAK,KAAA,IAAL,IAAA,KAAK,KAAA,KAAA,CAAL,GAAK,KAAA,CAAL,GAAA,KAAK,CAAE,UAA9C,CAAP;AACD","sourcesContent":["import { getVirtualParent } from './getVirtualParent';\n\n/**\n * Gets the element which is the parent of a given element.\n * This method prefers the virtual parent over real DOM parent when present.\n */\nexport function getParent(child: HTMLElement | null): HTMLElement | null {\n return (child && getVirtualParent(child)) || (child?.parentNode as HTMLElement | null);\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-portal/src/virtualParent/getParent.ts"],"names":[],"mappings":"AAAA,SAAS,gBAAT,QAAiC,oBAAjC;AAEA;;;AAGG;;AACH,OAAM,SAAU,SAAV,CAAoB,KAApB,EAA6C;EACjD,OAAQ,KAAK,IAAI,gBAAgB,CAAC,KAAD,CAA1B,KAAuC,KAAK,KAAA,IAAL,IAAA,KAAK,KAAA,KAAA,CAAL,GAAK,KAAA,CAAL,GAAA,KAAK,CAAE,UAA9C,CAAP;AACD","sourcesContent":["import { getVirtualParent } from './getVirtualParent';\n\n/**\n * Gets the element which is the parent of a given element.\n * This method prefers the virtual parent over real DOM parent when present.\n */\nexport function getParent(child: HTMLElement | null): HTMLElement | null {\n return (child && getVirtualParent(child)) || (child?.parentNode as HTMLElement | null);\n}\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["virtualParent/getVirtualParent.ts"],"names":[],"mappings":"AAAA,SAAS,gBAAT,QAAiC,oBAAjC;AACA;;AAEG;;AACH,OAAM,SAAU,gBAAV,CAA2B,KAA3B,EAA6C;EACjD,IAAI,MAAJ;;EACA,IAAI,gBAAgB,CAAC,KAAD,CAApB,EAA6B;IAC3B,MAAM,GAAG,KAAK,CAAC,QAAN,CAAe,MAAxB;EACD;;EACD,OAAO,MAAP;AACD","sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n/**\n * Gets the virtual parent given the child element, if it exists.\n */\nexport function getVirtualParent(child: HTMLElement): HTMLElement | undefined {\n let parent: HTMLElement | undefined;\n if (isVirtualElement(child)) {\n parent = child._virtual.parent;\n }\n return parent;\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-portal/src/virtualParent/getVirtualParent.ts"],"names":[],"mappings":"AAAA,SAAS,gBAAT,QAAiC,oBAAjC;AACA;;AAEG;;AACH,OAAM,SAAU,gBAAV,CAA2B,KAA3B,EAA6C;EACjD,IAAI,MAAJ;;EACA,IAAI,gBAAgB,CAAC,KAAD,CAApB,EAA6B;IAC3B,MAAM,GAAG,KAAK,CAAC,QAAN,CAAe,MAAxB;EACD;;EACD,OAAO,MAAP;AACD","sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n/**\n * Gets the virtual parent given the child element, if it exists.\n */\nexport function getVirtualParent(child: HTMLElement): HTMLElement | undefined {\n let parent: HTMLElement | undefined;\n if (isVirtualElement(child)) {\n parent = child._virtual.parent;\n }\n return parent;\n}\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["virtualParent/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from './elementContains';\nexport * from './getParent';\nexport * from './getVirtualParent';\nexport * from './isVirtualElement';\nexport * from './setVirtualParent';\n"]}
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,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from './elementContains';\nexport * from './getParent';\nexport * from './getVirtualParent';\nexport * from './isVirtualElement';\nexport * from './setVirtualParent';\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["virtualParent/isVirtualElement.ts"],"names":[],"mappings":"AAEA;;AAEG;AACH,OAAM,SAAU,gBAAV,CAA2B,OAA3B,EAAgE;EACpE,OAAO,OAAO,IAAI,CAAC,CAAkB,OAAQ,CAAC,QAA9C;AACD","sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Determines whether or not an element has the virtual hierarchy extension.\n */\nexport function isVirtualElement(element: HTMLElement | VirtualElement): element is VirtualElement {\n return element && !!(<VirtualElement>element)._virtual;\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-portal/src/virtualParent/isVirtualElement.ts"],"names":[],"mappings":"AAEA;;AAEG;AACH,OAAM,SAAU,gBAAV,CAA2B,OAA3B,EAAgE;EACpE,OAAO,OAAO,IAAI,CAAC,CAAkB,OAAQ,CAAC,QAA9C;AACD","sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Determines whether or not an element has the virtual hierarchy extension.\n */\nexport function isVirtualElement(element: HTMLElement | VirtualElement): element is VirtualElement {\n return element && !!(<VirtualElement>element)._virtual;\n}\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["virtualParent/setVirtualParent.ts"],"names":[],"mappings":"AAEA;;;;;AAKG;AACH,OAAM,SAAU,gBAAV,CAA2B,KAA3B,EAA+C,MAA/C,EAAmE;EACvE,IAAI,CAAC,KAAL,EAAY;IACV;EACD;;EAED,MAAM,YAAY,GAAmB,KAArC;;EAEA,IAAI,CAAC,YAAY,CAAC,QAAlB,EAA4B;IAC1B,YAAY,CAAC,QAAb,GAAwB,EAAxB;EACD;;EAED,YAAY,CAAC,QAAb,CAAsB,MAAtB,GAA+B,MAAM,IAAI,SAAzC;AACD","sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Sets the virtual parent of an element.\n *\n * @param child - Theme element to set the virtual parent\n * @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship\n */\nexport function setVirtualParent(child: HTMLElement, parent?: HTMLElement): void {\n if (!child) {\n return;\n }\n\n const virtualChild = <VirtualElement>child;\n\n if (!virtualChild._virtual) {\n virtualChild._virtual = {};\n }\n\n virtualChild._virtual.parent = parent || undefined;\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-portal/src/virtualParent/setVirtualParent.ts"],"names":[],"mappings":"AAEA;;;;;AAKG;AACH,OAAM,SAAU,gBAAV,CAA2B,KAA3B,EAA+C,MAA/C,EAAmE;EACvE,IAAI,CAAC,KAAL,EAAY;IACV;EACD;;EAED,MAAM,YAAY,GAAmB,KAArC;;EAEA,IAAI,CAAC,YAAY,CAAC,QAAlB,EAA4B;IAC1B,YAAY,CAAC,QAAb,GAAwB,EAAxB;EACD;;EAED,YAAY,CAAC,QAAb,CAAsB,MAAtB,GAA+B,MAAM,IAAI,SAAzC;AACD","sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Sets the virtual parent of an element.\n *\n * @param child - Theme element to set the virtual parent\n * @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship\n */\nexport function setVirtualParent(child: HTMLElement, parent?: HTMLElement): void {\n if (!child) {\n return;\n }\n\n const virtualChild = <VirtualElement>child;\n\n if (!virtualChild._virtual) {\n virtualChild._virtual = {};\n }\n\n virtualChild._virtual.parent = parent || undefined;\n}\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"../src/","sources":["virtualParent/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface VirtualElement extends HTMLElement {\n _virtual: {\n parent?: HTMLElement;\n };\n}\n"]}
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 HTMLElement {\n _virtual: {\n parent?: HTMLElement;\n };\n}\n"]}
@@ -0,0 +1,16 @@
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
@@ -0,0 +1 @@
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"]}
@@ -0,0 +1,5 @@
1
+ define(["require", "exports"], function (require, exports) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ });
5
+ //# sourceMappingURL=Portal.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Portal.types.js","sourceRoot":"","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;\n};\n\nexport type PortalState = Pick<PortalProps, 'children'> &\n Required<Pick<PortalProps, 'mountNode'>> & {\n /**\n * Ref to the root span element as virtual parent\n */\n virtualParentRootRef: React.MutableRefObject<HTMLSpanElement | null>;\n };\n"]}
@@ -0,0 +1,9 @@
1
+ define(["require", "exports", "tslib", "./Portal", "./Portal.types", "./renderPortal", "./usePortal"], function (require, exports, tslib_1, Portal_1, Portal_types_1, renderPortal_1, usePortal_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(Portal_1, exports);
5
+ tslib_1.__exportStar(Portal_types_1, exports);
6
+ tslib_1.__exportStar(renderPortal_1, exports);
7
+ tslib_1.__exportStar(usePortal_1, exports);
8
+ });
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-portal/src/components/Portal/index.ts"],"names":[],"mappings":";;;IAAA,wCAAyB;IACzB,8CAA+B;IAC/B,8CAA+B;IAC/B,2CAA4B","sourcesContent":["export * from './Portal';\nexport * from './Portal.types';\nexport * from './renderPortal';\nexport * from './usePortal';\n"]}
@@ -0,0 +1,13 @@
1
+ define(["require", "exports", "react-dom", "react"], function (require, exports, ReactDOM, React) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.renderPortal_unstable = void 0;
5
+ /**
6
+ * Render the final JSX of Portal
7
+ */
8
+ var renderPortal_unstable = function (state) {
9
+ return (React.createElement("span", { hidden: true, ref: state.virtualParentRootRef }, state.mountNode && ReactDOM.createPortal(state.children, state.mountNode)));
10
+ };
11
+ exports.renderPortal_unstable = renderPortal_unstable;
12
+ });
13
+ //# sourceMappingURL=renderPortal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderPortal.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-portal/src/components/Portal/renderPortal.tsx"],"names":[],"mappings":";;;;IAIA;;OAEG;IACI,IAAM,qBAAqB,GAAG,UAAC,KAAkB;QACtD,OAAO,CACL,8BAAM,MAAM,QAAC,GAAG,EAAE,KAAK,CAAC,oBAAoB,IACzC,KAAK,CAAC,SAAS,IAAI,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,CACrE,CACR,CAAC;IACJ,CAAC,CAAC;IANW,QAAA,qBAAqB,yBAMhC","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"]}
@@ -0,0 +1,30 @@
1
+ define(["require", "exports", "react", "./usePortalMountNode", "../../virtualParent/index"], function (require, exports, React, usePortalMountNode_1, index_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.usePortal_unstable = void 0;
5
+ /**
6
+ * Create the state required to render Portal.
7
+ *
8
+ * The returned state can be modified with hooks such as usePortalStyles, before being passed to renderPortal_unstable.
9
+ *
10
+ * @param props - props from this instance of Portal
11
+ */
12
+ var usePortal_unstable = function (props) {
13
+ var children = props.children, mountNode = props.mountNode;
14
+ var virtualParentRootRef = React.useRef(null);
15
+ var fallbackMountNode = usePortalMountNode_1.usePortalMountNode({ disabled: !!mountNode });
16
+ var state = {
17
+ children: children,
18
+ mountNode: mountNode !== null && mountNode !== void 0 ? mountNode : fallbackMountNode,
19
+ virtualParentRootRef: virtualParentRootRef,
20
+ };
21
+ React.useEffect(function () {
22
+ if (state.virtualParentRootRef.current && state.mountNode) {
23
+ index_1.setVirtualParent(state.mountNode, state.virtualParentRootRef.current);
24
+ }
25
+ }, [state.virtualParentRootRef, state.mountNode]);
26
+ return state;
27
+ };
28
+ exports.usePortal_unstable = usePortal_unstable;
29
+ });
30
+ //# sourceMappingURL=usePortal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePortal.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-portal/src/components/Portal/usePortal.ts"],"names":[],"mappings":";;;;IAKA;;;;;;OAMG;IACI,IAAM,kBAAkB,GAAG,UAAC,KAAkB;QAC3C,IAAA,QAAQ,GAAgB,KAAK,SAArB,EAAE,SAAS,GAAK,KAAK,UAAV,CAAW;QAEtC,IAAM,oBAAoB,GAAG,KAAK,CAAC,MAAM,CAAkB,IAAI,CAAC,CAAC;QACjE,IAAM,iBAAiB,GAAG,uCAAkB,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;QAExE,IAAM,KAAK,GAAgB;YACzB,QAAQ,UAAA;YACR,SAAS,EAAE,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,iBAAiB;YACzC,oBAAoB,sBAAA;SACrB,CAAC;QAEF,KAAK,CAAC,SAAS,CAAC;YACd,IAAI,KAAK,CAAC,oBAAoB,CAAC,OAAO,IAAI,KAAK,CAAC,SAAS,EAAE;gBACzD,wBAAgB,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;aACvE;QACH,CAAC,EAAE,CAAC,KAAK,CAAC,oBAAoB,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;QAElD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IAnBW,QAAA,kBAAkB,sBAmB7B","sourcesContent":["import * as React from 'react';\nimport { usePortalMountNode } from './usePortalMountNode';\nimport { setVirtualParent } from '../../virtualParent/index';\nimport type { PortalProps, PortalState } from './Portal.types';\n\n/**\n * Create the state required to render Portal.\n *\n * The returned state can be modified with hooks such as usePortalStyles, before being passed to renderPortal_unstable.\n *\n * @param props - props from this instance of Portal\n */\nexport const usePortal_unstable = (props: PortalProps): PortalState => {\n const { children, mountNode } = props;\n\n const virtualParentRootRef = React.useRef<HTMLSpanElement>(null);\n const fallbackMountNode = usePortalMountNode({ disabled: !!mountNode });\n\n const state: PortalState = {\n children,\n mountNode: mountNode ?? fallbackMountNode,\n virtualParentRootRef,\n };\n\n React.useEffect(() => {\n if (state.virtualParentRootRef.current && state.mountNode) {\n setVirtualParent(state.mountNode, state.virtualParentRootRef.current);\n }\n }, [state.virtualParentRootRef, state.mountNode]);\n\n return state;\n};\n"]}
@@ -0,0 +1,56 @@
1
+ define(["require", "exports", "react", "@fluentui/react-shared-contexts", "@griffel/react", "@fluentui/react-tabster"], function (require, exports, React, react_shared_contexts_1, react_1, react_tabster_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.usePortalMountNode = void 0;
5
+ var useStyles = react_1.makeStyles({
6
+ root: {
7
+ position: 'relative',
8
+ zIndex: 1000000,
9
+ },
10
+ });
11
+ /**
12
+ * Creates a new element on a document.body to mount portals
13
+ */
14
+ var usePortalMountNode = function (options) {
15
+ var _a = react_shared_contexts_1.useFluent_unstable(), targetDocument = _a.targetDocument, dir = _a.dir;
16
+ var focusVisibleRef = react_tabster_1.useFocusVisible();
17
+ var classes = useStyles();
18
+ var themeClassName = react_shared_contexts_1.useThemeClassName_unstable();
19
+ var className = react_1.mergeClasses(themeClassName, classes.root);
20
+ var element = React.useMemo(function () {
21
+ if (targetDocument === undefined || options.disabled) {
22
+ return null;
23
+ }
24
+ var newElement = targetDocument.createElement('div');
25
+ targetDocument.body.appendChild(newElement);
26
+ return newElement;
27
+ }, [targetDocument, options.disabled]);
28
+ // This useMemo call is intentional
29
+ // We don't want to re-create the portal element when its attributes change.
30
+ // This also should not be done in an effect because, changing the value of css variables
31
+ // after initial mount can trigger interesting CSS side effects like transitions.
32
+ React.useMemo(function () {
33
+ var _a;
34
+ if (element) {
35
+ var classesToApply_1 = className.split(' ').filter(Boolean);
36
+ (_a = element.classList).add.apply(_a, classesToApply_1);
37
+ element.setAttribute('dir', dir);
38
+ focusVisibleRef.current = element;
39
+ return function () {
40
+ var _a;
41
+ (_a = element.classList).remove.apply(_a, classesToApply_1);
42
+ element.removeAttribute('dir');
43
+ };
44
+ }
45
+ }, [className, dir, element, focusVisibleRef]);
46
+ React.useEffect(function () {
47
+ return function () {
48
+ var _a;
49
+ (_a = element === null || element === void 0 ? void 0 : element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(element);
50
+ };
51
+ }, [element]);
52
+ return element;
53
+ };
54
+ exports.usePortalMountNode = usePortalMountNode;
55
+ });
56
+ //# sourceMappingURL=usePortalMountNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePortalMountNode.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-portal/src/components/Portal/usePortalMountNode.ts"],"names":[],"mappings":";;;;IAeA,IAAM,SAAS,GAAG,kBAAU,CAAC;QAC3B,IAAI,EAAE;YACJ,QAAQ,EAAE,UAAU;YACpB,MAAM,EAAE,OAAO;SAChB;KACF,CAAC,CAAC;IAEH;;OAEG;IACI,IAAM,kBAAkB,GAAG,UAAC,OAAkC;QAC7D,IAAA,KAA0B,0CAAS,EAAE,EAAnC,cAAc,oBAAA,EAAE,GAAG,SAAgB,CAAC;QAC5C,IAAM,eAAe,GAAG,+BAAe,EAAgE,CAAC;QAExG,IAAM,OAAO,GAAG,SAAS,EAAE,CAAC;QAC5B,IAAM,cAAc,GAAG,kDAAiB,EAAE,CAAC;QAE3C,IAAM,SAAS,GAAG,oBAAY,CAAC,cAAc,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QAE7D,IAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;YAC5B,IAAI,cAAc,KAAK,SAAS,IAAI,OAAO,CAAC,QAAQ,EAAE;gBACpD,OAAO,IAAI,CAAC;aACb;YAED,IAAM,UAAU,GAAG,cAAc,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YACvD,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;YAE5C,OAAO,UAAU,CAAC;QACpB,CAAC,EAAE,CAAC,cAAc,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;QAEvC,mCAAmC;QACnC,4EAA4E;QAC5E,yFAAyF;QACzF,iFAAiF;QACjF,KAAK,CAAC,OAAO,CAAC;;YACZ,IAAI,OAAO,EAAE;gBACX,IAAM,gBAAc,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;gBAE5D,CAAA,KAAA,OAAO,CAAC,SAAS,CAAA,CAAC,GAAG,WAAI,gBAAc,EAAE;gBACzC,OAAO,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;gBACjC,eAAe,CAAC,OAAO,GAAG,OAAO,CAAC;gBAElC,OAAO;;oBACL,CAAA,KAAA,OAAO,CAAC,SAAS,CAAA,CAAC,MAAM,WAAI,gBAAc,EAAE;oBAC5C,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;gBACjC,CAAC,CAAC;aACH;QACH,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC;QAE/C,KAAK,CAAC,SAAS,CAAC;YACd,OAAO;;gBACL,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,0CAAE,WAAW,CAAC,OAAO,CAAC,CAAC;YAC/C,CAAC,CAAC;QACJ,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;QAEd,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;IA9CW,QAAA,kBAAkB,sBA8C7B","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';\n\nexport type UsePortalMountNodeOptions = {\n /**\n * Since hooks cannot be called conditionally use this flag to disable creating the node\n */\n disabled?: boolean;\n};\n\nconst useStyles = makeStyles({\n root: {\n position: 'relative',\n zIndex: 1000000,\n },\n});\n\n/**\n * Creates a new element on a document.body to mount portals\n */\nexport const usePortalMountNode = (options: UsePortalMountNodeOptions): HTMLElement | null => {\n const { targetDocument, dir } = useFluent();\n const focusVisibleRef = useFocusVisible<HTMLDivElement>() as React.MutableRefObject<HTMLElement | null>;\n\n const classes = useStyles();\n const themeClassName = useThemeClassName();\n\n const className = mergeClasses(themeClassName, classes.root);\n\n const element = React.useMemo(() => {\n if (targetDocument === undefined || options.disabled) {\n return null;\n }\n\n const newElement = targetDocument.createElement('div');\n targetDocument.body.appendChild(newElement);\n\n return newElement;\n }, [targetDocument, options.disabled]);\n\n // This useMemo call is intentional\n // We don't want to re-create the portal element when its attributes change.\n // This also should not be done in an effect because, changing the value of css variables\n // after initial mount can trigger interesting CSS side effects like transitions.\n React.useMemo(() => {\n if (element) {\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 }\n }, [className, dir, element, focusVisibleRef]);\n\n React.useEffect(() => {\n return () => {\n element?.parentElement?.removeChild(element);\n };\n }, [element]);\n\n return element;\n};\n"]}
@@ -0,0 +1,11 @@
1
+ define(["require", "exports", "./components/Portal/index", "./virtualParent/index"], function (require, exports, index_1, index_2) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.setVirtualParent = exports.elementContains = exports.usePortal_unstable = exports.renderPortal_unstable = exports.Portal = void 0;
5
+ Object.defineProperty(exports, "Portal", { enumerable: true, get: function () { return index_1.Portal; } });
6
+ Object.defineProperty(exports, "renderPortal_unstable", { enumerable: true, get: function () { return index_1.renderPortal_unstable; } });
7
+ Object.defineProperty(exports, "usePortal_unstable", { enumerable: true, get: function () { return index_1.usePortal_unstable; } });
8
+ Object.defineProperty(exports, "elementContains", { enumerable: true, get: function () { return index_2.elementContains; } });
9
+ Object.defineProperty(exports, "setVirtualParent", { enumerable: true, get: function () { return index_2.setVirtualParent; } });
10
+ });
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-portal/src/index.ts"],"names":[],"mappings":";;;;IAAS,+FAAA,MAAM,OAAA;IAAE,8GAAA,qBAAqB,OAAA;IAAE,2GAAA,kBAAkB,OAAA;IAEjD,wGAAA,eAAe,OAAA;IAAE,yGAAA,gBAAgB,OAAA","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"]}
@@ -0,0 +1,31 @@
1
+ define(["require", "exports", "./getParent"], function (require, exports, getParent_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.elementContains = void 0;
5
+ /**
6
+ * Similar functionality to `element.contains` DOM API for use with out of order DOM elements that
7
+ * checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent
8
+ *
9
+ * @returns true if the child can find the parent in its virtual hierarchy
10
+ */
11
+ function elementContains(parent, child) {
12
+ if (!parent || !child) {
13
+ return false;
14
+ }
15
+ if (parent === child) {
16
+ return true;
17
+ }
18
+ else {
19
+ while (child) {
20
+ var nextParent = getParent_1.getParent(child);
21
+ if (nextParent === parent) {
22
+ return true;
23
+ }
24
+ child = nextParent;
25
+ }
26
+ }
27
+ return false;
28
+ }
29
+ exports.elementContains = elementContains;
30
+ });
31
+ //# sourceMappingURL=elementContains.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elementContains.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/elementContains.ts"],"names":[],"mappings":";;;;IACA;;;;;OAKG;IACH,SAAgB,eAAe,CAAC,MAA0B,EAAE,KAAyB;QACnF,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,EAAE;YACrB,OAAO,KAAK,CAAC;SACd;QAED,IAAI,MAAM,KAAK,KAAK,EAAE;YACpB,OAAO,IAAI,CAAC;SACb;aAAM;YACL,OAAO,KAAK,EAAE;gBACZ,IAAM,UAAU,GAAuB,qBAAS,CAAC,KAAK,CAAC,CAAC;gBAExD,IAAI,UAAU,KAAK,MAAM,EAAE;oBACzB,OAAO,IAAI,CAAC;iBACb;gBAED,KAAK,GAAG,UAAU,CAAC;aACpB;SACF;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IApBD,0CAoBC","sourcesContent":["import { getParent } from './getParent';\n/**\n * Similar functionality to `element.contains` DOM API for use with out of order DOM elements that\n * checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent\n *\n * @returns true if the child can find the parent in its virtual hierarchy\n */\nexport function elementContains(parent: HTMLElement | null, child: HTMLElement | null): boolean {\n if (!parent || !child) {\n return false;\n }\n\n if (parent === child) {\n return true;\n } else {\n while (child) {\n const nextParent: HTMLElement | null = getParent(child);\n\n if (nextParent === parent) {\n return true;\n }\n\n child = nextParent;\n }\n }\n\n return false;\n}\n"]}
@@ -0,0 +1,14 @@
1
+ define(["require", "exports", "./getVirtualParent"], function (require, exports, getVirtualParent_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.getParent = void 0;
5
+ /**
6
+ * Gets the element which is the parent of a given element.
7
+ * This method prefers the virtual parent over real DOM parent when present.
8
+ */
9
+ function getParent(child) {
10
+ return (child && getVirtualParent_1.getVirtualParent(child)) || (child === null || child === void 0 ? void 0 : child.parentNode);
11
+ }
12
+ exports.getParent = getParent;
13
+ });
14
+ //# sourceMappingURL=getParent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getParent.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/getParent.ts"],"names":[],"mappings":";;;;IAEA;;;OAGG;IACH,SAAgB,SAAS,CAAC,KAAyB;QACjD,OAAO,CAAC,KAAK,IAAI,mCAAgB,CAAC,KAAK,CAAC,CAAC,KAAK,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAiC,CAAA,CAAC;IACzF,CAAC;IAFD,8BAEC","sourcesContent":["import { getVirtualParent } from './getVirtualParent';\n\n/**\n * Gets the element which is the parent of a given element.\n * This method prefers the virtual parent over real DOM parent when present.\n */\nexport function getParent(child: HTMLElement | null): HTMLElement | null {\n return (child && getVirtualParent(child)) || (child?.parentNode as HTMLElement | null);\n}\n"]}
@@ -0,0 +1,17 @@
1
+ define(["require", "exports", "./isVirtualElement"], function (require, exports, isVirtualElement_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.getVirtualParent = void 0;
5
+ /**
6
+ * Gets the virtual parent given the child element, if it exists.
7
+ */
8
+ function getVirtualParent(child) {
9
+ var parent;
10
+ if (isVirtualElement_1.isVirtualElement(child)) {
11
+ parent = child._virtual.parent;
12
+ }
13
+ return parent;
14
+ }
15
+ exports.getVirtualParent = getVirtualParent;
16
+ });
17
+ //# sourceMappingURL=getVirtualParent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getVirtualParent.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/getVirtualParent.ts"],"names":[],"mappings":";;;;IACA;;OAEG;IACH,SAAgB,gBAAgB,CAAC,KAAkB;QACjD,IAAI,MAA+B,CAAC;QACpC,IAAI,mCAAgB,CAAC,KAAK,CAAC,EAAE;YAC3B,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;SAChC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAND,4CAMC","sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n/**\n * Gets the virtual parent given the child element, if it exists.\n */\nexport function getVirtualParent(child: HTMLElement): HTMLElement | undefined {\n let parent: HTMLElement | undefined;\n if (isVirtualElement(child)) {\n parent = child._virtual.parent;\n }\n return parent;\n}\n"]}
@@ -0,0 +1,10 @@
1
+ define(["require", "exports", "tslib", "./elementContains", "./getParent", "./getVirtualParent", "./isVirtualElement", "./setVirtualParent"], function (require, exports, tslib_1, elementContains_1, getParent_1, getVirtualParent_1, isVirtualElement_1, setVirtualParent_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(elementContains_1, exports);
5
+ tslib_1.__exportStar(getParent_1, exports);
6
+ tslib_1.__exportStar(getVirtualParent_1, exports);
7
+ tslib_1.__exportStar(isVirtualElement_1, exports);
8
+ tslib_1.__exportStar(setVirtualParent_1, exports);
9
+ });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/index.ts"],"names":[],"mappings":";;;IAAA,iDAAkC;IAClC,2CAA4B;IAC5B,kDAAmC;IACnC,kDAAmC;IACnC,kDAAmC","sourcesContent":["export * from './elementContains';\nexport * from './getParent';\nexport * from './getVirtualParent';\nexport * from './isVirtualElement';\nexport * from './setVirtualParent';\n"]}
@@ -0,0 +1,13 @@
1
+ define(["require", "exports"], function (require, exports) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.isVirtualElement = void 0;
5
+ /**
6
+ * Determines whether or not an element has the virtual hierarchy extension.
7
+ */
8
+ function isVirtualElement(element) {
9
+ return element && !!element._virtual;
10
+ }
11
+ exports.isVirtualElement = isVirtualElement;
12
+ });
13
+ //# sourceMappingURL=isVirtualElement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isVirtualElement.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/isVirtualElement.ts"],"names":[],"mappings":";;;;IAEA;;OAEG;IACH,SAAgB,gBAAgB,CAAC,OAAqC;QACpE,OAAO,OAAO,IAAI,CAAC,CAAkB,OAAQ,CAAC,QAAQ,CAAC;IACzD,CAAC;IAFD,4CAEC","sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Determines whether or not an element has the virtual hierarchy extension.\n */\nexport function isVirtualElement(element: HTMLElement | VirtualElement): element is VirtualElement {\n return element && !!(<VirtualElement>element)._virtual;\n}\n"]}
@@ -0,0 +1,23 @@
1
+ define(["require", "exports"], function (require, exports) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.setVirtualParent = void 0;
5
+ /**
6
+ * Sets the virtual parent of an element.
7
+ *
8
+ * @param child - Theme element to set the virtual parent
9
+ * @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship
10
+ */
11
+ function setVirtualParent(child, parent) {
12
+ if (!child) {
13
+ return;
14
+ }
15
+ var virtualChild = child;
16
+ if (!virtualChild._virtual) {
17
+ virtualChild._virtual = {};
18
+ }
19
+ virtualChild._virtual.parent = parent || undefined;
20
+ }
21
+ exports.setVirtualParent = setVirtualParent;
22
+ });
23
+ //# sourceMappingURL=setVirtualParent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setVirtualParent.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/setVirtualParent.ts"],"names":[],"mappings":";;;;IAEA;;;;;OAKG;IACH,SAAgB,gBAAgB,CAAC,KAAkB,EAAE,MAAoB;QACvE,IAAI,CAAC,KAAK,EAAE;YACV,OAAO;SACR;QAED,IAAM,YAAY,GAAmB,KAAK,CAAC;QAE3C,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE;YAC1B,YAAY,CAAC,QAAQ,GAAG,EAAE,CAAC;SAC5B;QAED,YAAY,CAAC,QAAQ,CAAC,MAAM,GAAG,MAAM,IAAI,SAAS,CAAC;IACrD,CAAC;IAZD,4CAYC","sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Sets the virtual parent of an element.\n *\n * @param child - Theme element to set the virtual parent\n * @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship\n */\nexport function setVirtualParent(child: HTMLElement, parent?: HTMLElement): void {\n if (!child) {\n return;\n }\n\n const virtualChild = <VirtualElement>child;\n\n if (!virtualChild._virtual) {\n virtualChild._virtual = {};\n }\n\n virtualChild._virtual.parent = parent || undefined;\n}\n"]}
@@ -0,0 +1,5 @@
1
+ define(["require", "exports"], function (require, exports) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ });
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface VirtualElement extends HTMLElement {\n _virtual: {\n parent?: HTMLElement;\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["Portal.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,2BAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './components/Portal/index';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-portal/src/Portal.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,2BAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './components/Portal/index';\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["components/Portal/Portal.tsx"],"names":[],"mappings":";;;;;;;AAEA,MAAA,WAAA,gBAAA,OAAA,CAAA,aAAA,CAAA;;AACA,MAAA,cAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;AAGA;;;AAGG;;;AACI,MAAM,MAAM,GAA0B,KAAK,IAAG;EACnD,MAAM,KAAK,GAAG,WAAA,CAAA,kBAAA,CAAmB,KAAnB,CAAd;EAEA,OAAO,cAAA,CAAA,qBAAA,CAAsB,KAAtB,CAAP;AACD,CAJM;;AAAM,OAAA,CAAA,MAAA,GAAM,MAAN;AAMb,OAAA,CAAA,MAAA,CAAO,WAAP,GAAqB,QAArB","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"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-portal/src/components/Portal/Portal.tsx"],"names":[],"mappings":";;;;;;;AAEA,MAAA,WAAA,gBAAA,OAAA,CAAA,aAAA,CAAA;;AACA,MAAA,cAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;AAGA;;;AAGG;;;AACI,MAAM,MAAM,GAA0B,KAAK,IAAG;EACnD,MAAM,KAAK,GAAG,WAAA,CAAA,kBAAA,CAAmB,KAAnB,CAAd;EAEA,OAAO,cAAA,CAAA,qBAAA,CAAsB,KAAtB,CAAP;AACD,CAJM;;AAAM,OAAA,CAAA,MAAA,GAAM,MAAN;AAMb,OAAA,CAAA,MAAA,CAAO,WAAP,GAAqB,QAArB","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"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["components/Portal/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,UAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,gBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,gBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,aAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './Portal';\nexport * from './Portal.types';\nexport * from './renderPortal';\nexport * from './usePortal';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-portal/src/components/Portal/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,UAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,gBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,gBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,aAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './Portal';\nexport * from './Portal.types';\nexport * from './renderPortal';\nexport * from './usePortal';\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["components/Portal/renderPortal.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,QAAA,gBAAA,OAAA,CAAA,WAAA,CAAA;;AACA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;AAGA;;AAEG;;;AACI,MAAM,qBAAqB,GAAI,KAAD,IAA2C;EAC9E,OACE,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA;IAAM,MAAM,EAAA,IAAZ;IAAa,GAAG,EAAE,KAAK,CAAC;EAAxB,CAAA,EACG,KAAK,CAAC,SAAN,IAAmB,QAAQ,CAAC,YAAT,CAAsB,KAAK,CAAC,QAA5B,EAAsC,KAAK,CAAC,SAA5C,CADtB,CADF;AAKD,CANM;;AAAM,OAAA,CAAA,qBAAA,GAAqB,qBAArB","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"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-portal/src/components/Portal/renderPortal.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,QAAA,gBAAA,OAAA,CAAA,WAAA,CAAA;;AACA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;AAGA;;AAEG;;;AACI,MAAM,qBAAqB,GAAI,KAAD,IAA2C;EAC9E,OACE,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA;IAAM,MAAM,EAAA,IAAZ;IAAa,GAAG,EAAE,KAAK,CAAC;EAAxB,CAAA,EACG,KAAK,CAAC,SAAN,IAAmB,QAAQ,CAAC,YAAT,CAAsB,KAAK,CAAC,QAA5B,EAAsC,KAAK,CAAC,SAA5C,CADtB,CADF;AAKD,CANM;;AAAM,OAAA,CAAA,qBAAA,GAAqB,qBAArB","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"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["components/Portal/usePortal.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,oBAAA,gBAAA,OAAA,CAAA,sBAAA,CAAA;;AACA,MAAA,OAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAGA;;;;;;AAMG;;;AACI,MAAM,kBAAkB,GAAI,KAAD,IAAoC;EACpE,MAAM;IAAE,QAAF;IAAY;EAAZ,IAA0B,KAAhC;EAEA,MAAM,oBAAoB,GAAG,KAAK,CAAC,MAAN,CAA8B,IAA9B,CAA7B;EACA,MAAM,iBAAiB,GAAG,oBAAA,CAAA,kBAAA,CAAmB;IAAE,QAAQ,EAAE,CAAC,CAAC;EAAd,CAAnB,CAA1B;EAEA,MAAM,KAAK,GAAgB;IACzB,QADyB;IAEzB,SAAS,EAAE,SAAS,KAAA,IAAT,IAAA,SAAS,KAAA,KAAA,CAAT,GAAA,SAAA,GAAa,iBAFC;IAGzB;EAHyB,CAA3B;EAMA,KAAK,CAAC,SAAN,CAAgB,MAAK;IACnB,IAAI,KAAK,CAAC,oBAAN,CAA2B,OAA3B,IAAsC,KAAK,CAAC,SAAhD,EAA2D;MACzD,OAAA,CAAA,gBAAA,CAAiB,KAAK,CAAC,SAAvB,EAAkC,KAAK,CAAC,oBAAN,CAA2B,OAA7D;IACD;EACF,CAJD,EAIG,CAAC,KAAK,CAAC,oBAAP,EAA6B,KAAK,CAAC,SAAnC,CAJH;EAMA,OAAO,KAAP;AACD,CAnBM;;AAAM,OAAA,CAAA,kBAAA,GAAkB,kBAAlB","sourcesContent":["import * as React from 'react';\nimport { usePortalMountNode } from './usePortalMountNode';\nimport { setVirtualParent } from '../../virtualParent/index';\nimport type { PortalProps, PortalState } from './Portal.types';\n\n/**\n * Create the state required to render Portal.\n *\n * The returned state can be modified with hooks such as usePortalStyles, before being passed to renderPortal_unstable.\n *\n * @param props - props from this instance of Portal\n */\nexport const usePortal_unstable = (props: PortalProps): PortalState => {\n const { children, mountNode } = props;\n\n const virtualParentRootRef = React.useRef<HTMLSpanElement>(null);\n const fallbackMountNode = usePortalMountNode({ disabled: !!mountNode });\n\n const state: PortalState = {\n children,\n mountNode: mountNode ?? fallbackMountNode,\n virtualParentRootRef,\n };\n\n React.useEffect(() => {\n if (state.virtualParentRootRef.current && state.mountNode) {\n setVirtualParent(state.mountNode, state.virtualParentRootRef.current);\n }\n }, [state.virtualParentRootRef, state.mountNode]);\n\n return state;\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-portal/src/components/Portal/usePortal.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,oBAAA,gBAAA,OAAA,CAAA,sBAAA,CAAA;;AACA,MAAA,OAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAGA;;;;;;AAMG;;;AACI,MAAM,kBAAkB,GAAI,KAAD,IAAoC;EACpE,MAAM;IAAE,QAAF;IAAY;EAAZ,IAA0B,KAAhC;EAEA,MAAM,oBAAoB,GAAG,KAAK,CAAC,MAAN,CAA8B,IAA9B,CAA7B;EACA,MAAM,iBAAiB,GAAG,oBAAA,CAAA,kBAAA,CAAmB;IAAE,QAAQ,EAAE,CAAC,CAAC;EAAd,CAAnB,CAA1B;EAEA,MAAM,KAAK,GAAgB;IACzB,QADyB;IAEzB,SAAS,EAAE,SAAS,KAAA,IAAT,IAAA,SAAS,KAAA,KAAA,CAAT,GAAA,SAAA,GAAa,iBAFC;IAGzB;EAHyB,CAA3B;EAMA,KAAK,CAAC,SAAN,CAAgB,MAAK;IACnB,IAAI,KAAK,CAAC,oBAAN,CAA2B,OAA3B,IAAsC,KAAK,CAAC,SAAhD,EAA2D;MACzD,OAAA,CAAA,gBAAA,CAAiB,KAAK,CAAC,SAAvB,EAAkC,KAAK,CAAC,oBAAN,CAA2B,OAA7D;IACD;EACF,CAJD,EAIG,CAAC,KAAK,CAAC,oBAAP,EAA6B,KAAK,CAAC,SAAnC,CAJH;EAMA,OAAO,KAAP;AACD,CAnBM;;AAAM,OAAA,CAAA,kBAAA,GAAkB,kBAAlB","sourcesContent":["import * as React from 'react';\nimport { usePortalMountNode } from './usePortalMountNode';\nimport { setVirtualParent } from '../../virtualParent/index';\nimport type { PortalProps, PortalState } from './Portal.types';\n\n/**\n * Create the state required to render Portal.\n *\n * The returned state can be modified with hooks such as usePortalStyles, before being passed to renderPortal_unstable.\n *\n * @param props - props from this instance of Portal\n */\nexport const usePortal_unstable = (props: PortalProps): PortalState => {\n const { children, mountNode } = props;\n\n const virtualParentRootRef = React.useRef<HTMLSpanElement>(null);\n const fallbackMountNode = usePortalMountNode({ disabled: !!mountNode });\n\n const state: PortalState = {\n children,\n mountNode: mountNode ?? fallbackMountNode,\n virtualParentRootRef,\n };\n\n React.useEffect(() => {\n if (state.virtualParentRootRef.current && state.mountNode) {\n setVirtualParent(state.mountNode, state.virtualParentRootRef.current);\n }\n }, [state.virtualParentRootRef, state.mountNode]);\n\n return state;\n};\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["components/Portal/usePortalMountNode.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,uBAAA,gBAAA,OAAA,CAAA,iCAAA,CAAA;;AAIA,MAAA,OAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AACA,MAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;;AASA,MAAM,SAAS,gBAAG,OAAA,SAAA;EAAA;IAAA;IAAA;EAAA;AAAA;EAAA;AAAA,EAAlB;AAOA;;AAEG;;;AACI,MAAM,kBAAkB,GAAI,OAAD,IAA2D;EAC3F,MAAM;IAAE,cAAF;IAAkB;EAAlB,IAA0B,uBAAA,CAAA,kBAAA,EAAhC;EACA,MAAM,eAAe,GAAG,eAAA,CAAA,eAAA,EAAxB;EAEA,MAAM,OAAO,GAAG,SAAS,EAAzB;EACA,MAAM,cAAc,GAAG,uBAAA,CAAA,0BAAA,EAAvB;EAEA,MAAM,SAAS,GAAG,OAAA,CAAA,YAAA,CAAa,cAAb,EAA6B,OAAO,CAAC,IAArC,CAAlB;EAEA,MAAM,OAAO,GAAG,KAAK,CAAC,OAAN,CAAc,MAAK;IACjC,IAAI,cAAc,KAAK,SAAnB,IAAgC,OAAO,CAAC,QAA5C,EAAsD;MACpD,OAAO,IAAP;IACD;;IAED,MAAM,UAAU,GAAG,cAAc,CAAC,aAAf,CAA6B,KAA7B,CAAnB;IACA,cAAc,CAAC,IAAf,CAAoB,WAApB,CAAgC,UAAhC;IAEA,OAAO,UAAP;EACD,CATe,EASb,CAAC,cAAD,EAAiB,OAAO,CAAC,QAAzB,CATa,CAAhB,CAT2F,CAoB3F;EACA;EACA;EACA;;EACA,KAAK,CAAC,OAAN,CAAc,MAAK;IACjB,IAAI,OAAJ,EAAa;MACX,MAAM,cAAc,GAAG,SAAS,CAAC,KAAV,CAAgB,GAAhB,EAAqB,MAArB,CAA4B,OAA5B,CAAvB;MAEA,OAAO,CAAC,SAAR,CAAkB,GAAlB,CAAsB,GAAG,cAAzB;MACA,OAAO,CAAC,YAAR,CAAqB,KAArB,EAA4B,GAA5B;MACA,eAAe,CAAC,OAAhB,GAA0B,OAA1B;MAEA,OAAO,MAAK;QACV,OAAO,CAAC,SAAR,CAAkB,MAAlB,CAAyB,GAAG,cAA5B;QACA,OAAO,CAAC,eAAR,CAAwB,KAAxB;MACD,CAHD;IAID;EACF,CAbD,EAaG,CAAC,SAAD,EAAY,GAAZ,EAAiB,OAAjB,EAA0B,eAA1B,CAbH;EAeA,KAAK,CAAC,SAAN,CAAgB,MAAK;IACnB,OAAO,MAAK;;;MACV,CAAA,EAAA,GAAA,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,aAAT,MAAsB,IAAtB,IAAsB,EAAA,KAAA,KAAA,CAAtB,GAAsB,KAAA,CAAtB,GAAsB,EAAA,CAAE,WAAF,CAAc,OAAd,CAAtB;IACD,CAFD;EAGD,CAJD,EAIG,CAAC,OAAD,CAJH;EAMA,OAAO,OAAP;AACD,CA9CM;;AAAM,OAAA,CAAA,kBAAA,GAAkB,kBAAlB","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';\n\nexport type UsePortalMountNodeOptions = {\n /**\n * Since hooks cannot be called conditionally use this flag to disable creating the node\n */\n disabled?: boolean;\n};\n\nconst useStyles = makeStyles({\n root: {\n position: 'relative',\n zIndex: 1000000,\n },\n});\n\n/**\n * Creates a new element on a document.body to mount portals\n */\nexport const usePortalMountNode = (options: UsePortalMountNodeOptions): HTMLElement | null => {\n const { targetDocument, dir } = useFluent();\n const focusVisibleRef = useFocusVisible<HTMLDivElement>() as React.MutableRefObject<HTMLElement | null>;\n\n const classes = useStyles();\n const themeClassName = useThemeClassName();\n\n const className = mergeClasses(themeClassName, classes.root);\n\n const element = React.useMemo(() => {\n if (targetDocument === undefined || options.disabled) {\n return null;\n }\n\n const newElement = targetDocument.createElement('div');\n targetDocument.body.appendChild(newElement);\n\n return newElement;\n }, [targetDocument, options.disabled]);\n\n // This useMemo call is intentional\n // We don't want to re-create the portal element when its attributes change.\n // This also should not be done in an effect because, changing the value of css variables\n // after initial mount can trigger interesting CSS side effects like transitions.\n React.useMemo(() => {\n if (element) {\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 }\n }, [className, dir, element, focusVisibleRef]);\n\n React.useEffect(() => {\n return () => {\n element?.parentElement?.removeChild(element);\n };\n }, [element]);\n\n return element;\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-portal/src/components/Portal/usePortalMountNode.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,uBAAA,gBAAA,OAAA,CAAA,iCAAA,CAAA;;AAIA,MAAA,OAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AACA,MAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;;AASA,MAAM,SAAS,gBAAG,OAAA,SAAA;EAAA;IAAA;IAAA;EAAA;AAAA;EAAA;AAAA,EAAlB;AAOA;;AAEG;;;AACI,MAAM,kBAAkB,GAAI,OAAD,IAA2D;EAC3F,MAAM;IAAE,cAAF;IAAkB;EAAlB,IAA0B,uBAAA,CAAA,kBAAA,EAAhC;EACA,MAAM,eAAe,GAAG,eAAA,CAAA,eAAA,EAAxB;EAEA,MAAM,OAAO,GAAG,SAAS,EAAzB;EACA,MAAM,cAAc,GAAG,uBAAA,CAAA,0BAAA,EAAvB;EAEA,MAAM,SAAS,GAAG,OAAA,CAAA,YAAA,CAAa,cAAb,EAA6B,OAAO,CAAC,IAArC,CAAlB;EAEA,MAAM,OAAO,GAAG,KAAK,CAAC,OAAN,CAAc,MAAK;IACjC,IAAI,cAAc,KAAK,SAAnB,IAAgC,OAAO,CAAC,QAA5C,EAAsD;MACpD,OAAO,IAAP;IACD;;IAED,MAAM,UAAU,GAAG,cAAc,CAAC,aAAf,CAA6B,KAA7B,CAAnB;IACA,cAAc,CAAC,IAAf,CAAoB,WAApB,CAAgC,UAAhC;IAEA,OAAO,UAAP;EACD,CATe,EASb,CAAC,cAAD,EAAiB,OAAO,CAAC,QAAzB,CATa,CAAhB,CAT2F,CAoB3F;EACA;EACA;EACA;;EACA,KAAK,CAAC,OAAN,CAAc,MAAK;IACjB,IAAI,OAAJ,EAAa;MACX,MAAM,cAAc,GAAG,SAAS,CAAC,KAAV,CAAgB,GAAhB,EAAqB,MAArB,CAA4B,OAA5B,CAAvB;MAEA,OAAO,CAAC,SAAR,CAAkB,GAAlB,CAAsB,GAAG,cAAzB;MACA,OAAO,CAAC,YAAR,CAAqB,KAArB,EAA4B,GAA5B;MACA,eAAe,CAAC,OAAhB,GAA0B,OAA1B;MAEA,OAAO,MAAK;QACV,OAAO,CAAC,SAAR,CAAkB,MAAlB,CAAyB,GAAG,cAA5B;QACA,OAAO,CAAC,eAAR,CAAwB,KAAxB;MACD,CAHD;IAID;EACF,CAbD,EAaG,CAAC,SAAD,EAAY,GAAZ,EAAiB,OAAjB,EAA0B,eAA1B,CAbH;EAeA,KAAK,CAAC,SAAN,CAAgB,MAAK;IACnB,OAAO,MAAK;;;MACV,CAAA,EAAA,GAAA,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,aAAT,MAAsB,IAAtB,IAAsB,EAAA,KAAA,KAAA,CAAtB,GAAsB,KAAA,CAAtB,GAAsB,EAAA,CAAE,WAAF,CAAc,OAAd,CAAtB;IACD,CAFD;EAGD,CAJD,EAIG,CAAC,OAAD,CAJH;EAMA,OAAO,OAAP;AACD,CA9CM;;AAAM,OAAA,CAAA,kBAAA,GAAkB,kBAAlB","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';\n\nexport type UsePortalMountNodeOptions = {\n /**\n * Since hooks cannot be called conditionally use this flag to disable creating the node\n */\n disabled?: boolean;\n};\n\nconst useStyles = makeStyles({\n root: {\n position: 'relative',\n zIndex: 1000000,\n },\n});\n\n/**\n * Creates a new element on a document.body to mount portals\n */\nexport const usePortalMountNode = (options: UsePortalMountNodeOptions): HTMLElement | null => {\n const { targetDocument, dir } = useFluent();\n const focusVisibleRef = useFocusVisible<HTMLDivElement>() as React.MutableRefObject<HTMLElement | null>;\n\n const classes = useStyles();\n const themeClassName = useThemeClassName();\n\n const className = mergeClasses(themeClassName, classes.root);\n\n const element = React.useMemo(() => {\n if (targetDocument === undefined || options.disabled) {\n return null;\n }\n\n const newElement = targetDocument.createElement('div');\n targetDocument.body.appendChild(newElement);\n\n return newElement;\n }, [targetDocument, options.disabled]);\n\n // This useMemo call is intentional\n // We don't want to re-create the portal element when its attributes change.\n // This also should not be done in an effect because, changing the value of css variables\n // after initial mount can trigger interesting CSS side effects like transitions.\n React.useMemo(() => {\n if (element) {\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 }\n }, [className, dir, element, focusVisibleRef]);\n\n React.useEffect(() => {\n return () => {\n element?.parentElement?.removeChild(element);\n };\n }, [element]);\n\n return element;\n};\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,OAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,QAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,MAAA;EAAM;AAAN,CAAA;AAAQ,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,uBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,qBAAA;EAAqB;AAArB,CAAA;AAAuB,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,oBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,kBAAA;EAAkB;AAAlB,CAAA;;AAExC,IAAA,OAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,iBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,eAAA;EAAe;AAAf,CAAA;AAAiB,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,kBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,gBAAA;EAAgB;AAAhB,CAAA","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"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-portal/src/index.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,OAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,QAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,MAAA;EAAM;AAAN,CAAA;AAAQ,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,uBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,qBAAA;EAAqB;AAArB,CAAA;AAAuB,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,oBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,kBAAA;EAAkB;AAAlB,CAAA;;AAExC,IAAA,OAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,iBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,eAAA;EAAe;AAAf,CAAA;AAAiB,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,kBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,gBAAA;EAAgB;AAAhB,CAAA","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"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["virtualParent/elementContains.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,WAAA,gBAAA,OAAA,CAAA,aAAA,CAAA;AACA;;;;;AAKG;;;AACH,SAAgB,eAAhB,CAAgC,MAAhC,EAA4D,KAA5D,EAAqF;EACnF,IAAI,CAAC,MAAD,IAAW,CAAC,KAAhB,EAAuB;IACrB,OAAO,KAAP;EACD;;EAED,IAAI,MAAM,KAAK,KAAf,EAAsB;IACpB,OAAO,IAAP;EACD,CAFD,MAEO;IACL,OAAO,KAAP,EAAc;MACZ,MAAM,UAAU,GAAuB,WAAA,CAAA,SAAA,CAAU,KAAV,CAAvC;;MAEA,IAAI,UAAU,KAAK,MAAnB,EAA2B;QACzB,OAAO,IAAP;MACD;;MAED,KAAK,GAAG,UAAR;IACD;EACF;;EAED,OAAO,KAAP;AACD;;AApBD,OAAA,CAAA,eAAA,GAAA,eAAA","sourcesContent":["import { getParent } from './getParent';\n/**\n * Similar functionality to `element.contains` DOM API for use with out of order DOM elements that\n * checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent\n *\n * @returns true if the child can find the parent in its virtual hierarchy\n */\nexport function elementContains(parent: HTMLElement | null, child: HTMLElement | null): boolean {\n if (!parent || !child) {\n return false;\n }\n\n if (parent === child) {\n return true;\n } else {\n while (child) {\n const nextParent: HTMLElement | null = getParent(child);\n\n if (nextParent === parent) {\n return true;\n }\n\n child = nextParent;\n }\n }\n\n return false;\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-portal/src/virtualParent/elementContains.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,WAAA,gBAAA,OAAA,CAAA,aAAA,CAAA;AACA;;;;;AAKG;;;AACH,SAAgB,eAAhB,CAAgC,MAAhC,EAA4D,KAA5D,EAAqF;EACnF,IAAI,CAAC,MAAD,IAAW,CAAC,KAAhB,EAAuB;IACrB,OAAO,KAAP;EACD;;EAED,IAAI,MAAM,KAAK,KAAf,EAAsB;IACpB,OAAO,IAAP;EACD,CAFD,MAEO;IACL,OAAO,KAAP,EAAc;MACZ,MAAM,UAAU,GAAuB,WAAA,CAAA,SAAA,CAAU,KAAV,CAAvC;;MAEA,IAAI,UAAU,KAAK,MAAnB,EAA2B;QACzB,OAAO,IAAP;MACD;;MAED,KAAK,GAAG,UAAR;IACD;EACF;;EAED,OAAO,KAAP;AACD;;AApBD,OAAA,CAAA,eAAA,GAAA,eAAA","sourcesContent":["import { getParent } from './getParent';\n/**\n * Similar functionality to `element.contains` DOM API for use with out of order DOM elements that\n * checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent\n *\n * @returns true if the child can find the parent in its virtual hierarchy\n */\nexport function elementContains(parent: HTMLElement | null, child: HTMLElement | null): boolean {\n if (!parent || !child) {\n return false;\n }\n\n if (parent === child) {\n return true;\n } else {\n while (child) {\n const nextParent: HTMLElement | null = getParent(child);\n\n if (nextParent === parent) {\n return true;\n }\n\n child = nextParent;\n }\n }\n\n return false;\n}\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["virtualParent/getParent.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,kBAAA,gBAAA,OAAA,CAAA,oBAAA,CAAA;AAEA;;;AAGG;;;AACH,SAAgB,SAAhB,CAA0B,KAA1B,EAAmD;EACjD,OAAQ,KAAK,IAAI,kBAAA,CAAA,gBAAA,CAAiB,KAAjB,CAAV,KAAuC,KAAK,KAAA,IAAL,IAAA,KAAK,KAAA,KAAA,CAAL,GAAK,KAAA,CAAL,GAAA,KAAK,CAAE,UAA9C,CAAP;AACD;;AAFD,OAAA,CAAA,SAAA,GAAA,SAAA","sourcesContent":["import { getVirtualParent } from './getVirtualParent';\n\n/**\n * Gets the element which is the parent of a given element.\n * This method prefers the virtual parent over real DOM parent when present.\n */\nexport function getParent(child: HTMLElement | null): HTMLElement | null {\n return (child && getVirtualParent(child)) || (child?.parentNode as HTMLElement | null);\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-portal/src/virtualParent/getParent.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,kBAAA,gBAAA,OAAA,CAAA,oBAAA,CAAA;AAEA;;;AAGG;;;AACH,SAAgB,SAAhB,CAA0B,KAA1B,EAAmD;EACjD,OAAQ,KAAK,IAAI,kBAAA,CAAA,gBAAA,CAAiB,KAAjB,CAAV,KAAuC,KAAK,KAAA,IAAL,IAAA,KAAK,KAAA,KAAA,CAAL,GAAK,KAAA,CAAL,GAAA,KAAK,CAAE,UAA9C,CAAP;AACD;;AAFD,OAAA,CAAA,SAAA,GAAA,SAAA","sourcesContent":["import { getVirtualParent } from './getVirtualParent';\n\n/**\n * Gets the element which is the parent of a given element.\n * This method prefers the virtual parent over real DOM parent when present.\n */\nexport function getParent(child: HTMLElement | null): HTMLElement | null {\n return (child && getVirtualParent(child)) || (child?.parentNode as HTMLElement | null);\n}\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["virtualParent/getVirtualParent.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,kBAAA,gBAAA,OAAA,CAAA,oBAAA,CAAA;AACA;;AAEG;;;AACH,SAAgB,gBAAhB,CAAiC,KAAjC,EAAmD;EACjD,IAAI,MAAJ;;EACA,IAAI,kBAAA,CAAA,gBAAA,CAAiB,KAAjB,CAAJ,EAA6B;IAC3B,MAAM,GAAG,KAAK,CAAC,QAAN,CAAe,MAAxB;EACD;;EACD,OAAO,MAAP;AACD;;AAND,OAAA,CAAA,gBAAA,GAAA,gBAAA","sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n/**\n * Gets the virtual parent given the child element, if it exists.\n */\nexport function getVirtualParent(child: HTMLElement): HTMLElement | undefined {\n let parent: HTMLElement | undefined;\n if (isVirtualElement(child)) {\n parent = child._virtual.parent;\n }\n return parent;\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-portal/src/virtualParent/getVirtualParent.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,kBAAA,gBAAA,OAAA,CAAA,oBAAA,CAAA;AACA;;AAEG;;;AACH,SAAgB,gBAAhB,CAAiC,KAAjC,EAAmD;EACjD,IAAI,MAAJ;;EACA,IAAI,kBAAA,CAAA,gBAAA,CAAiB,KAAjB,CAAJ,EAA6B;IAC3B,MAAM,GAAG,KAAK,CAAC,QAAN,CAAe,MAAxB;EACD;;EACD,OAAO,MAAP;AACD;;AAND,OAAA,CAAA,gBAAA,GAAA,gBAAA","sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n/**\n * Gets the virtual parent given the child element, if it exists.\n */\nexport function getVirtualParent(child: HTMLElement): HTMLElement | undefined {\n let parent: HTMLElement | undefined;\n if (isVirtualElement(child)) {\n parent = child._virtual.parent;\n }\n return parent;\n}\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["virtualParent/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,aAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './elementContains';\nexport * from './getParent';\nexport * from './getVirtualParent';\nexport * from './isVirtualElement';\nexport * from './setVirtualParent';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-portal/src/virtualParent/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,aAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './elementContains';\nexport * from './getParent';\nexport * from './getVirtualParent';\nexport * from './isVirtualElement';\nexport * from './setVirtualParent';\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["virtualParent/isVirtualElement.ts"],"names":[],"mappings":";;;;;;AAEA;;AAEG;;AACH,SAAgB,gBAAhB,CAAiC,OAAjC,EAAsE;EACpE,OAAO,OAAO,IAAI,CAAC,CAAkB,OAAQ,CAAC,QAA9C;AACD;;AAFD,OAAA,CAAA,gBAAA,GAAA,gBAAA","sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Determines whether or not an element has the virtual hierarchy extension.\n */\nexport function isVirtualElement(element: HTMLElement | VirtualElement): element is VirtualElement {\n return element && !!(<VirtualElement>element)._virtual;\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-portal/src/virtualParent/isVirtualElement.ts"],"names":[],"mappings":";;;;;;AAEA;;AAEG;;AACH,SAAgB,gBAAhB,CAAiC,OAAjC,EAAsE;EACpE,OAAO,OAAO,IAAI,CAAC,CAAkB,OAAQ,CAAC,QAA9C;AACD;;AAFD,OAAA,CAAA,gBAAA,GAAA,gBAAA","sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Determines whether or not an element has the virtual hierarchy extension.\n */\nexport function isVirtualElement(element: HTMLElement | VirtualElement): element is VirtualElement {\n return element && !!(<VirtualElement>element)._virtual;\n}\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["virtualParent/setVirtualParent.ts"],"names":[],"mappings":";;;;;;AAEA;;;;;AAKG;;AACH,SAAgB,gBAAhB,CAAiC,KAAjC,EAAqD,MAArD,EAAyE;EACvE,IAAI,CAAC,KAAL,EAAY;IACV;EACD;;EAED,MAAM,YAAY,GAAmB,KAArC;;EAEA,IAAI,CAAC,YAAY,CAAC,QAAlB,EAA4B;IAC1B,YAAY,CAAC,QAAb,GAAwB,EAAxB;EACD;;EAED,YAAY,CAAC,QAAb,CAAsB,MAAtB,GAA+B,MAAM,IAAI,SAAzC;AACD;;AAZD,OAAA,CAAA,gBAAA,GAAA,gBAAA","sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Sets the virtual parent of an element.\n *\n * @param child - Theme element to set the virtual parent\n * @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship\n */\nexport function setVirtualParent(child: HTMLElement, parent?: HTMLElement): void {\n if (!child) {\n return;\n }\n\n const virtualChild = <VirtualElement>child;\n\n if (!virtualChild._virtual) {\n virtualChild._virtual = {};\n }\n\n virtualChild._virtual.parent = parent || undefined;\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-portal/src/virtualParent/setVirtualParent.ts"],"names":[],"mappings":";;;;;;AAEA;;;;;AAKG;;AACH,SAAgB,gBAAhB,CAAiC,KAAjC,EAAqD,MAArD,EAAyE;EACvE,IAAI,CAAC,KAAL,EAAY;IACV;EACD;;EAED,MAAM,YAAY,GAAmB,KAArC;;EAEA,IAAI,CAAC,YAAY,CAAC,QAAlB,EAA4B;IAC1B,YAAY,CAAC,QAAb,GAAwB,EAAxB;EACD;;EAED,YAAY,CAAC,QAAb,CAAsB,MAAtB,GAA+B,MAAM,IAAI,SAAzC;AACD;;AAZD,OAAA,CAAA,gBAAA,GAAA,gBAAA","sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Sets the virtual parent of an element.\n *\n * @param child - Theme element to set the virtual parent\n * @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship\n */\nexport function setVirtualParent(child: HTMLElement, parent?: HTMLElement): void {\n if (!child) {\n return;\n }\n\n const virtualChild = <VirtualElement>child;\n\n if (!virtualChild._virtual) {\n virtualChild._virtual = {};\n }\n\n virtualChild._virtual.parent = parent || undefined;\n}\n"],"sourceRoot":"../src/"}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@fluentui/react-portal",
3
- "version": "9.0.9",
3
+ "version": "9.0.11",
4
4
  "description": "A utility component that creates portals compatible with Fluent UI",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
7
- "typings": "dist/index.d.ts",
7
+ "typings": "./dist/index.d.ts",
8
8
  "sideEffects": false,
9
9
  "repository": {
10
10
  "type": "git",
@@ -20,10 +20,9 @@
20
20
  "lint": "just-scripts lint",
21
21
  "start": "yarn storybook",
22
22
  "test": "jest --passWithNoTests",
23
- "docs": "api-extractor run --config=config/api-extractor.local.json --local",
24
- "build:local": "tsc -p ./tsconfig.lib.json --module esnext --emitDeclarationOnly && node ../../../scripts/typescript/normalize-import --output ./dist/types/packages/react-components/react-portal/src && yarn docs",
25
23
  "storybook": "start-storybook",
26
- "type-check": "tsc -b tsconfig.json"
24
+ "type-check": "tsc -b tsconfig.json",
25
+ "generate-api": "tsc -p ./tsconfig.lib.json --emitDeclarationOnly && just-scripts api-extractor"
27
26
  },
28
27
  "devDependencies": {
29
28
  "@fluentui/eslint-plugin": "*",
@@ -31,9 +30,9 @@
31
30
  "@fluentui/scripts": "^1.0.0"
32
31
  },
33
32
  "dependencies": {
34
- "@fluentui/react-shared-contexts": "^9.1.0",
35
- "@fluentui/react-tabster": "^9.2.1",
36
- "@fluentui/react-utilities": "^9.2.0",
33
+ "@fluentui/react-shared-contexts": "^9.1.1",
34
+ "@fluentui/react-tabster": "^9.3.1",
35
+ "@fluentui/react-utilities": "^9.2.2",
37
36
  "@griffel/react": "^1.4.2",
38
37
  "tslib": "^2.1.0"
39
38
  },
@@ -51,9 +50,10 @@
51
50
  },
52
51
  "exports": {
53
52
  ".": {
54
- "types": "./lib/index.d.ts",
53
+ "types": "./dist/index.d.ts",
55
54
  "import": "./lib/index.js",
56
55
  "require": "./lib-commonjs/index.js"
57
- }
56
+ },
57
+ "./package.json": "./package.json"
58
58
  }
59
59
  }
package/Spec.md DELETED
@@ -1,254 +0,0 @@
1
- # Portal Spec
2
-
3
- ## Background
4
-
5
- Components that require positioning out of the normal DOM order such as Menu and Tooltip are generally rendered through React portals. This is very useful when the components need to break out of the bounds of a parent component so that the content is not overflowed or covered by another element with zIndex. Portals also support event bubbling in the React tree.
6
-
7
- Since our styling system uses css variables that are written onto DOM, we need to ensure that all portals are rendered onto a part of the DOM where the css variables are available.
8
-
9
- Portals also need need to include the same dir attribute as the parent react tree, so that RTL/LTR is displayed correctly in the portal and the parent content.
10
-
11
- ## Prior Art
12
-
13
- Open UI research was not done for this component. `Portal` does not actually represent a UI control, but a utility component specific to React that makes the rendering of out of order DOM elements easy from within the React tree.
14
-
15
- ### v0/v8 Comparison
16
-
17
- This section compares the noteworthy differences/similarities between the `Layer` and `Portal` components of v8 and v0 respectively that share functionality with this proposed converged component.
18
-
19
- #### Portal Trigger
20
-
21
- The v0 Portal component includes a `trigger` prop that allows consumers to open a React portal. The adoption is not widely used across v0's main consumer, Teams.
22
-
23
- The v8 `Layer` component fills a similar role to `PortalInner` which is the component that actually renders a React portal.
24
-
25
- #### Event propagation
26
-
27
- v8 `Layer` users must explicitly use the `enableEventBubbling` behaviour, which is default in React portals. This is mainly because `Layer` is older than `React.Portal`. Since synthetic event propagation was only introduced with React portals, it had to be enabled to preserve backwards compat.
28
-
29
- Meanwhile v0 does not allow any kind of way to disable native React event bubbling through portals, to achieve a similar effect, the user must manage this themselves.
30
-
31
- #### DOM insertion
32
-
33
- Both `Layer` and `Portal` allow insertion of portals to the same part of the DOM element.
34
-
35
- v8 Layer does this through a `LayerHost` which can be rendered at any part of the React tree. The result is a HTMLDiv element with a specific CSS class and unique Id. `Layer` will attempt to find a `LayerHost` to mount either by CSS class or user provided `hostId`. The default fallback is `document.body`. Each `Layer` will render its own `Fabric` provider. The `insertFirst` property supported by `Layer` was introduced in #8065 for modeless Dialogs which was achieved through `position: static` and DOM insertion order. The same effect can be achieved through `pointer-events: none`.
36
-
37
- The v0 `PortalBoxContext` stores a single HTMLDiv that is usually a child of `document.body` where all `Portal` components are rendered by default. The v0 `Provider` is rendered for the default portal element, where style and RTL overrides could be applied for all portals within.
38
-
39
- #### Lifecycle methods
40
-
41
- v0 `Portal` only supports the following lifecycle methods:
42
-
43
- - onMount
44
- - onUnmount
45
-
46
- `Layer` supports the following:
47
-
48
- - onLayerMounted
49
- - onLayerWillUnmount
50
-
51
- The lifecycle events are very similar, with the only difference being that `onLayerWillUnmount` is called with `hostId` changes. v0 does not consider the mountNode changing as an unmount of the component itself.
52
-
53
- #### Focus Management
54
-
55
- v0 `Portal` can be configured to focus trap its contents while v8 `Layer` does not offer this and users would need to use `FocusTrapZone` for this purpose.
56
-
57
- ## Sample Code
58
-
59
- `Portal` by default mounts the content to `document.body`. In the event a consumer needs to target a specific mount node for Portal content this should be configurable via prop. Both variants should still be able to access theme and fluent context if available.
60
-
61
- ```
62
- const customElement = document.createElement('div');
63
-
64
- <App> // using FluentProvider of ThemeProvider but not PortalProvider
65
- <Portal /> // attached to document.body
66
- <Portal mountNode={customElement} /> // mounted on custom element
67
- </App>
68
- ```
69
-
70
- `Portal` should be used as a component at any part of the React tree:
71
-
72
- ```tsx
73
- <ContextProvider>
74
- <Portal>
75
- <ContextConsumer /> // should be able to access context
76
- </Portal>
77
- </ContextProvider>
78
- ```
79
-
80
- `Portal` should be able to access theme values as css variables:
81
-
82
- ```tsx
83
- const useStyles = makeStyles({
84
- portalContent: theme => {...}
85
- })
86
-
87
-
88
- const styles = useStyles();
89
-
90
- <ThemeProvider>
91
- <Portal>
92
- <div className={styles.portalContent}>
93
- Can use all theme CSS variables from the parent ThemeProvider
94
- </div>
95
- </Portal>
96
- </ThemeProvider>
97
- ```
98
-
99
- ## Variants
100
-
101
- - Mounting the portal on a custom node
102
-
103
- ## API
104
-
105
- ### Portal
106
-
107
- | Name | Description | Required | Type | Default value |
108
- | --------- | -------------------------------------- | -------- | ----------- | -------------------------------- |
109
- | mountNode | Where the portal is mounted to the DOM | No | HTMLElement | ProviderContext or document.body |
110
-
111
- ### Virtual parents
112
-
113
- Out of order DOM elements can be problematic when using 'click outside' event listeners since you cannot rely on `element.contains(event.target)` because the `Portal` elements are out of DOM order.
114
-
115
- ```tsx
116
-
117
- const outerButtonRef = React.useRef();
118
- const innerButtonRef = React.useRef();
119
-
120
-
121
- <Portal>
122
- <div>
123
- <button ref={outerButtonRef}> Outer button </button>
124
- <Portal>
125
- <div>
126
- <button ref={innerButtonRef}> Inner button </button>
127
- </div>
128
- </Portal>
129
- </div>
130
- </Portal>
131
-
132
- // DOM output
133
- <div>
134
- <button>Outer button</button>
135
- </div>
136
-
137
- <div>
138
- <button>Inner button</button>
139
- </div>
140
-
141
- // Let's add an event listener to 'dismss' the outer portal when clicked outside
142
- // ⚠⚠⚠ This will always be called when clicking on the inner button
143
- document.addEventListener((event) => {
144
- if (outerButtonRef.current.contains(event.target)) {
145
- dismissOuterPortal();
146
- }
147
- })
148
- ```
149
-
150
- When the above case is not required, using `element.contains` is perfectly fine. But nested cases should still be handled appropriately. We do this using the concept of `virtual parents`
151
-
152
- `Portal` will make public 2 utilities that will only be used in cases where the user needs to know if an out of order DOM element will need to be used or not.
153
-
154
- - `setVirtualParent` - sets virtual parent
155
- - `elementContains` - similar to `element.contains` but uses the virtual hierarchy as reference
156
-
157
- Below shows what a virtual parent is
158
-
159
- ```tsx
160
- // Setting a virtual parent
161
-
162
- const parent document.getElementById('parent')
163
- const child document.getElement.ById('child');
164
-
165
- child._virtual.parent = parent;
166
- ```
167
-
168
- ## Structure
169
-
170
- ```tsx
171
- <FluentProvider>
172
- <Portal id="portal-1" />
173
- <Portal id="portal-2" />
174
- </FluentProvider>
175
- ```
176
-
177
- DOM output:
178
-
179
- ```tsx
180
- <body>
181
- <div>
182
- {/* Virtual parent for portal*/}
183
- <span aria-hidden />
184
- {/* Virtual parent for portal*/}
185
- <span aria-hidden />
186
- </div>
187
-
188
- <div id="portal-1" class="theme-provider-0">
189
- {children}
190
- </div>
191
- <div id="portal-2" class="theme-provider-0">
192
- {children}
193
- </div>
194
- </body>
195
- ```
196
-
197
- ```tsx
198
- <FluentProvider>
199
- <Portal id="portal-1">
200
- <Portal id="portal-2" />
201
- </Portal>
202
- </FluentProvider>
203
- ```
204
-
205
- DOM output:
206
-
207
- ```tsx
208
- <body>
209
- <div>
210
- {/* Virtual parent for outer portal*/}
211
- <span aria-hidden></span>
212
- </div>
213
-
214
- <div id="portal-1" class="theme-provider-0">
215
- {/* Virtual parent for inner portal*/}
216
- <span aria-hidden />
217
- {children}
218
- </div>
219
- <div id="portal-2" class="theme-provider-0">
220
- {children}
221
- </div>
222
- </body>
223
- ```
224
-
225
- ## Migration
226
-
227
- _Describe what will need to be done to upgrade from the existing implementations:_
228
-
229
- ### v8 migration
230
-
231
- - There will be no way to disable event bubbling, it will be up to consumers to call `stopPropagation` themselves or create extra utilities that do so
232
- - No more concept of `LayerHost` and id/class selectors, raw HTML elements/refs can be stored in context on the consumer app and used in `mountNode` for `Portals` if required
233
- - No more mount lifecycle methods, users can remedy this easily with `useEffect` or `useLayoutEffect` hooks
234
- - `insertFirst` will no longer be supported, and can be handled by a custom `mountNode` if necessary, sticky Dialog can be implmented with `pointer-events: none`
235
-
236
- ### v0 migration
237
-
238
- - No more openable portals - should use future converged `Popup`
239
- - No more focus trapping in `Portals` do that manually (Tabster)
240
- - No more mount lifecycle methods, users can remedy this easily with `useEffect` or `useLayoutEffect` hooks
241
-
242
- ## Behaviors
243
-
244
- ### Server Side Rendering (SSR)
245
-
246
- The ReactDOM `createPortal` requires a valid DOM node to render. This is problematic when `document` does not actually exist during the server render. Instead during the server render `null` will be used. This is not a big problem for most components that use portals such as popups or dialogs since they must be opened from some kind of trigger element (i.e. button)
247
-
248
- However, there are some cases where a `Portal` content will always need to be rendered on the page. Tooltips should always be rendered so that `aria` attributes will refer to actual elements. This is problematic since the Tooltip (or higher order component) needs to be aware of the server render where `null`is rendered and render the actual content on the first client render.
249
-
250
- The `Portal` component should handle this SSR case, and should be aware of the server and client renders when calling `ReactDOM.createPortal`.
251
-
252
- ## Accessibility
253
-
254
- This component is considered a utility to render its children to an out of order DOM element. Since the component itself does not render DOM it is up to the consumer to handle the A11y requirements of their portal content.