@fluentui/react-portal 9.0.14 → 9.1.0

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 +75 -1
  2. package/CHANGELOG.md +25 -2
  3. package/dist/index.d.ts +2 -2
  4. package/lib/components/Portal/Portal.js +0 -1
  5. package/lib/components/Portal/Portal.js.map +1 -1
  6. package/lib/components/Portal/renderPortal.js +0 -1
  7. package/lib/components/Portal/renderPortal.js.map +1 -1
  8. package/lib/components/Portal/usePortal.js +0 -1
  9. package/lib/components/Portal/usePortal.js.map +1 -1
  10. package/lib/components/Portal/usePortalMountNode.js +23 -29
  11. package/lib/components/Portal/usePortalMountNode.js.map +1 -1
  12. package/lib/virtualParent/elementContains.js +0 -5
  13. package/lib/virtualParent/elementContains.js.map +1 -1
  14. package/lib/virtualParent/getParent.js +2 -2
  15. package/lib/virtualParent/getParent.js.map +1 -1
  16. package/lib/virtualParent/getVirtualParent.js +1 -8
  17. package/lib/virtualParent/getVirtualParent.js.map +1 -1
  18. package/lib/virtualParent/isVirtualElement.js.map +1 -1
  19. package/lib/virtualParent/setVirtualParent.js +0 -3
  20. package/lib/virtualParent/setVirtualParent.js.map +1 -1
  21. package/lib/virtualParent/types.js.map +1 -1
  22. package/lib-amd/components/Portal/usePortalMountNode.js +20 -21
  23. package/lib-amd/components/Portal/usePortalMountNode.js.map +1 -1
  24. package/lib-amd/virtualParent/elementContains.js.map +1 -1
  25. package/lib-amd/virtualParent/getParent.js +2 -1
  26. package/lib-amd/virtualParent/getParent.js.map +1 -1
  27. package/lib-amd/virtualParent/getVirtualParent.js +1 -5
  28. package/lib-amd/virtualParent/getVirtualParent.js.map +1 -1
  29. package/lib-amd/virtualParent/isVirtualElement.js.map +1 -1
  30. package/lib-amd/virtualParent/setVirtualParent.js.map +1 -1
  31. package/lib-amd/virtualParent/types.js.map +1 -1
  32. package/lib-commonjs/Portal.js +0 -2
  33. package/lib-commonjs/Portal.js.map +1 -1
  34. package/lib-commonjs/components/Portal/Portal.js +0 -5
  35. package/lib-commonjs/components/Portal/Portal.js.map +1 -1
  36. package/lib-commonjs/components/Portal/Portal.types.js.map +1 -1
  37. package/lib-commonjs/components/Portal/index.js +0 -5
  38. package/lib-commonjs/components/Portal/index.js.map +1 -1
  39. package/lib-commonjs/components/Portal/renderPortal.js +0 -5
  40. package/lib-commonjs/components/Portal/renderPortal.js.map +1 -1
  41. package/lib-commonjs/components/Portal/usePortal.js +0 -6
  42. package/lib-commonjs/components/Portal/usePortal.js.map +1 -1
  43. package/lib-commonjs/components/Portal/usePortalMountNode.js +23 -34
  44. package/lib-commonjs/components/Portal/usePortalMountNode.js.map +1 -1
  45. package/lib-commonjs/index.js +0 -4
  46. package/lib-commonjs/index.js.map +1 -1
  47. package/lib-commonjs/virtualParent/elementContains.js +0 -8
  48. package/lib-commonjs/virtualParent/elementContains.js.map +1 -1
  49. package/lib-commonjs/virtualParent/getParent.js +2 -5
  50. package/lib-commonjs/virtualParent/getParent.js.map +1 -1
  51. package/lib-commonjs/virtualParent/getVirtualParent.js +1 -11
  52. package/lib-commonjs/virtualParent/getVirtualParent.js.map +1 -1
  53. package/lib-commonjs/virtualParent/index.js +0 -6
  54. package/lib-commonjs/virtualParent/index.js.map +1 -1
  55. package/lib-commonjs/virtualParent/isVirtualElement.js +0 -2
  56. package/lib-commonjs/virtualParent/isVirtualElement.js.map +1 -1
  57. package/lib-commonjs/virtualParent/setVirtualParent.js +0 -5
  58. package/lib-commonjs/virtualParent/setVirtualParent.js.map +1 -1
  59. package/lib-commonjs/virtualParent/types.js.map +1 -1
  60. package/package.json +7 -6
