@astryxdesign/cli 0.7.0-canary.4ec1f4e → 0.7.0-canary.5777977

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 (64) hide show
  1. package/README.md +61 -61
  2. package/api/build/build.mjs +9 -0
  3. package/api/component/_adapter.d.mts +2 -0
  4. package/api/component/_adapter.mjs +3 -1
  5. package/api/component/component.doc.mjs +5 -1
  6. package/api/docs/compiled-topics.test.mjs +16 -0
  7. package/api/integration/pack-check.test.mjs +8 -0
  8. package/api/template/list/list.mjs +23 -2
  9. package/api/template/list/list.test.mjs +52 -0
  10. package/api/template/template.doc.mjs +5 -4
  11. package/api/template/template.type.mjs +1 -1
  12. package/api/theme/build/build.d.mts +0 -1
  13. package/api/theme/build/build.mjs +4 -29
  14. package/api/theme/build/family.mjs +1 -1
  15. package/assets/codemods/transforms/next/__tests__/validate-data-token-ownership.test.mjs +84 -0
  16. package/assets/codemods/transforms/next/index.mjs +8 -0
  17. package/assets/codemods/transforms/next/validate-data-token-ownership.mjs +102 -0
  18. package/assets/docs/author-a-theme.doc.mjs +4 -4
  19. package/assets/docs/tree/tokens-data.doc.mjs +2 -2
  20. package/assets/docs/tree/tokens-usage.doc.mjs +1 -1
  21. package/assets/templates/blocks/components/ComplexSelector/ComplexSelectorDeadlinePicker.tsx +1 -1
  22. package/assets/templates/blocks/components/ComplexSelector/ComplexSelectorShowcase.tsx +1 -1
  23. package/assets/templates/blocks/components/ComplexSelector/ComplexSelectorTreeSearch.tsx +1 -1
  24. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.tsx +1 -1
  25. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider02Overrides.tsx +1 -1
  26. package/assets/templates/blocks/components/Selector/SelectorClearable.tsx +1 -1
  27. package/assets/templates/blocks/components/Selector/SelectorOptionDescriptions.tsx +2 -2
  28. package/assets/templates/blocks/components/Selector/SelectorShowcase.tsx +1 -1
  29. package/assets/templates/blocks/components/Selector/SelectorWithSections.tsx +1 -1
  30. package/assets/templates/blocks/components/SelectorOption/SelectorOptionBasic.tsx +1 -1
  31. package/assets/templates/blocks/components/SelectorOption/SelectorOptionShowcase.tsx +1 -1
  32. package/assets/templates/blocks/components/Slider/SliderFormattedValue.tsx +1 -1
  33. package/assets/templates/blocks/components/Slider/SliderRangeSlider.tsx +1 -1
  34. package/assets/templates/blocks/components/Slider/SliderShowcase.tsx +1 -1
  35. package/assets/templates/blocks/components/Slider/SliderWithMarks.tsx +1 -1
  36. package/assets/templates/blocks/components/Tokenizer/TokenizerClear.tsx +1 -1
  37. package/assets/templates/blocks/components/Tokenizer/TokenizerCreatable.tsx +2 -2
  38. package/assets/templates/blocks/components/Tokenizer/TokenizerEndContent.tsx +1 -1
  39. package/assets/templates/blocks/components/Tokenizer/TokenizerIcon.tsx +1 -1
  40. package/assets/templates/blocks/components/Tokenizer/TokenizerMaxEntries.tsx +1 -1
  41. package/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.tsx +2 -2
  42. package/assets/templates/blocks/components/Tokenizer/TokenizerShowcase.tsx +1 -1
  43. package/assets/templates/blocks/components/Tokenizer/TokenizerStates.tsx +4 -4
  44. package/assets/templates/blocks/components/Toolbar/ToolbarTableFilter.tsx +1 -1
  45. package/assets/templates/pages/canvas-editor/page.tsx +2 -2
  46. package/assets/templates/pages/form-wizard-vertical/page.tsx +1 -1
  47. package/assets/templates/pages/payment-form/page.tsx +1 -1
  48. package/assets/templates/pages/table-filter/page.tsx +3 -3
  49. package/assets/templates/pages/theme-showcase/page.tsx +2 -2
  50. package/assets/templates/themes/neutral/neutralPaletteRefs.generated.ts +10 -9
  51. package/clients/cli/commands/build-theme.color-scheme.test.mjs +10 -6
  52. package/clients/cli/commands/build-theme.data-tokens.test.mjs +23 -75
  53. package/clients/cli/commands/build.doc.mjs +1 -1
  54. package/clients/cli/commands/build.mjs +1 -1
  55. package/clients/cli/commands/component-ownership.test.mjs +2 -2
  56. package/clients/cli/commands/integration.mjs +2 -1
  57. package/clients/cli/commands/silent-success-refusals.test.mjs +15 -0
  58. package/clients/cli/commands/template.doc.mjs +1 -1
  59. package/foundation/discovery/template-needs.mjs +93 -11
  60. package/foundation/discovery/template-needs.test.mjs +106 -3
  61. package/foundation/env/package-manager.d.mts +13 -0
  62. package/foundation/env/package-manager.mjs +106 -63
  63. package/foundation/response/response-types.doc.mjs +1 -2
  64. package/package.json +9 -9
