@ttoss/fsl-theme 2.0.0 → 2.1.1

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 (48) hide show
  1. package/README.md +41 -30
  2. package/dist/{Types-BkaxtsMv.d.cts → Types-a_sfpbha.d.cts} +23 -11
  3. package/dist/{Types-BkaxtsMv.d.mts → Types-a_sfpbha.d.mts} +23 -11
  4. package/dist/{baseBundle-R7WyjyTw.mjs → baseBundle-CXdxj_re.mjs} +1 -1
  5. package/dist/{baseBundle-DdRSa5mf.cjs → baseBundle-a9LDsqYy.cjs} +1 -1
  6. package/dist/{createTheme--UFgVlEn.cjs → createTheme-B7H0xSVp.cjs} +95 -17
  7. package/dist/{createTheme-B6tVIikC.mjs → createTheme-Bm9LVQ4w.mjs} +96 -18
  8. package/dist/css.cjs +4 -3
  9. package/dist/css.d.cts +21 -2
  10. package/dist/css.d.mts +21 -2
  11. package/dist/css.mjs +4 -3
  12. package/dist/dataviz/index.cjs +2 -2
  13. package/dist/dataviz/index.d.cts +1 -1
  14. package/dist/dataviz/index.d.mts +1 -1
  15. package/dist/dataviz/index.mjs +1 -1
  16. package/dist/dtcg.d.cts +1 -1
  17. package/dist/dtcg.d.mts +1 -1
  18. package/dist/{index-7YL90Xqs.d.cts → index-BmZQVd3G.d.cts} +1 -1
  19. package/dist/{index-BmCTIOzh.d.mts → index-XZsRrMTF.d.mts} +1 -1
  20. package/dist/index.cjs +1 -1
  21. package/dist/index.d.cts +3 -3
  22. package/dist/index.d.mts +3 -3
  23. package/dist/index.mjs +1 -1
  24. package/dist/{react-Dt7vGAVG.d.cts → react-2D_CNVF2.d.cts} +50 -19
  25. package/dist/{react-C8JrZf-b.d.mts → react-BwnHHvJj.d.mts} +50 -19
  26. package/dist/{react-DLB8nrXQ.cjs → react-DQErMGJz.cjs} +90 -18
  27. package/dist/react.cjs +3 -1
  28. package/dist/react.d.cts +1 -1
  29. package/dist/react.d.mts +1 -1
  30. package/dist/react.mjs +92 -18
  31. package/dist/runtime-entry.cjs +1 -1
  32. package/dist/runtime-entry.mjs +1 -1
  33. package/dist/{ssrScript-MF5SIONH.cjs → ssrScript-D73WcrCM.cjs} +51 -3
  34. package/dist/{ssrScript-DNLlLDps.mjs → ssrScript-zDK1dqXr.mjs} +51 -3
  35. package/dist/themes/bruttal.cjs +2 -2
  36. package/dist/themes/bruttal.d.cts +1 -1
  37. package/dist/themes/bruttal.d.mts +1 -1
  38. package/dist/themes/bruttal.mjs +2 -2
  39. package/dist/{toCssVars-C-9yIZDR.mjs → toCssVars-CWTlp9St.mjs} +38 -3
  40. package/dist/{toCssVars-BseqmMcT.cjs → toCssVars-D0BR23cP.cjs} +38 -3
  41. package/dist/vars.cjs +7 -7
  42. package/dist/vars.d.cts +6 -6
  43. package/dist/vars.d.mts +6 -6
  44. package/dist/vars.mjs +7 -7
  45. package/dist/{withDataviz-CYRf4exT.cjs → withDataviz-DrUtw8cc.cjs} +1 -1
  46. package/dist/{withDataviz-BvpZJnFx.mjs → withDataviz-Ln3sEwb7.mjs} +1 -1
  47. package/llms.txt +6 -4
  48. package/package.json +8 -4
@@ -1,5 +1,5 @@
1
1
  /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
- import { a as flattenTheme, r as deepMerge, t as COMPOUND_REF_RE } from "./helpers-BXaKe2s3.mjs";
2
+ import { a as flattenTheme, i as flattenObject, r as deepMerge, t as COMPOUND_REF_RE } from "./helpers-BXaKe2s3.mjs";
3
3
 
4
4
  //#region src/baseTheme.ts
