@und-ui/tokens 0.1.0 → 0.3.0

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.
Files changed (247) hide show
  1. package/README.md +100 -11
  2. package/dist/android/values/und_colors.xml +204 -73
  3. package/dist/android/values/und_dimens.xml +15 -4
  4. package/dist/android/values-night/und_colors.xml +207 -76
  5. package/dist/css/base.css +610 -35
  6. package/dist/css/motion.css +129 -1
  7. package/dist/css/themes/butter.css +278 -0
  8. package/dist/css/themes/chocolate.css +255 -0
  9. package/dist/css/themes/gothic.css +710 -0
  10. package/dist/css/themes/kesar.css +1 -1
  11. package/dist/css/themes/matcha.css +291 -0
  12. package/dist/css/themes/mitti.css +1 -1
  13. package/dist/css/themes/nabh.css +179 -0
  14. package/dist/css/themes/neem.css +1 -1
  15. package/dist/css/themes/neutral.css +255 -0
  16. package/dist/css/themes/raat.css +35 -1
  17. package/dist/css/themes/stone.css +275 -0
  18. package/dist/css/themes/sutra.css +1 -1
  19. package/dist/css/themes/ujala.css +1 -1
  20. package/dist/css/themes/y2k.css +289 -0
  21. package/dist/css/tokens.css +2998 -1
  22. package/dist/dart/und_tokens.dart +11414 -320
  23. package/dist/js/contexts.js +1 -1
  24. package/dist/js/index.d.ts +583 -1
  25. package/dist/js/index.js +850 -157
  26. package/dist/json/flat/butter.dark.json +945 -0
  27. package/dist/json/flat/butter.darkMore.json +945 -0
  28. package/dist/json/flat/butter.light.json +945 -0
  29. package/dist/json/flat/butter.lightMore.json +945 -0
  30. package/dist/json/flat/chocolate.dark.json +945 -0
  31. package/dist/json/flat/chocolate.darkMore.json +945 -0
  32. package/dist/json/flat/chocolate.light.json +945 -0
  33. package/dist/json/flat/chocolate.lightMore.json +945 -0
  34. package/dist/json/flat/gothic.dark.json +945 -0
  35. package/dist/json/flat/gothic.darkMore.json +945 -0
  36. package/dist/json/flat/kesar.dark.json +207 -0
  37. package/dist/json/flat/kesar.darkMore.json +207 -0
  38. package/dist/json/flat/kesar.light.json +207 -0
  39. package/dist/json/flat/kesar.lightMore.json +207 -0
  40. package/dist/json/flat/matcha.dark.json +945 -0
  41. package/dist/json/flat/matcha.darkMore.json +945 -0
  42. package/dist/json/flat/matcha.light.json +945 -0
  43. package/dist/json/flat/matcha.lightMore.json +945 -0
  44. package/dist/json/flat/mitti.dark.json +207 -0
  45. package/dist/json/flat/mitti.darkMore.json +207 -0
  46. package/dist/json/flat/mitti.light.json +207 -0
  47. package/dist/json/flat/mitti.lightMore.json +207 -0
  48. package/dist/json/flat/nabh.dark.json +945 -0
  49. package/dist/json/flat/nabh.darkMore.json +945 -0
  50. package/dist/json/flat/nabh.light.json +945 -0
  51. package/dist/json/flat/nabh.lightMore.json +945 -0
  52. package/dist/json/flat/neem.dark.json +207 -0
  53. package/dist/json/flat/neem.darkMore.json +207 -0
  54. package/dist/json/flat/neem.light.json +207 -0
  55. package/dist/json/flat/neem.lightMore.json +207 -0
  56. package/dist/json/flat/neutral.dark.json +945 -0
  57. package/dist/json/flat/neutral.darkMore.json +945 -0
  58. package/dist/json/flat/neutral.light.json +945 -0
  59. package/dist/json/flat/neutral.lightMore.json +945 -0
  60. package/dist/json/flat/raat.dark.json +207 -0
  61. package/dist/json/flat/raat.darkMore.json +207 -0
  62. package/dist/json/flat/stone.dark.json +945 -0
  63. package/dist/json/flat/stone.darkMore.json +945 -0
  64. package/dist/json/flat/stone.light.json +945 -0
  65. package/dist/json/flat/stone.lightMore.json +945 -0
  66. package/dist/json/flat/sutra.dark.json +207 -0
  67. package/dist/json/flat/sutra.darkMore.json +207 -0
  68. package/dist/json/flat/sutra.light.json +207 -0
  69. package/dist/json/flat/sutra.lightMore.json +207 -0
  70. package/dist/json/flat/ujala.dark.json +207 -0
  71. package/dist/json/flat/ujala.darkMore.json +207 -0
  72. package/dist/json/flat/ujala.light.json +207 -0
  73. package/dist/json/flat/ujala.lightMore.json +207 -0
  74. package/dist/json/flat/y2k.dark.json +945 -0
  75. package/dist/json/flat/y2k.darkMore.json +945 -0
  76. package/dist/json/flat/y2k.light.json +945 -0
  77. package/dist/json/flat/y2k.lightMore.json +945 -0
  78. package/dist/json/nested/butter.dark.json +1177 -0
  79. package/dist/json/nested/butter.darkMore.json +1177 -0
  80. package/dist/json/nested/butter.light.json +1177 -0
  81. package/dist/json/nested/butter.lightMore.json +1177 -0
  82. package/dist/json/nested/chocolate.dark.json +1177 -0
  83. package/dist/json/nested/chocolate.darkMore.json +1177 -0
  84. package/dist/json/nested/chocolate.light.json +1177 -0
  85. package/dist/json/nested/chocolate.lightMore.json +1177 -0
  86. package/dist/json/nested/gothic.dark.json +1177 -0
  87. package/dist/json/nested/gothic.darkMore.json +1177 -0
  88. package/dist/json/nested/kesar.dark.json +295 -4
  89. package/dist/json/nested/kesar.darkMore.json +295 -4
  90. package/dist/json/nested/kesar.light.json +295 -4
  91. package/dist/json/nested/kesar.lightMore.json +295 -4
  92. package/dist/json/nested/matcha.dark.json +1177 -0
  93. package/dist/json/nested/matcha.darkMore.json +1177 -0
  94. package/dist/json/nested/matcha.light.json +1177 -0
  95. package/dist/json/nested/matcha.lightMore.json +1177 -0
  96. package/dist/json/nested/mitti.dark.json +295 -4
  97. package/dist/json/nested/mitti.darkMore.json +295 -4
  98. package/dist/json/nested/mitti.light.json +295 -4
  99. package/dist/json/nested/mitti.lightMore.json +295 -4
  100. package/dist/json/nested/nabh.dark.json +1177 -0
  101. package/dist/json/nested/nabh.darkMore.json +1177 -0
  102. package/dist/json/nested/nabh.light.json +1177 -0
  103. package/dist/json/nested/nabh.lightMore.json +1177 -0
  104. package/dist/json/nested/neem.dark.json +295 -4
  105. package/dist/json/nested/neem.darkMore.json +295 -4
  106. package/dist/json/nested/neem.light.json +295 -4
  107. package/dist/json/nested/neem.lightMore.json +295 -4
  108. package/dist/json/nested/neutral.dark.json +1177 -0
  109. package/dist/json/nested/neutral.darkMore.json +1177 -0
  110. package/dist/json/nested/neutral.light.json +1177 -0
  111. package/dist/json/nested/neutral.lightMore.json +1177 -0
  112. package/dist/json/nested/raat.dark.json +295 -4
  113. package/dist/json/nested/raat.darkMore.json +295 -4
  114. package/dist/json/nested/stone.dark.json +1177 -0
  115. package/dist/json/nested/stone.darkMore.json +1177 -0
  116. package/dist/json/nested/stone.light.json +1177 -0
  117. package/dist/json/nested/stone.lightMore.json +1177 -0
  118. package/dist/json/nested/sutra.dark.json +295 -4
  119. package/dist/json/nested/sutra.darkMore.json +295 -4
  120. package/dist/json/nested/sutra.light.json +295 -4
  121. package/dist/json/nested/sutra.lightMore.json +295 -4
  122. package/dist/json/nested/ujala.dark.json +295 -4
  123. package/dist/json/nested/ujala.darkMore.json +295 -4
  124. package/dist/json/nested/ujala.light.json +295 -4
  125. package/dist/json/nested/ujala.lightMore.json +295 -4
  126. package/dist/json/nested/y2k.dark.json +1177 -0
  127. package/dist/json/nested/y2k.darkMore.json +1177 -0
  128. package/dist/json/nested/y2k.light.json +1177 -0
  129. package/dist/json/nested/y2k.lightMore.json +1177 -0
  130. package/dist/kotlin/UndTokens.kt +15338 -2190
  131. package/dist/lib/build/formats/css.d.ts +7 -0
  132. package/dist/lib/build/formats/css.js +113 -3
  133. package/dist/lib/build/formats/dart.d.ts +0 -7
  134. package/dist/lib/build/formats/dart.js +22 -4
  135. package/dist/lib/build/formats/js.d.ts +0 -6
  136. package/dist/lib/build/formats/js.js +8 -1
  137. package/dist/lib/build/formats/kotlin.d.ts +1 -1
  138. package/dist/lib/build/formats/kotlin.js +43 -14
  139. package/dist/lib/build/formats/react-native.js +2 -1
  140. package/dist/lib/build/formats/swift.d.ts +0 -6
  141. package/dist/lib/build/formats/swift.js +78 -15
  142. package/dist/lib/build/formats/tailwind.js +22 -2
  143. package/dist/lib/build/index.js +6 -5
  144. package/dist/lib/build/native-model.d.ts +16 -0
  145. package/dist/lib/build/native-model.js +33 -0
  146. package/dist/lib/color/pairs.js +2 -1
  147. package/dist/lib/dtcg/engine.d.ts +6 -0
  148. package/dist/lib/dtcg/engine.js +21 -1
  149. package/dist/lib/source/generate.d.ts +3 -1
  150. package/dist/lib/source/generate.js +56 -7
  151. package/dist/lib/themes/aa.d.ts +44 -0
  152. package/dist/lib/themes/aa.js +168 -0
  153. package/dist/lib/themes/definitions.d.ts +21 -10
  154. package/dist/lib/themes/definitions.js +181 -5
  155. package/dist/lib/themes/generate.d.ts +47 -0
  156. package/dist/lib/themes/generate.js +329 -0
  157. package/dist/lib/themes/ported-map.d.ts +59 -0
  158. package/dist/lib/themes/ported-map.js +618 -0
  159. package/dist/lib/themes/ported.d.ts +10 -0
  160. package/dist/lib/themes/ported.js +1764 -0
  161. package/dist/react-native/index.d.ts +132 -1
  162. package/dist/react-native/tokens.js +16487 -1656
  163. package/dist/scss/_variables.scss +346 -138
  164. package/dist/scss/_vars.scss +208 -1
  165. package/dist/scss/butter.dark.scss +946 -0
  166. package/dist/scss/butter.darkMore.scss +946 -0
  167. package/dist/scss/butter.light.scss +946 -0
  168. package/dist/scss/butter.lightMore.scss +946 -0
  169. package/dist/scss/chocolate.dark.scss +946 -0
  170. package/dist/scss/chocolate.darkMore.scss +946 -0
  171. package/dist/scss/chocolate.light.scss +946 -0
  172. package/dist/scss/chocolate.lightMore.scss +946 -0
  173. package/dist/scss/gothic.dark.scss +946 -0
  174. package/dist/scss/gothic.darkMore.scss +946 -0
  175. package/dist/scss/kesar.dark.scss +207 -0
  176. package/dist/scss/kesar.darkMore.scss +207 -0
  177. package/dist/scss/kesar.light.scss +207 -0
  178. package/dist/scss/kesar.lightMore.scss +207 -0
  179. package/dist/scss/matcha.dark.scss +946 -0
  180. package/dist/scss/matcha.darkMore.scss +946 -0
  181. package/dist/scss/matcha.light.scss +946 -0
  182. package/dist/scss/matcha.lightMore.scss +946 -0
  183. package/dist/scss/mitti.dark.scss +207 -0
  184. package/dist/scss/mitti.darkMore.scss +207 -0
  185. package/dist/scss/mitti.light.scss +207 -0
  186. package/dist/scss/mitti.lightMore.scss +207 -0
  187. package/dist/scss/nabh.dark.scss +946 -0
  188. package/dist/scss/nabh.darkMore.scss +946 -0
  189. package/dist/scss/nabh.light.scss +946 -0
  190. package/dist/scss/nabh.lightMore.scss +946 -0
  191. package/dist/scss/neem.dark.scss +207 -0
  192. package/dist/scss/neem.darkMore.scss +207 -0
  193. package/dist/scss/neem.light.scss +207 -0
  194. package/dist/scss/neem.lightMore.scss +207 -0
  195. package/dist/scss/neutral.dark.scss +946 -0
  196. package/dist/scss/neutral.darkMore.scss +946 -0
  197. package/dist/scss/neutral.light.scss +946 -0
  198. package/dist/scss/neutral.lightMore.scss +946 -0
  199. package/dist/scss/raat.dark.scss +207 -0
  200. package/dist/scss/raat.darkMore.scss +207 -0
  201. package/dist/scss/stone.dark.scss +946 -0
  202. package/dist/scss/stone.darkMore.scss +946 -0
  203. package/dist/scss/stone.light.scss +946 -0
  204. package/dist/scss/stone.lightMore.scss +946 -0
  205. package/dist/scss/sutra.dark.scss +207 -0
  206. package/dist/scss/sutra.darkMore.scss +207 -0
  207. package/dist/scss/sutra.light.scss +207 -0
  208. package/dist/scss/sutra.lightMore.scss +207 -0
  209. package/dist/scss/ujala.dark.scss +207 -0
  210. package/dist/scss/ujala.darkMore.scss +207 -0
  211. package/dist/scss/ujala.light.scss +207 -0
  212. package/dist/scss/ujala.lightMore.scss +207 -0
  213. package/dist/scss/y2k.dark.scss +946 -0
  214. package/dist/scss/y2k.darkMore.scss +946 -0
  215. package/dist/scss/y2k.light.scss +946 -0
  216. package/dist/scss/y2k.lightMore.scss +946 -0
  217. package/dist/swift/UndTokens.swift +6061 -3432
  218. package/dist/tailwind/und.css +198 -2
  219. package/package.json +5 -1
  220. package/tokens/modes/dark.tokens.json +241 -0
  221. package/tokens/modes/light.tokens.json +246 -0
  222. package/tokens/palettes/butter.dark.tokens.json +887 -0
  223. package/tokens/palettes/butter.light.tokens.json +872 -0
  224. package/tokens/palettes/chocolate.dark.tokens.json +917 -0
  225. package/tokens/palettes/chocolate.light.tokens.json +902 -0
  226. package/tokens/palettes/gothic.dark.tokens.json +831 -0
  227. package/tokens/palettes/matcha.dark.tokens.json +932 -0
  228. package/tokens/palettes/matcha.light.tokens.json +907 -0
  229. package/tokens/palettes/nabh.dark.tokens.json +498 -0
  230. package/tokens/palettes/nabh.light.tokens.json +498 -0
  231. package/tokens/palettes/neutral.dark.tokens.json +837 -0
  232. package/tokens/palettes/neutral.light.tokens.json +817 -0
  233. package/tokens/palettes/stone.dark.tokens.json +877 -0
  234. package/tokens/palettes/stone.light.tokens.json +877 -0
  235. package/tokens/palettes/y2k.dark.tokens.json +877 -0
  236. package/tokens/palettes/y2k.light.tokens.json +877 -0
  237. package/tokens/semantic/roles.tokens.json +521 -0
  238. package/tokens/themes/butter.tokens.json +254 -0
  239. package/tokens/themes/chocolate.tokens.json +214 -0
  240. package/tokens/themes/gothic.tokens.json +249 -0
  241. package/tokens/themes/matcha.tokens.json +258 -0
  242. package/tokens/themes/nabh.tokens.json +174 -0
  243. package/tokens/themes/neutral.tokens.json +234 -0
  244. package/tokens/themes/stone.tokens.json +254 -0
  245. package/tokens/themes/ujala.tokens.json +1 -1
  246. package/tokens/themes/y2k.tokens.json +264 -0
  247. package/tokens/und.resolver.json +40 -4
