@fluentui/react-portal 9.0.0-alpha.8 → 9.0.0-nightly.25435def33.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. package/CHANGELOG.json +1486 -1
  2. package/CHANGELOG.md +568 -2
  3. package/README.md +114 -0
  4. package/Spec.md +100 -6
  5. package/dist/react-portal.d.ts +30 -9
  6. package/lib/Portal.js.map +1 -1
  7. package/lib/common/isConformant.d.ts +4 -2
  8. package/lib/common/isConformant.js.map +1 -1
  9. package/lib/components/Portal/Portal.d.ts +1 -1
  10. package/lib/components/Portal/Portal.js.map +1 -1
  11. package/lib/components/Portal/Portal.types.d.ts +11 -6
  12. package/lib/components/Portal/Portal.types.js.map +1 -1
  13. package/lib/components/Portal/index.js.map +1 -1
  14. package/lib/components/Portal/renderPortal.d.ts +2 -2
  15. package/lib/components/Portal/renderPortal.js +2 -4
  16. package/lib/components/Portal/renderPortal.js.map +1 -1
  17. package/lib/components/Portal/usePortal.d.ts +2 -3
  18. package/lib/components/Portal/usePortal.js +18 -8
  19. package/lib/components/Portal/usePortal.js.map +1 -1
  20. package/lib/components/Portal/usePortalMountNode.js +2 -0
  21. package/lib/components/Portal/usePortalMountNode.js.map +1 -1
  22. package/lib/index.d.ts +1 -0
  23. package/lib/index.js +1 -0
  24. package/lib/index.js.map +1 -1
  25. package/lib/tsdoc-metadata.json +1 -1
  26. package/lib/virtualParent/elementContains.d.ts +7 -0
  27. package/lib/virtualParent/elementContains.js +26 -0
  28. package/lib/virtualParent/elementContains.js.map +1 -0
  29. package/lib/virtualParent/getParent.d.ts +5 -0
  30. package/lib/virtualParent/getParent.js +9 -0
  31. package/lib/virtualParent/getParent.js.map +1 -0
  32. package/lib/virtualParent/getVirtualParent.d.ts +4 -0
  33. package/lib/virtualParent/getVirtualParent.js +12 -0
  34. package/lib/virtualParent/getVirtualParent.js.map +1 -0
  35. package/lib/virtualParent/index.d.ts +5 -0
  36. package/lib/virtualParent/index.js +6 -0
  37. package/lib/virtualParent/index.js.map +1 -0
  38. package/lib/virtualParent/isVirtualElement.d.ts +5 -0
  39. package/lib/virtualParent/isVirtualElement.js +7 -0
  40. package/lib/virtualParent/isVirtualElement.js.map +1 -0
  41. package/lib/virtualParent/setVirtualParent.d.ts +7 -0
  42. package/lib/virtualParent/setVirtualParent.js +17 -0
  43. package/lib/virtualParent/setVirtualParent.js.map +1 -0
  44. package/lib/virtualParent/types.d.ts +5 -0
  45. package/lib/virtualParent/types.js +2 -0
  46. package/lib/virtualParent/types.js.map +1 -0
  47. package/lib-commonjs/Portal.js.map +1 -1
  48. package/lib-commonjs/common/isConformant.d.ts +4 -2
  49. package/lib-commonjs/common/isConformant.js.map +1 -1
  50. package/lib-commonjs/components/Portal/Portal.d.ts +1 -1
  51. package/lib-commonjs/components/Portal/Portal.js.map +1 -1
  52. package/lib-commonjs/components/Portal/Portal.types.d.ts +11 -6
  53. package/lib-commonjs/components/Portal/Portal.types.js.map +1 -1
  54. package/lib-commonjs/components/Portal/index.js.map +1 -1
  55. package/lib-commonjs/components/Portal/renderPortal.d.ts +2 -2
  56. package/lib-commonjs/components/Portal/renderPortal.js +2 -4
  57. package/lib-commonjs/components/Portal/renderPortal.js.map +1 -1
  58. package/lib-commonjs/components/Portal/usePortal.d.ts +2 -3
  59. package/lib-commonjs/components/Portal/usePortal.js +17 -7
  60. package/lib-commonjs/components/Portal/usePortal.js.map +1 -1
  61. package/lib-commonjs/components/Portal/usePortalMountNode.js +2 -0
  62. package/lib-commonjs/components/Portal/usePortalMountNode.js.map +1 -1
  63. package/lib-commonjs/index.d.ts +1 -0
  64. package/lib-commonjs/index.js +4 -0
  65. package/lib-commonjs/index.js.map +1 -1
  66. package/lib-commonjs/virtualParent/elementContains.d.ts +7 -0
  67. package/lib-commonjs/virtualParent/elementContains.js +30 -0
  68. package/lib-commonjs/virtualParent/elementContains.js.map +1 -0
  69. package/lib-commonjs/virtualParent/getParent.d.ts +5 -0
  70. package/lib-commonjs/virtualParent/getParent.js +13 -0
  71. package/lib-commonjs/virtualParent/getParent.js.map +1 -0
  72. package/lib-commonjs/virtualParent/getVirtualParent.d.ts +4 -0
  73. package/lib-commonjs/virtualParent/getVirtualParent.js +16 -0
  74. package/lib-commonjs/virtualParent/getVirtualParent.js.map +1 -0
  75. package/lib-commonjs/virtualParent/index.d.ts +5 -0
  76. package/lib-commonjs/virtualParent/index.js +9 -0
  77. package/lib-commonjs/virtualParent/index.js.map +1 -0
  78. package/lib-commonjs/virtualParent/isVirtualElement.d.ts +5 -0
  79. package/lib-commonjs/virtualParent/isVirtualElement.js +11 -0
  80. package/lib-commonjs/virtualParent/isVirtualElement.js.map +1 -0
  81. package/lib-commonjs/virtualParent/setVirtualParent.d.ts +7 -0
  82. package/lib-commonjs/virtualParent/setVirtualParent.js +21 -0
  83. package/lib-commonjs/virtualParent/setVirtualParent.js.map +1 -0
  84. package/lib-commonjs/virtualParent/types.d.ts +5 -0
  85. package/lib-commonjs/virtualParent/types.js +3 -0
  86. package/lib-commonjs/virtualParent/types.js.map +1 -0
  87. package/package.json +15 -12
  88. package/config/api-extractor.json +0 -3
  89. package/config/tests.js +0 -7
  90. package/etc/react-portal.api.md +0 -32
  91. package/just.config.ts +0 -3
  92. package/lib-amd/Portal.d.ts +0 -1
  93. package/lib-amd/Portal.js +0 -6
  94. package/lib-amd/Portal.js.map +0 -1
  95. package/lib-amd/common/isConformant.d.ts +0 -2
  96. package/lib-amd/common/isConformant.js +0 -14
  97. package/lib-amd/common/isConformant.js.map +0 -1
  98. package/lib-amd/components/Portal/Portal.d.ts +0 -6
  99. package/lib-amd/components/Portal/Portal.js +0 -15
  100. package/lib-amd/components/Portal/Portal.js.map +0 -1
  101. package/lib-amd/components/Portal/Portal.types.d.ts +0 -16
  102. package/lib-amd/components/Portal/Portal.types.js +0 -5
  103. package/lib-amd/components/Portal/Portal.types.js.map +0 -1
  104. package/lib-amd/components/Portal/index.d.ts +0 -4
  105. package/lib-amd/components/Portal/index.js +0 -9
  106. package/lib-amd/components/Portal/index.js.map +0 -1
  107. package/lib-amd/components/Portal/renderPortal.d.ts +0 -6
  108. package/lib-amd/components/Portal/renderPortal.js +0 -16
  109. package/lib-amd/components/Portal/renderPortal.js.map +0 -1
  110. package/lib-amd/components/Portal/usePortal.d.ts +0 -10
  111. package/lib-amd/components/Portal/usePortal.js +0 -23
  112. package/lib-amd/components/Portal/usePortal.js.map +0 -1
  113. package/lib-amd/components/Portal/usePortalMountNode.d.ts +0 -10
  114. package/lib-amd/components/Portal/usePortalMountNode.js +0 -31
  115. package/lib-amd/components/Portal/usePortalMountNode.js.map +0 -1
  116. package/lib-amd/index.d.ts +0 -1
  117. package/lib-amd/index.js +0 -6
  118. package/lib-amd/index.js.map +0 -1
  119. package/src/components/Portal/Portal.types.ts +0 -24
