@elliemae/ds-portal 3.0.0-next.2 → 3.0.0-next.3
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.
- package/dist/cjs/DSPortal.js +87 -0
- package/dist/cjs/DSPortal.js.map +7 -0
- package/dist/cjs/index.js +36 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/esm/DSPortal.js +58 -0
- package/dist/esm/DSPortal.js.map +7 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +7 -0
- package/package.json +30 -21
- package/cjs/DSPortal.js +0 -94
- package/cjs/_virtual/_commonjsHelpers.js +0 -7
- package/cjs/_virtual/ie-remove-polyfill.tsx_commonjs-exports.js +0 -7
- package/cjs/ie-remove-polyfill.js +0 -22
- package/cjs/index.js +0 -10
- package/esm/DSPortal.js +0 -84
- package/esm/_virtual/_commonjsHelpers.js +0 -3
- package/esm/_virtual/ie-remove-polyfill.tsx_commonjs-exports.js +0 -3
- package/esm/ie-remove-polyfill.js +0 -19
- package/esm/index.js +0 -1
- package/types/DSPortal.d.ts +0 -18
- package/types/ie-remove-polyfill.d.ts +0 -0
- package/types/index.d.ts +0 -2
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (module2, isNodeMode) => {
|
|
21
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
+
return (module2, temp) => {
|
|
25
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
+
};
|
|
27
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
+
var DSPortal_exports = {};
|
|
29
|
+
__export(DSPortal_exports, {
|
|
30
|
+
DSPortal: () => DSPortal,
|
|
31
|
+
default: () => DSPortal_default
|
|
32
|
+
});
|
|
33
|
+
var React = __toESM(require("react"));
|
|
34
|
+
var import_react = __toESM(require("react"));
|
|
35
|
+
var import_react_dom = __toESM(require("react-dom"));
|
|
36
|
+
var import_ds_classnames = require("@elliemae/ds-classnames");
|
|
37
|
+
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
38
|
+
const blockName = "portal";
|
|
39
|
+
const canRenderPortal = (0, import_ds_utilities.isFunction)(import_react_dom.default.createPortal);
|
|
40
|
+
class DSPortal extends import_react.Component {
|
|
41
|
+
constructor() {
|
|
42
|
+
super(...arguments);
|
|
43
|
+
this.state = { isMounted: false };
|
|
44
|
+
}
|
|
45
|
+
componentDidMount() {
|
|
46
|
+
const { onRender } = this.props;
|
|
47
|
+
this.portalEl = this.createPortalContainer();
|
|
48
|
+
if (import_ds_utilities.DOCUMENT && this.portalEl) {
|
|
49
|
+
import_ds_utilities.DOCUMENT.body.appendChild(this.portalEl);
|
|
50
|
+
onRender();
|
|
51
|
+
this.setState({ isMounted: true });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
componentDidUpdate() {
|
|
55
|
+
if (!canRenderPortal) {
|
|
56
|
+
this.renderNoPortal();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
componentWillUnmount() {
|
|
60
|
+
if (this.portalEl) {
|
|
61
|
+
this.portalEl.parentNode.removeChild(this.portalEl);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
createPortalContainer() {
|
|
65
|
+
if (!import_ds_utilities.DOCUMENT)
|
|
66
|
+
return null;
|
|
67
|
+
const { className } = this.props;
|
|
68
|
+
const { cssClassName } = (0, import_ds_classnames.convertPropToCssClassName)(blockName, className);
|
|
69
|
+
const container = import_ds_utilities.DOCUMENT.createElement("div");
|
|
70
|
+
container.classList.add(cssClassName);
|
|
71
|
+
container.setAttribute("data-testid", "portal");
|
|
72
|
+
return container;
|
|
73
|
+
}
|
|
74
|
+
renderNoPortal() {
|
|
75
|
+
const { children } = this.props;
|
|
76
|
+
import_react_dom.default.unstable_renderSubtreeIntoContainer(this, /* @__PURE__ */ import_react.default.createElement("div", null, children), this.portalEl);
|
|
77
|
+
}
|
|
78
|
+
render() {
|
|
79
|
+
const { children } = this.props;
|
|
80
|
+
const { isMounted } = this.state;
|
|
81
|
+
return !canRenderPortal || !isMounted ? null : import_react_dom.default.createPortal(children, this.portalEl);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
DSPortal.defaultProps = { onRender: () => null };
|
|
85
|
+
var DSPortal_default = DSPortal;
|
|
86
|
+
module.exports = __toCommonJS(DSPortal_exports);
|
|
87
|
+
//# sourceMappingURL=DSPortal.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/DSPortal.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable react/prop-types */\nimport React, { Component } from 'react';\nimport ReactDOM from 'react-dom';\nimport { convertPropToCssClassName } from '@elliemae/ds-classnames';\nimport { isFunction, DOCUMENT } from '@elliemae/ds-utilities';\n\nconst blockName = 'portal';\n\nconst canRenderPortal = isFunction(ReactDOM.createPortal);\n\n// TODO: If this is rendered on server, is going to break\n\nclass DSPortal extends Component {\n // eslint-disable-next-line react/static-property-placement\n static defaultProps = { onRender: () => null };\n\n // eslint-disable-next-line react/state-in-constructor\n state = { isMounted: false };\n\n componentDidMount() {\n const { onRender } = this.props;\n this.portalEl = this.createPortalContainer();\n if (DOCUMENT && this.portalEl) {\n DOCUMENT.body.appendChild(this.portalEl);\n onRender();\n this.setState({ isMounted: true });\n }\n }\n\n componentDidUpdate() {\n if (!canRenderPortal) {\n this.renderNoPortal();\n }\n }\n\n componentWillUnmount() {\n if (this.portalEl) {\n this.portalEl.parentNode.removeChild(this.portalEl);\n }\n }\n\n createPortalContainer() {\n if (!DOCUMENT) return null;\n\n const { className } = this.props;\n const { cssClassName } = convertPropToCssClassName(blockName, className);\n const container = DOCUMENT.createElement('div');\n container.classList.add(cssClassName);\n container.setAttribute('data-testid', 'portal');\n\n return container;\n }\n\n renderNoPortal() {\n const { children } = this.props;\n ReactDOM.unstable_renderSubtreeIntoContainer(\n this,\n <div>{children}</div>,\n this.portalEl,\n );\n }\n\n render() {\n const { children } = this.props;\n const { isMounted } = this.state;\n return !canRenderPortal || !isMounted\n ? null\n : ReactDOM.createPortal(children, this.portalEl);\n }\n}\nexport { DSPortal };\nexport default DSPortal;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAAiC;AACjC,uBAAqB;AACrB,2BAA0C;AAC1C,0BAAqC;AAErC,MAAM,YAAY;AAElB,MAAM,kBAAkB,oCAAW,yBAAS;AAI5C,uBAAuB,uBAAU;AAAA,EAAjC,cAZA;AAYA;AAKE,iBAAQ,EAAE,WAAW;AAAA;AAAA,EAErB,oBAAoB;AAClB,UAAM,EAAE,aAAa,KAAK;AAC1B,SAAK,WAAW,KAAK;AACrB,QAAI,gCAAY,KAAK,UAAU;AAC7B,mCAAS,KAAK,YAAY,KAAK;AAC/B;AACA,WAAK,SAAS,EAAE,WAAW;AAAA;AAAA;AAAA,EAI/B,qBAAqB;AACnB,QAAI,CAAC,iBAAiB;AACpB,WAAK;AAAA;AAAA;AAAA,EAIT,uBAAuB;AACrB,QAAI,KAAK,UAAU;AACjB,WAAK,SAAS,WAAW,YAAY,KAAK;AAAA;AAAA;AAAA,EAI9C,wBAAwB;AACtB,QAAI,CAAC;AAAU,aAAO;AAEtB,UAAM,EAAE,cAAc,KAAK;AAC3B,UAAM,EAAE,iBAAiB,oDAA0B,WAAW;AAC9D,UAAM,YAAY,6BAAS,cAAc;AACzC,cAAU,UAAU,IAAI;AACxB,cAAU,aAAa,eAAe;AAEtC,WAAO;AAAA;AAAA,EAGT,iBAAiB;AACf,UAAM,EAAE,aAAa,KAAK;AAC1B,6BAAS,oCACP,MACA,mDAAC,OAAD,MAAM,WACN,KAAK;AAAA;AAAA,EAIT,SAAS;AACP,UAAM,EAAE,aAAa,KAAK;AAC1B,UAAM,EAAE,cAAc,KAAK;AAC3B,WAAO,CAAC,mBAAmB,CAAC,YACxB,OACA,yBAAS,aAAa,UAAU,KAAK;AAAA;AAAA;AArDpC,AAFT,SAES,eAAe,EAAE,UAAU,MAAM;AAyD1C,IAAO,mBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (module2, isNodeMode) => {
|
|
21
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
+
return (module2, temp) => {
|
|
25
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
+
};
|
|
27
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
+
var src_exports = {};
|
|
29
|
+
__export(src_exports, {
|
|
30
|
+
default: () => import_DSPortal.default
|
|
31
|
+
});
|
|
32
|
+
var React = __toESM(require("react"));
|
|
33
|
+
__reExport(src_exports, require("./DSPortal"));
|
|
34
|
+
var import_DSPortal = __toESM(require("./DSPortal"));
|
|
35
|
+
module.exports = __toCommonJS(src_exports);
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["export * from './DSPortal';\nexport { default } from './DSPortal';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAAc;AACd,sBAAwB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2, { Component } from "react";
|
|
3
|
+
import ReactDOM from "react-dom";
|
|
4
|
+
import { convertPropToCssClassName } from "@elliemae/ds-classnames";
|
|
5
|
+
import { isFunction, DOCUMENT } from "@elliemae/ds-utilities";
|
|
6
|
+
const blockName = "portal";
|
|
7
|
+
const canRenderPortal = isFunction(ReactDOM.createPortal);
|
|
8
|
+
class DSPortal extends Component {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.state = { isMounted: false };
|
|
12
|
+
}
|
|
13
|
+
componentDidMount() {
|
|
14
|
+
const { onRender } = this.props;
|
|
15
|
+
this.portalEl = this.createPortalContainer();
|
|
16
|
+
if (DOCUMENT && this.portalEl) {
|
|
17
|
+
DOCUMENT.body.appendChild(this.portalEl);
|
|
18
|
+
onRender();
|
|
19
|
+
this.setState({ isMounted: true });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
componentDidUpdate() {
|
|
23
|
+
if (!canRenderPortal) {
|
|
24
|
+
this.renderNoPortal();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
componentWillUnmount() {
|
|
28
|
+
if (this.portalEl) {
|
|
29
|
+
this.portalEl.parentNode.removeChild(this.portalEl);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
createPortalContainer() {
|
|
33
|
+
if (!DOCUMENT)
|
|
34
|
+
return null;
|
|
35
|
+
const { className } = this.props;
|
|
36
|
+
const { cssClassName } = convertPropToCssClassName(blockName, className);
|
|
37
|
+
const container = DOCUMENT.createElement("div");
|
|
38
|
+
container.classList.add(cssClassName);
|
|
39
|
+
container.setAttribute("data-testid", "portal");
|
|
40
|
+
return container;
|
|
41
|
+
}
|
|
42
|
+
renderNoPortal() {
|
|
43
|
+
const { children } = this.props;
|
|
44
|
+
ReactDOM.unstable_renderSubtreeIntoContainer(this, /* @__PURE__ */ React2.createElement("div", null, children), this.portalEl);
|
|
45
|
+
}
|
|
46
|
+
render() {
|
|
47
|
+
const { children } = this.props;
|
|
48
|
+
const { isMounted } = this.state;
|
|
49
|
+
return !canRenderPortal || !isMounted ? null : ReactDOM.createPortal(children, this.portalEl);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
DSPortal.defaultProps = { onRender: () => null };
|
|
53
|
+
var DSPortal_default = DSPortal;
|
|
54
|
+
export {
|
|
55
|
+
DSPortal,
|
|
56
|
+
DSPortal_default as default
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=DSPortal.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/DSPortal.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/prop-types */\nimport React, { Component } from 'react';\nimport ReactDOM from 'react-dom';\nimport { convertPropToCssClassName } from '@elliemae/ds-classnames';\nimport { isFunction, DOCUMENT } from '@elliemae/ds-utilities';\n\nconst blockName = 'portal';\n\nconst canRenderPortal = isFunction(ReactDOM.createPortal);\n\n// TODO: If this is rendered on server, is going to break\n\nclass DSPortal extends Component {\n // eslint-disable-next-line react/static-property-placement\n static defaultProps = { onRender: () => null };\n\n // eslint-disable-next-line react/state-in-constructor\n state = { isMounted: false };\n\n componentDidMount() {\n const { onRender } = this.props;\n this.portalEl = this.createPortalContainer();\n if (DOCUMENT && this.portalEl) {\n DOCUMENT.body.appendChild(this.portalEl);\n onRender();\n this.setState({ isMounted: true });\n }\n }\n\n componentDidUpdate() {\n if (!canRenderPortal) {\n this.renderNoPortal();\n }\n }\n\n componentWillUnmount() {\n if (this.portalEl) {\n this.portalEl.parentNode.removeChild(this.portalEl);\n }\n }\n\n createPortalContainer() {\n if (!DOCUMENT) return null;\n\n const { className } = this.props;\n const { cssClassName } = convertPropToCssClassName(blockName, className);\n const container = DOCUMENT.createElement('div');\n container.classList.add(cssClassName);\n container.setAttribute('data-testid', 'portal');\n\n return container;\n }\n\n renderNoPortal() {\n const { children } = this.props;\n ReactDOM.unstable_renderSubtreeIntoContainer(\n this,\n <div>{children}</div>,\n this.portalEl,\n );\n }\n\n render() {\n const { children } = this.props;\n const { isMounted } = this.state;\n return !canRenderPortal || !isMounted\n ? null\n : ReactDOM.createPortal(children, this.portalEl);\n }\n}\nexport { DSPortal };\nexport default DSPortal;\n"],
|
|
5
|
+
"mappings": "AAAA;ACCA;AACA;AACA;AACA;AAEA,MAAM,YAAY;AAElB,MAAM,kBAAkB,WAAW,SAAS;AAI5C,uBAAuB,UAAU;AAAA,EAAjC,cAZA;AAYA;AAKE,iBAAQ,EAAE,WAAW;AAAA;AAAA,EAErB,oBAAoB;AAClB,UAAM,EAAE,aAAa,KAAK;AAC1B,SAAK,WAAW,KAAK;AACrB,QAAI,YAAY,KAAK,UAAU;AAC7B,eAAS,KAAK,YAAY,KAAK;AAC/B;AACA,WAAK,SAAS,EAAE,WAAW;AAAA;AAAA;AAAA,EAI/B,qBAAqB;AACnB,QAAI,CAAC,iBAAiB;AACpB,WAAK;AAAA;AAAA;AAAA,EAIT,uBAAuB;AACrB,QAAI,KAAK,UAAU;AACjB,WAAK,SAAS,WAAW,YAAY,KAAK;AAAA;AAAA;AAAA,EAI9C,wBAAwB;AACtB,QAAI,CAAC;AAAU,aAAO;AAEtB,UAAM,EAAE,cAAc,KAAK;AAC3B,UAAM,EAAE,iBAAiB,0BAA0B,WAAW;AAC9D,UAAM,YAAY,SAAS,cAAc;AACzC,cAAU,UAAU,IAAI;AACxB,cAAU,aAAa,eAAe;AAEtC,WAAO;AAAA;AAAA,EAGT,iBAAiB;AACf,UAAM,EAAE,aAAa,KAAK;AAC1B,aAAS,oCACP,MACA,qCAAC,OAAD,MAAM,WACN,KAAK;AAAA;AAAA,EAIT,SAAS;AACP,UAAM,EAAE,aAAa,KAAK;AAC1B,UAAM,EAAE,cAAc,KAAK;AAC3B,WAAO,CAAC,mBAAmB,CAAC,YACxB,OACA,SAAS,aAAa,UAAU,KAAK;AAAA;AAAA;AArDpC,AAFT,SAES,eAAe,EAAE,UAAU,MAAM;AAyD1C,IAAO,mBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export * from './DSPortal';\nexport { default } from './DSPortal';\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-portal",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Portal",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"module": "./dist/esm/index.js",
|
|
10
|
+
"main": "./dist/cjs/index.js",
|
|
11
|
+
"types": "./dist/types/index.d.ts",
|
|
9
12
|
"exports": {
|
|
10
13
|
".": {
|
|
11
|
-
"import": "./esm/index.js",
|
|
12
|
-
"require": "./cjs/index.js"
|
|
14
|
+
"import": "./dist/esm/index.js",
|
|
15
|
+
"require": "./dist/cjs/index.js"
|
|
13
16
|
},
|
|
14
17
|
"./ie-remove-polyfill": {
|
|
15
|
-
"import": "./esm/ie-remove-polyfill.js",
|
|
16
|
-
"require": "./cjs/ie-remove-polyfill.js"
|
|
18
|
+
"import": "./dist/esm/ie-remove-polyfill.js",
|
|
19
|
+
"require": "./dist/cjs/ie-remove-polyfill.js"
|
|
17
20
|
},
|
|
18
21
|
"./DSPortal": {
|
|
19
|
-
"import": "./esm/DSPortal.js",
|
|
20
|
-
"require": "./cjs/DSPortal.js"
|
|
22
|
+
"import": "./dist/esm/DSPortal.js",
|
|
23
|
+
"require": "./dist/cjs/DSPortal.js"
|
|
21
24
|
}
|
|
22
25
|
},
|
|
23
26
|
"sideEffects": [
|
|
@@ -29,19 +32,19 @@
|
|
|
29
32
|
"url": "https://git.elliemae.io/platform-ui/dimsum.git"
|
|
30
33
|
},
|
|
31
34
|
"engines": {
|
|
32
|
-
"
|
|
33
|
-
"node": ">=
|
|
35
|
+
"pnpm": ">=6",
|
|
36
|
+
"node": ">=16"
|
|
34
37
|
},
|
|
35
38
|
"author": "ICE MT",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
39
|
+
"jestSonar": {
|
|
40
|
+
"sonar56x": true,
|
|
41
|
+
"reportPath": "reports",
|
|
42
|
+
"reportFile": "tests.xml",
|
|
43
|
+
"indent": 4
|
|
41
44
|
},
|
|
42
45
|
"dependencies": {
|
|
43
|
-
"@elliemae/ds-classnames": "3.0.0-next.
|
|
44
|
-
"@elliemae/ds-utilities": "3.0.0-next.
|
|
46
|
+
"@elliemae/ds-classnames": "3.0.0-next.3",
|
|
47
|
+
"@elliemae/ds-utilities": "3.0.0-next.3"
|
|
45
48
|
},
|
|
46
49
|
"peerDependencies": {
|
|
47
50
|
"react": "^17.0.2",
|
|
@@ -49,7 +52,13 @@
|
|
|
49
52
|
},
|
|
50
53
|
"publishConfig": {
|
|
51
54
|
"access": "public",
|
|
52
|
-
"
|
|
53
|
-
|
|
55
|
+
"typeSafety": false
|
|
56
|
+
},
|
|
57
|
+
"scripts": {
|
|
58
|
+
"dev": "cross-env NODE_ENV=development node ../../scripts/build/build.mjs --watch",
|
|
59
|
+
"test": "node ../../scripts/testing/test.mjs",
|
|
60
|
+
"lint": "node ../../scripts/lint.mjs",
|
|
61
|
+
"dts": "node ../../scripts/dts.mjs",
|
|
62
|
+
"build": "cross-env NODE_ENV=production node ../../scripts/build/build.mjs"
|
|
54
63
|
}
|
|
55
64
|
}
|
package/cjs/DSPortal.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
6
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
7
|
-
var react = require('react');
|
|
8
|
-
var ReactDOM = require('react-dom');
|
|
9
|
-
var dsClassnames = require('@elliemae/ds-classnames');
|
|
10
|
-
var dsUtilities = require('@elliemae/ds-utilities');
|
|
11
|
-
require('./ie-remove-polyfill.js');
|
|
12
|
-
|
|
13
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
-
|
|
15
|
-
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
16
|
-
var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
|
|
17
|
-
|
|
18
|
-
const blockName = 'portal';
|
|
19
|
-
const canRenderPortal = dsUtilities.isFunction(ReactDOM__default["default"].createPortal); // TODO: If this is rendered on server, is going to break
|
|
20
|
-
|
|
21
|
-
class DSPortal extends react.Component {
|
|
22
|
-
constructor() {
|
|
23
|
-
super(...arguments);
|
|
24
|
-
this.state = {
|
|
25
|
-
isMounted: false
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
componentDidMount() {
|
|
30
|
-
const {
|
|
31
|
-
onRender
|
|
32
|
-
} = this.props;
|
|
33
|
-
this.portalEl = this.createPortalContainer();
|
|
34
|
-
|
|
35
|
-
if (dsUtilities.DOCUMENT && this.portalEl) {
|
|
36
|
-
dsUtilities.DOCUMENT.body.appendChild(this.portalEl);
|
|
37
|
-
onRender();
|
|
38
|
-
this.setState({
|
|
39
|
-
isMounted: true
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
componentDidUpdate() {
|
|
45
|
-
if (!canRenderPortal) {
|
|
46
|
-
this.renderNoPortal();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
componentWillUnmount() {
|
|
51
|
-
if (this.portalEl) {
|
|
52
|
-
this.portalEl.parentNode.removeChild(this.portalEl);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
createPortalContainer() {
|
|
57
|
-
if (!dsUtilities.DOCUMENT) return null;
|
|
58
|
-
const {
|
|
59
|
-
className
|
|
60
|
-
} = this.props;
|
|
61
|
-
const {
|
|
62
|
-
cssClassName
|
|
63
|
-
} = dsClassnames.convertPropToCssClassName(blockName, className);
|
|
64
|
-
const container = dsUtilities.DOCUMENT.createElement('div');
|
|
65
|
-
container.classList.add(cssClassName);
|
|
66
|
-
container.setAttribute('data-testid', 'portal');
|
|
67
|
-
return container;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
renderNoPortal() {
|
|
71
|
-
const {
|
|
72
|
-
children
|
|
73
|
-
} = this.props;
|
|
74
|
-
ReactDOM__default["default"].unstable_renderSubtreeIntoContainer(this, /*#__PURE__*/_jsx__default["default"]("div", {}, void 0, children), this.portalEl);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
render() {
|
|
78
|
-
const {
|
|
79
|
-
children
|
|
80
|
-
} = this.props;
|
|
81
|
-
const {
|
|
82
|
-
isMounted
|
|
83
|
-
} = this.state;
|
|
84
|
-
return !canRenderPortal || !isMounted ? null : /*#__PURE__*/ReactDOM__default["default"].createPortal(children, this.portalEl);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
DSPortal.defaultProps = {
|
|
90
|
-
onRender: () => null
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
exports.DSPortal = DSPortal;
|
|
94
|
-
exports["default"] = DSPortal;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
6
|
-
|
|
7
|
-
exports.commonjsGlobal = commonjsGlobal;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _commonjsHelpers = require('./_virtual/_commonjsHelpers.js');
|
|
4
|
-
var ieRemovePolyfill = require('./_virtual/ie-remove-polyfill.tsx_commonjs-exports.js');
|
|
5
|
-
|
|
6
|
-
/* eslint-disable no-multi-assign,no-loops/no-loops, no-plusplus */
|
|
7
|
-
|
|
8
|
-
if (_commonjsHelpers.commonjsGlobal && _commonjsHelpers.commonjsGlobal.Element && _commonjsHelpers.commonjsGlobal.Element.prototype && _commonjsHelpers.commonjsGlobal.Element.prototype.remove === undefined) {
|
|
9
|
-
window.Element.prototype.remove = function () {
|
|
10
|
-
this.parentElement.removeChild(this);
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
NodeList.prototype.remove = HTMLCollection.prototype.remove = function () {
|
|
14
|
-
for (let i = this.length - 1; i >= 0; i--) {
|
|
15
|
-
if (this[i] && this[i].parentElement) {
|
|
16
|
-
this[i].parentElement.removeChild(this[i]);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
module.exports = ieRemovePolyfill.__exports;
|
package/cjs/index.js
DELETED
package/esm/DSPortal.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
3
|
-
import { Component } from 'react';
|
|
4
|
-
import ReactDOM from 'react-dom';
|
|
5
|
-
import { convertPropToCssClassName } from '@elliemae/ds-classnames';
|
|
6
|
-
import { isFunction, DOCUMENT } from '@elliemae/ds-utilities';
|
|
7
|
-
import './ie-remove-polyfill.js';
|
|
8
|
-
|
|
9
|
-
const blockName = 'portal';
|
|
10
|
-
const canRenderPortal = isFunction(ReactDOM.createPortal); // TODO: If this is rendered on server, is going to break
|
|
11
|
-
|
|
12
|
-
class DSPortal extends Component {
|
|
13
|
-
constructor() {
|
|
14
|
-
super(...arguments);
|
|
15
|
-
this.state = {
|
|
16
|
-
isMounted: false
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
componentDidMount() {
|
|
21
|
-
const {
|
|
22
|
-
onRender
|
|
23
|
-
} = this.props;
|
|
24
|
-
this.portalEl = this.createPortalContainer();
|
|
25
|
-
|
|
26
|
-
if (DOCUMENT && this.portalEl) {
|
|
27
|
-
DOCUMENT.body.appendChild(this.portalEl);
|
|
28
|
-
onRender();
|
|
29
|
-
this.setState({
|
|
30
|
-
isMounted: true
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
componentDidUpdate() {
|
|
36
|
-
if (!canRenderPortal) {
|
|
37
|
-
this.renderNoPortal();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
componentWillUnmount() {
|
|
42
|
-
if (this.portalEl) {
|
|
43
|
-
this.portalEl.parentNode.removeChild(this.portalEl);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
createPortalContainer() {
|
|
48
|
-
if (!DOCUMENT) return null;
|
|
49
|
-
const {
|
|
50
|
-
className
|
|
51
|
-
} = this.props;
|
|
52
|
-
const {
|
|
53
|
-
cssClassName
|
|
54
|
-
} = convertPropToCssClassName(blockName, className);
|
|
55
|
-
const container = DOCUMENT.createElement('div');
|
|
56
|
-
container.classList.add(cssClassName);
|
|
57
|
-
container.setAttribute('data-testid', 'portal');
|
|
58
|
-
return container;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
renderNoPortal() {
|
|
62
|
-
const {
|
|
63
|
-
children
|
|
64
|
-
} = this.props;
|
|
65
|
-
ReactDOM.unstable_renderSubtreeIntoContainer(this, /*#__PURE__*/_jsx("div", {}, void 0, children), this.portalEl);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
render() {
|
|
69
|
-
const {
|
|
70
|
-
children
|
|
71
|
-
} = this.props;
|
|
72
|
-
const {
|
|
73
|
-
isMounted
|
|
74
|
-
} = this.state;
|
|
75
|
-
return !canRenderPortal || !isMounted ? null : /*#__PURE__*/ReactDOM.createPortal(children, this.portalEl);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
DSPortal.defaultProps = {
|
|
81
|
-
onRender: () => null
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export { DSPortal, DSPortal as default };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { commonjsGlobal } from './_virtual/_commonjsHelpers.js';
|
|
2
|
-
import { __exports as ieRemovePolyfill } from './_virtual/ie-remove-polyfill.tsx_commonjs-exports.js';
|
|
3
|
-
export { __exports as default } from './_virtual/ie-remove-polyfill.tsx_commonjs-exports.js';
|
|
4
|
-
|
|
5
|
-
/* eslint-disable no-multi-assign,no-loops/no-loops, no-plusplus */
|
|
6
|
-
|
|
7
|
-
if (commonjsGlobal && commonjsGlobal.Element && commonjsGlobal.Element.prototype && commonjsGlobal.Element.prototype.remove === undefined) {
|
|
8
|
-
window.Element.prototype.remove = function () {
|
|
9
|
-
this.parentElement.removeChild(this);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
NodeList.prototype.remove = HTMLCollection.prototype.remove = function () {
|
|
13
|
-
for (let i = this.length - 1; i >= 0; i--) {
|
|
14
|
-
if (this[i] && this[i].parentElement) {
|
|
15
|
-
this[i].parentElement.removeChild(this[i]);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
}
|
package/esm/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { DSPortal, DSPortal as default } from './DSPortal.js';
|
package/types/DSPortal.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React, { Component } from 'react';
|
|
2
|
-
import './ie-remove-polyfill';
|
|
3
|
-
declare class DSPortal extends Component {
|
|
4
|
-
static defaultProps: {
|
|
5
|
-
onRender: () => null;
|
|
6
|
-
};
|
|
7
|
-
state: {
|
|
8
|
-
isMounted: boolean;
|
|
9
|
-
};
|
|
10
|
-
componentDidMount(): void;
|
|
11
|
-
componentDidUpdate(): void;
|
|
12
|
-
componentWillUnmount(): void;
|
|
13
|
-
createPortalContainer(): HTMLDivElement | null;
|
|
14
|
-
renderNoPortal(): void;
|
|
15
|
-
render(): React.ReactPortal | null;
|
|
16
|
-
}
|
|
17
|
-
export { DSPortal };
|
|
18
|
-
export default DSPortal;
|
|
File without changes
|
package/types/index.d.ts
DELETED