@veeqo/ui 9.4.0 → 9.4.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.
- package/dist/components/Portal/Portal.cjs +32 -21
- package/dist/components/Portal/Portal.cjs.map +1 -1
- package/dist/components/Portal/Portal.d.ts +13 -2
- package/dist/components/Portal/Portal.js +33 -22
- package/dist/components/Portal/Portal.js.map +1 -1
- package/dist/components/Portal/utils.cjs.map +1 -1
- package/dist/components/Portal/utils.d.ts +1 -1
- package/dist/components/Portal/utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,33 +2,44 @@
|
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var reactDom = require('react-dom');
|
|
5
|
-
require('../../
|
|
6
|
-
var useId = require('../../hooks/useId.cjs');
|
|
5
|
+
var generateId = require('../../utils/generateId.cjs');
|
|
7
6
|
var utils = require('./utils.cjs');
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* The portal component renders content on the document `body` unless `rootElementRef` is passed.
|
|
11
10
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const attachTo = rootElementRef || utils.getLastOpenDialog() || document.body;
|
|
21
|
-
attachTo.appendChild(element);
|
|
22
|
-
setPortalNode(element);
|
|
23
|
-
setIsMounted(true);
|
|
24
|
-
return () => {
|
|
25
|
-
if (document.contains(attachTo) && attachTo.contains(element)) {
|
|
26
|
-
attachTo.removeChild(element);
|
|
27
|
-
}
|
|
11
|
+
class Portal extends React.PureComponent {
|
|
12
|
+
constructor(props) {
|
|
13
|
+
super(props);
|
|
14
|
+
this.id = generateId.generateId('portal');
|
|
15
|
+
this.portalNode = null;
|
|
16
|
+
this.attachTo = null;
|
|
17
|
+
this.state = {
|
|
18
|
+
isMounted: false,
|
|
28
19
|
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
};
|
|
20
|
+
}
|
|
21
|
+
componentDidMount() {
|
|
22
|
+
const { rootElementRef } = this.props;
|
|
23
|
+
this.portalNode = document.createElement('div');
|
|
24
|
+
this.portalNode.id = `portal-${this.id}`;
|
|
25
|
+
this.portalNode.style.cssText = 'position: absolute; top: 0; left: 0;';
|
|
26
|
+
this.attachTo = rootElementRef || utils.getLastOpenDialog() || document.body;
|
|
27
|
+
this.attachTo.appendChild(this.portalNode);
|
|
28
|
+
this.setState({ isMounted: true });
|
|
29
|
+
}
|
|
30
|
+
componentWillUnmount() {
|
|
31
|
+
if (this.portalNode && this.attachTo) {
|
|
32
|
+
if (document.contains(this.attachTo) && this.attachTo.contains(this.portalNode)) {
|
|
33
|
+
this.attachTo.removeChild(this.portalNode);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
render() {
|
|
38
|
+
const { children } = this.props;
|
|
39
|
+
const { isMounted } = this.state;
|
|
40
|
+
return this.portalNode && isMounted ? reactDom.createPortal(children, this.portalNode) : null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
32
43
|
|
|
33
44
|
exports.Portal = Portal;
|
|
34
45
|
//# sourceMappingURL=Portal.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Portal.cjs","sources":["../../../src/components/Portal/Portal.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"Portal.cjs","sources":["../../../src/components/Portal/Portal.tsx"],"sourcesContent":["import { PureComponent, ReactNode } from 'react';\nimport { createPortal } from 'react-dom';\nimport { generateId } from '../../utils/generateId';\nimport { getLastOpenDialog } from './utils';\n\ntype PortalProps = {\n children: ReactNode;\n rootElementRef?: HTMLElement;\n};\n\ntype PortalState = {\n isMounted: boolean;\n};\n\n/**\n * The portal component renders content on the document `body` unless `rootElementRef` is passed.\n */\nexport class Portal extends PureComponent<PortalProps, PortalState> {\n id = generateId('portal');\n\n portalNode: HTMLElement | null = null;\n\n attachTo: HTMLElement | null = null;\n\n constructor(props: PortalProps) {\n super(props);\n this.state = {\n isMounted: false,\n };\n }\n\n componentDidMount() {\n const { rootElementRef } = this.props;\n\n this.portalNode = document.createElement('div');\n this.portalNode.id = `portal-${this.id}`;\n this.portalNode.style.cssText = 'position: absolute; top: 0; left: 0;';\n\n this.attachTo = rootElementRef || getLastOpenDialog() || document.body;\n this.attachTo.appendChild(this.portalNode);\n\n this.setState({ isMounted: true });\n }\n\n componentWillUnmount() {\n if (this.portalNode && this.attachTo) {\n if (document.contains(this.attachTo) && this.attachTo.contains(this.portalNode)) {\n this.attachTo.removeChild(this.portalNode);\n }\n }\n }\n\n render(): React.ReactPortal | null {\n const { children } = this.props;\n const { isMounted } = this.state;\n\n return this.portalNode && isMounted ? createPortal(children, this.portalNode) : null;\n }\n}\n"],"names":["PureComponent","generateId","getLastOpenDialog","createPortal"],"mappings":";;;;;;;AAcA;;AAEG;AACG,MAAO,MAAO,SAAQA,mBAAuC,CAAA;AAOjE,IAAA,WAAA,CAAY,KAAkB,EAAA;QAC5B,KAAK,CAAC,KAAK,CAAC;AAPd,QAAA,IAAA,CAAA,EAAE,GAAGC,qBAAU,CAAC,QAAQ,CAAC;QAEzB,IAAU,CAAA,UAAA,GAAuB,IAAI;QAErC,IAAQ,CAAA,QAAA,GAAuB,IAAI;QAIjC,IAAI,CAAC,KAAK,GAAG;AACX,YAAA,SAAS,EAAE,KAAK;SACjB;;IAGH,iBAAiB,GAAA;AACf,QAAA,MAAM,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC,KAAK;QAErC,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC;QAC/C,IAAI,CAAC,UAAU,CAAC,EAAE,GAAG,UAAU,IAAI,CAAC,EAAE,CAAA,CAAE;QACxC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,GAAG,sCAAsC;QAEtE,IAAI,CAAC,QAAQ,GAAG,cAAc,IAAIC,uBAAiB,EAAE,IAAI,QAAQ,CAAC,IAAI;QACtE,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC;QAE1C,IAAI,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;;IAGpC,oBAAoB,GAAA;AAClB,QAAA,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,QAAQ,EAAE;AACpC,YAAA,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;gBAC/E,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC;AAC3C;AACF;;IAGH,MAAM,GAAA;AACJ,QAAA,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK;AAC/B,QAAA,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,KAAK;QAEhC,OAAO,IAAI,CAAC,UAAU,IAAI,SAAS,GAAGC,qBAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,IAAI;;AAEvF;;;;"}
|
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PureComponent, ReactNode } from 'react';
|
|
2
2
|
type PortalProps = {
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
rootElementRef?: HTMLElement;
|
|
5
5
|
};
|
|
6
|
+
type PortalState = {
|
|
7
|
+
isMounted: boolean;
|
|
8
|
+
};
|
|
6
9
|
/**
|
|
7
10
|
* The portal component renders content on the document `body` unless `rootElementRef` is passed.
|
|
8
11
|
*/
|
|
9
|
-
export declare
|
|
12
|
+
export declare class Portal extends PureComponent<PortalProps, PortalState> {
|
|
13
|
+
id: string;
|
|
14
|
+
portalNode: HTMLElement | null;
|
|
15
|
+
attachTo: HTMLElement | null;
|
|
16
|
+
constructor(props: PortalProps);
|
|
17
|
+
componentDidMount(): void;
|
|
18
|
+
componentWillUnmount(): void;
|
|
19
|
+
render(): React.ReactPortal | null;
|
|
20
|
+
}
|
|
10
21
|
export {};
|
|
@@ -1,32 +1,43 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PureComponent } from 'react';
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
|
-
import '../../
|
|
4
|
-
import { useId } from '../../hooks/useId.js';
|
|
3
|
+
import { generateId } from '../../utils/generateId.js';
|
|
5
4
|
import { getLastOpenDialog } from './utils.js';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* The portal component renders content on the document `body` unless `rootElementRef` is passed.
|
|
9
8
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const attachTo = rootElementRef || getLastOpenDialog() || document.body;
|
|
19
|
-
attachTo.appendChild(element);
|
|
20
|
-
setPortalNode(element);
|
|
21
|
-
setIsMounted(true);
|
|
22
|
-
return () => {
|
|
23
|
-
if (document.contains(attachTo) && attachTo.contains(element)) {
|
|
24
|
-
attachTo.removeChild(element);
|
|
25
|
-
}
|
|
9
|
+
class Portal extends PureComponent {
|
|
10
|
+
constructor(props) {
|
|
11
|
+
super(props);
|
|
12
|
+
this.id = generateId('portal');
|
|
13
|
+
this.portalNode = null;
|
|
14
|
+
this.attachTo = null;
|
|
15
|
+
this.state = {
|
|
16
|
+
isMounted: false,
|
|
26
17
|
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
};
|
|
18
|
+
}
|
|
19
|
+
componentDidMount() {
|
|
20
|
+
const { rootElementRef } = this.props;
|
|
21
|
+
this.portalNode = document.createElement('div');
|
|
22
|
+
this.portalNode.id = `portal-${this.id}`;
|
|
23
|
+
this.portalNode.style.cssText = 'position: absolute; top: 0; left: 0;';
|
|
24
|
+
this.attachTo = rootElementRef || getLastOpenDialog() || document.body;
|
|
25
|
+
this.attachTo.appendChild(this.portalNode);
|
|
26
|
+
this.setState({ isMounted: true });
|
|
27
|
+
}
|
|
28
|
+
componentWillUnmount() {
|
|
29
|
+
if (this.portalNode && this.attachTo) {
|
|
30
|
+
if (document.contains(this.attachTo) && this.attachTo.contains(this.portalNode)) {
|
|
31
|
+
this.attachTo.removeChild(this.portalNode);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
render() {
|
|
36
|
+
const { children } = this.props;
|
|
37
|
+
const { isMounted } = this.state;
|
|
38
|
+
return this.portalNode && isMounted ? createPortal(children, this.portalNode) : null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
30
41
|
|
|
31
42
|
export { Portal };
|
|
32
43
|
//# sourceMappingURL=Portal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Portal.js","sources":["../../../src/components/Portal/Portal.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"Portal.js","sources":["../../../src/components/Portal/Portal.tsx"],"sourcesContent":["import { PureComponent, ReactNode } from 'react';\nimport { createPortal } from 'react-dom';\nimport { generateId } from '../../utils/generateId';\nimport { getLastOpenDialog } from './utils';\n\ntype PortalProps = {\n children: ReactNode;\n rootElementRef?: HTMLElement;\n};\n\ntype PortalState = {\n isMounted: boolean;\n};\n\n/**\n * The portal component renders content on the document `body` unless `rootElementRef` is passed.\n */\nexport class Portal extends PureComponent<PortalProps, PortalState> {\n id = generateId('portal');\n\n portalNode: HTMLElement | null = null;\n\n attachTo: HTMLElement | null = null;\n\n constructor(props: PortalProps) {\n super(props);\n this.state = {\n isMounted: false,\n };\n }\n\n componentDidMount() {\n const { rootElementRef } = this.props;\n\n this.portalNode = document.createElement('div');\n this.portalNode.id = `portal-${this.id}`;\n this.portalNode.style.cssText = 'position: absolute; top: 0; left: 0;';\n\n this.attachTo = rootElementRef || getLastOpenDialog() || document.body;\n this.attachTo.appendChild(this.portalNode);\n\n this.setState({ isMounted: true });\n }\n\n componentWillUnmount() {\n if (this.portalNode && this.attachTo) {\n if (document.contains(this.attachTo) && this.attachTo.contains(this.portalNode)) {\n this.attachTo.removeChild(this.portalNode);\n }\n }\n }\n\n render(): React.ReactPortal | null {\n const { children } = this.props;\n const { isMounted } = this.state;\n\n return this.portalNode && isMounted ? createPortal(children, this.portalNode) : null;\n }\n}\n"],"names":[],"mappings":";;;;;AAcA;;AAEG;AACG,MAAO,MAAO,SAAQ,aAAuC,CAAA;AAOjE,IAAA,WAAA,CAAY,KAAkB,EAAA;QAC5B,KAAK,CAAC,KAAK,CAAC;AAPd,QAAA,IAAA,CAAA,EAAE,GAAG,UAAU,CAAC,QAAQ,CAAC;QAEzB,IAAU,CAAA,UAAA,GAAuB,IAAI;QAErC,IAAQ,CAAA,QAAA,GAAuB,IAAI;QAIjC,IAAI,CAAC,KAAK,GAAG;AACX,YAAA,SAAS,EAAE,KAAK;SACjB;;IAGH,iBAAiB,GAAA;AACf,QAAA,MAAM,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC,KAAK;QAErC,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC;QAC/C,IAAI,CAAC,UAAU,CAAC,EAAE,GAAG,UAAU,IAAI,CAAC,EAAE,CAAA,CAAE;QACxC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,GAAG,sCAAsC;QAEtE,IAAI,CAAC,QAAQ,GAAG,cAAc,IAAI,iBAAiB,EAAE,IAAI,QAAQ,CAAC,IAAI;QACtE,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC;QAE1C,IAAI,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;;IAGpC,oBAAoB,GAAA;AAClB,QAAA,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,QAAQ,EAAE;AACpC,YAAA,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;gBAC/E,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC;AAC3C;AACF;;IAGH,MAAM,GAAA;AACJ,QAAA,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK;AAC/B,QAAA,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,KAAK;QAEhC,OAAO,IAAI,CAAC,UAAU,IAAI,SAAS,GAAG,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,IAAI;;AAEvF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","sources":["../../../src/components/Portal/utils.ts"],"sourcesContent":["export const getLastOpenDialog = () => {\n const dialogs = document.querySelectorAll('dialog[open]');\n if (dialogs.length === 0) return null;\n\n return dialogs[dialogs.length - 1];\n};\n"],"names":[],"mappings":";;AAAO,MAAM,iBAAiB,GAAG,
|
|
1
|
+
{"version":3,"file":"utils.cjs","sources":["../../../src/components/Portal/utils.ts"],"sourcesContent":["export const getLastOpenDialog = (): HTMLElement | null => {\n const dialogs = document.querySelectorAll('dialog[open]');\n if (dialogs.length === 0) return null;\n\n return dialogs[dialogs.length - 1] as HTMLElement;\n};\n"],"names":[],"mappings":";;AAAO,MAAM,iBAAiB,GAAG,MAAyB;IACxD,MAAM,OAAO,GAAG,QAAQ,CAAC,gBAAgB,CAAC,cAAc,CAAC;AACzD,IAAA,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,IAAI;IAErC,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAgB;AACnD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const getLastOpenDialog: () =>
|
|
1
|
+
export declare const getLastOpenDialog: () => HTMLElement | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../src/components/Portal/utils.ts"],"sourcesContent":["export const getLastOpenDialog = () => {\n const dialogs = document.querySelectorAll('dialog[open]');\n if (dialogs.length === 0) return null;\n\n return dialogs[dialogs.length - 1];\n};\n"],"names":[],"mappings":"AAAO,MAAM,iBAAiB,GAAG,
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../src/components/Portal/utils.ts"],"sourcesContent":["export const getLastOpenDialog = (): HTMLElement | null => {\n const dialogs = document.querySelectorAll('dialog[open]');\n if (dialogs.length === 0) return null;\n\n return dialogs[dialogs.length - 1] as HTMLElement;\n};\n"],"names":[],"mappings":"AAAO,MAAM,iBAAiB,GAAG,MAAyB;IACxD,MAAM,OAAO,GAAG,QAAQ,CAAC,gBAAgB,CAAC,cAAc,CAAC;AACzD,IAAA,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,IAAI;IAErC,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAgB;AACnD;;;;"}
|