@@ -38,6 +38,13 @@ export interface CssBlock {
38
38
  motionOnly?: boolean;
39
39
  }
40
40
  export declare function buildCssBlocks(files: TokenFiles, resolver: ResolverDoc, typeOf: (p: string) => DtcgType | undefined): CssBlock[];
41
+ /**
42
+ * One declaration for both modes. light-dark() only takes colours, so shadow
43
+ * lists are merged layer by layer (both modes must share the layer geometry).
44
+ */
45
+ export declare function mergeLightDark(light: string, dark: string): string;
46
+ /** Picks one side of every light-dark() in a value (what the browser does per color-scheme). */
47
+ export declare function pickLightDark(value: string, mode: 'light' | 'dark'): string;
41
48
  export declare function renderBlocks(blocks: CssBlock[], header: string): string;
42
49
  export declare function filterMotion(blocks: CssBlock[]): CssBlock[];
43
50
  export type { FlatToken };
@@ -1,5 +1,5 @@
1
1
  import { flattenFile } from '../../dtcg/engine.js';
2
- import { THEMES } from '../../themes/definitions.js';
2
+ import { DEFAULT_THEME, THEMES } from '../../themes/definitions.js';
3
3
  import { PREFIX, colorP3Css, cssName, tokenDeclarations } from '../css-values.js';
