@xanui/core 1.2.54 → 1.2.56
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/AppRoot/AppRootProvider.cjs +1 -0
- package/AppRoot/AppRootProvider.cjs.map +1 -1
- package/AppRoot/AppRootProvider.js +1 -0
- package/AppRoot/AppRootProvider.js.map +1 -1
- package/AppRoot/index.cjs +3 -3
- package/AppRoot/index.cjs.map +1 -1
- package/AppRoot/index.js +3 -3
- package/AppRoot/index.js.map +1 -1
- package/Portal/index.cjs +36 -0
- package/Portal/index.cjs.map +1 -0
- package/Portal/index.d.ts +15 -0
- package/Portal/index.js +34 -0
- package/Portal/index.js.map +1 -0
- package/breakpoint/BreakpointProvider.cjs +19 -15
- package/breakpoint/BreakpointProvider.cjs.map +1 -1
- package/breakpoint/BreakpointProvider.js +19 -15
- package/breakpoint/BreakpointProvider.js.map +1 -1
- package/breakpoint/useBreakpoint.cjs +12 -8
- package/breakpoint/useBreakpoint.cjs.map +1 -1
- package/breakpoint/useBreakpoint.d.ts +7 -5
- package/breakpoint/useBreakpoint.js +12 -8
- package/breakpoint/useBreakpoint.js.map +1 -1
- package/css/index.cjs +4 -4
- package/css/index.cjs.map +1 -1
- package/css/index.js +4 -4
- package/css/index.js.map +1 -1
- package/index.cjs +16 -16
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/hooks/usePortal.cjs +0 -69
- package/hooks/usePortal.cjs.map +0 -1
- package/hooks/usePortal.d.ts +0 -14
- package/hooks/usePortal.js +0 -67
- package/hooks/usePortal.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppRootProvider.cjs","sources":["../../src/AppRoot/AppRootProvider.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"AppRootProvider.cjs","sources":["../../src/AppRoot/AppRootProvider.tsx"],"sourcesContent":["\"use client\"\nimport React from \"react\";\n\nconst AppRootContext = React.createContext<(() => HTMLElement | null) | null>(null);\n\nexport const AppRootProvider: React.FC<{ element: () => HTMLElement | null; children: React.ReactNode }> = ({ element, children }) => {\n return (\n <AppRootContext.Provider value={element}>\n {children}\n </AppRootContext.Provider>\n );\n}\n\nexport const useAppRootElement = (): HTMLElement => {\n const context = React.useContext(AppRootContext);\n if (typeof window === 'undefined') {\n return null as any;\n }\n\n return context!() as HTMLElement\n}\n"],"names":[],"mappings":";;;;;;AAGA;AAEO;AACJ;AAKH;AAEO;;AAEJ;AACG;;;AAIN;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppRootProvider.js","sources":["../../src/AppRoot/AppRootProvider.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"AppRootProvider.js","sources":["../../src/AppRoot/AppRootProvider.tsx"],"sourcesContent":["\"use client\"\nimport React from \"react\";\n\nconst AppRootContext = React.createContext<(() => HTMLElement | null) | null>(null);\n\nexport const AppRootProvider: React.FC<{ element: () => HTMLElement | null; children: React.ReactNode }> = ({ element, children }) => {\n return (\n <AppRootContext.Provider value={element}>\n {children}\n </AppRootContext.Provider>\n );\n}\n\nexport const useAppRootElement = (): HTMLElement => {\n const context = React.useContext(AppRootContext);\n if (typeof window === 'undefined') {\n return null as any;\n }\n\n return context!() as HTMLElement\n}\n"],"names":[],"mappings":";;;;AAGA;AAEO;AACJ;AAKH;AAEO;;AAEJ;AACG;;;AAIN;;"}
|
package/AppRoot/index.cjs
CHANGED
|
@@ -27,11 +27,11 @@ const AppRoot = React.forwardRef((_a, ref) => {
|
|
|
27
27
|
const docid = React.useId();
|
|
28
28
|
const csscacheId = React.useId();
|
|
29
29
|
CSSCacheId !== null && CSSCacheId !== void 0 ? CSSCacheId : (CSSCacheId = csscacheId);
|
|
30
|
-
const [visibility, setVisibility] = React.useState("hidden");
|
|
30
|
+
// const [visibility, setVisibility] = React.useState<string>("hidden");
|
|
31
31
|
const rootRef = React.useRef(null);
|
|
32
32
|
const mergeRef = useMergeRefs(rootRef, ref);
|
|
33
33
|
React.useEffect(() => {
|
|
34
|
-
setVisibility("visible");
|
|
34
|
+
// setVisibility("visible");
|
|
35
35
|
// move oncss style tags to head
|
|
36
36
|
if (typeof _document === 'undefined')
|
|
37
37
|
return;
|
|
@@ -49,7 +49,7 @@ const AppRoot = React.forwardRef((_a, ref) => {
|
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
|
-
return (jsxRuntime.jsx(index.DocumentProvider, { value: _document ? { document: _document, id: docid } : undefined, children: jsxRuntime.jsx(CSSCacheProvider.CSSCacheProvider, { cacheId: CSSCacheId, children: jsxRuntime.jsx(AppRootProvider.AppRootProvider, { element: () => rootRef.current, children: jsxRuntime.jsx(ThemeProvider, Object.assign({ theme: theme }, props, { ref: mergeRef, isRoot: true, sx: Object.assign(Object.assign(
|
|
52
|
+
return (jsxRuntime.jsx(index.DocumentProvider, { value: _document ? { document: _document, id: docid } : undefined, children: jsxRuntime.jsx(CSSCacheProvider.CSSCacheProvider, { cacheId: CSSCacheId, children: jsxRuntime.jsx(AppRootProvider.AppRootProvider, { element: () => rootRef.current, children: jsxRuntime.jsx(ThemeProvider, Object.assign({ theme: theme }, props, { ref: mergeRef, isRoot: true, sx: Object.assign(Object.assign({}, props.sx), selection), children: jsxRuntime.jsxs(BreakpointProvider.BreakpointProvider, { children: [children, !disableRenderar && jsxRuntime.jsx(Renderar.RenderRenderar, {})] }) })) }) }) }));
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
module.exports = AppRoot;
|
package/AppRoot/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/AppRoot/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { useEffect, useId, useRef } from 'react';\nimport { TagComponentType } from '../Tag/types';\nimport { ThemeProvider, ThemeProviderProps } from '../theme';\nimport { BreakpointProvider } from '../breakpoint';\nimport { RenderRenderar } from './Renderar';\nimport { DocumentProvider } from '../Document';\nimport { AppRootProvider } from './AppRootProvider';\nimport useMergeRefs from '../hooks/useMergeRefs';\nimport { CSSCacheProvider } from '../css/CSSCacheProvider';\n\nexport type AppRootProps<T extends TagComponentType = \"div\"> = ThemeProviderProps<T> & {\n noScrollbarCss?: boolean;\n document?: Document;\n CSSCacheId?: string;\n disableRenderar?: boolean;\n selectionColor?: \"default\" | \"brand\" | \"accent\" | \"success\" | \"info\" | \"warning\" | \"danger\";\n}\n\nconst AppRoot = React.forwardRef(<T extends TagComponentType = \"div\">({ children, noScrollbarCss, CSSCacheId, theme, disableRenderar, selectionColor, document: _document, ...props }: AppRootProps<T>, ref: React.Ref<any>) => {\n noScrollbarCss ??= false\n selectionColor ??= \"brand\"\n if (typeof window !== \"undefined\") {\n _document ??= document\n }\n disableRenderar ??= false\n const docid = useId()\n const csscacheId = useId()\n CSSCacheId ??= csscacheId\n\n const [visibility, setVisibility] = React.useState<string>(\"hidden\");\n const rootRef = useRef(null)\n const mergeRef = useMergeRefs(rootRef, ref)\n\n useEffect(() => {\n setVisibility(\"visible\");\n\n // move oncss style tags to head\n if (typeof _document === 'undefined') return;\n const styles = Array.from(_document.querySelectorAll('body style[data-oncss]'));\n styles.forEach((style) => {\n _document.head.appendChild(style);\n });\n }, [])\n let selection: any = {}\n if (selectionColor && selectionColor !== 'default') {\n selection = {\n \"&::selection\": {\n bgcolor: `${selectionColor}.primary`,\n color: `${selectionColor}.text`\n }\n }\n }\n\n return (\n <DocumentProvider value={_document ? { document: _document, id: docid } : undefined}>\n <CSSCacheProvider cacheId={CSSCacheId}>\n <AppRootProvider element={() => rootRef.current}>\n <ThemeProvider\n theme={theme}\n {...props}\n ref={mergeRef}\n isRoot\n sx={{\n ...props.sx,\n ...(visibility === \"hidden\" ? { visibility: \"hidden\" } : {}),\n ...selection\n }}\n >\n <BreakpointProvider>\n {children}\n {!disableRenderar && <RenderRenderar />}\n </BreakpointProvider>\n </ThemeProvider>\n </AppRootProvider>\n </CSSCacheProvider>\n </DocumentProvider>\n )\n})\n\nexport default AppRoot\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAmBA;;;;AAGG;;;;AAIA;AACA
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/AppRoot/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { useEffect, useId, useRef } from 'react';\nimport { TagComponentType } from '../Tag/types';\nimport { ThemeProvider, ThemeProviderProps } from '../theme';\nimport { BreakpointProvider } from '../breakpoint';\nimport { RenderRenderar } from './Renderar';\nimport { DocumentProvider } from '../Document';\nimport { AppRootProvider } from './AppRootProvider';\nimport useMergeRefs from '../hooks/useMergeRefs';\nimport { CSSCacheProvider } from '../css/CSSCacheProvider';\n\nexport type AppRootProps<T extends TagComponentType = \"div\"> = ThemeProviderProps<T> & {\n noScrollbarCss?: boolean;\n document?: Document;\n CSSCacheId?: string;\n disableRenderar?: boolean;\n selectionColor?: \"default\" | \"brand\" | \"accent\" | \"success\" | \"info\" | \"warning\" | \"danger\";\n}\n\nconst AppRoot = React.forwardRef(<T extends TagComponentType = \"div\">({ children, noScrollbarCss, CSSCacheId, theme, disableRenderar, selectionColor, document: _document, ...props }: AppRootProps<T>, ref: React.Ref<any>) => {\n noScrollbarCss ??= false\n selectionColor ??= \"brand\"\n if (typeof window !== \"undefined\") {\n _document ??= document\n }\n disableRenderar ??= false\n const docid = useId()\n const csscacheId = useId()\n CSSCacheId ??= csscacheId\n\n // const [visibility, setVisibility] = React.useState<string>(\"hidden\");\n const rootRef = useRef(null)\n const mergeRef = useMergeRefs(rootRef, ref)\n\n useEffect(() => {\n // setVisibility(\"visible\");\n\n // move oncss style tags to head\n if (typeof _document === 'undefined') return;\n const styles = Array.from(_document.querySelectorAll('body style[data-oncss]'));\n styles.forEach((style) => {\n _document.head.appendChild(style);\n });\n }, [])\n let selection: any = {}\n if (selectionColor && selectionColor !== 'default') {\n selection = {\n \"&::selection\": {\n bgcolor: `${selectionColor}.primary`,\n color: `${selectionColor}.text`\n }\n }\n }\n\n return (\n <DocumentProvider value={_document ? { document: _document, id: docid } : undefined}>\n <CSSCacheProvider cacheId={CSSCacheId}>\n <AppRootProvider element={() => rootRef.current}>\n <ThemeProvider\n theme={theme}\n {...props}\n ref={mergeRef}\n isRoot\n sx={{\n ...props.sx,\n // ...(visibility === \"hidden\" ? { visibility: \"hidden\" } : {}),\n ...selection\n }}\n >\n <BreakpointProvider>\n {children}\n {!disableRenderar && <RenderRenderar />}\n </BreakpointProvider>\n </ThemeProvider>\n </AppRootProvider>\n </CSSCacheProvider>\n </DocumentProvider>\n )\n})\n\nexport default AppRoot\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAmBA;;;;AAGG;;;;AAIA;AACA;;;AAIA;;;;;;;AAQG;AACA;AACG;AACH;;;AAGH;AACG;AACG;;;AAGC;;;AAIP;AAwBH;;"}
|
package/AppRoot/index.js
CHANGED
|
@@ -25,11 +25,11 @@ const AppRoot = React__default.forwardRef((_a, ref) => {
|
|
|
25
25
|
const docid = useId();
|
|
26
26
|
const csscacheId = useId();
|
|
27
27
|
CSSCacheId !== null && CSSCacheId !== void 0 ? CSSCacheId : (CSSCacheId = csscacheId);
|
|
28
|
-
const [visibility, setVisibility] =
|
|
28
|
+
// const [visibility, setVisibility] = React.useState<string>("hidden");
|
|
29
29
|
const rootRef = useRef(null);
|
|
30
30
|
const mergeRef = useMergeRefs(rootRef, ref);
|
|
31
31
|
useEffect(() => {
|
|
32
|
-
setVisibility("visible");
|
|
32
|
+
// setVisibility("visible");
|
|
33
33
|
// move oncss style tags to head
|
|
34
34
|
if (typeof _document === 'undefined')
|
|
35
35
|
return;
|
|
@@ -47,7 +47,7 @@ const AppRoot = React__default.forwardRef((_a, ref) => {
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
-
return (jsx(DocumentProvider, { value: _document ? { document: _document, id: docid } : undefined, children: jsx(CSSCacheProvider, { cacheId: CSSCacheId, children: jsx(AppRootProvider, { element: () => rootRef.current, children: jsx(ThemeProvider, Object.assign({ theme: theme }, props, { ref: mergeRef, isRoot: true, sx: Object.assign(Object.assign(
|
|
50
|
+
return (jsx(DocumentProvider, { value: _document ? { document: _document, id: docid } : undefined, children: jsx(CSSCacheProvider, { cacheId: CSSCacheId, children: jsx(AppRootProvider, { element: () => rootRef.current, children: jsx(ThemeProvider, Object.assign({ theme: theme }, props, { ref: mergeRef, isRoot: true, sx: Object.assign(Object.assign({}, props.sx), selection), children: jsxs(BreakpointProvider, { children: [children, !disableRenderar && jsx(RenderRenderar, {})] }) })) }) }) }));
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
export { AppRoot as default };
|
package/AppRoot/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/AppRoot/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { useEffect, useId, useRef } from 'react';\nimport { TagComponentType } from '../Tag/types';\nimport { ThemeProvider, ThemeProviderProps } from '../theme';\nimport { BreakpointProvider } from '../breakpoint';\nimport { RenderRenderar } from './Renderar';\nimport { DocumentProvider } from '../Document';\nimport { AppRootProvider } from './AppRootProvider';\nimport useMergeRefs from '../hooks/useMergeRefs';\nimport { CSSCacheProvider } from '../css/CSSCacheProvider';\n\nexport type AppRootProps<T extends TagComponentType = \"div\"> = ThemeProviderProps<T> & {\n noScrollbarCss?: boolean;\n document?: Document;\n CSSCacheId?: string;\n disableRenderar?: boolean;\n selectionColor?: \"default\" | \"brand\" | \"accent\" | \"success\" | \"info\" | \"warning\" | \"danger\";\n}\n\nconst AppRoot = React.forwardRef(<T extends TagComponentType = \"div\">({ children, noScrollbarCss, CSSCacheId, theme, disableRenderar, selectionColor, document: _document, ...props }: AppRootProps<T>, ref: React.Ref<any>) => {\n noScrollbarCss ??= false\n selectionColor ??= \"brand\"\n if (typeof window !== \"undefined\") {\n _document ??= document\n }\n disableRenderar ??= false\n const docid = useId()\n const csscacheId = useId()\n CSSCacheId ??= csscacheId\n\n const [visibility, setVisibility] = React.useState<string>(\"hidden\");\n const rootRef = useRef(null)\n const mergeRef = useMergeRefs(rootRef, ref)\n\n useEffect(() => {\n setVisibility(\"visible\");\n\n // move oncss style tags to head\n if (typeof _document === 'undefined') return;\n const styles = Array.from(_document.querySelectorAll('body style[data-oncss]'));\n styles.forEach((style) => {\n _document.head.appendChild(style);\n });\n }, [])\n let selection: any = {}\n if (selectionColor && selectionColor !== 'default') {\n selection = {\n \"&::selection\": {\n bgcolor: `${selectionColor}.primary`,\n color: `${selectionColor}.text`\n }\n }\n }\n\n return (\n <DocumentProvider value={_document ? { document: _document, id: docid } : undefined}>\n <CSSCacheProvider cacheId={CSSCacheId}>\n <AppRootProvider element={() => rootRef.current}>\n <ThemeProvider\n theme={theme}\n {...props}\n ref={mergeRef}\n isRoot\n sx={{\n ...props.sx,\n ...(visibility === \"hidden\" ? { visibility: \"hidden\" } : {}),\n ...selection\n }}\n >\n <BreakpointProvider>\n {children}\n {!disableRenderar && <RenderRenderar />}\n </BreakpointProvider>\n </ThemeProvider>\n </AppRootProvider>\n </CSSCacheProvider>\n </DocumentProvider>\n )\n})\n\nexport default AppRoot\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAmBA;;;;AAGG;;;;AAIA;AACA
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/AppRoot/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { useEffect, useId, useRef } from 'react';\nimport { TagComponentType } from '../Tag/types';\nimport { ThemeProvider, ThemeProviderProps } from '../theme';\nimport { BreakpointProvider } from '../breakpoint';\nimport { RenderRenderar } from './Renderar';\nimport { DocumentProvider } from '../Document';\nimport { AppRootProvider } from './AppRootProvider';\nimport useMergeRefs from '../hooks/useMergeRefs';\nimport { CSSCacheProvider } from '../css/CSSCacheProvider';\n\nexport type AppRootProps<T extends TagComponentType = \"div\"> = ThemeProviderProps<T> & {\n noScrollbarCss?: boolean;\n document?: Document;\n CSSCacheId?: string;\n disableRenderar?: boolean;\n selectionColor?: \"default\" | \"brand\" | \"accent\" | \"success\" | \"info\" | \"warning\" | \"danger\";\n}\n\nconst AppRoot = React.forwardRef(<T extends TagComponentType = \"div\">({ children, noScrollbarCss, CSSCacheId, theme, disableRenderar, selectionColor, document: _document, ...props }: AppRootProps<T>, ref: React.Ref<any>) => {\n noScrollbarCss ??= false\n selectionColor ??= \"brand\"\n if (typeof window !== \"undefined\") {\n _document ??= document\n }\n disableRenderar ??= false\n const docid = useId()\n const csscacheId = useId()\n CSSCacheId ??= csscacheId\n\n // const [visibility, setVisibility] = React.useState<string>(\"hidden\");\n const rootRef = useRef(null)\n const mergeRef = useMergeRefs(rootRef, ref)\n\n useEffect(() => {\n // setVisibility(\"visible\");\n\n // move oncss style tags to head\n if (typeof _document === 'undefined') return;\n const styles = Array.from(_document.querySelectorAll('body style[data-oncss]'));\n styles.forEach((style) => {\n _document.head.appendChild(style);\n });\n }, [])\n let selection: any = {}\n if (selectionColor && selectionColor !== 'default') {\n selection = {\n \"&::selection\": {\n bgcolor: `${selectionColor}.primary`,\n color: `${selectionColor}.text`\n }\n }\n }\n\n return (\n <DocumentProvider value={_document ? { document: _document, id: docid } : undefined}>\n <CSSCacheProvider cacheId={CSSCacheId}>\n <AppRootProvider element={() => rootRef.current}>\n <ThemeProvider\n theme={theme}\n {...props}\n ref={mergeRef}\n isRoot\n sx={{\n ...props.sx,\n // ...(visibility === \"hidden\" ? { visibility: \"hidden\" } : {}),\n ...selection\n }}\n >\n <BreakpointProvider>\n {children}\n {!disableRenderar && <RenderRenderar />}\n </BreakpointProvider>\n </ThemeProvider>\n </AppRootProvider>\n </CSSCacheProvider>\n </DocumentProvider>\n )\n})\n\nexport default AppRoot\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAmBA;;;;AAGG;;;;AAIA;AACA;;;AAIA;;;;;;;AAQG;AACA;AACG;AACH;;;AAGH;AACG;AACG;;;AAGC;;;AAIP;AAwBH;;"}
|
package/Portal/index.cjs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var reactDom = require('react-dom');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* SSR-safe Portal component
|
|
9
|
+
* - container: HTMLElement or querySelector string
|
|
10
|
+
* - if not provided, creates a unique div automatically
|
|
11
|
+
*/
|
|
12
|
+
const Portal = ({ children, container }) => {
|
|
13
|
+
const portalNode = React.useMemo(() => {
|
|
14
|
+
if (typeof document === "undefined")
|
|
15
|
+
return null; // SSR
|
|
16
|
+
// Use container if provided
|
|
17
|
+
if (container instanceof HTMLElement)
|
|
18
|
+
return container;
|
|
19
|
+
if (typeof container === "string") {
|
|
20
|
+
const element = document.querySelector(container);
|
|
21
|
+
if (element)
|
|
22
|
+
return element;
|
|
23
|
+
}
|
|
24
|
+
// Auto-create a unique div
|
|
25
|
+
const element = document.createElement("div");
|
|
26
|
+
element.dataset.portal = Math.random().toString(36).substring(2, 9); // unique id
|
|
27
|
+
document.body.appendChild(element);
|
|
28
|
+
return element;
|
|
29
|
+
}, [container]);
|
|
30
|
+
if (!portalNode)
|
|
31
|
+
return null;
|
|
32
|
+
return reactDom.createPortal(children, portalNode);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
module.exports = Portal;
|
|
36
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/Portal/index.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { ReactNode, useMemo } from \"react\";\nimport { createPortal } from \"react-dom\";\n\nexport type PortalProps = {\n children: ReactNode;\n container?: HTMLElement | string; // HTMLElement or querySelector string\n}\n\n/**\n * SSR-safe Portal component\n * - container: HTMLElement or querySelector string\n * - if not provided, creates a unique div automatically\n */\nconst Portal: React.FC<PortalProps> = ({ children, container }) => {\n const portalNode = useMemo<HTMLElement | null>(() => {\n if (typeof document === \"undefined\") return null; // SSR\n\n // Use container if provided\n if (container instanceof HTMLElement) return container;\n if (typeof container === \"string\") {\n const element = document.querySelector<HTMLElement>(container);\n if (element) return element;\n }\n\n // Auto-create a unique div\n const element = document.createElement(\"div\");\n element.dataset.portal = Math.random().toString(36).substring(2, 9); // unique id\n document.body.appendChild(element);\n\n return element;\n }, [container]);\n\n if (!portalNode) return null;\n\n return createPortal(children, portalNode);\n};\n\nexport default Portal;"],"names":[],"mappings":";;;;;;AAUA;;;;AAIG;AACH;AACG;;;;;AAIyC;AACtC;;AAEG;AAAa;;;;;AAMhB;AAEA;AACH;AAEA;AAAiB;AAEjB;AACH;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React__default, { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
type PortalProps = {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
container?: HTMLElement | string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* SSR-safe Portal component
|
|
9
|
+
* - container: HTMLElement or querySelector string
|
|
10
|
+
* - if not provided, creates a unique div automatically
|
|
11
|
+
*/
|
|
12
|
+
declare const Portal: React__default.FC<PortalProps>;
|
|
13
|
+
|
|
14
|
+
export { Portal as default };
|
|
15
|
+
export type { PortalProps };
|
package/Portal/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* SSR-safe Portal component
|
|
7
|
+
* - container: HTMLElement or querySelector string
|
|
8
|
+
* - if not provided, creates a unique div automatically
|
|
9
|
+
*/
|
|
10
|
+
const Portal = ({ children, container }) => {
|
|
11
|
+
const portalNode = useMemo(() => {
|
|
12
|
+
if (typeof document === "undefined")
|
|
13
|
+
return null; // SSR
|
|
14
|
+
// Use container if provided
|
|
15
|
+
if (container instanceof HTMLElement)
|
|
16
|
+
return container;
|
|
17
|
+
if (typeof container === "string") {
|
|
18
|
+
const element = document.querySelector(container);
|
|
19
|
+
if (element)
|
|
20
|
+
return element;
|
|
21
|
+
}
|
|
22
|
+
// Auto-create a unique div
|
|
23
|
+
const element = document.createElement("div");
|
|
24
|
+
element.dataset.portal = Math.random().toString(36).substring(2, 9); // unique id
|
|
25
|
+
document.body.appendChild(element);
|
|
26
|
+
return element;
|
|
27
|
+
}, [container]);
|
|
28
|
+
if (!portalNode)
|
|
29
|
+
return null;
|
|
30
|
+
return createPortal(children, portalNode);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { Portal as default };
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/Portal/index.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { ReactNode, useMemo } from \"react\";\nimport { createPortal } from \"react-dom\";\n\nexport type PortalProps = {\n children: ReactNode;\n container?: HTMLElement | string; // HTMLElement or querySelector string\n}\n\n/**\n * SSR-safe Portal component\n * - container: HTMLElement or querySelector string\n * - if not provided, creates a unique div automatically\n */\nconst Portal: React.FC<PortalProps> = ({ children, container }) => {\n const portalNode = useMemo<HTMLElement | null>(() => {\n if (typeof document === \"undefined\") return null; // SSR\n\n // Use container if provided\n if (container instanceof HTMLElement) return container;\n if (typeof container === \"string\") {\n const element = document.querySelector<HTMLElement>(container);\n if (element) return element;\n }\n\n // Auto-create a unique div\n const element = document.createElement(\"div\");\n element.dataset.portal = Math.random().toString(36).substring(2, 9); // unique id\n document.body.appendChild(element);\n\n return element;\n }, [container]);\n\n if (!portalNode) return null;\n\n return createPortal(children, portalNode);\n};\n\nexport default Portal;"],"names":[],"mappings":";;;;AAUA;;;;AAIG;AACH;AACG;;;;;AAIyC;AACtC;;AAEG;AAAa;;;;;AAMhB;AAEA;AACH;AAEA;AAAiB;AAEjB;AACH;;"}
|
|
@@ -6,15 +6,14 @@ var React = require('react');
|
|
|
6
6
|
var index$1 = require('../css/index.cjs');
|
|
7
7
|
var index = require('../Document/index.cjs');
|
|
8
8
|
|
|
9
|
-
const BreakpointCtx = React.createContext(
|
|
9
|
+
const BreakpointCtx = React.createContext({
|
|
10
|
+
key: "xl",
|
|
11
|
+
width: 1920,
|
|
12
|
+
});
|
|
10
13
|
/**
|
|
11
14
|
* SSR-safe breakpoint detection
|
|
12
15
|
*/
|
|
13
|
-
const getKey = (
|
|
14
|
-
if (!doc || typeof window === "undefined" || typeof document === "undefined") {
|
|
15
|
-
return "xl";
|
|
16
|
-
}
|
|
17
|
-
const width = doc.documentElement.clientWidth || window.innerWidth;
|
|
16
|
+
const getKey = (width) => {
|
|
18
17
|
if (width < index$1.breakpoints.sm)
|
|
19
18
|
return "xs";
|
|
20
19
|
if (width < index$1.breakpoints.md)
|
|
@@ -26,22 +25,27 @@ const getKey = (doc) => {
|
|
|
26
25
|
return "xl";
|
|
27
26
|
};
|
|
28
27
|
const BreakpointProvider = ({ children }) => {
|
|
29
|
-
// hydrate-safe initial state
|
|
30
28
|
const doc = index.useDocument();
|
|
31
|
-
const
|
|
29
|
+
const getWidth = () => {
|
|
30
|
+
if (!doc)
|
|
31
|
+
return 1920; // SSR fallback
|
|
32
|
+
return doc.document.documentElement.clientWidth || window.innerWidth;
|
|
33
|
+
};
|
|
34
|
+
const [state, setState] = React.useState(() => {
|
|
35
|
+
const width = getWidth();
|
|
36
|
+
return { width, key: getKey(width) };
|
|
37
|
+
});
|
|
32
38
|
const handler = React.useCallback(() => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
39
|
+
const width = getWidth();
|
|
40
|
+
const key = getKey(width);
|
|
41
|
+
setState(prev => (prev.key === key ? prev : { key, width }));
|
|
37
42
|
}, [doc]);
|
|
38
|
-
// useLayoutEffect avoids visual flicker on first paint
|
|
39
43
|
React.useLayoutEffect(() => {
|
|
40
|
-
handler();
|
|
44
|
+
handler(); // set correct initial value
|
|
41
45
|
window.addEventListener("resize", handler, { passive: true });
|
|
42
46
|
return () => window.removeEventListener("resize", handler);
|
|
43
47
|
}, [handler]);
|
|
44
|
-
return
|
|
48
|
+
return jsxRuntime.jsx(BreakpointCtx.Provider, { value: state, children: children });
|
|
45
49
|
};
|
|
46
50
|
|
|
47
51
|
exports.BreakpointCtx = BreakpointCtx;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BreakpointProvider.cjs","sources":["../../src/breakpoint/BreakpointProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport React, {
|
|
1
|
+
{"version":3,"file":"BreakpointProvider.cjs","sources":["../../src/breakpoint/BreakpointProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { ReactNode, useState, useCallback, useLayoutEffect } from \"react\";\nimport { breakpoints } from \"../css\";\nimport { BreakpointKeys } from \"../css/types\";\nimport { useDocument } from \"../Document\";\n\ntype BreakpointCtxType = {\n key: BreakpointKeys;\n width: number;\n};\n\nexport const BreakpointCtx = React.createContext<BreakpointCtxType>({\n key: \"xl\",\n width: 1920,\n});\n\n/**\n * SSR-safe breakpoint detection\n */\nconst getKey = (width: number): BreakpointKeys => {\n if (width < breakpoints.sm) return \"xs\";\n if (width < breakpoints.md) return \"sm\";\n if (width < breakpoints.lg) return \"md\";\n if (width < breakpoints.xl) return \"lg\";\n return \"xl\";\n};\n\nexport const BreakpointProvider = ({ children }: { children?: ReactNode }) => {\n const doc = useDocument();\n\n const getWidth = () => {\n if (!doc) return 1920; // SSR fallback\n return doc.document.documentElement.clientWidth || window.innerWidth;\n };\n\n const [state, setState] = useState<BreakpointCtxType>(() => {\n const width = getWidth();\n return { width, key: getKey(width) };\n });\n\n const handler = useCallback(() => {\n const width = getWidth();\n const key = getKey(width);\n\n setState(prev => (prev.key === key ? prev : { key, width }));\n }, [doc]);\n\n useLayoutEffect(() => {\n handler(); // set correct initial value\n window.addEventListener(\"resize\", handler, { passive: true });\n return () => window.removeEventListener(\"resize\", handler);\n }, [handler]);\n\n return <BreakpointCtx.Provider value={state}>{children}</BreakpointCtx.Provider>;\n};"],"names":[],"mappings":";;;;;;;;AAYO;AACH;AACA;AACH;AAED;;AAEG;AACH;AACI;AAA4B;AAC5B;AAA4B;AAC5B;AAA4B;AAC5B;AAA4B;AAC5B;AACJ;;AAGI;;AAGI;;;AAEJ;;AAGI;;AAEJ;AAEA;AACI;AACA;;AAGJ;;;AAII;;AAEJ;;AAGJ;;;"}
|
|
@@ -4,15 +4,14 @@ import React__default, { useState, useCallback, useLayoutEffect } from 'react';
|
|
|
4
4
|
import { breakpoints } from '../css/index.js';
|
|
5
5
|
import { useDocument } from '../Document/index.js';
|
|
6
6
|
|
|
7
|
-
const BreakpointCtx = React__default.createContext(
|
|
7
|
+
const BreakpointCtx = React__default.createContext({
|
|
8
|
+
key: "xl",
|
|
9
|
+
width: 1920,
|
|
10
|
+
});
|
|
8
11
|
/**
|
|
9
12
|
* SSR-safe breakpoint detection
|
|
10
13
|
*/
|
|
11
|
-
const getKey = (
|
|
12
|
-
if (!doc || typeof window === "undefined" || typeof document === "undefined") {
|
|
13
|
-
return "xl";
|
|
14
|
-
}
|
|
15
|
-
const width = doc.documentElement.clientWidth || window.innerWidth;
|
|
14
|
+
const getKey = (width) => {
|
|
16
15
|
if (width < breakpoints.sm)
|
|
17
16
|
return "xs";
|
|
18
17
|
if (width < breakpoints.md)
|
|
@@ -24,22 +23,27 @@ const getKey = (doc) => {
|
|
|
24
23
|
return "xl";
|
|
25
24
|
};
|
|
26
25
|
const BreakpointProvider = ({ children }) => {
|
|
27
|
-
// hydrate-safe initial state
|
|
28
26
|
const doc = useDocument();
|
|
29
|
-
const
|
|
27
|
+
const getWidth = () => {
|
|
28
|
+
if (!doc)
|
|
29
|
+
return 1920; // SSR fallback
|
|
30
|
+
return doc.document.documentElement.clientWidth || window.innerWidth;
|
|
31
|
+
};
|
|
32
|
+
const [state, setState] = useState(() => {
|
|
33
|
+
const width = getWidth();
|
|
34
|
+
return { width, key: getKey(width) };
|
|
35
|
+
});
|
|
30
36
|
const handler = useCallback(() => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
37
|
+
const width = getWidth();
|
|
38
|
+
const key = getKey(width);
|
|
39
|
+
setState(prev => (prev.key === key ? prev : { key, width }));
|
|
35
40
|
}, [doc]);
|
|
36
|
-
// useLayoutEffect avoids visual flicker on first paint
|
|
37
41
|
useLayoutEffect(() => {
|
|
38
|
-
handler();
|
|
42
|
+
handler(); // set correct initial value
|
|
39
43
|
window.addEventListener("resize", handler, { passive: true });
|
|
40
44
|
return () => window.removeEventListener("resize", handler);
|
|
41
45
|
}, [handler]);
|
|
42
|
-
return
|
|
46
|
+
return jsx(BreakpointCtx.Provider, { value: state, children: children });
|
|
43
47
|
};
|
|
44
48
|
|
|
45
49
|
export { BreakpointCtx, BreakpointProvider };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BreakpointProvider.js","sources":["../../src/breakpoint/BreakpointProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport React, {
|
|
1
|
+
{"version":3,"file":"BreakpointProvider.js","sources":["../../src/breakpoint/BreakpointProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { ReactNode, useState, useCallback, useLayoutEffect } from \"react\";\nimport { breakpoints } from \"../css\";\nimport { BreakpointKeys } from \"../css/types\";\nimport { useDocument } from \"../Document\";\n\ntype BreakpointCtxType = {\n key: BreakpointKeys;\n width: number;\n};\n\nexport const BreakpointCtx = React.createContext<BreakpointCtxType>({\n key: \"xl\",\n width: 1920,\n});\n\n/**\n * SSR-safe breakpoint detection\n */\nconst getKey = (width: number): BreakpointKeys => {\n if (width < breakpoints.sm) return \"xs\";\n if (width < breakpoints.md) return \"sm\";\n if (width < breakpoints.lg) return \"md\";\n if (width < breakpoints.xl) return \"lg\";\n return \"xl\";\n};\n\nexport const BreakpointProvider = ({ children }: { children?: ReactNode }) => {\n const doc = useDocument();\n\n const getWidth = () => {\n if (!doc) return 1920; // SSR fallback\n return doc.document.documentElement.clientWidth || window.innerWidth;\n };\n\n const [state, setState] = useState<BreakpointCtxType>(() => {\n const width = getWidth();\n return { width, key: getKey(width) };\n });\n\n const handler = useCallback(() => {\n const width = getWidth();\n const key = getKey(width);\n\n setState(prev => (prev.key === key ? prev : { key, width }));\n }, [doc]);\n\n useLayoutEffect(() => {\n handler(); // set correct initial value\n window.addEventListener(\"resize\", handler, { passive: true });\n return () => window.removeEventListener(\"resize\", handler);\n }, [handler]);\n\n return <BreakpointCtx.Provider value={state}>{children}</BreakpointCtx.Provider>;\n};"],"names":[],"mappings":";;;;;;AAYO;AACH;AACA;AACH;AAED;;AAEG;AACH;AACI;AAA4B;AAC5B;AAA4B;AAC5B;AAA4B;AAC5B;AAA4B;AAC5B;AACJ;;AAGI;;AAGI;;;AAEJ;;AAGI;;AAEJ;AAEA;AACI;AACA;;AAGJ;;;AAII;;AAEJ;;AAGJ;;"}
|
|
@@ -5,18 +5,22 @@ var BreakpointProvider = require('./BreakpointProvider.cjs');
|
|
|
5
5
|
var index = require('../css/index.cjs');
|
|
6
6
|
|
|
7
7
|
const useBreakpoint = () => {
|
|
8
|
-
const value = React.useContext(BreakpointProvider.BreakpointCtx);
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
8
|
+
const { key: value, width } = React.useContext(BreakpointProvider.BreakpointCtx);
|
|
9
|
+
const is = (k) => value === k;
|
|
10
|
+
const isUp = (k) => width >= index.breakpoints[k];
|
|
11
|
+
const isDown = (k) => width < index.breakpoints[k];
|
|
12
|
+
const isOrUp = (k) => isUp(k) || is(k);
|
|
13
|
+
const isOrDown = (k) => isDown(k) || is(k);
|
|
14
|
+
const isBetween = (start, end) => width >= index.breakpoints[start] && width < index.breakpoints[end];
|
|
13
15
|
return {
|
|
14
|
-
value,
|
|
16
|
+
value, // current breakpoint key
|
|
17
|
+
width, // current width
|
|
15
18
|
is,
|
|
16
19
|
isUp,
|
|
17
20
|
isDown,
|
|
18
|
-
isOrUp
|
|
19
|
-
isOrDown
|
|
21
|
+
isOrUp,
|
|
22
|
+
isOrDown,
|
|
23
|
+
isBetween
|
|
20
24
|
};
|
|
21
25
|
};
|
|
22
26
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBreakpoint.cjs","sources":["../../src/breakpoint/useBreakpoint.ts"],"sourcesContent":["import { useContext } from \"react\"
|
|
1
|
+
{"version":3,"file":"useBreakpoint.cjs","sources":["../../src/breakpoint/useBreakpoint.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { BreakpointCtx } from \"./BreakpointProvider\";\nimport { breakpoints } from \"../css\";\nimport { BreakpointKeys } from \"../css/types\";\n\nconst useBreakpoint = () => {\n const { key: value, width } = useContext(BreakpointCtx);\n\n const is = (k: BreakpointKeys) => value === k;\n const isUp = (k: BreakpointKeys) => width >= breakpoints[k];\n const isDown = (k: BreakpointKeys) => width < breakpoints[k];\n const isOrUp = (k: BreakpointKeys) => isUp(k) || is(k);\n const isOrDown = (k: BreakpointKeys) => isDown(k) || is(k);\n const isBetween = (start: BreakpointKeys, end: BreakpointKeys) =>\n width >= breakpoints[start] && width < breakpoints[end];\n\n return {\n value, // current breakpoint key\n width, // current width\n is,\n isUp,\n isDown,\n isOrUp,\n isOrDown,\n isBetween\n };\n};\n\nexport default useBreakpoint;"],"names":["useContext","BreakpointCtx","breakpoints"],"mappings":";;;;;;AAKA,MAAM,aAAa,GAAG,MAAK;AACxB,IAAA,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,GAAGA,gBAAU,CAACC,gCAAa,CAAC;IAEvD,MAAM,EAAE,GAAG,CAAC,CAAiB,KAAK,KAAK,KAAK,CAAC;AAC7C,IAAA,MAAM,IAAI,GAAG,CAAC,CAAiB,KAAK,KAAK,IAAIC,iBAAW,CAAC,CAAC,CAAC;AAC3D,IAAA,MAAM,MAAM,GAAG,CAAC,CAAiB,KAAK,KAAK,GAAGA,iBAAW,CAAC,CAAC,CAAC;AAC5D,IAAA,MAAM,MAAM,GAAG,CAAC,CAAiB,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AACtD,IAAA,MAAM,QAAQ,GAAG,CAAC,CAAiB,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC1D,MAAM,SAAS,GAAG,CAAC,KAAqB,EAAE,GAAmB,KAC1D,KAAK,IAAIA,iBAAW,CAAC,KAAK,CAAC,IAAI,KAAK,GAAGA,iBAAW,CAAC,GAAG,CAAC;IAE1D,OAAO;AACJ,QAAA,KAAK;AACL,QAAA,KAAK;QACL,EAAE;QACF,IAAI;QACJ,MAAM;QACN,MAAM;QACN,QAAQ;QACR;KACF;AACJ;;;;"}
|
|
@@ -2,11 +2,13 @@ import { BreakpointKeys } from '../css/types.js';
|
|
|
2
2
|
|
|
3
3
|
declare const useBreakpoint: () => {
|
|
4
4
|
value: BreakpointKeys;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
width: number;
|
|
6
|
+
is: (k: BreakpointKeys) => boolean;
|
|
7
|
+
isUp: (k: BreakpointKeys) => boolean;
|
|
8
|
+
isDown: (k: BreakpointKeys) => boolean;
|
|
9
|
+
isOrUp: (k: BreakpointKeys) => boolean;
|
|
10
|
+
isOrDown: (k: BreakpointKeys) => boolean;
|
|
11
|
+
isBetween: (start: BreakpointKeys, end: BreakpointKeys) => boolean;
|
|
10
12
|
};
|
|
11
13
|
|
|
12
14
|
export { useBreakpoint as default };
|
|
@@ -3,18 +3,22 @@ import { BreakpointCtx } from './BreakpointProvider.js';
|
|
|
3
3
|
import { breakpoints } from '../css/index.js';
|
|
4
4
|
|
|
5
5
|
const useBreakpoint = () => {
|
|
6
|
-
const value = useContext(BreakpointCtx);
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
6
|
+
const { key: value, width } = useContext(BreakpointCtx);
|
|
7
|
+
const is = (k) => value === k;
|
|
8
|
+
const isUp = (k) => width >= breakpoints[k];
|
|
9
|
+
const isDown = (k) => width < breakpoints[k];
|
|
10
|
+
const isOrUp = (k) => isUp(k) || is(k);
|
|
11
|
+
const isOrDown = (k) => isDown(k) || is(k);
|
|
12
|
+
const isBetween = (start, end) => width >= breakpoints[start] && width < breakpoints[end];
|
|
11
13
|
return {
|
|
12
|
-
value,
|
|
14
|
+
value, // current breakpoint key
|
|
15
|
+
width, // current width
|
|
13
16
|
is,
|
|
14
17
|
isUp,
|
|
15
18
|
isDown,
|
|
16
|
-
isOrUp
|
|
17
|
-
isOrDown
|
|
19
|
+
isOrUp,
|
|
20
|
+
isOrDown,
|
|
21
|
+
isBetween
|
|
18
22
|
};
|
|
19
23
|
};
|
|
20
24
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBreakpoint.js","sources":["../../src/breakpoint/useBreakpoint.ts"],"sourcesContent":["import { useContext } from \"react\"
|
|
1
|
+
{"version":3,"file":"useBreakpoint.js","sources":["../../src/breakpoint/useBreakpoint.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { BreakpointCtx } from \"./BreakpointProvider\";\nimport { breakpoints } from \"../css\";\nimport { BreakpointKeys } from \"../css/types\";\n\nconst useBreakpoint = () => {\n const { key: value, width } = useContext(BreakpointCtx);\n\n const is = (k: BreakpointKeys) => value === k;\n const isUp = (k: BreakpointKeys) => width >= breakpoints[k];\n const isDown = (k: BreakpointKeys) => width < breakpoints[k];\n const isOrUp = (k: BreakpointKeys) => isUp(k) || is(k);\n const isOrDown = (k: BreakpointKeys) => isDown(k) || is(k);\n const isBetween = (start: BreakpointKeys, end: BreakpointKeys) =>\n width >= breakpoints[start] && width < breakpoints[end];\n\n return {\n value, // current breakpoint key\n width, // current width\n is,\n isUp,\n isDown,\n isOrUp,\n isOrDown,\n isBetween\n };\n};\n\nexport default useBreakpoint;"],"names":[],"mappings":";;;;AAKA,MAAM,aAAa,GAAG,MAAK;AACxB,IAAA,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC,aAAa,CAAC;IAEvD,MAAM,EAAE,GAAG,CAAC,CAAiB,KAAK,KAAK,KAAK,CAAC;AAC7C,IAAA,MAAM,IAAI,GAAG,CAAC,CAAiB,KAAK,KAAK,IAAI,WAAW,CAAC,CAAC,CAAC;AAC3D,IAAA,MAAM,MAAM,GAAG,CAAC,CAAiB,KAAK,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC;AAC5D,IAAA,MAAM,MAAM,GAAG,CAAC,CAAiB,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AACtD,IAAA,MAAM,QAAQ,GAAG,CAAC,CAAiB,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC1D,MAAM,SAAS,GAAG,CAAC,KAAqB,EAAE,GAAmB,KAC1D,KAAK,IAAI,WAAW,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC;IAE1D,OAAO;AACJ,QAAA,KAAK;AACL,QAAA,KAAK;QACL,EAAE;QACF,IAAI;QACJ,MAAM;QACN,MAAM;QACN,QAAQ;QACR;KACF;AACJ;;;;"}
|
package/css/index.cjs
CHANGED
|
@@ -7,10 +7,10 @@ var oncss = require('oncss');
|
|
|
7
7
|
|
|
8
8
|
const breakpoints = {
|
|
9
9
|
xs: 0,
|
|
10
|
-
sm:
|
|
11
|
-
md:
|
|
12
|
-
lg:
|
|
13
|
-
xl:
|
|
10
|
+
sm: 640,
|
|
11
|
+
md: 768,
|
|
12
|
+
lg: 1024,
|
|
13
|
+
xl: 1280,
|
|
14
14
|
};
|
|
15
15
|
const css = (props, options) => {
|
|
16
16
|
const cssOptions = Object.assign(Object.assign({}, options), { breakpoints,
|
package/css/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/css/index.ts"],"sourcesContent":["import getValue from \"./getValue\"\nimport getProps from \"./getProps\"\nimport aliases from \"./aliases\"\nimport { Aliases, BreakpointKeys, CSSOptionProps, CSSProps } from './types'\nimport { css as _css } from \"oncss\"\n\nexport {\n getValue,\n getProps\n}\n\nexport const breakpoints = {\n xs: 0,\n sm:
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/css/index.ts"],"sourcesContent":["import getValue from \"./getValue\"\nimport getProps from \"./getProps\"\nimport aliases from \"./aliases\"\nimport { Aliases, BreakpointKeys, CSSOptionProps, CSSProps } from './types'\nimport { css as _css } from \"oncss\"\n\nexport {\n getValue,\n getProps\n}\n\nexport const breakpoints = {\n xs: 0,\n sm: 640,\n md: 768,\n lg: 1024,\n xl: 1280,\n}\n\nexport const css = (props: CSSProps, options?: CSSOptionProps) => {\n const cssOptions: CSSOptionProps = {\n ...options,\n breakpoints,\n aliases,\n getValue: (p: any, v: any, _c: any, dept) => {\n if (options?.getValue) {\n let _val = options?.getValue(p, v, _c, dept)\n if (_val) return _val\n }\n return getValue(p, v, _c)\n },\n getProps: (p: any, v: any, _c: any, dept) => {\n if (options?.getProps) {\n let _p = options?.getProps(p, v, _c, dept)\n if (_p) return _p\n }\n return getProps(p, v, _c)\n },\n }\n return _css<Aliases, BreakpointKeys>(props, cssOptions)\n}\n\nexport const adjustColor = (hex: string, factor: number) => {\n\n hex = hex.replace(/^#/, '')\n\n let r = parseInt(hex.slice(0, 2), 16)\n let g = parseInt(hex.slice(2, 4), 16)\n let b = parseInt(hex.slice(4, 6), 16)\n\n r = Math.floor(r * factor)\n g = Math.floor(g * factor)\n b = Math.floor(b * factor)\n\n r = Math.min(255, Math.max(0, r))\n g = Math.min(255, Math.max(0, g))\n b = Math.min(255, Math.max(0, b))\n\n return `#${r.toString(16).padStart(2, '0')}${g.toString(16).padStart(2, '0')}${b.toString(16).padStart(2, '0')}`;\n}\n\nexport const adjustTextContrast = (color: string) => {\n color = color.replace(/^#/, '')\n const r = parseInt(color.slice(0, 2), 16);\n const g = parseInt(color.slice(2, 4), 16);\n const b = parseInt(color.slice(4, 6), 16);\n\n const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;\n return luminance > 0.5 ? '#111111' : '#FFFFFF';\n}\n\nexport const alpha = (color: string, opacity = 1) => {\n if (typeof opacity !== 'number') return color\n let _opacity = opacity * 100\n if (!color.startsWith(\"#\")) throw new Error(`color must be hex`)\n return (color + (`0${Math.round((255 / 100) * _opacity).toString(16)}`.slice(-2))).toUpperCase();\n};\n\n"],"names":["_css"],"mappings":";;;;;;;AAWO,MAAM,WAAW,GAAG;AACvB,IAAA,EAAE,EAAE,CAAC;AACL,IAAA,EAAE,EAAE,GAAG;AACP,IAAA,EAAE,EAAE,GAAG;AACP,IAAA,EAAE,EAAE,IAAI;AACR,IAAA,EAAE,EAAE,IAAI;;MAGC,GAAG,GAAG,CAAC,KAAe,EAAE,OAAwB,KAAI;AAC7D,IAAA,MAAM,UAAU,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EACT,OAAO,CAAA,EAAA,EACV,WAAW;AACX,QAAA,OAAO,EACP,QAAQ,EAAE,CAAC,CAAM,EAAE,CAAM,EAAE,EAAO,EAAE,IAAI,KAAI;YACxC,IAAI,OAAO,aAAP,OAAO,KAAA,MAAA,GAAA,MAAA,GAAP,OAAO,CAAE,QAAQ,EAAE;AACnB,gBAAA,IAAI,IAAI,GAAG,OAAO,aAAP,OAAO,KAAA,MAAA,GAAA,MAAA,GAAP,OAAO,CAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC;AAC5C,gBAAA,IAAI,IAAI;AAAE,oBAAA,OAAO,IAAI;YACzB;YACA,OAAO,QAAQ,CAAC,CAAC,EAAE,CAAK,CAAC;AAC7B,QAAA,CAAC,EACD,QAAQ,EAAE,CAAC,CAAM,EAAE,CAAM,EAAE,EAAO,EAAE,IAAI,KAAI;YAC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AA,OAAO,KAAK;AAC7C,IAAA,IAAI,QAAQ,GAAG,OAAO,GAAG,GAAG;AAC5B,IAAA,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,CAAA,iBAAA,CAAmB,CAAC;AAChE,IAAA,OAAO,CAAC,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,GAAG,IAAI,QAAQ,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA,CAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE;AACpG;;;;;;;;;;"}
|
package/css/index.js
CHANGED
|
@@ -5,10 +5,10 @@ import { css as css$1 } from 'oncss';
|
|
|
5
5
|
|
|
6
6
|
const breakpoints = {
|
|
7
7
|
xs: 0,
|
|
8
|
-
sm:
|
|
9
|
-
md:
|
|
10
|
-
lg:
|
|
11
|
-
xl:
|
|
8
|
+
sm: 640,
|
|
9
|
+
md: 768,
|
|
10
|
+
lg: 1024,
|
|
11
|
+
xl: 1280,
|
|
12
12
|
};
|
|
13
13
|
const css = (props, options) => {
|
|
14
14
|
const cssOptions = Object.assign(Object.assign({}, options), { breakpoints,
|
package/css/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/css/index.ts"],"sourcesContent":["import getValue from \"./getValue\"\nimport getProps from \"./getProps\"\nimport aliases from \"./aliases\"\nimport { Aliases, BreakpointKeys, CSSOptionProps, CSSProps } from './types'\nimport { css as _css } from \"oncss\"\n\nexport {\n getValue,\n getProps\n}\n\nexport const breakpoints = {\n xs: 0,\n sm:
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/css/index.ts"],"sourcesContent":["import getValue from \"./getValue\"\nimport getProps from \"./getProps\"\nimport aliases from \"./aliases\"\nimport { Aliases, BreakpointKeys, CSSOptionProps, CSSProps } from './types'\nimport { css as _css } from \"oncss\"\n\nexport {\n getValue,\n getProps\n}\n\nexport const breakpoints = {\n xs: 0,\n sm: 640,\n md: 768,\n lg: 1024,\n xl: 1280,\n}\n\nexport const css = (props: CSSProps, options?: CSSOptionProps) => {\n const cssOptions: CSSOptionProps = {\n ...options,\n breakpoints,\n aliases,\n getValue: (p: any, v: any, _c: any, dept) => {\n if (options?.getValue) {\n let _val = options?.getValue(p, v, _c, dept)\n if (_val) return _val\n }\n return getValue(p, v, _c)\n },\n getProps: (p: any, v: any, _c: any, dept) => {\n if (options?.getProps) {\n let _p = options?.getProps(p, v, _c, dept)\n if (_p) return _p\n }\n return getProps(p, v, _c)\n },\n }\n return _css<Aliases, BreakpointKeys>(props, cssOptions)\n}\n\nexport const adjustColor = (hex: string, factor: number) => {\n\n hex = hex.replace(/^#/, '')\n\n let r = parseInt(hex.slice(0, 2), 16)\n let g = parseInt(hex.slice(2, 4), 16)\n let b = parseInt(hex.slice(4, 6), 16)\n\n r = Math.floor(r * factor)\n g = Math.floor(g * factor)\n b = Math.floor(b * factor)\n\n r = Math.min(255, Math.max(0, r))\n g = Math.min(255, Math.max(0, g))\n b = Math.min(255, Math.max(0, b))\n\n return `#${r.toString(16).padStart(2, '0')}${g.toString(16).padStart(2, '0')}${b.toString(16).padStart(2, '0')}`;\n}\n\nexport const adjustTextContrast = (color: string) => {\n color = color.replace(/^#/, '')\n const r = parseInt(color.slice(0, 2), 16);\n const g = parseInt(color.slice(2, 4), 16);\n const b = parseInt(color.slice(4, 6), 16);\n\n const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;\n return luminance > 0.5 ? '#111111' : '#FFFFFF';\n}\n\nexport const alpha = (color: string, opacity = 1) => {\n if (typeof opacity !== 'number') return color\n let _opacity = opacity * 100\n if (!color.startsWith(\"#\")) throw new Error(`color must be hex`)\n return (color + (`0${Math.round((255 / 100) * _opacity).toString(16)}`.slice(-2))).toUpperCase();\n};\n\n"],"names":["_css"],"mappings":";;;;;AAWO,MAAM,WAAW,GAAG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W,EAAE;AACpG;;;;"}
|
package/index.cjs
CHANGED
|
@@ -7,18 +7,18 @@ var useColorTemplate = require('./hooks/useColorTemplate.cjs');
|
|
|
7
7
|
var useBreakpoint = require('./breakpoint/useBreakpoint.cjs');
|
|
8
8
|
var useBreakpointProps = require('./breakpoint/useBreakpointProps.cjs');
|
|
9
9
|
var useInterface = require('./hooks/useInterface.cjs');
|
|
10
|
-
var index$
|
|
10
|
+
var index$6 = require('./hooks/useTransition/index.cjs');
|
|
11
11
|
var useMergeRefs = require('./hooks/useMergeRefs.cjs');
|
|
12
|
-
var index$
|
|
12
|
+
var index$5 = require('./Transition/index.cjs');
|
|
13
13
|
var index = require('./AppRoot/index.cjs');
|
|
14
|
-
var
|
|
14
|
+
var index$3 = require('./Portal/index.cjs');
|
|
15
15
|
var Renderar = require('./AppRoot/Renderar.cjs');
|
|
16
|
-
var index$
|
|
16
|
+
var index$4 = require('./Document/index.cjs');
|
|
17
17
|
var AppRootProvider = require('./AppRoot/AppRootProvider.cjs');
|
|
18
18
|
var CSSCacheProvider = require('./css/CSSCacheProvider.cjs');
|
|
19
19
|
var index$1 = require('./Iframe/index.cjs');
|
|
20
|
-
var index$
|
|
21
|
-
var index$
|
|
20
|
+
var index$7 = require('./css/index.cjs');
|
|
21
|
+
var index$8 = require('./theme/index.cjs');
|
|
22
22
|
var getValue = require('./css/getValue.cjs');
|
|
23
23
|
var getProps = require('./css/getProps.cjs');
|
|
24
24
|
var ThemeProvider = require('./theme/ThemeProvider.cjs');
|
|
@@ -36,24 +36,24 @@ exports.useColorTemplate = useColorTemplate;
|
|
|
36
36
|
exports.useBreakpoint = useBreakpoint;
|
|
37
37
|
exports.useBreakpointProps = useBreakpointProps;
|
|
38
38
|
exports.useInterface = useInterface;
|
|
39
|
-
exports.useTransition = index$
|
|
39
|
+
exports.useTransition = index$6;
|
|
40
40
|
exports.useMergeRefs = useMergeRefs;
|
|
41
|
-
exports.Transition = index$
|
|
41
|
+
exports.Transition = index$5;
|
|
42
42
|
exports.AppRoot = index;
|
|
43
|
-
exports.
|
|
43
|
+
exports.Portal = index$3;
|
|
44
44
|
exports.Renderar = Renderar.Renderar;
|
|
45
|
-
exports.useDocument = index$
|
|
45
|
+
exports.useDocument = index$4.useDocument;
|
|
46
46
|
exports.useAppRootElement = AppRootProvider.useAppRootElement;
|
|
47
47
|
exports.getCSSCache = CSSCacheProvider.getCSSCache;
|
|
48
48
|
exports.useCSSCache = CSSCacheProvider.useCSSCache;
|
|
49
49
|
exports.useCSSCacheId = CSSCacheProvider.useCSSCacheId;
|
|
50
50
|
exports.Iframe = index$1;
|
|
51
|
-
exports.adjustColor = index$
|
|
52
|
-
exports.adjustTextContrast = index$
|
|
53
|
-
exports.alpha = index$
|
|
54
|
-
exports.breakpoints = index$
|
|
55
|
-
exports.css = index$
|
|
56
|
-
exports.themeRootClass = index$
|
|
51
|
+
exports.adjustColor = index$7.adjustColor;
|
|
52
|
+
exports.adjustTextContrast = index$7.adjustTextContrast;
|
|
53
|
+
exports.alpha = index$7.alpha;
|
|
54
|
+
exports.breakpoints = index$7.breakpoints;
|
|
55
|
+
exports.css = index$7.css;
|
|
56
|
+
exports.themeRootClass = index$8.themeRootClass;
|
|
57
57
|
exports.getValue = getValue;
|
|
58
58
|
exports.getProps = getProps;
|
|
59
59
|
exports.ThemeProvider = ThemeProvider;
|
package/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export { UseTransitionProps, UseTransitionState, UseTransitionVariant, UseTransi
|
|
|
9
9
|
export { default as useMergeRefs } from './hooks/useMergeRefs.js';
|
|
10
10
|
export { default as Transition, TransitionProps } from './Transition/index.js';
|
|
11
11
|
export { default as AppRoot, AppRootProps } from './AppRoot/index.js';
|
|
12
|
-
export { default as
|
|
12
|
+
export { default as Portal, PortalProps } from './Portal/index.js';
|
|
13
13
|
export { Renderar } from './AppRoot/Renderar.js';
|
|
14
14
|
export { useDocument } from './Document/index.js';
|
|
15
15
|
export { useAppRootElement } from './AppRoot/AppRootProvider.js';
|
package/index.js
CHANGED
|
@@ -9,7 +9,7 @@ export { default as useTransition } from './hooks/useTransition/index.js';
|
|
|
9
9
|
export { default as useMergeRefs } from './hooks/useMergeRefs.js';
|
|
10
10
|
export { default as Transition } from './Transition/index.js';
|
|
11
11
|
export { default as AppRoot } from './AppRoot/index.js';
|
|
12
|
-
export { default as
|
|
12
|
+
export { default as Portal } from './Portal/index.js';
|
|
13
13
|
export { Renderar } from './AppRoot/Renderar.js';
|
|
14
14
|
export { useDocument } from './Document/index.js';
|
|
15
15
|
export { useAppRootElement } from './AppRoot/AppRootProvider.js';
|
package/package.json
CHANGED
package/hooks/usePortal.cjs
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var client = require('react-dom/client');
|
|
7
|
-
var core = require('../theme/core.cjs');
|
|
8
|
-
require('../css/getValue.cjs');
|
|
9
|
-
require('oncss');
|
|
10
|
-
require('../theme/ThemeProvider.cjs');
|
|
11
|
-
require('react-state-bucket');
|
|
12
|
-
var AppRootProvider = require('../AppRoot/AppRootProvider.cjs');
|
|
13
|
-
var index = require('../Document/index.cjs');
|
|
14
|
-
var index$1 = require('../AppRoot/index.cjs');
|
|
15
|
-
var CSSCacheProvider = require('../css/CSSCacheProvider.cjs');
|
|
16
|
-
|
|
17
|
-
function usePortal(children, options) {
|
|
18
|
-
options = options || {};
|
|
19
|
-
if (options.autoMount === undefined) {
|
|
20
|
-
options.autoMount = true;
|
|
21
|
-
}
|
|
22
|
-
const [mounted, setMounted] = React.useState(options.autoMount);
|
|
23
|
-
const theme = core.useTheme();
|
|
24
|
-
const doc = index.useDocument();
|
|
25
|
-
const appRoot = AppRootProvider.useAppRootElement();
|
|
26
|
-
const cacheId = CSSCacheProvider.useCSSCacheId();
|
|
27
|
-
const { el, root } = React.useMemo(() => {
|
|
28
|
-
const el = doc === null || doc === void 0 ? void 0 : doc.document.createElement("div");
|
|
29
|
-
const root = client.createRoot(el);
|
|
30
|
-
return { el, root };
|
|
31
|
-
}, [options.autoMount]);
|
|
32
|
-
const container = () => {
|
|
33
|
-
const container = (options === null || options === void 0 ? void 0 : options.container) || appRoot;
|
|
34
|
-
if (!container)
|
|
35
|
-
throw new Error(`Container not found for portal. Please ensure that AppRoot is present in the application tree.`);
|
|
36
|
-
return container;
|
|
37
|
-
};
|
|
38
|
-
const mount = () => {
|
|
39
|
-
const cont = container();
|
|
40
|
-
if (!cont.contains(el)) {
|
|
41
|
-
cont.appendChild(el);
|
|
42
|
-
}
|
|
43
|
-
root.render(jsxRuntime.jsx(index$1, { disableRenderar: true, theme: theme.name, CSSCacheId: cacheId, document: doc === null || doc === void 0 ? void 0 : doc.document, children: children }));
|
|
44
|
-
};
|
|
45
|
-
const unmount = () => {
|
|
46
|
-
root.render(null);
|
|
47
|
-
el === null || el === void 0 ? void 0 : el.remove();
|
|
48
|
-
};
|
|
49
|
-
React.useEffect(() => {
|
|
50
|
-
(mounted && appRoot) ? mount() : unmount();
|
|
51
|
-
}, [mounted, appRoot]);
|
|
52
|
-
React.useEffect(() => {
|
|
53
|
-
if (mounted && appRoot)
|
|
54
|
-
mount();
|
|
55
|
-
}, [children, appRoot]);
|
|
56
|
-
React.useEffect(() => {
|
|
57
|
-
return () => {
|
|
58
|
-
unmount();
|
|
59
|
-
};
|
|
60
|
-
}, []);
|
|
61
|
-
return {
|
|
62
|
-
isMount: () => mounted,
|
|
63
|
-
mount: () => setMounted(true),
|
|
64
|
-
unmount: () => setMounted(false)
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
module.exports = usePortal;
|
|
69
|
-
//# sourceMappingURL=usePortal.cjs.map
|
package/hooks/usePortal.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"usePortal.cjs","sources":["../../src/hooks/usePortal.tsx"],"sourcesContent":["\"use client\";\nimport React, { useEffect, useMemo } from \"react\";\nimport { createRoot } from \"react-dom/client\";\nimport { ThemeProvider, useTheme } from \"../theme\";\nimport { useAppRootElement } from \"../AppRoot/AppRootProvider\";\nimport { useDocument } from \"../Document\";\nimport AppRoot from \"../AppRoot\";\nimport { useCSSCacheId } from \"../css/CSSCacheProvider\";\n\nexport type UsePortalOptions = {\n container?: HTMLElement;\n autoMount?: boolean;\n}\n\nfunction usePortal(children: React.ReactNode, options?: UsePortalOptions) {\n options = options || {};\n if (options.autoMount === undefined) {\n options.autoMount = true;\n }\n const [mounted, setMounted] = React.useState(options.autoMount);\n const theme = useTheme();\n const doc = useDocument()\n const appRoot = useAppRootElement();\n const cacheId = useCSSCacheId()\n\n const { el, root } = useMemo(() => {\n const el = doc?.document.createElement(\"div\");\n const root = createRoot(el!);\n return { el, root };\n }, [options.autoMount]);\n\n const container = () => {\n const container = options?.container || appRoot\n if (!container) throw new Error(`Container not found for portal. Please ensure that AppRoot is present in the application tree.`);\n return container;\n }\n\n const mount = () => {\n const cont = container();\n if (!cont.contains(el!)) {\n cont.appendChild(el!);\n }\n root.render(<AppRoot disableRenderar theme={theme.name} CSSCacheId={cacheId} document={doc?.document}>{children}</AppRoot>)\n }\n\n const unmount = () => {\n root.render(null)\n el?.remove();\n }\n\n useEffect(() => {\n (mounted && appRoot) ? mount() : unmount()\n }, [mounted, appRoot]);\n\n useEffect(() => {\n if (mounted && appRoot) mount()\n }, [children, appRoot]);\n\n useEffect(() => {\n return () => {\n unmount()\n };\n }, []);\n\n return {\n isMount: () => mounted,\n mount: () => setMounted(true),\n unmount: () => setMounted(false)\n }\n}\n\n\nexport default usePortal;"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAcA;AACG;AACA;AACG;;AAEH;AACA;AACA;AACA;AACA;;AAGG;AACA;AACA;AACH;;AAGG;AACA;AAAgB;AAChB;AACH;;AAGG;;AAEG;;AAEH;AACH;;AAGG;AACA;AACH;;AAGG;AACH;;;AAG2B;AAC3B;;AAGG;AACG;AACH;;;AAIA;AACA;AACA;;AAEN;;"}
|
package/hooks/usePortal.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React__default from 'react';
|
|
2
|
-
|
|
3
|
-
type UsePortalOptions = {
|
|
4
|
-
container?: HTMLElement;
|
|
5
|
-
autoMount?: boolean;
|
|
6
|
-
};
|
|
7
|
-
declare function usePortal(children: React__default.ReactNode, options?: UsePortalOptions): {
|
|
8
|
-
isMount: () => boolean;
|
|
9
|
-
mount: () => void;
|
|
10
|
-
unmount: () => void;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export { usePortal as default };
|
|
14
|
-
export type { UsePortalOptions };
|
package/hooks/usePortal.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import React__default, { useMemo, useEffect } from 'react';
|
|
4
|
-
import { createRoot } from 'react-dom/client';
|
|
5
|
-
import { useTheme } from '../theme/core.js';
|
|
6
|
-
import '../css/getValue.js';
|
|
7
|
-
import 'oncss';
|
|
8
|
-
import '../theme/ThemeProvider.js';
|
|
9
|
-
import 'react-state-bucket';
|
|
10
|
-
import { useAppRootElement } from '../AppRoot/AppRootProvider.js';
|
|
11
|
-
import { useDocument } from '../Document/index.js';
|
|
12
|
-
import AppRoot from '../AppRoot/index.js';
|
|
13
|
-
import { useCSSCacheId } from '../css/CSSCacheProvider.js';
|
|
14
|
-
|
|
15
|
-
function usePortal(children, options) {
|
|
16
|
-
options = options || {};
|
|
17
|
-
if (options.autoMount === undefined) {
|
|
18
|
-
options.autoMount = true;
|
|
19
|
-
}
|
|
20
|
-
const [mounted, setMounted] = React__default.useState(options.autoMount);
|
|
21
|
-
const theme = useTheme();
|
|
22
|
-
const doc = useDocument();
|
|
23
|
-
const appRoot = useAppRootElement();
|
|
24
|
-
const cacheId = useCSSCacheId();
|
|
25
|
-
const { el, root } = useMemo(() => {
|
|
26
|
-
const el = doc === null || doc === void 0 ? void 0 : doc.document.createElement("div");
|
|
27
|
-
const root = createRoot(el);
|
|
28
|
-
return { el, root };
|
|
29
|
-
}, [options.autoMount]);
|
|
30
|
-
const container = () => {
|
|
31
|
-
const container = (options === null || options === void 0 ? void 0 : options.container) || appRoot;
|
|
32
|
-
if (!container)
|
|
33
|
-
throw new Error(`Container not found for portal. Please ensure that AppRoot is present in the application tree.`);
|
|
34
|
-
return container;
|
|
35
|
-
};
|
|
36
|
-
const mount = () => {
|
|
37
|
-
const cont = container();
|
|
38
|
-
if (!cont.contains(el)) {
|
|
39
|
-
cont.appendChild(el);
|
|
40
|
-
}
|
|
41
|
-
root.render(jsx(AppRoot, { disableRenderar: true, theme: theme.name, CSSCacheId: cacheId, document: doc === null || doc === void 0 ? void 0 : doc.document, children: children }));
|
|
42
|
-
};
|
|
43
|
-
const unmount = () => {
|
|
44
|
-
root.render(null);
|
|
45
|
-
el === null || el === void 0 ? void 0 : el.remove();
|
|
46
|
-
};
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
(mounted && appRoot) ? mount() : unmount();
|
|
49
|
-
}, [mounted, appRoot]);
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
if (mounted && appRoot)
|
|
52
|
-
mount();
|
|
53
|
-
}, [children, appRoot]);
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
return () => {
|
|
56
|
-
unmount();
|
|
57
|
-
};
|
|
58
|
-
}, []);
|
|
59
|
-
return {
|
|
60
|
-
isMount: () => mounted,
|
|
61
|
-
mount: () => setMounted(true),
|
|
62
|
-
unmount: () => setMounted(false)
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export { usePortal as default };
|
|
67
|
-
//# sourceMappingURL=usePortal.js.map
|
package/hooks/usePortal.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"usePortal.js","sources":["../../src/hooks/usePortal.tsx"],"sourcesContent":["\"use client\";\nimport React, { useEffect, useMemo } from \"react\";\nimport { createRoot } from \"react-dom/client\";\nimport { ThemeProvider, useTheme } from \"../theme\";\nimport { useAppRootElement } from \"../AppRoot/AppRootProvider\";\nimport { useDocument } from \"../Document\";\nimport AppRoot from \"../AppRoot\";\nimport { useCSSCacheId } from \"../css/CSSCacheProvider\";\n\nexport type UsePortalOptions = {\n container?: HTMLElement;\n autoMount?: boolean;\n}\n\nfunction usePortal(children: React.ReactNode, options?: UsePortalOptions) {\n options = options || {};\n if (options.autoMount === undefined) {\n options.autoMount = true;\n }\n const [mounted, setMounted] = React.useState(options.autoMount);\n const theme = useTheme();\n const doc = useDocument()\n const appRoot = useAppRootElement();\n const cacheId = useCSSCacheId()\n\n const { el, root } = useMemo(() => {\n const el = doc?.document.createElement(\"div\");\n const root = createRoot(el!);\n return { el, root };\n }, [options.autoMount]);\n\n const container = () => {\n const container = options?.container || appRoot\n if (!container) throw new Error(`Container not found for portal. Please ensure that AppRoot is present in the application tree.`);\n return container;\n }\n\n const mount = () => {\n const cont = container();\n if (!cont.contains(el!)) {\n cont.appendChild(el!);\n }\n root.render(<AppRoot disableRenderar theme={theme.name} CSSCacheId={cacheId} document={doc?.document}>{children}</AppRoot>)\n }\n\n const unmount = () => {\n root.render(null)\n el?.remove();\n }\n\n useEffect(() => {\n (mounted && appRoot) ? mount() : unmount()\n }, [mounted, appRoot]);\n\n useEffect(() => {\n if (mounted && appRoot) mount()\n }, [children, appRoot]);\n\n useEffect(() => {\n return () => {\n unmount()\n };\n }, []);\n\n return {\n isMount: () => mounted,\n mount: () => setMounted(true),\n unmount: () => setMounted(false)\n }\n}\n\n\nexport default usePortal;"],"names":[],"mappings":";;;;;;;;;;;;;;AAcA;AACG;AACA;AACG;;AAEH;AACA;AACA;AACA;AACA;;AAGG;AACA;AACA;AACH;;AAGG;AACA;AAAgB;AAChB;AACH;;AAGG;;AAEG;;AAEH;AACH;;AAGG;AACA;AACH;;AAGG;AACH;;;AAG2B;AAC3B;;AAGG;AACG;AACH;;;AAIA;AACA;AACA;;AAEN;;"}
|