@ttoss/fsl-theme 1.1.13 → 1.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Types-BiBa17RL.d.cts +1427 -0
- package/dist/Types-BiBa17RL.d.mts +1427 -0
- package/dist/baseBundle-DxvXyhGa.mjs +17 -0
- package/dist/baseBundle-iEFf5nqT.cjs +22 -0
- package/dist/{esm/chunk-SE5Z52RE.js → createTheme-BLNYztZU.mjs} +76 -172
- package/dist/createTheme-Cv6RP9D6.cjs +1825 -0
- package/dist/css.cjs +48 -0
- package/dist/{css.d.ts → css.d.cts} +67 -63
- package/dist/css.d.mts +168 -0
- package/dist/css.mjs +42 -0
- package/dist/dataviz/index.cjs +45 -0
- package/dist/dataviz/{index.d.ts → index.d.cts} +9 -5
- package/dist/dataviz/index.d.mts +66 -0
- package/dist/dataviz/index.mjs +39 -0
- package/dist/dtcg.cjs +115 -0
- package/dist/{dtcg.d.ts → dtcg.d.cts} +9 -7
- package/dist/dtcg.d.mts +51 -0
- package/dist/dtcg.mjs +112 -0
- package/dist/helpers-4p4-QVt_.cjs +258 -0
- package/dist/helpers-CaswNJMy.mjs +211 -0
- package/dist/{index.d.ts → index-CsIjfw86.d.cts} +42 -34
- package/dist/index-nJrjI0BA.d.mts +94 -0
- package/dist/index.cjs +16 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.mjs +7 -0
- package/dist/{react.d.ts → react-CGa6FlNL.d.cts} +130 -106
- package/dist/react-DnKxR2gK.d.mts +370 -0
- package/dist/react-EUwpdvY7.cjs +481 -0
- package/dist/react.cjs +12 -0
- package/dist/react.d.cts +4 -0
- package/dist/react.d.mts +4 -0
- package/dist/react.mjs +412 -0
- package/dist/runtime-entry.cjs +9 -0
- package/dist/runtime-entry.d.cts +3 -0
- package/dist/runtime-entry.d.mts +3 -0
- package/dist/runtime-entry.mjs +3 -0
- package/dist/{runtime-entry.d.ts → ssrScript-BVysxDws.d.cts} +26 -23
- package/dist/ssrScript-BVysxDws.d.mts +98 -0
- package/dist/ssrScript-CRfrN8Pm.cjs +202 -0
- package/dist/ssrScript-D3kGPQpi.mjs +179 -0
- package/dist/themes/bruttal.cjs +75 -0
- package/dist/themes/bruttal.d.cts +3 -0
- package/dist/themes/bruttal.d.mts +3 -0
- package/dist/themes/bruttal.mjs +72 -0
- package/dist/themes/corporate.cjs +34 -0
- package/dist/themes/corporate.d.cts +3 -0
- package/dist/themes/corporate.d.mts +3 -0
- package/dist/{esm/chunk-TPMN75JM.js → themes/corporate.mjs} +7 -5
- package/dist/themes/oca.cjs +34 -0
- package/dist/themes/oca.d.cts +3 -0
- package/dist/themes/oca.d.mts +3 -0
- package/dist/{esm/chunk-DU4QDQUC.js → themes/oca.mjs} +7 -5
- package/dist/themes/ventures.cjs +34 -0
- package/dist/themes/ventures.d.cts +3 -0
- package/dist/themes/ventures.d.mts +3 -0
- package/dist/{esm/chunk-BXKVVQEP.js → themes/ventures.mjs} +7 -5
- package/dist/toCssVars-CYZCe-on.mjs +286 -0
- package/dist/toCssVars-DudHKvt2.cjs +297 -0
- package/dist/{esm/chunk-4Q4P3JBB.js → tokenRegistry-DjgSN3oU.mjs} +23 -20
- package/dist/tokenRegistry-OhaJ9sPJ.cjs +199 -0
- package/dist/vars.cjs +127 -0
- package/dist/{vars.d.ts → vars.d.cts} +8 -7
- package/dist/vars.d.mts +128 -0
- package/dist/vars.mjs +123 -0
- package/dist/withDataviz-B4pVsOwV.cjs +192 -0
- package/dist/{esm/chunk-FBVUI2PK.js → withDataviz-DY5s7R51.mjs} +40 -12
- package/package.json +20 -20
- package/dist/Types-6tR0_2Ss.d.ts +0 -1452
- package/dist/esm/chunk-5PWPAQMC.js +0 -9
- package/dist/esm/chunk-HRNXVRS3.js +0 -54
- package/dist/esm/chunk-IJGA42O6.js +0 -141
- package/dist/esm/chunk-PQPQNZ73.js +0 -262
- package/dist/esm/chunk-UMRQ4OTX.js +0 -11
- package/dist/esm/chunk-VL6EGE6Z.js +0 -222
- package/dist/esm/chunk-WVQSTQD5.js +0 -192
- package/dist/esm/css.js +0 -6
- package/dist/esm/dataviz/index.js +0 -19
- package/dist/esm/dtcg.js +0 -65
- package/dist/esm/index.js +0 -10
- package/dist/esm/react.js +0 -8
- package/dist/esm/runtime-entry.js +0 -4
- package/dist/esm/themes/bruttal.js +0 -6
- package/dist/esm/themes/corporate.js +0 -6
- package/dist/esm/themes/oca.js +0 -6
- package/dist/esm/themes/ventures.js +0 -6
- package/dist/esm/vars.js +0 -28
- package/dist/themes/bruttal.d.ts +0 -5
- package/dist/themes/corporate.d.ts +0 -5
- package/dist/themes/oca.d.ts +0 -5
- package/dist/themes/ventures.d.ts +0 -5
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
const require_helpers = require('./helpers-4p4-QVt_.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/themeBootstrap.ts
|
|
5
|
+
/**
|
|
6
|
+
* Reads persisted mode from localStorage and resolves the effective
|
|
7
|
+
* `mode` and `resolvedMode` (never `'system'`).
|
|
8
|
+
*
|
|
9
|
+
* Does **not** touch the DOM — DOM writes are performed by `apply()` inside
|
|
10
|
+
* `createThemeRuntime`, which is the single owner of all attribute mutations.
|
|
11
|
+
*/
|
|
12
|
+
const resolveTheme = cfg => {
|
|
13
|
+
let stored = null;
|
|
14
|
+
try {
|
|
15
|
+
const raw = localStorage.getItem(cfg.storageKey);
|
|
16
|
+
if (raw) stored = JSON.parse(raw);
|
|
17
|
+
} catch {}
|
|
18
|
+
const mode = stored != null && stored.mode != null && cfg.validModes.indexOf(stored.mode) !== -1 ? stored.mode : cfg.defaultMode;
|
|
19
|
+
return {
|
|
20
|
+
mode,
|
|
21
|
+
resolvedMode: mode === "system" ? typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : mode
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/runtime.ts
|
|
27
|
+
const DATA_THEME_ATTR = "data-tt-theme";
|
|
28
|
+
const DATA_MODE_ATTR = "data-tt-mode";
|
|
29
|
+
const DEFAULT_STORAGE_KEY = "tt-theme";
|
|
30
|
+
/** Valid values for the `mode` field. Used to sanitize localStorage input. */
|
|
31
|
+
const VALID_MODES = ["light", "dark", "system"];
|
|
32
|
+
const writeStorage = (key, data) => {
|
|
33
|
+
try {
|
|
34
|
+
localStorage.setItem(key, JSON.stringify(data));
|
|
35
|
+
} catch {}
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Creates a framework-agnostic runtime that manages theme switching.
|
|
39
|
+
*
|
|
40
|
+
* - Sets `data-tt-mode` (and `data-tt-theme` when `defaultTheme` is provided) attributes on the root element.
|
|
41
|
+
* - Updates `style.colorScheme` for native dark/light UI.
|
|
42
|
+
* - Persists `{ mode }` to localStorage.
|
|
43
|
+
* - Listens to `prefers-color-scheme` media query when mode is `'system'`.
|
|
44
|
+
* - Pub/sub pattern for state changes.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* const runtime = createThemeRuntime({ defaultMode: 'dark' });
|
|
49
|
+
* runtime.setMode('system');
|
|
50
|
+
* const unsub = runtime.subscribe(console.log);
|
|
51
|
+
* runtime.destroy();
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
const createThemeRuntime = (config = {}) => {
|
|
55
|
+
const {
|
|
56
|
+
defaultTheme,
|
|
57
|
+
defaultMode = "system",
|
|
58
|
+
storageKey = DEFAULT_STORAGE_KEY,
|
|
59
|
+
root = document.documentElement
|
|
60
|
+
} = config;
|
|
61
|
+
const listeners = /* @__PURE__ */new Set();
|
|
62
|
+
let destroyed = false;
|
|
63
|
+
const init = resolveTheme({
|
|
64
|
+
storageKey,
|
|
65
|
+
defaultMode,
|
|
66
|
+
validModes: VALID_MODES
|
|
67
|
+
});
|
|
68
|
+
let mode = init.mode;
|
|
69
|
+
let resolvedMode = init.resolvedMode;
|
|
70
|
+
const apply = () => {
|
|
71
|
+
if (defaultTheme) root.setAttribute(DATA_THEME_ATTR, defaultTheme);else root.removeAttribute(DATA_THEME_ATTR);
|
|
72
|
+
root.setAttribute(DATA_MODE_ATTR, resolvedMode);
|
|
73
|
+
root.style.colorScheme = resolvedMode;
|
|
74
|
+
};
|
|
75
|
+
const getState = () => {
|
|
76
|
+
return {
|
|
77
|
+
mode,
|
|
78
|
+
resolvedMode
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
apply();
|
|
82
|
+
let prevMode = mode;
|
|
83
|
+
let prevResolvedMode = resolvedMode;
|
|
84
|
+
const applyState = ({
|
|
85
|
+
persist
|
|
86
|
+
}) => {
|
|
87
|
+
if (mode === prevMode && resolvedMode === prevResolvedMode) return;
|
|
88
|
+
prevMode = mode;
|
|
89
|
+
prevResolvedMode = resolvedMode;
|
|
90
|
+
apply();
|
|
91
|
+
if (persist) writeStorage(storageKey, {
|
|
92
|
+
mode
|
|
93
|
+
});
|
|
94
|
+
const state = getState();
|
|
95
|
+
for (const listener of listeners) listener(state);
|
|
96
|
+
};
|
|
97
|
+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
98
|
+
const onSystemChange = () => {
|
|
99
|
+
resolvedMode = mediaQuery.matches ? "dark" : "light";
|
|
100
|
+
applyState({
|
|
101
|
+
persist: false
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
const syncMediaListener = active => {
|
|
105
|
+
mediaQuery.removeEventListener("change", onSystemChange);
|
|
106
|
+
if (active) mediaQuery.addEventListener("change", onSystemChange);
|
|
107
|
+
};
|
|
108
|
+
syncMediaListener(mode === "system");
|
|
109
|
+
const setMode = newMode => {
|
|
110
|
+
if (destroyed || !VALID_MODES.includes(newMode)) return;
|
|
111
|
+
mode = newMode;
|
|
112
|
+
resolvedMode = mode === "system" ? mediaQuery.matches ? "dark" : "light" : mode;
|
|
113
|
+
syncMediaListener(mode === "system");
|
|
114
|
+
applyState({
|
|
115
|
+
persist: true
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
const subscribe = listener => {
|
|
119
|
+
if (destroyed) return () => {};
|
|
120
|
+
listeners.add(listener);
|
|
121
|
+
return () => {
|
|
122
|
+
listeners.delete(listener);
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
const destroy = () => {
|
|
126
|
+
destroyed = true;
|
|
127
|
+
syncMediaListener(false);
|
|
128
|
+
listeners.clear();
|
|
129
|
+
};
|
|
130
|
+
return {
|
|
131
|
+
getState,
|
|
132
|
+
setMode,
|
|
133
|
+
subscribe,
|
|
134
|
+
destroy
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/ssrScript.ts
|
|
140
|
+
/**
|
|
141
|
+
* Returns self-contained JavaScript code that prevents theme flash on SSR/SSG.
|
|
142
|
+
*
|
|
143
|
+
* Insert the returned string into an inline `<script>` tag in the `<head>`,
|
|
144
|
+
* before any stylesheets or the app bundle.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```tsx
|
|
148
|
+
* // Next.js app/layout.tsx
|
|
149
|
+
* import { getThemeScriptContent } from '@ttoss/fsl-theme/runtime';
|
|
150
|
+
*
|
|
151
|
+
* export default function RootLayout({ children }) {
|
|
152
|
+
* return (
|
|
153
|
+
* <html lang="en">
|
|
154
|
+
* <head>
|
|
155
|
+
* <script dangerouslySetInnerHTML={{ __html: getThemeScriptContent() }} />
|
|
156
|
+
* </head>
|
|
157
|
+
* <body>{children}</body>
|
|
158
|
+
* </html>
|
|
159
|
+
* );
|
|
160
|
+
* }
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
const getThemeScriptContent = (config = {}) => {
|
|
164
|
+
const {
|
|
165
|
+
defaultTheme,
|
|
166
|
+
defaultMode = "system",
|
|
167
|
+
storageKey = DEFAULT_STORAGE_KEY
|
|
168
|
+
} = config;
|
|
169
|
+
if (defaultTheme !== void 0 && !require_helpers.SAFE_ID_RE.test(defaultTheme)) throw new Error(`Invalid defaultTheme "${defaultTheme}". Only alphanumeric characters, hyphens, and underscores are allowed.`);
|
|
170
|
+
return `(function(){var cfg=${JSON.stringify({
|
|
171
|
+
storageKey,
|
|
172
|
+
defaultTheme,
|
|
173
|
+
defaultMode,
|
|
174
|
+
validModes: [...VALID_MODES]
|
|
175
|
+
})};var d=document.documentElement;var s=null;try{var r=localStorage.getItem(cfg.storageKey);if(r)s=JSON.parse(r);}catch(e){}var m=(s!=null&&s.mode!=null&&cfg.validModes.indexOf(s.mode)!==-1)?s.mode:cfg.defaultMode;var rm=m==="system"?(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"):m;if(cfg.defaultTheme){d.setAttribute("data-tt-theme",cfg.defaultTheme);}else{d.removeAttribute("data-tt-theme");}d.setAttribute("data-tt-mode",rm);d.style.colorScheme=rm;})()`;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
//#endregion
|
|
179
|
+
Object.defineProperty(exports, 'DATA_MODE_ATTR', {
|
|
180
|
+
enumerable: true,
|
|
181
|
+
get: function () {
|
|
182
|
+
return DATA_MODE_ATTR;
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
Object.defineProperty(exports, 'DATA_THEME_ATTR', {
|
|
186
|
+
enumerable: true,
|
|
187
|
+
get: function () {
|
|
188
|
+
return DATA_THEME_ATTR;
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
Object.defineProperty(exports, 'createThemeRuntime', {
|
|
192
|
+
enumerable: true,
|
|
193
|
+
get: function () {
|
|
194
|
+
return createThemeRuntime;
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
Object.defineProperty(exports, 'getThemeScriptContent', {
|
|
198
|
+
enumerable: true,
|
|
199
|
+
get: function () {
|
|
200
|
+
return getThemeScriptContent;
|
|
201
|
+
}
|
|
202
|
+
});
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
import { n as SAFE_ID_RE } from "./helpers-CaswNJMy.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/themeBootstrap.ts
|
|
5
|
+
/**
|
|
6
|
+
* Reads persisted mode from localStorage and resolves the effective
|
|
7
|
+
* `mode` and `resolvedMode` (never `'system'`).
|
|
8
|
+
*
|
|
9
|
+
* Does **not** touch the DOM — DOM writes are performed by `apply()` inside
|
|
10
|
+
* `createThemeRuntime`, which is the single owner of all attribute mutations.
|
|
11
|
+
*/
|
|
12
|
+
const resolveTheme = cfg => {
|
|
13
|
+
let stored = null;
|
|
14
|
+
try {
|
|
15
|
+
const raw = localStorage.getItem(cfg.storageKey);
|
|
16
|
+
if (raw) stored = JSON.parse(raw);
|
|
17
|
+
} catch {}
|
|
18
|
+
const mode = stored != null && stored.mode != null && cfg.validModes.indexOf(stored.mode) !== -1 ? stored.mode : cfg.defaultMode;
|
|
19
|
+
return {
|
|
20
|
+
mode,
|
|
21
|
+
resolvedMode: mode === "system" ? typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : mode
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/runtime.ts
|
|
27
|
+
const DATA_THEME_ATTR = "data-tt-theme";
|
|
28
|
+
const DATA_MODE_ATTR = "data-tt-mode";
|
|
29
|
+
const DEFAULT_STORAGE_KEY = "tt-theme";
|
|
30
|
+
/** Valid values for the `mode` field. Used to sanitize localStorage input. */
|
|
31
|
+
const VALID_MODES = ["light", "dark", "system"];
|
|
32
|
+
const writeStorage = (key, data) => {
|
|
33
|
+
try {
|
|
34
|
+
localStorage.setItem(key, JSON.stringify(data));
|
|
35
|
+
} catch {}
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Creates a framework-agnostic runtime that manages theme switching.
|
|
39
|
+
*
|
|
40
|
+
* - Sets `data-tt-mode` (and `data-tt-theme` when `defaultTheme` is provided) attributes on the root element.
|
|
41
|
+
* - Updates `style.colorScheme` for native dark/light UI.
|
|
42
|
+
* - Persists `{ mode }` to localStorage.
|
|
43
|
+
* - Listens to `prefers-color-scheme` media query when mode is `'system'`.
|
|
44
|
+
* - Pub/sub pattern for state changes.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* const runtime = createThemeRuntime({ defaultMode: 'dark' });
|
|
49
|
+
* runtime.setMode('system');
|
|
50
|
+
* const unsub = runtime.subscribe(console.log);
|
|
51
|
+
* runtime.destroy();
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
const createThemeRuntime = (config = {}) => {
|
|
55
|
+
const {
|
|
56
|
+
defaultTheme,
|
|
57
|
+
defaultMode = "system",
|
|
58
|
+
storageKey = DEFAULT_STORAGE_KEY,
|
|
59
|
+
root = document.documentElement
|
|
60
|
+
} = config;
|
|
61
|
+
const listeners = /* @__PURE__ */new Set();
|
|
62
|
+
let destroyed = false;
|
|
63
|
+
const init = resolveTheme({
|
|
64
|
+
storageKey,
|
|
65
|
+
defaultMode,
|
|
66
|
+
validModes: VALID_MODES
|
|
67
|
+
});
|
|
68
|
+
let mode = init.mode;
|
|
69
|
+
let resolvedMode = init.resolvedMode;
|
|
70
|
+
const apply = () => {
|
|
71
|
+
if (defaultTheme) root.setAttribute(DATA_THEME_ATTR, defaultTheme);else root.removeAttribute(DATA_THEME_ATTR);
|
|
72
|
+
root.setAttribute(DATA_MODE_ATTR, resolvedMode);
|
|
73
|
+
root.style.colorScheme = resolvedMode;
|
|
74
|
+
};
|
|
75
|
+
const getState = () => {
|
|
76
|
+
return {
|
|
77
|
+
mode,
|
|
78
|
+
resolvedMode
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
apply();
|
|
82
|
+
let prevMode = mode;
|
|
83
|
+
let prevResolvedMode = resolvedMode;
|
|
84
|
+
const applyState = ({
|
|
85
|
+
persist
|
|
86
|
+
}) => {
|
|
87
|
+
if (mode === prevMode && resolvedMode === prevResolvedMode) return;
|
|
88
|
+
prevMode = mode;
|
|
89
|
+
prevResolvedMode = resolvedMode;
|
|
90
|
+
apply();
|
|
91
|
+
if (persist) writeStorage(storageKey, {
|
|
92
|
+
mode
|
|
93
|
+
});
|
|
94
|
+
const state = getState();
|
|
95
|
+
for (const listener of listeners) listener(state);
|
|
96
|
+
};
|
|
97
|
+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
98
|
+
const onSystemChange = () => {
|
|
99
|
+
resolvedMode = mediaQuery.matches ? "dark" : "light";
|
|
100
|
+
applyState({
|
|
101
|
+
persist: false
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
const syncMediaListener = active => {
|
|
105
|
+
mediaQuery.removeEventListener("change", onSystemChange);
|
|
106
|
+
if (active) mediaQuery.addEventListener("change", onSystemChange);
|
|
107
|
+
};
|
|
108
|
+
syncMediaListener(mode === "system");
|
|
109
|
+
const setMode = newMode => {
|
|
110
|
+
if (destroyed || !VALID_MODES.includes(newMode)) return;
|
|
111
|
+
mode = newMode;
|
|
112
|
+
resolvedMode = mode === "system" ? mediaQuery.matches ? "dark" : "light" : mode;
|
|
113
|
+
syncMediaListener(mode === "system");
|
|
114
|
+
applyState({
|
|
115
|
+
persist: true
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
const subscribe = listener => {
|
|
119
|
+
if (destroyed) return () => {};
|
|
120
|
+
listeners.add(listener);
|
|
121
|
+
return () => {
|
|
122
|
+
listeners.delete(listener);
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
const destroy = () => {
|
|
126
|
+
destroyed = true;
|
|
127
|
+
syncMediaListener(false);
|
|
128
|
+
listeners.clear();
|
|
129
|
+
};
|
|
130
|
+
return {
|
|
131
|
+
getState,
|
|
132
|
+
setMode,
|
|
133
|
+
subscribe,
|
|
134
|
+
destroy
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/ssrScript.ts
|
|
140
|
+
/**
|
|
141
|
+
* Returns self-contained JavaScript code that prevents theme flash on SSR/SSG.
|
|
142
|
+
*
|
|
143
|
+
* Insert the returned string into an inline `<script>` tag in the `<head>`,
|
|
144
|
+
* before any stylesheets or the app bundle.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```tsx
|
|
148
|
+
* // Next.js app/layout.tsx
|
|
149
|
+
* import { getThemeScriptContent } from '@ttoss/fsl-theme/runtime';
|
|
150
|
+
*
|
|
151
|
+
* export default function RootLayout({ children }) {
|
|
152
|
+
* return (
|
|
153
|
+
* <html lang="en">
|
|
154
|
+
* <head>
|
|
155
|
+
* <script dangerouslySetInnerHTML={{ __html: getThemeScriptContent() }} />
|
|
156
|
+
* </head>
|
|
157
|
+
* <body>{children}</body>
|
|
158
|
+
* </html>
|
|
159
|
+
* );
|
|
160
|
+
* }
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
const getThemeScriptContent = (config = {}) => {
|
|
164
|
+
const {
|
|
165
|
+
defaultTheme,
|
|
166
|
+
defaultMode = "system",
|
|
167
|
+
storageKey = DEFAULT_STORAGE_KEY
|
|
168
|
+
} = config;
|
|
169
|
+
if (defaultTheme !== void 0 && !SAFE_ID_RE.test(defaultTheme)) throw new Error(`Invalid defaultTheme "${defaultTheme}". Only alphanumeric characters, hyphens, and underscores are allowed.`);
|
|
170
|
+
return `(function(){var cfg=${JSON.stringify({
|
|
171
|
+
storageKey,
|
|
172
|
+
defaultTheme,
|
|
173
|
+
defaultMode,
|
|
174
|
+
validModes: [...VALID_MODES]
|
|
175
|
+
})};var d=document.documentElement;var s=null;try{var r=localStorage.getItem(cfg.storageKey);if(r)s=JSON.parse(r);}catch(e){}var m=(s!=null&&s.mode!=null&&cfg.validModes.indexOf(s.mode)!==-1)?s.mode:cfg.defaultMode;var rm=m==="system"?(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"):m;if(cfg.defaultTheme){d.setAttribute("data-tt-theme",cfg.defaultTheme);}else{d.removeAttribute("data-tt-theme");}d.setAttribute("data-tt-mode",rm);d.style.colorScheme=rm;})()`;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
//#endregion
|
|
179
|
+
export { createThemeRuntime as i, DATA_MODE_ATTR as n, DATA_THEME_ATTR as r, getThemeScriptContent as t };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, {
|
|
3
|
+
value: 'Module'
|
|
4
|
+
});
|
|
5
|
+
const require_createTheme = require('../createTheme-Cv6RP9D6.cjs');
|
|
6
|
+
const require_helpers = require('../helpers-4p4-QVt_.cjs');
|
|
7
|
+
const require_withDataviz = require('../withDataviz-B4pVsOwV.cjs');
|
|
8
|
+
|
|
9
|
+
//#region src/themes/bruttal.ts
|
|
10
|
+
/**
|
|
11
|
+
* Bruttal — warm brown brand palette with a brutalist visual identity.
|
|
12
|
+
*
|
|
13
|
+
* Semantic drift from the default theme:
|
|
14
|
+
* - Sharp corners: `radii.control` and `radii.surface` collapse to `core.radii.none`.
|
|
15
|
+
* - Flat surfaces: every `elevation.surface.*` stratum maps to `core.elevation.level.0`
|
|
16
|
+
* (and to `core.elevation.emphatic.0` in the dark alternate), expressing a brutalist
|
|
17
|
+
* "no shadows" aesthetic in both modes.
|
|
18
|
+
*
|
|
19
|
+
* Brand palette note:
|
|
20
|
+
* - `brand.500` is tuned to `#6D5D4F` (≈7.3:1 on `neutral.0`) so that semantic slots
|
|
21
|
+
* using `brand.500` as a filled background with `neutral.0` text meet WCAG AA Normal.
|
|
22
|
+
*
|
|
23
|
+
* The dark alternate inherits `darkAlternate`'s colour remaps and only overrides
|
|
24
|
+
* `elevation.surface.*` to preserve the flat brutalist identity under dark mode.
|
|
25
|
+
*/
|
|
26
|
+
const bundle = require_createTheme.createTheme({
|
|
27
|
+
overrides: {
|
|
28
|
+
core: {
|
|
29
|
+
colors: {
|
|
30
|
+
brand: {
|
|
31
|
+
50: "#FBF8F5",
|
|
32
|
+
100: "#F3EDE6",
|
|
33
|
+
200: "#E4D7CC",
|
|
34
|
+
300: "#CCBCAE",
|
|
35
|
+
400: "#96836F",
|
|
36
|
+
500: "#6D5D4F",
|
|
37
|
+
600: "#594A3F",
|
|
38
|
+
700: "#4E4239",
|
|
39
|
+
800: "#312921",
|
|
40
|
+
900: "#1A150E"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
semantic: {
|
|
45
|
+
radii: {
|
|
46
|
+
control: "{core.radii.none}",
|
|
47
|
+
surface: "{core.radii.none}"
|
|
48
|
+
},
|
|
49
|
+
elevation: {
|
|
50
|
+
surface: {
|
|
51
|
+
flat: "{core.elevation.level.0}",
|
|
52
|
+
raised: "{core.elevation.level.0}",
|
|
53
|
+
overlay: "{core.elevation.level.0}",
|
|
54
|
+
blocking: "{core.elevation.level.0}"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
alternate: require_helpers.deepMerge(require_createTheme.darkAlternate, {
|
|
60
|
+
semantic: {
|
|
61
|
+
elevation: {
|
|
62
|
+
surface: {
|
|
63
|
+
flat: "{core.elevation.emphatic.0}",
|
|
64
|
+
raised: "{core.elevation.emphatic.0}",
|
|
65
|
+
overlay: "{core.elevation.emphatic.0}",
|
|
66
|
+
blocking: "{core.elevation.emphatic.0}"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
const bruttal = require_withDataviz.withDataviz(bundle);
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
exports.bruttal = bruttal;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
import { i as darkAlternate, n as createTheme } from "../createTheme-BLNYztZU.mjs";
|
|
3
|
+
import { r as deepMerge } from "../helpers-CaswNJMy.mjs";
|
|
4
|
+
import { t as withDataviz } from "../withDataviz-DY5s7R51.mjs";
|
|
5
|
+
|
|
6
|
+
//#region src/themes/bruttal.ts
|
|
7
|
+
/**
|
|
8
|
+
* Bruttal — warm brown brand palette with a brutalist visual identity.
|
|
9
|
+
*
|
|
10
|
+
* Semantic drift from the default theme:
|
|
11
|
+
* - Sharp corners: `radii.control` and `radii.surface` collapse to `core.radii.none`.
|
|
12
|
+
* - Flat surfaces: every `elevation.surface.*` stratum maps to `core.elevation.level.0`
|
|
13
|
+
* (and to `core.elevation.emphatic.0` in the dark alternate), expressing a brutalist
|
|
14
|
+
* "no shadows" aesthetic in both modes.
|
|
15
|
+
*
|
|
16
|
+
* Brand palette note:
|
|
17
|
+
* - `brand.500` is tuned to `#6D5D4F` (≈7.3:1 on `neutral.0`) so that semantic slots
|
|
18
|
+
* using `brand.500` as a filled background with `neutral.0` text meet WCAG AA Normal.
|
|
19
|
+
*
|
|
20
|
+
* The dark alternate inherits `darkAlternate`'s colour remaps and only overrides
|
|
21
|
+
* `elevation.surface.*` to preserve the flat brutalist identity under dark mode.
|
|
22
|
+
*/
|
|
23
|
+
const bundle = createTheme({
|
|
24
|
+
overrides: {
|
|
25
|
+
core: {
|
|
26
|
+
colors: {
|
|
27
|
+
brand: {
|
|
28
|
+
50: "#FBF8F5",
|
|
29
|
+
100: "#F3EDE6",
|
|
30
|
+
200: "#E4D7CC",
|
|
31
|
+
300: "#CCBCAE",
|
|
32
|
+
400: "#96836F",
|
|
33
|
+
500: "#6D5D4F",
|
|
34
|
+
600: "#594A3F",
|
|
35
|
+
700: "#4E4239",
|
|
36
|
+
800: "#312921",
|
|
37
|
+
900: "#1A150E"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
semantic: {
|
|
42
|
+
radii: {
|
|
43
|
+
control: "{core.radii.none}",
|
|
44
|
+
surface: "{core.radii.none}"
|
|
45
|
+
},
|
|
46
|
+
elevation: {
|
|
47
|
+
surface: {
|
|
48
|
+
flat: "{core.elevation.level.0}",
|
|
49
|
+
raised: "{core.elevation.level.0}",
|
|
50
|
+
overlay: "{core.elevation.level.0}",
|
|
51
|
+
blocking: "{core.elevation.level.0}"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
alternate: deepMerge(darkAlternate, {
|
|
57
|
+
semantic: {
|
|
58
|
+
elevation: {
|
|
59
|
+
surface: {
|
|
60
|
+
flat: "{core.elevation.emphatic.0}",
|
|
61
|
+
raised: "{core.elevation.emphatic.0}",
|
|
62
|
+
overlay: "{core.elevation.emphatic.0}",
|
|
63
|
+
blocking: "{core.elevation.emphatic.0}"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
});
|
|
69
|
+
const bruttal = withDataviz(bundle);
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
export { bruttal };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, {
|
|
3
|
+
value: 'Module'
|
|
4
|
+
});
|
|
5
|
+
const require_createTheme = require('../createTheme-Cv6RP9D6.cjs');
|
|
6
|
+
const require_withDataviz = require('../withDataviz-B4pVsOwV.cjs');
|
|
7
|
+
|
|
8
|
+
//#region src/themes/corporate.ts
|
|
9
|
+
const bundle = require_createTheme.createTheme({
|
|
10
|
+
overrides: {
|
|
11
|
+
core: {
|
|
12
|
+
colors: {
|
|
13
|
+
brand: {
|
|
14
|
+
50: "#E3F2FF",
|
|
15
|
+
100: "#B3DAFF",
|
|
16
|
+
200: "#80BFFF",
|
|
17
|
+
300: "#4DA5FF",
|
|
18
|
+
400: "#1A8AFF",
|
|
19
|
+
500: "#0469E3",
|
|
20
|
+
600: "#0352A6",
|
|
21
|
+
700: "#022D66",
|
|
22
|
+
800: "#011923",
|
|
23
|
+
900: "#000000"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
semantic: {}
|
|
28
|
+
},
|
|
29
|
+
alternate: void 0
|
|
30
|
+
});
|
|
31
|
+
const corporate = require_withDataviz.withDataviz(bundle);
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
exports.corporate = corporate;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { n as createTheme } from "../createTheme-BLNYztZU.mjs";
|
|
3
|
+
import { t as withDataviz } from "../withDataviz-DY5s7R51.mjs";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
//#region src/themes/corporate.ts
|
|
6
|
+
const bundle = createTheme({
|
|
7
7
|
overrides: {
|
|
8
8
|
core: {
|
|
9
9
|
colors: {
|
|
@@ -25,5 +25,7 @@ var bundle = createTheme({
|
|
|
25
25
|
},
|
|
26
26
|
alternate: void 0
|
|
27
27
|
});
|
|
28
|
-
|
|
28
|
+
const corporate = withDataviz(bundle);
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
29
31
|
export { corporate };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, {
|
|
3
|
+
value: 'Module'
|
|
4
|
+
});
|
|
5
|
+
const require_createTheme = require('../createTheme-Cv6RP9D6.cjs');
|
|
6
|
+
const require_withDataviz = require('../withDataviz-B4pVsOwV.cjs');
|
|
7
|
+
|
|
8
|
+
//#region src/themes/oca.ts
|
|
9
|
+
const bundle = require_createTheme.createTheme({
|
|
10
|
+
overrides: {
|
|
11
|
+
core: {
|
|
12
|
+
colors: {
|
|
13
|
+
brand: {
|
|
14
|
+
50: "#F5FBEA",
|
|
15
|
+
100: "#E4F6C2",
|
|
16
|
+
200: "#CAED8A",
|
|
17
|
+
300: "#ABDF4E",
|
|
18
|
+
400: "#8ECE1F",
|
|
19
|
+
500: "#6DB800",
|
|
20
|
+
600: "#549100",
|
|
21
|
+
700: "#3C6A00",
|
|
22
|
+
800: "#254300",
|
|
23
|
+
900: "#111F00"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
semantic: {}
|
|
28
|
+
},
|
|
29
|
+
alternate: void 0
|
|
30
|
+
});
|
|
31
|
+
const oca = require_withDataviz.withDataviz(bundle);
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
exports.oca = oca;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { n as createTheme } from "../createTheme-BLNYztZU.mjs";
|
|
3
|
+
import { t as withDataviz } from "../withDataviz-DY5s7R51.mjs";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
//#region src/themes/oca.ts
|
|
6
|
+
const bundle = createTheme({
|
|
7
7
|
overrides: {
|
|
8
8
|
core: {
|
|
9
9
|
colors: {
|
|
@@ -25,5 +25,7 @@ var bundle = createTheme({
|
|
|
25
25
|
},
|
|
26
26
|
alternate: void 0
|
|
27
27
|
});
|
|
28
|
-
|
|
28
|
+
const oca = withDataviz(bundle);
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
29
31
|
export { oca };
|