@@ -99,14 +99,12 @@ import {resolveIconImports} from './icon-imports.mjs';
99
99
  // capability instead, required only by a theme that actually uses it:
100
100
  // requiring it unconditionally made every theme build — adaptations or not —
101
101
  // fail against an older published core. This is a targeted allowance for that
102
- // one capability, not a general scheme; the other two optional reads below
103
- // (`generateOnMediaCSS`, `dataTokenDefaults`) both exist in every core that
104
- // ships adaptations' predecessor surface.
102
+ // one capability, not a general scheme; `generateOnMediaCSS` exists in every
103
+ // core that ships adaptations' predecessor surface.
105
104
  /** @type {any} */ let _defineTheme = null;
106
105
  /** @type {any} */ let _generateThemeRulesSplit = null;
107
106
  /** @type {any} */ let _generateOnMediaCSS = null;
108
107
  /** @type {any} */ let _generateAdaptationCSS = null;
109
- /** @type {any} */ let _dataTokenDefaults = null;
110
108
  /**
111
109
  * The whole `@astryxdesign/core/theme` namespace. A theme file handed a
112
110
  * wrapped core must still get every export the installed one has, including
@@ -129,7 +127,6 @@ try {
129
127
  _generateThemeRulesSplit = coreTheme.generateThemeRulesSplit;
130
128
  _generateOnMediaCSS = coreTheme.generateOnMediaCSS;
131
129
  _generateAdaptationCSS = coreTheme.generateAdaptationCSS;
132
- _dataTokenDefaults = coreTheme.dataTokenDefaults;
133
130
  try {
134
131
  _coreRootModule = await import('@astryxdesign/core');
135
132
  } catch {
@@ -156,7 +153,6 @@ try {
156
153
  * generateThemeRulesSplit: any,
157
154
  * generateOnMediaCSS: any,
158
155
  * generateAdaptationCSS: any,
159
- * dataTokenDefaults: any,
160
156
  * }} CoreBindings
161
157
  */
162
158
 
@@ -173,7 +169,6 @@ const _cliCore = {
173
169
  generateThemeRulesSplit: _generateThemeRulesSplit,
174
170
  generateOnMediaCSS: _generateOnMediaCSS,
175
171
  generateAdaptationCSS: _generateAdaptationCSS,
176
- dataTokenDefaults: _dataTokenDefaults,
177
172
  };
178
173
 