5
5
  /**
@@ -66,6 +66,7 @@ var baseTheme = {
66
66
  100: "#fee2e2",
67
67
  300: "#fca5a5",
68
68
  500: "#ef4444",
69
+ 600: "#dc2626",
69
70
  700: "#b91c1c",
70
71
  900: "#7f1d1d"
71
72
  },
@@ -391,7 +392,7 @@ var baseTheme = {
391
392
  },
392
393
  negative: {
393
394
  background: {
394
- default: "{core.colors.red.500}",
395
+ default: "{core.colors.red.600}",
395
396
  hover: "{core.colors.red.700}",
396
397
  active: "{core.colors.red.900}",
397
398
  disabled: "{core.colors.neutral.200}",
@@ -400,7 +401,7 @@ var baseTheme = {
400
401
  expanded: "{core.colors.red.700}"
401
402
  },
402
403
  border: {
403
- default: "{core.colors.red.500}",
404
+ default: "{core.colors.red.600}",
404
405
  hover: "{core.colors.red.700}",
405
406
  active: "{core.colors.red.900}",
406
407
  focused: "{core.colors.red.700}",
@@ -455,7 +456,8 @@ var baseTheme = {
455
456
  checked: "{core.colors.brand.500}",
456
457
  indeterminate: "{core.colors.brand.300}",
457
458
  pressed: "{core.colors.neutral.100}",
458
- expanded: "{core.colors.neutral.50}"
459
+ expanded: "{core.colors.neutral.50}",
460
+ invalid: "{core.colors.neutral.0}"
459
461
  },
460
462
  border: {
461
463
  default: "{core.colors.neutral.300}",
@@ -467,12 +469,14 @@ var baseTheme = {
467
469
  checked: "{core.colors.brand.500}",
468
470
  indeterminate: "{core.colors.brand.300}",
469
471
  pressed: "{core.colors.neutral.500}",
470
- expanded: "{core.colors.brand.500}"
472
+ expanded: "{core.colors.brand.500}",
473
+ invalid: "{core.colors.red.600}"
471
474
  },
472
475
  text: {
473
476
  default: "{core.colors.neutral.900}",
474
477
  disabled: "{core.colors.neutral.500}",
475
478
  checked: "{core.colors.neutral.0}",
479
+ invalid: "{core.colors.neutral.900}",
476
480
  indeterminate: "{core.colors.neutral.900}"
477
481
  }
478
482
  },
@@ -1355,17 +1359,20 @@ var darkAlternate = {
1355
1359
  selected: "{core.colors.brand.700}",
1356
1360
  droptarget: "{core.colors.neutral.700}",
1357
1361
  pressed: "{core.colors.neutral.500}",
1358
- expanded: "{core.colors.neutral.500}"
1362
+ expanded: "{core.colors.neutral.500}",
1363
+ invalid: "{core.colors.neutral.700}"
1359
1364
  },
1360
1365
  border: {
1361
1366
  default: "{core.colors.neutral.500}",
1362
1367
  hover: "{core.colors.neutral.300}",
1363
1368
  focused: "{core.colors.brand.500}",
1364
- disabled: "{core.colors.neutral.700}"
1369
+ disabled: "{core.colors.neutral.700}",
1370
+ invalid: "{core.colors.red.300}"
1365
1371
  },
1366
1372
  text: {
1367
1373
  default: "{core.colors.neutral.0}",
1368
- disabled: "{core.colors.neutral.500}"
1374
+ disabled: "{core.colors.neutral.500}",
1375
+ invalid: "{core.colors.neutral.0}"
1369
1376
  }
1370
1377
  },
1371
1378
  secondary: {
@@ -1789,10 +1796,17 @@ var levenshtein = (a, b) => {
1789
1796
  * Validate that every `{ref}` in the merged theme points to an existing path.
1790
1797
  * Emits `console.warn` for each broken reference with a "did you mean?" suggestion.
1791
1798
  *
1799
+ * `onlyOwnerKeys` restricts which token paths are *checked* (resolution still
1800
+ * looks at the whole tree) — used to validate just the leaves an alternate
1801
+ * introduces without re-warning refs already reported for the base.
1802
+ *
1792
1803
  * **DEV-only** — callers gate this behind `process.env.NODE_ENV !== 'production'`
1793
1804
  * so bundlers tree-shake the entire call in production builds.
1794
1805
  */
