@ttoss/fsl-theme 1.1.11
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/LICENSE +21 -0
- package/README.md +390 -0
- package/dist/Types-6tR0_2Ss.d.ts +1452 -0
- package/dist/css.d.ts +164 -0
- package/dist/dataviz/index.d.ts +62 -0
- package/dist/dtcg.d.ts +49 -0
- package/dist/esm/chunk-4Q4P3JBB.js +185 -0
- package/dist/esm/chunk-5PWPAQMC.js +9 -0
- package/dist/esm/chunk-BXKVVQEP.js +29 -0
- package/dist/esm/chunk-DU4QDQUC.js +29 -0
- package/dist/esm/chunk-FBVUI2PK.js +147 -0
- package/dist/esm/chunk-HRNXVRS3.js +54 -0
- package/dist/esm/chunk-IJGA42O6.js +141 -0
- package/dist/esm/chunk-PQPQNZ73.js +262 -0
- package/dist/esm/chunk-SE5Z52RE.js +1898 -0
- package/dist/esm/chunk-TPMN75JM.js +29 -0
- package/dist/esm/chunk-UMRQ4OTX.js +11 -0
- package/dist/esm/chunk-VL6EGE6Z.js +222 -0
- package/dist/esm/chunk-WVQSTQD5.js +192 -0
- package/dist/esm/css.js +6 -0
- package/dist/esm/dataviz/index.js +19 -0
- package/dist/esm/dtcg.js +65 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/react.js +8 -0
- package/dist/esm/runtime-entry.js +4 -0
- package/dist/esm/themes/bruttal.js +6 -0
- package/dist/esm/themes/corporate.js +6 -0
- package/dist/esm/themes/oca.js +6 -0
- package/dist/esm/themes/ventures.js +6 -0
- package/dist/esm/vars.js +28 -0
- package/dist/index.d.ts +86 -0
- package/dist/react.d.ts +346 -0
- package/dist/runtime-entry.d.ts +95 -0
- package/dist/themes/bruttal.d.ts +5 -0
- package/dist/themes/corporate.d.ts +5 -0
- package/dist/themes/oca.d.ts +5 -0
- package/dist/themes/ventures.d.ts +5 -0
- package/dist/vars.d.ts +127 -0
- package/llms.txt +731 -0
- package/package.json +88 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
import { withDataviz } from "./chunk-FBVUI2PK.js";
|
|
3
|
+
import { createTheme, darkAlternate } from "./chunk-SE5Z52RE.js";
|
|
4
|
+
import { deepMerge } from "./chunk-WVQSTQD5.js";
|
|
5
|
+
|
|
6
|
+
// src/themes/bruttal.ts
|
|
7
|
+
var bundle = createTheme({
|
|
8
|
+
overrides: {
|
|
9
|
+
core: {
|
|
10
|
+
colors: {
|
|
11
|
+
brand: {
|
|
12
|
+
50: "#FBF8F5",
|
|
13
|
+
100: "#F3EDE6",
|
|
14
|
+
200: "#E4D7CC",
|
|
15
|
+
300: "#CCBCAE",
|
|
16
|
+
400: "#96836F",
|
|
17
|
+
500: "#6D5D4F",
|
|
18
|
+
600: "#594A3F",
|
|
19
|
+
700: "#4E4239",
|
|
20
|
+
800: "#312921",
|
|
21
|
+
900: "#1A150E"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
semantic: {
|
|
26
|
+
radii: {
|
|
27
|
+
control: "{core.radii.none}",
|
|
28
|
+
surface: "{core.radii.none}"
|
|
29
|
+
},
|
|
30
|
+
elevation: {
|
|
31
|
+
surface: {
|
|
32
|
+
flat: "{core.elevation.level.0}",
|
|
33
|
+
raised: "{core.elevation.level.0}",
|
|
34
|
+
overlay: "{core.elevation.level.0}",
|
|
35
|
+
blocking: "{core.elevation.level.0}"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
alternate: deepMerge(darkAlternate, {
|
|
41
|
+
semantic: {
|
|
42
|
+
elevation: {
|
|
43
|
+
surface: {
|
|
44
|
+
flat: "{core.elevation.emphatic.0}",
|
|
45
|
+
raised: "{core.elevation.emphatic.0}",
|
|
46
|
+
overlay: "{core.elevation.emphatic.0}",
|
|
47
|
+
blocking: "{core.elevation.emphatic.0}"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
});
|
|
53
|
+
var bruttal = withDataviz(bundle);
|
|
54
|
+
export { bruttal };
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
import { SAFE_ID_RE, __name } from "./chunk-WVQSTQD5.js";
|
|
3
|
+
|
|
4
|
+
// src/themeBootstrap.ts
|
|
5
|
+
var resolveTheme = /* @__PURE__ */__name(cfg => {
|
|
6
|
+
let stored = null;
|
|
7
|
+
try {
|
|
8
|
+
const raw = localStorage.getItem(cfg.storageKey);
|
|
9
|
+
if (raw) stored = JSON.parse(raw);
|
|
10
|
+
} catch {}
|
|
11
|
+
const mode = stored != null && stored.mode != null && cfg.validModes.indexOf(stored.mode) !== -1 ? stored.mode : cfg.defaultMode;
|
|
12
|
+
const resolvedMode = mode === "system" ? typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : mode;
|
|
13
|
+
return {
|
|
14
|
+
mode,
|
|
15
|
+
resolvedMode
|
|
16
|
+
};
|
|
17
|
+
}, "resolveTheme");
|
|
18
|
+
|
|
19
|
+
// src/runtime.ts
|
|
20
|
+
var DATA_THEME_ATTR = "data-tt-theme";
|
|
21
|
+
var DATA_MODE_ATTR = "data-tt-mode";
|
|
22
|
+
var DEFAULT_STORAGE_KEY = "tt-theme";
|
|
23
|
+
var VALID_MODES = ["light", "dark", "system"];
|
|
24
|
+
var writeStorage = /* @__PURE__ */__name((key, data) => {
|
|
25
|
+
try {
|
|
26
|
+
localStorage.setItem(key, JSON.stringify(data));
|
|
27
|
+
} catch {}
|
|
28
|
+
}, "writeStorage");
|
|
29
|
+
var createThemeRuntime = /* @__PURE__ */__name((config = {}) => {
|
|
30
|
+
const {
|
|
31
|
+
defaultTheme,
|
|
32
|
+
defaultMode = "system",
|
|
33
|
+
storageKey = DEFAULT_STORAGE_KEY,
|
|
34
|
+
root = document.documentElement
|
|
35
|
+
} = config;
|
|
36
|
+
const listeners = /* @__PURE__ */new Set();
|
|
37
|
+
let destroyed = false;
|
|
38
|
+
const init = resolveTheme({
|
|
39
|
+
storageKey,
|
|
40
|
+
defaultMode,
|
|
41
|
+
validModes: VALID_MODES
|
|
42
|
+
});
|
|
43
|
+
let mode = init.mode;
|
|
44
|
+
let resolvedMode = init.resolvedMode;
|
|
45
|
+
const apply = /* @__PURE__ */__name(() => {
|
|
46
|
+
if (defaultTheme) {
|
|
47
|
+
root.setAttribute(DATA_THEME_ATTR, defaultTheme);
|
|
48
|
+
} else {
|
|
49
|
+
root.removeAttribute(DATA_THEME_ATTR);
|
|
50
|
+
}
|
|
51
|
+
root.setAttribute(DATA_MODE_ATTR, resolvedMode);
|
|
52
|
+
root.style.colorScheme = resolvedMode;
|
|
53
|
+
}, "apply");
|
|
54
|
+
const getState = /* @__PURE__ */__name(() => {
|
|
55
|
+
return {
|
|
56
|
+
mode,
|
|
57
|
+
resolvedMode
|
|
58
|
+
};
|
|
59
|
+
}, "getState");
|
|
60
|
+
apply();
|
|
61
|
+
let prevMode = mode;
|
|
62
|
+
let prevResolvedMode = resolvedMode;
|
|
63
|
+
const applyState = /* @__PURE__ */__name(({
|
|
64
|
+
persist
|
|
65
|
+
}) => {
|
|
66
|
+
if (mode === prevMode && resolvedMode === prevResolvedMode) return;
|
|
67
|
+
prevMode = mode;
|
|
68
|
+
prevResolvedMode = resolvedMode;
|
|
69
|
+
apply();
|
|
70
|
+
if (persist) writeStorage(storageKey, {
|
|
71
|
+
mode
|
|
72
|
+
});
|
|
73
|
+
const state = getState();
|
|
74
|
+
for (const listener of listeners) listener(state);
|
|
75
|
+
}, "applyState");
|
|
76
|
+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
77
|
+
const onSystemChange = /* @__PURE__ */__name(() => {
|
|
78
|
+
resolvedMode = mediaQuery.matches ? "dark" : "light";
|
|
79
|
+
applyState({
|
|
80
|
+
persist: false
|
|
81
|
+
});
|
|
82
|
+
}, "onSystemChange");
|
|
83
|
+
const syncMediaListener = /* @__PURE__ */__name(active => {
|
|
84
|
+
mediaQuery.removeEventListener("change", onSystemChange);
|
|
85
|
+
if (active) {
|
|
86
|
+
mediaQuery.addEventListener("change", onSystemChange);
|
|
87
|
+
}
|
|
88
|
+
}, "syncMediaListener");
|
|
89
|
+
syncMediaListener(mode === "system");
|
|
90
|
+
const setMode = /* @__PURE__ */__name(newMode => {
|
|
91
|
+
if (destroyed || !VALID_MODES.includes(newMode)) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
mode = newMode;
|
|
95
|
+
resolvedMode = mode === "system" ? mediaQuery.matches ? "dark" : "light" : mode;
|
|
96
|
+
syncMediaListener(mode === "system");
|
|
97
|
+
applyState({
|
|
98
|
+
persist: true
|
|
99
|
+
});
|
|
100
|
+
}, "setMode");
|
|
101
|
+
const subscribe = /* @__PURE__ */__name(listener => {
|
|
102
|
+
if (destroyed) {
|
|
103
|
+
return () => {};
|
|
104
|
+
}
|
|
105
|
+
listeners.add(listener);
|
|
106
|
+
return () => {
|
|
107
|
+
listeners.delete(listener);
|
|
108
|
+
};
|
|
109
|
+
}, "subscribe");
|
|
110
|
+
const destroy = /* @__PURE__ */__name(() => {
|
|
111
|
+
destroyed = true;
|
|
112
|
+
syncMediaListener(false);
|
|
113
|
+
listeners.clear();
|
|
114
|
+
}, "destroy");
|
|
115
|
+
return {
|
|
116
|
+
getState,
|
|
117
|
+
setMode,
|
|
118
|
+
subscribe,
|
|
119
|
+
destroy
|
|
120
|
+
};
|
|
121
|
+
}, "createThemeRuntime");
|
|
122
|
+
|
|
123
|
+
// src/ssrScript.ts
|
|
124
|
+
var getThemeScriptContent = /* @__PURE__ */__name((config = {}) => {
|
|
125
|
+
const {
|
|
126
|
+
defaultTheme,
|
|
127
|
+
defaultMode = "system",
|
|
128
|
+
storageKey = DEFAULT_STORAGE_KEY
|
|
129
|
+
} = config;
|
|
130
|
+
if (defaultTheme !== void 0 && !SAFE_ID_RE.test(defaultTheme)) {
|
|
131
|
+
throw new Error(`Invalid defaultTheme "${defaultTheme}". Only alphanumeric characters, hyphens, and underscores are allowed.`);
|
|
132
|
+
}
|
|
133
|
+
const cfg = JSON.stringify({
|
|
134
|
+
storageKey,
|
|
135
|
+
defaultTheme,
|
|
136
|
+
defaultMode,
|
|
137
|
+
validModes: [...VALID_MODES]
|
|
138
|
+
});
|
|
139
|
+
return `(function(){var cfg=${cfg};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;})()`;
|
|
140
|
+
}, "getThemeScriptContent");
|
|
141
|
+
export { DATA_THEME_ATTR, DATA_MODE_ATTR, createThemeRuntime, getThemeScriptContent };
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
import { CSS_PATH_PREFIXES } from "./chunk-4Q4P3JBB.js";
|
|
3
|
+
import { COMPOUND_REF_RE, SAFE_ID_RE, __name, deepMerge, flattenObject, flattenTheme } from "./chunk-WVQSTQD5.js";
|
|
4
|
+
|
|
5
|
+
// src/roots/toCssVars.ts
|
|
6
|
+
var toCssVarName = /* @__PURE__ */__name(tokenPath => {
|
|
7
|
+
for (const [prefix, cssPrefix] of CSS_PATH_PREFIXES) {
|
|
8
|
+
if (tokenPath.startsWith(prefix)) {
|
|
9
|
+
const rest = tokenPath.slice(prefix.length).replace(/\./g, "-");
|
|
10
|
+
return `${cssPrefix}${rest}`;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return `--tt-${tokenPath.replace(/\./g, "-")}`;
|
|
14
|
+
}, "toCssVarName");
|
|
15
|
+
var inlineRefsToVars = /* @__PURE__ */__name(value => {
|
|
16
|
+
return value.replace(COMPOUND_REF_RE, (_match, path) => {
|
|
17
|
+
return `var(${toCssVarName(path)})`;
|
|
18
|
+
});
|
|
19
|
+
}, "inlineRefsToVars");
|
|
20
|
+
var buildCssVars = /* @__PURE__ */__name(theme => {
|
|
21
|
+
const vars = {};
|
|
22
|
+
const {
|
|
23
|
+
core: coreFlat,
|
|
24
|
+
semantic: semanticFlat
|
|
25
|
+
} = flattenTheme(theme);
|
|
26
|
+
for (const [path, value] of Object.entries(coreFlat)) {
|
|
27
|
+
vars[toCssVarName(path)] = value;
|
|
28
|
+
}
|
|
29
|
+
for (const [path, value] of Object.entries(semanticFlat)) {
|
|
30
|
+
const varName = toCssVarName(path);
|
|
31
|
+
if (typeof value === "string" && value.includes("{")) {
|
|
32
|
+
vars[varName] = inlineRefsToVars(value);
|
|
33
|
+
} else {
|
|
34
|
+
vars[varName] = value;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return vars;
|
|
38
|
+
}, "buildCssVars");
|
|
39
|
+
var sanitizeId = /* @__PURE__ */__name(value => {
|
|
40
|
+
if (!SAFE_ID_RE.test(value)) {
|
|
41
|
+
throw new Error(`Invalid themeId "${value}". Only alphanumeric characters, hyphens, and underscores are allowed.`);
|
|
42
|
+
}
|
|
43
|
+
return value;
|
|
44
|
+
}, "sanitizeId");
|
|
45
|
+
var buildSelector = /* @__PURE__ */__name(({
|
|
46
|
+
themeId,
|
|
47
|
+
mode,
|
|
48
|
+
selector
|
|
49
|
+
}) => {
|
|
50
|
+
if (selector) {
|
|
51
|
+
return selector;
|
|
52
|
+
}
|
|
53
|
+
if (!themeId) {
|
|
54
|
+
return mode ? `:root[data-tt-mode="${mode}"]` : ":root";
|
|
55
|
+
}
|
|
56
|
+
let s = `[data-tt-theme="${sanitizeId(themeId)}"]`;
|
|
57
|
+
if (mode) {
|
|
58
|
+
s += `[data-tt-mode="${mode}"]`;
|
|
59
|
+
}
|
|
60
|
+
return s;
|
|
61
|
+
}, "buildSelector");
|
|
62
|
+
var CQ_UNIT_RE = /cq(?:i|b|w|h|min|max)(?![a-z])/i;
|
|
63
|
+
var hasCqUnits = /* @__PURE__ */__name(value => {
|
|
64
|
+
return typeof value === "string" && CQ_UNIT_RE.test(value);
|
|
65
|
+
}, "hasCqUnits");
|
|
66
|
+
var toViewportFallback = /* @__PURE__ */__name(value => {
|
|
67
|
+
return value.replace(/cqmin(?![a-z])/gi, "vmin").replace(/cqmax(?![a-z])/gi, "vmax").replace(/cqi(?![a-z])/gi, "vw").replace(/cqb(?![a-z])/gi, "vh").replace(/cqw(?![a-z])/gi, "vw").replace(/cqh(?![a-z])/gi, "vh");
|
|
68
|
+
}, "toViewportFallback");
|
|
69
|
+
var extractContainerQueryVars = /* @__PURE__ */__name(vars => {
|
|
70
|
+
const cqVars = {};
|
|
71
|
+
for (const [name, value] of Object.entries(vars)) {
|
|
72
|
+
if (hasCqUnits(value)) {
|
|
73
|
+
cqVars[name] = value;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return cqVars;
|
|
77
|
+
}, "extractContainerQueryVars");
|
|
78
|
+
var buildReducedMotionVars = /* @__PURE__ */__name(theme => {
|
|
79
|
+
const noneVar = `var(${toCssVarName("core.motion.duration.none")})`;
|
|
80
|
+
const flat = flattenObject(theme.semantic.motion, "semantic.motion");
|
|
81
|
+
const vars = {};
|
|
82
|
+
for (const path of Object.keys(flat)) {
|
|
83
|
+
if (path.endsWith(".duration")) {
|
|
84
|
+
vars[toCssVarName(path)] = noneVar;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return vars;
|
|
88
|
+
}, "buildReducedMotionVars");
|
|
89
|
+
var buildCoarseHitVars = /* @__PURE__ */__name(theme => {
|
|
90
|
+
const vars = {};
|
|
91
|
+
for (const [key, value] of Object.entries(theme.core.sizing.hit.coarse)) {
|
|
92
|
+
if (typeof value === "string") {
|
|
93
|
+
vars[toCssVarName(`semantic.sizing.hit.${key}`)] = value;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return vars;
|
|
97
|
+
}, "buildCoarseHitVars");
|
|
98
|
+
var buildCssBlock = /* @__PURE__ */__name(({
|
|
99
|
+
selector,
|
|
100
|
+
vars,
|
|
101
|
+
containerQueryVars,
|
|
102
|
+
coarseHitVars,
|
|
103
|
+
reducedMotionVars,
|
|
104
|
+
colorScheme
|
|
105
|
+
}) => {
|
|
106
|
+
const varLines = /* @__PURE__ */__name(v => {
|
|
107
|
+
return Object.entries(v).map(([name, val]) => {
|
|
108
|
+
return ` ${name}: ${val};`;
|
|
109
|
+
});
|
|
110
|
+
}, "varLines");
|
|
111
|
+
const atRuleBlock = /* @__PURE__ */__name((atRule, v) => {
|
|
112
|
+
const lines = varLines(v);
|
|
113
|
+
return lines.length > 0 ? `${atRule} {
|
|
114
|
+
${selector} {
|
|
115
|
+
${lines.join("\n")}
|
|
116
|
+
}
|
|
117
|
+
}` : "";
|
|
118
|
+
}, "atRuleBlock");
|
|
119
|
+
const baseLines = [];
|
|
120
|
+
if (colorScheme) {
|
|
121
|
+
baseLines.push(` color-scheme: ${colorScheme};`);
|
|
122
|
+
}
|
|
123
|
+
for (const [name, value] of Object.entries(vars)) {
|
|
124
|
+
if (hasCqUnits(value)) {
|
|
125
|
+
baseLines.push(` ${name}: ${toViewportFallback(String(value))};`);
|
|
126
|
+
} else {
|
|
127
|
+
baseLines.push(` ${name}: ${value};`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const baseBlock = `${selector} {
|
|
131
|
+
${baseLines.join("\n")}
|
|
132
|
+
}`;
|
|
133
|
+
const cqContent = atRuleBlock("@supports (width: 1cqi)", containerQueryVars);
|
|
134
|
+
const cqBlock = cqContent ? `
|
|
135
|
+
|
|
136
|
+
${cqContent}` : "";
|
|
137
|
+
const coarseBlock = atRuleBlock("@media (any-pointer: coarse)", coarseHitVars);
|
|
138
|
+
const reducedMotionBlock = atRuleBlock("@media (prefers-reduced-motion: reduce)", reducedMotionVars);
|
|
139
|
+
return [baseBlock + cqBlock, coarseBlock, reducedMotionBlock].filter(Boolean).join("\n\n");
|
|
140
|
+
}, "buildCssBlock");
|
|
141
|
+
var toCssVarsBase = /* @__PURE__ */__name((theme, options = {}) => {
|
|
142
|
+
const cssVars = buildCssVars(theme);
|
|
143
|
+
const coarseHitVars = buildCoarseHitVars(theme);
|
|
144
|
+
const reducedMotionVars = buildReducedMotionVars(theme);
|
|
145
|
+
const containerQueryVars = extractContainerQueryVars(cssVars);
|
|
146
|
+
const selector = buildSelector(options);
|
|
147
|
+
const {
|
|
148
|
+
colorScheme,
|
|
149
|
+
mode
|
|
150
|
+
} = options;
|
|
151
|
+
const effectiveColorScheme = colorScheme ?? mode;
|
|
152
|
+
return {
|
|
153
|
+
cssVars,
|
|
154
|
+
coarseHitVars,
|
|
155
|
+
reducedMotionVars,
|
|
156
|
+
containerQueryVars,
|
|
157
|
+
selector,
|
|
158
|
+
toCssString: /* @__PURE__ */__name(() => {
|
|
159
|
+
return buildCssBlock({
|
|
160
|
+
selector,
|
|
161
|
+
vars: cssVars,
|
|
162
|
+
containerQueryVars,
|
|
163
|
+
coarseHitVars,
|
|
164
|
+
reducedMotionVars,
|
|
165
|
+
colorScheme: effectiveColorScheme
|
|
166
|
+
});
|
|
167
|
+
}, "toCssString")
|
|
168
|
+
};
|
|
169
|
+
}, "toCssVarsBase");
|
|
170
|
+
var isThemeBundle = /* @__PURE__ */__name(input => {
|
|
171
|
+
return "baseMode" in input && "base" in input;
|
|
172
|
+
}, "isThemeBundle");
|
|
173
|
+
var diffCssVars = /* @__PURE__ */__name(({
|
|
174
|
+
base,
|
|
175
|
+
full
|
|
176
|
+
}) => {
|
|
177
|
+
const diff = {};
|
|
178
|
+
for (const [key, value] of Object.entries(full)) {
|
|
179
|
+
if (base[key] !== value) {
|
|
180
|
+
diff[key] = value;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return diff;
|
|
184
|
+
}, "diffCssVars");
|
|
185
|
+
var bundleToCssVars = /* @__PURE__ */__name((bundle, options) => {
|
|
186
|
+
const {
|
|
187
|
+
themeId
|
|
188
|
+
} = options;
|
|
189
|
+
const {
|
|
190
|
+
baseMode,
|
|
191
|
+
base: baseTheme,
|
|
192
|
+
alternate
|
|
193
|
+
} = bundle;
|
|
194
|
+
const alternateMode = baseMode === "light" ? "dark" : "light";
|
|
195
|
+
const baseResult = toCssVarsBase(baseTheme, {
|
|
196
|
+
themeId,
|
|
197
|
+
colorScheme: baseMode
|
|
198
|
+
});
|
|
199
|
+
if (!alternate) {
|
|
200
|
+
return {
|
|
201
|
+
base: baseResult,
|
|
202
|
+
toCssString: /* @__PURE__ */__name(() => {
|
|
203
|
+
return baseResult.toCssString();
|
|
204
|
+
}, "toCssString")
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
const alternateTheme = {
|
|
208
|
+
core: baseTheme.core,
|
|
209
|
+
semantic: deepMerge(baseTheme.semantic, alternate.semantic)
|
|
210
|
+
};
|
|
211
|
+
const fullAlternateVars = buildCssVars(alternateTheme);
|
|
212
|
+
const diffVars = diffCssVars({
|
|
213
|
+
base: baseResult.cssVars,
|
|
214
|
+
full: fullAlternateVars
|
|
215
|
+
});
|
|
216
|
+
const alternateSelector = buildSelector({
|
|
217
|
+
themeId,
|
|
218
|
+
mode: alternateMode
|
|
219
|
+
});
|
|
220
|
+
const altCoarseHitVars = {};
|
|
221
|
+
const altReducedMotionVars = diffCssVars({
|
|
222
|
+
base: baseResult.reducedMotionVars,
|
|
223
|
+
full: buildReducedMotionVars(alternateTheme)
|
|
224
|
+
});
|
|
225
|
+
const altContainerQueryVars = extractContainerQueryVars(diffVars);
|
|
226
|
+
const alternateResult = {
|
|
227
|
+
cssVars: diffVars,
|
|
228
|
+
coarseHitVars: altCoarseHitVars,
|
|
229
|
+
reducedMotionVars: altReducedMotionVars,
|
|
230
|
+
containerQueryVars: altContainerQueryVars,
|
|
231
|
+
selector: alternateSelector,
|
|
232
|
+
toCssString: /* @__PURE__ */__name(() => {
|
|
233
|
+
return buildCssBlock({
|
|
234
|
+
selector: alternateSelector,
|
|
235
|
+
vars: diffVars,
|
|
236
|
+
containerQueryVars: altContainerQueryVars,
|
|
237
|
+
coarseHitVars: altCoarseHitVars,
|
|
238
|
+
reducedMotionVars: altReducedMotionVars,
|
|
239
|
+
colorScheme: alternateMode
|
|
240
|
+
});
|
|
241
|
+
}, "toCssString")
|
|
242
|
+
};
|
|
243
|
+
return {
|
|
244
|
+
base: baseResult,
|
|
245
|
+
alternate: alternateResult,
|
|
246
|
+
toCssString: /* @__PURE__ */__name(() => {
|
|
247
|
+
const parts = [baseResult.toCssString()];
|
|
248
|
+
if (Object.keys(diffVars).length > 0) {
|
|
249
|
+
parts.push(alternateResult.toCssString());
|
|
250
|
+
}
|
|
251
|
+
return parts.join("\n\n");
|
|
252
|
+
}, "toCssString")
|
|
253
|
+
};
|
|
254
|
+
}, "bundleToCssVars");
|
|
255
|
+
function toCssVars(input, options) {
|
|
256
|
+
if (isThemeBundle(input)) {
|
|
257
|
+
return bundleToCssVars(input, options ?? {});
|
|
258
|
+
}
|
|
259
|
+
return toCssVarsBase(input, options);
|
|
260
|
+
}
|
|
261
|
+
__name(toCssVars, "toCssVars");
|
|
262
|
+
export { toCssVarName, toCssVars };
|