@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,211 @@
|
|
|
1
|
+
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
//#region src/roots/helpers.ts
|
|
3
|
+
/** Check if a value is a token reference like `{core.colors.brand.500}` */
|
|
4
|
+
const isTokenRef = value => {
|
|
5
|
+
return typeof value === "string" && value.length > 2 && value.startsWith("{") && value.endsWith("}");
|
|
6
|
+
};
|
|
7
|
+
/** Extract the inner path from a token reference: `{core.colors.brand.500}` → `core.colors.brand.500` */
|
|
8
|
+
const extractRefPath = ref => {
|
|
9
|
+
return ref.slice(1, -1);
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Allowed characters for a theme identifier: alphanumeric, hyphens, underscores.
|
|
13
|
+
* Shared between toCssVars (CSS selector injection guard) and ssrScript (SSR inline script).
|
|
14
|
+
* A single definition prevents the two validation paths from silently diverging.
|
|
15
|
+
*/
|
|
16
|
+
const SAFE_ID_RE = /^[a-zA-Z0-9_-]+$/;
|
|
17
|
+
/**
|
|
18
|
+
* Matches every `{token.path}` reference embedded in a string value.
|
|
19
|
+
* Shared between helpers.ts (toFlatTokens) and toCssVars.ts (inlineRefsToVars)
|
|
20
|
+
* so a single definition governs the `{…}` syntax in both resolution paths.
|
|
21
|
+
*/
|
|
22
|
+
const COMPOUND_REF_RE = /\{([^}]+)\}/g;
|
|
23
|
+
const isPlainObject = value => {
|
|
24
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Recursively merges `overrides` into `base`.
|
|
28
|
+
* - Plain objects are merged recursively.
|
|
29
|
+
* - All other values (primitives, arrays) are replaced.
|
|
30
|
+
*/
|
|
31
|
+
const deepMerge = (base, overrides) => {
|
|
32
|
+
if (!isPlainObject(base) || !isPlainObject(overrides)) return overrides ?? base;
|
|
33
|
+
const result = {
|
|
34
|
+
...base
|
|
35
|
+
};
|
|
36
|
+
for (const key of Object.keys(overrides)) {
|
|
37
|
+
const baseVal = result[key];
|
|
38
|
+
const overVal = overrides[key];
|
|
39
|
+
if (overVal === void 0) continue;
|
|
40
|
+
if (isPlainObject(baseVal) && isPlainObject(overVal)) result[key] = deepMerge(baseVal, overVal);else result[key] = overVal;
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Flatten a nested object into a flat record with dot-separated keys.
|
|
46
|
+
*
|
|
47
|
+
* `{ brand: { 500: '#0469E3' } }` → `{ 'brand.500': '#0469E3' }`
|
|
48
|
+
*/
|
|
49
|
+
const flattenObject = (obj, prefix = "") => {
|
|
50
|
+
const result = {};
|
|
51
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
52
|
+
const fullKey = prefix ? `${prefix}.${key}` : key;
|
|
53
|
+
if (isPlainObject(value)) Object.assign(result, flattenObject(value, fullKey));else if (typeof value === "string" || typeof value === "number") result[fullKey] = value;
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Flatten a `ThemeTokens` into separate `{ core, semantic }` flat records
|
|
59
|
+
* with dot-separated keys. Centralizes the unsafe casts needed to traverse
|
|
60
|
+
* the opaque token trees.
|
|
61
|
+
*
|
|
62
|
+
* Used by both `toFlatTokens` (resolution) and `buildCssVars` (CSS emission)
|
|
63
|
+
* so the casts live in exactly one place.
|
|
64
|
+
*/
|
|
65
|
+
const flattenTheme = theme => {
|
|
66
|
+
return {
|
|
67
|
+
core: flattenObject(theme.core, "core"),
|
|
68
|
+
semantic: flattenObject(theme.semantic, "semantic")
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Compute the Levenshtein edit distance between two strings.
|
|
73
|
+
* Used exclusively by `validateRefs` to power "did you mean?" suggestions.
|
|
74
|
+
*/
|
|
75
|
+
const levenshtein = (a, b) => {
|
|
76
|
+
const m = a.length;
|
|
77
|
+
const n = b.length;
|
|
78
|
+
const dp = Array.from({
|
|
79
|
+
length: m + 1
|
|
80
|
+
}, () => {
|
|
81
|
+
return Array.from({
|
|
82
|
+
length: n + 1
|
|
83
|
+
}, () => {
|
|
84
|
+
return 0;
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
for (let i = 0; i <= m; i++) dp[i][0] = i;
|
|
88
|
+
for (let j = 0; j <= n; j++) dp[0][j] = j;
|
|
89
|
+
for (let i = 1; i <= m; i++) for (let j = 1; j <= n; j++) dp[i][j] = a[i - 1] === b[j - 1] ? dp[i - 1][j - 1] : 1 + Math.min(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1]);
|
|
90
|
+
return dp[m][n];
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Validate that every `{ref}` in the merged theme points to an existing path.
|
|
94
|
+
* Emits `console.warn` for each broken reference with a "did you mean?" suggestion.
|
|
95
|
+
*
|
|
96
|
+
* **DEV-only** — callers gate this behind `process.env.NODE_ENV !== 'production'`
|
|
97
|
+
* so bundlers tree-shake the entire call in production builds.
|
|
98
|
+
*/
|
|
99
|
+
const validateRefs = theme => {
|
|
100
|
+
const {
|
|
101
|
+
core,
|
|
102
|
+
semantic
|
|
103
|
+
} = flattenTheme(theme);
|
|
104
|
+
const all = {
|
|
105
|
+
...core,
|
|
106
|
+
...semantic
|
|
107
|
+
};
|
|
108
|
+
const allKeys = Object.keys(all);
|
|
109
|
+
const findSuggestion = (refPath, candidates) => {
|
|
110
|
+
if (candidates.length === 0) return "";
|
|
111
|
+
let bestDist = Infinity;
|
|
112
|
+
let bestKey = "";
|
|
113
|
+
for (const candidate of candidates) {
|
|
114
|
+
const dist = levenshtein(refPath, candidate);
|
|
115
|
+
if (dist < bestDist) {
|
|
116
|
+
bestDist = dist;
|
|
117
|
+
bestKey = candidate;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (bestDist <= Math.ceil(refPath.length * .4)) return `\n Did you mean '{${bestKey}}'?`;
|
|
121
|
+
return "";
|
|
122
|
+
};
|
|
123
|
+
for (const [ownerKey, value] of Object.entries(all)) {
|
|
124
|
+
if (typeof value !== "string" || !value.includes("{")) continue;
|
|
125
|
+
let match;
|
|
126
|
+
const re = new RegExp(COMPOUND_REF_RE.source, COMPOUND_REF_RE.flags);
|
|
127
|
+
while ((match = re.exec(value)) !== null) {
|
|
128
|
+
const refPath = match[1];
|
|
129
|
+
if (all[refPath] !== void 0) continue;
|
|
130
|
+
const prefix = refPath.split(".")[0];
|
|
131
|
+
const suggestion = findSuggestion(refPath, allKeys.filter(k => {
|
|
132
|
+
return k.startsWith(prefix + ".");
|
|
133
|
+
}));
|
|
134
|
+
console.warn(`[fsl-theme] Invalid token reference '{${refPath}}' at path '${ownerKey}'.${suggestion}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Flatten a `ThemeTokens` into a `Record<string, string | number>` with
|
|
140
|
+
* every `{ref}` recursively resolved to its final raw value where possible.
|
|
141
|
+
*
|
|
142
|
+
* By default, unresolvable references (missing target or circular dependency)
|
|
143
|
+
* are preserved as-is in the output. Pass `{ strict: true }` to instead throw
|
|
144
|
+
* on any unresolved reference — useful in tests and build steps that must
|
|
145
|
+
* fail loudly on palette drift.
|
|
146
|
+
*
|
|
147
|
+
* This is the universal primitive — every root is derived from this.
|
|
148
|
+
*/
|
|
149
|
+
const toFlatTokens = (theme, options = {}) => {
|
|
150
|
+
const {
|
|
151
|
+
strict = false
|
|
152
|
+
} = options;
|
|
153
|
+
const {
|
|
154
|
+
core: coreFlat,
|
|
155
|
+
semantic: semanticFlat
|
|
156
|
+
} = flattenTheme(theme);
|
|
157
|
+
const all = {
|
|
158
|
+
...coreFlat,
|
|
159
|
+
...semanticFlat
|
|
160
|
+
};
|
|
161
|
+
const unresolved = [];
|
|
162
|
+
const reportUnresolved = (key, path, reason) => {
|
|
163
|
+
if (strict) unresolved.push(`${key} → {${path}} (${reason})`);
|
|
164
|
+
};
|
|
165
|
+
/** Resolve a single pure `{path}` reference to its raw value. */
|
|
166
|
+
const resolveRef = (value, seen, ownerKey) => {
|
|
167
|
+
if (typeof value !== "string" || !isTokenRef(value)) return value;
|
|
168
|
+
const path = extractRefPath(value);
|
|
169
|
+
if (seen.has(path)) {
|
|
170
|
+
reportUnresolved(ownerKey, path, "circular reference");
|
|
171
|
+
return value;
|
|
172
|
+
}
|
|
173
|
+
const target = all[path];
|
|
174
|
+
if (target === void 0) {
|
|
175
|
+
reportUnresolved(ownerKey, path, "missing target");
|
|
176
|
+
return value;
|
|
177
|
+
}
|
|
178
|
+
seen.add(path);
|
|
179
|
+
return resolveRef(target, seen, ownerKey);
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* Resolve all embedded `{path}` refs in a raw string expression.
|
|
183
|
+
*
|
|
184
|
+
* Handles both pure refs (`{core.space.4}`) and compound expressions
|
|
185
|
+
* (`clamp({core.space.4}, {core.space.6}, {core.space.12})`).
|
|
186
|
+
*/
|
|
187
|
+
const resolveInline = (value, seen, ownerKey) => {
|
|
188
|
+
return value.replace(COMPOUND_REF_RE, (_match, path) => {
|
|
189
|
+
const target = all[path];
|
|
190
|
+
if (target === void 0) {
|
|
191
|
+
reportUnresolved(ownerKey, path, "missing target");
|
|
192
|
+
return `{${path}}`;
|
|
193
|
+
}
|
|
194
|
+
if (seen.has(path)) {
|
|
195
|
+
reportUnresolved(ownerKey, path, "circular reference");
|
|
196
|
+
return `{${path}}`;
|
|
197
|
+
}
|
|
198
|
+
const resolved = resolveRef(target, new Set(seen).add(path), ownerKey);
|
|
199
|
+
return String(resolved);
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
const resolved = {};
|
|
203
|
+
for (const [key, value] of Object.entries(all)) if (typeof value === "string") {
|
|
204
|
+
if (isTokenRef(value)) resolved[key] = resolveRef(value, /* @__PURE__ */new Set(), key);else if (value.includes("{")) resolved[key] = resolveInline(value, /* @__PURE__ */new Set(), key);else resolved[key] = value;
|
|
205
|
+
} else resolved[key] = value;
|
|
206
|
+
if (strict && unresolved.length > 0) throw new Error(`toFlatTokens: ${unresolved.length} unresolved reference(s):\n ${unresolved.join("\n ")}`);
|
|
207
|
+
return resolved;
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
//#endregion
|
|
211
|
+
export { flattenTheme as a, validateRefs as c, flattenObject as i, SAFE_ID_RE as n, isPlainObject as o, deepMerge as r, toFlatTokens as s, COMPOUND_REF_RE as t };
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
import { T as ThemeTokens, M as ModeOverride, a as ThemeBundle, D as DeepPartial } from './Types-6tR0_2Ss.js';
|
|
2
|
-
export { S as SemanticTokens } from './Types-6tR0_2Ss.js';
|
|
3
|
-
export { ThemeHeadProps, ThemeStylesProps } from './react.js';
|
|
4
|
-
export { ThemeMode } from './runtime-entry.js';
|
|
5
|
-
export { bruttal } from './themes/bruttal.js';
|
|
6
|
-
export { corporate } from './themes/corporate.js';
|
|
7
|
-
export { oca } from './themes/oca.js';
|
|
8
|
-
export { ventures } from './themes/ventures.js';
|
|
9
|
-
import 'react/jsx-runtime';
|
|
10
|
-
import 'react';
|
|
11
1
|
|
|
2
|
+
import { a as DeepPartial, i as ThemeTokens, r as ThemeBundle, t as ModeOverride } from "./Types-BiBa17RL.cjs";
|
|
3
|
+
//#region src/baseTheme.d.ts
|
|
12
4
|
/**
|
|
13
5
|
* **Foundation** — Neutral baseline theme.
|
|
14
6
|
*
|
|
@@ -17,7 +9,8 @@ import 'react';
|
|
|
17
9
|
*/
|
|
18
10
|
declare const baseTheme: ThemeTokens;
|
|
19
11
|
declare const darkAlternate: ModeOverride;
|
|
20
|
-
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/createTheme.d.ts
|
|
21
14
|
/**
|
|
22
15
|
* Creates a theme bundle with an optional alternate color mode.
|
|
23
16
|
*
|
|
@@ -60,27 +53,42 @@ declare const darkAlternate: ModeOverride;
|
|
|
60
53
|
* const myTheme = createTheme({ alternate: null });
|
|
61
54
|
* ```
|
|
62
55
|
*/
|
|
63
|
-
declare const createTheme: ({
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
56
|
+
declare const createTheme: ({
|
|
57
|
+
extends: parentBundle,
|
|
58
|
+
baseMode,
|
|
59
|
+
base,
|
|
60
|
+
overrides,
|
|
61
|
+
alternate
|
|
62
|
+
}?: {
|
|
63
|
+
/**
|
|
64
|
+
* Parent bundle to inherit from. `base`, `baseMode`, and `alternate` all
|
|
65
|
+
* default to the parent's values — including dark-mode inheritance.
|
|
66
|
+
*
|
|
67
|
+
* `extends` is a reserved word in JS — destructured as `parentBundle`
|
|
68
|
+
* in the implementation.
|
|
69
|
+
*/
|
|
70
|
+
extends?: ThemeBundle; /** Which mode the base represents. Defaults to `extends.baseMode` or `'light'`. */
|
|
71
|
+
baseMode?: "light" | "dark"; /** Base theme to extend. Defaults to `extends.base` or `baseTheme`. */
|
|
72
|
+
base?: ThemeTokens; /** Brand overrides applied to the base theme. */
|
|
73
|
+
overrides?: DeepPartial<ThemeTokens>;
|
|
74
|
+
/**
|
|
75
|
+
* Semantic remapping overrides for the opposite mode.
|
|
76
|
+
* Defaults to `darkAlternate` when not provided (and no `extends`).
|
|
77
|
+
* Pass `null` to opt out of any alternate (single-mode theme).
|
|
78
|
+
*/
|
|
79
|
+
alternate?: ModeOverride | null;
|
|
84
80
|
}) => ThemeBundle;
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/themes/bruttal.d.ts
|
|
83
|
+
declare const bruttal: ThemeBundle;
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/themes/corporate.d.ts
|
|
86
|
+
declare const corporate: ThemeBundle;
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/themes/oca.d.ts
|
|
89
|
+
declare const oca: ThemeBundle;
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/themes/ventures.d.ts
|
|
92
|
+
declare const ventures: ThemeBundle;
|
|
93
|
+
//#endregion
|
|
94
|
+
export { createTheme as a, bruttal as i, oca as n, baseTheme as o, corporate as r, darkAlternate as s, ventures as t };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
|
|
2
|
+
import { a as DeepPartial, i as ThemeTokens, r as ThemeBundle, t as ModeOverride } from "./Types-BiBa17RL.mjs";
|
|
3
|
+
//#region src/baseTheme.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* **Foundation** — Neutral baseline theme.
|
|
6
|
+
*
|
|
7
|
+
* System fonts, gray palette, and balanced proportions. Serves as the
|
|
8
|
+
* canonical base that all other themes extend via `createTheme`.
|
|
9
|
+
*/
|
|
10
|
+
declare const baseTheme: ThemeTokens;
|
|
11
|
+
declare const darkAlternate: ModeOverride;
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/createTheme.d.ts
|
|
14
|
+
/**
|
|
15
|
+
* Creates a theme bundle with an optional alternate color mode.
|
|
16
|
+
*
|
|
17
|
+
* The `extends` param is the idiomatic way to build on a built-in theme:
|
|
18
|
+
* it inherits the base tokens **and** the dark-mode alternate automatically.
|
|
19
|
+
*
|
|
20
|
+
* @param params.extends - Parent bundle to inherit from. `base`, `baseMode`, and
|
|
21
|
+
* `alternate` default to the parent's values when this is provided.
|
|
22
|
+
* @param params.baseMode - Which mode the base represents. Defaults to `'light'`.
|
|
23
|
+
* @param params.base - Base theme to extend. Defaults to `extends.base` or `baseTheme`.
|
|
24
|
+
* @param params.overrides - Brand overrides applied to the base theme.
|
|
25
|
+
* @param params.alternate - Semantic remapping overrides for the opposite color mode.
|
|
26
|
+
* Defaults to `darkAlternate` (built-in dark mode) when neither `alternate` nor
|
|
27
|
+
* `extends` is provided. Inherits from `extends.alternate` when `extends` is given.
|
|
28
|
+
* Pass `null` to explicitly opt out of any alternate (single-mode theme).
|
|
29
|
+
* Core tokens are immutable — only semantic references change between modes.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* // Path A — default foundation (light base + dark alternate included)
|
|
34
|
+
* const myTheme = createTheme();
|
|
35
|
+
* <ThemeProvider theme={myTheme} />
|
|
36
|
+
*
|
|
37
|
+
* // Path B — custom brand overrides (dark mode still included)
|
|
38
|
+
* const myTheme = createTheme({
|
|
39
|
+
* overrides: { core: { colors: { brand: { 500: '#FF0000' } } } },
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* // Path C — custom semantic dark alternate
|
|
43
|
+
* const myTheme = createTheme({
|
|
44
|
+
* overrides: { core: { colors: { brand: { 500: '#FF0000' } } } },
|
|
45
|
+
* alternate: {
|
|
46
|
+
* semantic: {
|
|
47
|
+
* colors: { informational: { primary: { background: { default: '{core.colors.neutral.900}' } } } },
|
|
48
|
+
* },
|
|
49
|
+
* },
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* // Path D — single-mode theme (no dark alternate)
|
|
53
|
+
* const myTheme = createTheme({ alternate: null });
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
declare const createTheme: ({
|
|
57
|
+
extends: parentBundle,
|
|
58
|
+
baseMode,
|
|
59
|
+
base,
|
|
60
|
+
overrides,
|
|
61
|
+
alternate
|
|
62
|
+
}?: {
|
|
63
|
+
/**
|
|
64
|
+
* Parent bundle to inherit from. `base`, `baseMode`, and `alternate` all
|
|
65
|
+
* default to the parent's values — including dark-mode inheritance.
|
|
66
|
+
*
|
|
67
|
+
* `extends` is a reserved word in JS — destructured as `parentBundle`
|
|
68
|
+
* in the implementation.
|
|
69
|
+
*/
|
|
70
|
+
extends?: ThemeBundle; /** Which mode the base represents. Defaults to `extends.baseMode` or `'light'`. */
|
|
71
|
+
baseMode?: "light" | "dark"; /** Base theme to extend. Defaults to `extends.base` or `baseTheme`. */
|
|
72
|
+
base?: ThemeTokens; /** Brand overrides applied to the base theme. */
|
|
73
|
+
overrides?: DeepPartial<ThemeTokens>;
|
|
74
|
+
/**
|
|
75
|
+
* Semantic remapping overrides for the opposite mode.
|
|
76
|
+
* Defaults to `darkAlternate` when not provided (and no `extends`).
|
|
77
|
+
* Pass `null` to opt out of any alternate (single-mode theme).
|
|
78
|
+
*/
|
|
79
|
+
alternate?: ModeOverride | null;
|
|
80
|
+
}) => ThemeBundle;
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/themes/bruttal.d.ts
|
|
83
|
+
declare const bruttal: ThemeBundle;
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/themes/corporate.d.ts
|
|
86
|
+
declare const corporate: ThemeBundle;
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/themes/oca.d.ts
|
|
89
|
+
declare const oca: ThemeBundle;
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/themes/ventures.d.ts
|
|
92
|
+
declare const ventures: ThemeBundle;
|
|
93
|
+
//#endregion
|
|
94
|
+
export { createTheme as a, bruttal as i, oca as n, baseTheme as o, corporate as r, darkAlternate as s, ventures as t };
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
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_themes_bruttal = require('./themes/bruttal.cjs');
|
|
7
|
+
const require_themes_corporate = require('./themes/corporate.cjs');
|
|
8
|
+
const require_themes_oca = require('./themes/oca.cjs');
|
|
9
|
+
const require_themes_ventures = require('./themes/ventures.cjs');
|
|
10
|
+
exports.baseTheme = require_createTheme.baseTheme;
|
|
11
|
+
exports.bruttal = require_themes_bruttal.bruttal;
|
|
12
|
+
exports.corporate = require_themes_corporate.corporate;
|
|
13
|
+
exports.createTheme = require_createTheme.createTheme;
|
|
14
|
+
exports.darkAlternate = require_createTheme.darkAlternate;
|
|
15
|
+
exports.oca = require_themes_oca.oca;
|
|
16
|
+
exports.ventures = require_themes_ventures.ventures;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
|
|
2
|
+
import { a as DeepPartial, i as ThemeTokens, n as SemanticTokens, r as ThemeBundle, t as ModeOverride } from "./Types-BiBa17RL.cjs";
|
|
3
|
+
import { a as createTheme, i as bruttal, n as oca, o as baseTheme, r as corporate, s as darkAlternate, t as ventures } from "./index-CsIjfw86.cjs";
|
|
4
|
+
import { o as ThemeMode } from "./ssrScript-BVysxDws.cjs";
|
|
5
|
+
import { c as ThemeStylesProps, n as ThemeHeadProps } from "./react-CGa6FlNL.cjs";
|
|
6
|
+
export { type DeepPartial, type ModeOverride, type SemanticTokens, type ThemeBundle, type ThemeHeadProps, type ThemeMode, type ThemeStylesProps, type ThemeTokens, baseTheme, bruttal, corporate, createTheme, darkAlternate, oca, ventures };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
|
|
2
|
+
import { a as DeepPartial, i as ThemeTokens, n as SemanticTokens, r as ThemeBundle, t as ModeOverride } from "./Types-BiBa17RL.mjs";
|
|
3
|
+
import { a as createTheme, i as bruttal, n as oca, o as baseTheme, r as corporate, s as darkAlternate, t as ventures } from "./index-nJrjI0BA.mjs";
|
|
4
|
+
import { o as ThemeMode } from "./ssrScript-BVysxDws.mjs";
|
|
5
|
+
import { c as ThemeStylesProps, n as ThemeHeadProps } from "./react-DnKxR2gK.mjs";
|
|
6
|
+
export { type DeepPartial, type ModeOverride, type SemanticTokens, type ThemeBundle, type ThemeHeadProps, type ThemeMode, type ThemeStylesProps, type ThemeTokens, baseTheme, bruttal, corporate, createTheme, darkAlternate, oca, ventures };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
import { i as darkAlternate, n as createTheme, r as baseTheme } from "./createTheme-BLNYztZU.mjs";
|
|
3
|
+
import { bruttal } from "./themes/bruttal.mjs";
|
|
4
|
+
import { corporate } from "./themes/corporate.mjs";
|
|
5
|
+
import { oca } from "./themes/oca.mjs";
|
|
6
|
+
import { ventures } from "./themes/ventures.mjs";
|
|
7
|
+
export { baseTheme, bruttal, corporate, createTheme, darkAlternate, oca, ventures };
|