179
174
  /**
@@ -188,7 +183,6 @@ function setCore(core) {
188
183
  _generateThemeRulesSplit = core.generateThemeRulesSplit;
189
184
  _generateOnMediaCSS = core.generateOnMediaCSS;
190
185
  _generateAdaptationCSS = core.generateAdaptationCSS;
191
- _dataTokenDefaults = core.dataTokenDefaults;
192
186
  }
193
187
 
194
188
  /**
@@ -295,7 +289,6 @@ async function loadProjectCore(cwd) {
295
289
  generateThemeRulesSplit: themeModule.generateThemeRulesSplit,
296
290
  generateOnMediaCSS: themeModule.generateOnMediaCSS,
297
291
  generateAdaptationCSS: themeModule.generateAdaptationCSS,
298
- dataTokenDefaults: themeModule.dataTokenDefaults,
299
292
  };
300
293
  }
301
294
 
@@ -2739,26 +2732,8 @@ async function themeBuildInternal(
2739
2732
  logger.log(`${source}No overrides found; nothing to build.`);
2740
2733
  return null;
2741
2734
  }
2742
- // The data-token defaults are theme-independent and go in @layer
2743
- // astryx-base, below the theme's own overrides. Formatted here from the
2744
- // public `dataTokenDefaults` export, byte for byte as the `<Theme>`
2745
- // runtime emits it — build-theme.data-tokens.test.mjs is the drift guard.
2746
- // Placed after the reset block and before the theme block: a layer's order
2747
- // is fixed by where it is first declared, so emitting it anywhere else in
2748
- // the file would invert reset < astryx-base < astryx-theme for a consumer
2749
- // who imports this stylesheet on its own.
2750
- const baseCss = _dataTokenDefaults
2751
- ? `:root {\n${Object.entries(_dataTokenDefaults)
2752
- .map(([name, value]) => ` ${name}: ${value};`)
2753
- .join('\n')}\n}`
2754
- : '';
2755
- if (baseCss) {
2756
- cssParts.splice(
2757
- prose.length > 0 ? 1 : 0,
2758
- 0,
2759
- `@layer astryx-base {\n${baseCss}\n}`,
2760
- );
2761
- }
2735
+ cssParts.unshift('@layer reset, astryx-base, astryx-theme;');
2736
+ const baseCss = '';
2762
2737
  cssPlan = {
2763
2738
  base: baseCss,
2764
2739
  prose,
@@ -438,5 +438,5 @@ export function generateFamilyCSS(members) {
438
438
  parts.push(`@layer astryx-base {\n${base.join('\n\n')}\n}`);
439
439
  if (themed.length > 0)
440
440
  parts.push(`@layer astryx-theme {\n${themed.join('\n\n')}\n}`);
441
- return `${parts.join('\n\n')}\n`;
441
+ return `@layer reset, astryx-base, astryx-theme;\n\n${parts.join('\n\n')}\n`;
442
442
  }
@@ -0,0 +1,84 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ import {describe, expect, it} from 'vitest';
4
+ import transform from '../validate-data-token-ownership.mjs';
5
+
6
+ async function run(source, file = 'test.tsx') {
7
+ const jscodeshift = (await import('jscodeshift')).default;
8
+ const parser =
9
+ file.endsWith('.ts') || file.endsWith('.tsx') ? 'tsx' : 'babel';
10
+ const api = {
11
+ jscodeshift: jscodeshift.withParser(parser),
12
+ stats: () => {},
13
+ report: () => {},
14
+ };
15
+ return transform({source, path: file}, api);
16
+ }
17
+
18
+ describe('validate-data-token-ownership', () => {
19
+ it('reports direct string and static-template consumers with both migration paths', async () => {
20
+ for (const source of [
21
+ `const fill = 'var(--color-data-categorical-green)';`,
22
+ 'const fill = `var(--color-data-categorical-green)`;',
23
+ `const border = '1px solid var(--color-data-categorical-green)';`,
24
+ 'const border = `${width}px solid var(--color-data-categorical-green)`;',
25
+ ]) {
26
+ await expect(run(source)).rejects.toThrow(
27
+ /CSS-capable code imports dataVars.*Canvas.*resolveThemeToken/s,
28
+ );
29
+ }
30
+ });
31
+
32
+ it('leaves fallbacks, dataVars access, and comments unchanged', async () => {
33
+ const source = `
34
+ // var(--color-data-categorical-green)
35
+ const fallback = 'var(--color-data-categorical-green, #008000)';
36
+ const fill = dataVars['--color-data-categorical-green'];
37
+ `;
38
+ expect(await run(source)).toBeUndefined();
39
+ });
40
+
41
+ it('reports stale generated theme CSS with root data defaults', async () => {
42
+ const source = `/* @generated by \`astryx theme build\` */
43
+ @layer astryx-base {
44
+ :root { --color-data-categorical-green: #008000; }
45
+ }`;
46
+ await expect(run(source, 'theme.css')).rejects.toThrow(
47
+ /Rebuild it with `astryx theme build`/,
48
+ );
49
+ });
50
+
51
+ it('reports raw stylesheet uses without a fallback', async () => {
52
+ await expect(
53
+ run('.bar { fill: var(--color-data-categorical-green); }', 'chart.css'),
54
+ ).rejects.toThrow(/Raw var\(--color-data-categorical-green\).*line 1/s);
55
+ });
56
+
57
+ it('leaves stylesheet uses with a fallback, and comments, unchanged', async () => {
58
+ expect(
59
+ await run(
60
+ `/* var(--color-data-categorical-green) */
61
+ .bar { fill: var(--color-data-categorical-green, #008000); }`,
62
+ 'chart.css',
63
+ ),
64
+ ).toBeUndefined();
65
+ });
66
+
67
+ it('does not claim ownership of hand-authored CSS or sparse theme overrides', async () => {
68
+ expect(
69
+ await run(
70
+ ':root { --color-data-categorical-green: #008000; }',
71
+ 'app.css',
72
+ ),
73
+ ).toBeUndefined();
74
+ expect(
75
+ await run(
76
+ `/* @generated by \`astryx theme build\` */
77
+ @scope ([data-astryx-theme="ocean"]) {
78
+ :scope { --color-data-categorical-green: #008000; }
79
+ }`,
80
+ 'theme.css',
81
+ ),
82
+ ).toBeUndefined();
83
+ });
84
+ });
@@ -10,6 +10,9 @@
10
10
  import migrateDeprecatedThemeSurface, {
11
11
  meta as migrateDeprecatedThemeSurfaceMeta,
12
12
  } from './migrate-deprecated-theme-surface.mjs';
13
+ import validateDataTokenOwnership, {
14
+ meta as validateDataTokenOwnershipMeta,
15
+ } from './validate-data-token-ownership.mjs';
13
16
 