4
4
  export const SCOPE_ATTRS = ['data-und-theme', 'data-und-mode', 'data-und-contrast'];
5
5
  const S_LIST = [':root', ...SCOPE_ATTRS.map((a) => `[${a}]`)];
@@ -156,13 +156,48 @@ export function buildCssBlocks(files, resolver, typeOf) {
156
156
  }, p3);
157
157
  }
158
158
  }
159
- // 3. Themes.
159
+ // 3. Themes (with their palette: per-mode literals merged through light-dark(),
160
+ // which follows the color-scheme every mode block sets).
160
161
  const theme = resolver.modifiers.theme;
162
+ const palette = resolver.modifiers.palette;
161
163
  for (const [name, list] of Object.entries(theme.contexts)) {
162
164
  const { decls, p3 } = declsForSources(ctx, refs(list));
163
165
  const def = THEMES.find((t) => t.name === name);
164
166
  if (def && def.modes.length === 1)
165
167
  decls.set('color-scheme', def.modes[0]);
168
+ if (palette) {
169
+ const per = ['light', 'dark']
170
+ .map((m) => palette.contexts[`${name}-${m}`])
171
+ .filter((c) => c !== undefined)
172
+ .map((c) => declsForSources(ctx, refs(c)).decls);
173
+ if (per.length === 1)
174
+ for (const [k, v] of per[0]) {
175
+ decls.delete(k);
176
+ decls.set(k, v);
177
+ }
178
+ if (per.length === 2) {
179
+ const [light, dark] = per;
180
+ for (const [k, l] of light) {
181
+ const d = dark.get(k);
182
+ if (d === undefined)
183
+ throw new Error(`Palette ${name}: ${k} has no dark value`);
184
+ decls.delete(k);
185
+ decls.set(k, mergeLightDark(l, d));
186
+ }
187
+ }
188
+ }
189
+ if (name === DEFAULT_THEME) {
190
+ // Un-themed scopes (no explicit other theme on them or above them) get the default theme.
191
+ const other = `[data-und-theme]:not([data-und-theme="${name}"])`;
192
+ pushWithP3(blocks, {
193
+ id: `theme:${name}:default`,
194
+ condition: { theme: name },
195
+ selector: `:where(:is(${S}):not(${other}):not(${other} *))`,
196
+ wrappers: [],
197
+ decls,
198
+ group: 'theme',
199
+ }, p3);
200
+ }
166
201
  pushWithP3(blocks, {
167
202
  id: `theme:${name}`,
168
203
  condition: { theme: name },
@@ -295,12 +330,86 @@ export function buildCssBlocks(files, resolver, typeOf) {
295
330
  });
296
331
  return blocks;
297
332
  }
333
+ /** Splits at top-level commas (not inside parentheses). */
334
+ function splitTop(v) {
335
+ const out = [];
336
+ let depth = 0;
337
+ let cur = '';
338
+ for (const ch of v) {
339
+ if (ch === '(')
340
+ depth++;
341
+ if (ch === ')')
342
+ depth--;
343
+ if (ch === ',' && depth === 0) {
344
+ out.push(cur.trim());
345
+ cur = '';
346
+ }
347
+ else
348
+ cur += ch;
349
+ }
350
+ out.push(cur.trim());
351
+ return out;
352
+ }
353
+ /**
354
+ * One declaration for both modes. light-dark() only takes colours, so shadow
355
+ * lists are merged layer by layer (both modes must share the layer geometry).
356
+ */
357
+ export function mergeLightDark(light, dark) {
358
+ if (light === dark)
359
+ return light;
360
+ const single = (v) => !/\s/.test(v) || /^var\([^)]*\)$/.test(v);
361
+ if (single(light) && single(dark))
362
+ return `light-dark(${light}, ${dark})`;
363
+ const ls = splitTop(light);
364
+ const ds = splitTop(dark);
365
+ if (ls.length !== ds.length)
366
+ throw new Error(`Cannot merge "${light}" and "${dark}"`);
367
+ return ls
368
+ .map((l, i) => {
369
+ const d = ds[i];
370
+ const li = l.lastIndexOf(' ');
371
+ const di = d.lastIndexOf(' ');
372
+ if (l.slice(0, li) !== d.slice(0, di))
373
+ throw new Error(`Shadow layers differ in geometry: "${l}" vs "${d}"`);
374
+ const lc = l.slice(li + 1);
375
+ const dc = d.slice(di + 1);
376
+ return `${l.slice(0, li)} ${lc === dc ? lc : `light-dark(${lc}, ${dc})`}`;
377
+ })
378
+ .join(', ');
379
+ }
380
+ /** Picks one side of every light-dark() in a value (what the browser does per color-scheme). */
381
+ export function pickLightDark(value, mode) {
382
+ let v = value;
383
+ for (let i = v.indexOf('light-dark('); i !== -1; i = v.indexOf('light-dark(')) {
384
+ const start = i + 'light-dark('.length;
385
+ let depth = 1;
386
+ let j = start;
387
+ for (; depth > 0; j++) {
388
+ if (v[j] === '(')
389
+ depth++;
390
+ else if (v[j] === ')')
391
+ depth--;
392
+ }
393
+ const [l, d] = splitTop(v.slice(start, j - 1));
394
+ v = v.slice(0, i) + (mode === 'light' ? l : d) + v.slice(j);
395
+ }
396
+ return v;
397
+ }
298
398
  function forcedColors(baseDecls) {
299
399
  const map = new Map();
300
400
  const set = (k, v) => map.set(k, v);
301
401
  for (const k of ['canvas', 'surface', 'raised', 'subtle', 'muted', 'muted-hover', 'muted-active'])
302
402
  set(`--und-bg-${k}`, 'Canvas');
303
403
  set('--und-bg-inverse', 'CanvasText');
404
+ set('--und-bg-card', 'Canvas');
405
+ for (const k of ['hover', 'pressed', 'skeleton', 'track'])
406
+ set(`--und-bg-${k}`, 'GrayText');
407
+ set('--und-bg-hover', 'transparent');
408
+ set('--und-bg-pressed', 'transparent');
409
+ for (const k of ['default', 'muted'])
410
+ set(`--und-icon-${k}`, 'CanvasText');
411
+ set('--und-icon-disabled', 'GrayText');
412
+ set('--und-icon-accent', 'LinkText');
304
413
  set('--und-bg-overlay', 'transparent');
305
414
  for (const k of ['default', 'muted', 'subtle'])
306
415
  set(`--und-fg-${k}`, 'CanvasText');
@@ -330,6 +439,7 @@ function forcedColors(baseDecls) {
330
439
  for (const k of ['solid', 'solid-hover'])
331
440
  set(`--und-status-${s}-${k}`, 'Highlight');
332
441
  set(`--und-status-${s}-on-solid`, 'HighlightText');
442
+ set(`--und-status-${s}-icon`, 'CanvasText');
333
443
  }
334
444
  for (const m of ['thin', 'regular', 'thick', 'chrome']) {
335
445
  set(`--und-material-${m}-bg`, 'Canvas');
@@ -338,7 +448,7 @@ function forcedColors(baseDecls) {
338
448
  }
339
449
  set('--und-material-chrome-highlight', 'transparent');
340
450
  for (const [k] of baseDecls)
341
- if (/^--und-shadow-\d$/.test(k))
451
+ if (/^--und-shadow-(\d|inset-[a-z]+)$/.test(k))
342
452
  set(k, 'none');
343
453
  for (let i = 0; i <= 5; i++)
344
454
  set(`--und-shadow-${i}`, 'none');
@@ -1,9 +1,2 @@
1
- /**
2
- * Flutter output: und_tokens.dart. No Material dependency: dart:ui types,
3
- * flutter/animation (Cubic), flutter/physics (SpringDescription),
4
- * flutter/painting (TextStyle, BoxShadow) and flutter/widgets (InheritedWidget).
5
- * UndThemeData has ==, hashCode and lerp so it works with InheritedWidget and
6
- * implicit animations.
7
- */
8
1
  import type { NativeModel } from '../native-model.js';
9
2
  export declare function renderDart(model: NativeModel): string;
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Flutter output: und_tokens.dart. No Material dependency: dart:ui types,
3
+ * flutter/animation (Cubic), flutter/physics (SpringDescription),
4
+ * flutter/painting (TextStyle, BoxShadow) and flutter/widgets (InheritedWidget).
5
+ * UndThemeData has ==, hashCode and lerp so it works with InheritedWidget and
6
+ * implicit animations.
7
+ */
8
+ import { DEFAULT_THEME } from '../../themes/definitions.js';
1
9
  import { VARIANTS, camel, stepName } from '../native-model.js';
2
10
  const d = (v) => {
3
11
  const r = Math.round(v * 10000) / 10000;
@@ -13,6 +21,13 @@ function color(c) {
13
21
  .toUpperCase();
14
22
  return `Color(0x${a}${c.hex.slice(1).toUpperCase()})`;
15
23
  }
24
+ /** Identifier part for a shadow key: numeric levels stay, `inset-hover` becomes `InsetHover`. */
25
+ function shadowId(k) {
26
+ if (/^[0-9]+$/.test(k))
27
+ return k;
28
+ const c = camel(k);
29
+ return c.charAt(0).toUpperCase() + c.slice(1);
30
+ }
16
31
  function shadow(s) {
17
32
  const layers = s.layers
18
33
  .filter((l) => !l.inset)
@@ -138,7 +153,7 @@ class UndRadii {
138
153
  ${radiusKeys.map((k) => ` final double ${stepName(k)};`).join('\n')}
139
154
 
140
155
  /// Concentric inner radius: outer - padding, at least 2.
141
- double inner(double outer, double padding) => (outer - padding) < 2 ? 2 : outer - padding;
156
+ double concentricInner(double outer, double padding) => (outer - padding) < 2 ? 2 : outer - padding;
142
157
 
143
158
  UndRadii lerp(UndRadii other, double t) => UndRadii(
144
159
  factor: lerpDouble(factor, other.factor, t)!,
@@ -240,12 +255,15 @@ ${[...model.typography].map(([k, t]) => ` ${str(camel(k))}: ${d(t.lineHeightI
240
255
 
241
256
  /// Elevation shadows per brightness (BoxShadow lists).
242
257
  abstract final class UndShadows {
243
- ${model.themes[0].shadows.light.size ? [...model.themes[0].shadows.light.keys()].map((k) => ` static const List<BoxShadow> light${k} = ${shadow(model.themes[0].shadows.light.get(k))};\n static const List<BoxShadow> dark${k} = ${shadow(model.themes[0].shadows.dark.get(k))};`).join('\n') : ''}
258
+ ${model.themes[0].shadows.light.size ? [...model.themes[0].shadows.light.keys()].map((k) => ` static const List<BoxShadow> light${shadowId(k)} = ${shadow(model.themes[0].shadows.light.get(k))};\n static const List<BoxShadow> dark${shadowId(k)} = ${shadow(model.themes[0].shadows.dark.get(k))};`).join('\n') : ''}
244
259
 
245
260
  static List<BoxShadow> of(int level, Brightness brightness) {
246
261
  final dark = brightness == Brightness.dark;
247
262
  switch (level) {
248
- ${[...model.themes[0].shadows.light.keys()].map((k) => ` case ${k}:\n return dark ? dark${k} : light${k};`).join('\n')}
263
+ ${[...model.themes[0].shadows.light.keys()]
264
+ .filter((k) => /^[0-9]+$/.test(k))
265
+ .map((k) => ` case ${k}:\n return dark ? dark${k} : light${k};`)
266
+ .join('\n')}
249
267
  default:
250
268
  return const <BoxShadow>[];
251
269
  }
@@ -329,7 +347,7 @@ class UndTheme extends InheritedWidget {
329
347
  final UndThemeData data;
330
348
 
331
349
  static UndThemeData of(BuildContext context) =>
332
- context.dependOnInheritedWidgetOfExactType<UndTheme>()?.data ?? UndThemeData.of(UndThemeName.ujala);
350
+ context.dependOnInheritedWidgetOfExactType<UndTheme>()?.data ?? UndThemeData.of(UndThemeName.${DEFAULT_THEME});
333
351
 
334
352
  @override
335
353
  bool updateShouldNotify(UndTheme oldWidget) => data != oldWidget.data;
@@ -1,9 +1,3 @@
1
- /**
2
- * ESM + .d.ts output.
3
- * tokens default context (Ujala, light, standard contrast), CSS-ready values
4
- * vars same shape, every leaf is var(--und-...) for runtime theming
5
- * getTokens() any resolver input; built from per-context diffs
6
- */
7
1
  import type { Context } from '../../dtcg/engine.js';
8
2
  import type { MatValue } from '../materialize.js';
9
3
  type Json = string | number | boolean | null | Json[] | {
@@ -1,3 +1,10 @@
1
+ /**
2
+ * ESM + .d.ts output.
3
+ * tokens default context (Ujala, light, standard contrast), CSS-ready values
4
+ * vars same shape, every leaf is var(--und-...) for runtime theming
5
+ * getTokens() any resolver input; built from per-context diffs
6
+ */
7
+ import { DEFAULT_THEME } from '../../themes/definitions.js';
1
8
  import { cssName } from '../css-values.js';
2
9
  import { fluidClamp, hex8 } from '../css-values.js';
3
10
  import { materialize } from '../materialize.js';
@@ -198,7 +205,7 @@ function apply(tree, diff) {
198
205
  * Values match the CSS output for the same attributes (radius and tempo applied).
199
206
  */
200
207
  export function getTokens(input = {}) {
201
- const theme = input.theme ?? 'ujala';
208
+ const theme = input.theme ?? ${JSON.stringify(DEFAULT_THEME)};
202
209
  const meta = themes.find((t) => t.name === theme);
203
210
  if (!meta) throw new Error('Unknown UND theme: ' + theme);
204
211
  const mode = meta.modes.includes(input.mode ?? 'light') ? (input.mode ?? 'light') : meta.modes[0];
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Jetpack Compose output: UndTokens.kt (package dev.undui.tokens).
3
- * UndColors (data class per theme x variant), UndTypography, UndSpacing,
3
+ * UndColors (grouped role data classes, one lazy scheme per theme x variant), UndTypography, UndSpacing,
4
4
  * UndRadii, UndMotion and UndControl objects. Wide-gamut colours use
5
5
  * ColorSpaces.DisplayP3.
6
6
  */
@@ -1,4 +1,4 @@
1
- import { VARIANTS, camel, stepName } from '../native-model.js';
1
+ import { VARIANTS, camel, colorRoleGroups, stepName } from '../native-model.js';
2
2
  const f = (v) => {
3
3
  const r = Math.round(v * 10000) / 10000;
4
4
  return `${Number.isInteger(r) ? `${r}.0` : `${r}`}f`;
@@ -15,11 +15,16 @@ function color(c) {
15
15
  .toUpperCase();
16
16
  return `Color(0x${a}${c.hex.slice(1).toUpperCase()})`;
17
17
  }
18
+ // Kotlin hard keywords need backticks when used as identifiers.
19
+ const KOTLIN_KEYWORDS = new Set('as break class continue do else false for fun if in interface is null object package return super this throw true try typealias typeof val var when while'.split(' '));
20
+ const kid = (name) => (KOTLIN_KEYWORDS.has(name) ? `\`${name}\`` : name);
18
21
  function cap(s) {
19
22
  return s.charAt(0).toUpperCase() + s.slice(1);
20
23
  }
21
24
  export function renderKotlin(model) {
22
- const roles = model.colorRoles.map(([name]) => name);
25
+ const groups = colorRoleGroups(model.colorRoles);
26
+ const groupClass = (g) => `Und${cap(g)}Colors`;
27
+ const themeObject = (name) => `Und${cap(name)}Colors`;
23
28
  const L = [];
24
29
  L.push(`// Generated by @und-ui/tokens ${model.version}. Do not edit.
25
30
  // Source: DTCG 2025.10 tokens. Semantic roles only (no hue names).
@@ -49,34 +54,58 @@ enum class UndCharacter { Crisp, Standard, Expressive }
49
54
 
50
55
  enum class UndDensity { Comfortable, Compact, Touch }
51
56
 
52
- /** Semantic colour roles for one theme and appearance. */
57
+ /** Semantic colour roles for one theme and appearance, stored per group (bg, fg, status, ...). */
53
58
  @Immutable
54
59
  data class UndColors(
55
- ${roles.map((r) => ` val ${r}: Color,`).join('\n')}
60
+ ${groups.map(([g]) => ` val ${kid(g)}: ${groupClass(g)},`).join('\n')}
56
61
  ) {
62
+ // Flat role accessors: colors.bgSurface == colors.bg.surface.
63
+ ${groups.flatMap(([g, rs]) => rs.map((r) => ` val ${kid(r.flat)}: Color get() = ${kid(g)}.${kid(r.member)}`)).join('\n')}
64
+
57
65
  companion object {
58
66
  ${model.themes
59
- .flatMap((t) => VARIANTS.map((v) => ` val ${t.def.name}${cap(v)}: UndColors = UndColors(
60
- ${roles.map((r) => ` ${r} = ${color(t.colors[v].get(r))},`).join('\n')}
61
- )`))
62
- .join('\n\n')}
67
+ .flatMap((t) => VARIANTS.map((v) => ` val ${t.def.name}${cap(v)}: UndColors get() = ${themeObject(t.def.name)}.${v}`))
68
+ .join('\n')}
63
69
 
64
70
  /** Pick a scheme. Dark-only themes (Raat) ignore [dark]. */
65
71
  fun of(theme: UndThemeName, dark: Boolean, highContrast: Boolean = false): UndColors = when (theme) {
66
72
  ${model.themes
67
73
  .map((t) => {
68
- const name = t.def.name;
69
- return ` UndThemeName.${cap(name)} -> when {
70
- dark && highContrast -> ${name}DarkMore
71
- dark -> ${name}Dark
72
- highContrast -> ${name}LightMore
73
- else -> ${name}Light
74
+ const o = themeObject(t.def.name);
75
+ return ` UndThemeName.${cap(t.def.name)} -> when {
76
+ dark && highContrast -> ${o}.darkMore
77
+ dark -> ${o}.dark
78
+ highContrast -> ${o}.lightMore
79
+ else -> ${o}.light
74
80
  }`;
75
81
  })
76
82
  .join('\n')}
77
83
  }
78
84
  }
79
85
  }
86
+
87
+ ${groups
88
+ .map(([g, rs]) => `/** Colour roles in the ${g} group. */
89
+ @Immutable
90
+ data class ${groupClass(g)}(
91
+ ${rs.map((r) => ` val ${kid(r.member)}: Color,`).join('\n')}
92
+ )`)
93
+ .join('\n\n')}
94
+
95
+ ${model.themes
96
+ .map((t) => `/** ${t.def.label} schemes. One object per theme, one lazy method per variant: every class and method stays far below JVM limits. */
97
+ private object ${themeObject(t.def.name)} {
98
+ ${VARIANTS.map((v) => ` val ${v}: UndColors by lazy(LazyThreadSafetyMode.PUBLICATION) {
99
+ UndColors(
100
+ ${groups
101
+ .map(([g, rs]) => ` ${kid(g)} = ${groupClass(g)}(
102
+ ${rs.map((r) => ` ${kid(r.member)} = ${color(t.colors[v].get(r.flat))},`).join('\n')}
103
+ ),`)
104
+ .join('\n')}
105
+ )
106
+ }`).join('\n\n')}
107
+ }`)
108
+ .join('\n\n')}
80
109
  `);
81
110
  const dpObject = (name, entries, doc, prefix = 's') => `/** ${doc} */\nobject ${name} {\n${[...entries].map(([k, v]) => ` val ${stepName(k, prefix)}: Dp = ${dp(v)}`).join('\n')}\n}\n`;
82
111
  L.push(dpObject('UndSpacing', model.spacing, '4dp spacing scale (report 3.1). Density never changes these.'));
@@ -4,6 +4,7 @@
4
4
  * index.js Platform-aware entry: resolves shadows, hit targets, hairlines and
5
5
  * monospace families with Platform.select / StyleSheet.hairlineWidth.
6
6
  */
7
+ import { DEFAULT_THEME } from '../../themes/definitions.js';
7
8
  import { hex8 } from '../css-values.js';
8
9
  import { VARIANTS, camel, stepName } from '../native-model.js';
9
10
  const HEADER = '// Generated by @und-ui/tokens. Do not edit.\n';
@@ -107,7 +108,7 @@ const MONO = { ios: 'Menlo', android: 'monospace', web: 'ui-monospace, monospace
107
108
  * @param {{ theme?: string, scheme?: 'light' | 'dark', highContrast?: boolean, hairlineWidth?: number }} [options]
108
109
  */
109
110
  export function createTheme(os, options = {}) {
110
- const t = data.themes[options.theme ?? 'ujala'];
111
+ const t = data.themes[options.theme ?? ${JSON.stringify(DEFAULT_THEME)}];
111
112
  if (!t) throw new Error('Unknown UND theme: ' + options.theme);
112
113
  const dark = t.darkOnly || options.scheme === 'dark';
113
114
  const variant = (dark ? 'dark' : 'light') + (options.highContrast ? 'More' : '');
@@ -1,8 +1,2 @@
1
- /**
2
- * SwiftUI output: UndTokens.swift.
3
- * Foundation-only value types (compile on Linux) plus `#if canImport(SwiftUI)`
4
- * extensions that produce dynamic Colors (light/dark x Increase Contrast),
5
- * Fonts (Dynamic Type relative) and spring Animations.
6
- */
7
1
  import type { NativeModel } from '../native-model.js';
8
2
  export declare function renderSwift(model: NativeModel): string;
@@ -1,9 +1,20 @@
1
- import { VARIANTS, camel, stepName } from '../native-model.js';
1
+ /**
2
+ * SwiftUI output: UndTokens.swift.
3
+ * Foundation-only value types (compile on Linux) plus `#if canImport(SwiftUI)`
4
+ * extensions that produce dynamic Colors (light/dark x Increase Contrast),
5
+ * Fonts (Dynamic Type relative) and spring Animations.
6
+ */
7
+ import { DEFAULT_THEME } from '../../themes/definitions.js';
8
+ import { VARIANTS, camel, colorRoleGroups, stepName } from '../native-model.js';
2
9
  const n = (v) => {
3
10
  const r = Math.round(v * 10000) / 10000;
4
11
  return Number.isInteger(r) ? `${r}` : `${r}`;
5
12
  };
6
13
  const str = (s) => JSON.stringify(s);
14
+ const cap = (s) => s.charAt(0).toUpperCase() + s.slice(1);
15
+ // Swift keywords need backticks when declared as identifiers (argument labels do not).
16
+ const SWIFT_KEYWORDS = new Set('as associatedtype break case catch class continue default defer deinit do else enum extension fallthrough false fileprivate for func guard if import in init inout internal is let nil operator private protocol public repeat rethrows return self Self static struct subscript super switch throw throws true try typealias var where while'.split(' '));
17
+ const sid = (name) => (SWIFT_KEYWORDS.has(name) ? `\`${name}\`` : name);
7
18
  function rgba(c) {
8
19
  if (c.p3)
9
20
  return `UndRGBA(${n(c.p3[0])}, ${n(c.p3[1])}, ${n(c.p3[2])}, ${n(c.alpha)}, space: .displayP3)`;
@@ -93,24 +104,76 @@ public enum UndCharacter: String, Sendable { case crisp, standard, expressive }
93
104
  public enum UndDensity: String, Sendable { case comfortable, compact, touch }
94
105
  public enum UndGlass: String, Sendable { case chrome, on, off }
95
106
  `);
96
- // Colour roles struct
97
- L.push(`/// Semantic colour roles (names generated from token paths, for example bg.surface -> bgSurface).
107
+ // Colour roles: one nested struct per group, stored behind a single reference so UndColorRoles
108
+ // (and UndTheme, which embeds it) stays pointer-sized. A flat struct with hundreds of roles made a
109
+ // memberwise initialiser with hundreds of parameters and multi-kilobyte value copies.
110
+ const groups = colorRoleGroups(model.colorRoles);
111
+ const groupType = (g) => `${cap(g)}Roles`;
112
+ const groupLines = [];
113
+ for (const [g, rs] of groups) {
114
+ groupLines.push(` /// Colour roles in the ${g} group.
115
+ public struct ${groupType(g)}: Sendable, Equatable {
116
+ ${rs.map((r) => ` public let ${sid(r.member)}: UndDynamicColor`).join('\n')}
117
+
118
+ public init(
119
+ ${rs.map((r, i) => ` ${sid(r.member)}: UndDynamicColor${i === rs.length - 1 ? '' : ','}`).join('\n')}
120
+ ) {
121
+ ${rs.map((r) => ` self.${sid(r.member)} = ${sid(r.member)}`).join('\n')}
122
+ }
123
+ }
124
+ `);
125
+ }
126
+ L.push(`/// Semantic colour roles, grouped by token path (bg.surface -> colors.bg.surface, also colors.bgSurface).
98
127
  public struct UndColorRoles: Sendable, Equatable {
99
- ${roles.map((r) => ` public let ${r}: UndDynamicColor`).join('\n')}
128
+ ${groupLines.join('\n')}
129
+ private final class Storage: Sendable {
130
+ ${groups.map(([g]) => ` let ${sid(g)}: ${groupType(g)}`).join('\n')}
131
+
132
+ init(${groups.map(([g]) => `${sid(g)}: ${groupType(g)}`).join(', ')}) {
133
+ ${groups.map(([g]) => ` self.${sid(g)} = ${sid(g)}`).join('\n')}
134
+ }
135
+ }
136
+
137
+ private let storage: Storage
138
+
139
+ public init(${groups.map(([g]) => `${sid(g)}: ${groupType(g)}`).join(', ')}) {
140
+ storage = Storage(${groups.map(([g]) => `${sid(g)}: ${sid(g)}`).join(', ')})
141
+ }
142
+
143
+ ${groups.map(([g]) => ` public var ${sid(g)}: ${groupType(g)} { storage.${sid(g)} }`).join('\n')}
144
+
145
+ public static func == (lhs: UndColorRoles, rhs: UndColorRoles) -> Bool {
146
+ if lhs.storage === rhs.storage { return true }
147
+ ${groups.map(([g]) => ` guard lhs.${sid(g)} == rhs.${sid(g)} else { return false }`).join('\n')}
148
+ return true
149
+ }
150
+ }
151
+
152
+ /// Flat role accessors: bgSurface == bg.surface.
153
+ extension UndColorRoles {
154
+ ${groups.flatMap(([g, rs]) => rs.map((r) => ` public var ${sid(r.flat)}: UndDynamicColor { storage.${sid(g)}.${sid(r.member)} }`)).join('\n')}
100
155
  }
101
156
  `);
102
- L.push('extension UndColorRoles {');
103
157
  for (const t of model.themes) {
104
- L.push(` public static let ${t.def.name} = UndColorRoles(`);
105
- L.push(roles
106
- .map((r) => {
107
- const parts = VARIANTS.map((v) => `${v}: ${rgba(t.colors[v].get(r))}`).join(',\n ');
108
- return ` ${r}: UndDynamicColor(\n ${parts}\n )`;
109
- })
110
- .join(',\n'));
111
- L.push(' )');
158
+ const ns = `Und${cap(t.def.name)}ColorRoles`;
159
+ L.push(`extension UndColorRoles {
160
+ public static let ${t.def.name}: UndColorRoles = ${ns}.roles
161
+ }
162
+
163
+ /// ${t.def.label} roles: one lazily initialised static per group keeps every initialiser small.
164
+ private enum ${ns} {`);
165
+ for (const [g, rs] of groups) {
166
+ L.push(` static let ${sid(g)}: UndColorRoles.${groupType(g)} = {`);
167
+ rs.forEach((r, i) => {
168
+ const parts = VARIANTS.map((v) => `${v}: ${rgba(t.colors[v].get(r.flat))}`).join(', ');
169
+ L.push(` let c${i}: UndDynamicColor = UndDynamicColor(${parts})`);
170
+ });
171
+ L.push(` return UndColorRoles.${groupType(g)}(${rs.map((r, i) => `${r.member}: c${i}`).join(', ')})`);
172
+ L.push(' }()');
173
+ }
174
+ L.push(` static let roles: UndColorRoles = UndColorRoles(${groups.map(([g]) => `${g}: ${sid(g)}`).join(', ')})`);
175
+ L.push('}\n');
112
176
  }
113
- L.push('}\n');
114
177
  // Spacing / sizes
115
178
  const cg = (name, entries, doc, prefix = 's') => `/// ${doc}\npublic enum ${name} {\n${[...entries].map(([k, v]) => ` public static let ${stepName(k, prefix)}: CGFloat = ${n(v)}`).join('\n')}\n}\n`;
116
179
  L.push(cg('UndSpacing', model.spacing, '4pt spacing scale (report 3.1). Density never changes these.'));
@@ -371,7 +434,7 @@ ${Object.entries(IOS_WEIGHT)
371
434
  }
372
435
 
373
436
  private struct UndThemeKey: EnvironmentKey {
374
- static let defaultValue: UndTheme = .ujala
437
+ static let defaultValue: UndTheme = .${DEFAULT_THEME}
375
438
  }
376
439
 
377
440
  extension EnvironmentValues {
@@ -1,4 +1,5 @@
1
1
  import { isBridge } from '../../dtcg/types.js';
2
+ import { THEMES } from '../../themes/definitions.js';
2
3
  import { cssName } from '../css-values.js';
3
4
  import { materialize } from '../materialize.js';
4
5
  export function renderTailwind(ctx, themes, version) {
@@ -14,6 +15,11 @@ export function renderTailwind(ctx, themes, version) {
14
15
  'link',
15
16
  'dataviz',
16
17
  'selection',
18
+ 'icon',
19
+ 'tone',
20
+ 'data',
21
+ 'syntax',
22
+ 'tint',
17
23
  ];
18
24
  const add = (k, v) => lines.push(` ${k}: ${v};`);
19
25
  lines.push(' /* Colours: semantic roles (theme-aware) */');
@@ -41,8 +47,11 @@ export function renderTailwind(ctx, themes, version) {
41
47
  add(`--radius-${p.slice(6)}`, `var(${cssName(p)})`);
42
48
  lines.push(' /* Elevation */');
43
49
  for (const p of paths)
44
- if (/^shadow\.\d$/.test(p))
50
+ if (/^shadow\.(\d|low|med|high)$/.test(p))
45
51
  add(`--shadow-${p.slice(7)}`, `var(${cssName(p)})`);
52
+ for (const p of paths)
53
+ if (/^shadow\.inset-/.test(p))
54
+ add(`--inset-shadow-${p.slice(13)}`, `var(${cssName(p)})`);
46
55
  lines.push(' /* Fonts */');
47
56
  add('--font-sans', 'var(--und-typeface-body)');
48
57
  add('--font-heading', 'var(--und-typeface-heading)');
@@ -62,6 +71,15 @@ export function renderTailwind(ctx, themes, version) {
62
71
  add(`--text-${n}--letter-spacing`, `var(${v}-tracking)`);
63
72
  add(`--text-${n}--font-weight`, `var(${v}-weight)`);
64
73
  }
74
+ lines.push(' /* Element type scale (text-heading-1 ... text-supporting; follows the theme) */');
75
+ for (const p of paths) {
76
+ const m = /^type\.([a-z0-9-]+)\.size$/.exec(p);
77
+ if (!m)
78
+ continue;
79
+ add(`--text-${m[1]}`, `var(--und-type-${m[1]}-size)`);
80
+ add(`--text-${m[1]}--line-height`, `var(--und-type-${m[1]}-leading)`);
81
+ add(`--text-${m[1]}--font-weight`, `var(--und-type-${m[1]}-weight)`);
82
+ }
65
83
  lines.push(' /* Motion */');
66
84
  for (const e of ['enter', 'exit', 'move', 'emphasized'])
67
85
  add(`--ease-${e}`, `var(--und-motion-ease-${e})`);
@@ -79,7 +97,9 @@ export function renderTailwind(ctx, themes, version) {
79
97
  bp.push(` --breakpoint-${p.slice(11)}: ${m.css};`);
80
98
  }
81
99
  const variants = [
82
- '@custom-variant und-dark (&:where([data-und-mode="dark"], [data-und-mode="dark"] *, [data-und-theme="raat"], [data-und-theme="raat"] *));',
100
+ `@custom-variant und-dark (&:where([data-und-mode="dark"], [data-und-mode="dark"] *${THEMES.filter((t) => t.modes.length === 1 && t.modes[0] === 'dark')
101
+ .map((t) => `, [data-und-theme="${t.name}"], [data-und-theme="${t.name}"] *`)
102
+ .join('')}));`,
83
103
  '@custom-variant und-more (&:where([data-und-contrast="more"], [data-und-contrast="more"] *));',
84
104
  '@custom-variant und-compact (&:where([data-und-density="compact"], [data-und-density="compact"] *));',
85
105
  ...themes.map((t) => `@custom-variant theme-${t} (&:where([data-und-theme="${t}"], [data-und-theme="${t}"] *));`),
@@ -6,7 +6,7 @@
6
6
  import { readFileSync } from 'node:fs';
7
7
  import { join } from 'node:path';
8
8
  import { TokenFiles, resolveContext } from '../dtcg/engine.js';
9
- import { THEMES } from '../themes/definitions.js';
9
+ import { DEFAULT_THEME, THEMES } from '../themes/definitions.js';
10
10
  import { colorContextKeys, variantName } from './contexts.js';
11
11
  import { buildCssBlocks, filterMotion, renderBlocks } from './formats/css.js';
12
12
  import { renderDart } from './formats/dart.js';
@@ -38,10 +38,11 @@ export async function buildAll(root) {
38
38
  const blocks = buildCssBlocks(files, resolver, typeOf);
39
39
  const cssHeader = (what) => header(version, what);
40
40
  out['css/tokens.css'] = renderBlocks(blocks, cssHeader('All themes, modes, contrast, density, transparency and motion contexts. Attributes on <html> (or any scope element): data-und-theme, data-und-mode, data-und-contrast, data-und-density, data-und-transparency, data-und-motion.'));
41
- const nonDefaultTheme = (b) => b.group === 'theme' && !b.id.startsWith('theme:ujala');
41
+ const themeOf = (b) => (b.group === 'theme' ? b.id.split(':')[1] : undefined);
42
+ const nonDefaultTheme = (b) => b.group === 'theme' && themeOf(b) !== DEFAULT_THEME;
42
43
  out['css/base.css'] = renderBlocks(blocks.filter((b) => !nonDefaultTheme(b)), cssHeader('Everything except the non-default themes. Add css/themes/<name>.css for the themes you use.'));
43
44
  for (const t of THEMES) {
44
- out[`css/themes/${t.name}.css`] = renderBlocks(blocks.filter((b) => b.group === 'theme' && b.id.split(':')[1] === t.name), cssHeader(`${t.label} theme. Load after css/base.css; activate with data-und-theme="${t.name}".`));
45
+ out[`css/themes/${t.name}.css`] = renderBlocks(blocks.filter((b) => themeOf(b) === t.name && !b.id.endsWith(':default') && !b.id.endsWith(':default:p3')), cssHeader(`${t.label} theme. Load after css/base.css; activate with data-und-theme="${t.name}".`));
45
46
  }
46
47
  out['css/motion.css'] = renderBlocks(filterMotion(blocks), cssHeader('Motion only: durations x tempo (--und-motion-tempo), easings, spring linear() curves with cubic-bezier fallback, and reduced-motion rules. Included in tokens.css.'));
47
48
  const cssProperties = new Set();
@@ -101,7 +102,7 @@ export async function buildAll(root) {
101
102
  for (const [f, content] of Object.entries(sd))
102
103
  out[f] = content;
103
104
  }
104
- out['scss/_variables.scss'] = out['scss/ujala.light.scss'];
105
+ out['scss/_variables.scss'] = out[`scss/${DEFAULT_THEME}.light.scss`];
105
106
  out['scss/_vars.scss'] =
106
107
  `// Generated by @und-ui/tokens ${version}. Do not edit.\n// Runtime-themable Sass variables: each one is the CSS custom property.\n${[
107
108
  ...cssProperties,
@@ -110,7 +111,7 @@ export async function buildAll(root) {
110
111
  .sort()
111
112
  .map((p) => `$${p.slice(2)}: var(${p});`)
112
113
  .join('\n')}\n`;
113
- Object.assign(out, await buildAndroid(ctxByKey.get('ujala/light'), ctxByKey.get('ujala/dark')));
114
+ Object.assign(out, await buildAndroid(ctxByKey.get(`${DEFAULT_THEME}/light`), ctxByKey.get(`${DEFAULT_THEME}/dark`)));
114
115
  // Tailwind
115
116
  out['tailwind/und.css'] = renderTailwind(defaultCtx, THEMES.map((t) => t.name), version);
116
117
  // Native
@@ -7,6 +7,22 @@ export declare const VARIANTS: readonly Variant[];
7
7
  export declare function camel(path: string): string;
8
8
  /** Identifier-safe key for scale steps: `2xl` -> `xxl`, `3xl` -> `xxxl`, `0_5` -> `s0p5`. */
9
9
  export declare function stepName(key: string, numericPrefix?: string): string;
10
+ /** One colour role inside a role group: `bg.surface` -> group `bg`, member `surface`, flat `bgSurface`. */
11
+ export interface GroupedRole {
12
+ flat: string;
13
+ member: string;
14
+ path: string;
15
+ }
16
+ /**
17
+ * Most roles one group may hold. Kotlin `Color` is a `long` (2 JVM parameter slots) and a JVM method
18
+ * takes at most 255 slots, so a data class constructor must stay well below 127 colour parameters.
19
+ */
20
+ export declare const MAX_ROLES_PER_GROUP = 100;
21
+ /**
22
+ * Colour roles grouped by the first token path segment (bg, fg, status, data, ...). Native outputs
23
+ * store roles per group so no generated class or method grows with the total role count.
24
+ */
25
+ export declare function colorRoleGroups(roles: [string, string][]): [string, GroupedRole[]][];
10
26
  export interface NativeTheme {
11
27
  def: ThemeDefinition;
12
28
  colors: Record<Variant, Map<string, MatColor>>;