@ttoss/fsl-theme 2.1.3 → 2.1.4
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/README.md +2 -0
- package/dist/dataviz/index.cjs +29 -0
- package/dist/dataviz/index.d.cts +22 -1
- package/dist/dataviz/index.d.mts +22 -1
- package/dist/dataviz/index.mjs +29 -1
- package/dist/toVars-BDBDTI_F.mjs +39 -0
- package/dist/toVars-BTDr1haK.d.mts +46 -0
- package/dist/toVars-BcSZEbMb.d.cts +46 -0
- package/dist/toVars-O-E9ryvq.cjs +44 -0
- package/dist/vars.cjs +5 -39
- package/dist/vars.d.cts +4 -44
- package/dist/vars.d.mts +4 -44
- package/dist/vars.mjs +3 -37
- package/llms.txt +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -290,6 +290,8 @@ export const myVars: CssVarsMap<MySemanticTokens> = buildVarsMap(
|
|
|
290
290
|
|
|
291
291
|
For one-off custom keys, use `toCssVarName` from `@ttoss/fsl-theme/css` directly — no extended type required.
|
|
292
292
|
|
|
293
|
+
The first-party dataviz extension ships its own mirror — import `datavizVars` from `@ttoss/fsl-theme/dataviz` instead of hand-rolling this recipe (e.g. `datavizVars.color.series[1]` → `'var(--tt-dataviz-color-series-1)'`).
|
|
294
|
+
|
|
293
295
|
## Next.js (SSR)
|
|
294
296
|
|
|
295
297
|
### React 19 App Router (recommended)
|
package/dist/dataviz/index.cjs
CHANGED
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, Symbol.toStringTag, {
|
|
|
3
3
|
value: 'Module'
|
|
4
4
|
});
|
|
5
5
|
const require_react = require('../react-C1WRCOFF.cjs');
|
|
6
|
+
const require_baseBundle = require('../baseBundle-DaO6jyk3.cjs');
|
|
6
7
|
const require_withDataviz = require('../withDataviz-BzDgnXPu.cjs');
|
|
8
|
+
const require_toVars = require('../toVars-O-E9ryvq.cjs');
|
|
7
9
|
|
|
8
10
|
//#region src/dataviz/useDatavizTokens.ts
|
|
9
11
|
/**
|
|
@@ -38,8 +40,35 @@ var useDatavizTokens = () => {
|
|
|
38
40
|
return tokens.dataviz;
|
|
39
41
|
};
|
|
40
42
|
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/dataviz/vars.ts
|
|
45
|
+
/**
|
|
46
|
+
* Typed CSS-var mirror of the dataviz semantic tokens — the extension's
|
|
47
|
+
* counterpart of the foundation's `vars` export.
|
|
48
|
+
*
|
|
49
|
+
* Var names derive from token paths alone, so this map is valid for any
|
|
50
|
+
* theme extended with `withDataviz` (only the values behind the CSS vars
|
|
51
|
+
* change per theme/mode). Chart code references the vars; the CSS emitted
|
|
52
|
+
* by `toCssVars` carries the values.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```tsx
|
|
56
|
+
* import { datavizVars } from '@ttoss/fsl-theme/dataviz';
|
|
57
|
+
*
|
|
58
|
+
* <rect fill={datavizVars.color.series[1]} />
|
|
59
|
+
* // → fill: 'var(--tt-dataviz-color-series-1)'
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
var datavizVars = require_toVars.buildVarsMap({
|
|
63
|
+
core: require_baseBundle.baseBundle.base.core,
|
|
64
|
+
semantic: {
|
|
65
|
+
dataviz: require_withDataviz.semanticDataviz
|
|
66
|
+
}
|
|
67
|
+
}).dataviz;
|
|
68
|
+
|
|
41
69
|
//#endregion
|
|
42
70
|
exports.coreDataviz = require_withDataviz.coreDataviz;
|
|
71
|
+
exports.datavizVars = datavizVars;
|
|
43
72
|
exports.semanticDataviz = require_withDataviz.semanticDataviz;
|
|
44
73
|
exports.useDatavizTokens = useDatavizTokens;
|
|
45
74
|
exports.withDataviz = require_withDataviz.withDataviz;
|
package/dist/dataviz/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { c as SemanticDataviz, i as ThemeBundle, s as CoreDataviz } from "../Types-8o6d09ll.cjs";
|
|
3
|
+
import { t as CssVarsMap } from "../toVars-BcSZEbMb.cjs";
|
|
3
4
|
|
|
4
5
|
//#region src/dataviz/baseTheme.d.ts
|
|
5
6
|
/**
|
|
@@ -39,6 +40,26 @@ declare const semanticDataviz: SemanticDataviz;
|
|
|
39
40
|
*/
|
|
40
41
|
declare const useDatavizTokens: () => SemanticDataviz;
|
|
41
42
|
//#endregion
|
|
43
|
+
//#region src/dataviz/vars.d.ts
|
|
44
|
+
/**
|
|
45
|
+
* Typed CSS-var mirror of the dataviz semantic tokens — the extension's
|
|
46
|
+
* counterpart of the foundation's `vars` export.
|
|
47
|
+
*
|
|
48
|
+
* Var names derive from token paths alone, so this map is valid for any
|
|
49
|
+
* theme extended with `withDataviz` (only the values behind the CSS vars
|
|
50
|
+
* change per theme/mode). Chart code references the vars; the CSS emitted
|
|
51
|
+
* by `toCssVars` carries the values.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```tsx
|
|
55
|
+
* import { datavizVars } from '@ttoss/fsl-theme/dataviz';
|
|
56
|
+
*
|
|
57
|
+
* <rect fill={datavizVars.color.series[1]} />
|
|
58
|
+
* // → fill: 'var(--tt-dataviz-color-series-1)'
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
declare const datavizVars: CssVarsMap<SemanticDataviz>;
|
|
62
|
+
//#endregion
|
|
42
63
|
//#region src/dataviz/withDataviz.d.ts
|
|
43
64
|
/**
|
|
44
65
|
* Extend a `ThemeBundle` with the dataviz token layer.
|
|
@@ -63,4 +84,4 @@ declare const useDatavizTokens: () => SemanticDataviz;
|
|
|
63
84
|
*/
|
|
64
85
|
declare const withDataviz: (bundle: ThemeBundle) => ThemeBundle;
|
|
65
86
|
//#endregion
|
|
66
|
-
export { type CoreDataviz, type SemanticDataviz, coreDataviz, semanticDataviz, useDatavizTokens, withDataviz };
|
|
87
|
+
export { type CoreDataviz, type SemanticDataviz, coreDataviz, datavizVars, semanticDataviz, useDatavizTokens, withDataviz };
|
package/dist/dataviz/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { c as SemanticDataviz, i as ThemeBundle, s as CoreDataviz } from "../Types-8o6d09ll.mjs";
|
|
3
|
+
import { t as CssVarsMap } from "../toVars-BTDr1haK.mjs";
|
|
3
4
|
|
|
4
5
|
//#region src/dataviz/baseTheme.d.ts
|
|
5
6
|
/**
|
|
@@ -39,6 +40,26 @@ declare const semanticDataviz: SemanticDataviz;
|
|
|
39
40
|
*/
|
|
40
41
|
declare const useDatavizTokens: () => SemanticDataviz;
|
|
41
42
|
//#endregion
|
|
43
|
+
//#region src/dataviz/vars.d.ts
|
|
44
|
+
/**
|
|
45
|
+
* Typed CSS-var mirror of the dataviz semantic tokens — the extension's
|
|
46
|
+
* counterpart of the foundation's `vars` export.
|
|
47
|
+
*
|
|
48
|
+
* Var names derive from token paths alone, so this map is valid for any
|
|
49
|
+
* theme extended with `withDataviz` (only the values behind the CSS vars
|
|
50
|
+
* change per theme/mode). Chart code references the vars; the CSS emitted
|
|
51
|
+
* by `toCssVars` carries the values.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```tsx
|
|
55
|
+
* import { datavizVars } from '@ttoss/fsl-theme/dataviz';
|
|
56
|
+
*
|
|
57
|
+
* <rect fill={datavizVars.color.series[1]} />
|
|
58
|
+
* // → fill: 'var(--tt-dataviz-color-series-1)'
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
declare const datavizVars: CssVarsMap<SemanticDataviz>;
|
|
62
|
+
//#endregion
|
|
42
63
|
//#region src/dataviz/withDataviz.d.ts
|
|
43
64
|
/**
|
|
44
65
|
* Extend a `ThemeBundle` with the dataviz token layer.
|
|
@@ -63,4 +84,4 @@ declare const useDatavizTokens: () => SemanticDataviz;
|
|
|
63
84
|
*/
|
|
64
85
|
declare const withDataviz: (bundle: ThemeBundle) => ThemeBundle;
|
|
65
86
|
//#endregion
|
|
66
|
-
export { type CoreDataviz, type SemanticDataviz, coreDataviz, semanticDataviz, useDatavizTokens, withDataviz };
|
|
87
|
+
export { type CoreDataviz, type SemanticDataviz, coreDataviz, datavizVars, semanticDataviz, useDatavizTokens, withDataviz };
|
package/dist/dataviz/index.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
import { t as baseBundle } from "../baseBundle-BpCf8Cc9.mjs";
|
|
2
3
|
import { n as coreDataviz, r as semanticDataviz, t as withDataviz } from "../withDataviz-BKqs0un0.mjs";
|
|
3
4
|
import { useTokens } from "../react.mjs";
|
|
5
|
+
import { t as buildVarsMap } from "../toVars-BDBDTI_F.mjs";
|
|
4
6
|
|
|
5
7
|
//#region src/dataviz/useDatavizTokens.ts
|
|
6
8
|
/**
|
|
@@ -36,4 +38,30 @@ var useDatavizTokens = () => {
|
|
|
36
38
|
};
|
|
37
39
|
|
|
38
40
|
//#endregion
|
|
39
|
-
|
|
41
|
+
//#region src/dataviz/vars.ts
|
|
42
|
+
/**
|
|
43
|
+
* Typed CSS-var mirror of the dataviz semantic tokens — the extension's
|
|
44
|
+
* counterpart of the foundation's `vars` export.
|
|
45
|
+
*
|
|
46
|
+
* Var names derive from token paths alone, so this map is valid for any
|
|
47
|
+
* theme extended with `withDataviz` (only the values behind the CSS vars
|
|
48
|
+
* change per theme/mode). Chart code references the vars; the CSS emitted
|
|
49
|
+
* by `toCssVars` carries the values.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```tsx
|
|
53
|
+
* import { datavizVars } from '@ttoss/fsl-theme/dataviz';
|
|
54
|
+
*
|
|
55
|
+
* <rect fill={datavizVars.color.series[1]} />
|
|
56
|
+
* // → fill: 'var(--tt-dataviz-color-series-1)'
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
var datavizVars = buildVarsMap({
|
|
60
|
+
core: baseBundle.base.core,
|
|
61
|
+
semantic: {
|
|
62
|
+
dataviz: semanticDataviz
|
|
63
|
+
}
|
|
64
|
+
}).dataviz;
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
export { coreDataviz, datavizVars, semanticDataviz, useDatavizTokens, withDataviz };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
import { o as isPlainObject } from "./helpers-BXaKe2s3.mjs";
|
|
3
|
+
import { t as toCssVarName } from "./toCssVars-CTGqZ_t3.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/roots/toVars.ts
|
|
6
|
+
/**
|
|
7
|
+
* Build a deeply-nested CSS var-reference map from a theme's semantic layer.
|
|
8
|
+
*
|
|
9
|
+
* Walks `theme.semantic` recursively and replaces every leaf value with the
|
|
10
|
+
* corresponding `var(--tt-*)` CSS custom property reference. The resulting
|
|
11
|
+
* object has the exact same shape as `theme.semantic` but with `string` leaves.
|
|
12
|
+
*
|
|
13
|
+
* Keys starting with `$` are skipped (deprecation metadata).
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { buildVarsMap } from './roots/toVars';
|
|
18
|
+
* import { baseTheme } from './baseTheme';
|
|
19
|
+
*
|
|
20
|
+
* const vars = buildVarsMap(baseTheme);
|
|
21
|
+
* vars.colors.action.primary.background.default
|
|
22
|
+
* // → 'var(--tt-colors-action-primary-background-default)'
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
var buildVarsMap = theme => {
|
|
26
|
+
const walk = (obj, prefix) => {
|
|
27
|
+
const result = {};
|
|
28
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
29
|
+
if (key.startsWith("$")) continue;
|
|
30
|
+
const fullPath = `${prefix}.${key}`;
|
|
31
|
+
if (isPlainObject(value)) result[key] = walk(value, fullPath);else if (typeof value === "string" || typeof value === "number") result[key] = `var(${toCssVarName(fullPath)})`;
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
return walk(theme.semantic, "semantic");
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
export { buildVarsMap as t };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
|
|
2
|
+
import { a as ThemeTokens } from "./Types-8o6d09ll.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/roots/toVars.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Transforms a token-tree type into an identical structure where every leaf
|
|
7
|
+
* value becomes `string` (a CSS `var(--tt-*)` reference).
|
|
8
|
+
*
|
|
9
|
+
* Keys starting with `$` (e.g. `$deprecated`) are excluded — they are
|
|
10
|
+
* metadata, not consumable tokens.
|
|
11
|
+
*
|
|
12
|
+
* Optional keys in the source type remain optional in the mapped type, so
|
|
13
|
+
* theme extensions such as `dataviz?` are typed as `CssVarsMap<...> | undefined`
|
|
14
|
+
* and TypeScript will require callers to guard against `undefined` before
|
|
15
|
+
* accessing their members.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* type Colors = { action: { primary: { background: { default: TokenRef } } } };
|
|
20
|
+
* type ColorVars = CssVarsMap<Colors>;
|
|
21
|
+
* // → { action: { primary: { background: { default: string } } } }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
type CssVarsMap<T> = { [K in keyof T as K extends `$${string}` ? never : K]: NonNullable<T[K]> extends string | number ? string : undefined extends T[K] ? CssVarsMap<NonNullable<T[K]>> | undefined : CssVarsMap<NonNullable<T[K]>> };
|
|
25
|
+
/**
|
|
26
|
+
* Build a deeply-nested CSS var-reference map from a theme's semantic layer.
|
|
27
|
+
*
|
|
28
|
+
* Walks `theme.semantic` recursively and replaces every leaf value with the
|
|
29
|
+
* corresponding `var(--tt-*)` CSS custom property reference. The resulting
|
|
30
|
+
* object has the exact same shape as `theme.semantic` but with `string` leaves.
|
|
31
|
+
*
|
|
32
|
+
* Keys starting with `$` are skipped (deprecation metadata).
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { buildVarsMap } from './roots/toVars';
|
|
37
|
+
* import { baseTheme } from './baseTheme';
|
|
38
|
+
*
|
|
39
|
+
* const vars = buildVarsMap(baseTheme);
|
|
40
|
+
* vars.colors.action.primary.background.default
|
|
41
|
+
* // → 'var(--tt-colors-action-primary-background-default)'
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
declare const buildVarsMap: (theme: ThemeTokens) => CssVarsMap<ThemeTokens["semantic"]>;
|
|
45
|
+
//#endregion
|
|
46
|
+
export { buildVarsMap as n, CssVarsMap as t };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
|
|
2
|
+
import { a as ThemeTokens } from "./Types-8o6d09ll.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/roots/toVars.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Transforms a token-tree type into an identical structure where every leaf
|
|
7
|
+
* value becomes `string` (a CSS `var(--tt-*)` reference).
|
|
8
|
+
*
|
|
9
|
+
* Keys starting with `$` (e.g. `$deprecated`) are excluded — they are
|
|
10
|
+
* metadata, not consumable tokens.
|
|
11
|
+
*
|
|
12
|
+
* Optional keys in the source type remain optional in the mapped type, so
|
|
13
|
+
* theme extensions such as `dataviz?` are typed as `CssVarsMap<...> | undefined`
|
|
14
|
+
* and TypeScript will require callers to guard against `undefined` before
|
|
15
|
+
* accessing their members.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* type Colors = { action: { primary: { background: { default: TokenRef } } } };
|
|
20
|
+
* type ColorVars = CssVarsMap<Colors>;
|
|
21
|
+
* // → { action: { primary: { background: { default: string } } } }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
type CssVarsMap<T> = { [K in keyof T as K extends `$${string}` ? never : K]: NonNullable<T[K]> extends string | number ? string : undefined extends T[K] ? CssVarsMap<NonNullable<T[K]>> | undefined : CssVarsMap<NonNullable<T[K]>> };
|
|
25
|
+
/**
|
|
26
|
+
* Build a deeply-nested CSS var-reference map from a theme's semantic layer.
|
|
27
|
+
*
|
|
28
|
+
* Walks `theme.semantic` recursively and replaces every leaf value with the
|
|
29
|
+
* corresponding `var(--tt-*)` CSS custom property reference. The resulting
|
|
30
|
+
* object has the exact same shape as `theme.semantic` but with `string` leaves.
|
|
31
|
+
*
|
|
32
|
+
* Keys starting with `$` are skipped (deprecation metadata).
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { buildVarsMap } from './roots/toVars';
|
|
37
|
+
* import { baseTheme } from './baseTheme';
|
|
38
|
+
*
|
|
39
|
+
* const vars = buildVarsMap(baseTheme);
|
|
40
|
+
* vars.colors.action.primary.background.default
|
|
41
|
+
* // → 'var(--tt-colors-action-primary-background-default)'
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
declare const buildVarsMap: (theme: ThemeTokens) => CssVarsMap<ThemeTokens["semantic"]>;
|
|
45
|
+
//#endregion
|
|
46
|
+
export { buildVarsMap as n, CssVarsMap as t };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
const require_helpers = require('./helpers-BU40JvFA.cjs');
|
|
3
|
+
const require_toCssVars = require('./toCssVars-NGi4K2Oc.cjs');
|
|
4
|
+
|
|
5
|
+
//#region src/roots/toVars.ts
|
|
6
|
+
/**
|
|
7
|
+
* Build a deeply-nested CSS var-reference map from a theme's semantic layer.
|
|
8
|
+
*
|
|
9
|
+
* Walks `theme.semantic` recursively and replaces every leaf value with the
|
|
10
|
+
* corresponding `var(--tt-*)` CSS custom property reference. The resulting
|
|
11
|
+
* object has the exact same shape as `theme.semantic` but with `string` leaves.
|
|
12
|
+
*
|
|
13
|
+
* Keys starting with `$` are skipped (deprecation metadata).
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { buildVarsMap } from './roots/toVars';
|
|
18
|
+
* import { baseTheme } from './baseTheme';
|
|
19
|
+
*
|
|
20
|
+
* const vars = buildVarsMap(baseTheme);
|
|
21
|
+
* vars.colors.action.primary.background.default
|
|
22
|
+
* // → 'var(--tt-colors-action-primary-background-default)'
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
var buildVarsMap = theme => {
|
|
26
|
+
const walk = (obj, prefix) => {
|
|
27
|
+
const result = {};
|
|
28
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
29
|
+
if (key.startsWith("$")) continue;
|
|
30
|
+
const fullPath = `${prefix}.${key}`;
|
|
31
|
+
if (require_helpers.isPlainObject(value)) result[key] = walk(value, fullPath);else if (typeof value === "string" || typeof value === "number") result[key] = `var(${require_toCssVars.toCssVarName(fullPath)})`;
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
return walk(theme.semantic, "semantic");
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
Object.defineProperty(exports, 'buildVarsMap', {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function () {
|
|
42
|
+
return buildVarsMap;
|
|
43
|
+
}
|
|
44
|
+
});
|
package/dist/vars.cjs
CHANGED
|
@@ -2,44 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, {
|
|
3
3
|
value: 'Module'
|
|
4
4
|
});
|
|
5
|
-
const require_helpers = require('./helpers-BU40JvFA.cjs');
|
|
6
5
|
const require_baseBundle = require('./baseBundle-DaO6jyk3.cjs');
|
|
7
|
-
const
|
|
6
|
+
const require_toVars = require('./toVars-O-E9ryvq.cjs');
|
|
8
7
|
|
|
9
|
-
//#region src/roots/toVars.ts
|
|
10
|
-
/**
|
|
11
|
-
* Build a deeply-nested CSS var-reference map from a theme's semantic layer.
|
|
12
|
-
*
|
|
13
|
-
* Walks `theme.semantic` recursively and replaces every leaf value with the
|
|
14
|
-
* corresponding `var(--tt-*)` CSS custom property reference. The resulting
|
|
15
|
-
* object has the exact same shape as `theme.semantic` but with `string` leaves.
|
|
16
|
-
*
|
|
17
|
-
* Keys starting with `$` are skipped (deprecation metadata).
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```ts
|
|
21
|
-
* import { buildVarsMap } from './roots/toVars';
|
|
22
|
-
* import { baseTheme } from './baseTheme';
|
|
23
|
-
*
|
|
24
|
-
* const vars = buildVarsMap(baseTheme);
|
|
25
|
-
* vars.colors.action.primary.background.default
|
|
26
|
-
* // → 'var(--tt-colors-action-primary-background-default)'
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
var buildVarsMap = theme => {
|
|
30
|
-
const walk = (obj, prefix) => {
|
|
31
|
-
const result = {};
|
|
32
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
33
|
-
if (key.startsWith("$")) continue;
|
|
34
|
-
const fullPath = `${prefix}.${key}`;
|
|
35
|
-
if (require_helpers.isPlainObject(value)) result[key] = walk(value, fullPath);else if (typeof value === "string" || typeof value === "number") result[key] = `var(${require_toCssVars.toCssVarName(fullPath)})`;
|
|
36
|
-
}
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
|
-
return walk(theme.semantic, "semantic");
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
//#endregion
|
|
43
8
|
//#region src/vars.ts
|
|
44
9
|
/**
|
|
45
10
|
* Static map of all semantic tokens as typed CSS `var(--tt-*)` references.
|
|
@@ -84,7 +49,8 @@ var buildVarsMap = theme => {
|
|
|
84
49
|
* `vars` reflects the semantic token shape of the **default theme**. If your
|
|
85
50
|
* project extends `SemanticTokens` with custom token families (e.g. a
|
|
86
51
|
* `dataviz` palette, project-specific component tokens), those extra leaves
|
|
87
|
-
* won't appear on this export.
|
|
52
|
+
* won't appear on this export. The first-party dataviz extension ships its
|
|
53
|
+
* own mirror — `datavizVars` from `@ttoss/fsl-theme/dataviz`.
|
|
88
54
|
*
|
|
89
55
|
* ### Typed extension recipe
|
|
90
56
|
*
|
|
@@ -120,8 +86,8 @@ var buildVarsMap = theme => {
|
|
|
120
86
|
* @see {@link toCssVarName} — for raw CSS property names (without `var()`)
|
|
121
87
|
* @see {@link useResolvedTokens} — for resolved raw values in non-CSS environments (React Native, canvas, PDF)
|
|
122
88
|
*/
|
|
123
|
-
var vars = buildVarsMap(require_baseBundle.baseBundle.base);
|
|
89
|
+
var vars = require_toVars.buildVarsMap(require_baseBundle.baseBundle.base);
|
|
124
90
|
|
|
125
91
|
//#endregion
|
|
126
|
-
exports.buildVarsMap = buildVarsMap;
|
|
92
|
+
exports.buildVarsMap = require_toVars.buildVarsMap;
|
|
127
93
|
exports.vars = vars;
|
package/dist/vars.d.cts
CHANGED
|
@@ -1,48 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
2
|
+
import { n as SemanticTokens } from "./Types-8o6d09ll.cjs";
|
|
3
|
+
import { n as buildVarsMap, t as CssVarsMap } from "./toVars-BcSZEbMb.cjs";
|
|
3
4
|
|
|
4
|
-
//#region src/roots/toVars.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Transforms a token-tree type into an identical structure where every leaf
|
|
7
|
-
* value becomes `string` (a CSS `var(--tt-*)` reference).
|
|
8
|
-
*
|
|
9
|
-
* Keys starting with `$` (e.g. `$deprecated`) are excluded — they are
|
|
10
|
-
* metadata, not consumable tokens.
|
|
11
|
-
*
|
|
12
|
-
* Optional keys in the source type remain optional in the mapped type, so
|
|
13
|
-
* theme extensions such as `dataviz?` are typed as `CssVarsMap<...> | undefined`
|
|
14
|
-
* and TypeScript will require callers to guard against `undefined` before
|
|
15
|
-
* accessing their members.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```ts
|
|
19
|
-
* type Colors = { action: { primary: { background: { default: TokenRef } } } };
|
|
20
|
-
* type ColorVars = CssVarsMap<Colors>;
|
|
21
|
-
* // → { action: { primary: { background: { default: string } } } }
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
type CssVarsMap<T> = { [K in keyof T as K extends `$${string}` ? never : K]: NonNullable<T[K]> extends string | number ? string : undefined extends T[K] ? CssVarsMap<NonNullable<T[K]>> | undefined : CssVarsMap<NonNullable<T[K]>> };
|
|
25
|
-
/**
|
|
26
|
-
* Build a deeply-nested CSS var-reference map from a theme's semantic layer.
|
|
27
|
-
*
|
|
28
|
-
* Walks `theme.semantic` recursively and replaces every leaf value with the
|
|
29
|
-
* corresponding `var(--tt-*)` CSS custom property reference. The resulting
|
|
30
|
-
* object has the exact same shape as `theme.semantic` but with `string` leaves.
|
|
31
|
-
*
|
|
32
|
-
* Keys starting with `$` are skipped (deprecation metadata).
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```ts
|
|
36
|
-
* import { buildVarsMap } from './roots/toVars';
|
|
37
|
-
* import { baseTheme } from './baseTheme';
|
|
38
|
-
*
|
|
39
|
-
* const vars = buildVarsMap(baseTheme);
|
|
40
|
-
* vars.colors.action.primary.background.default
|
|
41
|
-
* // → 'var(--tt-colors-action-primary-background-default)'
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
declare const buildVarsMap: (theme: ThemeTokens) => CssVarsMap<ThemeTokens["semantic"]>;
|
|
45
|
-
//#endregion
|
|
46
5
|
//#region src/vars.d.ts
|
|
47
6
|
/**
|
|
48
7
|
* Static map of all semantic tokens as typed CSS `var(--tt-*)` references.
|
|
@@ -87,7 +46,8 @@ declare const buildVarsMap: (theme: ThemeTokens) => CssVarsMap<ThemeTokens["sema
|
|
|
87
46
|
* `vars` reflects the semantic token shape of the **default theme**. If your
|
|
88
47
|
* project extends `SemanticTokens` with custom token families (e.g. a
|
|
89
48
|
* `dataviz` palette, project-specific component tokens), those extra leaves
|
|
90
|
-
* won't appear on this export.
|
|
49
|
+
* won't appear on this export. The first-party dataviz extension ships its
|
|
50
|
+
* own mirror — `datavizVars` from `@ttoss/fsl-theme/dataviz`.
|
|
91
51
|
*
|
|
92
52
|
* ### Typed extension recipe
|
|
93
53
|
*
|
package/dist/vars.d.mts
CHANGED
|
@@ -1,48 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
2
|
+
import { n as SemanticTokens } from "./Types-8o6d09ll.mjs";
|
|
3
|
+
import { n as buildVarsMap, t as CssVarsMap } from "./toVars-BTDr1haK.mjs";
|
|
3
4
|
|
|
4
|
-
//#region src/roots/toVars.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Transforms a token-tree type into an identical structure where every leaf
|
|
7
|
-
* value becomes `string` (a CSS `var(--tt-*)` reference).
|
|
8
|
-
*
|
|
9
|
-
* Keys starting with `$` (e.g. `$deprecated`) are excluded — they are
|
|
10
|
-
* metadata, not consumable tokens.
|
|
11
|
-
*
|
|
12
|
-
* Optional keys in the source type remain optional in the mapped type, so
|
|
13
|
-
* theme extensions such as `dataviz?` are typed as `CssVarsMap<...> | undefined`
|
|
14
|
-
* and TypeScript will require callers to guard against `undefined` before
|
|
15
|
-
* accessing their members.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```ts
|
|
19
|
-
* type Colors = { action: { primary: { background: { default: TokenRef } } } };
|
|
20
|
-
* type ColorVars = CssVarsMap<Colors>;
|
|
21
|
-
* // → { action: { primary: { background: { default: string } } } }
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
type CssVarsMap<T> = { [K in keyof T as K extends `$${string}` ? never : K]: NonNullable<T[K]> extends string | number ? string : undefined extends T[K] ? CssVarsMap<NonNullable<T[K]>> | undefined : CssVarsMap<NonNullable<T[K]>> };
|
|
25
|
-
/**
|
|
26
|
-
* Build a deeply-nested CSS var-reference map from a theme's semantic layer.
|
|
27
|
-
*
|
|
28
|
-
* Walks `theme.semantic` recursively and replaces every leaf value with the
|
|
29
|
-
* corresponding `var(--tt-*)` CSS custom property reference. The resulting
|
|
30
|
-
* object has the exact same shape as `theme.semantic` but with `string` leaves.
|
|
31
|
-
*
|
|
32
|
-
* Keys starting with `$` are skipped (deprecation metadata).
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```ts
|
|
36
|
-
* import { buildVarsMap } from './roots/toVars';
|
|
37
|
-
* import { baseTheme } from './baseTheme';
|
|
38
|
-
*
|
|
39
|
-
* const vars = buildVarsMap(baseTheme);
|
|
40
|
-
* vars.colors.action.primary.background.default
|
|
41
|
-
* // → 'var(--tt-colors-action-primary-background-default)'
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
declare const buildVarsMap: (theme: ThemeTokens) => CssVarsMap<ThemeTokens["semantic"]>;
|
|
45
|
-
//#endregion
|
|
46
5
|
//#region src/vars.d.ts
|
|
47
6
|
/**
|
|
48
7
|
* Static map of all semantic tokens as typed CSS `var(--tt-*)` references.
|
|
@@ -87,7 +46,8 @@ declare const buildVarsMap: (theme: ThemeTokens) => CssVarsMap<ThemeTokens["sema
|
|
|
87
46
|
* `vars` reflects the semantic token shape of the **default theme**. If your
|
|
88
47
|
* project extends `SemanticTokens` with custom token families (e.g. a
|
|
89
48
|
* `dataviz` palette, project-specific component tokens), those extra leaves
|
|
90
|
-
* won't appear on this export.
|
|
49
|
+
* won't appear on this export. The first-party dataviz extension ships its
|
|
50
|
+
* own mirror — `datavizVars` from `@ttoss/fsl-theme/dataviz`.
|
|
91
51
|
*
|
|
92
52
|
* ### Typed extension recipe
|
|
93
53
|
*
|
package/dist/vars.mjs
CHANGED
|
@@ -1,42 +1,7 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
-
import { o as isPlainObject } from "./helpers-BXaKe2s3.mjs";
|
|
3
2
|
import { t as baseBundle } from "./baseBundle-BpCf8Cc9.mjs";
|
|
4
|
-
import { t as
|
|
3
|
+
import { t as buildVarsMap } from "./toVars-BDBDTI_F.mjs";
|
|
5
4
|
|
|
6
|
-
//#region src/roots/toVars.ts
|
|
7
|
-
/**
|
|
8
|
-
* Build a deeply-nested CSS var-reference map from a theme's semantic layer.
|
|
9
|
-
*
|
|
10
|
-
* Walks `theme.semantic` recursively and replaces every leaf value with the
|
|
11
|
-
* corresponding `var(--tt-*)` CSS custom property reference. The resulting
|
|
12
|
-
* object has the exact same shape as `theme.semantic` but with `string` leaves.
|
|
13
|
-
*
|
|
14
|
-
* Keys starting with `$` are skipped (deprecation metadata).
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```ts
|
|
18
|
-
* import { buildVarsMap } from './roots/toVars';
|
|
19
|
-
* import { baseTheme } from './baseTheme';
|
|
20
|
-
*
|
|
21
|
-
* const vars = buildVarsMap(baseTheme);
|
|
22
|
-
* vars.colors.action.primary.background.default
|
|
23
|
-
* // → 'var(--tt-colors-action-primary-background-default)'
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
var buildVarsMap = theme => {
|
|
27
|
-
const walk = (obj, prefix) => {
|
|
28
|
-
const result = {};
|
|
29
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
30
|
-
if (key.startsWith("$")) continue;
|
|
31
|
-
const fullPath = `${prefix}.${key}`;
|
|
32
|
-
if (isPlainObject(value)) result[key] = walk(value, fullPath);else if (typeof value === "string" || typeof value === "number") result[key] = `var(${toCssVarName(fullPath)})`;
|
|
33
|
-
}
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
|
-
return walk(theme.semantic, "semantic");
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
//#endregion
|
|
40
5
|
//#region src/vars.ts
|
|
41
6
|
/**
|
|
42
7
|
* Static map of all semantic tokens as typed CSS `var(--tt-*)` references.
|
|
@@ -81,7 +46,8 @@ var buildVarsMap = theme => {
|
|
|
81
46
|
* `vars` reflects the semantic token shape of the **default theme**. If your
|
|
82
47
|
* project extends `SemanticTokens` with custom token families (e.g. a
|
|
83
48
|
* `dataviz` palette, project-specific component tokens), those extra leaves
|
|
84
|
-
* won't appear on this export.
|
|
49
|
+
* won't appear on this export. The first-party dataviz extension ships its
|
|
50
|
+
* own mirror — `datavizVars` from `@ttoss/fsl-theme/dataviz`.
|
|
85
51
|
*
|
|
86
52
|
* ### Typed extension recipe
|
|
87
53
|
*
|
package/llms.txt
CHANGED
|
@@ -323,7 +323,7 @@ Never both. Never neither.
|
|
|
323
323
|
|
|
324
324
|
**§8 — Optional families have fallback rules:**
|
|
325
325
|
- `elevation.tonal` absent → fall back to `elevation.surface` alone.
|
|
326
|
-
- `dataviz` absent → the consumer's app does not opt in to dataviz; do not generate dataviz components.
|
|
326
|
+
- `dataviz` absent → the consumer's app does not opt in to dataviz; do not generate dataviz components. When present, reference its tokens via `datavizVars` from `@ttoss/fsl-theme/dataviz` (typed `var(--tt-dataviz-*)` mirror).
|
|
327
327
|
- Optional state (e.g. `hover`) absent on a leaf → fall back to `default`.
|
|
328
328
|
|
|
329
329
|
## Disambiguation — confusable picks
|