@@ -1 +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"]}
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,KAAW,EAAE,MAAa;QACzD,IAAI,CAAC,KAAK,EAAE;YACV,OAAO;SACR;QAED,IAAM,YAAY,GAAG,KAAuB,CAAC;QAE7C,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: Node, parent?: Node): void {\n if (!child) {\n return;\n }\n\n const virtualChild = child as VirtualElement;\n\n if (!virtualChild._virtual) {\n virtualChild._virtual = {};\n }\n\n virtualChild._virtual.parent = parent || undefined;\n}\n"]}
@@ -1 +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
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-portal/src/virtualParent/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface VirtualElement extends Node {\n _virtual: {\n parent?: Node;\n };\n}\n"]}
@@ -3,8 +3,6 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  const tslib_1 = /*#__PURE__*/require("tslib");
8
-
9
7
  tslib_1.__exportStar(require("./components/Portal/index"), exports);
10
8
  //# sourceMappingURL=Portal.js.map
@@ -1 +1 @@
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
+ {"version":3,"mappings":";;;;;;AAAAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/Portal.ts"],"sourcesContent":["export * from './components/Portal/index';\n"]}
@@ -4,21 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Portal = void 0;
7
-
8
7
  const usePortal_1 = /*#__PURE__*/require("./usePortal");
9
-
10
8
  const renderPortal_1 = /*#__PURE__*/require("./renderPortal");
11
9
  /**
12
10
  * A portal provides a way to render children into a DOM node
13
11
  * that exists outside the DOM hierarchy of the parent component.
14
12
  */
15
-
16
-
17
13
  const Portal = props => {
18
14
  const state = usePortal_1.usePortal_unstable(props);
19
15
  return renderPortal_1.renderPortal_unstable(state);
20
16
  };
21
-
22
17
  exports.Portal = Portal;
23
18
  exports.Portal.displayName = 'Portal';
24
19
  //# sourceMappingURL=Portal.js.map