14
17
  export default [
15
18
  {
@@ -17,4 +20,9 @@ export default [
17
20
  transform: migrateDeprecatedThemeSurface,
18
21
  meta: migrateDeprecatedThemeSurfaceMeta,
19
22
  },
23
+ {
24
+ name: 'validate-data-token-ownership',
25
+ transform: validateDataTokenOwnership,
26
+ meta: validateDataTokenOwnershipMeta,
27
+ },
20
28
  ];
@@ -0,0 +1,102 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Report data-token consumers that need an ownership migration.
5
+ *
6
+ * @input Consumer JavaScript/TypeScript source and generated theme CSS
7
+ * @output No rewritten source; actionable upgrade errors for fallback-less
8
+ * `var(--color-data-*)` uses (in JS strings, embedded or whole, and in CSS)
9
+ * and stale generated root-default artifacts
10
+ * @position Next-release upgrade validation for spec:AST-066
11
+ */
12
+
13
+ import * as path from 'node:path';
14
+
15
+ export const meta = {
16
+ title: 'Validate data-token ownership',
17
+ description:
18
+ 'Reports fallback-less data-token var() uses in source strings and stylesheets for manual CSS/non-CSS migration, and stale generated theme CSS that still owns root defaults.',
19
+ fileExtensions: ['.tsx', '.ts', '.jsx', '.js', '.mjs', '.cjs', '.css'],
20
+ };
21
+
22
+ // A use without a fallback; `var(--color-data-x, <fallback>)` stays valid.
23
+ const DIRECT_DATA_VAR = /var\(\s*(--color-data-[a-z0-9-]+)\s*\)/u;
24
+ const CSS_COMMENT = /\/\*[\s\S]*?\*\//gu;
25
+ const GENERATED_THEME_HEADER = '@generated by `astryx theme build`';
26
+ const ROOT_DATA_DECLARATION = /:root\s*\{[^}]*--color-data-/su;
27
+
28
+ /** @param {any} node */
29
+ function staticString(node) {
30
+ if (
31
+ (node?.type === 'StringLiteral' || node?.type === 'Literal') &&
32
+ typeof node.value === 'string'
33
+ ) {
34
+ return node.value;
35
+ }
36
+ if (node?.type === 'TemplateLiteral') {
37
+ // Each static chunk of the template; a use can sit between expressions.
38
+ return (node.quasis ?? [])
39
+ .map((/** @type {any} */ q) => q?.value?.cooked ?? q?.value?.raw ?? '')
40
+ .join('\u0000');
41
+ }
42
+ return undefined;
43
+ }
44
+
45
+ /**
46
+ * @param {import('../../../../authoring/codemod/type').AstryxCodemodFile} file
47
+ * @param {import('../../../../authoring/codemod/type').CodemodTransformApi} api
48
+ * @returns {undefined}
49
+ */
50
+ export default function validateDataTokenOwnership(file, api) {
51
+ if (!file.source.includes('--color-data-')) return undefined;
52
+
53
+ if (path.extname(file.path) === '.css') {
54
+ if (
55
+ file.source.includes(GENERATED_THEME_HEADER) &&
56
+ ROOT_DATA_DECLARATION.test(file.source)
57
+ ) {
58
+ throw new Error(
59
+ 'This generated theme CSS still emits canonical data defaults at :root. Rebuild it with `astryx theme build`; defaults now come from compiled dataVars consumers.',
60
+ );
61
+ }
62
+ const uncommented = file.source.replace(CSS_COMMENT, comment =>
63
+ comment.replace(/[^\n]/gu, ' '),
64
+ );
65
+ const cssMatch = DIRECT_DATA_VAR.exec(uncommented);
66
+ if (cssMatch) {
67
+ const line = uncommented.slice(0, cssMatch.index).split('\n').length;
68
+ throw new Error(
69
+ `Raw var(${cssMatch[1]}) without a fallback at line ${line} needs manual migration: compiled dataVars output is not guaranteed in this stylesheet, so add an explicit fallback or style the element from code that imports dataVars from @astryxdesign/core/theme/dataTokens.stylex.`,
70
+ );
71
+ }
72
+ return undefined;
73
+ }
74
+
75
+ const j = api.jscodeshift;
76
+ const root = j(file.source);
77
+ /** @type {{token: string, line: number|null}|null} */
78
+ let found = null;
79
+ const inspect = (/** @type {any} */ node) => {
80
+ if (found) return;
81
+ const value = staticString(node);
82
+ const match =
83
+ typeof value === 'string' ? value.match(DIRECT_DATA_VAR) : null;
84
+ if (match) {
85
+ found = {token: match[1], line: node.loc?.start?.line ?? null};
86
+ }
87
+ };
88
+
89
+ /** @param {any} nodePath */
90
+ const inspectPath = nodePath => inspect(nodePath.node);
91
+ root.find(j.StringLiteral).forEach(inspectPath);
92
+ root.find(j.Literal).forEach(inspectPath);
93
+ root.find(j.TemplateLiteral).forEach(inspectPath);
94
+
95
+ if (found) {
96
+ const {token, line} = found;
97
+ throw new Error(
98
+ `Direct var(${token})${line == null ? '' : ` at line ${line}`} needs manual migration: CSS-capable code imports dataVars from @astryxdesign/core/theme/dataTokens.stylex; Canvas and other non-CSS APIs use resolveThemeToken() or useTheme().token().`,
99
+ );
100
+ }
101
+ return undefined;
102
+ }
@@ -34,10 +34,10 @@ export const docs = {
34
34
  {
35
35
  title: 'defineTheme',
36
36
  content: [
37
- {type: 'prose', text: "defineTheme creates a theme from token overrides and optional scale configs. Only override tokens that differ from defaults; omitted tokens use the design system defaults. Scale configs generate tokens from parameters. Explicit token overrides always take precedence over scale-generated values, token by token. localTokens accepts any valid CSS custom-property name; prefixes do not establish ownership. One caveat for the accent: overriding --color-accent in tokens re-points the reference tokens (--color-accent-muted, --color-text-accent, --color-icon-accent) but NOT --color-on-accent, which stays baked from the color.accent seed. To give each scheme its own accent with a consistent derived palette, pass a [light, dark] tuple to color.accent instead of overriding the token."},
38
- {type: 'code', lang: 'tsx', label: 'defineTheme with scale configs', code: "import {defineTheme} from '@astryxdesign/core/theme';\n\nconst myTheme = defineTheme({\n name: 'my-theme',\n // accent: single hex, or [light, dark] tuple to seed each scheme separately\n color: { accent: ['#7B61FF', '#9B85FF'], neutralStyle: 'cool' },\n typography: {\n scale: { base: 14, ratio: 1.2 },\n body: { family: 'Inter', fallbacks: '-apple-system, sans-serif' },\n },\n radius: { base: 4, multiplier: 1 },\n motion: { fast: 175, medium: 410, ratio: 0.75 },\n tokens: {\n // Explicit overrides take precedence over scale-generated values\n '--color-background-body': ['#FFFFFF', '#0A0A0A'],\n },\n});"},
37
+ {type: 'prose', text: 'defineTheme creates a theme from explicit token overrides and optional scale configs. Existing themes may use `color` to expand an accent seed into neutral, surface, text, border, and related values; it is not an accent-only edit. Keep that configuration when preserving existing output. For new complete palettes, generate and review a committed palette module, then import its `palette` export and reference stable stops from semantic tokens. This keeps mapped roles coherent when the accepted palette is regenerated; generation itself does not rewrite the theme. Other scale configs generate typography, radius, and motion values from parameters. Explicit token overrides always take precedence over scale-generated values, token by token. When an existing `color` config is in use, overriding `--color-accent` in `tokens` re-points `--color-accent-muted`, `--color-text-accent`, and `--color-icon-accent`, but `--color-on-accent` stays baked from the `color.accent` seed. Prefer a `[light, dark]` tuple for `color.accent` over overriding `--color-accent` alone. localTokens accepts any valid CSS custom-property name; prefixes do not establish ownership.'},
38
+ {type: 'code', lang: 'tsx', label: 'defineTheme with generated palette references and non-color scale configs', code: "import {defineTheme} from '@astryxdesign/core/theme';\nimport {palette} from './palette.generated';\n\nconst myTheme = defineTheme({\n name: 'my-theme',\n typography: {\n scale: { base: 14, ratio: 1.2 },\n body: { family: 'Inter', fallbacks: '-apple-system, sans-serif' },\n },\n radius: { base: 4, multiplier: 1 },\n motion: { fast: 175, medium: 410, ratio: 0.75 },\n tokens: {\n '--color-background-surface': [\n palette.neutral.light[100],\n palette.neutral.dark[15],\n ],\n },\n});"},
39
39
  {type: 'table', headers: ['Config', 'Generates', 'Parameters'], rows: [
40
- ['color', '--color-accent, --color-background-*, --color-text-*, --color-border, etc.', 'accent? (hex or [light, dark] tuple; omit for neutral-only), neutralStyle? (warm|cool|neutral), contrast? (standard|high)'],
40
+ ['color (existing themes)', '--color-accent, --color-background-*, --color-text-*, --color-border, etc.', 'Supported broad scale: accent? (hex or [light, dark] tuple), neutralStyle? (warm|cool|neutral), contrast? (standard|high). Use theme palette generate for new complete palettes.'],
41
41
  ['typography.scale', '--text-heading-*-size/weight/leading, --text-body-size/weight/leading', 'base (px), ratio'],
42
42
  ['typography.body/heading/code', '--font-family-body, --font-family-heading, --font-family-code', 'family, fallbacks?, url?, weight?'],
43
43
  ['radius', '--radius-inner, --radius-element, --radius-container, --radius-page, --radius-chat', 'base (px), multiplier (0–2)'],
@@ -157,7 +157,7 @@ export const docs = {
157
157
  {
158
158
  title: 'useTheme Hook',
159
159
  content: [
160
- {type: 'prose', text: '`useTheme()` reads the nearest Theme and effective color mode from React context. Use it inside client components for SVG, canvas, charts, maps, and third-party configuration objects that need token values in JavaScript.'},
160
+ {type: 'prose', text: '`useTheme()` reads the nearest Theme and effective color mode from React context. Prefer `dataVars` for CSS-capable SVG and DOM values. Use this hook for canvas, charts, maps, third-party configuration objects, or an SVG API that requires a concrete JavaScript color instead of a `var(...)` reference.'},
161
161
  {type: 'code', lang: 'tsx', label: 'Access resolved token values in React', code: "import {useMemo} from 'react';\nimport {useTheme} from '@astryxdesign/core/theme';\n\nfunction ChartConfig() {\n const {mode, tokens} = useTheme();\n const options = useMemo(() => ({\n mode,\n textColor: tokens['--color-text-primary'],\n gridColor: tokens['--color-border'],\n seriesColor: tokens['--color-data-categorical-blue'],\n }), [mode, tokens]);\n return <Chart options={options} />;\n}"},
162
162
  {type: 'prose', text: 'Prefer CSS variables for ordinary styling. See {@link generic:use-a-theme} for the provider setup, and {@link namespace:tokens} for the full token reference.'},
163
163
  ],
@@ -17,14 +17,14 @@ export const docs = {
17
17
  "order": 20
18
18
  },
19
19
  "category": "foundations",
20
- "description": "Colors for charts and graphs: one categorical accent per series, a neutral for labels and reference lines, and sequential ramps from 5 (darkest) to 1 (lightest) for ordered scales and heatmaps. Import their public StyleX variables from @astryxdesign/core/theme/dataTokens.stylex.",
20
+ "description": "Colors for charts and graphs: one categorical accent per series, a neutral for labels and reference lines, and sequential ramps from 5 (darkest) to 1 (lightest) for ordered scales and heatmaps. Import dataVars from @astryxdesign/core/theme/dataTokens.stylex for CSS-capable code. Retaining any member emits the complete 56-variable group; an unused graph emits none.",
21
21
  "sections": [
22
22
  {
23
23
  "title": "Data Visualization Tokens",
24
24
  "content": [
25
25
  {
26
26
  "type": "prose",
27
- "text": "Colors for charts and graphs: one categorical accent per series, a neutral for labels and reference lines, and sequential ramps from 5 (darkest) to 1 (lightest) for ordered scales and heatmaps. Import their public StyleX variables from @astryxdesign/core/theme/dataTokens.stylex."
27
+ "text": "Colors for charts and graphs: one categorical accent per series, a neutral for labels and reference lines, and sequential ramps from 5 (darkest) to 1 (lightest) for ordered scales and heatmaps. Import dataVars from @astryxdesign/core/theme/dataTokens.stylex for CSS-capable code. Retaining any member emits the complete 56-variable group; an unused graph emits none."
28
28
  },
29
29
  {
30
30
  "type": "table",
@@ -28,7 +28,7 @@ export const docs = {
28
28
  },
29
29
  {
30
30
  "type": "prose",
31
- "text": "See {@link namespace:styling} for how to apply tokens via xstyle, className, and compound component patterns. See {@link generic:author-a-theme} for overriding tokens with defineTheme."
31
+ "text": "Use `dataVars` for StyleX, DOM styles, and SVG presentation attributes. Canvas and other APIs that require concrete mode-resolved values use `resolveThemeToken()` or `useTheme().token()` instead. Raw CSS may use the stable custom-property names only when compiled dataVars output is guaranteed or the declaration carries an explicit fallback. See {@link namespace:styling} for xstyle, className, and compound component patterns, and {@link generic:author-a-theme} for overriding tokens with defineTheme."
32
32
  }
33
33
  ]
34
34
  }
@@ -47,7 +47,7 @@ export default function ComplexSelectorDeadlinePicker() {
47
47
  value={value}
48
48
  onChange={setValue}
49
49
  triggerLabel={formatDeadline(value)}
50
- style={{width: 320}}>
50
+ controlStyle={{width: 320}}>
51
51
  {(selectedValue, onChange, close) => {
52
52
  const set = (patch: Partial<Deadline>) =>
53
53
  onChange({...selectedValue, ...patch});
@@ -184,7 +184,7 @@ export default function ComplexSelectorShowcase() {
184
184
  value={value}
185
185
  onChange={setValue}
186
186
  triggerLabel={`${value.fruit} · ${value.ripeness}`}
187
- style={{width: 280}}>
187
+ controlStyle={{width: 280}}>
188
188
  {(selectedValue, onChange, close) => (
189
189
  <FruitRipenessGrid
190
190
  value={selectedValue}
@@ -175,7 +175,7 @@ export default function ComplexSelectorTreeSearch() {
175
175
  value={value}
176
176
  onChange={setValue}
177
177
  triggerLabel={value.path}
178
- style={{width: 360}}>
178
+ controlStyle={{width: 360}}>
179
179
  {(selectedValue, onChange, close) => (
180
180
  <DestinationSearch
181
181
  value={selectedValue}
@@ -29,7 +29,7 @@ export default function InternationalizationProviderShippedLocale() {
29
29
  <SegmentedControlItem value="fr-FR" label="FR" />
30
30
  </SegmentedControl>
31
31
  <Selector
32
- style={{width: 300}}
32
+ controlStyle={{width: 300}}
33
33
  label="Billing region"
34
34
  options={[
35
35
  {value: 'americas', label: 'Americas'},
@@ -17,7 +17,7 @@ export default function InternationalizationProviderOverrides() {
17
17
  },
18
18
  }}>
19
19
  <Selector
20
- style={{width: 300}}
20
+ controlStyle={{width: 300}}
21
21
  label="Billing region"
22
22
  options={[
23
23
  {value: 'americas', label: 'Americas'},
@@ -9,7 +9,7 @@ export default function SelectorClearable() {
9
9
  const [value, setValue] = useState<string | null>('engineering');
10
10
  return (
11
11
  <Selector
12
- style={{width: 300}}
12
+ controlStyle={{width: 300}}
13
13
  label="Department"
14
14
  options={[
15
15
  {value: 'engineering', label: 'Engineering'},
@@ -32,7 +32,7 @@ export default function SelectorOptionDescriptions() {
32
32
  return (
33
33
  <Stack direction="vertical" gap={6}>
34
34
  <Selector
35
- style={{width: 320}}
35
+ controlStyle={{width: 320}}
36
36
  label="Visibility"
37
37
  description="Default trigger: one line at the size token."
38
38
  options={VISIBILITY}
@@ -40,7 +40,7 @@ export default function SelectorOptionDescriptions() {
40
40
  onChange={setCondensed}
41
41
  />
42
42
  <Selector
43
- style={{width: 320}}
43
+ controlStyle={{width: 320}}
44
44
  label="Visibility"
45
45
  description="A stacked SelectorOption: the description gets its own line, and the trigger grows by exactly one line."
46
46
  options={VISIBILITY}
@@ -9,7 +9,7 @@ export default function SelectorShowcase() {
9
9
  const [value, setValue] = useState<string | undefined>();
10
10
  return (
11
11
  <Selector
12
- style={{width: 300}}
12
+ controlStyle={{width: 300}}
13
13
  label="Fruit"
14
14
  options={['Apple', 'Banana', 'Orange', 'Mango', 'Pineapple']}
15
15
  placeholder="Select a fruit..."
@@ -9,7 +9,7 @@ export default function SelectorWithSections() {
9
9
  const [value, setValue] = useState<string | undefined>();
10
10
  return (
11
11
  <Selector
12
- style={{width: 300}}
12
+ controlStyle={{width: 300}}
13
13
  label="Office"
14
14
  options={[
15
15
  {
@@ -22,7 +22,7 @@ export default function SelectorOptionBasic() {
22
22
 
23
23
  return (
24
24
  <Selector
25
- style={{width: 300}}
25
+ controlStyle={{width: 300}}
26
26
  label="Role"
27
27
  options={roles}
28
28
  value={value}
@@ -25,7 +25,7 @@ export default function SelectorOptionShowcase() {
25
25
 
26
26
  return (
27
27
  <Selector
28
- style={{width: 300}}
28
+ controlStyle={{width: 300}}
29
29
  label="Role"
30
30
  options={roles}
31
31
  value={value}
@@ -9,7 +9,7 @@ export default function SliderFormattedValue() {
9
9
  const [value, setValue] = useState(72);
10
10
  return (
11
11
  <Slider
12
- style={{width: 300}}
12
+ containerStyle={{width: 300}}
13
13
  label="Temperature"
14
14
  value={value}
15
15
  onChange={setValue}
@@ -12,7 +12,7 @@ export default function SliderRangeSlider() {
12
12
  label="Price range"
13
13
  value={value}
14
14
  onChange={setValue}
15
- style={{width: 300}}
15
+ containerStyle={{width: 300}}
16
16
  />
17
17
  );
18
18
  }
@@ -12,7 +12,7 @@ export default function SliderShowcase() {
12
12
  label="Volume"
13
13
  value={value}
14
14
  onChange={setValue}
15
- style={{width: 300}}
15
+ containerStyle={{width: 300}}
16
16
  />
17
17
  );
18
18
  }
@@ -9,7 +9,7 @@ export default function SliderWithMarks() {
9
9
  const [value, setValue] = useState(50);
10
10
  return (
11
11
  <Slider
12
- style={{width: 300}}
12
+ containerStyle={{width: 300}}
13
13
  label="Volume"
14
14
  value={value}
15
15
  onChange={setValue}
@@ -37,7 +37,7 @@ export default function TokenizerClear() {
37
37
  value={value}
38
38
  onChange={items => setValue(items)}
39
39
  hasClear
40
- style={{width: 400}}
40
+ containerStyle={{width: 400}}
41
41
  />
42
42
  </Stack>
43
43
  );
@@ -44,7 +44,7 @@ export default function TokenizerCreatable() {
44
44
  onChange={items => setTags(items)}
45
45
  hasCreate
46
46
  placeholder="Type a tag and press Enter..."
47
- style={{width: 400}}
47
+ containerStyle={{width: 400}}
48
48
  />
49
49
  </Stack>
50
50
  <Stack direction="vertical" gap={1}>
@@ -59,7 +59,7 @@ export default function TokenizerCreatable() {
59
59
  hasCreate
60
60
  hasEntriesOnFocus
61
61
  placeholder="Search or type a new name..."
62
- style={{width: 400}}
62
+ containerStyle={{width: 400}}
63
63
  />
64
64
  </Stack>
65
65
  </Stack>
@@ -39,7 +39,7 @@ export default function TokenizerEndContent() {
39
39
  value={value}
40
40
  onChange={items => setValue(items)}
41
41
  endContent={<Button label="Apply" variant="primary" size="sm" />}
42
- style={{width: 400}}
42
+ containerStyle={{width: 400}}
43
43
  />
44
44
  </Stack>
45
45
  );
@@ -38,7 +38,7 @@ export default function TokenizerIcon() {
38
38
  value={value}
39
39
  onChange={items => setValue(items)}
40
40
  startIcon={MagnifyingGlassIcon}
41
- style={{width: 400}}
41
+ containerStyle={{width: 400}}
42
42
  />
43
43
  </Stack>
44
44
  );
@@ -44,7 +44,7 @@ export default function TokenizerMaxEntries() {
44
44
  value={value}
45
45
  onChange={items => setValue(items)}
46
46
  maxEntries={MAX_SKILLS}
47
- style={{width: 400}}
47
+ containerStyle={{width: 400}}
48
48
  />
49
49
  </Stack>
50
50
  );
@@ -40,7 +40,7 @@ export default function TokenizerOverflow() {
40
40
  value={inlineValue}
41
41
  onChange={items => setInlineValue(items)}
42
42
  tokenOverflowBehavior="unfocusedInline"
43
- style={{width: 400, maxWidth: 400}}
43
+ containerStyle={{width: 400, maxWidth: 400}}
44
44
  />
45
45
  </Stack>
46
46
  <Stack direction="vertical" gap={1}>
@@ -54,7 +54,7 @@ export default function TokenizerOverflow() {
54
54
  value={layerValue}
55
55
  onChange={items => setLayerValue(items)}
56
56
  tokenOverflowBehavior="unfocusedLayer"
57
- style={{width: 400, maxWidth: 400}}
57
+ containerStyle={{width: 400, maxWidth: 400}}
58
58
  />
59
59
  </Stack>
60
60
  </Stack>
@@ -23,7 +23,7 @@ export default function TokenizerShowcase() {
23
23
  searchSource={source}
24
24
  value={value}
25
25
  onChange={setValue}
26
- style={{width: 400}}
26
+ containerStyle={{width: 400}}
27
27
  />
28
28
  );
29
29
  }
@@ -39,7 +39,7 @@ export default function TokenizerStates() {
39
39
  value={[users[0], users[2]]}
40
40
  onChange={() => {}}
41
41
  isDisabled
42
- style={{width: 400}}
42
+ containerStyle={{width: 400}}
43
43
  />
44
44
  <Tokenizer
45
45
  label="Error message"
@@ -49,7 +49,7 @@ export default function TokenizerStates() {
49
49
  onChange={items => setErrorValue(items)}
50
50
  isRequired
51
51
  status={{type: 'error', message: 'At least one reviewer is required'}}
52
- style={{width: 400}}
52
+ containerStyle={{width: 400}}
53
53
  />
54
54
  <Tokenizer
55
55
  label="Warning message"
@@ -61,7 +61,7 @@ export default function TokenizerStates() {
61
61
  type: 'warning',
62
62
  message: 'Consider adding at least 2 approvers',
63
63
  }}
64
- style={{width: 400}}
64
+ containerStyle={{width: 400}}
65
65
  />
66
66
  <Tokenizer
67
67
  label="Success message"
@@ -70,7 +70,7 @@ export default function TokenizerStates() {
70
70
  value={successValue}
71
71
  onChange={items => setSuccessValue(items)}
72
72
  status={{type: 'success', message: 'All required reviewers added'}}
73
- style={{width: 400}}
73
+ containerStyle={{width: 400}}
74
74
  />
75
75
  </Stack>
76
76
  );