@@ -1,2 +0,0 @@
1
- import { IsConformantOptions } from '@fluentui/react-conformance';
2
- export declare function isConformant(testInfo: Omit<IsConformantOptions, 'componentPath'>): void;
@@ -1,14 +0,0 @@
1
- define(["require", "exports", "@fluentui/react-conformance"], function (require, exports, react_conformance_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.isConformant = void 0;
5
- function isConformant(testInfo) {
6
- var defaultOptions = {
7
- asPropHandlesRef: true,
8
- componentPath: module.parent.filename.replace('.test', ''),
9
- };
10
- react_conformance_1.isConformant(defaultOptions, testInfo);
11
- }
12
- exports.isConformant = isConformant;
13
- });
14
- //# sourceMappingURL=isConformant.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isConformant.js","sourceRoot":"../src/","sources":["common/isConformant.ts"],"names":[],"mappings":";;;;IAEA,SAAgB,YAAY,CAAC,QAAoD;QAC/E,IAAM,cAAc,GAAG;YACrB,gBAAgB,EAAE,IAAI;YACtB,aAAa,EAAE,MAAO,CAAC,MAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;SAC7D,CAAC;QAEF,gCAAgB,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAPD,oCAOC","sourcesContent":["import { isConformant as baseIsConformant, IsConformantOptions } from '@fluentui/react-conformance';\n\nexport function isConformant(testInfo: Omit<IsConformantOptions, 'componentPath'>) {\n const defaultOptions = {\n asPropHandlesRef: true,\n componentPath: module!.parent!.filename.replace('.test', ''),\n };\n\n baseIsConformant(defaultOptions, testInfo);\n}\n"]}
@@ -1,6 +0,0 @@
1
- import * as React from 'react';
2
- import { PortalProps } from './Portal.types';
3
- /**
4
- * Component that renders children in a React portal
5
- */
6
- export declare const Portal: React.FC<PortalProps>;
@@ -1,15 +0,0 @@
1
- define(["require", "exports", "./usePortal", "./renderPortal"], function (require, exports, usePortal_1, renderPortal_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.Portal = void 0;
5
- /**
6
- * Component that renders children in a React portal
7
- */
8
- var Portal = function (props) {
9
- var state = usePortal_1.usePortal(props);
10
- return renderPortal_1.renderPortal(state);
11
- };
12
- exports.Portal = Portal;
13
- exports.Portal.displayName = 'Portal';
14
- });
15
- //# sourceMappingURL=Portal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Portal.js","sourceRoot":"../src/","sources":["components/Portal/Portal.tsx"],"names":[],"mappings":";;;;IAMA;;OAEG;IACI,IAAM,MAAM,GAA0B,UAAA,KAAK;QAChD,IAAM,KAAK,GAAG,qBAAS,CAAC,KAAK,CAAC,CAAC;QAE/B,OAAO,2BAAY,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC,CAAC;IAJW,QAAA,MAAM,UAIjB;IAEF,cAAM,CAAC,WAAW,GAAG,QAAQ,CAAC","sourcesContent":["import * as React from 'react';\n\nimport { usePortal } from './usePortal';\nimport { PortalProps } from './Portal.types';\nimport { renderPortal } from './renderPortal';\n\n/**\n * Component that renders children in a React portal\n */\nexport const Portal: React.FC<PortalProps> = props => {\n const state = usePortal(props);\n\n return renderPortal(state);\n};\n\nPortal.displayName = 'Portal';\n"]}
@@ -1,16 +0,0 @@
1
- import * as React from 'react';
2
- export interface PortalProps {
3
- /**
4
- * React children
5
- */
6
- children?: React.ReactNode;
7
- /**
8
- * Where the portal children are mounted on DOM
9
- * @defaultValue a new element on document.body without any styling
10
- */
11
- mountNode?: HTMLDivElement | null;
12
- }
13
- export interface PortalState extends PortalProps {
14
- /** Indicates if a Portal should be rendered. */
15
- shouldRender: boolean;
16
- }
@@ -1,5 +0,0 @@
1
- define(["require", "exports"], function (require, exports) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- });
5
- //# sourceMappingURL=Portal.types.js.map
@@ -1 +0,0 @@
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 interface PortalProps {\n /**\n * React children\n */\n children?: React.ReactNode;\n /**\n * Where the portal children are mounted on DOM\n * @defaultValue a new element on document.body without any styling\n */\n mountNode?: HTMLDivElement | null;\n\n /**\n * React events should not bubble up the portal\n */\n // TODO clarify if this is still needed\n // disableEventBubbling?: 'first' | 'last';\n}\n\nexport interface PortalState extends PortalProps {\n /** Indicates if a Portal should be rendered. */\n shouldRender: boolean;\n}\n"]}
@@ -1,4 +0,0 @@
1
- export * from './Portal';
2
- export * from './Portal.types';
3
- export * from './renderPortal';
4
- export * from './usePortal';
@@ -1,9 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["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"]}
@@ -1,6 +0,0 @@
1
- import * as React from 'react';
2
- import { PortalState } from './Portal.types';
3
- /**
4
- * Render the final JSX of Portal
5
- */
6
- export declare const renderPortal: (state: PortalState) => React.ReactPortal | null;
@@ -1,16 +0,0 @@
1
- define(["require", "exports", "react-dom"], function (require, exports, ReactDOM) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.renderPortal = void 0;
5
- /**
6
- * Render the final JSX of Portal
7
- */
8
- var renderPortal = function (state) {
9
- if (state.shouldRender && state.mountNode) {
10
- return ReactDOM.createPortal(state.children, state.mountNode);
11
- }
12
- return null;
13
- };
14
- exports.renderPortal = renderPortal;
15
- });
16
- //# sourceMappingURL=renderPortal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"renderPortal.js","sourceRoot":"../src/","sources":["components/Portal/renderPortal.tsx"],"names":[],"mappings":";;;;IAIA;;OAEG;IACI,IAAM,YAAY,GAAG,UAAC,KAAkB;QAC7C,IAAI,KAAK,CAAC,YAAY,IAAI,KAAK,CAAC,SAAS,EAAE;YACzC,OAAO,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;SAC/D;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IANW,QAAA,YAAY,gBAMvB","sourcesContent":["import * as ReactDOM from 'react-dom';\nimport * as React from 'react';\nimport { PortalState } from './Portal.types';\n\n/**\n * Render the final JSX of Portal\n */\nexport const renderPortal = (state: PortalState): React.ReactPortal | null => {\n if (state.shouldRender && state.mountNode) {\n return ReactDOM.createPortal(state.children, state.mountNode);\n }\n\n return null;\n};\n"]}
@@ -1,10 +0,0 @@
1
- import { PortalProps, PortalState } from './Portal.types';
2
- /**
3
- * Create the state required to render Portal.
4
- *
5
- * The returned state can be modified with hooks such as usePortalStyles, before being passed to renderPortal.
6
- *
7
- * @param props - props from this instance of Portal
8
- * @param defaultProps - (optional) default prop values provided by the implementing type
9
- */
10
- export declare const usePortal: (props: PortalProps, defaultProps?: PortalProps | undefined) => PortalState;
@@ -1,23 +0,0 @@
1
- define(["require", "exports", "@fluentui/react-utilities", "./usePortalMountNode"], function (require, exports, react_utilities_1, usePortalMountNode_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.usePortal = void 0;
5
- var mergeProps = react_utilities_1.makeMergeProps();
6
- /**
7
- * Create the state required to render Portal.
8
- *
9
- * The returned state can be modified with hooks such as usePortalStyles, before being passed to renderPortal.
10
- *
11
- * @param props - props from this instance of Portal
12
- * @param defaultProps - (optional) default prop values provided by the implementing type
13
- */
14
- var usePortal = function (props, defaultProps) {
15
- var _a;
16
- var state = mergeProps({ shouldRender: !react_utilities_1.useIsSSR() }, defaultProps, props);
17
- var fallbackMountNode = usePortalMountNode_1.usePortalMountNode({ disabled: !!state.mountNode });
18
- state.mountNode = (_a = state.mountNode) !== null && _a !== void 0 ? _a : fallbackMountNode;
19
- return state;
20
- };
21
- exports.usePortal = usePortal;
22
- });
23
- //# sourceMappingURL=usePortal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usePortal.js","sourceRoot":"../src/","sources":["components/Portal/usePortal.ts"],"names":[],"mappings":";;;;IAKA,IAAM,UAAU,GAAG,gCAAc,EAAe,CAAC;IAEjD;;;;;;;OAOG;IACI,IAAM,SAAS,GAAG,UAAC,KAAkB,EAAE,YAA0B;;QACtE,IAAM,KAAK,GAAG,UAAU,CAAC,EAAE,YAAY,EAAE,CAAC,0BAAQ,EAAE,EAAE,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;QAC7E,IAAM,iBAAiB,GAAG,uCAAkB,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;QAE9E,KAAK,CAAC,SAAS,SAAG,KAAK,CAAC,SAAS,mCAAI,iBAAiB,CAAC;QAEvD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IAPW,QAAA,SAAS,aAOpB","sourcesContent":["import { makeMergeProps, useIsSSR } from '@fluentui/react-utilities';\n\nimport { PortalProps, PortalState } from './Portal.types';\nimport { usePortalMountNode } from './usePortalMountNode';\n\nconst mergeProps = makeMergeProps<PortalState>();\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.\n *\n * @param props - props from this instance of Portal\n * @param defaultProps - (optional) default prop values provided by the implementing type\n */\nexport const usePortal = (props: PortalProps, defaultProps?: PortalProps): PortalState => {\n const state = mergeProps({ shouldRender: !useIsSSR() }, defaultProps, props);\n const fallbackMountNode = usePortalMountNode({ disabled: !!state.mountNode });\n\n state.mountNode = state.mountNode ?? fallbackMountNode;\n\n return state;\n};\n"]}
@@ -1,10 +0,0 @@
1
- export declare type UsePortalMountNodeOptions = {
2
- /**
3
- * Since hooks cannot be called conditionally use this flag to disable creating the node
4
- */
5
- disabled?: boolean;
6
- };
7
- /**
8
- * Creates a new element on a document.body to mount portals
9
- */
10
- export declare const usePortalMountNode: (options: UsePortalMountNodeOptions) => HTMLDivElement | undefined;
@@ -1,31 +0,0 @@
1
- define(["require", "exports", "react", "@fluentui/react-utilities", "@fluentui/react-shared-contexts"], function (require, exports, React, react_utilities_1, react_shared_contexts_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.usePortalMountNode = void 0;
5
- /**
6
- * Creates a new element on a document.body to mount portals
7
- */
8
- var usePortalMountNode = function (options) {
9
- var themeClassName = react_shared_contexts_1.useThemeClassName();
10
- var _a = react_shared_contexts_1.useFluent(), targetDocument = _a.targetDocument, dir = _a.dir;
11
- var element = React.useMemo(function () {
12
- if (targetDocument === undefined || options.disabled) {
13
- return undefined;
14
- }
15
- var newElement = targetDocument.createElement('div');
16
- newElement.setAttribute('class', themeClassName);
17
- newElement.setAttribute('dir', dir);
18
- targetDocument.body.appendChild(newElement);
19
- return newElement;
20
- }, [targetDocument, themeClassName, dir, options.disabled]);
21
- react_utilities_1.useIsomorphicLayoutEffect(function () {
22
- return function () {
23
- var _a;
24
- (_a = element === null || element === void 0 ? void 0 : element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(element);
25
- };
26
- }, [element]);
27
- return element;
28
- };
29
- exports.usePortalMountNode = usePortalMountNode;
30
- });
31
- //# sourceMappingURL=usePortalMountNode.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usePortalMountNode.js","sourceRoot":"../src/","sources":["components/Portal/usePortalMountNode.ts"],"names":[],"mappings":";;;;IAWA;;OAEG;IACI,IAAM,kBAAkB,GAAG,UAAC,OAAkC;QACnE,IAAM,cAAc,GAAG,yCAAiB,EAAE,CAAC;QACrC,IAAA,KAA0B,iCAAS,EAAE,EAAnC,cAAc,oBAAA,EAAE,GAAG,SAAgB,CAAC;QAE5C,IAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;YAC5B,IAAI,cAAc,KAAK,SAAS,IAAI,OAAO,CAAC,QAAQ,EAAE;gBACpD,OAAO,SAAS,CAAC;aAClB;YAED,IAAM,UAAU,GAAG,cAAc,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YACvD,UAAU,CAAC,YAAY,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;YACjD,UAAU,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YACpC,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;YAE5C,OAAO,UAAU,CAAC;QACpB,CAAC,EAAE,CAAC,cAAc,EAAE,cAAc,EAAE,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;QAE5D,2CAAyB,CAAC;YACxB,OAAO;;gBACL,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,0CAAE,WAAW,CAAC,OAAO,EAAE;YAC/C,CAAC,CAAC;QACJ,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;QAEd,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;IAxBW,QAAA,kBAAkB,sBAwB7B","sourcesContent":["import * as React from 'react';\nimport { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport { useThemeClassName, useFluent } from '@fluentui/react-shared-contexts';\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\n/**\n * Creates a new element on a document.body to mount portals\n */\nexport const usePortalMountNode = (options: UsePortalMountNodeOptions) => {\n const themeClassName = useThemeClassName();\n const { targetDocument, dir } = useFluent();\n\n const element = React.useMemo(() => {\n if (targetDocument === undefined || options.disabled) {\n return undefined;\n }\n\n const newElement = targetDocument.createElement('div');\n newElement.setAttribute('class', themeClassName);\n newElement.setAttribute('dir', dir);\n targetDocument.body.appendChild(newElement);\n\n return newElement;\n }, [targetDocument, themeClassName, dir, options.disabled]);\n\n useIsomorphicLayoutEffect(() => {\n return () => {\n element?.parentElement?.removeChild(element);\n };\n }, [element]);\n\n return element;\n};\n"]}
@@ -1 +0,0 @@
1
- export * from './components/Portal/index';
package/lib-amd/index.js DELETED
@@ -1,6 +0,0 @@
1
- define(["require", "exports", "tslib", "./components/Portal/index"], function (require, exports, tslib_1, index_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- tslib_1.__exportStar(index_1, exports);
5
- });
6
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":";;;IAAA,uCAA0C","sourcesContent":["export * from './components/Portal/index';\n"]}
@@ -1,24 +0,0 @@
1
- import * as React from 'react';
2
-
3
- export interface PortalProps {
4
- /**
5
- * React children
6
- */
7
- children?: React.ReactNode;
8
- /**
9
- * Where the portal children are mounted on DOM
10
- * @defaultValue a new element on document.body without any styling
11
- */
12
- mountNode?: HTMLDivElement | null;
13
-
14
- /**
15
- * React events should not bubble up the portal
16
- */
17
- // TODO clarify if this is still needed
18
- // disableEventBubbling?: 'first' | 'last';
19
- }
20
-
21
- export interface PortalState extends PortalProps {
22
- /** Indicates if a Portal should be rendered. */
23
- shouldRender: boolean;
24
- }