@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.
- package/CHANGELOG.json +1486 -1
- package/CHANGELOG.md +568 -2
- package/README.md +114 -0
- package/Spec.md +100 -6
- package/dist/react-portal.d.ts +30 -9
- package/lib/Portal.js.map +1 -1
- package/lib/common/isConformant.d.ts +4 -2
- package/lib/common/isConformant.js.map +1 -1
- package/lib/components/Portal/Portal.d.ts +1 -1
- package/lib/components/Portal/Portal.js.map +1 -1
- package/lib/components/Portal/Portal.types.d.ts +11 -6
- package/lib/components/Portal/Portal.types.js.map +1 -1
- package/lib/components/Portal/index.js.map +1 -1
- package/lib/components/Portal/renderPortal.d.ts +2 -2
- package/lib/components/Portal/renderPortal.js +2 -4
- package/lib/components/Portal/renderPortal.js.map +1 -1
- package/lib/components/Portal/usePortal.d.ts +2 -3
- package/lib/components/Portal/usePortal.js +18 -8
- package/lib/components/Portal/usePortal.js.map +1 -1
- package/lib/components/Portal/usePortalMountNode.js +2 -0
- package/lib/components/Portal/usePortalMountNode.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/virtualParent/elementContains.d.ts +7 -0
- package/lib/virtualParent/elementContains.js +26 -0
- package/lib/virtualParent/elementContains.js.map +1 -0
- package/lib/virtualParent/getParent.d.ts +5 -0
- package/lib/virtualParent/getParent.js +9 -0
- package/lib/virtualParent/getParent.js.map +1 -0
- package/lib/virtualParent/getVirtualParent.d.ts +4 -0
- package/lib/virtualParent/getVirtualParent.js +12 -0
- package/lib/virtualParent/getVirtualParent.js.map +1 -0
- package/lib/virtualParent/index.d.ts +5 -0
- package/lib/virtualParent/index.js +6 -0
- package/lib/virtualParent/index.js.map +1 -0
- package/lib/virtualParent/isVirtualElement.d.ts +5 -0
- package/lib/virtualParent/isVirtualElement.js +7 -0
- package/lib/virtualParent/isVirtualElement.js.map +1 -0
- package/lib/virtualParent/setVirtualParent.d.ts +7 -0
- package/lib/virtualParent/setVirtualParent.js +17 -0
- package/lib/virtualParent/setVirtualParent.js.map +1 -0
- package/lib/virtualParent/types.d.ts +5 -0
- package/lib/virtualParent/types.js +2 -0
- package/lib/virtualParent/types.js.map +1 -0
- package/lib-commonjs/Portal.js.map +1 -1
- package/lib-commonjs/common/isConformant.d.ts +4 -2
- package/lib-commonjs/common/isConformant.js.map +1 -1
- package/lib-commonjs/components/Portal/Portal.d.ts +1 -1
- package/lib-commonjs/components/Portal/Portal.js.map +1 -1
- package/lib-commonjs/components/Portal/Portal.types.d.ts +11 -6
- package/lib-commonjs/components/Portal/Portal.types.js.map +1 -1
- package/lib-commonjs/components/Portal/index.js.map +1 -1
- package/lib-commonjs/components/Portal/renderPortal.d.ts +2 -2
- package/lib-commonjs/components/Portal/renderPortal.js +2 -4
- package/lib-commonjs/components/Portal/renderPortal.js.map +1 -1
- package/lib-commonjs/components/Portal/usePortal.d.ts +2 -3
- package/lib-commonjs/components/Portal/usePortal.js +17 -7
- package/lib-commonjs/components/Portal/usePortal.js.map +1 -1
- package/lib-commonjs/components/Portal/usePortalMountNode.js +2 -0
- package/lib-commonjs/components/Portal/usePortalMountNode.js.map +1 -1
- package/lib-commonjs/index.d.ts +1 -0
- package/lib-commonjs/index.js +4 -0
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/virtualParent/elementContains.d.ts +7 -0
- package/lib-commonjs/virtualParent/elementContains.js +30 -0
- package/lib-commonjs/virtualParent/elementContains.js.map +1 -0
- package/lib-commonjs/virtualParent/getParent.d.ts +5 -0
- package/lib-commonjs/virtualParent/getParent.js +13 -0
- package/lib-commonjs/virtualParent/getParent.js.map +1 -0
- package/lib-commonjs/virtualParent/getVirtualParent.d.ts +4 -0
- package/lib-commonjs/virtualParent/getVirtualParent.js +16 -0
- package/lib-commonjs/virtualParent/getVirtualParent.js.map +1 -0
- package/lib-commonjs/virtualParent/index.d.ts +5 -0
- package/lib-commonjs/virtualParent/index.js +9 -0
- package/lib-commonjs/virtualParent/index.js.map +1 -0
- package/lib-commonjs/virtualParent/isVirtualElement.d.ts +5 -0
- package/lib-commonjs/virtualParent/isVirtualElement.js +11 -0
- package/lib-commonjs/virtualParent/isVirtualElement.js.map +1 -0
- package/lib-commonjs/virtualParent/setVirtualParent.d.ts +7 -0
- package/lib-commonjs/virtualParent/setVirtualParent.js +21 -0
- package/lib-commonjs/virtualParent/setVirtualParent.js.map +1 -0
- package/lib-commonjs/virtualParent/types.d.ts +5 -0
- package/lib-commonjs/virtualParent/types.js +3 -0
- package/lib-commonjs/virtualParent/types.js.map +1 -0
- package/package.json +15 -12
- package/config/api-extractor.json +0 -3
- package/config/tests.js +0 -7
- package/etc/react-portal.api.md +0 -32
- package/just.config.ts +0 -3
- package/lib-amd/Portal.d.ts +0 -1
- package/lib-amd/Portal.js +0 -6
- package/lib-amd/Portal.js.map +0 -1
- package/lib-amd/common/isConformant.d.ts +0 -2
- package/lib-amd/common/isConformant.js +0 -14
- package/lib-amd/common/isConformant.js.map +0 -1
- package/lib-amd/components/Portal/Portal.d.ts +0 -6
- package/lib-amd/components/Portal/Portal.js +0 -15
- package/lib-amd/components/Portal/Portal.js.map +0 -1
- package/lib-amd/components/Portal/Portal.types.d.ts +0 -16
- package/lib-amd/components/Portal/Portal.types.js +0 -5
- package/lib-amd/components/Portal/Portal.types.js.map +0 -1
- package/lib-amd/components/Portal/index.d.ts +0 -4
- package/lib-amd/components/Portal/index.js +0 -9
- package/lib-amd/components/Portal/index.js.map +0 -1
- package/lib-amd/components/Portal/renderPortal.d.ts +0 -6
- package/lib-amd/components/Portal/renderPortal.js +0 -16
- package/lib-amd/components/Portal/renderPortal.js.map +0 -1
- package/lib-amd/components/Portal/usePortal.d.ts +0 -10
- package/lib-amd/components/Portal/usePortal.js +0 -23
- package/lib-amd/components/Portal/usePortal.js.map +0 -1
- package/lib-amd/components/Portal/usePortalMountNode.d.ts +0 -10
- package/lib-amd/components/Portal/usePortalMountNode.js +0 -31
- package/lib-amd/components/Portal/usePortalMountNode.js.map +0 -1
- package/lib-amd/index.d.ts +0 -1
- package/lib-amd/index.js +0 -6
- package/lib-amd/index.js.map +0 -1
- package/src/components/Portal/Portal.types.ts +0 -24
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"isVirtualElement.js","sourceRoot":"","sources":["../../src/virtualParent/isVirtualElement.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAqC;IACpE,OAAO,OAAO,IAAI,CAAC,CAAkB,OAAQ,CAAC,QAAQ,CAAC;AACzD,CAAC"}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/**
|
2
|
+
* Sets the virtual parent of an element.
|
3
|
+
*
|
4
|
+
* @param child - Theme element to set the virtual parent
|
5
|
+
* @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship
|
6
|
+
*/
|
7
|
+
export declare function setVirtualParent(child: HTMLElement, parent?: HTMLElement): void;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
/**
|
2
|
+
* Sets the virtual parent of an element.
|
3
|
+
*
|
4
|
+
* @param child - Theme element to set the virtual parent
|
5
|
+
* @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship
|
6
|
+
*/
|
7
|
+
export function setVirtualParent(child, parent) {
|
8
|
+
if (!child) {
|
9
|
+
return;
|
10
|
+
}
|
11
|
+
var virtualChild = child;
|
12
|
+
if (!virtualChild._virtual) {
|
13
|
+
virtualChild._virtual = {};
|
14
|
+
}
|
15
|
+
virtualChild._virtual.parent = parent || undefined;
|
16
|
+
}
|
17
|
+
//# sourceMappingURL=setVirtualParent.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"setVirtualParent.js","sourceRoot":"","sources":["../../src/virtualParent/setVirtualParent.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAkB,EAAE,MAAoB;IACvE,IAAI,CAAC,KAAK,EAAE;QACV,OAAO;KACR;IAED,IAAM,YAAY,GAAmB,KAAK,CAAC;IAE3C,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE;QAC1B,YAAY,CAAC,QAAQ,GAAG,EAAE,CAAC;KAC5B;IAED,YAAY,CAAC,QAAQ,CAAC,MAAM,GAAG,MAAM,IAAI,SAAS,CAAC;AACrD,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/virtualParent/types.ts"],"names":[],"mappings":""}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Portal.js","sourceRoot":"
|
1
|
+
{"version":3,"file":"Portal.js","sourceRoot":"","sources":["../src/Portal.ts"],"names":[],"mappings":";;;AAAA,oEAA0C"}
|
@@ -1,2 +1,4 @@
|
|
1
|
-
import { IsConformantOptions } from '@fluentui/react-conformance';
|
2
|
-
export declare function isConformant(testInfo: Omit<IsConformantOptions
|
1
|
+
import type { IsConformantOptions } from '@fluentui/react-conformance';
|
2
|
+
export declare function isConformant<TProps = {}>(testInfo: Omit<IsConformantOptions<TProps>, 'componentPath'> & {
|
3
|
+
componentPath?: string;
|
4
|
+
}): void;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"isConformant.js","sourceRoot":"
|
1
|
+
{"version":3,"file":"isConformant.js","sourceRoot":"","sources":["../../src/common/isConformant.ts"],"names":[],"mappings":";;;AAAA,iEAA+E;AAG/E,SAAgB,YAAY,CAC1B,QAAyF;IAEzF,IAAM,cAAc,GAAyC;QAC3D,gBAAgB,EAAE,IAAI;QACtB,aAAa,EAAE,MAAO,CAAC,MAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;KAC7D,CAAC;IAEF,gCAAgB,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;AAC7C,CAAC;AATD,oCASC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Portal.js","sourceRoot":"
|
1
|
+
{"version":3,"file":"Portal.js","sourceRoot":"","sources":["../../../src/components/Portal/Portal.tsx"],"names":[],"mappings":";;;AAEA,yCAAwC;AACxC,+CAA8C;AAG9C;;GAEG;AACI,IAAM,MAAM,GAA0B,UAAA,KAAK;IAChD,IAAM,KAAK,GAAG,qBAAS,CAAC,KAAK,CAAC,CAAC;IAE/B,OAAO,2BAAY,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC,CAAC;AAJW,QAAA,MAAM,UAIjB;AAEF,cAAM,CAAC,WAAW,GAAG,QAAQ,CAAC"}
|
@@ -1,16 +1,21 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
export
|
2
|
+
export declare type PortalCommons = {
|
3
3
|
/**
|
4
4
|
* React children
|
5
5
|
*/
|
6
|
-
children
|
6
|
+
children: React.ReactNode;
|
7
7
|
/**
|
8
8
|
* Where the portal children are mounted on DOM
|
9
9
|
* @defaultValue a new element on document.body without any styling
|
10
10
|
*/
|
11
|
-
mountNode
|
12
|
-
}
|
13
|
-
export
|
11
|
+
mountNode: HTMLDivElement | undefined;
|
12
|
+
};
|
13
|
+
export declare type PortalProps = Partial<PortalCommons>;
|
14
|
+
export declare type PortalState = PortalCommons & {
|
14
15
|
/** Indicates if a Portal should be rendered. */
|
15
16
|
shouldRender: boolean;
|
16
|
-
|
17
|
+
/**
|
18
|
+
* Ref to the root span element as virtual parent
|
19
|
+
*/
|
20
|
+
virtualParentRootRef: React.MutableRefObject<HTMLSpanElement | null>;
|
21
|
+
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Portal.types.js","sourceRoot":"
|
1
|
+
{"version":3,"file":"Portal.types.js","sourceRoot":"","sources":["../../../src/components/Portal/Portal.types.ts"],"names":[],"mappings":""}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Portal/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyB;AACzB,yDAA+B;AAC/B,yDAA+B;AAC/B,sDAA4B"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
import { PortalState } from './Portal.types';
|
2
|
+
import type { PortalState } from './Portal.types';
|
3
3
|
/**
|
4
4
|
* Render the final JSX of Portal
|
5
5
|
*/
|
6
|
-
export declare const renderPortal: (state: PortalState) => React.
|
6
|
+
export declare const renderPortal: (state: PortalState) => React.ReactElement;
|
@@ -2,14 +2,12 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.renderPortal = void 0;
|
4
4
|
var ReactDOM = require("react-dom");
|
5
|
+
var React = require("react");
|
5
6
|
/**
|
6
7
|
* Render the final JSX of Portal
|
7
8
|
*/
|
8
9
|
var renderPortal = function (state) {
|
9
|
-
|
10
|
-
return ReactDOM.createPortal(state.children, state.mountNode);
|
11
|
-
}
|
12
|
-
return null;
|
10
|
+
return (React.createElement("span", { hidden: true, ref: state.virtualParentRootRef }, state.shouldRender && state.mountNode && ReactDOM.createPortal(state.children, state.mountNode)));
|
13
11
|
};
|
14
12
|
exports.renderPortal = renderPortal;
|
15
13
|
//# sourceMappingURL=renderPortal.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"renderPortal.js","sourceRoot":"
|
1
|
+
{"version":3,"file":"renderPortal.js","sourceRoot":"","sources":["../../../src/components/Portal/renderPortal.tsx"],"names":[],"mappings":";;;AAAA,oCAAsC;AACtC,6BAA+B;AAG/B;;GAEG;AACI,IAAM,YAAY,GAAG,UAAC,KAAkB;IAC7C,OAAO,CACL,8BAAM,MAAM,QAAC,GAAG,EAAE,KAAK,CAAC,oBAAoB,IACzC,KAAK,CAAC,YAAY,IAAI,KAAK,CAAC,SAAS,IAAI,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,CAC3F,CACR,CAAC;AACJ,CAAC,CAAC;AANW,QAAA,YAAY,gBAMvB"}
|
@@ -1,10 +1,9 @@
|
|
1
|
-
import { PortalProps, PortalState } from './Portal.types';
|
1
|
+
import type { PortalProps, PortalState } from './Portal.types';
|
2
2
|
/**
|
3
3
|
* Create the state required to render Portal.
|
4
4
|
*
|
5
5
|
* The returned state can be modified with hooks such as usePortalStyles, before being passed to renderPortal.
|
6
6
|
*
|
7
7
|
* @param props - props from this instance of Portal
|
8
|
-
* @param defaultProps - (optional) default prop values provided by the implementing type
|
9
8
|
*/
|
10
|
-
export declare const usePortal: (props: PortalProps
|
9
|
+
export declare const usePortal: (props: PortalProps) => PortalState;
|
@@ -1,22 +1,32 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.usePortal = void 0;
|
4
|
+
var React = require("react");
|
4
5
|
var react_utilities_1 = require("@fluentui/react-utilities");
|
5
6
|
var usePortalMountNode_1 = require("./usePortalMountNode");
|
6
|
-
var
|
7
|
+
var index_1 = require("../../virtualParent/index");
|
7
8
|
/**
|
8
9
|
* Create the state required to render Portal.
|
9
10
|
*
|
10
11
|
* The returned state can be modified with hooks such as usePortalStyles, before being passed to renderPortal.
|
11
12
|
*
|
12
13
|
* @param props - props from this instance of Portal
|
13
|
-
* @param defaultProps - (optional) default prop values provided by the implementing type
|
14
14
|
*/
|
15
|
-
var usePortal = function (props
|
16
|
-
var
|
17
|
-
var
|
18
|
-
var fallbackMountNode = usePortalMountNode_1.usePortalMountNode({ disabled: !!
|
19
|
-
state
|
15
|
+
var usePortal = function (props) {
|
16
|
+
var children = props.children, mountNode = props.mountNode;
|
17
|
+
var virtualParentRootRef = React.useRef(null);
|
18
|
+
var fallbackMountNode = usePortalMountNode_1.usePortalMountNode({ disabled: !!mountNode });
|
19
|
+
var state = {
|
20
|
+
children: children,
|
21
|
+
mountNode: mountNode !== null && mountNode !== void 0 ? mountNode : fallbackMountNode,
|
22
|
+
shouldRender: !react_utilities_1.useIsSSR(),
|
23
|
+
virtualParentRootRef: virtualParentRootRef,
|
24
|
+
};
|
25
|
+
React.useEffect(function () {
|
26
|
+
if (state.virtualParentRootRef.current && state.mountNode) {
|
27
|
+
index_1.setVirtualParent(state.mountNode, state.virtualParentRootRef.current);
|
28
|
+
}
|
29
|
+
}, [state.virtualParentRootRef, state.mountNode]);
|
20
30
|
return state;
|
21
31
|
};
|
22
32
|
exports.usePortal = usePortal;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"usePortal.js","sourceRoot":"
|
1
|
+
{"version":3,"file":"usePortal.js","sourceRoot":"","sources":["../../../src/components/Portal/usePortal.ts"],"names":[],"mappings":";;;AAAA,6BAA+B;AAC/B,6DAAqD;AACrD,2DAA0D;AAC1D,mDAA6D;AAG7D;;;;;;GAMG;AACI,IAAM,SAAS,GAAG,UAAC,KAAkB;IAClC,IAAA,QAAQ,GAAgB,KAAK,SAArB,EAAE,SAAS,GAAK,KAAK,UAAV,CAAW;IAEtC,IAAM,oBAAoB,GAAG,KAAK,CAAC,MAAM,CAAkB,IAAI,CAAC,CAAC;IACjE,IAAM,iBAAiB,GAAG,uCAAkB,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;IAExE,IAAM,KAAK,GAAgB;QACzB,QAAQ,UAAA;QACR,SAAS,EAAE,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,iBAAiB;QACzC,YAAY,EAAE,CAAC,0BAAQ,EAAE;QACzB,oBAAoB,sBAAA;KACrB,CAAC;IAEF,KAAK,CAAC,SAAS,CAAC;QACd,IAAI,KAAK,CAAC,oBAAoB,CAAC,OAAO,IAAI,KAAK,CAAC,SAAS,EAAE;YACzD,wBAAgB,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;SACvE;IACH,CAAC,EAAE,CAAC,KAAK,CAAC,oBAAoB,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;IAElD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AApBW,QAAA,SAAS,aAoBpB"}
|
@@ -4,6 +4,7 @@ exports.usePortalMountNode = void 0;
|
|
4
4
|
var React = require("react");
|
5
5
|
var react_utilities_1 = require("@fluentui/react-utilities");
|
6
6
|
var react_shared_contexts_1 = require("@fluentui/react-shared-contexts");
|
7
|
+
var react_tabster_1 = require("@fluentui/react-tabster");
|
7
8
|
/**
|
8
9
|
* Creates a new element on a document.body to mount portals
|
9
10
|
*/
|
@@ -20,6 +21,7 @@ var usePortalMountNode = function (options) {
|
|
20
21
|
targetDocument.body.appendChild(newElement);
|
21
22
|
return newElement;
|
22
23
|
}, [targetDocument, themeClassName, dir, options.disabled]);
|
24
|
+
react_tabster_1.useKeyboardNavAttribute().current = element;
|
23
25
|
react_utilities_1.useIsomorphicLayoutEffect(function () {
|
24
26
|
return function () {
|
25
27
|
var _a;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"usePortalMountNode.js","sourceRoot":"
|
1
|
+
{"version":3,"file":"usePortalMountNode.js","sourceRoot":"","sources":["../../../src/components/Portal/usePortalMountNode.ts"],"names":[],"mappings":";;;AAAA,6BAA+B;AAC/B,6DAAsE;AACtE,yEAA+E;AAC/E,yDAAkE;AASlE;;GAEG;AACI,IAAM,kBAAkB,GAAG,UAAC,OAAkC;IACnE,IAAM,cAAc,GAAG,yCAAiB,EAAE,CAAC;IACrC,IAAA,KAA0B,iCAAS,EAAE,EAAnC,cAAc,oBAAA,EAAE,GAAG,SAAgB,CAAC;IAE5C,IAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC5B,IAAI,cAAc,KAAK,SAAS,IAAI,OAAO,CAAC,QAAQ,EAAE;YACpD,OAAO,SAAS,CAAC;SAClB;QAED,IAAM,UAAU,GAAG,cAAc,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACvD,UAAU,CAAC,YAAY,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QACjD,UAAU,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACpC,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QAE5C,OAAO,UAAU,CAAC;IACpB,CAAC,EAAE,CAAC,cAAc,EAAE,cAAc,EAAE,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE3D,uCAAuB,EAA0C,CAAC,OAAO,GAAG,OAAQ,CAAC;IAEtF,2CAAyB,CAAC;QACxB,OAAO;;YACL,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,0CAAE,WAAW,CAAC,OAAO,EAAE;QAC/C,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AA1BW,QAAA,kBAAkB,sBA0B7B"}
|
package/lib-commonjs/index.d.ts
CHANGED
package/lib-commonjs/index.js
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.setVirtualParent = exports.elementContains = void 0;
|
3
4
|
var tslib_1 = require("tslib");
|
4
5
|
tslib_1.__exportStar(require("./components/Portal/index"), exports);
|
6
|
+
var index_1 = require("./virtualParent/index");
|
7
|
+
Object.defineProperty(exports, "elementContains", { enumerable: true, get: function () { return index_1.elementContains; } });
|
8
|
+
Object.defineProperty(exports, "setVirtualParent", { enumerable: true, get: function () { return index_1.setVirtualParent; } });
|
5
9
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,oEAA0C;AAC1C,+CAA0E;AAAjE,wGAAA,eAAe,OAAA;AAAE,yGAAA,gBAAgB,OAAA"}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/**
|
2
|
+
* Similar functionality to `element.contains` DOM API for use with out of order DOM elements that
|
3
|
+
* checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent
|
4
|
+
*
|
5
|
+
* @returns true if the child can find the parent in its virtual hierarchy
|
6
|
+
*/
|
7
|
+
export declare function elementContains(parent: HTMLElement | null, child: HTMLElement | null): boolean;
|
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.elementContains = void 0;
|
4
|
+
var getParent_1 = require("./getParent");
|
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
|
+
//# sourceMappingURL=elementContains.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"elementContains.js","sourceRoot":"","sources":["../../src/virtualParent/elementContains.ts"],"names":[],"mappings":";;;AAAA,yCAAwC;AACxC;;;;;GAKG;AACH,SAAgB,eAAe,CAAC,MAA0B,EAAE,KAAyB;IACnF,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,EAAE;QACrB,OAAO,KAAK,CAAC;KACd;IAED,IAAI,MAAM,KAAK,KAAK,EAAE;QACpB,OAAO,IAAI,CAAC;KACb;SAAM;QACL,OAAO,KAAK,EAAE;YACZ,IAAM,UAAU,GAAuB,qBAAS,CAAC,KAAK,CAAC,CAAC;YAExD,IAAI,UAAU,KAAK,MAAM,EAAE;gBACzB,OAAO,IAAI,CAAC;aACb;YAED,KAAK,GAAG,UAAU,CAAC;SACpB;KACF;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AApBD,0CAoBC"}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getParent = void 0;
|
4
|
+
var getVirtualParent_1 = require("./getVirtualParent");
|
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
|
+
//# sourceMappingURL=getParent.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getParent.js","sourceRoot":"","sources":["../../src/virtualParent/getParent.ts"],"names":[],"mappings":";;;AAAA,uDAAsD;AAEtD;;;GAGG;AACH,SAAgB,SAAS,CAAC,KAAyB;IACjD,OAAO,CAAC,KAAK,IAAI,mCAAgB,CAAC,KAAK,CAAC,CAAC,KAAK,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAiC,CAAA,CAAC;AACzF,CAAC;AAFD,8BAEC"}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getVirtualParent = void 0;
|
4
|
+
var isVirtualElement_1 = require("./isVirtualElement");
|
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
|
+
//# sourceMappingURL=getVirtualParent.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getVirtualParent.js","sourceRoot":"","sources":["../../src/virtualParent/getVirtualParent.ts"],"names":[],"mappings":";;;AAAA,uDAAsD;AACtD;;GAEG;AACH,SAAgB,gBAAgB,CAAC,KAAkB;IACjD,IAAI,MAA+B,CAAC;IACpC,IAAI,mCAAgB,CAAC,KAAK,CAAC,EAAE;QAC3B,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;KAChC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAND,4CAMC"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
var tslib_1 = require("tslib");
|
4
|
+
tslib_1.__exportStar(require("./elementContains"), exports);
|
5
|
+
tslib_1.__exportStar(require("./getParent"), exports);
|
6
|
+
tslib_1.__exportStar(require("./getVirtualParent"), exports);
|
7
|
+
tslib_1.__exportStar(require("./isVirtualElement"), exports);
|
8
|
+
tslib_1.__exportStar(require("./setVirtualParent"), exports);
|
9
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/virtualParent/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC;AAClC,sDAA4B;AAC5B,6DAAmC;AACnC,6DAAmC;AACnC,6DAAmC"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.isVirtualElement = void 0;
|
4
|
+
/**
|
5
|
+
* Determines whether or not an element has the virtual hierarchy extension.
|
6
|
+
*/
|
7
|
+
function isVirtualElement(element) {
|
8
|
+
return element && !!element._virtual;
|
9
|
+
}
|
10
|
+
exports.isVirtualElement = isVirtualElement;
|
11
|
+
//# sourceMappingURL=isVirtualElement.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"isVirtualElement.js","sourceRoot":"","sources":["../../src/virtualParent/isVirtualElement.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,SAAgB,gBAAgB,CAAC,OAAqC;IACpE,OAAO,OAAO,IAAI,CAAC,CAAkB,OAAQ,CAAC,QAAQ,CAAC;AACzD,CAAC;AAFD,4CAEC"}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/**
|
2
|
+
* Sets the virtual parent of an element.
|
3
|
+
*
|
4
|
+
* @param child - Theme element to set the virtual parent
|
5
|
+
* @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship
|
6
|
+
*/
|
7
|
+
export declare function setVirtualParent(child: HTMLElement, parent?: HTMLElement): void;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.setVirtualParent = void 0;
|
4
|
+
/**
|
5
|
+
* Sets the virtual parent of an element.
|
6
|
+
*
|
7
|
+
* @param child - Theme element to set the virtual parent
|
8
|
+
* @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship
|
9
|
+
*/
|
10
|
+
function setVirtualParent(child, parent) {
|
11
|
+
if (!child) {
|
12
|
+
return;
|
13
|
+
}
|
14
|
+
var virtualChild = child;
|
15
|
+
if (!virtualChild._virtual) {
|
16
|
+
virtualChild._virtual = {};
|
17
|
+
}
|
18
|
+
virtualChild._virtual.parent = parent || undefined;
|
19
|
+
}
|
20
|
+
exports.setVirtualParent = setVirtualParent;
|
21
|
+
//# sourceMappingURL=setVirtualParent.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"setVirtualParent.js","sourceRoot":"","sources":["../../src/virtualParent/setVirtualParent.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAC,KAAkB,EAAE,MAAoB;IACvE,IAAI,CAAC,KAAK,EAAE;QACV,OAAO;KACR;IAED,IAAM,YAAY,GAAmB,KAAK,CAAC;IAE3C,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE;QAC1B,YAAY,CAAC,QAAQ,GAAG,EAAE,CAAC;KAC5B;IAED,YAAY,CAAC,QAAQ,CAAC,MAAM,GAAG,MAAM,IAAI,SAAS,CAAC;AACrD,CAAC;AAZD,4CAYC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/virtualParent/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-portal",
|
3
|
-
"version": "9.0.0-
|
3
|
+
"version": "9.0.0-nightly.25435def33.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",
|
@@ -13,19 +13,21 @@
|
|
13
13
|
"license": "MIT",
|
14
14
|
"scripts": {
|
15
15
|
"build": "just-scripts build",
|
16
|
+
"bundle-size": "bundle-size measure",
|
16
17
|
"clean": "just-scripts clean",
|
17
18
|
"code-style": "just-scripts code-style",
|
18
19
|
"just": "just-scripts",
|
19
20
|
"lint": "just-scripts lint",
|
20
|
-
"start": "
|
21
|
-
"
|
22
|
-
"
|
23
|
-
"
|
21
|
+
"start": "yarn storybook",
|
22
|
+
"test": "jest",
|
23
|
+
"docs": "api-extractor run --config=config/api-extractor.local.json --local",
|
24
|
+
"build:local": "tsc -p . --module esnext --emitDeclarationOnly && node ../../scripts/typescript/normalize-import --output dist/react-portal/src && yarn docs",
|
25
|
+
"storybook": "start-storybook"
|
24
26
|
},
|
25
27
|
"devDependencies": {
|
26
|
-
"@fluentui/eslint-plugin": "
|
27
|
-
"@fluentui/jest-serializer-make-styles": "
|
28
|
-
"@fluentui/react-conformance": "
|
28
|
+
"@fluentui/eslint-plugin": "*",
|
29
|
+
"@fluentui/jest-serializer-make-styles": "9.0.0-nightly.25435def33.0",
|
30
|
+
"@fluentui/react-conformance": "*",
|
29
31
|
"@fluentui/scripts": "^1.0.0",
|
30
32
|
"@types/enzyme": "3.10.3",
|
31
33
|
"@types/enzyme-adapter-react-16": "1.0.3",
|
@@ -39,9 +41,10 @@
|
|
39
41
|
"react-test-renderer": "^16.3.0"
|
40
42
|
},
|
41
43
|
"dependencies": {
|
42
|
-
"@fluentui/react-make-styles": "
|
43
|
-
"@fluentui/react-shared-contexts": "
|
44
|
-
"@fluentui/react-
|
44
|
+
"@fluentui/react-make-styles": "9.0.0-nightly.25435def33.0",
|
45
|
+
"@fluentui/react-shared-contexts": "9.0.0-nightly.25435def33.0",
|
46
|
+
"@fluentui/react-tabster": "9.0.0-nightly.25435def33.0",
|
47
|
+
"@fluentui/react-utilities": "9.0.0-nightly.25435def33.0",
|
45
48
|
"tslib": "^2.1.0"
|
46
49
|
},
|
47
50
|
"peerDependencies": {
|
@@ -51,7 +54,7 @@
|
|
51
54
|
"react-dom": ">=16.8.0 <18.0.0"
|
52
55
|
},
|
53
56
|
"beachball": {
|
54
|
-
"tag": "
|
57
|
+
"tag": "beta",
|
55
58
|
"disallowedChangeTypes": [
|
56
59
|
"major",
|
57
60
|
"minor",
|
package/config/tests.js
DELETED
package/etc/react-portal.api.md
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
## API Report File for "@fluentui/react-portal"
|
2
|
-
|
3
|
-
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
4
|
-
|
5
|
-
```ts
|
6
|
-
|
7
|
-
import * as React_2 from 'react';
|
8
|
-
|
9
|
-
// @public
|
10
|
-
export const Portal: React_2.FC<PortalProps>;
|
11
|
-
|
12
|
-
// @public (undocumented)
|
13
|
-
export interface PortalProps {
|
14
|
-
children?: React_2.ReactNode;
|
15
|
-
mountNode?: HTMLDivElement | null;
|
16
|
-
}
|
17
|
-
|
18
|
-
// @public (undocumented)
|
19
|
-
export interface PortalState extends PortalProps {
|
20
|
-
shouldRender: boolean;
|
21
|
-
}
|
22
|
-
|
23
|
-
// @public
|
24
|
-
export const renderPortal: (state: PortalState) => React_2.ReactPortal | null;
|
25
|
-
|
26
|
-
// @public
|
27
|
-
export const usePortal: (props: PortalProps, defaultProps?: PortalProps | undefined) => PortalState;
|
28
|
-
|
29
|
-
|
30
|
-
// (No @packageDocumentation comment for this package)
|
31
|
-
|
32
|
-
```
|
package/just.config.ts
DELETED
package/lib-amd/Portal.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './components/Portal/index';
|
package/lib-amd/Portal.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=Portal.js.map
|
package/lib-amd/Portal.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"Portal.js","sourceRoot":"../src/","sources":["Portal.ts"],"names":[],"mappings":";;;IAAA,uCAA0C","sourcesContent":["export * from './components/Portal/index';\n"]}
|