@xanui/core 1.2.60 → 1.2.61
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/index.cjs +15 -14
- package/AppRoot/index.cjs.map +1 -1
- package/AppRoot/index.d.ts +2 -1
- package/AppRoot/index.js +16 -15
- package/AppRoot/index.js.map +1 -1
- package/Iframe/index.cjs +0 -1
- package/Iframe/index.cjs.map +1 -1
- package/Iframe/index.js +0 -1
- package/Iframe/index.js.map +1 -1
- package/breakpoint/BreakpointProvider.cjs +10 -8
- package/breakpoint/BreakpointProvider.cjs.map +1 -1
- package/breakpoint/BreakpointProvider.js +10 -8
- package/breakpoint/BreakpointProvider.js.map +1 -1
- package/breakpoint/useBreakpoint.cjs.map +1 -1
- package/breakpoint/useBreakpoint.js.map +1 -1
- package/hooks/useInterface.cjs +0 -1
- package/hooks/useInterface.cjs.map +1 -1
- package/hooks/useInterface.d.ts +2 -2
- package/hooks/useInterface.js +0 -1
- package/hooks/useInterface.js.map +1 -1
- package/index.cjs +0 -2
- package/index.cjs.map +1 -1
- package/index.d.ts +0 -1
- package/index.js +0 -1
- package/index.js.map +1 -1
- package/package.json +2 -3
- package/theme/ThemeProvider.cjs +7 -2
- package/theme/ThemeProvider.cjs.map +1 -1
- package/theme/ThemeProvider.d.ts +2 -1
- package/theme/ThemeProvider.js +7 -2
- package/theme/ThemeProvider.js.map +1 -1
- package/theme/core.cjs +9 -2
- package/theme/core.cjs.map +1 -1
- package/theme/core.d.ts +5 -1
- package/theme/core.js +10 -3
- package/theme/core.js.map +1 -1
- package/theme/index.cjs +0 -1
- package/theme/index.cjs.map +1 -1
- package/theme/index.js +0 -1
- package/theme/index.js.map +1 -1
- package/theme/createThemeSwitcher.cjs +0 -26
- package/theme/createThemeSwitcher.cjs.map +0 -1
- package/theme/createThemeSwitcher.d.ts +0 -15
- package/theme/createThemeSwitcher.js +0 -24
- package/theme/createThemeSwitcher.js.map +0 -1
package/AppRoot/index.cjs
CHANGED
|
@@ -8,7 +8,6 @@ require('../theme/core.cjs');
|
|
|
8
8
|
require('../css/getValue.cjs');
|
|
9
9
|
require('oncss');
|
|
10
10
|
var ThemeProvider = require('../theme/ThemeProvider.cjs');
|
|
11
|
-
require('react-state-bucket');
|
|
12
11
|
var BreakpointProvider = require('../breakpoint/BreakpointProvider.cjs');
|
|
13
12
|
var Renderar = require('./Renderar.cjs');
|
|
14
13
|
var index = require('../Document/index.cjs');
|
|
@@ -17,8 +16,7 @@ var useMergeRefs = require('../hooks/useMergeRefs.cjs');
|
|
|
17
16
|
var CSSCacheProvider = require('../css/CSSCacheProvider.cjs');
|
|
18
17
|
|
|
19
18
|
const AppRoot = React.forwardRef((_a, ref) => {
|
|
20
|
-
var { children,
|
|
21
|
-
disableFlashing !== null && disableFlashing !== void 0 ? disableFlashing : (disableFlashing = false);
|
|
19
|
+
var { children, defaultBreakpoint, noScrollbarCss, CSSCacheId, theme, onThemeChange, disableRenderar, selectionColor, document: _document } = _a, props = tslib.__rest(_a, ["children", "defaultBreakpoint", "noScrollbarCss", "CSSCacheId", "theme", "onThemeChange", "disableRenderar", "selectionColor", "document"]);
|
|
22
20
|
noScrollbarCss !== null && noScrollbarCss !== void 0 ? noScrollbarCss : (noScrollbarCss = false);
|
|
23
21
|
selectionColor !== null && selectionColor !== void 0 ? selectionColor : (selectionColor = "brand");
|
|
24
22
|
if (typeof window !== "undefined") {
|
|
@@ -28,20 +26,20 @@ const AppRoot = React.forwardRef((_a, ref) => {
|
|
|
28
26
|
const docid = React.useId();
|
|
29
27
|
const csscacheId = React.useId();
|
|
30
28
|
CSSCacheId !== null && CSSCacheId !== void 0 ? CSSCacheId : (CSSCacheId = csscacheId);
|
|
31
|
-
const [visibility, setVisibility] = React.useState(!
|
|
29
|
+
const [visibility, setVisibility] = React.useState(!defaultBreakpoint ? "hidden" : "");
|
|
32
30
|
const rootRef = React.useRef(null);
|
|
33
31
|
const mergeRef = useMergeRefs(rootRef, ref);
|
|
34
32
|
React.useLayoutEffect(() => {
|
|
35
|
-
!
|
|
33
|
+
!defaultBreakpoint && setVisibility("");
|
|
34
|
+
}, []);
|
|
35
|
+
React.useEffect(() => {
|
|
36
|
+
if (typeof _document === 'undefined')
|
|
37
|
+
return;
|
|
38
|
+
const styles = Array.from(_document.querySelectorAll('body style[data-oncss]'));
|
|
39
|
+
styles.forEach((style) => {
|
|
40
|
+
_document.head.appendChild(style);
|
|
41
|
+
});
|
|
36
42
|
}, []);
|
|
37
|
-
// useEffect(() => {
|
|
38
|
-
// // move oncss style tags to head
|
|
39
|
-
// if (typeof _document === 'undefined') return;
|
|
40
|
-
// const styles = Array.from(_document.querySelectorAll('body style[data-oncss]'));
|
|
41
|
-
// styles.forEach((style) => {
|
|
42
|
-
// _document.head.appendChild(style);
|
|
43
|
-
// });
|
|
44
|
-
// }, [])
|
|
45
43
|
let selection = {};
|
|
46
44
|
if (selectionColor && selectionColor !== 'default') {
|
|
47
45
|
selection = {
|
|
@@ -51,7 +49,10 @@ const AppRoot = React.forwardRef((_a, ref) => {
|
|
|
51
49
|
}
|
|
52
50
|
};
|
|
53
51
|
}
|
|
54
|
-
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
|
|
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, onThemeChange: (t) => {
|
|
53
|
+
onThemeChange && onThemeChange(t);
|
|
54
|
+
document.cookie = `xuitm=${t};path=/`;
|
|
55
|
+
} }, props, { ref: mergeRef, isRoot: true, sx: Object.assign(Object.assign(Object.assign({}, props.sx), (visibility === "hidden" ? { visibility: "hidden" } : {})), selection), children: jsxRuntime.jsxs(BreakpointProvider.BreakpointProvider, { defaultKey: defaultBreakpoint !== null && defaultBreakpoint !== void 0 ? defaultBreakpoint : "xl", children: [children, !disableRenderar && jsxRuntime.jsx(Renderar.RenderRenderar, {})] }) })) }) }) }));
|
|
55
56
|
});
|
|
56
57
|
|
|
57
58
|
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, useLayoutEffect, 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
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/AppRoot/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { useEffect, useId, useLayoutEffect, 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';\nimport { BreakpointKeys } from '../css/types';\n\nexport type AppRootProps<T extends TagComponentType = \"div\"> = ThemeProviderProps<T> & {\n noScrollbarCss?: boolean;\n document?: Document;\n CSSCacheId?: string;\n disableRenderar?: boolean;\n defaultBreakpoint?: BreakpointKeys\n selectionColor?: \"default\" | \"brand\" | \"accent\" | \"success\" | \"info\" | \"warning\" | \"danger\";\n}\n\nconst AppRoot = React.forwardRef(<T extends TagComponentType = \"div\">({ children, defaultBreakpoint, noScrollbarCss, CSSCacheId, theme, onThemeChange, disableRenderar, selectionColor, document: _document, ...props }: AppRootProps<T>, ref: React.Ref<any>) => {\n\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>(!defaultBreakpoint ? \"hidden\" : \"\");\n const rootRef = useRef(null)\n const mergeRef = useMergeRefs(rootRef, ref)\n\n useLayoutEffect(() => {\n !defaultBreakpoint && setVisibility(\"\");\n }, [])\n\n useEffect(() => {\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\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 onThemeChange={(t) => {\n onThemeChange && onThemeChange(t)\n document.cookie = `xuitm=${t};path=/`\n }}\n {...props}\n ref={mergeRef}\n isRoot\n sx={{\n ...props.sx,\n ...(visibility === \"hidden\" ? { visibility: \"hidden\" } : {}),\n ...selection\n }}\n >\n <BreakpointProvider defaultKey={defaultBreakpoint ?? \"xl\"}>\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":";;;;;;;;;;;;;;;;;AAqBA;;;;AAIG;;;;AAIA;AACA;;;AAIA;;;AAIG;;;;;AAKA;AACA;AACG;AACH;;;AAIH;AACG;AACG;;;AAGC;;;;AAWW;AACA;AACH;AAmBlB;;"}
|
package/AppRoot/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
2
|
import { TagComponentType } from '../Tag/types.js';
|
|
3
|
+
import { BreakpointKeys } from '../css/types.js';
|
|
3
4
|
import { ThemeProviderProps } from '../theme/ThemeProvider.js';
|
|
4
5
|
|
|
5
6
|
type AppRootProps<T extends TagComponentType = "div"> = ThemeProviderProps<T> & {
|
|
@@ -7,7 +8,7 @@ type AppRootProps<T extends TagComponentType = "div"> = ThemeProviderProps<T> &
|
|
|
7
8
|
document?: Document;
|
|
8
9
|
CSSCacheId?: string;
|
|
9
10
|
disableRenderar?: boolean;
|
|
10
|
-
|
|
11
|
+
defaultBreakpoint?: BreakpointKeys;
|
|
11
12
|
selectionColor?: "default" | "brand" | "accent" | "success" | "info" | "warning" | "danger";
|
|
12
13
|
};
|
|
13
14
|
declare const AppRoot: React__default.ForwardRefExoticComponent<Omit<AppRootProps<TagComponentType>, "ref"> & React__default.RefAttributes<any>>;
|
package/AppRoot/index.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { __rest } from 'tslib';
|
|
3
3
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
|
-
import React__default, { useId, useRef, useLayoutEffect } from 'react';
|
|
4
|
+
import React__default, { useId, useRef, useLayoutEffect, useEffect } from 'react';
|
|
5
5
|
import '../theme/core.js';
|
|
6
6
|
import '../css/getValue.js';
|
|
7
7
|
import 'oncss';
|
|
8
8
|
import ThemeProvider from '../theme/ThemeProvider.js';
|
|
9
|
-
import 'react-state-bucket';
|
|
10
9
|
import { BreakpointProvider } from '../breakpoint/BreakpointProvider.js';
|
|
11
10
|
import { RenderRenderar } from './Renderar.js';
|
|
12
11
|
import { DocumentProvider } from '../Document/index.js';
|
|
@@ -15,8 +14,7 @@ import useMergeRefs from '../hooks/useMergeRefs.js';
|
|
|
15
14
|
import { CSSCacheProvider } from '../css/CSSCacheProvider.js';
|
|
16
15
|
|
|
17
16
|
const AppRoot = React__default.forwardRef((_a, ref) => {
|
|
18
|
-
var { children,
|
|
19
|
-
disableFlashing !== null && disableFlashing !== void 0 ? disableFlashing : (disableFlashing = false);
|
|
17
|
+
var { children, defaultBreakpoint, noScrollbarCss, CSSCacheId, theme, onThemeChange, disableRenderar, selectionColor, document: _document } = _a, props = __rest(_a, ["children", "defaultBreakpoint", "noScrollbarCss", "CSSCacheId", "theme", "onThemeChange", "disableRenderar", "selectionColor", "document"]);
|
|
20
18
|
noScrollbarCss !== null && noScrollbarCss !== void 0 ? noScrollbarCss : (noScrollbarCss = false);
|
|
21
19
|
selectionColor !== null && selectionColor !== void 0 ? selectionColor : (selectionColor = "brand");
|
|
22
20
|
if (typeof window !== "undefined") {
|
|
@@ -26,20 +24,20 @@ const AppRoot = React__default.forwardRef((_a, ref) => {
|
|
|
26
24
|
const docid = useId();
|
|
27
25
|
const csscacheId = useId();
|
|
28
26
|
CSSCacheId !== null && CSSCacheId !== void 0 ? CSSCacheId : (CSSCacheId = csscacheId);
|
|
29
|
-
const [visibility, setVisibility] = React__default.useState(!
|
|
27
|
+
const [visibility, setVisibility] = React__default.useState(!defaultBreakpoint ? "hidden" : "");
|
|
30
28
|
const rootRef = useRef(null);
|
|
31
29
|
const mergeRef = useMergeRefs(rootRef, ref);
|
|
32
30
|
useLayoutEffect(() => {
|
|
33
|
-
!
|
|
31
|
+
!defaultBreakpoint && setVisibility("");
|
|
32
|
+
}, []);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (typeof _document === 'undefined')
|
|
35
|
+
return;
|
|
36
|
+
const styles = Array.from(_document.querySelectorAll('body style[data-oncss]'));
|
|
37
|
+
styles.forEach((style) => {
|
|
38
|
+
_document.head.appendChild(style);
|
|
39
|
+
});
|
|
34
40
|
}, []);
|
|
35
|
-
// useEffect(() => {
|
|
36
|
-
// // move oncss style tags to head
|
|
37
|
-
// if (typeof _document === 'undefined') return;
|
|
38
|
-
// const styles = Array.from(_document.querySelectorAll('body style[data-oncss]'));
|
|
39
|
-
// styles.forEach((style) => {
|
|
40
|
-
// _document.head.appendChild(style);
|
|
41
|
-
// });
|
|
42
|
-
// }, [])
|
|
43
41
|
let selection = {};
|
|
44
42
|
if (selectionColor && selectionColor !== 'default') {
|
|
45
43
|
selection = {
|
|
@@ -49,7 +47,10 @@ const AppRoot = React__default.forwardRef((_a, ref) => {
|
|
|
49
47
|
}
|
|
50
48
|
};
|
|
51
49
|
}
|
|
52
|
-
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
|
|
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, onThemeChange: (t) => {
|
|
51
|
+
onThemeChange && onThemeChange(t);
|
|
52
|
+
document.cookie = `xuitm=${t};path=/`;
|
|
53
|
+
} }, props, { ref: mergeRef, isRoot: true, sx: Object.assign(Object.assign(Object.assign({}, props.sx), (visibility === "hidden" ? { visibility: "hidden" } : {})), selection), children: jsxs(BreakpointProvider, { defaultKey: defaultBreakpoint !== null && defaultBreakpoint !== void 0 ? defaultBreakpoint : "xl", children: [children, !disableRenderar && jsx(RenderRenderar, {})] }) })) }) }) }));
|
|
53
54
|
});
|
|
54
55
|
|
|
55
56
|
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, useLayoutEffect, 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
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/AppRoot/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { useEffect, useId, useLayoutEffect, 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';\nimport { BreakpointKeys } from '../css/types';\n\nexport type AppRootProps<T extends TagComponentType = \"div\"> = ThemeProviderProps<T> & {\n noScrollbarCss?: boolean;\n document?: Document;\n CSSCacheId?: string;\n disableRenderar?: boolean;\n defaultBreakpoint?: BreakpointKeys\n selectionColor?: \"default\" | \"brand\" | \"accent\" | \"success\" | \"info\" | \"warning\" | \"danger\";\n}\n\nconst AppRoot = React.forwardRef(<T extends TagComponentType = \"div\">({ children, defaultBreakpoint, noScrollbarCss, CSSCacheId, theme, onThemeChange, disableRenderar, selectionColor, document: _document, ...props }: AppRootProps<T>, ref: React.Ref<any>) => {\n\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>(!defaultBreakpoint ? \"hidden\" : \"\");\n const rootRef = useRef(null)\n const mergeRef = useMergeRefs(rootRef, ref)\n\n useLayoutEffect(() => {\n !defaultBreakpoint && setVisibility(\"\");\n }, [])\n\n useEffect(() => {\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\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 onThemeChange={(t) => {\n onThemeChange && onThemeChange(t)\n document.cookie = `xuitm=${t};path=/`\n }}\n {...props}\n ref={mergeRef}\n isRoot\n sx={{\n ...props.sx,\n ...(visibility === \"hidden\" ? { visibility: \"hidden\" } : {}),\n ...selection\n }}\n >\n <BreakpointProvider defaultKey={defaultBreakpoint ?? \"xl\"}>\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":";;;;;;;;;;;;;;;AAqBA;;;;AAIG;;;;AAIA;AACA;;;AAIA;;;AAIG;;;;;AAKA;AACA;AACG;AACH;;;AAIH;AACG;AACG;;;AAGC;;;;AAWW;AACA;AACH;AAmBlB;;"}
|
package/Iframe/index.cjs
CHANGED
|
@@ -8,7 +8,6 @@ var core = require('../theme/core.cjs');
|
|
|
8
8
|
require('../css/getValue.cjs');
|
|
9
9
|
require('oncss');
|
|
10
10
|
require('../theme/ThemeProvider.cjs');
|
|
11
|
-
require('react-state-bucket');
|
|
12
11
|
var index$1 = require('../Tag/index.cjs');
|
|
13
12
|
var reactDom = require('react-dom');
|
|
14
13
|
var index$2 = require('../AppRoot/index.cjs');
|
package/Iframe/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/Iframe/index.tsx"],"sourcesContent":["'use client'\nimport React, { createContext, useEffect, useRef, useState } from \"react\";\nimport { useTheme } from \"../theme\";\nimport Tag from \"../Tag\";\nimport { createPortal } from \"react-dom\";\nimport AppRoot from \"../AppRoot\";\nimport { TagPropsRoot } from \"../Tag/types\";\nimport useMergeRefs from \"../hooks/useMergeRefs\";\n\nconst IframeContext = createContext<{ document: Document | null; window: Window | null; }>({\n document: null,\n window: null,\n});\n\n\nexport type IframeProps = Omit<TagPropsRoot<\"iframe\">, \"component\"> & {\n theme?: string;\n CSSCacheId?: string;\n}\n\nconst Iframe = ({ children, sxr, theme, CSSCacheId, ...props }: IframeProps, ref: React.Ref<HTMLIFrameElement>) => {\n const [doc, setDoc] = useState<Document | null>(null);\n const iframeRef = useRef<HTMLIFrameElement>(null);\n const _ref = useMergeRefs(iframeRef, ref)\n const parentTheme = useTheme()\n theme ??= parentTheme.name\n\n useEffect(() => {\n if (!iframeRef.current) return;\n const iframe = iframeRef.current;\n const onLoad = () => setDoc(iframe.contentDocument);\n iframe.addEventListener(\"load\", onLoad);\n return () => iframe.removeEventListener(\"load\", onLoad);\n }, []);\n\n return (\n <>\n <Tag\n {...props}\n component={\"iframe\"}\n sxr={{\n border: 'none',\n width: \"100%\",\n height: \"100%\",\n p: 0,\n m: 0,\n ...sxr\n }}\n ref={_ref}\n srcDoc={\"<!DOCTYPE html><html><head></head><body></body></html>\"}\n />\n {doc &&\n createPortal(\n <IframeContext.Provider\n value={{\n document: doc,\n window: doc.defaultView,\n }}\n >\n <AppRoot disableRenderar theme={theme} document={doc as Document} CSSCacheId={CSSCacheId}>\n {children}\n </AppRoot>\n </IframeContext.Provider>,\n doc.body\n )}\n </>\n );\n}\n\nexport default React.forwardRef(Iframe)"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/Iframe/index.tsx"],"sourcesContent":["'use client'\nimport React, { createContext, useEffect, useRef, useState } from \"react\";\nimport { useTheme } from \"../theme\";\nimport Tag from \"../Tag\";\nimport { createPortal } from \"react-dom\";\nimport AppRoot from \"../AppRoot\";\nimport { TagPropsRoot } from \"../Tag/types\";\nimport useMergeRefs from \"../hooks/useMergeRefs\";\n\nconst IframeContext = createContext<{ document: Document | null; window: Window | null; }>({\n document: null,\n window: null,\n});\n\n\nexport type IframeProps = Omit<TagPropsRoot<\"iframe\">, \"component\"> & {\n theme?: string;\n CSSCacheId?: string;\n}\n\nconst Iframe = ({ children, sxr, theme, CSSCacheId, ...props }: IframeProps, ref: React.Ref<HTMLIFrameElement>) => {\n const [doc, setDoc] = useState<Document | null>(null);\n const iframeRef = useRef<HTMLIFrameElement>(null);\n const _ref = useMergeRefs(iframeRef, ref)\n const parentTheme = useTheme()\n theme ??= parentTheme.name\n\n useEffect(() => {\n if (!iframeRef.current) return;\n const iframe = iframeRef.current;\n const onLoad = () => setDoc(iframe.contentDocument);\n iframe.addEventListener(\"load\", onLoad);\n return () => iframe.removeEventListener(\"load\", onLoad);\n }, []);\n\n return (\n <>\n <Tag\n {...props}\n component={\"iframe\"}\n sxr={{\n border: 'none',\n width: \"100%\",\n height: \"100%\",\n p: 0,\n m: 0,\n ...sxr\n }}\n ref={_ref}\n srcDoc={\"<!DOCTYPE html><html><head></head><body></body></html>\"}\n />\n {doc &&\n createPortal(\n <IframeContext.Provider\n value={{\n document: doc,\n window: doc.defaultView,\n }}\n >\n <AppRoot disableRenderar theme={theme} document={doc as Document} CSSCacheId={CSSCacheId}>\n {children}\n </AppRoot>\n </IframeContext.Provider>,\n doc.body\n )}\n </>\n );\n}\n\nexport default React.forwardRef(Iframe)"],"names":[],"mappings":";;;;;;;;;;;;;;;AASA;AACG;AACA;AACF;AAQD;AAAgB;;AAEb;;AAEA;;;;;AAKG;;AAEA;;;;AAqBM;AAGS;;;AAYrB;AAEA;;"}
|
package/Iframe/index.js
CHANGED
|
@@ -6,7 +6,6 @@ import { useTheme } from '../theme/core.js';
|
|
|
6
6
|
import '../css/getValue.js';
|
|
7
7
|
import 'oncss';
|
|
8
8
|
import '../theme/ThemeProvider.js';
|
|
9
|
-
import 'react-state-bucket';
|
|
10
9
|
import Tag from '../Tag/index.js';
|
|
11
10
|
import { createPortal } from 'react-dom';
|
|
12
11
|
import AppRoot from '../AppRoot/index.js';
|
package/Iframe/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/Iframe/index.tsx"],"sourcesContent":["'use client'\nimport React, { createContext, useEffect, useRef, useState } from \"react\";\nimport { useTheme } from \"../theme\";\nimport Tag from \"../Tag\";\nimport { createPortal } from \"react-dom\";\nimport AppRoot from \"../AppRoot\";\nimport { TagPropsRoot } from \"../Tag/types\";\nimport useMergeRefs from \"../hooks/useMergeRefs\";\n\nconst IframeContext = createContext<{ document: Document | null; window: Window | null; }>({\n document: null,\n window: null,\n});\n\n\nexport type IframeProps = Omit<TagPropsRoot<\"iframe\">, \"component\"> & {\n theme?: string;\n CSSCacheId?: string;\n}\n\nconst Iframe = ({ children, sxr, theme, CSSCacheId, ...props }: IframeProps, ref: React.Ref<HTMLIFrameElement>) => {\n const [doc, setDoc] = useState<Document | null>(null);\n const iframeRef = useRef<HTMLIFrameElement>(null);\n const _ref = useMergeRefs(iframeRef, ref)\n const parentTheme = useTheme()\n theme ??= parentTheme.name\n\n useEffect(() => {\n if (!iframeRef.current) return;\n const iframe = iframeRef.current;\n const onLoad = () => setDoc(iframe.contentDocument);\n iframe.addEventListener(\"load\", onLoad);\n return () => iframe.removeEventListener(\"load\", onLoad);\n }, []);\n\n return (\n <>\n <Tag\n {...props}\n component={\"iframe\"}\n sxr={{\n border: 'none',\n width: \"100%\",\n height: \"100%\",\n p: 0,\n m: 0,\n ...sxr\n }}\n ref={_ref}\n srcDoc={\"<!DOCTYPE html><html><head></head><body></body></html>\"}\n />\n {doc &&\n createPortal(\n <IframeContext.Provider\n value={{\n document: doc,\n window: doc.defaultView,\n }}\n >\n <AppRoot disableRenderar theme={theme} document={doc as Document} CSSCacheId={CSSCacheId}>\n {children}\n </AppRoot>\n </IframeContext.Provider>,\n doc.body\n )}\n </>\n );\n}\n\nexport default React.forwardRef(Iframe)"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/Iframe/index.tsx"],"sourcesContent":["'use client'\nimport React, { createContext, useEffect, useRef, useState } from \"react\";\nimport { useTheme } from \"../theme\";\nimport Tag from \"../Tag\";\nimport { createPortal } from \"react-dom\";\nimport AppRoot from \"../AppRoot\";\nimport { TagPropsRoot } from \"../Tag/types\";\nimport useMergeRefs from \"../hooks/useMergeRefs\";\n\nconst IframeContext = createContext<{ document: Document | null; window: Window | null; }>({\n document: null,\n window: null,\n});\n\n\nexport type IframeProps = Omit<TagPropsRoot<\"iframe\">, \"component\"> & {\n theme?: string;\n CSSCacheId?: string;\n}\n\nconst Iframe = ({ children, sxr, theme, CSSCacheId, ...props }: IframeProps, ref: React.Ref<HTMLIFrameElement>) => {\n const [doc, setDoc] = useState<Document | null>(null);\n const iframeRef = useRef<HTMLIFrameElement>(null);\n const _ref = useMergeRefs(iframeRef, ref)\n const parentTheme = useTheme()\n theme ??= parentTheme.name\n\n useEffect(() => {\n if (!iframeRef.current) return;\n const iframe = iframeRef.current;\n const onLoad = () => setDoc(iframe.contentDocument);\n iframe.addEventListener(\"load\", onLoad);\n return () => iframe.removeEventListener(\"load\", onLoad);\n }, []);\n\n return (\n <>\n <Tag\n {...props}\n component={\"iframe\"}\n sxr={{\n border: 'none',\n width: \"100%\",\n height: \"100%\",\n p: 0,\n m: 0,\n ...sxr\n }}\n ref={_ref}\n srcDoc={\"<!DOCTYPE html><html><head></head><body></body></html>\"}\n />\n {doc &&\n createPortal(\n <IframeContext.Provider\n value={{\n document: doc,\n window: doc.defaultView,\n }}\n >\n <AppRoot disableRenderar theme={theme} document={doc as Document} CSSCacheId={CSSCacheId}>\n {children}\n </AppRoot>\n </IframeContext.Provider>,\n doc.body\n )}\n </>\n );\n}\n\nexport default React.forwardRef(Iframe)"],"names":[],"mappings":";;;;;;;;;;;;;AASA;AACG;AACA;AACF;AAQD;AAAgB;;AAEb;;AAEA;;;;;AAKG;;AAEA;;;;AAqBM;AAGS;;;AAYrB;AAEA;;"}
|
|
@@ -5,7 +5,7 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var index = require('../css/index.cjs');
|
|
7
7
|
|
|
8
|
-
const BreakpointCtx = React.createContext(
|
|
8
|
+
const BreakpointCtx = React.createContext(null);
|
|
9
9
|
const queries = {
|
|
10
10
|
xs: `(max-width:${index.breakpoints.sm - 0.02}px)`,
|
|
11
11
|
sm: `(min-width:${index.breakpoints.sm}px) and (max-width:${index.breakpoints.md - 0.02}px)`,
|
|
@@ -13,27 +13,29 @@ const queries = {
|
|
|
13
13
|
lg: `(min-width:${index.breakpoints.lg}px) and (max-width:${index.breakpoints.xl - 0.02}px)`,
|
|
14
14
|
xl: `(min-width:${index.breakpoints.xl}px)`
|
|
15
15
|
};
|
|
16
|
-
const getCurrent = () => {
|
|
16
|
+
const getCurrent = (def) => {
|
|
17
17
|
if (typeof window === "undefined")
|
|
18
|
-
return
|
|
18
|
+
return def;
|
|
19
19
|
const entries = Object.entries(queries);
|
|
20
20
|
for (const [key, query] of entries) {
|
|
21
21
|
if (window.matchMedia(query).matches) {
|
|
22
22
|
return key;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
return
|
|
25
|
+
return def;
|
|
26
26
|
};
|
|
27
|
-
const BreakpointProvider = ({ children }) => {
|
|
28
|
-
const [current, setCurrent] = React.useState(
|
|
27
|
+
const BreakpointProvider = ({ children, defaultKey }) => {
|
|
28
|
+
const [current, setCurrent] = React.useState(defaultKey);
|
|
29
29
|
React.useEffect(() => {
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const current = getCurrent(defaultKey);
|
|
31
|
+
setCurrent(current);
|
|
32
|
+
document.cookie = `xuibp=${current};path=/`;
|
|
32
33
|
const mqls = Object.entries(queries).map(([key, query]) => {
|
|
33
34
|
const mql = window.matchMedia(query);
|
|
34
35
|
const handler = () => {
|
|
35
36
|
if (mql.matches) {
|
|
36
37
|
setCurrent(key);
|
|
38
|
+
document.cookie = `xuibp=${key};path=/`;
|
|
37
39
|
}
|
|
38
40
|
};
|
|
39
41
|
mql.addEventListener("change", handler);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BreakpointProvider.cjs","sources":["../../src/breakpoint/BreakpointProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { ReactNode, useEffect, useState } from \"react\";\nimport { breakpoints } from \"../css\";\nimport { BreakpointKeys } from \"../css/types\";\n\nexport const BreakpointCtx = React.createContext<BreakpointKeys>(
|
|
1
|
+
{"version":3,"file":"BreakpointProvider.cjs","sources":["../../src/breakpoint/BreakpointProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { ReactNode, useEffect, useState } from \"react\";\nimport { breakpoints } from \"../css\";\nimport { BreakpointKeys } from \"../css/types\";\n\nexport const BreakpointCtx = React.createContext<BreakpointKeys | null>(null);\n\nconst queries: Record<BreakpointKeys, string> = {\n xs: `(max-width:${breakpoints.sm - 0.02}px)`,\n sm: `(min-width:${breakpoints.sm}px) and (max-width:${breakpoints.md - 0.02}px)`,\n md: `(min-width:${breakpoints.md}px) and (max-width:${breakpoints.lg - 0.02}px)`,\n lg: `(min-width:${breakpoints.lg}px) and (max-width:${breakpoints.xl - 0.02}px)`,\n xl: `(min-width:${breakpoints.xl}px)`\n};\n\nconst getCurrent = (def: BreakpointKeys): BreakpointKeys => {\n if (typeof window === \"undefined\") return def;\n const entries = Object.entries(queries) as [BreakpointKeys, string][];\n for (const [key, query] of entries) {\n if (window.matchMedia(query).matches) {\n return key;\n }\n }\n return def;\n};\n\nexport const BreakpointProvider = ({ children, defaultKey }: { children?: ReactNode, defaultKey: BreakpointKeys }) => {\n const [current, setCurrent] = useState<BreakpointKeys>(defaultKey);\n\n useEffect(() => {\n const current = getCurrent(defaultKey)\n setCurrent(current)\n document.cookie = `xuibp=${current};path=/`\n const mqls = Object.entries(queries).map(([key, query]) => {\n const mql = window.matchMedia(query);\n const handler = () => {\n if (mql.matches) {\n setCurrent(key as BreakpointKeys);\n document.cookie = `xuibp=${key};path=/`\n }\n };\n\n mql.addEventListener(\"change\", handler);\n\n return () => mql.removeEventListener(\"change\", handler);\n });\n\n return () => {\n mqls.forEach(fn => fn());\n };\n }, []);\n\n return (\n <BreakpointCtx.Provider value={current}>\n {children}\n </BreakpointCtx.Provider>\n );\n};"],"names":[],"mappings":";;;;;;;AAMO;AAEP;AACI;;;;AAIA;;AAGJ;;AACuC;;;;AAI3B;;;AAGR;AACJ;AAEO;;;AAIC;;AAEA;AACA;;;AAGQ;;AAEI;;AAER;AAEA;;AAGJ;AAEA;;AAEA;;AAGJ;AAKJ;;;"}
|
|
@@ -3,7 +3,7 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import React__default, { useState, useEffect } from 'react';
|
|
4
4
|
import { breakpoints } from '../css/index.js';
|
|
5
5
|
|
|
6
|
-
const BreakpointCtx = React__default.createContext(
|
|
6
|
+
const BreakpointCtx = React__default.createContext(null);
|
|
7
7
|
const queries = {
|
|
8
8
|
xs: `(max-width:${breakpoints.sm - 0.02}px)`,
|
|
9
9
|
sm: `(min-width:${breakpoints.sm}px) and (max-width:${breakpoints.md - 0.02}px)`,
|
|
@@ -11,27 +11,29 @@ const queries = {
|
|
|
11
11
|
lg: `(min-width:${breakpoints.lg}px) and (max-width:${breakpoints.xl - 0.02}px)`,
|
|
12
12
|
xl: `(min-width:${breakpoints.xl}px)`
|
|
13
13
|
};
|
|
14
|
-
const getCurrent = () => {
|
|
14
|
+
const getCurrent = (def) => {
|
|
15
15
|
if (typeof window === "undefined")
|
|
16
|
-
return
|
|
16
|
+
return def;
|
|
17
17
|
const entries = Object.entries(queries);
|
|
18
18
|
for (const [key, query] of entries) {
|
|
19
19
|
if (window.matchMedia(query).matches) {
|
|
20
20
|
return key;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
return
|
|
23
|
+
return def;
|
|
24
24
|
};
|
|
25
|
-
const BreakpointProvider = ({ children }) => {
|
|
26
|
-
const [current, setCurrent] = useState(
|
|
25
|
+
const BreakpointProvider = ({ children, defaultKey }) => {
|
|
26
|
+
const [current, setCurrent] = useState(defaultKey);
|
|
27
27
|
useEffect(() => {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const current = getCurrent(defaultKey);
|
|
29
|
+
setCurrent(current);
|
|
30
|
+
document.cookie = `xuibp=${current};path=/`;
|
|
30
31
|
const mqls = Object.entries(queries).map(([key, query]) => {
|
|
31
32
|
const mql = window.matchMedia(query);
|
|
32
33
|
const handler = () => {
|
|
33
34
|
if (mql.matches) {
|
|
34
35
|
setCurrent(key);
|
|
36
|
+
document.cookie = `xuibp=${key};path=/`;
|
|
35
37
|
}
|
|
36
38
|
};
|
|
37
39
|
mql.addEventListener("change", handler);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BreakpointProvider.js","sources":["../../src/breakpoint/BreakpointProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { ReactNode, useEffect, useState } from \"react\";\nimport { breakpoints } from \"../css\";\nimport { BreakpointKeys } from \"../css/types\";\n\nexport const BreakpointCtx = React.createContext<BreakpointKeys>(
|
|
1
|
+
{"version":3,"file":"BreakpointProvider.js","sources":["../../src/breakpoint/BreakpointProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { ReactNode, useEffect, useState } from \"react\";\nimport { breakpoints } from \"../css\";\nimport { BreakpointKeys } from \"../css/types\";\n\nexport const BreakpointCtx = React.createContext<BreakpointKeys | null>(null);\n\nconst queries: Record<BreakpointKeys, string> = {\n xs: `(max-width:${breakpoints.sm - 0.02}px)`,\n sm: `(min-width:${breakpoints.sm}px) and (max-width:${breakpoints.md - 0.02}px)`,\n md: `(min-width:${breakpoints.md}px) and (max-width:${breakpoints.lg - 0.02}px)`,\n lg: `(min-width:${breakpoints.lg}px) and (max-width:${breakpoints.xl - 0.02}px)`,\n xl: `(min-width:${breakpoints.xl}px)`\n};\n\nconst getCurrent = (def: BreakpointKeys): BreakpointKeys => {\n if (typeof window === \"undefined\") return def;\n const entries = Object.entries(queries) as [BreakpointKeys, string][];\n for (const [key, query] of entries) {\n if (window.matchMedia(query).matches) {\n return key;\n }\n }\n return def;\n};\n\nexport const BreakpointProvider = ({ children, defaultKey }: { children?: ReactNode, defaultKey: BreakpointKeys }) => {\n const [current, setCurrent] = useState<BreakpointKeys>(defaultKey);\n\n useEffect(() => {\n const current = getCurrent(defaultKey)\n setCurrent(current)\n document.cookie = `xuibp=${current};path=/`\n const mqls = Object.entries(queries).map(([key, query]) => {\n const mql = window.matchMedia(query);\n const handler = () => {\n if (mql.matches) {\n setCurrent(key as BreakpointKeys);\n document.cookie = `xuibp=${key};path=/`\n }\n };\n\n mql.addEventListener(\"change\", handler);\n\n return () => mql.removeEventListener(\"change\", handler);\n });\n\n return () => {\n mqls.forEach(fn => fn());\n };\n }, []);\n\n return (\n <BreakpointCtx.Provider value={current}>\n {children}\n </BreakpointCtx.Provider>\n );\n};"],"names":[],"mappings":";;;;;AAMO;AAEP;AACI;;;;AAIA;;AAGJ;;AACuC;;;;AAI3B;;;AAGR;AACJ;AAEO;;;AAIC;;AAEA;AACA;;;AAGQ;;AAEI;;AAER;AAEA;;AAGJ;AAEA;;AAEA;;AAGJ;AAKJ;;"}
|
|
@@ -1 +1 @@
|
|
|
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 keys = Object.keys(breakpoints) as BreakpointKeys[];\n\nconst useBreakpoint = () => {\n const value = useContext(BreakpointCtx)
|
|
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 keys = Object.keys(breakpoints) as BreakpointKeys[];\n\nconst useBreakpoint = () => {\n const value = useContext(BreakpointCtx) as BreakpointKeys\n const index = keys.indexOf(value);\n\n const is = (key: BreakpointKeys) => value === key;\n const isUp = (key: BreakpointKeys) => index >= keys.indexOf(key);\n const isDown = (key: BreakpointKeys) => index < keys.indexOf(key);\n const isBetween = (start: BreakpointKeys, end: BreakpointKeys) =>\n index >= keys.indexOf(start) && index < keys.indexOf(end);\n const isOrUp = (k: BreakpointKeys) => isUp(k) || is(k);\n const isOrDown = (k: BreakpointKeys) => isDown(k) || is(k);\n\n return {\n value,\n is,\n isUp,\n isDown,\n isBetween,\n isOrUp,\n isOrDown\n };\n};\n\nexport default useBreakpoint;"],"names":["breakpoints","useContext","BreakpointCtx"],"mappings":";;;;;;AAKA,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAACA,iBAAW,CAAqB;AAEzD,MAAM,aAAa,GAAG,MAAK;AACxB,IAAA,MAAM,KAAK,GAAGC,gBAAU,CAACC,gCAAa,CAAmB;IACzD,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;IAEjC,MAAM,EAAE,GAAG,CAAC,GAAmB,KAAK,KAAK,KAAK,GAAG;AACjD,IAAA,MAAM,IAAI,GAAG,CAAC,GAAmB,KAAK,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;AAChE,IAAA,MAAM,MAAM,GAAG,CAAC,GAAmB,KAAK,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;IACjE,MAAM,SAAS,GAAG,CAAC,KAAqB,EAAE,GAAmB,KAC1D,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,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;IAE1D,OAAO;QACJ,KAAK;QACL,EAAE;QACF,IAAI;QACJ,MAAM;QACN,SAAS;QACT,MAAM;QACN;KACF;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
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 keys = Object.keys(breakpoints) as BreakpointKeys[];\n\nconst useBreakpoint = () => {\n const value = useContext(BreakpointCtx)
|
|
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 keys = Object.keys(breakpoints) as BreakpointKeys[];\n\nconst useBreakpoint = () => {\n const value = useContext(BreakpointCtx) as BreakpointKeys\n const index = keys.indexOf(value);\n\n const is = (key: BreakpointKeys) => value === key;\n const isUp = (key: BreakpointKeys) => index >= keys.indexOf(key);\n const isDown = (key: BreakpointKeys) => index < keys.indexOf(key);\n const isBetween = (start: BreakpointKeys, end: BreakpointKeys) =>\n index >= keys.indexOf(start) && index < keys.indexOf(end);\n const isOrUp = (k: BreakpointKeys) => isUp(k) || is(k);\n const isOrDown = (k: BreakpointKeys) => isDown(k) || is(k);\n\n return {\n value,\n is,\n isUp,\n isDown,\n isBetween,\n isOrUp,\n isOrDown\n };\n};\n\nexport default useBreakpoint;"],"names":[],"mappings":";;;;AAKA,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAqB;AAEzD,MAAM,aAAa,GAAG,MAAK;AACxB,IAAA,MAAM,KAAK,GAAG,UAAU,CAAC,aAAa,CAAmB;IACzD,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;IAEjC,MAAM,EAAE,GAAG,CAAC,GAAmB,KAAK,KAAK,KAAK,GAAG;AACjD,IAAA,MAAM,IAAI,GAAG,CAAC,GAAmB,KAAK,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;AAChE,IAAA,MAAM,MAAM,GAAG,CAAC,GAAmB,KAAK,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;IACjE,MAAM,SAAS,GAAG,CAAC,KAAqB,EAAE,GAAmB,KAC1D,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,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;IAE1D,OAAO;QACJ,KAAK;QACL,EAAE;QACF,IAAI;QACJ,MAAM;QACN,SAAS;QACT,MAAM;QACN;KACF;AACJ;;;;"}
|
package/hooks/useInterface.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInterface.cjs","sources":["../../src/hooks/useInterface.ts"],"sourcesContent":["import { useTheme } from \"../theme\"\n\nconst useInterface = <P extends object>(name: string, userPorps: P, defaultProps: P) => {\n const theme = useTheme()\n let _props = { ...defaultProps, ...userPorps } as P\n if (name in theme.interfaces) {\n return theme.interfaces[name](_props, theme)\n }\n return [_props, theme]\n}\n\nexport default useInterface"],"names":["useTheme"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useInterface.cjs","sources":["../../src/hooks/useInterface.ts"],"sourcesContent":["import { useTheme } from \"../theme\"\n\nconst useInterface = <P extends object>(name: string, userPorps: P, defaultProps: P) => {\n const theme = useTheme()\n let _props = { ...defaultProps, ...userPorps } as P\n if (name in theme.interfaces) {\n return theme.interfaces[name](_props, theme)\n }\n return [_props, theme]\n}\n\nexport default useInterface"],"names":["useTheme"],"mappings":";;;;;;;AAEA,MAAM,YAAY,GAAG,CAAmB,IAAY,EAAE,SAAY,EAAE,YAAe,KAAI;AACnF,IAAA,MAAM,KAAK,GAAGA,aAAQ,EAAE;AACxB,IAAA,IAAI,MAAM,GAAG,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAK,YAAY,CAAA,EAAK,SAAS,CAAO;AACnD,IAAA,IAAI,IAAI,IAAI,KAAK,CAAC,UAAU,EAAE;QAC1B,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC;IAChD;AACA,IAAA,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC;AAC1B;;;;"}
|
package/hooks/useInterface.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UseThemeOptions } from '../theme/core.js';
|
|
2
2
|
|
|
3
|
-
declare const useInterface: <P extends object>(name: string, userPorps: P, defaultProps: P) => P | (P |
|
|
3
|
+
declare const useInterface: <P extends object>(name: string, userPorps: P, defaultProps: P) => P | (P | UseThemeOptions)[];
|
|
4
4
|
|
|
5
5
|
export { useInterface as default };
|
package/hooks/useInterface.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInterface.js","sources":["../../src/hooks/useInterface.ts"],"sourcesContent":["import { useTheme } from \"../theme\"\n\nconst useInterface = <P extends object>(name: string, userPorps: P, defaultProps: P) => {\n const theme = useTheme()\n let _props = { ...defaultProps, ...userPorps } as P\n if (name in theme.interfaces) {\n return theme.interfaces[name](_props, theme)\n }\n return [_props, theme]\n}\n\nexport default useInterface"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useInterface.js","sources":["../../src/hooks/useInterface.ts"],"sourcesContent":["import { useTheme } from \"../theme\"\n\nconst useInterface = <P extends object>(name: string, userPorps: P, defaultProps: P) => {\n const theme = useTheme()\n let _props = { ...defaultProps, ...userPorps } as P\n if (name in theme.interfaces) {\n return theme.interfaces[name](_props, theme)\n }\n return [_props, theme]\n}\n\nexport default useInterface"],"names":[],"mappings":";;;;;AAEA,MAAM,YAAY,GAAG,CAAmB,IAAY,EAAE,SAAY,EAAE,YAAe,KAAI;AACnF,IAAA,MAAM,KAAK,GAAG,QAAQ,EAAE;AACxB,IAAA,IAAI,MAAM,GAAG,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAK,YAAY,CAAA,EAAK,SAAS,CAAO;AACnD,IAAA,IAAI,IAAI,IAAI,KAAK,CAAC,UAAU,EAAE;QAC1B,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC;IAChD;AACA,IAAA,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC;AAC1B;;;;"}
|
package/index.cjs
CHANGED
|
@@ -22,7 +22,6 @@ 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');
|
|
25
|
-
var createThemeSwitcher = require('./theme/createThemeSwitcher.cjs');
|
|
26
25
|
var createTheme = require('./theme/createTheme.cjs');
|
|
27
26
|
var core = require('./theme/core.cjs');
|
|
28
27
|
var ThemeDefaultOptions = require('./theme/ThemeDefaultOptions.cjs');
|
|
@@ -58,7 +57,6 @@ exports.themeRootClass = index$8.themeRootClass;
|
|
|
58
57
|
exports.getValue = getValue;
|
|
59
58
|
exports.getProps = getProps;
|
|
60
59
|
exports.ThemeProvider = ThemeProvider;
|
|
61
|
-
exports.createThemeSwitcher = createThemeSwitcher;
|
|
62
60
|
exports.createTheme = createTheme.createTheme;
|
|
63
61
|
exports.getTheme = core.getTheme;
|
|
64
62
|
exports.useTheme = core.useTheme;
|
package/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/index.d.ts
CHANGED
|
@@ -23,7 +23,6 @@ export { ColorsRefTypes, ObjectType, ThemeColorOption, ThemeOptionInput, ThemeOp
|
|
|
23
23
|
export { default as getValue } from './css/getValue.js';
|
|
24
24
|
export { default as getProps } from './css/getProps.js';
|
|
25
25
|
export { default as ThemeProvider, ThemeProviderProps } from './theme/ThemeProvider.js';
|
|
26
|
-
export { ThemeSwitcherOption, default as createThemeSwitcher } from './theme/createThemeSwitcher.js';
|
|
27
26
|
export { createTheme } from './theme/createTheme.js';
|
|
28
27
|
export { getTheme, useTheme } from './theme/core.js';
|
|
29
28
|
export { darkThemeOptions, lightThemeOptions } from './theme/ThemeDefaultOptions.js';
|
package/index.js
CHANGED
|
@@ -20,7 +20,6 @@ export { themeRootClass } from './theme/index.js';
|
|
|
20
20
|
export { default as getValue } from './css/getValue.js';
|
|
21
21
|
export { default as getProps } from './css/getProps.js';
|
|
22
22
|
export { default as ThemeProvider } from './theme/ThemeProvider.js';
|
|
23
|
-
export { default as createThemeSwitcher } from './theme/createThemeSwitcher.js';
|
|
24
23
|
export { createTheme } from './theme/createTheme.js';
|
|
25
24
|
export { getTheme, useTheme } from './theme/core.js';
|
|
26
25
|
export { darkThemeOptions, lightThemeOptions } from './theme/ThemeDefaultOptions.js';
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xanui/core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.61",
|
|
4
4
|
"description": "Xanui Core Library",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./index.cjs",
|
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
"sideEffects": false,
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"oncss": "^1.2.11",
|
|
12
|
-
"pretty-class": "^1.0.8"
|
|
13
|
-
"react-state-bucket": "^1.2.17"
|
|
12
|
+
"pretty-class": "^1.0.8"
|
|
14
13
|
},
|
|
15
14
|
"keywords": []
|
|
16
15
|
}
|
package/theme/ThemeProvider.cjs
CHANGED
|
@@ -35,7 +35,7 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
|
35
35
|
|
|
36
36
|
ThemeDefaultOptions.createDefaultThemes();
|
|
37
37
|
const ThemeProvider = (_a) => {
|
|
38
|
-
var { children, theme, isRoot, noScrollbarCss } = _a, props = tslib.__rest(_a, ["children", "theme", "isRoot", "noScrollbarCss"]);
|
|
38
|
+
var { children, theme, onThemeChange, isRoot, noScrollbarCss } = _a, props = tslib.__rest(_a, ["children", "theme", "onThemeChange", "isRoot", "noScrollbarCss"]);
|
|
39
39
|
let THEME = core.ThemeFactory.get(theme);
|
|
40
40
|
if (!THEME) {
|
|
41
41
|
console.error(`ThemeProvider: The theme '${theme}' is not defined. Please make sure to use a valid theme name.`);
|
|
@@ -143,7 +143,12 @@ const ThemeProvider = (_a) => {
|
|
|
143
143
|
cacheId
|
|
144
144
|
});
|
|
145
145
|
}, [noScrollbarCss, theme]);
|
|
146
|
-
return (jsxRuntime.jsxs(core.ThemeContex.Provider, { value:
|
|
146
|
+
return (jsxRuntime.jsxs(core.ThemeContex.Provider, { value: {
|
|
147
|
+
theme,
|
|
148
|
+
onChange: (t) => {
|
|
149
|
+
onThemeChange && onThemeChange(t);
|
|
150
|
+
}
|
|
151
|
+
}, children: [isRoot && jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ServerStyleTag, { factory: resetCss }), !noScrollbarCss && jsxRuntime.jsx(ServerStyleTag, { factory: scrollbarCss })] }), jsxRuntime.jsx(ServerStyleTag, { factory: themeGlobalStyle }), jsxRuntime.jsx(index$3, Object.assign({ minHeight: "100%", bgcolor: "background.primary", color: "text.primary", fontSize: "text", fontWeight: "text", lineHeight: "text", fontFamily: `system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif` }, props, { sxr: {
|
|
147
152
|
"& a": {
|
|
148
153
|
color: "brand.primary",
|
|
149
154
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeProvider.cjs","sources":["../../src/theme/ThemeProvider.tsx"],"sourcesContent":["\"use client\";\nimport * as React from \"react\"\nimport { ThemeOptions } from \"./types\"\nimport Tag from \"../Tag\"\nimport { TagComponentType, TagProps } from \"../Tag/types\"\nimport { ThemeContex, ThemeFactory } from \"./core\"\nimport ThemeCssVars from \"./ThemeCssVars\"\nimport { css } from \"../css\"\nimport { createDefaultThemes } from \"./ThemeDefaultOptions\"\nimport ServerStyleTag from \"../Tag/ServerStyleTag\"\nimport { useDocument } from \"../Document\";\nimport { themeRootClass } from \".\";\nimport { useCSSCacheId } from \"../css/CSSCacheProvider\";\n\nexport type ThemeProviderProps<T extends TagComponentType = 'div'> = TagProps<T> & {\n theme: string;\n isRoot?: boolean;\n noScrollbarCss?: boolean;\n}\n\ncreateDefaultThemes()\n\nconst ThemeProvider = <T extends TagComponentType = 'div'>({ children, theme, isRoot, noScrollbarCss, ...props }: ThemeProviderProps<T>) => {\n let THEME = ThemeFactory.get(theme) as ThemeOptions\n if (!THEME) {\n console.error(`ThemeProvider: The theme '${theme}' is not defined. Please make sure to use a valid theme name.`)\n THEME = ThemeFactory.get(\"light\") as ThemeOptions\n }\n const doc = useDocument()\n const cacheId = useCSSCacheId()\n\n const themeGlobalStyle: any = React.useMemo(() => {\n const root_cls = `.xui-${theme}-theme-root`\n let gkeys = Object.keys(THEME.globalStyle || {})\n let gstyles: any = {}\n gkeys.forEach((key) => {\n gstyles[`${root_cls} ${key}`] = THEME.globalStyle[key as any]\n })\n\n return css({\n \"@global\": {\n ...gstyles,\n [root_cls]: ThemeCssVars(THEME)\n }\n }, {\n injectStyle: typeof window !== 'undefined',\n container: doc?.document,\n cacheId\n })\n }, [theme, doc])\n\n const resetCss = React.useMemo(() => {\n if (!isRoot) return\n return css({\n \"@global\": {\n \"*\": {\n m: 0,\n p: 0,\n outline: \"none\",\n boxSizing: \"border-box\",\n verticalAlign: \"baseline\",\n },\n \"html, body\": {\n height: \"100%\",\n \"-webkit-font-smoothing\": \"antialiased\",\n \"-moz-osx-font-smoothing\": \"grayscale\",\n } as any,\n \"img, picture, video, canvas, svg\": {\n maxWidth: \"100%\",\n display: \"block\"\n },\n \"input, button, textarea, select\": {\n font: \"inherit\"\n },\n \"table\": {\n borderCollapse: \"collapse\",\n borderSpacing: 0,\n },\n \"ol, ul\": {\n listStyle: \"none\",\n padding: 0,\n margin: 0,\n },\n \"a\": {\n display: \"inline-block\",\n color: \"inherit\",\n textDecoration: \"none\",\n cursor: \"pointer\",\n \"&:hover\": {\n textDecoration: \"underline\"\n }\n },\n \"p, h1, h2, h3, h4, h5, h6\": {\n overflowWrap: \"break-word\",\n },\n }\n }, {\n injectStyle: typeof window !== 'undefined',\n container: doc?.document,\n cacheId\n })\n }, [])\n\n const scrollbarCss: any = React.useMemo(() => {\n if (noScrollbarCss) return;\n const cls = (cls: string) => `${themeRootClass(theme)} ${cls}`\n let thumbSize = 6\n let thumbColor = \"var(--color-text-secondary)\"\n let trackColor = \"transparent\"\n\n return css({\n \"@global\": {\n [cls('*::-webkit-scrollbar')]: {\n width: thumbSize,\n height: thumbSize,\n },\n [cls(\"*::-webkit-scrollbar-thumb\")]: {\n backgroundColor: thumbColor,\n borderRadius: \"6px\",\n opacity: 0.6,\n },\n [cls(\"*::-webkit-scrollbar-thumb:hover\")]: {\n backgroundColor: thumbColor,\n opacity: 0.0,\n },\n [cls(\"*::-webkit-scrollbar-track\")]: {\n backgroundColor: trackColor,\n borderRadius: \"6px\",\n },\n }\n }, {\n injectStyle: typeof window !== 'undefined',\n container: doc?.document,\n cacheId\n }) as any\n }, [noScrollbarCss, theme])\n\n return (\n <ThemeContex.Provider value={theme}>\n {\n isRoot && <>\n <ServerStyleTag factory={resetCss as any} />\n {\n !noScrollbarCss && <ServerStyleTag factory={scrollbarCss} />\n }\n </>\n }\n <ServerStyleTag factory={themeGlobalStyle} />\n <Tag\n minHeight=\"100%\"\n bgcolor=\"background.primary\"\n color=\"text.primary\"\n fontSize=\"text\"\n fontWeight=\"text\"\n lineHeight=\"text\"\n fontFamily={`system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif`}\n {...props}\n sxr={{\n \"& a\": {\n color: \"brand.primary\",\n },\n }}\n baseClass={`${theme}-theme-root`}\n direction={THEME.rtl ? \"rtl\" : \"ltr\"}\n >\n {children}\n </Tag>\n </ThemeContex.Provider>\n )\n}\n\nexport default ThemeProvider"],"names":["createDefaultThemes"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ThemeProvider.cjs","sources":["../../src/theme/ThemeProvider.tsx"],"sourcesContent":["\"use client\";\nimport * as React from \"react\"\nimport { ThemeOptions } from \"./types\"\nimport Tag from \"../Tag\"\nimport { TagComponentType, TagProps } from \"../Tag/types\"\nimport { ThemeContex, ThemeFactory } from \"./core\"\nimport ThemeCssVars from \"./ThemeCssVars\"\nimport { css } from \"../css\"\nimport { createDefaultThemes } from \"./ThemeDefaultOptions\"\nimport ServerStyleTag from \"../Tag/ServerStyleTag\"\nimport { useDocument } from \"../Document\";\nimport { themeRootClass } from \".\";\nimport { useCSSCacheId } from \"../css/CSSCacheProvider\";\n\nexport type ThemeProviderProps<T extends TagComponentType = 'div'> = TagProps<T> & {\n theme: string;\n onThemeChange?: (theme: string) => void\n isRoot?: boolean;\n noScrollbarCss?: boolean;\n}\n\ncreateDefaultThemes()\n\nconst ThemeProvider = <T extends TagComponentType = 'div'>({ children, theme, onThemeChange, isRoot, noScrollbarCss, ...props }: ThemeProviderProps<T>) => {\n let THEME = ThemeFactory.get(theme) as ThemeOptions\n if (!THEME) {\n console.error(`ThemeProvider: The theme '${theme}' is not defined. Please make sure to use a valid theme name.`)\n THEME = ThemeFactory.get(\"light\") as ThemeOptions\n }\n const doc = useDocument()\n const cacheId = useCSSCacheId()\n\n const themeGlobalStyle: any = React.useMemo(() => {\n const root_cls = `.xui-${theme}-theme-root`\n let gkeys = Object.keys(THEME.globalStyle || {})\n let gstyles: any = {}\n gkeys.forEach((key) => {\n gstyles[`${root_cls} ${key}`] = THEME.globalStyle[key as any]\n })\n\n return css({\n \"@global\": {\n ...gstyles,\n [root_cls]: ThemeCssVars(THEME)\n }\n }, {\n injectStyle: typeof window !== 'undefined',\n container: doc?.document,\n cacheId\n })\n }, [theme, doc])\n\n const resetCss = React.useMemo(() => {\n if (!isRoot) return\n return css({\n \"@global\": {\n \"*\": {\n m: 0,\n p: 0,\n outline: \"none\",\n boxSizing: \"border-box\",\n verticalAlign: \"baseline\",\n },\n \"html, body\": {\n height: \"100%\",\n \"-webkit-font-smoothing\": \"antialiased\",\n \"-moz-osx-font-smoothing\": \"grayscale\",\n } as any,\n \"img, picture, video, canvas, svg\": {\n maxWidth: \"100%\",\n display: \"block\"\n },\n \"input, button, textarea, select\": {\n font: \"inherit\"\n },\n \"table\": {\n borderCollapse: \"collapse\",\n borderSpacing: 0,\n },\n \"ol, ul\": {\n listStyle: \"none\",\n padding: 0,\n margin: 0,\n },\n \"a\": {\n display: \"inline-block\",\n color: \"inherit\",\n textDecoration: \"none\",\n cursor: \"pointer\",\n \"&:hover\": {\n textDecoration: \"underline\"\n }\n },\n \"p, h1, h2, h3, h4, h5, h6\": {\n overflowWrap: \"break-word\",\n },\n }\n }, {\n injectStyle: typeof window !== 'undefined',\n container: doc?.document,\n cacheId\n })\n }, [])\n\n const scrollbarCss: any = React.useMemo(() => {\n if (noScrollbarCss) return;\n const cls = (cls: string) => `${themeRootClass(theme)} ${cls}`\n let thumbSize = 6\n let thumbColor = \"var(--color-text-secondary)\"\n let trackColor = \"transparent\"\n\n return css({\n \"@global\": {\n [cls('*::-webkit-scrollbar')]: {\n width: thumbSize,\n height: thumbSize,\n },\n [cls(\"*::-webkit-scrollbar-thumb\")]: {\n backgroundColor: thumbColor,\n borderRadius: \"6px\",\n opacity: 0.6,\n },\n [cls(\"*::-webkit-scrollbar-thumb:hover\")]: {\n backgroundColor: thumbColor,\n opacity: 0.0,\n },\n [cls(\"*::-webkit-scrollbar-track\")]: {\n backgroundColor: trackColor,\n borderRadius: \"6px\",\n },\n }\n }, {\n injectStyle: typeof window !== 'undefined',\n container: doc?.document,\n cacheId\n }) as any\n }, [noScrollbarCss, theme])\n\n return (\n <ThemeContex.Provider value={{\n theme,\n onChange: (t) => {\n onThemeChange && onThemeChange(t)\n }\n }}>\n {\n isRoot && <>\n <ServerStyleTag factory={resetCss as any} />\n {\n !noScrollbarCss && <ServerStyleTag factory={scrollbarCss} />\n }\n </>\n }\n <ServerStyleTag factory={themeGlobalStyle} />\n <Tag\n minHeight=\"100%\"\n bgcolor=\"background.primary\"\n color=\"text.primary\"\n fontSize=\"text\"\n fontWeight=\"text\"\n lineHeight=\"text\"\n fontFamily={`system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif`}\n {...props}\n sxr={{\n \"& a\": {\n color: \"brand.primary\",\n },\n }}\n baseClass={`${theme}-theme-root`}\n direction={THEME.rtl ? \"rtl\" : \"ltr\"}\n >\n {children}\n </Tag>\n </ThemeContex.Provider>\n )\n}\n\nexport default ThemeProvider"],"names":["createDefaultThemes"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBAA;AAEA;AAA2D;;;AAGrD;AACA;;AAEH;AACA;AAEA;AACG;AACA;;AAEA;AACG;AACH;AAEA;;;AAMG;AACA;;AAEF;AACJ;AAEA;AACG;;AACA;AACG;AACG;AACG;AACA;AACA;AACA;AACA;AACF;AACD;AACG;AACA;AACA;AACK;AACR;AACG;AACA;AACF;AACD;AACG;AACF;AACD;AACG;AACA;AACF;AACD;AACG;AACA;AACA;AACF;AACD;AACG;AACA;AACA;AACA;AACA;AACG;AACF;AACH;AACD;AACG;AACF;AACH;;AAED;AACA;;AAEF;;AAGJ;AACG;;AACA;;;;AAKA;AACG;AACG;AACG;AACA;AACF;AACD;AACG;AACA;AACA;AACF;AACD;AACG;AACA;AACF;AACD;AACG;AACA;AACF;AACH;;AAED;AACA;;AAEF;AACJ;AAEA;;AAGM;AACG;;AAEL;AAoBQ;AACG;AACF;;AAShB;;"}
|
package/theme/ThemeProvider.d.ts
CHANGED
|
@@ -3,10 +3,11 @@ import { TagComponentType, TagProps } from '../Tag/types.js';
|
|
|
3
3
|
|
|
4
4
|
type ThemeProviderProps<T extends TagComponentType = 'div'> = TagProps<T> & {
|
|
5
5
|
theme: string;
|
|
6
|
+
onThemeChange?: (theme: string) => void;
|
|
6
7
|
isRoot?: boolean;
|
|
7
8
|
noScrollbarCss?: boolean;
|
|
8
9
|
};
|
|
9
|
-
declare const ThemeProvider: <T extends TagComponentType = "div">({ children, theme, isRoot, noScrollbarCss, ...props }: ThemeProviderProps<T>) => React.JSX.Element;
|
|
10
|
+
declare const ThemeProvider: <T extends TagComponentType = "div">({ children, theme, onThemeChange, isRoot, noScrollbarCss, ...props }: ThemeProviderProps<T>) => React.JSX.Element;
|
|
10
11
|
|
|
11
12
|
export { ThemeProvider as default };
|
|
12
13
|
export type { ThemeProviderProps };
|
package/theme/ThemeProvider.js
CHANGED
|
@@ -14,7 +14,7 @@ import { useCSSCacheId } from '../css/CSSCacheProvider.js';
|
|
|
14
14
|
|
|
15
15
|
createDefaultThemes();
|
|
16
16
|
const ThemeProvider = (_a) => {
|
|
17
|
-
var { children, theme, isRoot, noScrollbarCss } = _a, props = __rest(_a, ["children", "theme", "isRoot", "noScrollbarCss"]);
|
|
17
|
+
var { children, theme, onThemeChange, isRoot, noScrollbarCss } = _a, props = __rest(_a, ["children", "theme", "onThemeChange", "isRoot", "noScrollbarCss"]);
|
|
18
18
|
let THEME = ThemeFactory.get(theme);
|
|
19
19
|
if (!THEME) {
|
|
20
20
|
console.error(`ThemeProvider: The theme '${theme}' is not defined. Please make sure to use a valid theme name.`);
|
|
@@ -122,7 +122,12 @@ const ThemeProvider = (_a) => {
|
|
|
122
122
|
cacheId
|
|
123
123
|
});
|
|
124
124
|
}, [noScrollbarCss, theme]);
|
|
125
|
-
return (jsxs(ThemeContex.Provider, { value:
|
|
125
|
+
return (jsxs(ThemeContex.Provider, { value: {
|
|
126
|
+
theme,
|
|
127
|
+
onChange: (t) => {
|
|
128
|
+
onThemeChange && onThemeChange(t);
|
|
129
|
+
}
|
|
130
|
+
}, children: [isRoot && jsxs(Fragment, { children: [jsx(ServerStyleTag, { factory: resetCss }), !noScrollbarCss && jsx(ServerStyleTag, { factory: scrollbarCss })] }), jsx(ServerStyleTag, { factory: themeGlobalStyle }), jsx(Tag, Object.assign({ minHeight: "100%", bgcolor: "background.primary", color: "text.primary", fontSize: "text", fontWeight: "text", lineHeight: "text", fontFamily: `system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif` }, props, { sxr: {
|
|
126
131
|
"& a": {
|
|
127
132
|
color: "brand.primary",
|
|
128
133
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeProvider.js","sources":["../../src/theme/ThemeProvider.tsx"],"sourcesContent":["\"use client\";\nimport * as React from \"react\"\nimport { ThemeOptions } from \"./types\"\nimport Tag from \"../Tag\"\nimport { TagComponentType, TagProps } from \"../Tag/types\"\nimport { ThemeContex, ThemeFactory } from \"./core\"\nimport ThemeCssVars from \"./ThemeCssVars\"\nimport { css } from \"../css\"\nimport { createDefaultThemes } from \"./ThemeDefaultOptions\"\nimport ServerStyleTag from \"../Tag/ServerStyleTag\"\nimport { useDocument } from \"../Document\";\nimport { themeRootClass } from \".\";\nimport { useCSSCacheId } from \"../css/CSSCacheProvider\";\n\nexport type ThemeProviderProps<T extends TagComponentType = 'div'> = TagProps<T> & {\n theme: string;\n isRoot?: boolean;\n noScrollbarCss?: boolean;\n}\n\ncreateDefaultThemes()\n\nconst ThemeProvider = <T extends TagComponentType = 'div'>({ children, theme, isRoot, noScrollbarCss, ...props }: ThemeProviderProps<T>) => {\n let THEME = ThemeFactory.get(theme) as ThemeOptions\n if (!THEME) {\n console.error(`ThemeProvider: The theme '${theme}' is not defined. Please make sure to use a valid theme name.`)\n THEME = ThemeFactory.get(\"light\") as ThemeOptions\n }\n const doc = useDocument()\n const cacheId = useCSSCacheId()\n\n const themeGlobalStyle: any = React.useMemo(() => {\n const root_cls = `.xui-${theme}-theme-root`\n let gkeys = Object.keys(THEME.globalStyle || {})\n let gstyles: any = {}\n gkeys.forEach((key) => {\n gstyles[`${root_cls} ${key}`] = THEME.globalStyle[key as any]\n })\n\n return css({\n \"@global\": {\n ...gstyles,\n [root_cls]: ThemeCssVars(THEME)\n }\n }, {\n injectStyle: typeof window !== 'undefined',\n container: doc?.document,\n cacheId\n })\n }, [theme, doc])\n\n const resetCss = React.useMemo(() => {\n if (!isRoot) return\n return css({\n \"@global\": {\n \"*\": {\n m: 0,\n p: 0,\n outline: \"none\",\n boxSizing: \"border-box\",\n verticalAlign: \"baseline\",\n },\n \"html, body\": {\n height: \"100%\",\n \"-webkit-font-smoothing\": \"antialiased\",\n \"-moz-osx-font-smoothing\": \"grayscale\",\n } as any,\n \"img, picture, video, canvas, svg\": {\n maxWidth: \"100%\",\n display: \"block\"\n },\n \"input, button, textarea, select\": {\n font: \"inherit\"\n },\n \"table\": {\n borderCollapse: \"collapse\",\n borderSpacing: 0,\n },\n \"ol, ul\": {\n listStyle: \"none\",\n padding: 0,\n margin: 0,\n },\n \"a\": {\n display: \"inline-block\",\n color: \"inherit\",\n textDecoration: \"none\",\n cursor: \"pointer\",\n \"&:hover\": {\n textDecoration: \"underline\"\n }\n },\n \"p, h1, h2, h3, h4, h5, h6\": {\n overflowWrap: \"break-word\",\n },\n }\n }, {\n injectStyle: typeof window !== 'undefined',\n container: doc?.document,\n cacheId\n })\n }, [])\n\n const scrollbarCss: any = React.useMemo(() => {\n if (noScrollbarCss) return;\n const cls = (cls: string) => `${themeRootClass(theme)} ${cls}`\n let thumbSize = 6\n let thumbColor = \"var(--color-text-secondary)\"\n let trackColor = \"transparent\"\n\n return css({\n \"@global\": {\n [cls('*::-webkit-scrollbar')]: {\n width: thumbSize,\n height: thumbSize,\n },\n [cls(\"*::-webkit-scrollbar-thumb\")]: {\n backgroundColor: thumbColor,\n borderRadius: \"6px\",\n opacity: 0.6,\n },\n [cls(\"*::-webkit-scrollbar-thumb:hover\")]: {\n backgroundColor: thumbColor,\n opacity: 0.0,\n },\n [cls(\"*::-webkit-scrollbar-track\")]: {\n backgroundColor: trackColor,\n borderRadius: \"6px\",\n },\n }\n }, {\n injectStyle: typeof window !== 'undefined',\n container: doc?.document,\n cacheId\n }) as any\n }, [noScrollbarCss, theme])\n\n return (\n <ThemeContex.Provider value={theme}>\n {\n isRoot && <>\n <ServerStyleTag factory={resetCss as any} />\n {\n !noScrollbarCss && <ServerStyleTag factory={scrollbarCss} />\n }\n </>\n }\n <ServerStyleTag factory={themeGlobalStyle} />\n <Tag\n minHeight=\"100%\"\n bgcolor=\"background.primary\"\n color=\"text.primary\"\n fontSize=\"text\"\n fontWeight=\"text\"\n lineHeight=\"text\"\n fontFamily={`system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif`}\n {...props}\n sxr={{\n \"& a\": {\n color: \"brand.primary\",\n },\n }}\n baseClass={`${theme}-theme-root`}\n direction={THEME.rtl ? \"rtl\" : \"ltr\"}\n >\n {children}\n </Tag>\n </ThemeContex.Provider>\n )\n}\n\nexport default ThemeProvider"],"names":[],"mappings":";;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ThemeProvider.js","sources":["../../src/theme/ThemeProvider.tsx"],"sourcesContent":["\"use client\";\nimport * as React from \"react\"\nimport { ThemeOptions } from \"./types\"\nimport Tag from \"../Tag\"\nimport { TagComponentType, TagProps } from \"../Tag/types\"\nimport { ThemeContex, ThemeFactory } from \"./core\"\nimport ThemeCssVars from \"./ThemeCssVars\"\nimport { css } from \"../css\"\nimport { createDefaultThemes } from \"./ThemeDefaultOptions\"\nimport ServerStyleTag from \"../Tag/ServerStyleTag\"\nimport { useDocument } from \"../Document\";\nimport { themeRootClass } from \".\";\nimport { useCSSCacheId } from \"../css/CSSCacheProvider\";\n\nexport type ThemeProviderProps<T extends TagComponentType = 'div'> = TagProps<T> & {\n theme: string;\n onThemeChange?: (theme: string) => void\n isRoot?: boolean;\n noScrollbarCss?: boolean;\n}\n\ncreateDefaultThemes()\n\nconst ThemeProvider = <T extends TagComponentType = 'div'>({ children, theme, onThemeChange, isRoot, noScrollbarCss, ...props }: ThemeProviderProps<T>) => {\n let THEME = ThemeFactory.get(theme) as ThemeOptions\n if (!THEME) {\n console.error(`ThemeProvider: The theme '${theme}' is not defined. Please make sure to use a valid theme name.`)\n THEME = ThemeFactory.get(\"light\") as ThemeOptions\n }\n const doc = useDocument()\n const cacheId = useCSSCacheId()\n\n const themeGlobalStyle: any = React.useMemo(() => {\n const root_cls = `.xui-${theme}-theme-root`\n let gkeys = Object.keys(THEME.globalStyle || {})\n let gstyles: any = {}\n gkeys.forEach((key) => {\n gstyles[`${root_cls} ${key}`] = THEME.globalStyle[key as any]\n })\n\n return css({\n \"@global\": {\n ...gstyles,\n [root_cls]: ThemeCssVars(THEME)\n }\n }, {\n injectStyle: typeof window !== 'undefined',\n container: doc?.document,\n cacheId\n })\n }, [theme, doc])\n\n const resetCss = React.useMemo(() => {\n if (!isRoot) return\n return css({\n \"@global\": {\n \"*\": {\n m: 0,\n p: 0,\n outline: \"none\",\n boxSizing: \"border-box\",\n verticalAlign: \"baseline\",\n },\n \"html, body\": {\n height: \"100%\",\n \"-webkit-font-smoothing\": \"antialiased\",\n \"-moz-osx-font-smoothing\": \"grayscale\",\n } as any,\n \"img, picture, video, canvas, svg\": {\n maxWidth: \"100%\",\n display: \"block\"\n },\n \"input, button, textarea, select\": {\n font: \"inherit\"\n },\n \"table\": {\n borderCollapse: \"collapse\",\n borderSpacing: 0,\n },\n \"ol, ul\": {\n listStyle: \"none\",\n padding: 0,\n margin: 0,\n },\n \"a\": {\n display: \"inline-block\",\n color: \"inherit\",\n textDecoration: \"none\",\n cursor: \"pointer\",\n \"&:hover\": {\n textDecoration: \"underline\"\n }\n },\n \"p, h1, h2, h3, h4, h5, h6\": {\n overflowWrap: \"break-word\",\n },\n }\n }, {\n injectStyle: typeof window !== 'undefined',\n container: doc?.document,\n cacheId\n })\n }, [])\n\n const scrollbarCss: any = React.useMemo(() => {\n if (noScrollbarCss) return;\n const cls = (cls: string) => `${themeRootClass(theme)} ${cls}`\n let thumbSize = 6\n let thumbColor = \"var(--color-text-secondary)\"\n let trackColor = \"transparent\"\n\n return css({\n \"@global\": {\n [cls('*::-webkit-scrollbar')]: {\n width: thumbSize,\n height: thumbSize,\n },\n [cls(\"*::-webkit-scrollbar-thumb\")]: {\n backgroundColor: thumbColor,\n borderRadius: \"6px\",\n opacity: 0.6,\n },\n [cls(\"*::-webkit-scrollbar-thumb:hover\")]: {\n backgroundColor: thumbColor,\n opacity: 0.0,\n },\n [cls(\"*::-webkit-scrollbar-track\")]: {\n backgroundColor: trackColor,\n borderRadius: \"6px\",\n },\n }\n }, {\n injectStyle: typeof window !== 'undefined',\n container: doc?.document,\n cacheId\n }) as any\n }, [noScrollbarCss, theme])\n\n return (\n <ThemeContex.Provider value={{\n theme,\n onChange: (t) => {\n onThemeChange && onThemeChange(t)\n }\n }}>\n {\n isRoot && <>\n <ServerStyleTag factory={resetCss as any} />\n {\n !noScrollbarCss && <ServerStyleTag factory={scrollbarCss} />\n }\n </>\n }\n <ServerStyleTag factory={themeGlobalStyle} />\n <Tag\n minHeight=\"100%\"\n bgcolor=\"background.primary\"\n color=\"text.primary\"\n fontSize=\"text\"\n fontWeight=\"text\"\n lineHeight=\"text\"\n fontFamily={`system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif`}\n {...props}\n sxr={{\n \"& a\": {\n color: \"brand.primary\",\n },\n }}\n baseClass={`${theme}-theme-root`}\n direction={THEME.rtl ? \"rtl\" : \"ltr\"}\n >\n {children}\n </Tag>\n </ThemeContex.Provider>\n )\n}\n\nexport default ThemeProvider"],"names":[],"mappings":";;;;;;;;;;;;;;AAqBA;AAEA;AAA2D;;;AAGrD;AACA;;AAEH;AACA;AAEA;AACG;AACA;;AAEA;AACG;AACH;AAEA;;;AAMG;AACA;;AAEF;AACJ;AAEA;AACG;;AACA;AACG;AACG;AACG;AACA;AACA;AACA;AACA;AACF;AACD;AACG;AACA;AACA;AACK;AACR;AACG;AACA;AACF;AACD;AACG;AACF;AACD;AACG;AACA;AACF;AACD;AACG;AACA;AACA;AACF;AACD;AACG;AACA;AACA;AACA;AACA;AACG;AACF;AACH;AACD;AACG;AACF;AACH;;AAED;AACA;;AAEF;;AAGJ;AACG;;AACA;;;;AAKA;AACG;AACG;AACG;AACA;AACF;AACD;AACG;AACA;AACA;AACF;AACD;AACG;AACA;AACF;AACD;AACG;AACA;AACF;AACH;;AAED;AACA;;AAEF;AACJ;AAEA;;AAGM;AACG;;AAEL;AAoBQ;AACG;AACF;;AAShB;;"}
|
package/theme/core.cjs
CHANGED
|
@@ -3,14 +3,21 @@
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
|
|
5
5
|
const ThemeFactory = new Map();
|
|
6
|
-
const ThemeContex = React.createContext(
|
|
6
|
+
const ThemeContex = React.createContext({
|
|
7
|
+
theme: "light",
|
|
8
|
+
onChange: () => { }
|
|
9
|
+
});
|
|
7
10
|
const getTheme = (theme) => ThemeFactory.get(theme);
|
|
8
11
|
const useTheme = () => {
|
|
9
|
-
const
|
|
12
|
+
const ctx = React.useContext(ThemeContex);
|
|
13
|
+
const theme = ThemeFactory.get(ctx === null || ctx === void 0 ? void 0 : ctx.theme);
|
|
10
14
|
if (!theme) {
|
|
11
15
|
console.error("Theme not found, returning light theme as fallback");
|
|
12
16
|
return ThemeFactory.get("light");
|
|
13
17
|
}
|
|
18
|
+
theme.change = (theme) => {
|
|
19
|
+
ctx.onChange(theme);
|
|
20
|
+
};
|
|
14
21
|
return theme;
|
|
15
22
|
};
|
|
16
23
|
const mergeObject = (a, b) => {
|
package/theme/core.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.cjs","sources":["../../src/theme/core.ts"],"sourcesContent":["import React from \"react\"\nimport { ObjectType, ThemeOptions } from \"./types\"\n\nexport const ThemeFactory = new Map<string, ThemeOptions>()\nexport const ThemeContex = React.createContext(\"light\")\nexport const getTheme = (theme: string) => ThemeFactory.get(theme)\nexport const useTheme = ():
|
|
1
|
+
{"version":3,"file":"core.cjs","sources":["../../src/theme/core.ts"],"sourcesContent":["import React, { useContext } from \"react\"\nimport { ObjectType, ThemeOptions } from \"./types\"\n\nexport type ThemeCntextProps = {\n theme: string,\n onChange: (theme: string) => void\n}\nexport const ThemeFactory = new Map<string, ThemeOptions>()\nexport const ThemeContex = React.createContext<ThemeCntextProps>({\n theme: \"light\",\n onChange: () => { }\n})\nexport const getTheme = (theme: string) => ThemeFactory.get(theme)\n\nexport type UseThemeOptions = ThemeOptions & { change: (theme: string) => void }\nexport const useTheme = (): UseThemeOptions => {\n const ctx = useContext(ThemeContex)\n const theme = ThemeFactory.get(ctx?.theme) as any\n if (!theme) {\n console.error(\"Theme not found, returning light theme as fallback\")\n return ThemeFactory.get(\"light\") as any\n }\n\n theme.change = (theme: string) => {\n ctx.onChange(theme)\n }\n return theme as UseThemeOptions\n}\n\nexport const mergeObject = (a: ObjectType, b: ObjectType) => {\n a = { ...a }\n b = { ...b }\n for (const key in b) {\n const v = (b as any)[key]\n if (typeof v === 'object' && !Array.isArray(v) && !React.isValidElement(v)) {\n a[key] = mergeObject(a[key], b[key])\n } else {\n a[key] = v\n }\n }\n return a\n}\n"],"names":["useContext"],"mappings":";;;;AAOO,MAAM,YAAY,GAAG,IAAI,GAAG;AAC5B,MAAM,WAAW,GAAG,KAAK,CAAC,aAAa,CAAmB;AAC9D,IAAA,KAAK,EAAE,OAAO;AACd,IAAA,QAAQ,EAAE,MAAK,EAAG;AACpB,CAAA;AACM,MAAM,QAAQ,GAAG,CAAC,KAAa,KAAK,YAAY,CAAC,GAAG,CAAC,KAAK;AAG1D,MAAM,QAAQ,GAAG,MAAsB;AAC3C,IAAA,MAAM,GAAG,GAAGA,gBAAU,CAAC,WAAW,CAAC;AACnC,IAAA,MAAM,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,GAAG,KAAA,IAAA,IAAH,GAAG,KAAA,MAAA,GAAA,MAAA,GAAH,GAAG,CAAE,KAAK,CAAQ;IACjD,IAAI,CAAC,KAAK,EAAE;AACT,QAAA,OAAO,CAAC,KAAK,CAAC,oDAAoD,CAAC;AACnE,QAAA,OAAO,YAAY,CAAC,GAAG,CAAC,OAAO,CAAQ;IAC1C;AAEA,IAAA,KAAK,CAAC,MAAM,GAAG,CAAC,KAAa,KAAI;AAC9B,QAAA,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC;AACtB,IAAA,CAAC;AACD,IAAA,OAAO,KAAwB;AAClC;MAEa,WAAW,GAAG,CAAC,CAAa,EAAE,CAAa,KAAI;IACzD,CAAC,GAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAQ,CAAC,CAAE;IACZ,CAAC,GAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAQ,CAAC,CAAE;AACZ,IAAA,KAAK,MAAM,GAAG,IAAI,CAAC,EAAE;AAClB,QAAA,MAAM,CAAC,GAAI,CAAS,CAAC,GAAG,CAAC;QACzB,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE;AACzE,YAAA,CAAC,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;QACvC;aAAO;AACJ,YAAA,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;QACb;IACH;AACA,IAAA,OAAO,CAAC;AACX;;;;;;;;"}
|
package/theme/core.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { ThemeOptions } from './types.js';
|
|
2
2
|
|
|
3
3
|
declare const getTheme: (theme: string) => ThemeOptions | undefined;
|
|
4
|
-
|
|
4
|
+
type UseThemeOptions = ThemeOptions & {
|
|
5
|
+
change: (theme: string) => void;
|
|
6
|
+
};
|
|
7
|
+
declare const useTheme: () => UseThemeOptions;
|
|
5
8
|
|
|
6
9
|
export { getTheme, useTheme };
|
|
10
|
+
export type { UseThemeOptions };
|
package/theme/core.js
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import React__default from 'react';
|
|
1
|
+
import React__default, { useContext } from 'react';
|
|
2
2
|
|
|
3
3
|
const ThemeFactory = new Map();
|
|
4
|
-
const ThemeContex = React__default.createContext(
|
|
4
|
+
const ThemeContex = React__default.createContext({
|
|
5
|
+
theme: "light",
|
|
6
|
+
onChange: () => { }
|
|
7
|
+
});
|
|
5
8
|
const getTheme = (theme) => ThemeFactory.get(theme);
|
|
6
9
|
const useTheme = () => {
|
|
7
|
-
const
|
|
10
|
+
const ctx = useContext(ThemeContex);
|
|
11
|
+
const theme = ThemeFactory.get(ctx === null || ctx === void 0 ? void 0 : ctx.theme);
|
|
8
12
|
if (!theme) {
|
|
9
13
|
console.error("Theme not found, returning light theme as fallback");
|
|
10
14
|
return ThemeFactory.get("light");
|
|
11
15
|
}
|
|
16
|
+
theme.change = (theme) => {
|
|
17
|
+
ctx.onChange(theme);
|
|
18
|
+
};
|
|
12
19
|
return theme;
|
|
13
20
|
};
|
|
14
21
|
const mergeObject = (a, b) => {
|
package/theme/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sources":["../../src/theme/core.ts"],"sourcesContent":["import React from \"react\"\nimport { ObjectType, ThemeOptions } from \"./types\"\n\nexport const ThemeFactory = new Map<string, ThemeOptions>()\nexport const ThemeContex = React.createContext(\"light\")\nexport const getTheme = (theme: string) => ThemeFactory.get(theme)\nexport const useTheme = ():
|
|
1
|
+
{"version":3,"file":"core.js","sources":["../../src/theme/core.ts"],"sourcesContent":["import React, { useContext } from \"react\"\nimport { ObjectType, ThemeOptions } from \"./types\"\n\nexport type ThemeCntextProps = {\n theme: string,\n onChange: (theme: string) => void\n}\nexport const ThemeFactory = new Map<string, ThemeOptions>()\nexport const ThemeContex = React.createContext<ThemeCntextProps>({\n theme: \"light\",\n onChange: () => { }\n})\nexport const getTheme = (theme: string) => ThemeFactory.get(theme)\n\nexport type UseThemeOptions = ThemeOptions & { change: (theme: string) => void }\nexport const useTheme = (): UseThemeOptions => {\n const ctx = useContext(ThemeContex)\n const theme = ThemeFactory.get(ctx?.theme) as any\n if (!theme) {\n console.error(\"Theme not found, returning light theme as fallback\")\n return ThemeFactory.get(\"light\") as any\n }\n\n theme.change = (theme: string) => {\n ctx.onChange(theme)\n }\n return theme as UseThemeOptions\n}\n\nexport const mergeObject = (a: ObjectType, b: ObjectType) => {\n a = { ...a }\n b = { ...b }\n for (const key in b) {\n const v = (b as any)[key]\n if (typeof v === 'object' && !Array.isArray(v) && !React.isValidElement(v)) {\n a[key] = mergeObject(a[key], b[key])\n } else {\n a[key] = v\n }\n }\n return a\n}\n"],"names":["React"],"mappings":";;AAOO,MAAM,YAAY,GAAG,IAAI,GAAG;AAC5B,MAAM,WAAW,GAAGA,cAAK,CAAC,aAAa,CAAmB;AAC9D,IAAA,KAAK,EAAE,OAAO;AACd,IAAA,QAAQ,EAAE,MAAK,EAAG;AACpB,CAAA;AACM,MAAM,QAAQ,GAAG,CAAC,KAAa,KAAK,YAAY,CAAC,GAAG,CAAC,KAAK;AAG1D,MAAM,QAAQ,GAAG,MAAsB;AAC3C,IAAA,MAAM,GAAG,GAAG,UAAU,CAAC,WAAW,CAAC;AACnC,IAAA,MAAM,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,GAAG,KAAA,IAAA,IAAH,GAAG,KAAA,MAAA,GAAA,MAAA,GAAH,GAAG,CAAE,KAAK,CAAQ;IACjD,IAAI,CAAC,KAAK,EAAE;AACT,QAAA,OAAO,CAAC,KAAK,CAAC,oDAAoD,CAAC;AACnE,QAAA,OAAO,YAAY,CAAC,GAAG,CAAC,OAAO,CAAQ;IAC1C;AAEA,IAAA,KAAK,CAAC,MAAM,GAAG,CAAC,KAAa,KAAI;AAC9B,QAAA,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC;AACtB,IAAA,CAAC;AACD,IAAA,OAAO,KAAwB;AAClC;MAEa,WAAW,GAAG,CAAC,CAAa,EAAE,CAAa,KAAI;IACzD,CAAC,GAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAQ,CAAC,CAAE;IACZ,CAAC,GAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAQ,CAAC,CAAE;AACZ,IAAA,KAAK,MAAM,GAAG,IAAI,CAAC,EAAE;AAClB,QAAA,MAAM,CAAC,GAAI,CAAS,CAAC,GAAG,CAAC;QACzB,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAACA,cAAK,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE;AACzE,YAAA,CAAC,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;QACvC;aAAO;AACJ,YAAA,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;QACb;IACH;AACA,IAAA,OAAO,CAAC;AACX;;;;"}
|
package/theme/index.cjs
CHANGED
package/theme/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/theme/index.tsx"],"sourcesContent":["import { createTheme } from \"./createTheme\"\nimport ThemeProvider from './ThemeProvider'\nimport
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/theme/index.tsx"],"sourcesContent":["import { createTheme } from \"./createTheme\"\nimport ThemeProvider from './ThemeProvider'\nimport { getTheme, useTheme } from './core'\nimport { lightThemeOptions, darkThemeOptions } from './ThemeDefaultOptions'\nexport type { ThemeProviderProps } from './ThemeProvider'\n\nexport const themeRootClass = (theme: string) => `.xui-${theme}-theme-root`\n\nexport {\n ThemeProvider,\n createTheme,\n getTheme,\n useTheme,\n lightThemeOptions,\n darkThemeOptions\n}\n\n"],"names":[],"mappings":";;;;;;;AAMO,MAAM,cAAc,GAAG,CAAC,KAAa,KAAK,CAAA,KAAA,EAAQ,KAAK,CAAA,WAAA;;;;;;;"}
|
package/theme/index.js
CHANGED
package/theme/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/theme/index.tsx"],"sourcesContent":["import { createTheme } from \"./createTheme\"\nimport ThemeProvider from './ThemeProvider'\nimport
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/theme/index.tsx"],"sourcesContent":["import { createTheme } from \"./createTheme\"\nimport ThemeProvider from './ThemeProvider'\nimport { getTheme, useTheme } from './core'\nimport { lightThemeOptions, darkThemeOptions } from './ThemeDefaultOptions'\nexport type { ThemeProviderProps } from './ThemeProvider'\n\nexport const themeRootClass = (theme: string) => `.xui-${theme}-theme-root`\n\nexport {\n ThemeProvider,\n createTheme,\n getTheme,\n useTheme,\n lightThemeOptions,\n darkThemeOptions\n}\n\n"],"names":[],"mappings":";;;;;AAMO,MAAM,cAAc,GAAG,CAAC,KAAa,KAAK,CAAA,KAAA,EAAQ,KAAK,CAAA,WAAA;;;;"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
var reactStateBucket = require('react-state-bucket');
|
|
5
|
-
var core = require('./core.cjs');
|
|
6
|
-
|
|
7
|
-
const createThemeSwitcher = (defaultTheme, option) => {
|
|
8
|
-
const useThemeBucket = reactStateBucket.createBucket({ name: reactStateBucket.xv.string().default(defaultTheme) }, {
|
|
9
|
-
store: (option === null || option === void 0 ? void 0 : option.store) || "memory",
|
|
10
|
-
onChange: (_key, value) => {
|
|
11
|
-
(option === null || option === void 0 ? void 0 : option.onChange) && (option === null || option === void 0 ? void 0 : option.onChange(value));
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
const useThemeSwitcher = () => {
|
|
15
|
-
const bucket = useThemeBucket();
|
|
16
|
-
return {
|
|
17
|
-
name: bucket.state.name,
|
|
18
|
-
theme: core.getTheme(bucket.state.name),
|
|
19
|
-
change: (theme) => bucket.set('name', theme)
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
return useThemeSwitcher;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
module.exports = createThemeSwitcher;
|
|
26
|
-
//# sourceMappingURL=createThemeSwitcher.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createThemeSwitcher.cjs","sources":["../../src/theme/createThemeSwitcher.ts"],"sourcesContent":["\"use client\";\nimport { createBucket, xv } from \"react-state-bucket\"\nimport { getTheme } from \"./core\"\nimport { BucketOptions } from \"react-state-bucket\"\n\nexport type ThemeSwitcherOption = {\n store?: BucketOptions['store'],\n onChange?: (theme: string) => void\n}\n\nconst createThemeSwitcher = (defaultTheme: string, option?: ThemeSwitcherOption) => {\n\n const useThemeBucket = createBucket({ name: xv.string().default(defaultTheme) }, {\n store: option?.store || \"memory\",\n onChange: (_key, value) => {\n option?.onChange && option?.onChange(value)\n }\n })\n\n const useThemeSwitcher = () => {\n const bucket = useThemeBucket()\n return {\n name: bucket.state.name,\n theme: getTheme(bucket.state.name),\n change: (theme: string) => bucket.set('name', theme)\n }\n }\n return useThemeSwitcher\n}\n\nexport default createThemeSwitcher"],"names":[],"mappings":";;;;;;AAUA;AAEG;;AAEG;AACG;;AAEL;;AAGE;;AAEG;;AAEA;;AAEN;AACA;AACH;;"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ThemeOptions } from './types.js';
|
|
2
|
-
import { BucketOptions } from 'react-state-bucket';
|
|
3
|
-
|
|
4
|
-
type ThemeSwitcherOption = {
|
|
5
|
-
store?: BucketOptions['store'];
|
|
6
|
-
onChange?: (theme: string) => void;
|
|
7
|
-
};
|
|
8
|
-
declare const createThemeSwitcher: (defaultTheme: string, option?: ThemeSwitcherOption) => () => {
|
|
9
|
-
name: any;
|
|
10
|
-
theme: ThemeOptions | undefined;
|
|
11
|
-
change: (theme: string) => void;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export { createThemeSwitcher as default };
|
|
15
|
-
export type { ThemeSwitcherOption };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { createBucket, xv } from 'react-state-bucket';
|
|
3
|
-
import { getTheme } from './core.js';
|
|
4
|
-
|
|
5
|
-
const createThemeSwitcher = (defaultTheme, option) => {
|
|
6
|
-
const useThemeBucket = createBucket({ name: xv.string().default(defaultTheme) }, {
|
|
7
|
-
store: (option === null || option === void 0 ? void 0 : option.store) || "memory",
|
|
8
|
-
onChange: (_key, value) => {
|
|
9
|
-
(option === null || option === void 0 ? void 0 : option.onChange) && (option === null || option === void 0 ? void 0 : option.onChange(value));
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
const useThemeSwitcher = () => {
|
|
13
|
-
const bucket = useThemeBucket();
|
|
14
|
-
return {
|
|
15
|
-
name: bucket.state.name,
|
|
16
|
-
theme: getTheme(bucket.state.name),
|
|
17
|
-
change: (theme) => bucket.set('name', theme)
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
return useThemeSwitcher;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export { createThemeSwitcher as default };
|
|
24
|
-
//# sourceMappingURL=createThemeSwitcher.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createThemeSwitcher.js","sources":["../../src/theme/createThemeSwitcher.ts"],"sourcesContent":["\"use client\";\nimport { createBucket, xv } from \"react-state-bucket\"\nimport { getTheme } from \"./core\"\nimport { BucketOptions } from \"react-state-bucket\"\n\nexport type ThemeSwitcherOption = {\n store?: BucketOptions['store'],\n onChange?: (theme: string) => void\n}\n\nconst createThemeSwitcher = (defaultTheme: string, option?: ThemeSwitcherOption) => {\n\n const useThemeBucket = createBucket({ name: xv.string().default(defaultTheme) }, {\n store: option?.store || \"memory\",\n onChange: (_key, value) => {\n option?.onChange && option?.onChange(value)\n }\n })\n\n const useThemeSwitcher = () => {\n const bucket = useThemeBucket()\n return {\n name: bucket.state.name,\n theme: getTheme(bucket.state.name),\n change: (theme: string) => bucket.set('name', theme)\n }\n }\n return useThemeSwitcher\n}\n\nexport default createThemeSwitcher"],"names":[],"mappings":";;;;AAUA;AAEG;;AAEG;AACG;;AAEL;;AAGE;;AAEG;;AAEA;;AAEN;AACA;AACH;;"}
|