@elliemae/ds-portal 3.37.0-rc.4 → 3.37.0
Sign up to get free protection for your applications and to get access to all the features.
package/dist/cjs/DSPortal.js
CHANGED
@@ -37,9 +37,10 @@ var import_jsx_runtime = require("react/jsx-runtime");
|
|
37
37
|
var import_react = require("react");
|
38
38
|
var import_react_dom = __toESM(require("react-dom"));
|
39
39
|
var import_ds_classnames = require("@elliemae/ds-classnames");
|
40
|
-
var
|
40
|
+
var import_lodash = require("lodash");
|
41
|
+
const DOCUMENT = typeof document !== "undefined" ? document : null;
|
41
42
|
const blockName = "portal";
|
42
|
-
const canRenderPortal = (0,
|
43
|
+
const canRenderPortal = (0, import_lodash.isFunction)(import_react_dom.default.createPortal);
|
43
44
|
class DSPortal extends import_react.Component {
|
44
45
|
constructor(props) {
|
45
46
|
super(props);
|
@@ -51,8 +52,8 @@ class DSPortal extends import_react.Component {
|
|
51
52
|
componentDidMount() {
|
52
53
|
const { onRender } = this.props;
|
53
54
|
this.portalEl = this.createPortalContainer();
|
54
|
-
if (
|
55
|
-
|
55
|
+
if (DOCUMENT && this.portalEl) {
|
56
|
+
DOCUMENT.body.appendChild(this.portalEl);
|
56
57
|
onRender();
|
57
58
|
this.setState({ isMounted: true });
|
58
59
|
}
|
@@ -68,10 +69,10 @@ class DSPortal extends import_react.Component {
|
|
68
69
|
}
|
69
70
|
}
|
70
71
|
createPortalContainer() {
|
71
|
-
if (!
|
72
|
+
if (!DOCUMENT) return null;
|
72
73
|
const { className } = this.props;
|
73
74
|
const { cssClassName } = (0, import_ds_classnames.convertPropToCssClassName)(blockName, className);
|
74
|
-
const container =
|
75
|
+
const container = DOCUMENT.createElement("div");
|
75
76
|
container.classList.add(cssClassName);
|
76
77
|
container.setAttribute("data-testid", "portal");
|
77
78
|
return container;
|
package/dist/cjs/DSPortal.js.map
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
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
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
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 } from 'lodash';\n\nconst DOCUMENT = typeof document !== 'undefined' ? document : null;\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 constructor(props) {\n super(props);\n\n this.createPortalContainer = this.createPortalContainer.bind(this);\n this.renderNoPortal = this.renderNoPortal.bind(this);\n }\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(this, <div>{children}</div>, this.portalEl);\n }\n\n render() {\n const { children } = this.props;\n const { isMounted } = this.state;\n return !canRenderPortal || !isMounted ? null : 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;AAAA;ACAA,YAAuB;ADgEgC;AA/DvD,mBAAiC;AACjC,uBAAqB;AACrB,2BAA0C;AAC1C,oBAA2B;AAE3B,MAAM,WAAW,OAAO,aAAa,cAAc,WAAW;AAE9D,MAAM,YAAY;AAElB,MAAM,sBAAkB,0BAAW,iBAAAA,QAAS,YAAY;AAIxD,MAAM,iBAAiB,uBAAU;AAAA,EAI/B,YAAY,OAAO;AACjB,UAAM,KAAK;AAOb;AAAA,iBAAQ,EAAE,WAAW,MAAM;AALzB,SAAK,wBAAwB,KAAK,sBAAsB,KAAK,IAAI;AACjE,SAAK,iBAAiB,KAAK,eAAe,KAAK,IAAI;AAAA,EACrD;AAAA,EAKA,oBAAoB;AAClB,UAAM,EAAE,SAAS,IAAI,KAAK;AAC1B,SAAK,WAAW,KAAK,sBAAsB;AAC3C,QAAI,YAAY,KAAK,UAAU;AAC7B,eAAS,KAAK,YAAY,KAAK,QAAQ;AACvC,eAAS;AACT,WAAK,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,IACnC;AAAA,EACF;AAAA,EAEA,qBAAqB;AACnB,QAAI,CAAC,iBAAiB;AACpB,WAAK,eAAe;AAAA,IACtB;AAAA,EACF;AAAA,EAEA,uBAAuB;AACrB,QAAI,KAAK,UAAU;AACjB,WAAK,SAAS,WAAW,YAAY,KAAK,QAAQ;AAAA,IACpD;AAAA,EACF;AAAA,EAEA,wBAAwB;AACtB,QAAI,CAAC,SAAU,QAAO;AAEtB,UAAM,EAAE,UAAU,IAAI,KAAK;AAC3B,UAAM,EAAE,aAAa,QAAI,gDAA0B,WAAW,SAAS;AACvE,UAAM,YAAY,SAAS,cAAc,KAAK;AAC9C,cAAU,UAAU,IAAI,YAAY;AACpC,cAAU,aAAa,eAAe,QAAQ;AAE9C,WAAO;AAAA,EACT;AAAA,EAEA,iBAAiB;AACf,UAAM,EAAE,SAAS,IAAI,KAAK;AAC1B,qBAAAA,QAAS,oCAAoC,MAAM,4CAAC,SAAK,UAAS,GAAQ,KAAK,QAAQ;AAAA,EACzF;AAAA,EAEA,SAAS;AACP,UAAM,EAAE,SAAS,IAAI,KAAK;AAC1B,UAAM,EAAE,UAAU,IAAI,KAAK;AAC3B,WAAO,CAAC,mBAAmB,CAAC,YAAY,OAAO,iBAAAA,QAAS,aAAa,UAAU,KAAK,QAAQ;AAAA,EAC9F;AACF;AAAA;AA1DM,SAEG,eAAe,EAAE,UAAU,MAAM,KAAK;AA0D/C,IAAO,mBAAQ;",
|
6
6
|
"names": ["ReactDOM"]
|
7
7
|
}
|
package/dist/esm/DSPortal.js
CHANGED
@@ -3,7 +3,8 @@ import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { Component } from "react";
|
4
4
|
import ReactDOM from "react-dom";
|
5
5
|
import { convertPropToCssClassName } from "@elliemae/ds-classnames";
|
6
|
-
import { isFunction
|
6
|
+
import { isFunction } from "lodash";
|
7
|
+
const DOCUMENT = typeof document !== "undefined" ? document : null;
|
7
8
|
const blockName = "portal";
|
8
9
|
const canRenderPortal = isFunction(ReactDOM.createPortal);
|
9
10
|
class DSPortal extends Component {
|
package/dist/esm/DSPortal.js.map
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
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
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
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 } from 'lodash';\n\nconst DOCUMENT = typeof document !== 'undefined' ? document : null;\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 constructor(props) {\n super(props);\n\n this.createPortalContainer = this.createPortalContainer.bind(this);\n this.renderNoPortal = this.renderNoPortal.bind(this);\n }\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(this, <div>{children}</div>, this.portalEl);\n }\n\n render() {\n const { children } = this.props;\n const { isMounted } = this.state;\n return !canRenderPortal || !isMounted ? null : ReactDOM.createPortal(children, this.portalEl);\n }\n}\nexport { DSPortal };\nexport default DSPortal;\n"],
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACgEgC;AA/DvD,SAAgB,iBAAiB;AACjC,OAAO,cAAc;AACrB,SAAS,iCAAiC;AAC1C,SAAS,kBAAkB;AAE3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AC3B,WAAO,CAAC,mBAAmB,CAAC,YAAY,OAAO,SAAS,aAAa,UAAU,KAAK,QAAQ;AAAA,EAC9F;AACF;AAAA;AA1DM,SAEG,eAAe,EAAE,UAAU,MAAM,KAAK;AA0D/C,IAAO,mBAAQ;",
|
6
6
|
"names": []
|
7
7
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@elliemae/ds-portal",
|
3
|
-
"version": "3.37.0
|
3
|
+
"version": "3.37.0",
|
4
4
|
"license": "MIT",
|
5
5
|
"description": "ICE MT - Dimsum - Portal",
|
6
6
|
"files": [
|
@@ -36,13 +36,12 @@
|
|
36
36
|
"indent": 4
|
37
37
|
},
|
38
38
|
"dependencies": {
|
39
|
-
"@elliemae/ds-classnames": "3.37.0
|
40
|
-
"@elliemae/ds-utilities": "3.37.0-rc.4"
|
39
|
+
"@elliemae/ds-classnames": "3.37.0"
|
41
40
|
},
|
42
41
|
"devDependencies": {
|
43
42
|
"@elliemae/pui-cli": "9.0.0-next.50",
|
44
43
|
"styled-components": "~5.3.9",
|
45
|
-
"@elliemae/ds-monorepo-devops": "3.37.0
|
44
|
+
"@elliemae/ds-monorepo-devops": "3.37.0"
|
46
45
|
},
|
47
46
|
"peerDependencies": {
|
48
47
|
"react": "^17.0.2",
|