@fluentui/react-portal 0.0.0-nightly-20220302-0405.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/CHANGELOG.json +2010 -0
  2. package/CHANGELOG.md +749 -0
  3. package/LICENSE +15 -0
  4. package/README.md +147 -0
  5. package/Spec.md +254 -0
  6. package/dist/react-portal.d.ts +62 -0
  7. package/lib/Portal.d.ts +1 -0
  8. package/lib/Portal.js +2 -0
  9. package/lib/Portal.js.map +1 -0
  10. package/lib/components/Portal/Portal.d.ts +7 -0
  11. package/lib/components/Portal/Portal.js +13 -0
  12. package/lib/components/Portal/Portal.js.map +1 -0
  13. package/lib/components/Portal/Portal.types.d.ts +22 -0
  14. package/lib/components/Portal/Portal.types.js +2 -0
  15. package/lib/components/Portal/Portal.types.js.map +1 -0
  16. package/lib/components/Portal/index.d.ts +4 -0
  17. package/lib/components/Portal/index.js +5 -0
  18. package/lib/components/Portal/index.js.map +1 -0
  19. package/lib/components/Portal/renderPortal.d.ts +6 -0
  20. package/lib/components/Portal/renderPortal.js +13 -0
  21. package/lib/components/Portal/renderPortal.js.map +1 -0
  22. package/lib/components/Portal/usePortal.d.ts +9 -0
  23. package/lib/components/Portal/usePortal.js +35 -0
  24. package/lib/components/Portal/usePortal.js.map +1 -0
  25. package/lib/components/Portal/usePortalMountNode.d.ts +10 -0
  26. package/lib/components/Portal/usePortalMountNode.js +36 -0
  27. package/lib/components/Portal/usePortalMountNode.js.map +1 -0
  28. package/lib/index.d.ts +2 -0
  29. package/lib/index.js +3 -0
  30. package/lib/index.js.map +1 -0
  31. package/lib/tsdoc-metadata.json +11 -0
  32. package/lib/virtualParent/elementContains.d.ts +7 -0
  33. package/lib/virtualParent/elementContains.js +30 -0
  34. package/lib/virtualParent/elementContains.js.map +1 -0
  35. package/lib/virtualParent/getParent.d.ts +5 -0
  36. package/lib/virtualParent/getParent.js +10 -0
  37. package/lib/virtualParent/getParent.js.map +1 -0
  38. package/lib/virtualParent/getVirtualParent.d.ts +4 -0
  39. package/lib/virtualParent/getVirtualParent.js +15 -0
  40. package/lib/virtualParent/getVirtualParent.js.map +1 -0
  41. package/lib/virtualParent/index.d.ts +5 -0
  42. package/lib/virtualParent/index.js +6 -0
  43. package/lib/virtualParent/index.js.map +1 -0
  44. package/lib/virtualParent/isVirtualElement.d.ts +5 -0
  45. package/lib/virtualParent/isVirtualElement.js +7 -0
  46. package/lib/virtualParent/isVirtualElement.js.map +1 -0
  47. package/lib/virtualParent/setVirtualParent.d.ts +7 -0
  48. package/lib/virtualParent/setVirtualParent.js +20 -0
  49. package/lib/virtualParent/setVirtualParent.js.map +1 -0
  50. package/lib/virtualParent/types.d.ts +5 -0
  51. package/lib/virtualParent/types.js +2 -0
  52. package/lib/virtualParent/types.js.map +1 -0
  53. package/lib-commonjs/Portal.d.ts +1 -0
  54. package/lib-commonjs/Portal.js +10 -0
  55. package/lib-commonjs/Portal.js.map +1 -0
  56. package/lib-commonjs/components/Portal/Portal.d.ts +7 -0
  57. package/lib-commonjs/components/Portal/Portal.js +24 -0
  58. package/lib-commonjs/components/Portal/Portal.js.map +1 -0
  59. package/lib-commonjs/components/Portal/Portal.types.d.ts +22 -0
  60. package/lib-commonjs/components/Portal/Portal.types.js +6 -0
  61. package/lib-commonjs/components/Portal/Portal.types.js.map +1 -0
  62. package/lib-commonjs/components/Portal/index.d.ts +4 -0
  63. package/lib-commonjs/components/Portal/index.js +16 -0
  64. package/lib-commonjs/components/Portal/index.js.map +1 -0
  65. package/lib-commonjs/components/Portal/renderPortal.d.ts +6 -0
  66. package/lib-commonjs/components/Portal/renderPortal.js +24 -0
  67. package/lib-commonjs/components/Portal/renderPortal.js.map +1 -0
  68. package/lib-commonjs/components/Portal/usePortal.d.ts +9 -0
  69. package/lib-commonjs/components/Portal/usePortal.js +48 -0
  70. package/lib-commonjs/components/Portal/usePortal.js.map +1 -0
  71. package/lib-commonjs/components/Portal/usePortalMountNode.d.ts +10 -0
  72. package/lib-commonjs/components/Portal/usePortalMountNode.js +49 -0
  73. package/lib-commonjs/components/Portal/usePortalMountNode.js.map +1 -0
  74. package/lib-commonjs/index.d.ts +2 -0
  75. package/lib-commonjs/index.js +26 -0
  76. package/lib-commonjs/index.js.map +1 -0
  77. package/lib-commonjs/virtualParent/elementContains.d.ts +7 -0
  78. package/lib-commonjs/virtualParent/elementContains.js +40 -0
  79. package/lib-commonjs/virtualParent/elementContains.js.map +1 -0
  80. package/lib-commonjs/virtualParent/getParent.d.ts +5 -0
  81. package/lib-commonjs/virtualParent/getParent.js +20 -0
  82. package/lib-commonjs/virtualParent/getParent.js.map +1 -0
  83. package/lib-commonjs/virtualParent/getVirtualParent.d.ts +4 -0
  84. package/lib-commonjs/virtualParent/getVirtualParent.js +25 -0
  85. package/lib-commonjs/virtualParent/getVirtualParent.js.map +1 -0
  86. package/lib-commonjs/virtualParent/index.d.ts +5 -0
  87. package/lib-commonjs/virtualParent/index.js +18 -0
  88. package/lib-commonjs/virtualParent/index.js.map +1 -0
  89. package/lib-commonjs/virtualParent/isVirtualElement.d.ts +5 -0
  90. package/lib-commonjs/virtualParent/isVirtualElement.js +16 -0
  91. package/lib-commonjs/virtualParent/isVirtualElement.js.map +1 -0
  92. package/lib-commonjs/virtualParent/setVirtualParent.d.ts +7 -0
  93. package/lib-commonjs/virtualParent/setVirtualParent.js +29 -0
  94. package/lib-commonjs/virtualParent/setVirtualParent.js.map +1 -0
  95. package/lib-commonjs/virtualParent/types.d.ts +5 -0
  96. package/lib-commonjs/virtualParent/types.js +6 -0
  97. package/lib-commonjs/virtualParent/types.js.map +1 -0
  98. package/package.json +62 -0
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.elementContains = void 0;
7
+
8
+ const getParent_1 = /*#__PURE__*/require("./getParent");
9
+ /**
10
+ * Similar functionality to `element.contains` DOM API for use with out of order DOM elements that
11
+ * checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent
12
+ *
13
+ * @returns true if the child can find the parent in its virtual hierarchy
14
+ */
15
+
16
+
17
+ function elementContains(parent, child) {
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) {
29
+ return true;
30
+ }
31
+
32
+ child = nextParent;
33
+ }
34
+ }
35
+
36
+ return false;
37
+ }
38
+
39
+ exports.elementContains = elementContains;
40
+ //# sourceMappingURL=elementContains.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["virtualParent/elementContains.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,WAAA,gBAAA,OAAA,CAAA,aAAA,CAAA;AACA;;;;;AAKG;;;AACH,SAAgB,eAAhB,CAAgC,MAAhC,EAA4D,KAA5D,EAAqF;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","sourcesContent":["import { getParent } from './getParent';\n/**\n * Similar functionality to `element.contains` DOM API for use with out of order DOM elements that\n * checks the virtual parent hierarchy. If a virtual parents exists, it is chosen over the actual parent\n *\n * @returns true if the child can find the parent in its virtual hierarchy\n */\nexport function elementContains(parent: HTMLElement | null, child: HTMLElement | null): boolean {\n if (!parent || !child) {\n return false;\n }\n\n if (parent === child) {\n return true;\n } else {\n while (child) {\n const nextParent: HTMLElement | null = getParent(child);\n\n if (nextParent === parent) {\n return true;\n }\n\n child = nextParent;\n }\n }\n\n return false;\n}\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Gets the element which is the parent of a given element.
3
+ * This method prefers the virtual parent over real DOM parent when present.
4
+ */
5
+ export declare function getParent(child: HTMLElement | null): HTMLElement | null;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getParent = void 0;
7
+
8
+ const getVirtualParent_1 = /*#__PURE__*/require("./getVirtualParent");
9
+ /**
10
+ * Gets the element which is the parent of a given element.
11
+ * This method prefers the virtual parent over real DOM parent when present.
12
+ */
13
+
14
+
15
+ function getParent(child) {
16
+ return child && getVirtualParent_1.getVirtualParent(child) || (child === null || child === void 0 ? void 0 : child.parentNode);
17
+ }
18
+
19
+ exports.getParent = getParent;
20
+ //# sourceMappingURL=getParent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["virtualParent/getParent.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,kBAAA,gBAAA,OAAA,CAAA,oBAAA,CAAA;AAEA;;;AAGG;;;AACH,SAAgB,SAAhB,CAA0B,KAA1B,EAAmD;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","sourcesContent":["import { getVirtualParent } from './getVirtualParent';\n\n/**\n * Gets the element which is the parent of a given element.\n * This method prefers the virtual parent over real DOM parent when present.\n */\nexport function getParent(child: HTMLElement | null): HTMLElement | null {\n return (child && getVirtualParent(child)) || (child?.parentNode as HTMLElement | null);\n}\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Gets the virtual parent given the child element, if it exists.
3
+ */
4
+ export declare function getVirtualParent(child: HTMLElement): HTMLElement | undefined;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getVirtualParent = void 0;
7
+
8
+ const isVirtualElement_1 = /*#__PURE__*/require("./isVirtualElement");
9
+ /**
10
+ * Gets the virtual parent given the child element, if it exists.
11
+ */
12
+
13
+
14
+ function getVirtualParent(child) {
15
+ let parent;
16
+
17
+ if (isVirtualElement_1.isVirtualElement(child)) {
18
+ parent = child._virtual.parent;
19
+ }
20
+
21
+ return parent;
22
+ }
23
+
24
+ exports.getVirtualParent = getVirtualParent;
25
+ //# sourceMappingURL=getVirtualParent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["virtualParent/getVirtualParent.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,kBAAA,gBAAA,OAAA,CAAA,oBAAA,CAAA;AACA;;AAEG;;;AACH,SAAgB,gBAAhB,CAAiC,KAAjC,EAAmD;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","sourcesContent":["import { isVirtualElement } from './isVirtualElement';\n/**\n * Gets the virtual parent given the child element, if it exists.\n */\nexport function getVirtualParent(child: HTMLElement): HTMLElement | undefined {\n let parent: HTMLElement | undefined;\n if (isVirtualElement(child)) {\n parent = child._virtual.parent;\n }\n return parent;\n}\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,5 @@
1
+ export * from './elementContains';
2
+ export * from './getParent';
3
+ export * from './getVirtualParent';
4
+ export * from './isVirtualElement';
5
+ export * from './setVirtualParent';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ const tslib_1 = /*#__PURE__*/require("tslib");
8
+
9
+ tslib_1.__exportStar(require("./elementContains"), exports);
10
+
11
+ tslib_1.__exportStar(require("./getParent"), exports);
12
+
13
+ tslib_1.__exportStar(require("./getVirtualParent"), exports);
14
+
15
+ tslib_1.__exportStar(require("./isVirtualElement"), exports);
16
+
17
+ tslib_1.__exportStar(require("./setVirtualParent"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["virtualParent/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,aAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './elementContains';\nexport * from './getParent';\nexport * from './getVirtualParent';\nexport * from './isVirtualElement';\nexport * from './setVirtualParent';\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,5 @@
1
+ import type { VirtualElement } from './types';
2
+ /**
3
+ * Determines whether or not an element has the virtual hierarchy extension.
4
+ */
5
+ export declare function isVirtualElement(element: HTMLElement | VirtualElement): element is VirtualElement;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isVirtualElement = void 0;
7
+ /**
8
+ * Determines whether or not an element has the virtual hierarchy extension.
9
+ */
10
+
11
+ function isVirtualElement(element) {
12
+ return element && !!element._virtual;
13
+ }
14
+
15
+ exports.isVirtualElement = isVirtualElement;
16
+ //# sourceMappingURL=isVirtualElement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["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","sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Determines whether or not an element has the virtual hierarchy extension.\n */\nexport function isVirtualElement(element: HTMLElement | VirtualElement): element is VirtualElement {\n return element && !!(<VirtualElement>element)._virtual;\n}\n"],"sourceRoot":"../src/"}
@@ -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,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.setVirtualParent = void 0;
7
+ /**
8
+ * Sets the virtual parent of an element.
9
+ *
10
+ * @param child - Theme element to set the virtual parent
11
+ * @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship
12
+ */
13
+
14
+ function setVirtualParent(child, parent) {
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;
26
+ }
27
+
28
+ exports.setVirtualParent = setVirtualParent;
29
+ //# sourceMappingURL=setVirtualParent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["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","sourcesContent":["import type { VirtualElement } from './types';\n\n/**\n * Sets the virtual parent of an element.\n *\n * @param child - Theme element to set the virtual parent\n * @param parent - The virtual parent, use `undefined` to remove a virtual parent relationship\n */\nexport function setVirtualParent(child: HTMLElement, parent?: HTMLElement): void {\n if (!child) {\n return;\n }\n\n const virtualChild = <VirtualElement>child;\n\n if (!virtualChild._virtual) {\n virtualChild._virtual = {};\n }\n\n virtualChild._virtual.parent = parent || undefined;\n}\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,5 @@
1
+ export interface VirtualElement extends HTMLElement {
2
+ _virtual: {
3
+ parent?: HTMLElement;
4
+ };
5
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":"../src/"}
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@fluentui/react-portal",
3
+ "version": "0.0.0-nightly-20220302-0405.1",
4
+ "description": "A utility component that creates portals compatible with Fluent UI",
5
+ "main": "lib-commonjs/index.js",
6
+ "module": "lib/index.js",
7
+ "typings": "lib/index.d.ts",
8
+ "sideEffects": false,
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/microsoft/fluentui"
12
+ },
13
+ "license": "MIT",
14
+ "scripts": {
15
+ "build": "just-scripts build",
16
+ "bundle-size": "bundle-size measure",
17
+ "clean": "just-scripts clean",
18
+ "code-style": "just-scripts code-style",
19
+ "just": "just-scripts",
20
+ "lint": "just-scripts lint",
21
+ "start": "yarn storybook",
22
+ "test": "jest --passWithNoTests",
23
+ "docs": "api-extractor run --config=config/api-extractor.local.json --local",
24
+ "build:local": "tsc -p ./tsconfig.lib.json --module esnext --emitDeclarationOnly && node ../../scripts/typescript/normalize-import --output ./dist/packages/react-portal/src && yarn docs",
25
+ "storybook": "node ../../scripts/storybook/runner",
26
+ "type-check": "tsc -b tsconfig.json"
27
+ },
28
+ "devDependencies": {
29
+ "@fluentui/eslint-plugin": "*",
30
+ "@fluentui/react-conformance": "*",
31
+ "@fluentui/scripts": "^1.0.0",
32
+ "@types/enzyme": "3.10.3",
33
+ "@types/enzyme-adapter-react-16": "1.0.3",
34
+ "@types/react": "16.9.42",
35
+ "@types/react-dom": "16.9.10",
36
+ "@types/react-test-renderer": "^16.0.0",
37
+ "enzyme": "~3.10.0",
38
+ "enzyme-adapter-react-16": "^1.15.0",
39
+ "react": "16.8.6",
40
+ "react-dom": "16.8.6",
41
+ "react-test-renderer": "^16.3.0"
42
+ },
43
+ "dependencies": {
44
+ "@fluentui/react-shared-contexts": "0.0.0-nightly-20220302-0405.1",
45
+ "@fluentui/react-tabster": "0.0.0-nightly-20220302-0405.1",
46
+ "@fluentui/react-utilities": "0.0.0-nightly-20220302-0405.1",
47
+ "tslib": "^2.1.0"
48
+ },
49
+ "peerDependencies": {
50
+ "@types/react": ">=16.8.0 <18.0.0",
51
+ "@types/react-dom": ">=16.8.0 <18.0.0",
52
+ "react": ">=16.8.0 <18.0.0",
53
+ "react-dom": ">=16.8.0 <18.0.0"
54
+ },
55
+ "beachball": {
56
+ "disallowedChangeTypes": [
57
+ "major",
58
+ "minor",
59
+ "patch"
60
+ ]
61
+ }
62
+ }