@xanui/core 1.2.43 → 1.2.45
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 +20 -0
- package/AppRoot/AppRootProvider.cjs.map +1 -0
- package/AppRoot/AppRootProvider.js +7 -10
- package/AppRoot/AppRootProvider.js.map +1 -1
- package/AppRoot/Renderar.cjs +89 -0
- package/AppRoot/Renderar.cjs.map +1 -0
- package/AppRoot/Renderar.d.ts +1 -0
- package/AppRoot/Renderar.js +52 -20
- package/AppRoot/Renderar.js.map +1 -1
- package/AppRoot/index.cjs +45 -0
- package/AppRoot/index.cjs.map +1 -0
- package/AppRoot/index.js +25 -24
- package/AppRoot/index.js.map +1 -1
- package/Document/index.cjs +21 -0
- package/Document/index.cjs.map +1 -0
- package/Document/index.d.ts +7 -1
- package/Document/index.js +8 -11
- package/Document/index.js.map +1 -1
- package/Iframe/index.cjs +45 -0
- package/Iframe/{index.mjs.map → index.cjs.map} +1 -1
- package/Iframe/index.js +23 -25
- package/Iframe/index.js.map +1 -1
- package/Tag/ServerStyleTag.cjs +13 -0
- package/Tag/{ServerStyleTag.mjs.map → ServerStyleTag.cjs.map} +1 -1
- package/Tag/ServerStyleTag.js +3 -5
- package/Tag/ServerStyleTag.js.map +1 -1
- package/Tag/{cssPropList.mjs → cssPropList.cjs} +4 -2
- package/Tag/cssPropList.cjs.map +1 -0
- package/Tag/cssPropList.js +1 -3
- package/Tag/cssPropList.js.map +1 -1
- package/Tag/index.cjs +40 -0
- package/Tag/{index.mjs.map → index.cjs.map} +1 -1
- package/Tag/index.js +10 -31
- package/Tag/index.js.map +1 -1
- package/Tag/{useTagProps.mjs → useTagProps.cjs} +18 -16
- package/Tag/useTagProps.cjs.map +1 -0
- package/Tag/useTagProps.js +15 -17
- package/Tag/useTagProps.js.map +1 -1
- package/Transition/index.cjs +29 -0
- package/Transition/{index.mjs.map → index.cjs.map} +1 -1
- package/Transition/index.js +13 -15
- package/Transition/index.js.map +1 -1
- package/breakpoint/BreakpointProvider.cjs +49 -0
- package/breakpoint/BreakpointProvider.cjs.map +1 -0
- package/breakpoint/BreakpointProvider.js +27 -24
- package/breakpoint/BreakpointProvider.js.map +1 -1
- package/breakpoint/useBreakpoint.cjs +24 -0
- package/breakpoint/{useBreakpoint.mjs.map → useBreakpoint.cjs.map} +1 -1
- package/breakpoint/useBreakpoint.js +7 -9
- package/breakpoint/useBreakpoint.js.map +1 -1
- package/breakpoint/{useBreakpointProps.mjs → useBreakpointProps.cjs} +8 -6
- package/breakpoint/useBreakpointProps.cjs.map +1 -0
- package/breakpoint/useBreakpointProps.js +5 -7
- package/breakpoint/useBreakpointProps.js.map +1 -1
- package/css/CSSCacheProvider.cjs +34 -0
- package/css/{CSSCacheProvider.mjs.map → CSSCacheProvider.cjs.map} +1 -1
- package/css/CSSCacheProvider.js +10 -15
- package/css/CSSCacheProvider.js.map +1 -1
- package/css/{aliases.mjs → aliases.cjs} +4 -2
- package/css/aliases.cjs.map +1 -0
- package/css/aliases.js +1 -3
- package/css/aliases.js.map +1 -1
- package/css/{getProps.mjs → getProps.cjs} +4 -2
- package/css/{getProps.mjs.map → getProps.cjs.map} +1 -1
- package/css/getProps.js +1 -3
- package/css/getProps.js.map +1 -1
- package/css/{getValue.mjs → getValue.cjs} +4 -2
- package/css/{getValue.mjs.map → getValue.cjs.map} +1 -1
- package/css/getValue.js +1 -3
- package/css/getValue.js.map +1 -1
- package/css/{index.mjs → index.cjs} +15 -7
- package/css/index.cjs.map +1 -0
- package/css/index.js +6 -14
- package/css/index.js.map +1 -1
- package/hooks/{useAnimation.mjs → useAnimation.cjs} +16 -11
- package/hooks/{useAnimation.mjs.map → useAnimation.cjs.map} +1 -1
- package/hooks/useAnimation.js +10 -15
- package/hooks/useAnimation.js.map +1 -1
- package/hooks/{useColorTemplate.mjs → useColorTemplate.cjs} +4 -2
- package/hooks/{useColorTemplate.mjs.map → useColorTemplate.cjs.map} +1 -1
- package/hooks/useColorTemplate.js +1 -3
- package/hooks/useColorTemplate.js.map +1 -1
- package/hooks/useInterface.cjs +19 -0
- package/hooks/useInterface.cjs.map +1 -0
- package/hooks/useInterface.js +7 -9
- package/hooks/useInterface.js.map +1 -1
- package/hooks/{useMergeRefs.mjs → useMergeRefs.cjs} +6 -4
- package/hooks/{useMergeRefs.mjs.map → useMergeRefs.cjs.map} +1 -1
- package/hooks/useMergeRefs.js +3 -5
- package/hooks/useMergeRefs.js.map +1 -1
- package/hooks/usePortal.cjs +69 -0
- package/hooks/usePortal.cjs.map +1 -0
- package/hooks/usePortal.js +29 -32
- package/hooks/usePortal.js.map +1 -1
- package/hooks/useTransition/{index.mjs → index.cjs} +29 -27
- package/hooks/useTransition/index.cjs.map +1 -0
- package/hooks/useTransition/index.js +26 -28
- package/hooks/useTransition/index.js.map +1 -1
- package/hooks/useTransition/{variants.mjs → variants.cjs} +17 -2
- package/hooks/useTransition/{variants.mjs.map → variants.cjs.map} +1 -1
- package/hooks/useTransition/variants.js +1 -16
- package/hooks/useTransition/variants.js.map +1 -1
- package/index.cjs +64 -0
- package/index.cjs.map +1 -0
- package/index.js +25 -63
- package/index.js.map +1 -1
- package/package.json +4 -11
- package/theme/{ThemeCssVars.mjs → ThemeCssVars.cjs} +4 -2
- package/theme/{ThemeCssVars.mjs.map → ThemeCssVars.cjs.map} +1 -1
- package/theme/ThemeCssVars.js +1 -3
- package/theme/ThemeCssVars.js.map +1 -1
- package/theme/{ThemeDefaultOptions.mjs → ThemeDefaultOptions.cjs} +11 -5
- package/theme/{ThemeDefaultOptions.mjs.map → ThemeDefaultOptions.cjs.map} +1 -1
- package/theme/ThemeDefaultOptions.js +4 -10
- package/theme/ThemeDefaultOptions.js.map +1 -1
- package/theme/{ThemeProvider.mjs → ThemeProvider.cjs} +52 -31
- package/theme/ThemeProvider.cjs.map +1 -0
- package/theme/ThemeProvider.js +30 -51
- package/theme/ThemeProvider.js.map +1 -1
- package/theme/{core.mjs → core.cjs} +12 -6
- package/theme/core.cjs.map +1 -0
- package/theme/core.js +5 -11
- package/theme/core.js.map +1 -1
- package/theme/createTheme.cjs +27 -0
- package/theme/{createTheme.mjs.map → createTheme.cjs.map} +1 -1
- package/theme/createTheme.js +10 -12
- package/theme/createTheme.js.map +1 -1
- package/theme/{createThemeSwitcher.mjs → createThemeSwitcher.cjs} +8 -6
- package/theme/{createThemeSwitcher.mjs.map → createThemeSwitcher.cjs.map} +1 -1
- package/theme/createThemeSwitcher.js +5 -7
- package/theme/createThemeSwitcher.js.map +1 -1
- package/theme/index.cjs +15 -0
- package/theme/{index.mjs.map → index.cjs.map} +1 -1
- package/theme/index.js +6 -11
- package/theme/index.js.map +1 -1
- package/AppRoot/AppRootProvider.mjs +0 -17
- package/AppRoot/AppRootProvider.mjs.map +0 -1
- package/AppRoot/Renderar.mjs +0 -51
- package/AppRoot/Renderar.mjs.map +0 -1
- package/AppRoot/index.mjs +0 -40
- package/AppRoot/index.mjs.map +0 -1
- package/Document/index.mjs +0 -18
- package/Document/index.mjs.map +0 -1
- package/Iframe/index.mjs +0 -43
- package/Tag/ServerStyleTag.mjs +0 -11
- package/Tag/cssPropList.mjs.map +0 -1
- package/Tag/index.mjs +0 -19
- package/Tag/useTagProps.mjs.map +0 -1
- package/Transition/index.mjs +0 -27
- package/breakpoint/BreakpointProvider.mjs +0 -40
- package/breakpoint/BreakpointProvider.mjs.map +0 -1
- package/breakpoint/useBreakpoint.mjs +0 -22
- package/breakpoint/useBreakpointProps.mjs.map +0 -1
- package/css/CSSCacheProvider.mjs +0 -29
- package/css/aliases.mjs.map +0 -1
- package/css/index.mjs.map +0 -1
- package/hooks/useInterface.mjs +0 -17
- package/hooks/useInterface.mjs.map +0 -1
- package/hooks/usePortal.mjs +0 -68
- package/hooks/usePortal.mjs.map +0 -1
- package/hooks/useTransition/index.mjs.map +0 -1
- package/index.mjs +0 -26
- package/index.mjs.map +0 -1
- package/theme/ThemeProvider.mjs.map +0 -1
- package/theme/core.mjs.map +0 -1
- package/theme/createTheme.mjs +0 -25
- package/theme/index.mjs +0 -10
|
@@ -1,46 +1,67 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
4
|
-
import * as React from 'react';
|
|
5
|
-
import Tag from '../Tag/index.mjs';
|
|
6
|
-
import { ThemeFactory, ThemeContex } from './core.mjs';
|
|
7
|
-
import ThemeCssVars from './ThemeCssVars.mjs';
|
|
8
|
-
import { css } from '../css/index.mjs';
|
|
9
|
-
import { createDefaultThemes } from './ThemeDefaultOptions.mjs';
|
|
10
|
-
import ServerStyleTag from '../Tag/ServerStyleTag.mjs';
|
|
11
|
-
import { useDocument } from '../Document/index.mjs';
|
|
12
|
-
import { themeRootClass } from './index.mjs';
|
|
13
|
-
import { useCSSCacheId } from '../css/CSSCacheProvider.mjs';
|
|
2
|
+
'use strict';
|
|
14
3
|
|
|
15
|
-
|
|
4
|
+
var tslib = require('tslib');
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var index$3 = require('../Tag/index.cjs');
|
|
8
|
+
var core = require('./core.cjs');
|
|
9
|
+
var ThemeCssVars = require('./ThemeCssVars.cjs');
|
|
10
|
+
var index$1 = require('../css/index.cjs');
|
|
11
|
+
var ThemeDefaultOptions = require('./ThemeDefaultOptions.cjs');
|
|
12
|
+
var ServerStyleTag = require('../Tag/ServerStyleTag.cjs');
|
|
13
|
+
var index = require('../Document/index.cjs');
|
|
14
|
+
var index$2 = require('./index.cjs');
|
|
15
|
+
var CSSCacheProvider = require('../css/CSSCacheProvider.cjs');
|
|
16
|
+
|
|
17
|
+
function _interopNamespaceDefault(e) {
|
|
18
|
+
var n = Object.create(null);
|
|
19
|
+
if (e) {
|
|
20
|
+
Object.keys(e).forEach(function (k) {
|
|
21
|
+
if (k !== 'default') {
|
|
22
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
23
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return e[k]; }
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
n.default = e;
|
|
31
|
+
return Object.freeze(n);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
35
|
+
|
|
36
|
+
ThemeDefaultOptions.createDefaultThemes();
|
|
16
37
|
const ThemeProvider = (_a) => {
|
|
17
|
-
var { children, theme, isRoot, noScrollbarCss } = _a, props = __rest(_a, ["children", "theme", "isRoot", "noScrollbarCss"]);
|
|
18
|
-
let THEME = ThemeFactory.get(theme);
|
|
38
|
+
var { children, theme, isRoot, noScrollbarCss } = _a, props = tslib.__rest(_a, ["children", "theme", "isRoot", "noScrollbarCss"]);
|
|
39
|
+
let THEME = core.ThemeFactory.get(theme);
|
|
19
40
|
if (!THEME) {
|
|
20
41
|
console.error(`ThemeProvider: The theme '${theme}' is not defined. Please make sure to use a valid theme name.`);
|
|
21
|
-
THEME = ThemeFactory.get("light");
|
|
42
|
+
THEME = core.ThemeFactory.get("light");
|
|
22
43
|
}
|
|
23
|
-
const doc = useDocument();
|
|
24
|
-
const cacheId = useCSSCacheId();
|
|
25
|
-
const themeGlobalStyle =
|
|
44
|
+
const doc = index.useDocument();
|
|
45
|
+
const cacheId = CSSCacheProvider.useCSSCacheId();
|
|
46
|
+
const themeGlobalStyle = React__namespace.useMemo(() => {
|
|
26
47
|
const root_cls = `.xui-${theme}-theme-root`;
|
|
27
48
|
let gkeys = Object.keys(THEME.globalStyle || {});
|
|
28
49
|
let gstyles = {};
|
|
29
50
|
gkeys.forEach((key) => {
|
|
30
51
|
gstyles[`${root_cls} ${key}`] = THEME.globalStyle[key];
|
|
31
52
|
});
|
|
32
|
-
return css({
|
|
53
|
+
return index$1.css({
|
|
33
54
|
"@global": Object.assign(Object.assign({}, gstyles), { [root_cls]: ThemeCssVars(THEME) })
|
|
34
55
|
}, {
|
|
35
56
|
injectStyle: typeof window !== 'undefined',
|
|
36
|
-
container: doc,
|
|
57
|
+
container: doc === null || doc === void 0 ? void 0 : doc.document,
|
|
37
58
|
cacheId
|
|
38
59
|
});
|
|
39
60
|
}, [theme, doc]);
|
|
40
|
-
const resetCss =
|
|
61
|
+
const resetCss = React__namespace.useMemo(() => {
|
|
41
62
|
if (!isRoot)
|
|
42
63
|
return;
|
|
43
|
-
return css({
|
|
64
|
+
return index$1.css({
|
|
44
65
|
"@global": {
|
|
45
66
|
"*": {
|
|
46
67
|
m: 0,
|
|
@@ -85,18 +106,18 @@ const ThemeProvider = (_a) => {
|
|
|
85
106
|
}
|
|
86
107
|
}, {
|
|
87
108
|
injectStyle: typeof window !== 'undefined',
|
|
88
|
-
container: doc,
|
|
109
|
+
container: doc === null || doc === void 0 ? void 0 : doc.document,
|
|
89
110
|
cacheId
|
|
90
111
|
});
|
|
91
112
|
}, []);
|
|
92
|
-
const scrollbarCss =
|
|
113
|
+
const scrollbarCss = React__namespace.useMemo(() => {
|
|
93
114
|
if (noScrollbarCss)
|
|
94
115
|
return;
|
|
95
|
-
const cls = (cls) => `${themeRootClass(theme)} ${cls}`;
|
|
116
|
+
const cls = (cls) => `${index$2.themeRootClass(theme)} ${cls}`;
|
|
96
117
|
let thumbSize = 6;
|
|
97
118
|
let thumbColor = "var(--color-text-secondary)";
|
|
98
119
|
let trackColor = "transparent";
|
|
99
|
-
return css({
|
|
120
|
+
return index$1.css({
|
|
100
121
|
"@global": {
|
|
101
122
|
[cls('*::-webkit-scrollbar')]: {
|
|
102
123
|
width: thumbSize,
|
|
@@ -118,16 +139,16 @@ const ThemeProvider = (_a) => {
|
|
|
118
139
|
}
|
|
119
140
|
}, {
|
|
120
141
|
injectStyle: typeof window !== 'undefined',
|
|
121
|
-
container: doc,
|
|
142
|
+
container: doc === null || doc === void 0 ? void 0 : doc.document,
|
|
122
143
|
cacheId
|
|
123
144
|
});
|
|
124
145
|
}, [noScrollbarCss, theme]);
|
|
125
|
-
return (jsxs(ThemeContex.Provider, { value: theme, children: [isRoot && jsxs(Fragment, { children: [jsx(ServerStyleTag, { factory: resetCss }), !noScrollbarCss && jsx(ServerStyleTag, { factory: scrollbarCss })] }), jsx(ServerStyleTag, { factory: themeGlobalStyle }), jsx(
|
|
146
|
+
return (jsxRuntime.jsxs(core.ThemeContex.Provider, { value: theme, 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: {
|
|
126
147
|
"& a": {
|
|
127
148
|
color: "brand.primary",
|
|
128
149
|
},
|
|
129
150
|
}, baseClass: `${theme}-theme-root`, direction: THEME.rtl ? "rtl" : "ltr", children: children }))] }));
|
|
130
151
|
};
|
|
131
152
|
|
|
132
|
-
|
|
133
|
-
//# sourceMappingURL=ThemeProvider.
|
|
153
|
+
module.exports = ThemeProvider;
|
|
154
|
+
//# sourceMappingURL=ThemeProvider.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThemeProvider.cjs","sources":["../../src/theme/ThemeProvider.tsx"],"sourcesContent":["\"use client\";\r\nimport * as React from \"react\"\r\nimport { ThemeOptions } from \"./types\"\r\nimport Tag from \"../Tag\"\r\nimport { TagComponentType, TagProps } from \"../Tag/types\"\r\nimport { ThemeContex, ThemeFactory } from \"./core\"\r\nimport ThemeCssVars from \"./ThemeCssVars\"\r\nimport { css } from \"../css\"\r\nimport { createDefaultThemes } from \"./ThemeDefaultOptions\"\r\nimport ServerStyleTag from \"../Tag/ServerStyleTag\"\r\nimport { useDocument } from \"../Document\";\r\nimport { themeRootClass } from \".\";\r\nimport { useCSSCacheId } from \"../css/CSSCacheProvider\";\r\n\r\nexport type ThemeProviderProps<T extends TagComponentType = 'div'> = TagProps<T> & {\r\n theme: string;\r\n isRoot?: boolean;\r\n noScrollbarCss?: boolean;\r\n}\r\n\r\ncreateDefaultThemes()\r\n\r\nconst ThemeProvider = <T extends TagComponentType = 'div'>({ children, theme, isRoot, noScrollbarCss, ...props }: ThemeProviderProps<T>) => {\r\n let THEME = ThemeFactory.get(theme) as ThemeOptions\r\n if (!THEME) {\r\n console.error(`ThemeProvider: The theme '${theme}' is not defined. Please make sure to use a valid theme name.`)\r\n THEME = ThemeFactory.get(\"light\") as ThemeOptions\r\n }\r\n const doc = useDocument()\r\n const cacheId = useCSSCacheId()\r\n\r\n const themeGlobalStyle: any = React.useMemo(() => {\r\n const root_cls = `.xui-${theme}-theme-root`\r\n let gkeys = Object.keys(THEME.globalStyle || {})\r\n let gstyles: any = {}\r\n gkeys.forEach((key) => {\r\n gstyles[`${root_cls} ${key}`] = THEME.globalStyle[key as any]\r\n })\r\n\r\n return css({\r\n \"@global\": {\r\n ...gstyles,\r\n [root_cls]: ThemeCssVars(THEME)\r\n }\r\n }, {\r\n injectStyle: typeof window !== 'undefined',\r\n container: doc?.document,\r\n cacheId\r\n })\r\n }, [theme, doc])\r\n\r\n const resetCss = React.useMemo(() => {\r\n if (!isRoot) return\r\n return css({\r\n \"@global\": {\r\n \"*\": {\r\n m: 0,\r\n p: 0,\r\n outline: \"none\",\r\n boxSizing: \"border-box\",\r\n verticalAlign: \"baseline\",\r\n },\r\n \"html, body\": {\r\n minHeight: \"100%\",\r\n \"-webkit-font-smoothing\": \"antialiased\",\r\n \"-moz-osx-font-smoothing\": \"grayscale\",\r\n } as any,\r\n \"img, picture, video, canvas, svg\": {\r\n maxWidth: \"100%\",\r\n display: \"block\"\r\n },\r\n \"input, button, textarea, select\": {\r\n font: \"inherit\"\r\n },\r\n \"table\": {\r\n borderCollapse: \"collapse\",\r\n borderSpacing: 0,\r\n },\r\n \"ol, ul\": {\r\n listStyle: \"none\",\r\n padding: 0,\r\n margin: 0,\r\n },\r\n \"a\": {\r\n display: \"inline-block\",\r\n color: \"inherit\",\r\n textDecoration: \"none\",\r\n cursor: \"pointer\",\r\n \"&:hover\": {\r\n textDecoration: \"underline\"\r\n }\r\n },\r\n \"p, h1, h2, h3, h4, h5, h6\": {\r\n overflowWrap: \"break-word\",\r\n },\r\n }\r\n }, {\r\n injectStyle: typeof window !== 'undefined',\r\n container: doc?.document,\r\n cacheId\r\n })\r\n }, [])\r\n\r\n const scrollbarCss: any = React.useMemo(() => {\r\n if (noScrollbarCss) return;\r\n const cls = (cls: string) => `${themeRootClass(theme)} ${cls}`\r\n let thumbSize = 6\r\n let thumbColor = \"var(--color-text-secondary)\"\r\n let trackColor = \"transparent\"\r\n\r\n return css({\r\n \"@global\": {\r\n [cls('*::-webkit-scrollbar')]: {\r\n width: thumbSize,\r\n height: thumbSize,\r\n },\r\n [cls(\"*::-webkit-scrollbar-thumb\")]: {\r\n backgroundColor: thumbColor,\r\n borderRadius: \"6px\",\r\n opacity: 0.6,\r\n },\r\n [cls(\"*::-webkit-scrollbar-thumb:hover\")]: {\r\n backgroundColor: thumbColor,\r\n opacity: 0.0,\r\n },\r\n [cls(\"*::-webkit-scrollbar-track\")]: {\r\n backgroundColor: trackColor,\r\n borderRadius: \"6px\",\r\n },\r\n }\r\n }, {\r\n injectStyle: typeof window !== 'undefined',\r\n container: doc?.document,\r\n cacheId\r\n }) as any\r\n }, [noScrollbarCss, theme])\r\n\r\n return (\r\n <ThemeContex.Provider value={theme}>\r\n {\r\n isRoot && <>\r\n <ServerStyleTag factory={resetCss as any} />\r\n {\r\n !noScrollbarCss && <ServerStyleTag factory={scrollbarCss} />\r\n }\r\n </>\r\n }\r\n <ServerStyleTag factory={themeGlobalStyle} />\r\n <Tag\r\n minHeight=\"100%\"\r\n bgcolor=\"background.primary\"\r\n color=\"text.primary\"\r\n fontSize=\"text\"\r\n fontWeight=\"text\"\r\n lineHeight=\"text\"\r\n fontFamily={`system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif`}\r\n {...props}\r\n sxr={{\r\n \"& a\": {\r\n color: \"brand.primary\",\r\n },\r\n }}\r\n baseClass={`${theme}-theme-root`}\r\n direction={THEME.rtl ? \"rtl\" : \"ltr\"}\r\n >\r\n {children}\r\n </Tag>\r\n </ThemeContex.Provider>\r\n )\r\n}\r\n\r\nexport default ThemeProvider"],"names":["createDefaultThemes"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBAA;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;AAqBY;AACG;AACF;;AAShB;;"}
|
package/theme/ThemeProvider.js
CHANGED
|
@@ -1,67 +1,46 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
2
|
+
import { __rest } from 'tslib';
|
|
3
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import Tag from '../Tag/index.js';
|
|
6
|
+
import { ThemeFactory, ThemeContex } from './core.js';
|
|
7
|
+
import ThemeCssVars from './ThemeCssVars.js';
|
|
8
|
+
import { css } from '../css/index.js';
|
|
9
|
+
import { createDefaultThemes } from './ThemeDefaultOptions.js';
|
|
10
|
+
import ServerStyleTag from '../Tag/ServerStyleTag.js';
|
|
11
|
+
import { useDocument } from '../Document/index.js';
|
|
12
|
+
import { themeRootClass } from './index.js';
|
|
13
|
+
import { useCSSCacheId } from '../css/CSSCacheProvider.js';
|
|
3
14
|
|
|
4
|
-
|
|
5
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
var React = require('react');
|
|
7
|
-
var index$3 = require('../Tag/index.js');
|
|
8
|
-
var core = require('./core.js');
|
|
9
|
-
var ThemeCssVars = require('./ThemeCssVars.js');
|
|
10
|
-
var index$1 = require('../css/index.js');
|
|
11
|
-
var ThemeDefaultOptions = require('./ThemeDefaultOptions.js');
|
|
12
|
-
var ServerStyleTag = require('../Tag/ServerStyleTag.js');
|
|
13
|
-
var index = require('../Document/index.js');
|
|
14
|
-
var index$2 = require('./index.js');
|
|
15
|
-
var CSSCacheProvider = require('../css/CSSCacheProvider.js');
|
|
16
|
-
|
|
17
|
-
function _interopNamespaceDefault(e) {
|
|
18
|
-
var n = Object.create(null);
|
|
19
|
-
if (e) {
|
|
20
|
-
Object.keys(e).forEach(function (k) {
|
|
21
|
-
if (k !== 'default') {
|
|
22
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
23
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
get: function () { return e[k]; }
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
n.default = e;
|
|
31
|
-
return Object.freeze(n);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
35
|
-
|
|
36
|
-
ThemeDefaultOptions.createDefaultThemes();
|
|
15
|
+
createDefaultThemes();
|
|
37
16
|
const ThemeProvider = (_a) => {
|
|
38
|
-
var { children, theme, isRoot, noScrollbarCss } = _a, props =
|
|
39
|
-
let THEME =
|
|
17
|
+
var { children, theme, isRoot, noScrollbarCss } = _a, props = __rest(_a, ["children", "theme", "isRoot", "noScrollbarCss"]);
|
|
18
|
+
let THEME = ThemeFactory.get(theme);
|
|
40
19
|
if (!THEME) {
|
|
41
20
|
console.error(`ThemeProvider: The theme '${theme}' is not defined. Please make sure to use a valid theme name.`);
|
|
42
|
-
THEME =
|
|
21
|
+
THEME = ThemeFactory.get("light");
|
|
43
22
|
}
|
|
44
|
-
const doc =
|
|
45
|
-
const cacheId =
|
|
46
|
-
const themeGlobalStyle =
|
|
23
|
+
const doc = useDocument();
|
|
24
|
+
const cacheId = useCSSCacheId();
|
|
25
|
+
const themeGlobalStyle = React.useMemo(() => {
|
|
47
26
|
const root_cls = `.xui-${theme}-theme-root`;
|
|
48
27
|
let gkeys = Object.keys(THEME.globalStyle || {});
|
|
49
28
|
let gstyles = {};
|
|
50
29
|
gkeys.forEach((key) => {
|
|
51
30
|
gstyles[`${root_cls} ${key}`] = THEME.globalStyle[key];
|
|
52
31
|
});
|
|
53
|
-
return
|
|
32
|
+
return css({
|
|
54
33
|
"@global": Object.assign(Object.assign({}, gstyles), { [root_cls]: ThemeCssVars(THEME) })
|
|
55
34
|
}, {
|
|
56
35
|
injectStyle: typeof window !== 'undefined',
|
|
57
|
-
container: doc,
|
|
36
|
+
container: doc === null || doc === void 0 ? void 0 : doc.document,
|
|
58
37
|
cacheId
|
|
59
38
|
});
|
|
60
39
|
}, [theme, doc]);
|
|
61
|
-
const resetCss =
|
|
40
|
+
const resetCss = React.useMemo(() => {
|
|
62
41
|
if (!isRoot)
|
|
63
42
|
return;
|
|
64
|
-
return
|
|
43
|
+
return css({
|
|
65
44
|
"@global": {
|
|
66
45
|
"*": {
|
|
67
46
|
m: 0,
|
|
@@ -106,18 +85,18 @@ const ThemeProvider = (_a) => {
|
|
|
106
85
|
}
|
|
107
86
|
}, {
|
|
108
87
|
injectStyle: typeof window !== 'undefined',
|
|
109
|
-
container: doc,
|
|
88
|
+
container: doc === null || doc === void 0 ? void 0 : doc.document,
|
|
110
89
|
cacheId
|
|
111
90
|
});
|
|
112
91
|
}, []);
|
|
113
|
-
const scrollbarCss =
|
|
92
|
+
const scrollbarCss = React.useMemo(() => {
|
|
114
93
|
if (noScrollbarCss)
|
|
115
94
|
return;
|
|
116
|
-
const cls = (cls) => `${
|
|
95
|
+
const cls = (cls) => `${themeRootClass(theme)} ${cls}`;
|
|
117
96
|
let thumbSize = 6;
|
|
118
97
|
let thumbColor = "var(--color-text-secondary)";
|
|
119
98
|
let trackColor = "transparent";
|
|
120
|
-
return
|
|
99
|
+
return css({
|
|
121
100
|
"@global": {
|
|
122
101
|
[cls('*::-webkit-scrollbar')]: {
|
|
123
102
|
width: thumbSize,
|
|
@@ -139,16 +118,16 @@ const ThemeProvider = (_a) => {
|
|
|
139
118
|
}
|
|
140
119
|
}, {
|
|
141
120
|
injectStyle: typeof window !== 'undefined',
|
|
142
|
-
container: doc,
|
|
121
|
+
container: doc === null || doc === void 0 ? void 0 : doc.document,
|
|
143
122
|
cacheId
|
|
144
123
|
});
|
|
145
124
|
}, [noScrollbarCss, theme]);
|
|
146
|
-
return (
|
|
125
|
+
return (jsxs(ThemeContex.Provider, { value: theme, 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: {
|
|
147
126
|
"& a": {
|
|
148
127
|
color: "brand.primary",
|
|
149
128
|
},
|
|
150
129
|
}, baseClass: `${theme}-theme-root`, direction: THEME.rtl ? "rtl" : "ltr", children: children }))] }));
|
|
151
130
|
};
|
|
152
131
|
|
|
153
|
-
|
|
132
|
+
export { ThemeProvider as default };
|
|
154
133
|
//# sourceMappingURL=ThemeProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeProvider.js","sources":["../../src/theme/ThemeProvider.tsx"],"sourcesContent":["\"use client\";\r\nimport * as React from \"react\"\r\nimport { ThemeOptions } from \"./types\"\r\nimport Tag from \"../Tag\"\r\nimport { TagComponentType, TagProps } from \"../Tag/types\"\r\nimport { ThemeContex, ThemeFactory } from \"./core\"\r\nimport ThemeCssVars from \"./ThemeCssVars\"\r\nimport { css } from \"../css\"\r\nimport { createDefaultThemes } from \"./ThemeDefaultOptions\"\r\nimport ServerStyleTag from \"../Tag/ServerStyleTag\"\r\nimport { useDocument } from \"../Document\";\r\nimport { themeRootClass } from \".\";\r\nimport { useCSSCacheId } from \"../css/CSSCacheProvider\";\r\n\r\nexport type ThemeProviderProps<T extends TagComponentType = 'div'> = TagProps<T> & {\r\n theme: string;\r\n isRoot?: boolean;\r\n noScrollbarCss?: boolean;\r\n}\r\n\r\ncreateDefaultThemes()\r\n\r\nconst ThemeProvider = <T extends TagComponentType = 'div'>({ children, theme, isRoot, noScrollbarCss, ...props }: ThemeProviderProps<T>) => {\r\n let THEME = ThemeFactory.get(theme) as ThemeOptions\r\n if (!THEME) {\r\n console.error(`ThemeProvider: The theme '${theme}' is not defined. Please make sure to use a valid theme name.`)\r\n THEME = ThemeFactory.get(\"light\") as ThemeOptions\r\n }\r\n const doc = useDocument()
|
|
1
|
+
{"version":3,"file":"ThemeProvider.js","sources":["../../src/theme/ThemeProvider.tsx"],"sourcesContent":["\"use client\";\r\nimport * as React from \"react\"\r\nimport { ThemeOptions } from \"./types\"\r\nimport Tag from \"../Tag\"\r\nimport { TagComponentType, TagProps } from \"../Tag/types\"\r\nimport { ThemeContex, ThemeFactory } from \"./core\"\r\nimport ThemeCssVars from \"./ThemeCssVars\"\r\nimport { css } from \"../css\"\r\nimport { createDefaultThemes } from \"./ThemeDefaultOptions\"\r\nimport ServerStyleTag from \"../Tag/ServerStyleTag\"\r\nimport { useDocument } from \"../Document\";\r\nimport { themeRootClass } from \".\";\r\nimport { useCSSCacheId } from \"../css/CSSCacheProvider\";\r\n\r\nexport type ThemeProviderProps<T extends TagComponentType = 'div'> = TagProps<T> & {\r\n theme: string;\r\n isRoot?: boolean;\r\n noScrollbarCss?: boolean;\r\n}\r\n\r\ncreateDefaultThemes()\r\n\r\nconst ThemeProvider = <T extends TagComponentType = 'div'>({ children, theme, isRoot, noScrollbarCss, ...props }: ThemeProviderProps<T>) => {\r\n let THEME = ThemeFactory.get(theme) as ThemeOptions\r\n if (!THEME) {\r\n console.error(`ThemeProvider: The theme '${theme}' is not defined. Please make sure to use a valid theme name.`)\r\n THEME = ThemeFactory.get(\"light\") as ThemeOptions\r\n }\r\n const doc = useDocument()\r\n const cacheId = useCSSCacheId()\r\n\r\n const themeGlobalStyle: any = React.useMemo(() => {\r\n const root_cls = `.xui-${theme}-theme-root`\r\n let gkeys = Object.keys(THEME.globalStyle || {})\r\n let gstyles: any = {}\r\n gkeys.forEach((key) => {\r\n gstyles[`${root_cls} ${key}`] = THEME.globalStyle[key as any]\r\n })\r\n\r\n return css({\r\n \"@global\": {\r\n ...gstyles,\r\n [root_cls]: ThemeCssVars(THEME)\r\n }\r\n }, {\r\n injectStyle: typeof window !== 'undefined',\r\n container: doc?.document,\r\n cacheId\r\n })\r\n }, [theme, doc])\r\n\r\n const resetCss = React.useMemo(() => {\r\n if (!isRoot) return\r\n return css({\r\n \"@global\": {\r\n \"*\": {\r\n m: 0,\r\n p: 0,\r\n outline: \"none\",\r\n boxSizing: \"border-box\",\r\n verticalAlign: \"baseline\",\r\n },\r\n \"html, body\": {\r\n minHeight: \"100%\",\r\n \"-webkit-font-smoothing\": \"antialiased\",\r\n \"-moz-osx-font-smoothing\": \"grayscale\",\r\n } as any,\r\n \"img, picture, video, canvas, svg\": {\r\n maxWidth: \"100%\",\r\n display: \"block\"\r\n },\r\n \"input, button, textarea, select\": {\r\n font: \"inherit\"\r\n },\r\n \"table\": {\r\n borderCollapse: \"collapse\",\r\n borderSpacing: 0,\r\n },\r\n \"ol, ul\": {\r\n listStyle: \"none\",\r\n padding: 0,\r\n margin: 0,\r\n },\r\n \"a\": {\r\n display: \"inline-block\",\r\n color: \"inherit\",\r\n textDecoration: \"none\",\r\n cursor: \"pointer\",\r\n \"&:hover\": {\r\n textDecoration: \"underline\"\r\n }\r\n },\r\n \"p, h1, h2, h3, h4, h5, h6\": {\r\n overflowWrap: \"break-word\",\r\n },\r\n }\r\n }, {\r\n injectStyle: typeof window !== 'undefined',\r\n container: doc?.document,\r\n cacheId\r\n })\r\n }, [])\r\n\r\n const scrollbarCss: any = React.useMemo(() => {\r\n if (noScrollbarCss) return;\r\n const cls = (cls: string) => `${themeRootClass(theme)} ${cls}`\r\n let thumbSize = 6\r\n let thumbColor = \"var(--color-text-secondary)\"\r\n let trackColor = \"transparent\"\r\n\r\n return css({\r\n \"@global\": {\r\n [cls('*::-webkit-scrollbar')]: {\r\n width: thumbSize,\r\n height: thumbSize,\r\n },\r\n [cls(\"*::-webkit-scrollbar-thumb\")]: {\r\n backgroundColor: thumbColor,\r\n borderRadius: \"6px\",\r\n opacity: 0.6,\r\n },\r\n [cls(\"*::-webkit-scrollbar-thumb:hover\")]: {\r\n backgroundColor: thumbColor,\r\n opacity: 0.0,\r\n },\r\n [cls(\"*::-webkit-scrollbar-track\")]: {\r\n backgroundColor: trackColor,\r\n borderRadius: \"6px\",\r\n },\r\n }\r\n }, {\r\n injectStyle: typeof window !== 'undefined',\r\n container: doc?.document,\r\n cacheId\r\n }) as any\r\n }, [noScrollbarCss, theme])\r\n\r\n return (\r\n <ThemeContex.Provider value={theme}>\r\n {\r\n isRoot && <>\r\n <ServerStyleTag factory={resetCss as any} />\r\n {\r\n !noScrollbarCss && <ServerStyleTag factory={scrollbarCss} />\r\n }\r\n </>\r\n }\r\n <ServerStyleTag factory={themeGlobalStyle} />\r\n <Tag\r\n minHeight=\"100%\"\r\n bgcolor=\"background.primary\"\r\n color=\"text.primary\"\r\n fontSize=\"text\"\r\n fontWeight=\"text\"\r\n lineHeight=\"text\"\r\n fontFamily={`system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif`}\r\n {...props}\r\n sxr={{\r\n \"& a\": {\r\n color: \"brand.primary\",\r\n },\r\n }}\r\n baseClass={`${theme}-theme-root`}\r\n direction={THEME.rtl ? \"rtl\" : \"ltr\"}\r\n >\r\n {children}\r\n </Tag>\r\n </ThemeContex.Provider>\r\n )\r\n}\r\n\r\nexport default ThemeProvider"],"names":[],"mappings":";;;;;;;;;;;;;;AAoBA;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;AAqBY;AACG;AACF;;AAShB;;"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
2
4
|
|
|
3
5
|
const ThemeFactory = new Map();
|
|
4
|
-
const ThemeContex =
|
|
6
|
+
const ThemeContex = React.createContext("light");
|
|
5
7
|
const getTheme = (theme) => ThemeFactory.get(theme);
|
|
6
8
|
const useTheme = () => {
|
|
7
|
-
const theme = ThemeFactory.get(
|
|
9
|
+
const theme = ThemeFactory.get(React.useContext(ThemeContex));
|
|
8
10
|
if (!theme) {
|
|
9
11
|
console.error("Theme not found, returning light theme as fallback");
|
|
10
12
|
return ThemeFactory.get("light");
|
|
@@ -16,7 +18,7 @@ const mergeObject = (a, b) => {
|
|
|
16
18
|
b = Object.assign({}, b);
|
|
17
19
|
for (const key in b) {
|
|
18
20
|
const v = b[key];
|
|
19
|
-
if (typeof v === 'object' && !Array.isArray(v) && !
|
|
21
|
+
if (typeof v === 'object' && !Array.isArray(v) && !React.isValidElement(v)) {
|
|
20
22
|
a[key] = mergeObject(a[key], b[key]);
|
|
21
23
|
}
|
|
22
24
|
else {
|
|
@@ -26,5 +28,9 @@ const mergeObject = (a, b) => {
|
|
|
26
28
|
return a;
|
|
27
29
|
};
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
exports.ThemeContex = ThemeContex;
|
|
32
|
+
exports.ThemeFactory = ThemeFactory;
|
|
33
|
+
exports.getTheme = getTheme;
|
|
34
|
+
exports.mergeObject = mergeObject;
|
|
35
|
+
exports.useTheme = useTheme;
|
|
36
|
+
//# sourceMappingURL=core.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.cjs","sources":["../../src/theme/core.ts"],"sourcesContent":["import React from \"react\"\r\nimport { ObjectType, ThemeOptions } from \"./types\"\r\n\r\nexport const ThemeFactory = new Map<string, ThemeOptions>()\r\nexport const ThemeContex = React.createContext(\"light\")\r\nexport const getTheme = (theme: string) => ThemeFactory.get(theme)\r\nexport const useTheme = (): ThemeOptions => {\r\n const theme = ThemeFactory.get(React.useContext(ThemeContex)) as any\r\n if (!theme) {\r\n console.error(\"Theme not found, returning light theme as fallback\")\r\n return ThemeFactory.get(\"light\") as any\r\n }\r\n return theme\r\n}\r\n\r\nexport const mergeObject = (a: ObjectType, b: ObjectType) => {\r\n a = { ...a }\r\n b = { ...b }\r\n for (const key in b) {\r\n const v = (b as any)[key]\r\n if (typeof v === 'object' && !Array.isArray(v) && !React.isValidElement(v)) {\r\n a[key] = mergeObject(a[key], b[key])\r\n } else {\r\n a[key] = v\r\n }\r\n }\r\n return a\r\n}\r\n"],"names":[],"mappings":";;;;AAGO,MAAM,YAAY,GAAG,IAAI,GAAG;AAC5B,MAAM,WAAW,GAAG,KAAK,CAAC,aAAa,CAAC,OAAO;AAC/C,MAAM,QAAQ,GAAG,CAAC,KAAa,KAAK,YAAY,CAAC,GAAG,CAAC,KAAK;AAC1D,MAAM,QAAQ,GAAG,MAAmB;AACxC,IAAA,MAAM,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,CAAQ;IACpE,IAAI,CAAC,KAAK,EAAE;AACT,QAAA,OAAO,CAAC,KAAK,CAAC,oDAAoD,CAAC;AACnE,QAAA,OAAO,YAAY,CAAC,GAAG,CAAC,OAAO,CAAQ;IAC1C;AACA,IAAA,OAAO,KAAK;AACf;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.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
1
|
+
import React__default from 'react';
|
|
4
2
|
|
|
5
3
|
const ThemeFactory = new Map();
|
|
6
|
-
const ThemeContex =
|
|
4
|
+
const ThemeContex = React__default.createContext("light");
|
|
7
5
|
const getTheme = (theme) => ThemeFactory.get(theme);
|
|
8
6
|
const useTheme = () => {
|
|
9
|
-
const theme = ThemeFactory.get(
|
|
7
|
+
const theme = ThemeFactory.get(React__default.useContext(ThemeContex));
|
|
10
8
|
if (!theme) {
|
|
11
9
|
console.error("Theme not found, returning light theme as fallback");
|
|
12
10
|
return ThemeFactory.get("light");
|
|
@@ -18,7 +16,7 @@ const mergeObject = (a, b) => {
|
|
|
18
16
|
b = Object.assign({}, b);
|
|
19
17
|
for (const key in b) {
|
|
20
18
|
const v = b[key];
|
|
21
|
-
if (typeof v === 'object' && !Array.isArray(v) && !
|
|
19
|
+
if (typeof v === 'object' && !Array.isArray(v) && !React__default.isValidElement(v)) {
|
|
22
20
|
a[key] = mergeObject(a[key], b[key]);
|
|
23
21
|
}
|
|
24
22
|
else {
|
|
@@ -28,9 +26,5 @@ const mergeObject = (a, b) => {
|
|
|
28
26
|
return a;
|
|
29
27
|
};
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
exports.ThemeFactory = ThemeFactory;
|
|
33
|
-
exports.getTheme = getTheme;
|
|
34
|
-
exports.mergeObject = mergeObject;
|
|
35
|
-
exports.useTheme = useTheme;
|
|
29
|
+
export { ThemeContex, ThemeFactory, getTheme, mergeObject, useTheme };
|
|
36
30
|
//# sourceMappingURL=core.js.map
|
package/theme/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sources":["../../src/theme/core.ts"],"sourcesContent":["import React from \"react\"\r\nimport { ObjectType, ThemeOptions } from \"./types\"\r\n\r\nexport const ThemeFactory = new Map<string, ThemeOptions>()\r\nexport const ThemeContex = React.createContext(\"light\")\r\nexport const getTheme = (theme: string) => ThemeFactory.get(theme)\r\nexport const useTheme = (): ThemeOptions => {\r\n const theme = ThemeFactory.get(React.useContext(ThemeContex)) as any\r\n if (!theme) {\r\n console.error(\"Theme not found, returning light theme as fallback\")\r\n return ThemeFactory.get(\"light\") as any\r\n }\r\n return theme\r\n}\r\n\r\nexport const mergeObject = (a: ObjectType, b: ObjectType) => {\r\n a = { ...a }\r\n b = { ...b }\r\n for (const key in b) {\r\n const v = (b as any)[key]\r\n if (typeof v === 'object' && !Array.isArray(v) && !React.isValidElement(v)) {\r\n a[key] = mergeObject(a[key], b[key])\r\n } else {\r\n a[key] = v\r\n }\r\n }\r\n return a\r\n}\r\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"core.js","sources":["../../src/theme/core.ts"],"sourcesContent":["import React from \"react\"\r\nimport { ObjectType, ThemeOptions } from \"./types\"\r\n\r\nexport const ThemeFactory = new Map<string, ThemeOptions>()\r\nexport const ThemeContex = React.createContext(\"light\")\r\nexport const getTheme = (theme: string) => ThemeFactory.get(theme)\r\nexport const useTheme = (): ThemeOptions => {\r\n const theme = ThemeFactory.get(React.useContext(ThemeContex)) as any\r\n if (!theme) {\r\n console.error(\"Theme not found, returning light theme as fallback\")\r\n return ThemeFactory.get(\"light\") as any\r\n }\r\n return theme\r\n}\r\n\r\nexport const mergeObject = (a: ObjectType, b: ObjectType) => {\r\n a = { ...a }\r\n b = { ...b }\r\n for (const key in b) {\r\n const v = (b as any)[key]\r\n if (typeof v === 'object' && !Array.isArray(v) && !React.isValidElement(v)) {\r\n a[key] = mergeObject(a[key], b[key])\r\n } else {\r\n a[key] = v\r\n }\r\n }\r\n return a\r\n}\r\n"],"names":["React"],"mappings":";;AAGO,MAAM,YAAY,GAAG,IAAI,GAAG;AAC5B,MAAM,WAAW,GAAGA,cAAK,CAAC,aAAa,CAAC,OAAO;AAC/C,MAAM,QAAQ,GAAG,CAAC,KAAa,KAAK,YAAY,CAAC,GAAG,CAAC,KAAK;AAC1D,MAAM,QAAQ,GAAG,MAAmB;AACxC,IAAA,MAAM,KAAK,GAAG,YAAY,CAAC,GAAG,CAACA,cAAK,CAAC,UAAU,CAAC,WAAW,CAAC,CAAQ;IACpE,IAAI,CAAC,KAAK,EAAE;AACT,QAAA,OAAO,CAAC,KAAK,CAAC,oDAAoD,CAAC;AACnE,QAAA,OAAO,YAAY,CAAC,GAAG,CAAC,OAAO,CAAQ;IAC1C;AACA,IAAA,OAAO,KAAK;AACf;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;;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('./core.cjs');
|
|
4
|
+
var index = require('../css/index.cjs');
|
|
5
|
+
var ThemeDefaultOptions = require('./ThemeDefaultOptions.cjs');
|
|
6
|
+
|
|
7
|
+
const createTheme = (name, options) => {
|
|
8
|
+
if (core.ThemeFactory.has(name)) {
|
|
9
|
+
console.error(`createTheme: The theme '${name}' is already defined. Please choose a different name for the theme.`);
|
|
10
|
+
return core.ThemeFactory.get(name);
|
|
11
|
+
}
|
|
12
|
+
let theme = core.mergeObject(ThemeDefaultOptions.lightThemeOptions, Object.assign(Object.assign({}, options), { name, breakpoints: index.breakpoints }));
|
|
13
|
+
// add alpha colors
|
|
14
|
+
for (let color in theme.colors) {
|
|
15
|
+
const c = theme.colors[color];
|
|
16
|
+
const is_common = color === 'divider' || color === 'background' || color === 'text';
|
|
17
|
+
c.soft = {
|
|
18
|
+
primary: is_common ? index.alpha(c.primary, 0.60) : index.alpha(c.primary, 0.08),
|
|
19
|
+
secondary: is_common ? index.alpha(c.primary, 0.90) : index.alpha(c.primary, 0.12)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
core.ThemeFactory.set(name, theme);
|
|
23
|
+
return theme;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
exports.createTheme = createTheme;
|
|
27
|
+
//# sourceMappingURL=createTheme.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTheme.
|
|
1
|
+
{"version":3,"file":"createTheme.cjs","sources":["../../src/theme/createTheme.ts"],"sourcesContent":["import { ThemeOptions, ThemeOptionInput, ThemeOptionsColor } from \"./types\"\r\nimport { mergeObject, ThemeFactory } from \"./core\"\r\nimport { alpha, breakpoints } from \"../css\"\r\nimport { lightThemeOptions } from \"./ThemeDefaultOptions\"\r\n\r\nexport const createTheme = (name: string, options: ThemeOptionInput): ThemeOptions => {\r\n if (ThemeFactory.has(name)) {\r\n console.error(`createTheme: The theme '${name}' is already defined. Please choose a different name for the theme.`)\r\n return ThemeFactory.get(name) as ThemeOptions\r\n }\r\n\r\n let theme: any = mergeObject(lightThemeOptions, {\r\n ...options,\r\n name,\r\n breakpoints: breakpoints\r\n })\r\n\r\n // add alpha colors\r\n for (let color in theme.colors) {\r\n const c = theme.colors[color] as ThemeOptionsColor\r\n const is_common = color === 'divider' || color === 'background' || color === 'text'\r\n c.soft = {\r\n primary: is_common ? alpha(c.primary, 0.60) : alpha(c.primary, 0.08),\r\n secondary: is_common ? alpha(c.primary, 0.90) : alpha(c.primary, 0.12)\r\n }\r\n }\r\n\r\n ThemeFactory.set(name, theme)\r\n\r\n return theme as ThemeOptions\r\n}\r\n"],"names":["ThemeFactory","mergeObject","lightThemeOptions","breakpoints","alpha"],"mappings":";;;;;;MAKa,WAAW,GAAG,CAAC,IAAY,EAAE,OAAyB,KAAkB;AAClF,IAAA,IAAIA,iBAAY,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;AACzB,QAAA,OAAO,CAAC,KAAK,CAAC,2BAA2B,IAAI,CAAA,mEAAA,CAAqE,CAAC;AACnH,QAAA,OAAOA,iBAAY,CAAC,GAAG,CAAC,IAAI,CAAiB;IAChD;AAEA,IAAA,IAAI,KAAK,GAAQC,gBAAW,CAACC,qCAAiB,EAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EACxC,OAAO,CAAA,EAAA,EACV,IAAI,EACJ,WAAW,EAAEC,iBAAW,IACzB;;AAGF,IAAA,KAAK,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE;QAC7B,MAAM,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAsB;AAClD,QAAA,MAAM,SAAS,GAAG,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,YAAY,IAAI,KAAK,KAAK,MAAM;QACnF,CAAC,CAAC,IAAI,GAAG;YACN,OAAO,EAAE,SAAS,GAAGC,WAAK,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,GAAGA,WAAK,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC;YACpE,SAAS,EAAE,SAAS,GAAGA,WAAK,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,GAAGA,WAAK,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI;SACvE;IACJ;AAEA,IAAAJ,iBAAY,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC;AAE7B,IAAA,OAAO,KAAqB;AAC/B;;;;"}
|
package/theme/createTheme.js
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var index = require('../css/index.js');
|
|
5
|
-
var ThemeDefaultOptions = require('./ThemeDefaultOptions.js');
|
|
1
|
+
import { ThemeFactory, mergeObject } from './core.js';
|
|
2
|
+
import { breakpoints, alpha } from '../css/index.js';
|
|
3
|
+
import { lightThemeOptions } from './ThemeDefaultOptions.js';
|
|
6
4
|
|
|
7
5
|
const createTheme = (name, options) => {
|
|
8
|
-
if (
|
|
6
|
+
if (ThemeFactory.has(name)) {
|
|
9
7
|
console.error(`createTheme: The theme '${name}' is already defined. Please choose a different name for the theme.`);
|
|
10
|
-
return
|
|
8
|
+
return ThemeFactory.get(name);
|
|
11
9
|
}
|
|
12
|
-
let theme =
|
|
10
|
+
let theme = mergeObject(lightThemeOptions, Object.assign(Object.assign({}, options), { name, breakpoints: breakpoints }));
|
|
13
11
|
// add alpha colors
|
|
14
12
|
for (let color in theme.colors) {
|
|
15
13
|
const c = theme.colors[color];
|
|
16
14
|
const is_common = color === 'divider' || color === 'background' || color === 'text';
|
|
17
15
|
c.soft = {
|
|
18
|
-
primary: is_common ?
|
|
19
|
-
secondary: is_common ?
|
|
16
|
+
primary: is_common ? alpha(c.primary, 0.60) : alpha(c.primary, 0.08),
|
|
17
|
+
secondary: is_common ? alpha(c.primary, 0.90) : alpha(c.primary, 0.12)
|
|
20
18
|
};
|
|
21
19
|
}
|
|
22
|
-
|
|
20
|
+
ThemeFactory.set(name, theme);
|
|
23
21
|
return theme;
|
|
24
22
|
};
|
|
25
23
|
|
|
26
|
-
|
|
24
|
+
export { createTheme };
|
|
27
25
|
//# sourceMappingURL=createTheme.js.map
|
package/theme/createTheme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTheme.js","sources":["../../src/theme/createTheme.ts"],"sourcesContent":["import { ThemeOptions, ThemeOptionInput, ThemeOptionsColor } from \"./types\"\r\nimport { mergeObject, ThemeFactory } from \"./core\"\r\nimport { alpha, breakpoints } from \"../css\"\r\nimport { lightThemeOptions } from \"./ThemeDefaultOptions\"\r\n\r\nexport const createTheme = (name: string, options: ThemeOptionInput): ThemeOptions => {\r\n if (ThemeFactory.has(name)) {\r\n console.error(`createTheme: The theme '${name}' is already defined. Please choose a different name for the theme.`)\r\n return ThemeFactory.get(name) as ThemeOptions\r\n }\r\n\r\n let theme: any = mergeObject(lightThemeOptions, {\r\n ...options,\r\n name,\r\n breakpoints: breakpoints\r\n })\r\n\r\n // add alpha colors\r\n for (let color in theme.colors) {\r\n const c = theme.colors[color] as ThemeOptionsColor\r\n const is_common = color === 'divider' || color === 'background' || color === 'text'\r\n c.soft = {\r\n primary: is_common ? alpha(c.primary, 0.60) : alpha(c.primary, 0.08),\r\n secondary: is_common ? alpha(c.primary, 0.90) : alpha(c.primary, 0.12)\r\n }\r\n }\r\n\r\n ThemeFactory.set(name, theme)\r\n\r\n return theme as ThemeOptions\r\n}\r\n"],"names":[
|
|
1
|
+
{"version":3,"file":"createTheme.js","sources":["../../src/theme/createTheme.ts"],"sourcesContent":["import { ThemeOptions, ThemeOptionInput, ThemeOptionsColor } from \"./types\"\r\nimport { mergeObject, ThemeFactory } from \"./core\"\r\nimport { alpha, breakpoints } from \"../css\"\r\nimport { lightThemeOptions } from \"./ThemeDefaultOptions\"\r\n\r\nexport const createTheme = (name: string, options: ThemeOptionInput): ThemeOptions => {\r\n if (ThemeFactory.has(name)) {\r\n console.error(`createTheme: The theme '${name}' is already defined. Please choose a different name for the theme.`)\r\n return ThemeFactory.get(name) as ThemeOptions\r\n }\r\n\r\n let theme: any = mergeObject(lightThemeOptions, {\r\n ...options,\r\n name,\r\n breakpoints: breakpoints\r\n })\r\n\r\n // add alpha colors\r\n for (let color in theme.colors) {\r\n const c = theme.colors[color] as ThemeOptionsColor\r\n const is_common = color === 'divider' || color === 'background' || color === 'text'\r\n c.soft = {\r\n primary: is_common ? alpha(c.primary, 0.60) : alpha(c.primary, 0.08),\r\n secondary: is_common ? alpha(c.primary, 0.90) : alpha(c.primary, 0.12)\r\n }\r\n }\r\n\r\n ThemeFactory.set(name, theme)\r\n\r\n return theme as ThemeOptions\r\n}\r\n"],"names":[],"mappings":";;;;MAKa,WAAW,GAAG,CAAC,IAAY,EAAE,OAAyB,KAAkB;AAClF,IAAA,IAAI,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;AACzB,QAAA,OAAO,CAAC,KAAK,CAAC,2BAA2B,IAAI,CAAA,mEAAA,CAAqE,CAAC;AACnH,QAAA,OAAO,YAAY,CAAC,GAAG,CAAC,IAAI,CAAiB;IAChD;AAEA,IAAA,IAAI,KAAK,GAAQ,WAAW,CAAC,iBAAiB,EAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EACxC,OAAO,CAAA,EAAA,EACV,IAAI,EACJ,WAAW,EAAE,WAAW,IACzB;;AAGF,IAAA,KAAK,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE;QAC7B,MAAM,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAsB;AAClD,QAAA,MAAM,SAAS,GAAG,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,YAAY,IAAI,KAAK,KAAK,MAAM;QACnF,CAAC,CAAC,IAAI,GAAG;YACN,OAAO,EAAE,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC;YACpE,SAAS,EAAE,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI;SACvE;IACJ;AAEA,IAAA,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC;AAE7B,IAAA,OAAO,KAAqB;AAC/B;;;;"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var reactStateBucket = require('react-state-bucket');
|
|
5
|
+
var core = require('./core.cjs');
|
|
4
6
|
|
|
5
7
|
const createThemeSwitcher = (defaultTheme, option) => {
|
|
6
|
-
const useThemeBucket = createBucket({ name: xv.string().default(defaultTheme) }, {
|
|
8
|
+
const useThemeBucket = reactStateBucket.createBucket({ name: reactStateBucket.xv.string().default(defaultTheme) }, {
|
|
7
9
|
store: (option === null || option === void 0 ? void 0 : option.store) || "memory",
|
|
8
10
|
onChange: (_key, value) => {
|
|
9
11
|
(option === null || option === void 0 ? void 0 : option.onChange) && (option === null || option === void 0 ? void 0 : option.onChange(value));
|
|
@@ -13,12 +15,12 @@ const createThemeSwitcher = (defaultTheme, option) => {
|
|
|
13
15
|
const bucket = useThemeBucket();
|
|
14
16
|
return {
|
|
15
17
|
name: bucket.state.name,
|
|
16
|
-
theme: getTheme(bucket.state.name),
|
|
18
|
+
theme: core.getTheme(bucket.state.name),
|
|
17
19
|
change: (theme) => bucket.set('name', theme)
|
|
18
20
|
};
|
|
19
21
|
};
|
|
20
22
|
return useThemeSwitcher;
|
|
21
23
|
};
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
//# sourceMappingURL=createThemeSwitcher.
|
|
25
|
+
module.exports = createThemeSwitcher;
|
|
26
|
+
//# sourceMappingURL=createThemeSwitcher.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createThemeSwitcher.
|
|
1
|
+
{"version":3,"file":"createThemeSwitcher.cjs","sources":["../../src/theme/createThemeSwitcher.ts"],"sourcesContent":["\"use client\";\r\nimport { createBucket, xv } from \"react-state-bucket\"\r\nimport { getTheme } from \"./core\"\r\nimport { BucketOptions } from \"react-state-bucket\"\r\n\r\nexport type ThemeSwitcherOption = {\r\n store?: BucketOptions['store'],\r\n onChange?: (theme: string) => void\r\n}\r\n\r\nconst createThemeSwitcher = (defaultTheme: string, option?: ThemeSwitcherOption) => {\r\n\r\n const useThemeBucket = createBucket({ name: xv.string().default(defaultTheme) }, {\r\n store: option?.store || \"memory\",\r\n onChange: (_key, value) => {\r\n option?.onChange && option?.onChange(value)\r\n }\r\n })\r\n\r\n const useThemeSwitcher = () => {\r\n const bucket = useThemeBucket()\r\n return {\r\n name: bucket.state.name,\r\n theme: getTheme(bucket.state.name),\r\n change: (theme: string) => bucket.set('name', theme)\r\n }\r\n }\r\n return useThemeSwitcher\r\n}\r\n\r\nexport default createThemeSwitcher"],"names":[],"mappings":";;;;;;AAUA;AAEG;;AAEG;AACG;;AAEL;;AAGE;;AAEG;;AAEA;;AAEN;AACA;AACH;;"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var reactStateBucket = require('react-state-bucket');
|
|
5
|
-
var core = require('./core.js');
|
|
2
|
+
import { createBucket, xv } from 'react-state-bucket';
|
|
3
|
+
import { getTheme } from './core.js';
|
|
6
4
|
|
|
7
5
|
const createThemeSwitcher = (defaultTheme, option) => {
|
|
8
|
-
const useThemeBucket =
|
|
6
|
+
const useThemeBucket = createBucket({ name: xv.string().default(defaultTheme) }, {
|
|
9
7
|
store: (option === null || option === void 0 ? void 0 : option.store) || "memory",
|
|
10
8
|
onChange: (_key, value) => {
|
|
11
9
|
(option === null || option === void 0 ? void 0 : option.onChange) && (option === null || option === void 0 ? void 0 : option.onChange(value));
|
|
@@ -15,12 +13,12 @@ const createThemeSwitcher = (defaultTheme, option) => {
|
|
|
15
13
|
const bucket = useThemeBucket();
|
|
16
14
|
return {
|
|
17
15
|
name: bucket.state.name,
|
|
18
|
-
theme:
|
|
16
|
+
theme: getTheme(bucket.state.name),
|
|
19
17
|
change: (theme) => bucket.set('name', theme)
|
|
20
18
|
};
|
|
21
19
|
};
|
|
22
20
|
return useThemeSwitcher;
|
|
23
21
|
};
|
|
24
22
|
|
|
25
|
-
|
|
23
|
+
export { createThemeSwitcher as default };
|
|
26
24
|
//# sourceMappingURL=createThemeSwitcher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createThemeSwitcher.js","sources":["../../src/theme/createThemeSwitcher.ts"],"sourcesContent":["\"use client\";\r\nimport { createBucket, xv } from \"react-state-bucket\"\r\nimport { getTheme } from \"./core\"\r\nimport { BucketOptions } from \"react-state-bucket\"\r\n\r\nexport type ThemeSwitcherOption = {\r\n store?: BucketOptions['store'],\r\n onChange?: (theme: string) => void\r\n}\r\n\r\nconst createThemeSwitcher = (defaultTheme: string, option?: ThemeSwitcherOption) => {\r\n\r\n const useThemeBucket = createBucket({ name: xv.string().default(defaultTheme) }, {\r\n store: option?.store || \"memory\",\r\n onChange: (_key, value) => {\r\n option?.onChange && option?.onChange(value)\r\n }\r\n })\r\n\r\n const useThemeSwitcher = () => {\r\n const bucket = useThemeBucket()\r\n return {\r\n name: bucket.state.name,\r\n theme: getTheme(bucket.state.name),\r\n change: (theme: string) => bucket.set('name', theme)\r\n }\r\n }\r\n return useThemeSwitcher\r\n}\r\n\r\nexport default createThemeSwitcher"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createThemeSwitcher.js","sources":["../../src/theme/createThemeSwitcher.ts"],"sourcesContent":["\"use client\";\r\nimport { createBucket, xv } from \"react-state-bucket\"\r\nimport { getTheme } from \"./core\"\r\nimport { BucketOptions } from \"react-state-bucket\"\r\n\r\nexport type ThemeSwitcherOption = {\r\n store?: BucketOptions['store'],\r\n onChange?: (theme: string) => void\r\n}\r\n\r\nconst createThemeSwitcher = (defaultTheme: string, option?: ThemeSwitcherOption) => {\r\n\r\n const useThemeBucket = createBucket({ name: xv.string().default(defaultTheme) }, {\r\n store: option?.store || \"memory\",\r\n onChange: (_key, value) => {\r\n option?.onChange && option?.onChange(value)\r\n }\r\n })\r\n\r\n const useThemeSwitcher = () => {\r\n const bucket = useThemeBucket()\r\n return {\r\n name: bucket.state.name,\r\n theme: getTheme(bucket.state.name),\r\n change: (theme: string) => bucket.set('name', theme)\r\n }\r\n }\r\n return useThemeSwitcher\r\n}\r\n\r\nexport default createThemeSwitcher"],"names":[],"mappings":";;;;AAUA;AAEG;;AAEG;AACG;;AAEL;;AAGE;;AAEG;;AAEA;;AAEN;AACA;AACH;;"}
|
package/theme/index.cjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('./core.cjs');
|
|
4
|
+
require('../css/getValue.cjs');
|
|
5
|
+
require('oncss');
|
|
6
|
+
var ThemeProvider = require('./ThemeProvider.cjs');
|
|
7
|
+
require('react-state-bucket');
|
|
8
|
+
|
|
9
|
+
const themeRootClass = (theme) => `.xui-${theme}-theme-root`;
|
|
10
|
+
|
|
11
|
+
exports.getTheme = core.getTheme;
|
|
12
|
+
exports.useTheme = core.useTheme;
|
|
13
|
+
exports.ThemeProvider = ThemeProvider;
|
|
14
|
+
exports.themeRootClass = themeRootClass;
|
|
15
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/theme/index.tsx"],"sourcesContent":["import { createTheme } from \"./createTheme\"\r\nimport ThemeProvider from './ThemeProvider'\r\nimport createThemeSwitcher from './createThemeSwitcher'\r\nimport { getTheme, useTheme } from './core'\r\nexport type { ThemeProviderProps } from './ThemeProvider'\r\nexport type { ThemeSwitcherOption } from './createThemeSwitcher'\r\n\r\nexport const themeRootClass = (theme: string) => `.xui-${theme}-theme-root`\r\n\r\nexport {\r\n ThemeProvider,\r\n createThemeSwitcher,\r\n createTheme,\r\n getTheme,\r\n useTheme\r\n}\r\n\r\n"],"names":[],"mappings":";;;;;;;;AAOO,MAAM,cAAc,GAAG,CAAC,KAAa,KAAK,CAAA,KAAA,EAAQ,KAAK,CAAA,WAAA;;;;;;;"}
|