1795
- var validateRefs = theme => {
1806
+ var validateRefs = (theme, options = {}) => {
1807
+ const {
1808
+ onlyOwnerKeys
1809
+ } = options;
1796
1810
  const {
1797
1811
  core,
1798
1812
  semantic
@@ -1817,6 +1831,7 @@ var validateRefs = theme => {
1817
1831
  return "";
1818
1832
  };
1819
1833
  for (const [ownerKey, value] of Object.entries(all)) {
1834
+ if (onlyOwnerKeys && !onlyOwnerKeys.has(ownerKey)) continue;
1820
1835
  if (typeof value !== "string" || !value.includes("{")) continue;
1821
1836
  let match;
1822
1837
  const re = new RegExp(COMPOUND_REF_RE.source, COMPOUND_REF_RE.flags);
@@ -1835,6 +1850,41 @@ var validateRefs = theme => {
1835
1850
  //#endregion
1836
1851
  //#region src/createTheme.ts
1837
1852
  /**
1853
+ * Deep-clone to break shared references between base and result.
1854
+ * Tokens are primitives (strings, numbers) — `structuredClone` is safe and
1855
+ * more correct than a JSON round-trip (preserves `undefined`, `NaN`, etc.).
1856
+ *
1857
+ * Falls back to a JSON round-trip when `structuredClone` is unavailable
1858
+ * (e.g. Jest's jsdom environment, older embedded runtimes) so importing the
1859
+ * package never throws at module-evaluation time. Token trees are plain
1860
+ * string/number leaves, so the fallback is lossless for valid themes.
1861
+ */
1862
+ var cloneTokens = value => {
1863
+ if (typeof structuredClone === "function") return structuredClone(value);
1864
+ return JSON.parse(JSON.stringify(value));
1865
+ };
1866
+ /**
1867
+ * DEV-only: validate the refs an alternate introduces against the built base.
1868
+ * The alternate is authored by hand (semantic-only remaps), so a typo'd
1869
+ * dark-mode ref must warn at theme creation instead of silently emitting a
1870
+ * broken CSS var in production.
1871
+ *
1872
+ * Only the leaves the alternate itself provides are checked — base refs were
1873
+ * already validated by `buildTheme`, so they would otherwise warn twice.
1874
+ */
1875
+ var validateAlternateRefs = ({
1876
+ base,
1877
+ alternate
1878
+ }) => {
1879
+ const alternateKeys = new Set(Object.keys(flattenObject(alternate.semantic, "semantic")));
1880
+ validateRefs({
1881
+ core: base.core,
1882
+ semantic: deepMerge(base.semantic, alternate.semantic)
1883
+ }, {
1884
+ onlyOwnerKeys: alternateKeys
1885
+ });
1886
+ };
1887
+ /**
1838
1888
  * Creates a fully resolved `ThemeTokens` by merging partial overrides into a base.
1839
1889
  * Internal engine — consumers should use `createTheme` which returns `ThemeBundle`.
1840
1890
  *
@@ -1846,13 +1896,28 @@ var buildTheme = ({
1846
1896
  } = {}) => {
1847
1897
  const merged = deepMerge(base, overrides);
1848
1898
  if (process.env.NODE_ENV !== "production") validateRefs(merged);
1849
- return structuredClone(merged);
1899
+ return cloneTokens(merged);
1850
1900
  };
1851
1901
  var resolveAlternate = (alternate, parentBundle) => {
1852
1902
  if (alternate === null) return void 0;
1853
1903
  if (alternate !== void 0) return alternate;
1854
1904
  return parentBundle?.alternate ?? darkAlternate;
1855
1905
  };
1906
+ /** Resolve every `createTheme` input against its `extends` parent + defaults. */
1907
+ var resolveBundleInputs = ({
1908
+ parentBundle,
1909
+ baseMode,
1910
+ base,
1911
+ alternate,
1912
+ brief
1913
+ }) => {
1914
+ return {
1915
+ resolvedBase: base ?? parentBundle?.base,
1916
+ resolvedBaseMode: baseMode ?? parentBundle?.baseMode ?? "light",
1917
+ resolvedAlternate: resolveAlternate(alternate, parentBundle),
1918
+ resolvedMeta: brief ?? parentBundle?.meta
1919
+ };
1920
+ };
1856
1921
  /**
1857
1922
  * Creates a theme bundle with an optional alternate color mode.
1858
1923
  *
@@ -1903,16 +1968,29 @@ var createTheme = ({
1903
1968
  alternate,
1904
1969
  brief
1905
1970
  } = {}) => {
1906
- const resolvedBase = base ?? parentBundle?.base;
1907
- const resolvedBaseMode = baseMode ?? parentBundle?.baseMode ?? "light";
1908
- const resolvedAlternate = resolveAlternate(alternate, parentBundle);
1909
- const resolvedMeta = brief ?? parentBundle?.meta;
1971
+ const {
1972
+ resolvedBase,
1973
+ resolvedBaseMode,
1974
+ resolvedAlternate,
1975
+ resolvedMeta
1976
+ } = resolveBundleInputs({
1977
+ parentBundle,
1978
+ baseMode,
1979
+ base,
1980
+ alternate,
1981
+ brief
1982
+ });
1983
+ const builtBase = buildTheme({
1984
+ base: resolvedBase,
1985
+ overrides
1986
+ });
1987
+ if (process.env.NODE_ENV !== "production" && resolvedAlternate) validateAlternateRefs({
1988
+ base: builtBase,
1989
+ alternate: resolvedAlternate
1990
+ });
1910
1991
  return {
1911
1992
  baseMode: resolvedBaseMode,
1912
- base: buildTheme({
1913
- base: resolvedBase,
1914
- overrides
1915
- }),
1993
+ base: builtBase,
1916
1994
  alternate: resolvedAlternate,
1917
1995
  ...(resolvedMeta ? {
1918
1996
  meta: resolvedMeta
package/dist/css.cjs CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, {
3
3
  value: 'Module'
4
4
  });
5
5
  const require_helpers = require('./helpers-BU40JvFA.cjs');
6
- const require_toCssVars = require('./toCssVars-BseqmMcT.cjs');
6
+ const require_toCssVars = require('./toCssVars-D0BR23cP.cjs');
7
7
 
8
8
  //#region src/css.ts
9
9
  /**
@@ -35,9 +35,10 @@ const require_toCssVars = require('./toCssVars-BseqmMcT.cjs');
35
35
  * res.type('text/css').send(getThemeStylesContent(myBundle, 'myTheme'));
36
36
  * ```
37
37
  */
38
- var getThemeStylesContent = (bundle, themeId) => {
38
+ var getThemeStylesContent = (bundle, themeId, options) => {
39
39
  return require_toCssVars.toCssVars(bundle, {
40
- themeId
40
+ themeId,
41
+ systemModeFallback: options?.systemModeFallback
41
42
  }).toCssString();
42
43
  };
43
44
 
package/dist/css.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- import { a as ThemeTokens, i as ThemeBundle } from "./Types-BkaxtsMv.cjs";
2
+ import { a as ThemeTokens, i as ThemeBundle } from "./Types-a_sfpbha.cjs";
3
3
 
4
4
  //#region src/roots/helpers.d.ts
5
5
  /**
@@ -97,6 +97,18 @@ interface BundleCssVarsOptions {
97
97
  * multi-theme scenarios (Storybook, micro-frontends).
98
98
  */
99
99
  themeId?: string;
100
+ /**
101
+ * Emit the `@media (prefers-color-scheme)` fallback block so the OS
102
+ * preference applies before JS runs (and without JS). Only meaningful for
103
+ * themeId-less bundles. Default `true`.
104
+ *
105
+ * Set `false` when the app is deliberately single-default (`defaultMode`
106
+ * `'light'` or `'dark'` with the alternate reachable only via explicit
107
+ * toggle) — otherwise dark-OS users would get the alternate on first paint
108
+ * against the app's configured default. `<ThemeProvider>` / `<ThemeHead>`
109
+ * derive this automatically from their `defaultMode` prop.
110
+ */
111
+ systemModeFallback?: boolean;
100
112
  }
101
113
  /**
102
114
  * Return type of `bundleToCssVars()`.
@@ -163,6 +175,13 @@ declare function toCssVars(bundle: ThemeBundle, options?: BundleCssVarsOptions):
163
175
  * res.type('text/css').send(getThemeStylesContent(myBundle, 'myTheme'));
164
176
  * ```
165
177
  */
166
- declare const getThemeStylesContent: (bundle: ThemeBundle, themeId?: string) => string;
178
+ declare const getThemeStylesContent: (bundle: ThemeBundle, themeId?: string, options?: {
179
+ /**
180
+ * Emit the `@media (prefers-color-scheme)` fallback block (themeId-less
181
+ * bundles only). Default `true`. Pass `false` for apps whose
182
+ * `defaultMode` is a fixed `'light'`/`'dark'` rather than `'system'`.
183
+ */
184
+ systemModeFallback?: boolean;
185
+ }) => string;
167
186
  //#endregion
168
187
  export { type BundleCssVarsOptions, type BundleCssVarsResult, type CssVarsOptions, type CssVarsResult, type FlatTokenMap, getThemeStylesContent, toCssVarName, toCssVars, toFlatTokens };
package/dist/css.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- import { a as ThemeTokens, i as ThemeBundle } from "./Types-BkaxtsMv.mjs";
2
+ import { a as ThemeTokens, i as ThemeBundle } from "./Types-a_sfpbha.mjs";
3
3
 
4
4
  //#region src/roots/helpers.d.ts
5
5
  /**
@@ -97,6 +97,18 @@ interface BundleCssVarsOptions {
97
97
  * multi-theme scenarios (Storybook, micro-frontends).
98
98
  */
99
99
  themeId?: string;
100
+ /**
101
+ * Emit the `@media (prefers-color-scheme)` fallback block so the OS
102
+ * preference applies before JS runs (and without JS). Only meaningful for
103
+ * themeId-less bundles. Default `true`.
104
+ *
105
+ * Set `false` when the app is deliberately single-default (`defaultMode`
106
+ * `'light'` or `'dark'` with the alternate reachable only via explicit
107
+ * toggle) — otherwise dark-OS users would get the alternate on first paint
108
+ * against the app's configured default. `<ThemeProvider>` / `<ThemeHead>`
109
+ * derive this automatically from their `defaultMode` prop.
110
+ */
111
+ systemModeFallback?: boolean;
100
112
  }
101
113
  /**
102
114
  * Return type of `bundleToCssVars()`.
@@ -163,6 +175,13 @@ declare function toCssVars(bundle: ThemeBundle, options?: BundleCssVarsOptions):
163
175
  * res.type('text/css').send(getThemeStylesContent(myBundle, 'myTheme'));
164
176
  * ```
165
177
  */
166
- declare const getThemeStylesContent: (bundle: ThemeBundle, themeId?: string) => string;
178
+ declare const getThemeStylesContent: (bundle: ThemeBundle, themeId?: string, options?: {
179
+ /**
180
+ * Emit the `@media (prefers-color-scheme)` fallback block (themeId-less
181
+ * bundles only). Default `true`. Pass `false` for apps whose
182
+ * `defaultMode` is a fixed `'light'`/`'dark'` rather than `'system'`.
183
+ */
184
+ systemModeFallback?: boolean;
185
+ }) => string;
167
186
  //#endregion
168
187
  export { type BundleCssVarsOptions, type BundleCssVarsResult, type CssVarsOptions, type CssVarsResult, type FlatTokenMap, getThemeStylesContent, toCssVarName, toCssVars, toFlatTokens };
package/dist/css.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
2
  import { s as toFlatTokens } from "./helpers-BXaKe2s3.mjs";
3
- import { n as toCssVars, t as toCssVarName } from "./toCssVars-C-9yIZDR.mjs";
3
+ import { n as toCssVars, t as toCssVarName } from "./toCssVars-CWTlp9St.mjs";
4
4
 
5
5
  //#region src/css.ts
6
6
  /**
@@ -32,9 +32,10 @@ import { n as toCssVars, t as toCssVarName } from "./toCssVars-C-9yIZDR.mjs";
32
32
  * res.type('text/css').send(getThemeStylesContent(myBundle, 'myTheme'));
33
33
  * ```
34
34
  */
35
- var getThemeStylesContent = (bundle, themeId) => {
35
+ var getThemeStylesContent = (bundle, themeId, options) => {
36
36
  return toCssVars(bundle, {
37
- themeId
37
+ themeId,
38
+ systemModeFallback: options?.systemModeFallback
38
39
  }).toCssString();
39
40
  };
40
41
 
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, {
3
3
  value: 'Module'
4
4
  });
5
- const require_react = require('../react-DLB8nrXQ.cjs');
6
- const require_withDataviz = require('../withDataviz-CYRf4exT.cjs');
5
+ const require_react = require('../react-DQErMGJz.cjs');
6
+ const require_withDataviz = require('../withDataviz-DrUtw8cc.cjs');
7
7
 
8
8
  //#region src/dataviz/useDatavizTokens.ts
9
9
  /**
@@ -1,5 +1,5 @@
1
1
 
2
- import { c as SemanticDataviz, i as ThemeBundle, s as CoreDataviz } from "../Types-BkaxtsMv.cjs";
2
+ import { c as SemanticDataviz, i as ThemeBundle, s as CoreDataviz } from "../Types-a_sfpbha.cjs";
3
3
 
4
4
  //#region src/dataviz/baseTheme.d.ts
5
5
  /**
@@ -1,5 +1,5 @@
1
1
 
2
- import { c as SemanticDataviz, i as ThemeBundle, s as CoreDataviz } from "../Types-BkaxtsMv.mjs";
2
+ import { c as SemanticDataviz, i as ThemeBundle, s as CoreDataviz } from "../Types-a_sfpbha.mjs";
3
3
 
4
4
  //#region src/dataviz/baseTheme.d.ts
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
- import { n as coreDataviz, r as semanticDataviz, t as withDataviz } from "../withDataviz-BvpZJnFx.mjs";
2
+ import { n as coreDataviz, r as semanticDataviz, t as withDataviz } from "../withDataviz-Ln3sEwb7.mjs";
3
3
  import { useTokens } from "../react.mjs";
4
4
 
5
5
  //#region src/dataviz/useDatavizTokens.ts
package/dist/dtcg.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- import { a as ThemeTokens } from "./Types-BkaxtsMv.cjs";
2
+ import { a as ThemeTokens } from "./Types-a_sfpbha.cjs";
3
3
 
4
4
  //#region src/roots/toDTCG.d.ts
5
5
  /**
package/dist/dtcg.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- import { a as ThemeTokens } from "./Types-BkaxtsMv.mjs";
2
+ import { a as ThemeTokens } from "./Types-a_sfpbha.mjs";
3
3
 
4
4
  //#region src/roots/toDTCG.d.ts
5
5
  /**
@@ -1,5 +1,5 @@
1
1
 
2
- import { a as ThemeTokens, i as ThemeBundle, o as DeepPartial, r as ThemeBrief, t as ModeOverride } from "./Types-BkaxtsMv.cjs";
2
+ import { a as ThemeTokens, i as ThemeBundle, o as DeepPartial, r as ThemeBrief, t as ModeOverride } from "./Types-a_sfpbha.cjs";
3
3
  //#region src/baseTheme.d.ts
4
4
  /**
5
5
  * **Foundation** — Neutral baseline theme.
@@ -1,5 +1,5 @@
1
1
 
2
- import { a as ThemeTokens, i as ThemeBundle, o as DeepPartial, r as ThemeBrief, t as ModeOverride } from "./Types-BkaxtsMv.mjs";
2
+ import { a as ThemeTokens, i as ThemeBundle, o as DeepPartial, r as ThemeBrief, t as ModeOverride } from "./Types-a_sfpbha.mjs";
3
3
  //#region src/baseTheme.d.ts
4
4
  /**
5
5
  * **Foundation** — Neutral baseline theme.
package/dist/index.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, {
3
3
  value: 'Module'
4
4
  });
5
- const require_createTheme = require('./createTheme--UFgVlEn.cjs');
5
+ const require_createTheme = require('./createTheme-B7H0xSVp.cjs');
6
6
  const require_themes_bruttal = require('./themes/bruttal.cjs');
7
7
  exports.baseTheme = require_createTheme.baseTheme;
8
8
  exports.bruttal = require_themes_bruttal.bruttal;
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
- import { a as ThemeTokens, i as ThemeBundle, n as SemanticTokens, o as DeepPartial, r as ThemeBrief, t as ModeOverride } from "./Types-BkaxtsMv.cjs";
3
- import { i as darkAlternate, n as createTheme, r as baseTheme, t as bruttal } from "./index-7YL90Xqs.cjs";
2
+ import { a as ThemeTokens, i as ThemeBundle, n as SemanticTokens, o as DeepPartial, r as ThemeBrief, t as ModeOverride } from "./Types-a_sfpbha.cjs";
3
+ import { i as darkAlternate, n as createTheme, r as baseTheme, t as bruttal } from "./index-BmZQVd3G.cjs";
4
4
  import { o as ThemeMode } from "./ssrScript-BVysxDws.cjs";
5
- import { c as ThemeStylesProps, n as ThemeHeadProps } from "./react-Dt7vGAVG.cjs";
5
+ import { c as ThemeStylesProps, n as ThemeHeadProps } from "./react-2D_CNVF2.cjs";
6
6
  export { type DeepPartial, type ModeOverride, type SemanticTokens, type ThemeBrief, type ThemeBundle, type ThemeHeadProps, type ThemeMode, type ThemeStylesProps, type ThemeTokens, baseTheme, bruttal, createTheme, darkAlternate };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
- import { a as ThemeTokens, i as ThemeBundle, n as SemanticTokens, o as DeepPartial, r as ThemeBrief, t as ModeOverride } from "./Types-BkaxtsMv.mjs";
3
- import { i as darkAlternate, n as createTheme, r as baseTheme, t as bruttal } from "./index-BmCTIOzh.mjs";
2
+ import { a as ThemeTokens, i as ThemeBundle, n as SemanticTokens, o as DeepPartial, r as ThemeBrief, t as ModeOverride } from "./Types-a_sfpbha.mjs";
3
+ import { i as darkAlternate, n as createTheme, r as baseTheme, t as bruttal } from "./index-XZsRrMTF.mjs";
4
4
  import { o as ThemeMode } from "./ssrScript-BVysxDws.mjs";
5
- import { c as ThemeStylesProps, n as ThemeHeadProps } from "./react-C8JrZf-b.mjs";
5
+ import { c as ThemeStylesProps, n as ThemeHeadProps } from "./react-BwnHHvJj.mjs";
6
6
  export { type DeepPartial, type ModeOverride, type SemanticTokens, type ThemeBrief, type ThemeBundle, type ThemeHeadProps, type ThemeMode, type ThemeStylesProps, type ThemeTokens, baseTheme, bruttal, createTheme, darkAlternate };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
- import { a as darkAlternate, i as baseTheme, n as createTheme } from "./createTheme-B6tVIikC.mjs";
2
+ import { a as darkAlternate, i as baseTheme, n as createTheme } from "./createTheme-Bm9LVQ4w.mjs";
3
3
  import { bruttal } from "./themes/bruttal.mjs";
4
4
  export { baseTheme, bruttal, createTheme, darkAlternate };
@@ -1,9 +1,17 @@
1
1
 
2
- import { i as ThemeBundle, n as SemanticTokens } from "./Types-BkaxtsMv.cjs";
2
+ import { i as ThemeBundle, n as SemanticTokens } from "./Types-a_sfpbha.cjs";
3
3
  import { a as ResolvedMode, o as ThemeMode, t as ThemeScriptConfig } from "./ssrScript-BVysxDws.cjs";
4
4
  import * as React from "react";
5
5
 
6
6
  //#region src/react.d.ts
7
+ /**
8
+ * Accepted shapes for the `root` prop: a concrete element, or a ref object.
9
+ * Prefer the ref form — refs are populated before layout effects run, so the
10
+ * runtime attaches directly to the target element with no transient attach
11
+ * to `<html>` on the first render (the element form is `null` during the
12
+ * first render when read from `ref.current`).
13
+ */
14
+ type ThemeRootInput = HTMLElement | React.RefObject<HTMLElement | null>;
7
15
  /**
8
16
  * Props for the `ThemeProvider` component.
9
17
  */
@@ -83,25 +91,32 @@ interface ThemeProviderProps {
83
91
  onModeChange?: (mode: ThemeMode, resolvedMode: ResolvedMode) => void;
84
92
  /**
85
93
  * Root element to anchor `data-tt-theme` / `data-tt-mode` attributes.
86
- * Defaults to `document.documentElement`. Pass a container element for
87
- * Storybook isolation or micro-frontend use cases.
94
+ * Defaults to `document.documentElement`. Pass a container for Storybook
95
+ * isolation or micro-frontend use cases.
88
96
  *
89
- * Because the element is often `null` on the first render when passed via
90
- * `ref.current`, `root` is reactive: the runtime is recreated once when
91
- * it transitions from `undefined` to the actual element.
97
+ * **Must be paired with `themeId`.** Without a `themeId`, the generated CSS
98
+ * targets `:root` / `:root[data-tt-mode="dark"]` (the `<html>` element),
99
+ * while the attributes are written to this element — the alternate mode CSS
100
+ * would never match. A dev-mode warning fires on this combination.
101
+ *
102
+ * **Prefer passing the ref object itself** (`root={rootRef}`): refs are
103
+ * populated before layout effects, so the runtime attaches directly to the
104
+ * element. Passing `rootRef.current ?? undefined` also works, but the value
105
+ * is `null` on the first render, causing one transient attach to `<html>`
106
+ * before the runtime is recreated on the element.
92
107
  *
93
108
  * @example
94
109
  * ```tsx
95
110
  * // Storybook decorator — isolates each story from <html>
96
111
  * const rootRef = React.useRef<HTMLDivElement>(null);
97
112
  * <div ref={rootRef}>
98
- * <ThemeProvider theme={myTheme} root={rootRef.current ?? undefined}>
113
+ * <ThemeProvider theme={myTheme} themeId="story" root={rootRef}>
99
114
  * <Story />
100
115
  * </ThemeProvider>
101
116
  * </div>
102
117
  * ```
103
118
  */
104
- root?: HTMLElement;
119
+ root?: ThemeRootInput;
105
120
  children: React.ReactNode;
106
121
  }
107
122
  /**
@@ -134,7 +149,7 @@ declare const ThemeProvider: ({
134
149
  onModeChange,
135
150
  root,
136
151
  children
137
- }: ThemeProviderProps) => any;
152
+ }: ThemeProviderProps) => import("react/jsx-runtime").JSX.Element;
138
153
  /**
139
154
  * Access mode state and the mode setter — without subscribing to theme changes.
140
155
  *
@@ -178,11 +193,11 @@ declare const useColorMode: () => UseColorModeResult;
178
193
  * inline styles produces silently broken rendering:
179
194
  *
180
195
  * ```tsx
181
- * // ✗ WRONG — tokens.colors.brand.main is '{core.colors.brand.main}', not '#FF0000'
182
- * <div style={{ color: tokens.colors.brand.main }} />
196
+ * // ✗ WRONG — the leaf is '{core.colors.neutral.1000}' (a ref string), not a CSS color
197
+ * <div style={{ color: tokens.colors.action.primary.text.default }} />
183
198
  *
184
199
  * // ✓ CSS consumers — use vars:
185
- * <div style={{ color: 'var(--tt-color-brand-main)' }} />
200
+ * <div style={{ color: 'var(--tt-colors-action-primary-text-default)' }} />
186
201
  *
187
202
  * // ✓ Non-CSS consumers (React Native, canvas) — use useResolvedTokens():
188
203
  * const resolved = useResolvedTokens();
@@ -197,8 +212,8 @@ declare const useColorMode: () => UseColorModeResult;
197
212
  *
198
213
  * const Button = () => {
199
214
  * const tokens = useTokens(); // introspection only
200
- * // tokens.colors.action.primary.background.default → '{core.colors.brand.500}'
201
- * return <button style={{ background: 'var(--tt-action-primary-background-default)' }} />;
215
+ * // tokens.colors.action.primary.background.default → '{core.colors.neutral.1000}'
216
+ * return <button style={{ background: 'var(--tt-colors-action-primary-background-default)' }} />;
202
217
  * };
203
218
  * ```
204
219
  */
@@ -218,13 +233,21 @@ declare const useTokens: () => SemanticTokens;
218
233
  *
219
234
  * ```tsx
220
235
  * // ✓ CSS (browser)
221
- * <div style={{ color: 'var(--tt-color-informational-primary-default)' }} />
236
+ * <div style={{ color: 'var(--tt-colors-informational-primary-text-default)' }} />
222
237
  *
223
238
  * // ✓ Non-CSS (React Native, canvas)
224
239
  * const resolved = useResolvedTokens();
225
240
  * <View style={{ backgroundColor: resolved['semantic.colors.action.primary.background.default'] }} />
226
241
  * ```
227
242
  *
243
+ * ### ⚠ CSS-coupled tokens stay unresolved
244
+ * A registered set of dimensional tokens (model.md §8 — spacing steps, fluid
245
+ * `text.*.fontSize`, `sizing.hit.*`, `sizing.viewport.*`, `sizing.measure.reading`,
246
+ * `spacing.gutter.*`) carry CSS-only constructs (`var()`, `calc()`, `clamp()`,
247
+ * `cqi`, `dvh`, `ch`). This hook returns those **as-is** — they are not usable
248
+ * outside a CSS engine. Colors, opacity, z-index, font weights/leading and
249
+ * other scalar tokens resolve to plain raw values and are safe everywhere.
250
+ *
228
251
  * Requires `<ThemeProvider theme={...}>`.
229
252
  *
230
253
  * @example
@@ -276,7 +299,7 @@ declare const ThemeScript: ({
276
299
  defaultMode,
277
300
  storageKey,
278
301
  nonce
279
- }?: ThemeScriptProps) => any;
302
+ }?: ThemeScriptProps) => import("react/jsx-runtime").JSX.Element;
280
303
  /**
281
304
  * Props for the `ThemeStyles` component.
282
305
  */
@@ -296,6 +319,13 @@ interface ThemeStylesProps {
296
319
  themeId?: string;
297
320
  /** CSP nonce for the inline style tag. */
298
321
  nonce?: string;
322
+ /**
323
+ * Emit the `@media (prefers-color-scheme)` fallback block (themeId-less
324
+ * bundles only). Default `true`. Set `false` when the app's `defaultMode`
325
+ * is a fixed `'light'`/`'dark'` rather than `'system'` — `<ThemeHead>`
326
+ * derives this automatically from its `defaultMode`.
327
+ */
328
+ systemModeFallback?: boolean;
299
329
  }
300
330
  /**
301
331
  * Renders an inline `<style>` tag with all CSS Custom Properties for a theme
@@ -346,8 +376,9 @@ interface ThemeStylesProps {
346
376
  declare const ThemeStyles: ({
347
377
  theme,
348
378
  themeId,
349
- nonce
350
- }: ThemeStylesProps) => any;
379
+ nonce,
380
+ systemModeFallback
381
+ }: ThemeStylesProps) => import("react/jsx-runtime").JSX.Element;
351
382
  /**
352
383
  * Props for the `ThemeHead` component.
353
384
  */
@@ -406,6 +437,6 @@ declare const ThemeHead: ({
406
437
  nonce,
407
438
  defaultMode,
408
439
  storageKey
409
- }: ThemeHeadProps) => any;
440
+ }: ThemeHeadProps) => import("react/jsx-runtime").JSX.Element;
410
441
  //#endregion
411
442
  export { ThemeScript as a, ThemeStylesProps as c, useResolvedTokens as d, useTokens as f, ThemeProviderProps as i, UseColorModeResult as l, ThemeHeadProps as n, ThemeScriptProps as o, ThemeProvider as r, ThemeStyles as s, ThemeHead as t, useColorMode as u };