@fluentui/react-portal 9.0.0-beta.4 → 9.0.0-beta.5
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +59 -6
- package/CHANGELOG.md +21 -7
- package/lib/components/Portal/Portal.js +3 -2
- package/lib/components/Portal/Portal.js.map +1 -1
- package/lib/components/Portal/renderPortal.js +6 -2
- package/lib/components/Portal/renderPortal.js.map +1 -1
- package/lib/components/Portal/usePortal.js +22 -16
- package/lib/components/Portal/usePortal.js.map +1 -1
- package/lib/components/Portal/usePortalMountNode.js +27 -21
- package/lib/components/Portal/usePortalMountNode.js.map +1 -1
- package/lib/virtualParent/elementContains.js +18 -14
- package/lib/virtualParent/elementContains.js.map +1 -1
- package/lib/virtualParent/getParent.js +2 -1
- package/lib/virtualParent/getParent.js.map +1 -1
- package/lib/virtualParent/getVirtualParent.js +8 -5
- package/lib/virtualParent/getVirtualParent.js.map +1 -1
- package/lib/virtualParent/isVirtualElement.js +1 -1
- package/lib/virtualParent/isVirtualElement.js.map +1 -1
- package/lib/virtualParent/setVirtualParent.js +11 -8
- package/lib/virtualParent/setVirtualParent.js.map +1 -1
- package/lib-commonjs/Portal.js +7 -2
- package/lib-commonjs/Portal.js.map +1 -1
- package/lib-commonjs/components/Portal/Portal.js +13 -5
- package/lib-commonjs/components/Portal/Portal.js.map +1 -1
- package/lib-commonjs/components/Portal/Portal.types.js +4 -1
- package/lib-commonjs/components/Portal/Portal.types.js.map +1 -1
- package/lib-commonjs/components/Portal/index.js +10 -2
- package/lib-commonjs/components/Portal/index.js.map +1 -1
- package/lib-commonjs/components/Portal/renderPortal.js +16 -5
- package/lib-commonjs/components/Portal/renderPortal.js.map +1 -1
- package/lib-commonjs/components/Portal/usePortal.js +36 -21
- package/lib-commonjs/components/Portal/usePortal.js.map +1 -1
- package/lib-commonjs/components/Portal/usePortalMountNode.js +41 -26
- package/lib-commonjs/components/Portal/usePortalMountNode.js.map +1 -1
- package/lib-commonjs/index.js +22 -5
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/virtualParent/elementContains.js +26 -16
- package/lib-commonjs/virtualParent/elementContains.js.map +1 -1
- package/lib-commonjs/virtualParent/getParent.js +10 -3
- package/lib-commonjs/virtualParent/getParent.js.map +1 -1
- package/lib-commonjs/virtualParent/getVirtualParent.js +16 -7
- package/lib-commonjs/virtualParent/getVirtualParent.js.map +1 -1
- package/lib-commonjs/virtualParent/index.js +11 -2
- package/lib-commonjs/virtualParent/index.js.map +1 -1
- package/lib-commonjs/virtualParent/isVirtualElement.js +7 -2
- package/lib-commonjs/virtualParent/isVirtualElement.js.map +1 -1
- package/lib-commonjs/virtualParent/setVirtualParent.js +17 -9
- package/lib-commonjs/virtualParent/setVirtualParent.js.map +1 -1
- package/lib-commonjs/virtualParent/types.js +4 -1
- package/lib-commonjs/virtualParent/types.js.map +1 -1
- package/package.json +11 -9
- package/lib/common/isConformant.d.ts +0 -4
- package/lib/common/isConformant.js +0 -9
- package/lib/common/isConformant.js.map +0 -1
- package/lib-commonjs/common/isConformant.d.ts +0 -4
- package/lib-commonjs/common/isConformant.js +0 -13
- package/lib-commonjs/common/isConformant.js.map +0 -1
package/CHANGELOG.json
CHANGED
@@ -2,7 +2,60 @@
|
|
2
2
|
"name": "@fluentui/react-portal",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
5
|
+
"date": "Thu, 25 Nov 2021 08:31:33 GMT",
|
6
|
+
"tag": "@fluentui/react-portal_v9.0.0-beta.5",
|
7
|
+
"version": "9.0.0-beta.5",
|
8
|
+
"comments": {
|
9
|
+
"none": [
|
10
|
+
{
|
11
|
+
"author": "lingfangao@hotmail.com",
|
12
|
+
"package": "@fluentui/react-portal",
|
13
|
+
"commit": "8a141d14f3a14de2e1c4691dad908622f310a9d1",
|
14
|
+
"comment": "Migrate package to use solution tsconfigs"
|
15
|
+
}
|
16
|
+
],
|
17
|
+
"prerelease": [
|
18
|
+
{
|
19
|
+
"author": "beachball",
|
20
|
+
"package": "@fluentui/react-portal",
|
21
|
+
"comment": "Bump @fluentui/react-make-styles to v9.0.0-beta.4",
|
22
|
+
"commit": "281e8820669214c1ffb9bc75e9b719a3b27fa9b6"
|
23
|
+
},
|
24
|
+
{
|
25
|
+
"author": "beachball",
|
26
|
+
"package": "@fluentui/react-portal",
|
27
|
+
"comment": "Bump @fluentui/react-shared-contexts to v9.0.0-beta.4",
|
28
|
+
"commit": "281e8820669214c1ffb9bc75e9b719a3b27fa9b6"
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"author": "beachball",
|
32
|
+
"package": "@fluentui/react-portal",
|
33
|
+
"comment": "Bump @fluentui/react-tabster to v9.0.0-beta.5",
|
34
|
+
"commit": "281e8820669214c1ffb9bc75e9b719a3b27fa9b6"
|
35
|
+
},
|
36
|
+
{
|
37
|
+
"author": "beachball",
|
38
|
+
"package": "@fluentui/react-portal",
|
39
|
+
"comment": "Bump @fluentui/react-utilities to v9.0.0-beta.4",
|
40
|
+
"commit": "281e8820669214c1ffb9bc75e9b719a3b27fa9b6"
|
41
|
+
},
|
42
|
+
{
|
43
|
+
"author": "beachball",
|
44
|
+
"package": "@fluentui/react-portal",
|
45
|
+
"comment": "Bump @fluentui/jest-serializer-make-styles to v9.0.0-beta.4",
|
46
|
+
"commit": "281e8820669214c1ffb9bc75e9b719a3b27fa9b6"
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"author": "beachball",
|
50
|
+
"package": "@fluentui/react-portal",
|
51
|
+
"comment": "Bump @fluentui/babel-make-styles to v9.0.0-beta.4",
|
52
|
+
"commit": "281e8820669214c1ffb9bc75e9b719a3b27fa9b6"
|
53
|
+
}
|
54
|
+
]
|
55
|
+
}
|
56
|
+
},
|
57
|
+
{
|
58
|
+
"date": "Fri, 12 Nov 2021 13:25:29 GMT",
|
6
59
|
"tag": "@fluentui/react-portal_v9.0.0-beta.4",
|
7
60
|
"version": "9.0.0-beta.4",
|
8
61
|
"comments": {
|
@@ -37,31 +90,31 @@
|
|
37
90
|
"author": "beachball",
|
38
91
|
"package": "@fluentui/react-portal",
|
39
92
|
"comment": "Bump @fluentui/react-make-styles to v9.0.0-beta.3",
|
40
|
-
"commit": "
|
93
|
+
"commit": "742342e52c65066f779232e4e1302fedf0dd460d"
|
41
94
|
},
|
42
95
|
{
|
43
96
|
"author": "beachball",
|
44
97
|
"package": "@fluentui/react-portal",
|
45
98
|
"comment": "Bump @fluentui/react-shared-contexts to v9.0.0-beta.3",
|
46
|
-
"commit": "
|
99
|
+
"commit": "742342e52c65066f779232e4e1302fedf0dd460d"
|
47
100
|
},
|
48
101
|
{
|
49
102
|
"author": "beachball",
|
50
103
|
"package": "@fluentui/react-portal",
|
51
104
|
"comment": "Bump @fluentui/react-tabster to v9.0.0-beta.4",
|
52
|
-
"commit": "
|
105
|
+
"commit": "742342e52c65066f779232e4e1302fedf0dd460d"
|
53
106
|
},
|
54
107
|
{
|
55
108
|
"author": "beachball",
|
56
109
|
"package": "@fluentui/react-portal",
|
57
110
|
"comment": "Bump @fluentui/react-utilities to v9.0.0-beta.3",
|
58
|
-
"commit": "
|
111
|
+
"commit": "742342e52c65066f779232e4e1302fedf0dd460d"
|
59
112
|
},
|
60
113
|
{
|
61
114
|
"author": "beachball",
|
62
115
|
"package": "@fluentui/react-portal",
|
63
116
|
"comment": "Bump @fluentui/jest-serializer-make-styles to v9.0.0-beta.3",
|
64
|
-
"commit": "
|
117
|
+
"commit": "742342e52c65066f779232e4e1302fedf0dd460d"
|
65
118
|
}
|
66
119
|
]
|
67
120
|
}
|
package/CHANGELOG.md
CHANGED
@@ -1,23 +1,37 @@
|
|
1
1
|
# Change Log - @fluentui/react-portal
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Thu, 25 Nov 2021 08:31:33 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
+
## [9.0.0-beta.5](https://github.com/microsoft/fluentui/tree/@fluentui/react-portal_v9.0.0-beta.5)
|
8
|
+
|
9
|
+
Thu, 25 Nov 2021 08:31:33 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-portal_v9.0.0-beta.4..@fluentui/react-portal_v9.0.0-beta.5)
|
11
|
+
|
12
|
+
### Changes
|
13
|
+
|
14
|
+
- Bump @fluentui/react-make-styles to v9.0.0-beta.4 ([PR #20609](https://github.com/microsoft/fluentui/pull/20609) by beachball)
|
15
|
+
- Bump @fluentui/react-shared-contexts to v9.0.0-beta.4 ([PR #20609](https://github.com/microsoft/fluentui/pull/20609) by beachball)
|
16
|
+
- Bump @fluentui/react-tabster to v9.0.0-beta.5 ([PR #20609](https://github.com/microsoft/fluentui/pull/20609) by beachball)
|
17
|
+
- Bump @fluentui/react-utilities to v9.0.0-beta.4 ([PR #20609](https://github.com/microsoft/fluentui/pull/20609) by beachball)
|
18
|
+
- Bump @fluentui/jest-serializer-make-styles to v9.0.0-beta.4 ([PR #20609](https://github.com/microsoft/fluentui/pull/20609) by beachball)
|
19
|
+
- Bump @fluentui/babel-make-styles to v9.0.0-beta.4 ([PR #20609](https://github.com/microsoft/fluentui/pull/20609) by beachball)
|
20
|
+
|
7
21
|
## [9.0.0-beta.4](https://github.com/microsoft/fluentui/tree/@fluentui/react-portal_v9.0.0-beta.4)
|
8
22
|
|
9
|
-
Fri, 12 Nov 2021
|
23
|
+
Fri, 12 Nov 2021 13:25:29 GMT
|
10
24
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-portal_v9.0.0-beta.3..@fluentui/react-portal_v9.0.0-beta.4)
|
11
25
|
|
12
26
|
### Changes
|
13
27
|
|
14
28
|
- Updated beta and RC components to ES2019 ([PR #20405](https://github.com/microsoft/fluentui/pull/20405) by gcox@microsoft.com)
|
15
29
|
- Broke up stories added codesandbox refs ([PR #20372](https://github.com/microsoft/fluentui/pull/20372) by gcox@microsoft.com)
|
16
|
-
- Bump @fluentui/react-make-styles to v9.0.0-beta.3 ([PR #
|
17
|
-
- Bump @fluentui/react-shared-contexts to v9.0.0-beta.3 ([PR #
|
18
|
-
- Bump @fluentui/react-tabster to v9.0.0-beta.4 ([PR #
|
19
|
-
- Bump @fluentui/react-utilities to v9.0.0-beta.3 ([PR #
|
20
|
-
- Bump @fluentui/jest-serializer-make-styles to v9.0.0-beta.3 ([PR #
|
30
|
+
- Bump @fluentui/react-make-styles to v9.0.0-beta.3 ([PR #20583](https://github.com/microsoft/fluentui/pull/20583) by beachball)
|
31
|
+
- Bump @fluentui/react-shared-contexts to v9.0.0-beta.3 ([PR #20583](https://github.com/microsoft/fluentui/pull/20583) by beachball)
|
32
|
+
- Bump @fluentui/react-tabster to v9.0.0-beta.4 ([PR #20583](https://github.com/microsoft/fluentui/pull/20583) by beachball)
|
33
|
+
- Bump @fluentui/react-utilities to v9.0.0-beta.3 ([PR #20583](https://github.com/microsoft/fluentui/pull/20583) by beachball)
|
34
|
+
- Bump @fluentui/jest-serializer-make-styles to v9.0.0-beta.3 ([PR #20583](https://github.com/microsoft/fluentui/pull/20583) by beachball)
|
21
35
|
|
22
36
|
## [9.0.0-beta.3](https://github.com/microsoft/fluentui/tree/@fluentui/react-portal_v9.0.0-beta.3)
|
23
37
|
|
@@ -4,9 +4,10 @@ import { renderPortal } from './renderPortal';
|
|
4
4
|
* A portal provides a way to render children into a DOM node
|
5
5
|
* that exists outside the DOM hierarchy of the parent component.
|
6
6
|
*/
|
7
|
+
|
7
8
|
export const Portal = props => {
|
8
|
-
|
9
|
-
|
9
|
+
const state = usePortal(props);
|
10
|
+
return renderPortal(state);
|
10
11
|
};
|
11
12
|
Portal.displayName = 'Portal';
|
12
13
|
//# sourceMappingURL=Portal.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../../src/components/Portal/Portal.tsx"],"names":[],"mappings":"AAEA,SAAS,SAAT,QAA0B,aAA1B;AACA,SAAS,YAAT,QAA6B,gBAA7B;AAGA;;;AAGG;;AACH,OAAO,MAAM,MAAM,GAA0B,KAAK,IAAG;AACnD,QAAM,KAAK,GAAG,SAAS,CAAC,KAAD,CAAvB;AAEA,SAAO,YAAY,CAAC,KAAD,CAAnB;AACD,CAJM;AAMP,MAAM,CAAC,WAAP,GAAqB,QAArB","sourceRoot":""}
|
@@ -3,7 +3,11 @@ import * as React from 'react';
|
|
3
3
|
/**
|
4
4
|
* Render the final JSX of Portal
|
5
5
|
*/
|
6
|
-
|
7
|
-
|
6
|
+
|
7
|
+
export const renderPortal = state => {
|
8
|
+
return /*#__PURE__*/React.createElement("span", {
|
9
|
+
hidden: true,
|
10
|
+
ref: state.virtualParentRootRef
|
11
|
+
}, state.shouldRender && state.mountNode && /*#__PURE__*/ReactDOM.createPortal(state.children, state.mountNode));
|
8
12
|
};
|
9
13
|
//# sourceMappingURL=renderPortal.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../../src/components/Portal/renderPortal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAZ,MAA0B,WAA1B;AACA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAGA;;AAEG;;AACH,OAAO,MAAM,YAAY,GAAI,KAAD,IAA2C;AACrE,sBACE,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA;AAAM,IAAA,MAAM,EAAA,IAAZ;AAAa,IAAA,GAAG,EAAE,KAAK,CAAC;AAAxB,GAAA,EACG,KAAK,CAAC,YAAN,IAAsB,KAAK,CAAC,SAA5B,iBAAyC,QAAQ,CAAC,YAAT,CAAsB,KAAK,CAAC,QAA5B,EAAsC,KAAK,CAAC,SAA5C,CAD5C,CADF;AAKD,CANM","sourceRoot":""}
|
@@ -9,21 +9,27 @@ import { setVirtualParent } from '../../virtualParent/index';
|
|
9
9
|
*
|
10
10
|
* @param props - props from this instance of Portal
|
11
11
|
*/
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
12
|
+
|
13
|
+
export const usePortal = props => {
|
14
|
+
const {
|
15
|
+
children,
|
16
|
+
mountNode
|
17
|
+
} = props;
|
18
|
+
const virtualParentRootRef = React.useRef(null);
|
19
|
+
const fallbackMountNode = usePortalMountNode({
|
20
|
+
disabled: !!mountNode
|
21
|
+
});
|
22
|
+
const state = {
|
23
|
+
children,
|
24
|
+
mountNode: mountNode !== null && mountNode !== void 0 ? mountNode : fallbackMountNode,
|
25
|
+
shouldRender: !useIsSSR(),
|
26
|
+
virtualParentRootRef
|
27
|
+
};
|
28
|
+
React.useEffect(() => {
|
29
|
+
if (state.virtualParentRootRef.current && state.mountNode) {
|
30
|
+
setVirtualParent(state.mountNode, state.virtualParentRootRef.current);
|
31
|
+
}
|
32
|
+
}, [state.virtualParentRootRef, state.mountNode]);
|
33
|
+
return state;
|
28
34
|
};
|
29
35
|
//# sourceMappingURL=usePortal.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../../src/components/Portal/usePortal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,QAAT,QAAyB,2BAAzB;AACA,SAAS,kBAAT,QAAmC,sBAAnC;AACA,SAAS,gBAAT,QAAiC,2BAAjC;AAGA;;;;;;AAMG;;AACH,OAAO,MAAM,SAAS,GAAI,KAAD,IAAoC;AAC3D,QAAM;AAAE,IAAA,QAAF;AAAY,IAAA;AAAZ,MAA0B,KAAhC;AAEA,QAAM,oBAAoB,GAAG,KAAK,CAAC,MAAN,CAA8B,IAA9B,CAA7B;AACA,QAAM,iBAAiB,GAAG,kBAAkB,CAAC;AAAE,IAAA,QAAQ,EAAE,CAAC,CAAC;AAAd,GAAD,CAA5C;AAEA,QAAM,KAAK,GAAgB;AACzB,IAAA,QADyB;AAEzB,IAAA,SAAS,EAAE,SAAS,KAAA,IAAT,IAAA,SAAS,KAAA,KAAA,CAAT,GAAA,SAAA,GAAa,iBAFC;AAGzB,IAAA,YAAY,EAAE,CAAC,QAAQ,EAHE;AAIzB,IAAA;AAJyB,GAA3B;AAOA,EAAA,KAAK,CAAC,SAAN,CAAgB,MAAK;AACnB,QAAI,KAAK,CAAC,oBAAN,CAA2B,OAA3B,IAAsC,KAAK,CAAC,SAAhD,EAA2D;AACzD,MAAA,gBAAgB,CAAC,KAAK,CAAC,SAAP,EAAkB,KAAK,CAAC,oBAAN,CAA2B,OAA7C,CAAhB;AACD;AACF,GAJD,EAIG,CAAC,KAAK,CAAC,oBAAP,EAA6B,KAAK,CAAC,SAAnC,CAJH;AAMA,SAAO,KAAP;AACD,CApBM","sourceRoot":""}
|
@@ -5,26 +5,32 @@ import { useKeyboardNavAttribute } from '@fluentui/react-tabster';
|
|
5
5
|
/**
|
6
6
|
* Creates a new element on a document.body to mount portals
|
7
7
|
*/
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
return
|
8
|
+
|
9
|
+
export const usePortalMountNode = options => {
|
10
|
+
const themeClassName = useThemeClassName();
|
11
|
+
const {
|
12
|
+
targetDocument,
|
13
|
+
dir
|
14
|
+
} = useFluent();
|
15
|
+
const element = React.useMemo(() => {
|
16
|
+
if (targetDocument === undefined || options.disabled) {
|
17
|
+
return undefined;
|
18
|
+
}
|
19
|
+
|
20
|
+
const newElement = targetDocument.createElement('div');
|
21
|
+
newElement.setAttribute('class', themeClassName);
|
22
|
+
newElement.setAttribute('dir', dir);
|
23
|
+
targetDocument.body.appendChild(newElement);
|
24
|
+
return newElement;
|
25
|
+
}, [targetDocument, themeClassName, dir, options.disabled]);
|
26
|
+
useKeyboardNavAttribute().current = element;
|
27
|
+
useIsomorphicLayoutEffect(() => {
|
28
|
+
return () => {
|
29
|
+
var _a;
|
30
|
+
|
31
|
+
(_a = element === null || element === void 0 ? void 0 : element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(element);
|
32
|
+
};
|
33
|
+
}, [element]);
|
34
|
+
return element;
|
29
35
|
};
|
30
36
|
//# sourceMappingURL=usePortalMountNode.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../../src/components/Portal/usePortalMountNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,yBAAT,QAA0C,2BAA1C;AACA,SAAS,iBAAT,EAA4B,SAA5B,QAA6C,iCAA7C;AACA,SAAS,uBAAT,QAAwC,yBAAxC;AASA;;AAEG;;AACH,OAAO,MAAM,kBAAkB,GAAI,OAAD,IAAuC;AACvE,QAAM,cAAc,GAAG,iBAAiB,EAAxC;AACA,QAAM;AAAE,IAAA,cAAF;AAAkB,IAAA;AAAlB,MAA0B,SAAS,EAAzC;AAEA,QAAM,OAAO,GAAG,KAAK,CAAC,OAAN,CAAc,MAAK;AACjC,QAAI,cAAc,KAAK,SAAnB,IAAgC,OAAO,CAAC,QAA5C,EAAsD;AACpD,aAAO,SAAP;AACD;;AAED,UAAM,UAAU,GAAG,cAAc,CAAC,aAAf,CAA6B,KAA7B,CAAnB;AACA,IAAA,UAAU,CAAC,YAAX,CAAwB,OAAxB,EAAiC,cAAjC;AACA,IAAA,UAAU,CAAC,YAAX,CAAwB,KAAxB,EAA+B,GAA/B;AACA,IAAA,cAAc,CAAC,IAAf,CAAoB,WAApB,CAAgC,UAAhC;AAEA,WAAO,UAAP;AACD,GAXe,EAWb,CAAC,cAAD,EAAiB,cAAjB,EAAiC,GAAjC,EAAsC,OAAO,CAAC,QAA9C,CAXa,CAAhB;AAaC,EAAA,uBAAuB,GAA2C,OAAlE,GAA4E,OAA5E;AAED,EAAA,yBAAyB,CAAC,MAAK;AAC7B,WAAO,MAAK;;;AACV,OAAA,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;AACD,KAFD;AAGD,GAJwB,EAItB,CAAC,OAAD,CAJsB,CAAzB;AAMA,SAAO,OAAP;AACD,CA1BM","sourceRoot":""}
|
@@ -5,22 +5,26 @@ import { getParent } from './getParent';
|
|
5
5
|
*
|
6
6
|
* @returns true if the child can find the parent in its virtual hierarchy
|
7
7
|
*/
|
8
|
+
|
8
9
|
export function elementContains(parent, child) {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
if (!parent || !child) {
|
11
|
+
return false;
|
12
|
+
}
|
13
|
+
|
14
|
+
if (parent === child) {
|
15
|
+
return true;
|
16
|
+
} else {
|
17
|
+
while (child) {
|
18
|
+
const nextParent = getParent(child);
|
19
|
+
|
20
|
+
if (nextParent === parent) {
|
13
21
|
return true;
|
22
|
+
}
|
23
|
+
|
24
|
+
child = nextParent;
|
14
25
|
}
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
if (nextParent === parent) {
|
19
|
-
return true;
|
20
|
-
}
|
21
|
-
child = nextParent;
|
22
|
-
}
|
23
|
-
}
|
24
|
-
return false;
|
26
|
+
}
|
27
|
+
|
28
|
+
return false;
|
25
29
|
}
|
26
30
|
//# sourceMappingURL=elementContains.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../src/virtualParent/elementContains.ts"],"names":[],"mappings":"AAAA,SAAS,SAAT,QAA0B,aAA1B;AACA;;;;;AAKG;;AACH,OAAM,SAAU,eAAV,CAA0B,MAA1B,EAAsD,KAAtD,EAA+E;AACnF,MAAI,CAAC,MAAD,IAAW,CAAC,KAAhB,EAAuB;AACrB,WAAO,KAAP;AACD;;AAED,MAAI,MAAM,KAAK,KAAf,EAAsB;AACpB,WAAO,IAAP;AACD,GAFD,MAEO;AACL,WAAO,KAAP,EAAc;AACZ,YAAM,UAAU,GAAuB,SAAS,CAAC,KAAD,CAAhD;;AAEA,UAAI,UAAU,KAAK,MAAnB,EAA2B;AACzB,eAAO,IAAP;AACD;;AAED,MAAA,KAAK,GAAG,UAAR;AACD;AACF;;AAED,SAAO,KAAP;AACD","sourceRoot":""}
|
@@ -3,7 +3,8 @@ import { getVirtualParent } from './getVirtualParent';
|
|
3
3
|
* Gets the element which is the parent of a given element.
|
4
4
|
* This method prefers the virtual parent over real DOM parent when present.
|
5
5
|
*/
|
6
|
+
|
6
7
|
export function getParent(child) {
|
7
|
-
|
8
|
+
return child && getVirtualParent(child) || (child === null || child === void 0 ? void 0 : child.parentNode);
|
8
9
|
}
|
9
10
|
//# sourceMappingURL=getParent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../src/virtualParent/getParent.ts"],"names":[],"mappings":"AAAA,SAAS,gBAAT,QAAiC,oBAAjC;AAEA;;;AAGG;;AACH,OAAM,SAAU,SAAV,CAAoB,KAApB,EAA6C;AACjD,SAAQ,KAAK,IAAI,gBAAgB,CAAC,KAAD,CAA1B,KAAuC,KAAK,KAAA,IAAL,IAAA,KAAK,KAAA,KAAA,CAAL,GAAK,KAAA,CAAL,GAAA,KAAK,CAAE,UAA9C,CAAP;AACD","sourceRoot":""}
|
@@ -2,11 +2,14 @@ import { isVirtualElement } from './isVirtualElement';
|
|
2
2
|
/**
|
3
3
|
* Gets the virtual parent given the child element, if it exists.
|
4
4
|
*/
|
5
|
+
|
5
6
|
export function getVirtualParent(child) {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
let parent;
|
8
|
+
|
9
|
+
if (isVirtualElement(child)) {
|
10
|
+
parent = child._virtual.parent;
|
11
|
+
}
|
12
|
+
|
13
|
+
return parent;
|
11
14
|
}
|
12
15
|
//# sourceMappingURL=getVirtualParent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../src/virtualParent/getVirtualParent.ts"],"names":[],"mappings":"AAAA,SAAS,gBAAT,QAAiC,oBAAjC;AACA;;AAEG;;AACH,OAAM,SAAU,gBAAV,CAA2B,KAA3B,EAA6C;AACjD,MAAI,MAAJ;;AACA,MAAI,gBAAgB,CAAC,KAAD,CAApB,EAA6B;AAC3B,IAAA,MAAM,GAAG,KAAK,CAAC,QAAN,CAAe,MAAxB;AACD;;AACD,SAAO,MAAP;AACD","sourceRoot":""}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../src/virtualParent/isVirtualElement.ts"],"names":[],"mappings":"AAEA;;AAEG;AACH,OAAM,SAAU,gBAAV,CAA2B,OAA3B,EAAgE;AACpE,SAAO,OAAO,IAAI,CAAC,CAAkB,OAAQ,CAAC,QAA9C;AACD","sourceRoot":""}
|
@@ -5,13 +5,16 @@
|
|
5
5
|
* @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship
|
6
6
|
*/
|
7
7
|
export function setVirtualParent(child, parent) {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
virtualChild._virtual
|
8
|
+
if (!child) {
|
9
|
+
return;
|
10
|
+
}
|
11
|
+
|
12
|
+
const virtualChild = child;
|
13
|
+
|
14
|
+
if (!virtualChild._virtual) {
|
15
|
+
virtualChild._virtual = {};
|
16
|
+
}
|
17
|
+
|
18
|
+
virtualChild._virtual.parent = parent || undefined;
|
16
19
|
}
|
17
20
|
//# sourceMappingURL=setVirtualParent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../src/virtualParent/setVirtualParent.ts"],"names":[],"mappings":"AAEA;;;;;AAKG;AACH,OAAM,SAAU,gBAAV,CAA2B,KAA3B,EAA+C,MAA/C,EAAmE;AACvE,MAAI,CAAC,KAAL,EAAY;AACV;AACD;;AAED,QAAM,YAAY,GAAmB,KAArC;;AAEA,MAAI,CAAC,YAAY,CAAC,QAAlB,EAA4B;AAC1B,IAAA,YAAY,CAAC,QAAb,GAAwB,EAAxB;AACD;;AAED,EAAA,YAAY,CAAC,QAAb,CAAsB,MAAtB,GAA+B,MAAM,IAAI,SAAzC;AACD","sourceRoot":""}
|
package/lib-commonjs/Portal.js
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
|
-
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
|
7
|
+
const tslib_1 = /*#__PURE__*/require("tslib");
|
8
|
+
|
4
9
|
tslib_1.__exportStar(require("./components/Portal/index"), exports);
|
5
10
|
//# sourceMappingURL=Portal.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../src/Portal.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,2BAAA,CAAA,EAAA,OAAA","sourceRoot":""}
|
@@ -1,16 +1,24 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
3
6
|
exports.Portal = void 0;
|
4
|
-
|
5
|
-
const
|
7
|
+
|
8
|
+
const usePortal_1 = /*#__PURE__*/require("./usePortal");
|
9
|
+
|
10
|
+
const renderPortal_1 = /*#__PURE__*/require("./renderPortal");
|
6
11
|
/**
|
7
12
|
* A portal provides a way to render children into a DOM node
|
8
13
|
* that exists outside the DOM hierarchy of the parent component.
|
9
14
|
*/
|
15
|
+
|
16
|
+
|
10
17
|
const Portal = props => {
|
11
|
-
|
12
|
-
|
18
|
+
const state = usePortal_1.usePortal(props);
|
19
|
+
return renderPortal_1.renderPortal(state);
|
13
20
|
};
|
21
|
+
|
14
22
|
exports.Portal = Portal;
|
15
23
|
exports.Portal.displayName = 'Portal';
|
16
24
|
//# sourceMappingURL=Portal.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../../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;AACnD,QAAM,KAAK,GAAG,WAAA,CAAA,SAAA,CAAU,KAAV,CAAd;AAEA,SAAO,cAAA,CAAA,YAAA,CAAa,KAAb,CAAP;AACD,CAJM;;AAAM,OAAA,CAAA,MAAA,GAAM,MAAN;AAMb,OAAA,CAAA,MAAA,CAAO,WAAP,GAAqB,QAArB","sourceRoot":""}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}
|
@@ -1,8 +1,16 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
|
-
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
|
7
|
+
const tslib_1 = /*#__PURE__*/require("tslib");
|
8
|
+
|
4
9
|
tslib_1.__exportStar(require("./Portal"), exports);
|
10
|
+
|
5
11
|
tslib_1.__exportStar(require("./Portal.types"), exports);
|
12
|
+
|
6
13
|
tslib_1.__exportStar(require("./renderPortal"), exports);
|
14
|
+
|
7
15
|
tslib_1.__exportStar(require("./usePortal"), exports);
|
8
16
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../../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","sourceRoot":""}
|
@@ -1,13 +1,24 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
3
6
|
exports.renderPortal = void 0;
|
4
|
-
|
5
|
-
const
|
7
|
+
|
8
|
+
const ReactDOM = /*#__PURE__*/require("react-dom");
|
9
|
+
|
10
|
+
const React = /*#__PURE__*/require("react");
|
6
11
|
/**
|
7
12
|
* Render the final JSX of Portal
|
8
13
|
*/
|
9
|
-
|
10
|
-
|
14
|
+
|
15
|
+
|
16
|
+
const renderPortal = state => {
|
17
|
+
return React.createElement("span", {
|
18
|
+
hidden: true,
|
19
|
+
ref: state.virtualParentRootRef
|
20
|
+
}, state.shouldRender && state.mountNode && ReactDOM.createPortal(state.children, state.mountNode));
|
11
21
|
};
|
22
|
+
|
12
23
|
exports.renderPortal = renderPortal;
|
13
24
|
//# sourceMappingURL=renderPortal.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../../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,YAAY,GAAI,KAAD,IAA2C;AACrE,SACE,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA;AAAM,IAAA,MAAM,EAAA,IAAZ;AAAa,IAAA,GAAG,EAAE,KAAK,CAAC;AAAxB,GAAA,EACG,KAAK,CAAC,YAAN,IAAsB,KAAK,CAAC,SAA5B,IAAyC,QAAQ,CAAC,YAAT,CAAsB,KAAK,CAAC,QAA5B,EAAsC,KAAK,CAAC,SAA5C,CAD5C,CADF;AAKD,CANM;;AAAM,OAAA,CAAA,YAAA,GAAY,YAAZ","sourceRoot":""}
|
@@ -1,10 +1,17 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
3
6
|
exports.usePortal = void 0;
|
4
|
-
|
5
|
-
const
|
6
|
-
|
7
|
-
const
|
7
|
+
|
8
|
+
const React = /*#__PURE__*/require("react");
|
9
|
+
|
10
|
+
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
11
|
+
|
12
|
+
const usePortalMountNode_1 = /*#__PURE__*/require("./usePortalMountNode");
|
13
|
+
|
14
|
+
const index_1 = /*#__PURE__*/require("../../virtualParent/index");
|
8
15
|
/**
|
9
16
|
* Create the state required to render Portal.
|
10
17
|
*
|
@@ -12,22 +19,30 @@ const index_1 = require("../../virtualParent/index");
|
|
12
19
|
*
|
13
20
|
* @param props - props from this instance of Portal
|
14
21
|
*/
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
22
|
+
|
23
|
+
|
24
|
+
const usePortal = props => {
|
25
|
+
const {
|
26
|
+
children,
|
27
|
+
mountNode
|
28
|
+
} = props;
|
29
|
+
const virtualParentRootRef = React.useRef(null);
|
30
|
+
const fallbackMountNode = usePortalMountNode_1.usePortalMountNode({
|
31
|
+
disabled: !!mountNode
|
32
|
+
});
|
33
|
+
const state = {
|
34
|
+
children,
|
35
|
+
mountNode: mountNode !== null && mountNode !== void 0 ? mountNode : fallbackMountNode,
|
36
|
+
shouldRender: !react_utilities_1.useIsSSR(),
|
37
|
+
virtualParentRootRef
|
38
|
+
};
|
39
|
+
React.useEffect(() => {
|
40
|
+
if (state.virtualParentRootRef.current && state.mountNode) {
|
41
|
+
index_1.setVirtualParent(state.mountNode, state.virtualParentRootRef.current);
|
42
|
+
}
|
43
|
+
}, [state.virtualParentRootRef, state.mountNode]);
|
44
|
+
return state;
|
31
45
|
};
|
46
|
+
|
32
47
|
exports.usePortal = usePortal;
|
33
48
|
//# sourceMappingURL=usePortal.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../../src/components/Portal/usePortal.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,oBAAA,gBAAA,OAAA,CAAA,sBAAA,CAAA;;AACA,MAAA,OAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAGA;;;;;;AAMG;;;AACI,MAAM,SAAS,GAAI,KAAD,IAAoC;AAC3D,QAAM;AAAE,IAAA,QAAF;AAAY,IAAA;AAAZ,MAA0B,KAAhC;AAEA,QAAM,oBAAoB,GAAG,KAAK,CAAC,MAAN,CAA8B,IAA9B,CAA7B;AACA,QAAM,iBAAiB,GAAG,oBAAA,CAAA,kBAAA,CAAmB;AAAE,IAAA,QAAQ,EAAE,CAAC,CAAC;AAAd,GAAnB,CAA1B;AAEA,QAAM,KAAK,GAAgB;AACzB,IAAA,QADyB;AAEzB,IAAA,SAAS,EAAE,SAAS,KAAA,IAAT,IAAA,SAAS,KAAA,KAAA,CAAT,GAAA,SAAA,GAAa,iBAFC;AAGzB,IAAA,YAAY,EAAE,CAAC,iBAAA,CAAA,QAAA,EAHU;AAIzB,IAAA;AAJyB,GAA3B;AAOA,EAAA,KAAK,CAAC,SAAN,CAAgB,MAAK;AACnB,QAAI,KAAK,CAAC,oBAAN,CAA2B,OAA3B,IAAsC,KAAK,CAAC,SAAhD,EAA2D;AACzD,MAAA,OAAA,CAAA,gBAAA,CAAiB,KAAK,CAAC,SAAvB,EAAkC,KAAK,CAAC,oBAAN,CAA2B,OAA7D;AACD;AACF,GAJD,EAIG,CAAC,KAAK,CAAC,oBAAP,EAA6B,KAAK,CAAC,SAAnC,CAJH;AAMA,SAAO,KAAP;AACD,CApBM;;AAAM,OAAA,CAAA,SAAA,GAAS,SAAT","sourceRoot":""}
|
@@ -1,34 +1,49 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
3
6
|
exports.usePortalMountNode = void 0;
|
4
|
-
|
5
|
-
const
|
6
|
-
|
7
|
-
const
|
7
|
+
|
8
|
+
const React = /*#__PURE__*/require("react");
|
9
|
+
|
10
|
+
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
11
|
+
|
12
|
+
const react_shared_contexts_1 = /*#__PURE__*/require("@fluentui/react-shared-contexts");
|
13
|
+
|
14
|
+
const react_tabster_1 = /*#__PURE__*/require("@fluentui/react-tabster");
|
8
15
|
/**
|
9
16
|
* Creates a new element on a document.body to mount portals
|
10
17
|
*/
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
18
|
+
|
19
|
+
|
20
|
+
const usePortalMountNode = options => {
|
21
|
+
const themeClassName = react_shared_contexts_1.useThemeClassName();
|
22
|
+
const {
|
23
|
+
targetDocument,
|
24
|
+
dir
|
25
|
+
} = react_shared_contexts_1.useFluent();
|
26
|
+
const element = React.useMemo(() => {
|
27
|
+
if (targetDocument === undefined || options.disabled) {
|
28
|
+
return undefined;
|
29
|
+
}
|
30
|
+
|
31
|
+
const newElement = targetDocument.createElement('div');
|
32
|
+
newElement.setAttribute('class', themeClassName);
|
33
|
+
newElement.setAttribute('dir', dir);
|
34
|
+
targetDocument.body.appendChild(newElement);
|
35
|
+
return newElement;
|
36
|
+
}, [targetDocument, themeClassName, dir, options.disabled]);
|
37
|
+
react_tabster_1.useKeyboardNavAttribute().current = element;
|
38
|
+
react_utilities_1.useIsomorphicLayoutEffect(() => {
|
39
|
+
return () => {
|
40
|
+
var _a;
|
41
|
+
|
42
|
+
(_a = element === null || element === void 0 ? void 0 : element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(element);
|
43
|
+
};
|
44
|
+
}, [element]);
|
45
|
+
return element;
|
32
46
|
};
|
47
|
+
|
33
48
|
exports.usePortalMountNode = usePortalMountNode;
|
34
49
|
//# sourceMappingURL=usePortalMountNode.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../../src/components/Portal/usePortalMountNode.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,uBAAA,gBAAA,OAAA,CAAA,iCAAA,CAAA;;AACA,MAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;AASA;;AAEG;;;AACI,MAAM,kBAAkB,GAAI,OAAD,IAAuC;AACvE,QAAM,cAAc,GAAG,uBAAA,CAAA,iBAAA,EAAvB;AACA,QAAM;AAAE,IAAA,cAAF;AAAkB,IAAA;AAAlB,MAA0B,uBAAA,CAAA,SAAA,EAAhC;AAEA,QAAM,OAAO,GAAG,KAAK,CAAC,OAAN,CAAc,MAAK;AACjC,QAAI,cAAc,KAAK,SAAnB,IAAgC,OAAO,CAAC,QAA5C,EAAsD;AACpD,aAAO,SAAP;AACD;;AAED,UAAM,UAAU,GAAG,cAAc,CAAC,aAAf,CAA6B,KAA7B,CAAnB;AACA,IAAA,UAAU,CAAC,YAAX,CAAwB,OAAxB,EAAiC,cAAjC;AACA,IAAA,UAAU,CAAC,YAAX,CAAwB,KAAxB,EAA+B,GAA/B;AACA,IAAA,cAAc,CAAC,IAAf,CAAoB,WAApB,CAAgC,UAAhC;AAEA,WAAO,UAAP;AACD,GAXe,EAWb,CAAC,cAAD,EAAiB,cAAjB,EAAiC,GAAjC,EAAsC,OAAO,CAAC,QAA9C,CAXa,CAAhB;AAaC,EAAA,eAAA,CAAA,uBAAA,GAAkE,OAAlE,GAA4E,OAA5E;AAED,EAAA,iBAAA,CAAA,yBAAA,CAA0B,MAAK;AAC7B,WAAO,MAAK;;;AACV,OAAA,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;AACD,KAFD;AAGD,GAJD,EAIG,CAAC,OAAD,CAJH;AAMA,SAAO,OAAP;AACD,CA1BM;;AAAM,OAAA,CAAA,kBAAA,GAAkB,kBAAlB","sourceRoot":""}
|
package/lib-commonjs/index.js
CHANGED
@@ -1,9 +1,26 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
3
6
|
exports.setVirtualParent = exports.elementContains = void 0;
|
4
|
-
|
7
|
+
|
8
|
+
const tslib_1 = /*#__PURE__*/require("tslib");
|
9
|
+
|
5
10
|
tslib_1.__exportStar(require("./components/Portal/index"), exports);
|
6
|
-
|
7
|
-
|
8
|
-
|
11
|
+
|
12
|
+
var index_1 = /*#__PURE__*/require("./virtualParent/index");
|
13
|
+
|
14
|
+
Object.defineProperty(exports, "elementContains", {
|
15
|
+
enumerable: true,
|
16
|
+
get: function () {
|
17
|
+
return index_1.elementContains;
|
18
|
+
}
|
19
|
+
});
|
20
|
+
Object.defineProperty(exports, "setVirtualParent", {
|
21
|
+
enumerable: true,
|
22
|
+
get: function () {
|
23
|
+
return index_1.setVirtualParent;
|
24
|
+
}
|
25
|
+
});
|
9
26
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,2BAAA,CAAA,EAAA,OAAA;;AACA,IAAA,OAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,iBAAA,EAAA;AAAA,EAAA,UAAA,EAAA,IAAA;AAAA,EAAA,GAAA,EAAA,YAAA;AAAA,WAAA,OAAA,CAAA,eAAA;AAAe;AAAf,CAAA;AAAiB,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,kBAAA,EAAA;AAAA,EAAA,UAAA,EAAA,IAAA;AAAA,EAAA,GAAA,EAAA,YAAA;AAAA,WAAA,OAAA,CAAA,gBAAA;AAAgB;AAAhB,CAAA","sourceRoot":""}
|
@@ -1,30 +1,40 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
3
6
|
exports.elementContains = void 0;
|
4
|
-
|
7
|
+
|
8
|
+
const getParent_1 = /*#__PURE__*/require("./getParent");
|
5
9
|
/**
|
6
10
|
* Similar functionality to `element.contains` DOM API for use with out of order DOM elements that
|
7
11
|
* checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent
|
8
12
|
*
|
9
13
|
* @returns true if the child can find the parent in its virtual hierarchy
|
10
14
|
*/
|
15
|
+
|
16
|
+
|
11
17
|
function elementContains(parent, child) {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
18
|
+
if (!parent || !child) {
|
19
|
+
return false;
|
20
|
+
}
|
21
|
+
|
22
|
+
if (parent === child) {
|
23
|
+
return true;
|
24
|
+
} else {
|
25
|
+
while (child) {
|
26
|
+
const nextParent = getParent_1.getParent(child);
|
27
|
+
|
28
|
+
if (nextParent === parent) {
|
16
29
|
return true;
|
30
|
+
}
|
31
|
+
|
32
|
+
child = nextParent;
|
17
33
|
}
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
if (nextParent === parent) {
|
22
|
-
return true;
|
23
|
-
}
|
24
|
-
child = nextParent;
|
25
|
-
}
|
26
|
-
}
|
27
|
-
return false;
|
34
|
+
}
|
35
|
+
|
36
|
+
return false;
|
28
37
|
}
|
38
|
+
|
29
39
|
exports.elementContains = elementContains;
|
30
40
|
//# sourceMappingURL=elementContains.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../src/virtualParent/elementContains.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,WAAA,gBAAA,OAAA,CAAA,aAAA,CAAA;AACA;;;;;AAKG;;;AACH,SAAgB,eAAhB,CAAgC,MAAhC,EAA4D,KAA5D,EAAqF;AACnF,MAAI,CAAC,MAAD,IAAW,CAAC,KAAhB,EAAuB;AACrB,WAAO,KAAP;AACD;;AAED,MAAI,MAAM,KAAK,KAAf,EAAsB;AACpB,WAAO,IAAP;AACD,GAFD,MAEO;AACL,WAAO,KAAP,EAAc;AACZ,YAAM,UAAU,GAAuB,WAAA,CAAA,SAAA,CAAU,KAAV,CAAvC;;AAEA,UAAI,UAAU,KAAK,MAAnB,EAA2B;AACzB,eAAO,IAAP;AACD;;AAED,MAAA,KAAK,GAAG,UAAR;AACD;AACF;;AAED,SAAO,KAAP;AACD;;AApBD,OAAA,CAAA,eAAA,GAAA,eAAA","sourceRoot":""}
|
@@ -1,13 +1,20 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
3
6
|
exports.getParent = void 0;
|
4
|
-
|
7
|
+
|
8
|
+
const getVirtualParent_1 = /*#__PURE__*/require("./getVirtualParent");
|
5
9
|
/**
|
6
10
|
* Gets the element which is the parent of a given element.
|
7
11
|
* This method prefers the virtual parent over real DOM parent when present.
|
8
12
|
*/
|
13
|
+
|
14
|
+
|
9
15
|
function getParent(child) {
|
10
|
-
|
16
|
+
return child && getVirtualParent_1.getVirtualParent(child) || (child === null || child === void 0 ? void 0 : child.parentNode);
|
11
17
|
}
|
18
|
+
|
12
19
|
exports.getParent = getParent;
|
13
20
|
//# sourceMappingURL=getParent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../src/virtualParent/getParent.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,kBAAA,gBAAA,OAAA,CAAA,oBAAA,CAAA;AAEA;;;AAGG;;;AACH,SAAgB,SAAhB,CAA0B,KAA1B,EAAmD;AACjD,SAAQ,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","sourceRoot":""}
|
@@ -1,16 +1,25 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
3
6
|
exports.getVirtualParent = void 0;
|
4
|
-
|
7
|
+
|
8
|
+
const isVirtualElement_1 = /*#__PURE__*/require("./isVirtualElement");
|
5
9
|
/**
|
6
10
|
* Gets the virtual parent given the child element, if it exists.
|
7
11
|
*/
|
12
|
+
|
13
|
+
|
8
14
|
function getVirtualParent(child) {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
15
|
+
let parent;
|
16
|
+
|
17
|
+
if (isVirtualElement_1.isVirtualElement(child)) {
|
18
|
+
parent = child._virtual.parent;
|
19
|
+
}
|
20
|
+
|
21
|
+
return parent;
|
14
22
|
}
|
23
|
+
|
15
24
|
exports.getVirtualParent = getVirtualParent;
|
16
25
|
//# sourceMappingURL=getVirtualParent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../src/virtualParent/getVirtualParent.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,kBAAA,gBAAA,OAAA,CAAA,oBAAA,CAAA;AACA;;AAEG;;;AACH,SAAgB,gBAAhB,CAAiC,KAAjC,EAAmD;AACjD,MAAI,MAAJ;;AACA,MAAI,kBAAA,CAAA,gBAAA,CAAiB,KAAjB,CAAJ,EAA6B;AAC3B,IAAA,MAAM,GAAG,KAAK,CAAC,QAAN,CAAe,MAAxB;AACD;;AACD,SAAO,MAAP;AACD;;AAND,OAAA,CAAA,gBAAA,GAAA,gBAAA","sourceRoot":""}
|
@@ -1,9 +1,18 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
|
-
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
|
7
|
+
const tslib_1 = /*#__PURE__*/require("tslib");
|
8
|
+
|
4
9
|
tslib_1.__exportStar(require("./elementContains"), exports);
|
10
|
+
|
5
11
|
tslib_1.__exportStar(require("./getParent"), exports);
|
12
|
+
|
6
13
|
tslib_1.__exportStar(require("./getVirtualParent"), exports);
|
14
|
+
|
7
15
|
tslib_1.__exportStar(require("./isVirtualElement"), exports);
|
16
|
+
|
8
17
|
tslib_1.__exportStar(require("./setVirtualParent"), exports);
|
9
18
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../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","sourceRoot":""}
|
@@ -1,11 +1,16 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
3
6
|
exports.isVirtualElement = void 0;
|
4
7
|
/**
|
5
8
|
* Determines whether or not an element has the virtual hierarchy extension.
|
6
9
|
*/
|
10
|
+
|
7
11
|
function isVirtualElement(element) {
|
8
|
-
|
12
|
+
return element && !!element._virtual;
|
9
13
|
}
|
14
|
+
|
10
15
|
exports.isVirtualElement = isVirtualElement;
|
11
16
|
//# sourceMappingURL=isVirtualElement.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../src/virtualParent/isVirtualElement.ts"],"names":[],"mappings":";;;;;;AAEA;;AAEG;;AACH,SAAgB,gBAAhB,CAAiC,OAAjC,EAAsE;AACpE,SAAO,OAAO,IAAI,CAAC,CAAkB,OAAQ,CAAC,QAA9C;AACD;;AAFD,OAAA,CAAA,gBAAA,GAAA,gBAAA","sourceRoot":""}
|
@@ -1,5 +1,8 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
3
6
|
exports.setVirtualParent = void 0;
|
4
7
|
/**
|
5
8
|
* Sets the virtual parent of an element.
|
@@ -7,15 +10,20 @@ exports.setVirtualParent = void 0;
|
|
7
10
|
* @param child - Theme element to set the virtual parent
|
8
11
|
* @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship
|
9
12
|
*/
|
13
|
+
|
10
14
|
function setVirtualParent(child, parent) {
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
virtualChild._virtual
|
15
|
+
if (!child) {
|
16
|
+
return;
|
17
|
+
}
|
18
|
+
|
19
|
+
const virtualChild = child;
|
20
|
+
|
21
|
+
if (!virtualChild._virtual) {
|
22
|
+
virtualChild._virtual = {};
|
23
|
+
}
|
24
|
+
|
25
|
+
virtualChild._virtual.parent = parent || undefined;
|
19
26
|
}
|
27
|
+
|
20
28
|
exports.setVirtualParent = setVirtualParent;
|
21
29
|
//# sourceMappingURL=setVirtualParent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../src/virtualParent/setVirtualParent.ts"],"names":[],"mappings":";;;;;;AAEA;;;;;AAKG;;AACH,SAAgB,gBAAhB,CAAiC,KAAjC,EAAqD,MAArD,EAAyE;AACvE,MAAI,CAAC,KAAL,EAAY;AACV;AACD;;AAED,QAAM,YAAY,GAAmB,KAArC;;AAEA,MAAI,CAAC,YAAY,CAAC,QAAlB,EAA4B;AAC1B,IAAA,YAAY,CAAC,QAAb,GAAwB,EAAxB;AACD;;AAED,EAAA,YAAY,CAAC,QAAb,CAAsB,MAAtB,GAA+B,MAAM,IAAI,SAAzC;AACD;;AAZD,OAAA,CAAA,gBAAA,GAAA,gBAAA","sourceRoot":""}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-portal",
|
3
|
-
"version": "9.0.0-beta.
|
3
|
+
"version": "9.0.0-beta.5",
|
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",
|
@@ -21,12 +21,13 @@
|
|
21
21
|
"start": "yarn storybook",
|
22
22
|
"test": "jest",
|
23
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
|
+
"build:local": "tsc -p ./tsconfig.lib.json --module esnext --emitDeclarationOnly && node ../../scripts/typescript/normalize-import --output ./dist/packages/react-portal/src && yarn docs",
|
25
|
+
"storybook": "start-storybook",
|
26
|
+
"type-check": "tsc -b tsconfig.json"
|
26
27
|
},
|
27
28
|
"devDependencies": {
|
28
29
|
"@fluentui/eslint-plugin": "*",
|
29
|
-
"@fluentui/jest-serializer-make-styles": "9.0.0-beta.
|
30
|
+
"@fluentui/jest-serializer-make-styles": "9.0.0-beta.4",
|
30
31
|
"@fluentui/react-conformance": "*",
|
31
32
|
"@fluentui/scripts": "^1.0.0",
|
32
33
|
"@types/enzyme": "3.10.3",
|
@@ -38,13 +39,14 @@
|
|
38
39
|
"enzyme-adapter-react-16": "^1.15.0",
|
39
40
|
"react": "16.8.6",
|
40
41
|
"react-dom": "16.8.6",
|
41
|
-
"react-test-renderer": "^16.3.0"
|
42
|
+
"react-test-renderer": "^16.3.0",
|
43
|
+
"@fluentui/babel-make-styles": "9.0.0-beta.4"
|
42
44
|
},
|
43
45
|
"dependencies": {
|
44
|
-
"@fluentui/react-make-styles": "9.0.0-beta.
|
45
|
-
"@fluentui/react-shared-contexts": "9.0.0-beta.
|
46
|
-
"@fluentui/react-tabster": "9.0.0-beta.
|
47
|
-
"@fluentui/react-utilities": "9.0.0-beta.
|
46
|
+
"@fluentui/react-make-styles": "9.0.0-beta.4",
|
47
|
+
"@fluentui/react-shared-contexts": "9.0.0-beta.4",
|
48
|
+
"@fluentui/react-tabster": "9.0.0-beta.5",
|
49
|
+
"@fluentui/react-utilities": "9.0.0-beta.4",
|
48
50
|
"tslib": "^2.1.0"
|
49
51
|
},
|
50
52
|
"peerDependencies": {
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import { isConformant as baseIsConformant } from '@fluentui/react-conformance';
|
2
|
-
export function isConformant(testInfo) {
|
3
|
-
const defaultOptions = {
|
4
|
-
asPropHandlesRef: true,
|
5
|
-
componentPath: module.parent.filename.replace('.test', ''),
|
6
|
-
};
|
7
|
-
baseIsConformant(defaultOptions, testInfo);
|
8
|
-
}
|
9
|
-
//# sourceMappingURL=isConformant.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"isConformant.js","sourceRoot":"","sources":["../../src/common/isConformant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAG/E,MAAM,UAAU,YAAY,CAC1B,QAAyF;IAEzF,MAAM,cAAc,GAAyC;QAC3D,gBAAgB,EAAE,IAAI;QACtB,aAAa,EAAE,MAAO,CAAC,MAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;KAC7D,CAAC;IAEF,gBAAgB,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;AAC7C,CAAC"}
|
@@ -1,13 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.isConformant = void 0;
|
4
|
-
const react_conformance_1 = require("@fluentui/react-conformance");
|
5
|
-
function isConformant(testInfo) {
|
6
|
-
const 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
|
-
//# sourceMappingURL=isConformant.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"isConformant.js","sourceRoot":"","sources":["../../src/common/isConformant.ts"],"names":[],"mappings":";;;AAAA,mEAA+E;AAG/E,SAAgB,YAAY,CAC1B,QAAyF;IAEzF,MAAM,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"}
|