@@ -1 +1 @@
1
- {"version":3,"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
+ {"version":3,"mappings":";;;;;;AAEA;AACA;AAGA;;;;AAIO,MAAMA,MAAM,GAA0BC,KAAK,IAAG;EACnD,MAAMC,KAAK,GAAGC,8BAAkB,CAACF,KAAK,CAAC;EAEvC,OAAOG,oCAAqB,CAACF,KAAK,CAAC;AACrC,CAAC;AAJYG,cAAM;AAMnBA,cAAM,CAACC,WAAW,GAAG,QAAQ","names":["Portal","props","state","usePortal_1","renderPortal_1","exports","displayName"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/components/Portal/Portal.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { usePortal_unstable } from './usePortal';\nimport { renderPortal_unstable } from './renderPortal';\nimport type { PortalProps } from './Portal.types';\n\n/**\n * A portal provides a way to render children into a DOM node\n * that exists outside the DOM hierarchy of the parent component.\n */\nexport const Portal: React.FC<PortalProps> = props => {\n const state = usePortal_unstable(props);\n\n return renderPortal_unstable(state);\n};\n\nPortal.displayName = 'Portal';\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":"../src/"}
1
+ {"version":3,"mappings":"","names":[],"sourceRoot":"../src/","sources":[],"sourcesContent":[]}
@@ -3,14 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  const tslib_1 = /*#__PURE__*/require("tslib");
8
-
9
7
  tslib_1.__exportStar(require("./Portal"), exports);
10
-
11
8
  tslib_1.__exportStar(require("./Portal.types"), exports);
12
-
13
9
  tslib_1.__exportStar(require("./renderPortal"), exports);
14
-
15
10
  tslib_1.__exportStar(require("./usePortal"), exports);
16
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-portal/src/components/Portal/index.ts"],"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,"mappings":";;;;;;AAAAA;AACAA;AACAA;AACAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/components/Portal/index.ts"],"sourcesContent":["export * from './Portal';\nexport * from './Portal.types';\nexport * from './renderPortal';\nexport * from './usePortal';\n"]}
@@ -4,21 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.renderPortal_unstable = void 0;
7
-
8
7
  const ReactDOM = /*#__PURE__*/require("react-dom");
9
-
10
8
  const React = /*#__PURE__*/require("react");
11
9
  /**
12
10
  * Render the final JSX of Portal
13
11
  */
14
-
15
-
16
12
  const renderPortal_unstable = state => {
17
13
  return React.createElement("span", {
18
14
  hidden: true,
19
15
  ref: state.virtualParentRootRef
20
16
  }, state.mountNode && ReactDOM.createPortal(state.children, state.mountNode));
21
17
  };
22
-
23
18
  exports.renderPortal_unstable = renderPortal_unstable;
24
19
  //# sourceMappingURL=renderPortal.js.map
@@ -1 +1 @@
1
- {"version":3,"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
+ {"version":3,"mappings":";;;;;;AAAA;AACA;AAGA;;;AAGO,MAAMA,qBAAqB,GAAIC,KAAkB,IAAwB;EAC9E,OACEC;IAAMC,MAAM;IAACC,GAAG,EAAEH,KAAK,CAACI;EAAoB,GACzCJ,KAAK,CAACK,SAAS,IAAIC,QAAQ,CAACC,YAAY,CAACP,KAAK,CAACQ,QAAQ,EAAER,KAAK,CAACK,SAAS,CAAC,CACrE;AAEX,CAAC;AANYI,6BAAqB","names":["renderPortal_unstable","state","React","hidden","ref","virtualParentRootRef","mountNode","ReactDOM","createPortal","children","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/components/Portal/renderPortal.tsx"],"sourcesContent":["import * as ReactDOM from 'react-dom';\nimport * as React from 'react';\nimport type { PortalState } from './Portal.types';\n\n/**\n * Render the final JSX of Portal\n */\nexport const renderPortal_unstable = (state: PortalState): React.ReactElement => {\n return (\n <span hidden ref={state.virtualParentRootRef}>\n {state.mountNode && ReactDOM.createPortal(state.children, state.mountNode)}\n </span>\n );\n};\n"]}
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.usePortal_unstable = void 0;
7
-
8
7
  const React = /*#__PURE__*/require("react");
9
-
10
8
  const usePortalMountNode_1 = /*#__PURE__*/require("./usePortalMountNode");
11
-
12
9
  const index_1 = /*#__PURE__*/require("../../virtualParent/index");
13
10
  /**
14
11
  * Create the state required to render Portal.
@@ -17,8 +14,6 @@ const index_1 = /*#__PURE__*/require("../../virtualParent/index");
17
14
  *
18
15
  * @param props - props from this instance of Portal
19
16
  */
20
-
21
-
22
17
  const usePortal_unstable = props => {
23
18
  const {
24
19
  children,
@@ -40,6 +35,5 @@ const usePortal_unstable = props => {
40
35
  }, [state.virtualParentRootRef, state.mountNode]);
41
36
  return state;
42
37
  };
43
-
44
38
  exports.usePortal_unstable = usePortal_unstable;
45
39
  //# sourceMappingURL=usePortal.js.map
@@ -1 +1 @@
1
- {"version":3,"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
+ {"version":3,"mappings":";;;;;;AAAA;AACA;AACA;AAGA;;;;;;;AAOO,MAAMA,kBAAkB,GAAIC,KAAkB,IAAiB;EACpE,MAAM;IAAEC,QAAQ;IAAEC;EAAS,CAAE,GAAGF,KAAK;EAErC,MAAMG,oBAAoB,GAAGC,KAAK,CAACC,MAAM,CAAkB,IAAI,CAAC;EAChE,MAAMC,iBAAiB,GAAGC,uCAAkB,CAAC;IAAEC,QAAQ,EAAE,CAAC,CAACN;EAAS,CAAE,CAAC;EAEvE,MAAMO,KAAK,GAAgB;IACzBR,QAAQ;IACRC,SAAS,EAAEA,SAAS,aAATA,SAAS,cAATA,SAAS,GAAII,iBAAiB;IACzCH;GACD;EAEDC,KAAK,CAACM,SAAS,CAAC,MAAK;IACnB,IAAID,KAAK,CAACN,oBAAoB,CAACQ,OAAO,IAAIF,KAAK,CAACP,SAAS,EAAE;MACzDU,wBAAgB,CAACH,KAAK,CAACP,SAAS,EAAEO,KAAK,CAACN,oBAAoB,CAACQ,OAAO,CAAC;;EAEzE,CAAC,EAAE,CAACF,KAAK,CAACN,oBAAoB,EAAEM,KAAK,CAACP,SAAS,CAAC,CAAC;EAEjD,OAAOO,KAAK;AACd,CAAC;AAnBYI,0BAAkB","names":["usePortal_unstable","props","children","mountNode","virtualParentRootRef","React","useRef","fallbackMountNode","usePortalMountNode_1","disabled","state","useEffect","current","index_1","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/components/Portal/usePortal.ts"],"sourcesContent":["import * as React from 'react';\nimport { usePortalMountNode } from './usePortalMountNode';\nimport { setVirtualParent } from '../../virtualParent/index';\nimport type { PortalProps, PortalState } from './Portal.types';\n\n/**\n * Create the state required to render Portal.\n *\n * The returned state can be modified with hooks such as usePortalStyles, before being passed to renderPortal_unstable.\n *\n * @param props - props from this instance of Portal\n */\nexport const usePortal_unstable = (props: PortalProps): PortalState => {\n const { children, mountNode } = props;\n\n const virtualParentRootRef = React.useRef<HTMLSpanElement>(null);\n const fallbackMountNode = usePortalMountNode({ disabled: !!mountNode });\n\n const state: PortalState = {\n children,\n mountNode: mountNode ?? fallbackMountNode,\n virtualParentRootRef,\n };\n\n React.useEffect(() => {\n if (state.virtualParentRootRef.current && state.mountNode) {\n setVirtualParent(state.mountNode, state.virtualParentRootRef.current);\n }\n }, [state.virtualParentRootRef, state.mountNode]);\n\n return state;\n};\n"]}
@@ -4,28 +4,25 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.usePortalMountNode = void 0;
7
-
8
7
  const React = /*#__PURE__*/require("react");
9
-
10
8
  const react_shared_contexts_1 = /*#__PURE__*/require("@fluentui/react-shared-contexts");
11
-
12
9
  const react_1 = /*#__PURE__*/require("@griffel/react");
13
-
14
10
  const react_tabster_1 = /*#__PURE__*/require("@fluentui/react-tabster");
15
-
11
+ const use_disposable_1 = /*#__PURE__*/require("use-disposable");
12
+ const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
13
+ // String concatenation is used to prevent bundlers to complain with older versions of React
14
+ const useInsertionEffect = React['useInsertion' + 'Effect'] ? React['useInsertion' + 'Effect'] : react_utilities_1.useIsomorphicLayoutEffect;
16
15
  const useStyles = /*#__PURE__*/react_1.__styles({
17
- "root": {
18
- "qhf8xq": "f10pi13n",
19
- "Bj3rh1h": "f494woh"
16
+ root: {
17
+ qhf8xq: "f10pi13n",
18
+ Bj3rh1h: "f494woh"
20
19
  }
21
20
  }, {
22
- "d": [".f10pi13n{position:relative;}", ".f494woh{z-index:1000000;}"]
21
+ d: [".f10pi13n{position:relative;}", ".f494woh{z-index:1000000;}"]
23
22
  });
24
23
  /**
25
24
  * Creates a new element on a document.body to mount portals
26
25
  */
27
-
28
-
29
26
  const usePortalMountNode = options => {
30
27
  const {
31
28
  targetDocument,
@@ -35,40 +32,32 @@ const usePortalMountNode = options => {
35
32
  const classes = useStyles();
36
33
  const themeClassName = react_shared_contexts_1.useThemeClassName_unstable();
37
34
  const className = react_1.mergeClasses(themeClassName, classes.root);
38
- const element = React.useMemo(() => {
35
+ const element = use_disposable_1.useDisposable(() => {
39
36
  if (targetDocument === undefined || options.disabled) {
40
- return null;
37
+ return [null, () => null];
41
38
  }
42
-
43
39
  const newElement = targetDocument.createElement('div');
44
40
  targetDocument.body.appendChild(newElement);
45
- return newElement;
46
- }, [targetDocument, options.disabled]); // This useMemo call is intentional
41
+ return [newElement, () => newElement.remove()];
42
+ }, [targetDocument]);
43
+ // This useEffect call is intentional
47
44
  // We don't want to re-create the portal element when its attributes change.
48
45
  // This also should not be done in an effect because, changing the value of css variables
49
46
  // after initial mount can trigger interesting CSS side effects like transitions.
50
-
51
- React.useMemo(() => {
52
- if (element) {
53
- const classesToApply = className.split(' ').filter(Boolean);
54
- element.classList.add(...classesToApply);
55
- element.setAttribute('dir', dir);
56
- focusVisibleRef.current = element;
57
- return () => {
58
- element.classList.remove(...classesToApply);
59
- element.removeAttribute('dir');
60
- };
47
+ useInsertionEffect(() => {
48
+ if (!element) {
49
+ return;
61
50
  }
62
- }, [className, dir, element, focusVisibleRef]);
63
- React.useEffect(() => {
51
+ const classesToApply = className.split(' ').filter(Boolean);
52
+ element.classList.add(...classesToApply);
53
+ element.setAttribute('dir', dir);
54
+ focusVisibleRef.current = element;
64
55
  return () => {
65
- var _a;
66
-
67
- (_a = element === null || element === void 0 ? void 0 : element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(element);
56
+ element.classList.remove(...classesToApply);
57
+ element.removeAttribute('dir');
68
58
  };
69
- }, [element]);
59
+ }, [className, dir, element, focusVisibleRef]);
70
60
  return element;
71
61
  };
72
-
73
62
  exports.usePortalMountNode = usePortalMountNode;
74
63
  //# sourceMappingURL=usePortalMountNode.js.map
@@ -1 +1 @@
1
- {"version":3,"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
+ {"version":3,"mappings":";;;;;;AAAA;AACA;AAIA;AACA;AACA;AACA;AAEA;AACA,MAAMA,kBAAkB,GAAIC,KAAe,CAAC,cAAc,GAAG,QAAQ,CAAC,GACjEA,KAAe,CAAC,cAAc,GAAG,QAAQ,CAAC,GAC3CC,2CAAyB;AAS7B,MAAMC,SAAS,gBAAGC,gBAAU;EAAA;IAAA;IAAA;EAAA;AAAA;EAAA;AAAA,EAK1B;AAEF;;;AAGO,MAAMC,kBAAkB,GAAIC,OAAkC,IAAwB;EAC3F,MAAM;IAAEC,cAAc;IAAEC;EAAG,CAAE,GAAGC,0CAAS,EAAE;EAC3C,MAAMC,eAAe,GAAGC,+BAAe,EAAgE;EACvG,MAAMC,OAAO,GAAGT,SAAS,EAAE;EAC3B,MAAMU,cAAc,GAAGJ,kDAAiB,EAAE;EAE1C,MAAMK,SAAS,GAAGV,oBAAY,CAACS,cAAc,EAAED,OAAO,CAACG,IAAI,CAAC;EAE5D,MAAMC,OAAO,GAAGC,8BAAa,CAAC,MAAK;IACjC,IAAIV,cAAc,KAAKW,SAAS,IAAIZ,OAAO,CAACa,QAAQ,EAAE;MACpD,OAAO,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC;;IAG3B,MAAMC,UAAU,GAAGb,cAAc,CAACc,aAAa,CAAC,KAAK,CAAC;IACtDd,cAAc,CAACe,IAAI,CAACC,WAAW,CAACH,UAAU,CAAC;IAC3C,OAAO,CAACA,UAAU,EAAE,MAAMA,UAAU,CAACI,MAAM,EAAE,CAAC;EAChD,CAAC,EAAE,CAACjB,cAAc,CAAC,CAAC;EAEpB;EACA;EACA;EACA;EACAP,kBAAkB,CAAC,MAAK;IACtB,IAAI,CAACgB,OAAO,EAAE;MACZ;;IAGF,MAAMS,cAAc,GAAGX,SAAS,CAACY,KAAK,CAAC,GAAG,CAAC,CAACC,MAAM,CAACC,OAAO,CAAC;IAE3DZ,OAAO,CAACa,SAAS,CAACC,GAAG,CAAC,GAAGL,cAAc,CAAC;IACxCT,OAAO,CAACe,YAAY,CAAC,KAAK,EAAEvB,GAAG,CAAC;IAChCE,eAAe,CAACsB,OAAO,GAAGhB,OAAO;IAEjC,OAAO,MAAK;MACVA,OAAO,CAACa,SAAS,CAACL,MAAM,CAAC,GAAGC,cAAc,CAAC;MAC3CT,OAAO,CAACiB,eAAe,CAAC,KAAK,CAAC;IAChC,CAAC;EACH,CAAC,EAAE,CAACnB,SAAS,EAAEN,GAAG,EAAEQ,OAAO,EAAEN,eAAe,CAAC,CAAC;EAE9C,OAAOM,OAAO;AAChB,CAAC;AAxCYkB,0BAAkB","names":["useInsertionEffect","React","react_utilities_1","useStyles","react_1","usePortalMountNode","options","targetDocument","dir","react_shared_contexts_1","focusVisibleRef","react_tabster_1","classes","themeClassName","className","root","element","use_disposable_1","undefined","disabled","newElement","createElement","body","appendChild","remove","classesToApply","split","filter","Boolean","classList","add","setAttribute","current","removeAttribute","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/components/Portal/usePortalMountNode.ts"],"sourcesContent":["import * as React from 'react';\nimport {\n useThemeClassName_unstable as useThemeClassName,\n useFluent_unstable as useFluent,\n} from '@fluentui/react-shared-contexts';\nimport { makeStyles, mergeClasses } from '@griffel/react';\nimport { useFocusVisible } from '@fluentui/react-tabster';\nimport { useDisposable } from 'use-disposable';\nimport { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\n\n// String concatenation is used to prevent bundlers to complain with older versions of React\nconst useInsertionEffect = (React as never)['useInsertion' + 'Effect']\n ? (React as never)['useInsertion' + 'Effect']\n : useIsomorphicLayoutEffect;\n\nexport type UsePortalMountNodeOptions = {\n /**\n * Since hooks cannot be called conditionally use this flag to disable creating the node\n */\n disabled?: boolean;\n};\n\nconst useStyles = makeStyles({\n root: {\n position: 'relative',\n zIndex: 1000000,\n },\n});\n\n/**\n * Creates a new element on a document.body to mount portals\n */\nexport const usePortalMountNode = (options: UsePortalMountNodeOptions): HTMLElement | null => {\n const { targetDocument, dir } = useFluent();\n const focusVisibleRef = useFocusVisible<HTMLDivElement>() as React.MutableRefObject<HTMLElement | null>;\n const classes = useStyles();\n const themeClassName = useThemeClassName();\n\n const className = mergeClasses(themeClassName, classes.root);\n\n const element = useDisposable(() => {\n if (targetDocument === undefined || options.disabled) {\n return [null, () => null];\n }\n\n const newElement = targetDocument.createElement('div');\n targetDocument.body.appendChild(newElement);\n return [newElement, () => newElement.remove()];\n }, [targetDocument]);\n\n // This useEffect call is intentional\n // We don't want to re-create the portal element when its attributes change.\n // This also should not be done in an effect because, changing the value of css variables\n // after initial mount can trigger interesting CSS side effects like transitions.\n useInsertionEffect(() => {\n if (!element) {\n return;\n }\n\n const classesToApply = className.split(' ').filter(Boolean);\n\n element.classList.add(...classesToApply);\n element.setAttribute('dir', dir);\n focusVisibleRef.current = element;\n\n return () => {\n element.classList.remove(...classesToApply);\n element.removeAttribute('dir');\n };\n }, [className, dir, element, focusVisibleRef]);\n\n return element;\n};\n"]}
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.setVirtualParent = exports.elementContains = exports.usePortal_unstable = exports.renderPortal_unstable = exports.Portal = void 0;
7
-
8
7
  var index_1 = /*#__PURE__*/require("./components/Portal/index");
9
-
10
8
  Object.defineProperty(exports, "Portal", {
11
9
  enumerable: true,
12
10
  get: function () {
@@ -25,9 +23,7 @@ Object.defineProperty(exports, "usePortal_unstable", {
25
23
  return index_1.usePortal_unstable;
26
24
  }
27
25
  });
28
-
29
26
  var index_2 = /*#__PURE__*/require("./virtualParent/index");
30
-
31
27
  Object.defineProperty(exports, "elementContains", {
32
28
  enumerable: true,
33
29
  get: function () {
@@ -1 +1 @@
1
- {"version":3,"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
+ {"version":3,"mappings":";;;;;;AAAA;AAASA;EAAAC;EAAAC;IAAA,qBAAM;EAAA;AAAA;AAAEF;EAAAC;EAAAC;IAAA,oCAAqB;EAAA;AAAA;AAAEF;EAAAC;EAAAC;IAAA,iCAAkB;EAAA;AAAA;AAE1D;AAASF;EAAAC;EAAAC;IAAA,8BAAe;EAAA;AAAA;AAAEF;EAAAC;EAAAC;IAAA,+BAAgB;EAAA;AAAA","names":["Object","enumerable","get"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/index.ts"],"sourcesContent":["export { Portal, renderPortal_unstable, usePortal_unstable } from './components/Portal/index';\nexport type { PortalProps, PortalState } from './components/Portal/index';\nexport { elementContains, setVirtualParent } from './virtualParent/index';\n"]}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.elementContains = void 0;
7
-
8
7
  const getParent_1 = /*#__PURE__*/require("./getParent");
9
8
  /**
10
9
  * Similar functionality to `element.contains` DOM API for use with out of order DOM elements that
@@ -12,29 +11,22 @@ const getParent_1 = /*#__PURE__*/require("./getParent");
12
11
  *
13
12
  * @returns true if the child can find the parent in its virtual hierarchy
14
13
  */
15
-
16
-
17
14
  function elementContains(parent, child) {
18
15
  if (!parent || !child) {
19
16
  return false;
20
17
  }
21
-
22
18
  if (parent === child) {
23
19
  return true;
24
20
  } else {
25
21
  while (child) {
26
22
  const nextParent = getParent_1.getParent(child);
27
-
28
23
  if (nextParent === parent) {
29
24
  return true;
30
25
  }
31
-
32
26
  child = nextParent;
33
27
  }
34
28
  }
35
-
36
29
  return false;
37
30
  }
38
-
39
31
  exports.elementContains = elementContains;
40
32
  //# sourceMappingURL=elementContains.js.map
@@ -1 +1 @@
1
- {"version":3,"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
+ {"version":3,"mappings":";;;;;;AAAA;AACA;;;;;;AAMA,SAAgBA,eAAe,CAACC,MAAmB,EAAEC,KAAkB;EACrE,IAAI,CAACD,MAAM,IAAI,CAACC,KAAK,EAAE;IACrB,OAAO,KAAK;;EAGd,IAAID,MAAM,KAAKC,KAAK,EAAE;IACpB,OAAO,IAAI;GACZ,MAAM;IACL,OAAOA,KAAK,EAAE;MACZ,MAAMC,UAAU,GAAGC,qBAAS,CAACF,KAAK,CAAC;MAEnC,IAAIC,UAAU,KAAKF,MAAM,EAAE;QACzB,OAAO,IAAI;;MAGbC,KAAK,GAAGC,UAAU;;;EAItB,OAAO,KAAK;AACd;AApBAE","names":["elementContains","parent","child","nextParent","getParent_1","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/virtualParent/elementContains.ts"],"sourcesContent":["import { getParent } from './getParent';\n/**\n * Similar functionality to `element.contains` DOM API for use with out of order DOM elements that\n * checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent\n *\n * @returns true if the child can find the parent in its virtual hierarchy\n */\nexport function elementContains(parent: Node | null, child: Node | null): boolean {\n if (!parent || !child) {\n return false;\n }\n\n if (parent === child) {\n return true;\n } else {\n while (child) {\n const nextParent = getParent(child);\n\n if (nextParent === parent) {\n return true;\n }\n\n child = nextParent;\n }\n }\n\n return false;\n}\n"]}
@@ -4,17 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getParent = void 0;
7
-
8
7
  const getVirtualParent_1 = /*#__PURE__*/require("./getVirtualParent");
9
8
  /**
10
9
  * Gets the element which is the parent of a given element.
11
10
  * This method prefers the virtual parent over real DOM parent when present.
12
11
  */
13
-
14
-
15
12
  function getParent(child) {
16
- return child && getVirtualParent_1.getVirtualParent(child) || (child === null || child === void 0 ? void 0 : child.parentNode);
13
+ var _a;
14
+ return (_a = child && getVirtualParent_1.getVirtualParent(child) || (child === null || child === void 0 ? void 0 : child.parentNode)) !== null && _a !== void 0 ? _a : null;
17
15
  }
18
-
19
16
  exports.getParent = getParent;
20
17
  //# sourceMappingURL=getParent.js.map
@@ -1 +1 @@
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
+ {"version":3,"mappings":";;;;;;AAAA;AAEA;;;;AAIA,SAAgBA,SAAS,CAACC,KAAkB;;EAC1C,OAAO,MAAEA,KAAK,IAAIC,mCAAgB,CAACD,KAAK,CAAC,KAAKA,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEE,UAAU,CAAC,mCAAI,IAAI;AAC1E;AAFAC","names":["getParent","child","getVirtualParent_1","parentNode","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/virtualParent/getParent.ts"],"sourcesContent":["import { getVirtualParent } from './getVirtualParent';\n\n/**\n * Gets the element which is the parent of a given element.\n * This method prefers the virtual parent over real DOM parent when present.\n */\nexport function getParent(child: Node | null): Node | null {\n return ((child && getVirtualParent(child)) || child?.parentNode) ?? null;\n}\n"]}
@@ -4,22 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getVirtualParent = void 0;
7
-
8
7
  const isVirtualElement_1 = /*#__PURE__*/require("./isVirtualElement");
9
8
  /**
10
9
  * Gets the virtual parent given the child element, if it exists.
11
10
  */
12
-
13
-
14
11
  function getVirtualParent(child) {
15
- let parent;
16
-
17
- if (isVirtualElement_1.isVirtualElement(child)) {
18
- parent = child._virtual.parent;
19
- }
20
-
21
- return parent;
12
+ return isVirtualElement_1.isVirtualElement(child) ? child._virtual.parent : undefined;
22
13
  }
23
-
24
14
  exports.getVirtualParent = getVirtualParent;
25
15
  //# sourceMappingURL=getVirtualParent.js.map
@@ -1 +1 @@
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
+ {"version":3,"mappings":";;;;;;AAAA;AACA;;;AAGA,SAAgBA,gBAAgB,CAACC,KAAW;EAC1C,OAAOC,mCAAgB,CAACD,KAAK,CAAC,GAAGA,KAAK,CAACE,QAAQ,CAACC,MAAM,GAAGC,SAAS;AACpE;AAFAC","names":["getVirtualParent","child","isVirtualElement_1","_virtual","parent","undefined","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/virtualParent/getVirtualParent.ts"],"sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n/**\n * Gets the virtual parent given the child element, if it exists.\n */\nexport function getVirtualParent(child: Node): Node | undefined {\n return isVirtualElement(child) ? child._virtual.parent : undefined;\n}\n"]}
@@ -3,16 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  const tslib_1 = /*#__PURE__*/require("tslib");
8
-
9
7
  tslib_1.__exportStar(require("./elementContains"), exports);
10
-
11
8
  tslib_1.__exportStar(require("./getParent"), exports);
12
-
13
9
  tslib_1.__exportStar(require("./getVirtualParent"), exports);
14
-
15
10
  tslib_1.__exportStar(require("./isVirtualElement"), exports);
16
-
17
11
  tslib_1.__exportStar(require("./setVirtualParent"), exports);
18
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-portal/src/virtualParent/index.ts"],"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,"mappings":";;;;;;AAAAA;AACAA;AACAA;AACAA;AACAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/virtualParent/index.ts"],"sourcesContent":["export * from './elementContains';\nexport * from './getParent';\nexport * from './getVirtualParent';\nexport * from './isVirtualElement';\nexport * from './setVirtualParent';\n"]}
@@ -7,10 +7,8 @@ exports.isVirtualElement = void 0;
7
7
  /**
8
8
  * Determines whether or not an element has the virtual hierarchy extension.
9
9
  */
10
-
11
10
  function isVirtualElement(element) {
12
11
  return element && !!element._virtual;
13
12
  }
14
-
15
13
  exports.isVirtualElement = isVirtualElement;
16
14
  //# sourceMappingURL=isVirtualElement.js.map
@@ -1 +1 @@
1
- {"version":3,"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
+ {"version":3,"mappings":";;;;;;AAEA;;;AAGA,SAAgBA,gBAAgB,CAACC,OAA8B;EAC7D,OAAOA,OAAO,IAAI,CAAC,CAAkBA,OAAQ,CAACC,QAAQ;AACxD;AAFAC","names":["isVirtualElement","element","_virtual","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/virtualParent/isVirtualElement.ts"],"sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Determines whether or not an element has the virtual hierarchy extension.\n */\nexport function isVirtualElement(element: Node | VirtualElement): element is VirtualElement {\n return element && !!(<VirtualElement>element)._virtual;\n}\n"]}
@@ -10,20 +10,15 @@ exports.setVirtualParent = void 0;
10
10
  * @param child - Theme element to set the virtual parent
11
11
  * @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship
12
12
  */
13
-
14
13
  function setVirtualParent(child, parent) {
15
14
  if (!child) {
16
15
  return;
17
16
  }
18
-
19
17
  const virtualChild = child;
20
-
21
18
  if (!virtualChild._virtual) {
22
19
  virtualChild._virtual = {};
23
20
  }
24
-
25
21
  virtualChild._virtual.parent = parent || undefined;
26
22
  }
27
-
28
23
  exports.setVirtualParent = setVirtualParent;
29
24
  //# sourceMappingURL=setVirtualParent.js.map
@@ -1 +1 @@
1
- {"version":3,"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/"}
1
+ {"version":3,"mappings":";;;;;;AAEA;;;;;;AAMA,SAAgBA,gBAAgB,CAACC,KAAW,EAAEC,MAAa;EACzD,IAAI,CAACD,KAAK,EAAE;IACV;;EAGF,MAAME,YAAY,GAAGF,KAAuB;EAE5C,IAAI,CAACE,YAAY,CAACC,QAAQ,EAAE;IAC1BD,YAAY,CAACC,QAAQ,GAAG,EAAE;;EAG5BD,YAAY,CAACC,QAAQ,CAACF,MAAM,GAAGA,MAAM,IAAIG,SAAS;AACpD;AAZAC","names":["setVirtualParent","child","parent","virtualChild","_virtual","undefined","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-portal/src/virtualParent/setVirtualParent.ts"],"sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Sets the virtual parent of an element.\n *\n * @param child - Theme element to set the virtual parent\n * @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship\n */\nexport function setVirtualParent(child: Node, parent?: Node): void {\n if (!child) {\n return;\n }\n\n const virtualChild = child as VirtualElement;\n\n if (!virtualChild._virtual) {\n virtualChild._virtual = {};\n }\n\n virtualChild._virtual.parent = parent || undefined;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":"../src/"}
1
+ {"version":3,"mappings":"","names":[],"sourceRoot":"../src/","sources":[],"sourcesContent":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-portal",
3
- "version": "9.0.14",
3
+ "version": "9.1.0",
4
4
  "description": "A utility component that creates portals compatible with Fluent UI",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -27,14 +27,15 @@
27
27
  "devDependencies": {
28
28
  "@fluentui/eslint-plugin": "*",
29
29
  "@fluentui/react-conformance": "*",
30
- "@fluentui/scripts": "^1.0.0"
30
+ "@fluentui/scripts": "*"
31
31
  },
32
32
  "dependencies": {
33
33
  "@fluentui/react-shared-contexts": "^9.1.4",
34
- "@fluentui/react-tabster": "^9.3.4",
35
- "@fluentui/react-utilities": "^9.3.0",
36
- "@griffel/react": "^1.4.2",
37
- "tslib": "^2.1.0"
34
+ "@fluentui/react-tabster": "^9.3.6",
35
+ "@fluentui/react-utilities": "^9.4.0",
36
+ "@griffel/react": "^1.5.2",
37
+ "tslib": "^2.1.0",
38
+ "use-disposable": "^1.0.1"
38
39
  },
39
40
  "peerDependencies": {
40
41
  "@types/react": ">=16.8.0 <19.0.0",