@xylabs/react-portal 3.0.5 → 3.0.7
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/browser/components/Portal/Portal.js +2 -1
- package/dist/browser/components/Portal/Portal.js.map +1 -1
- package/dist/browser/components/Portal/index.js +23 -2
- package/dist/browser/components/Portal/index.js.map +1 -1
- package/dist/browser/components/index.js +23 -1
- package/dist/browser/components/index.js.map +1 -1
- package/dist/browser/index.js +23 -1
- package/dist/browser/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
// src/components/Portal/Portal.tsx
|
|
1
2
|
import { useEffect, useState } from "react";
|
|
2
3
|
import { createPortal } from "react-dom";
|
|
3
|
-
|
|
4
|
+
var Portal = ({ children, className, el = "div", target = "body" }) => {
|
|
4
5
|
const [container] = useState(document.createElement(el));
|
|
5
6
|
if (className) {
|
|
6
7
|
container.classList.add(className);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/Portal/Portal.tsx"],"sourcesContent":["import { useEffect, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { PortalProps } from './PortalProps'\n\nexport const Portal: React.FC<PortalProps> = ({ children, className, el = 'div', target = 'body' }: PortalProps) => {\n const [container] = useState(document.createElement(el))\n if (className) {\n container.classList.add(className)\n }\n useEffect(() => {\n const targetElement = document.querySelector(target)\n if (!targetElement) {\n console.warn(`Unable to find target element: ${target}`)\n }\n targetElement?.appendChild(container)\n return () => {\n targetElement?.removeChild(container)\n }\n }, [container, target])\n\n return createPortal(children, container)\n}\n"],"mappings":"AAAA,SAAS,WAAW,gBAAgB;AACpC,SAAS,oBAAoB;AAItB,
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/Portal/Portal.tsx"],"sourcesContent":["import { useEffect, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { PortalProps } from './PortalProps'\n\nexport const Portal: React.FC<PortalProps> = ({ children, className, el = 'div', target = 'body' }: PortalProps) => {\n const [container] = useState(document.createElement(el))\n if (className) {\n container.classList.add(className)\n }\n useEffect(() => {\n const targetElement = document.querySelector(target)\n if (!targetElement) {\n console.warn(`Unable to find target element: ${target}`)\n }\n targetElement?.appendChild(container)\n return () => {\n targetElement?.removeChild(container)\n }\n }, [container, target])\n\n return createPortal(children, container)\n}\n"],"mappings":";AAAA,SAAS,WAAW,gBAAgB;AACpC,SAAS,oBAAoB;AAItB,IAAM,SAAgC,CAAC,EAAE,UAAU,WAAW,KAAK,OAAO,SAAS,OAAO,MAAmB;AAClH,QAAM,CAAC,SAAS,IAAI,SAAS,SAAS,cAAc,EAAE,CAAC;AACvD,MAAI,WAAW;AACb,cAAU,UAAU,IAAI,SAAS;AAAA,EACnC;AACA,YAAU,MAAM;AACd,UAAM,gBAAgB,SAAS,cAAc,MAAM;AACnD,QAAI,CAAC,eAAe;AAClB,cAAQ,KAAK,kCAAkC,MAAM,EAAE;AAAA,IACzD;AACA,mBAAe,YAAY,SAAS;AACpC,WAAO,MAAM;AACX,qBAAe,YAAY,SAAS;AAAA,IACtC;AAAA,EACF,GAAG,CAAC,WAAW,MAAM,CAAC;AAEtB,SAAO,aAAa,UAAU,SAAS;AACzC;","names":[]}
|
|
@@ -1,3 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// src/components/Portal/Portal.tsx
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { createPortal } from "react-dom";
|
|
4
|
+
var Portal = ({ children, className, el = "div", target = "body" }) => {
|
|
5
|
+
const [container] = useState(document.createElement(el));
|
|
6
|
+
if (className) {
|
|
7
|
+
container.classList.add(className);
|
|
8
|
+
}
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const targetElement = document.querySelector(target);
|
|
11
|
+
if (!targetElement) {
|
|
12
|
+
console.warn(`Unable to find target element: ${target}`);
|
|
13
|
+
}
|
|
14
|
+
targetElement?.appendChild(container);
|
|
15
|
+
return () => {
|
|
16
|
+
targetElement?.removeChild(container);
|
|
17
|
+
};
|
|
18
|
+
}, [container, target]);
|
|
19
|
+
return createPortal(children, container);
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
Portal
|
|
23
|
+
};
|
|
3
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/Portal/
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/Portal/Portal.tsx"],"sourcesContent":["import { useEffect, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { PortalProps } from './PortalProps'\n\nexport const Portal: React.FC<PortalProps> = ({ children, className, el = 'div', target = 'body' }: PortalProps) => {\n const [container] = useState(document.createElement(el))\n if (className) {\n container.classList.add(className)\n }\n useEffect(() => {\n const targetElement = document.querySelector(target)\n if (!targetElement) {\n console.warn(`Unable to find target element: ${target}`)\n }\n targetElement?.appendChild(container)\n return () => {\n targetElement?.removeChild(container)\n }\n }, [container, target])\n\n return createPortal(children, container)\n}\n"],"mappings":";AAAA,SAAS,WAAW,gBAAgB;AACpC,SAAS,oBAAoB;AAItB,IAAM,SAAgC,CAAC,EAAE,UAAU,WAAW,KAAK,OAAO,SAAS,OAAO,MAAmB;AAClH,QAAM,CAAC,SAAS,IAAI,SAAS,SAAS,cAAc,EAAE,CAAC;AACvD,MAAI,WAAW;AACb,cAAU,UAAU,IAAI,SAAS;AAAA,EACnC;AACA,YAAU,MAAM;AACd,UAAM,gBAAgB,SAAS,cAAc,MAAM;AACnD,QAAI,CAAC,eAAe;AAClB,cAAQ,KAAK,kCAAkC,MAAM,EAAE;AAAA,IACzD;AACA,mBAAe,YAAY,SAAS;AACpC,WAAO,MAAM;AACX,qBAAe,YAAY,SAAS;AAAA,IACtC;AAAA,EACF,GAAG,CAAC,WAAW,MAAM,CAAC;AAEtB,SAAO,aAAa,UAAU,SAAS;AACzC;","names":[]}
|
|
@@ -1,2 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
// src/components/Portal/Portal.tsx
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { createPortal } from "react-dom";
|
|
4
|
+
var Portal = ({ children, className, el = "div", target = "body" }) => {
|
|
5
|
+
const [container] = useState(document.createElement(el));
|
|
6
|
+
if (className) {
|
|
7
|
+
container.classList.add(className);
|
|
8
|
+
}
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const targetElement = document.querySelector(target);
|
|
11
|
+
if (!targetElement) {
|
|
12
|
+
console.warn(`Unable to find target element: ${target}`);
|
|
13
|
+
}
|
|
14
|
+
targetElement?.appendChild(container);
|
|
15
|
+
return () => {
|
|
16
|
+
targetElement?.removeChild(container);
|
|
17
|
+
};
|
|
18
|
+
}, [container, target]);
|
|
19
|
+
return createPortal(children, container);
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
Portal
|
|
23
|
+
};
|
|
2
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Portal/Portal.tsx"],"sourcesContent":["import { useEffect, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { PortalProps } from './PortalProps'\n\nexport const Portal: React.FC<PortalProps> = ({ children, className, el = 'div', target = 'body' }: PortalProps) => {\n const [container] = useState(document.createElement(el))\n if (className) {\n container.classList.add(className)\n }\n useEffect(() => {\n const targetElement = document.querySelector(target)\n if (!targetElement) {\n console.warn(`Unable to find target element: ${target}`)\n }\n targetElement?.appendChild(container)\n return () => {\n targetElement?.removeChild(container)\n }\n }, [container, target])\n\n return createPortal(children, container)\n}\n"],"mappings":";AAAA,SAAS,WAAW,gBAAgB;AACpC,SAAS,oBAAoB;AAItB,IAAM,SAAgC,CAAC,EAAE,UAAU,WAAW,KAAK,OAAO,SAAS,OAAO,MAAmB;AAClH,QAAM,CAAC,SAAS,IAAI,SAAS,SAAS,cAAc,EAAE,CAAC;AACvD,MAAI,WAAW;AACb,cAAU,UAAU,IAAI,SAAS;AAAA,EACnC;AACA,YAAU,MAAM;AACd,UAAM,gBAAgB,SAAS,cAAc,MAAM;AACnD,QAAI,CAAC,eAAe;AAClB,cAAQ,KAAK,kCAAkC,MAAM,EAAE;AAAA,IACzD;AACA,mBAAe,YAAY,SAAS;AACpC,WAAO,MAAM;AACX,qBAAe,YAAY,SAAS;AAAA,IACtC;AAAA,EACF,GAAG,CAAC,WAAW,MAAM,CAAC;AAEtB,SAAO,aAAa,UAAU,SAAS;AACzC;","names":[]}
|
package/dist/browser/index.js
CHANGED
|
@@ -1,2 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
// src/components/Portal/Portal.tsx
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { createPortal } from "react-dom";
|
|
4
|
+
var Portal = ({ children, className, el = "div", target = "body" }) => {
|
|
5
|
+
const [container] = useState(document.createElement(el));
|
|
6
|
+
if (className) {
|
|
7
|
+
container.classList.add(className);
|
|
8
|
+
}
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const targetElement = document.querySelector(target);
|
|
11
|
+
if (!targetElement) {
|
|
12
|
+
console.warn(`Unable to find target element: ${target}`);
|
|
13
|
+
}
|
|
14
|
+
targetElement?.appendChild(container);
|
|
15
|
+
return () => {
|
|
16
|
+
targetElement?.removeChild(container);
|
|
17
|
+
};
|
|
18
|
+
}, [container, target]);
|
|
19
|
+
return createPortal(children, container);
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
Portal
|
|
23
|
+
};
|
|
2
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/
|
|
1
|
+
{"version":3,"sources":["../../src/components/Portal/Portal.tsx"],"sourcesContent":["import { useEffect, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { PortalProps } from './PortalProps'\n\nexport const Portal: React.FC<PortalProps> = ({ children, className, el = 'div', target = 'body' }: PortalProps) => {\n const [container] = useState(document.createElement(el))\n if (className) {\n container.classList.add(className)\n }\n useEffect(() => {\n const targetElement = document.querySelector(target)\n if (!targetElement) {\n console.warn(`Unable to find target element: ${target}`)\n }\n targetElement?.appendChild(container)\n return () => {\n targetElement?.removeChild(container)\n }\n }, [container, target])\n\n return createPortal(children, container)\n}\n"],"mappings":";AAAA,SAAS,WAAW,gBAAgB;AACpC,SAAS,oBAAoB;AAItB,IAAM,SAAgC,CAAC,EAAE,UAAU,WAAW,KAAK,OAAO,SAAS,OAAO,MAAmB;AAClH,QAAM,CAAC,SAAS,IAAI,SAAS,SAAS,cAAc,EAAE,CAAC;AACvD,MAAI,WAAW;AACb,cAAU,UAAU,IAAI,SAAS;AAAA,EACnC;AACA,YAAU,MAAM;AACd,UAAM,gBAAgB,SAAS,cAAc,MAAM;AACnD,QAAI,CAAC,eAAe;AAClB,cAAQ,KAAK,kCAAkC,MAAM,EAAE;AAAA,IACzD;AACA,mBAAe,YAAY,SAAS;AACpC,WAAO,MAAM;AACX,qBAAe,YAAY,SAAS;AAAA,IACtC;AAAA,EACF,GAAG,CAAC,WAAW,MAAM,CAAC;AAEtB,SAAO,aAAa,UAAU,SAAS;AACzC;","names":[]}
|
package/package.json
CHANGED
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"description": "Common React library for all XY Labs projects that use React",
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@types/react-dom": "^18.2.8",
|
|
18
|
-
"@xylabs/ts-scripts-yarn3": "^3.0.
|
|
19
|
-
"@xylabs/tsconfig-react": "^3.0.
|
|
18
|
+
"@xylabs/ts-scripts-yarn3": "^3.0.82",
|
|
19
|
+
"@xylabs/tsconfig-react": "^3.0.82",
|
|
20
20
|
"react": "^18.2.0",
|
|
21
21
|
"react-dom": "^18.2.0",
|
|
22
22
|
"typescript": "^5.2.2"
|
|
@@ -72,6 +72,6 @@
|
|
|
72
72
|
"url": "https://github.com/xylabs/sdk-react.git"
|
|
73
73
|
},
|
|
74
74
|
"sideEffects": false,
|
|
75
|
-
"version": "3.0.
|
|
75
|
+
"version": "3.0.7",
|
|
76
76
|
"type": "module"
|
|
77
77
|
}
|