@astryxdesign/cli 0.1.3 → 0.1.4-canary.02643db

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 (30) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/docs/browser-support.doc.mjs +200 -0
  3. package/docs/layout.doc.mjs +2 -2
  4. package/docs/theme.doc.mjs +2 -2
  5. package/package.json +7 -7
  6. package/src/api/component.mjs +2 -1
  7. package/src/api/template.mjs +14 -3
  8. package/src/codemods/transforms/v0.1.0/__tests__/drop-xds-prefix-imports.test.mjs +43 -0
  9. package/src/codemods/transforms/v0.1.0/__tests__/migrate-xds-css-surfaces.test.mjs +36 -0
  10. package/src/codemods/transforms/v0.1.0/__tests__/migrate-xds-module-specifiers.test.mjs +41 -0
  11. package/src/codemods/transforms/v0.1.0/drop-xds-prefix-imports.mjs +65 -13
  12. package/src/codemods/transforms/v0.1.0/migrate-xds-css-surfaces.mjs +43 -3
  13. package/src/codemods/transforms/v0.1.0/migrate-xds-module-specifiers.mjs +45 -0
  14. package/src/commands/agent-docs.mjs +2 -1
  15. package/src/commands/component-resolution.test.mjs +4 -4
  16. package/src/commands/doctor.test.mjs +4 -3
  17. package/src/lib/component-discovery.mjs +8 -4
  18. package/src/lib/component-format.mjs +13 -2
  19. package/src/lib/component-format.test.mjs +42 -0
  20. package/src/utils/paths.test.mjs +2 -2
  21. package/templates/blocks/components/BaseTypeahead/BaseTypeaheadCustomSearch.doc.mjs +14 -0
  22. package/templates/blocks/components/BaseTypeahead/BaseTypeaheadCustomSearch.tsx +58 -0
  23. package/templates/blocks/components/CodeBlock/CodeBlockTerminal.doc.mjs +14 -0
  24. package/templates/blocks/components/CodeBlock/CodeBlockTerminal.tsx +24 -0
  25. package/templates/blocks/components/MetadataListItem/MetadataListItemBasic.doc.mjs +1 -1
  26. package/templates/blocks/components/TabList/TabListTabsWithActions.doc.mjs +1 -1
  27. package/templates/blocks/components/Table/TableRowExpansionTable.doc.mjs +14 -0
  28. package/templates/blocks/components/Table/TableRowExpansionTable.tsx +99 -0
  29. package/templates/blocks/components/ToggleButtonGroup/ToggleButtonGroupVertical.doc.mjs +1 -1
  30. package/templates/themes/stone/stoneTheme.ts +6 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # @xds/cli
2
2
 
3
+ # 0.1.4
4
+
5
+ #### Fixes
6
+
7
+ - `astryx component <Name>` now prints the correct `defineTheme` component-override key. The theming example stripped a stale `xds-` prefix (left over from the astryx rename) instead of `astryx-`, so it advertised keys like `astryx-base-table` / `astryx-button`. Those double-prefix to `.astryx-astryx-*` selectors at runtime and silently match nothing. Keys are now the stable class name minus `astryx-` (e.g. `base-table`, `button`), which is what `generateThemeRules` expects (#3458).
8
+ - Harden the v0.1.0 upgrade codemods against three cases surfaced while migrating consumer apps:
9
+
10
+ #### Documentation
11
+
12
+ - Add a browser-support guide (`astryx docs browser-support`) documenting the support tiers, the modern platform features Astryx depends on (Popover API, CSS anchor positioning, `light-dark()`), which components are affected, and how consumers can support older browsers for their own audience.
13
+
14
+ #### Other Changes
15
+
16
+ - **drop-xds-prefix-imports**: when un-prefixing an `@xds/core` import (e.g. `XDSCodeBlock` → `CodeBlock`) would collide with a same-named local binding in the file (such as a local `export function CodeBlock` wrapper), alias the import to `Astryx<Name>` and rewrite its usages instead of producing a duplicate declaration that breaks the build.
17
+ - **migrate-xds-css-surfaces**: rewrite CSS `@import` of `@xds/*` package stylesheets (both `'…'`/`"…"` and `url(…)` forms), including the `@xds/core/xds.css` → `@astryxdesign/core/astryx.css` file rename and the `theme-default`/`theme-daily` → `theme-neutral` collapse.
18
+ - **migrate-xds-module-specifiers**: when collapsing `@xds/theme-default`/`@xds/theme-daily` to `@astryxdesign/theme-neutral`, remap the `defaultTheme` export to `neutralTheme`, aliasing back to the original local name (`neutralTheme as defaultTheme`) so downstream usages keep working.
19
+
20
+ #### Contributors
21
+
22
+ Thanks to everyone who contributed to this release:
23
+
24
+ - @cixzhang
25
+ - @ejhammond
26
+ - @ryanda9910
27
+
28
+ ---
29
+
3
30
  # 0.1.3
4
31
 
5
32
  #### New Features
@@ -0,0 +1,200 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @type {import('../../core/src/docs-types').ReferenceDoc} */
4
+
5
+ export const docs = {
6
+ name: 'browser-support',
7
+ title: 'Browser Support',
8
+ category: 'guide',
9
+ description:
10
+ 'What browsers Astryx targets, which modern platform features it depends on, and how to support older browsers for your own audience.',
11
+
12
+ sections: [
13
+ {
14
+ title: 'Overview',
15
+ content: [
16
+ {
17
+ type: 'prose',
18
+ text: 'Astryx is built on modern web platform features: the Popover API, CSS anchor positioning, and CSS `light-dark()`. These let components stay small, accessible, and dependency-free, but they also set a floor on which browsers render everything correctly.',
19
+ },
20
+ {
21
+ type: 'prose',
22
+ text: 'A design system does not own its traffic; the products built on it do. Their audiences range from evergreen-Chrome-only internal tools to public sites with meaningful older-Safari share. So Astryx does not declare a single hard browser floor the way an app would. Instead it defines tiers that describe what works at each level, and hands the final decision to you. Pick the tier that matches your audience.',
23
+ },
24
+ ],
25
+ },
26
+ {
27
+ title: 'Support Tiers',
28
+ content: [
29
+ {
30
+ type: 'prose',
31
+ text: 'Astryx officially supports Tier 1 and Tier 2. Tier 3 is best-effort: components will not crash, but positioning and theming may degrade.',
32
+ },
33
+ {
34
+ type: 'table',
35
+ headers: ['Tier', 'Baseline', 'Representative versions', 'What your users experience'],
36
+ rows: [
37
+ [
38
+ 'Tier 1: Full fidelity',
39
+ 'Current Baseline (2026)',
40
+ 'Chrome 125+, Edge 125+, Safari 26+, Firefox 147+',
41
+ 'Everything works, including CSS anchor positioning. This is the reference target.',
42
+ ],
43
+ [
44
+ 'Tier 2: Functional',
45
+ 'Baseline − 2 years (2024)',
46
+ 'Chrome 114+, Edge 114+, Safari 17+, Firefox 125+',
47
+ 'Components open, dismiss, and are fully usable. Only anchor positioning is missing, so layered surfaces (tooltips, menus, popovers) may not be positioned next to their trigger.',
48
+ ],
49
+ [
50
+ 'Tier 3: Below Tier 2',
51
+ 'Older than Baseline − 2',
52
+ 'Anything older',
53
+ 'Best-effort. The only guarantee is "does not crash." `light-dark()` is unavailable, so theme colors may fall back to defaults.',
54
+ ],
55
+ ],
56
+ },
57
+ ],
58
+ },
59
+ {
60
+ title: 'Which Features Set the Floor',
61
+ content: [
62
+ {
63
+ type: 'prose',
64
+ text: 'Only three modern features carry a browser requirement. Everything else Astryx uses (`:has()`, `color-mix()`, container queries, the `<dialog>` element) has been widely available since 2023 or earlier and needs no special handling.',
65
+ },
66
+ {
67
+ type: 'table',
68
+ headers: ['Feature', 'Role in Astryx', 'Widely available'],
69
+ rows: [
70
+ [
71
+ 'CSS Anchor Positioning',
72
+ 'Positions layered surfaces relative to their trigger (tooltips, menus, popovers, dropdowns).',
73
+ 'Baseline 2026: the tightest requirement.',
74
+ ],
75
+ [
76
+ 'Popover API',
77
+ 'Opens, stacks, and light-dismisses layered surfaces via the top layer.',
78
+ 'Baseline 2025.',
79
+ ],
80
+ [
81
+ 'CSS light-dark()',
82
+ 'Compiles every theme color tuple into a single value that responds to color scheme. Underpins the whole theming system.',
83
+ 'Widely available since mid-2024.',
84
+ ],
85
+ ],
86
+ },
87
+ {
88
+ type: 'prose',
89
+ text: 'The gap that matters is between Tier 1 and Tier 2: the Popover API and `light-dark()` reached wide availability well before anchor positioning. So in Tier 2 browsers, layered surfaces open and dismiss correctly; they just are not positioned. This is the one feature most consumers will need to reason about.',
90
+ },
91
+ ],
92
+ },
93
+ {
94
+ title: 'Which Components Are Affected',
95
+ content: [
96
+ {
97
+ type: 'prose',
98
+ text: 'The browser requirement is concentrated in the layered-surface components: anything that renders content in an overlay positioned against a trigger:',
99
+ },
100
+ {
101
+ type: 'list',
102
+ style: 'unordered',
103
+ items: [
104
+ 'Tooltip',
105
+ 'HoverCard',
106
+ 'Popover',
107
+ 'ContextMenu',
108
+ 'Selector and MultiSelector (dropdown surfaces)',
109
+ 'Tokenizer (suggestion menu)',
110
+ 'Carousel (anchored controls)',
111
+ ],
112
+ },
113
+ {
114
+ type: 'prose',
115
+ text: 'If your product does not use any of these, it has no anchor-positioning requirement at all; it needs only `light-dark()` (Tier 2 and up) for correct theme colors. Layout, typography, forms, buttons, cards, tables, and navigation all work down to Tier 2 with no special handling.',
116
+ },
117
+ ],
118
+ },
119
+ {
120
+ title: 'What Astryx Guarantees',
121
+ content: [
122
+ {
123
+ type: 'list',
124
+ style: 'do',
125
+ items: [
126
+ 'Components never throw on missing platform APIs. Where a browser lacks the Popover API, layers fall back to plain visibility instead of crashing.',
127
+ 'Tier 1 and Tier 2 are officially supported and tested.',
128
+ 'Non-layered components render correctly down to Tier 2.',
129
+ ],
130
+ },
131
+ {
132
+ type: 'list',
133
+ style: 'dont',
134
+ items: [
135
+ 'Astryx does not guarantee correct layer positioning below Tier 1 (anchor positioning). Closing that gap for a Tier 2 audience is a consumer choice; see below.',
136
+ 'Astryx does not ship a `light-dark()` fallback, so theme colors are not guaranteed below Tier 2.',
137
+ ],
138
+ },
139
+ ],
140
+ },
141
+ {
142
+ title: 'Supporting Older Browsers',
143
+ content: [
144
+ {
145
+ type: 'prose',
146
+ text: 'If your audience includes Tier 2 browsers and you need correct layer positioning, you have three options, cheapest first. All of them are decisions you make for your audience; Astryx does not impose one.',
147
+ },
148
+ {
149
+ type: 'list',
150
+ style: 'ordered',
151
+ items: [
152
+ 'Polyfill anchor positioning. Load a CSS anchor positioning polyfill conditionally behind an `@supports` check so it costs nothing on Tier 1. This is the lowest-effort way to get correct positioning; note that polyfills may not cover every position-fallback feature.',
153
+ 'Provide a JS positioning fallback. Detect missing support with `CSS.supports("anchor-name", "--x")` and position layers with a measurement-based library (e.g. a floating-element positioner) when it returns false. More code, full control.',
154
+ 'Accept degraded positioning. Document for your users that on Tier 2 browsers, layered surfaces open correctly but may not sit next to their trigger. Cheapest, and often fine for internal tools on evergreen browsers.',
155
+ ],
156
+ },
157
+ {
158
+ type: 'prose',
159
+ text: 'Feature-detect at runtime rather than sniffing user agents:',
160
+ },
161
+ {
162
+ type: 'code',
163
+ lang: 'js',
164
+ label: 'Feature detection',
165
+ code: `// Popover API (Tier 2 and up)
166
+ const hasPopover = typeof HTMLElement !== 'undefined'
167
+ && typeof HTMLElement.prototype.showPopover === 'function';
168
+
169
+ // CSS anchor positioning (Tier 1)
170
+ const hasAnchorPositioning = CSS.supports('anchor-name', '--x');
171
+
172
+ // CSS light-dark() (Tier 2 and up)
173
+ const hasLightDark = CSS.supports('color', 'light-dark(#000, #fff)');`,
174
+ },
175
+ ],
176
+ },
177
+ {
178
+ title: 'How These Tiers Move Over Time',
179
+ content: [
180
+ {
181
+ type: 'prose',
182
+ text: 'The tiers are rolling, not frozen to specific versions. They track the Web Baseline year:',
183
+ },
184
+ {
185
+ type: 'list',
186
+ style: 'unordered',
187
+ items: [
188
+ 'Tier 1 tracks the current Baseline year.',
189
+ 'Tier 2 tracks Baseline minus two years.',
190
+ 'Tier 3 is everything older, and remains best-effort.',
191
+ ],
192
+ },
193
+ {
194
+ type: 'prose',
195
+ text: 'This is not an arbitrary window: Baseline − 2 is close to where anchor positioning stops being available while the Popover API and `light-dark()` still are, so the tier boundary tracks a real capability edge, not a guessed date. The version floors above are reviewed and advanced roughly once a year as new Baseline years land. Always feature-detect rather than hardcoding version numbers, so your app adapts automatically as the platform moves.',
196
+ },
197
+ ],
198
+ },
199
+ ],
200
+ };
@@ -92,7 +92,7 @@ export const docs = {
92
92
  content: [
93
93
  {
94
94
  type: 'prose',
95
- text: 'Card is a widget container, not a list-item wrapper. The fastest way to make an app look like a generic AI prototype is to wrap every record in a Card with a Badge. Dense data anything the user scans, filters, or selects belongs in rows: Table for columnar data, List/Item for single-line records, edge-to-edge with dividers and 32–40px row height.',
95
+ text: 'Card is a widget container, not a list-item wrapper. The fastest way to make an app look like a generic AI prototype is to wrap every record in a Card with a Badge. Dense data (anything the user scans, filters, or selects) belongs in rows: Table for columnar data, List/Item for single-line records, edge-to-edge with dividers and 32–40px row height.',
96
96
  },
97
97
  {
98
98
  type: 'list',
@@ -111,7 +111,7 @@ export const docs = {
111
111
  'Wrapping each list item in a Card (card soup)',
112
112
  'Stacking full-width Cards as a substitute for page structure',
113
113
  'Nesting Cards inside Cards',
114
- 'Using Badge as decoration reserve it for counts and enumerated states; use StatusDot or Token for status and metadata',
114
+ 'Using Badge as decoration: reserve it for counts and enumerated states; use StatusDot or Token for status and metadata',
115
115
  ],
116
116
  },
117
117
  ],
@@ -124,14 +124,14 @@ function App() {
124
124
  type: 'table',
125
125
  headers: ['Prop', 'Type', 'Default', 'Description'],
126
126
  rows: [
127
- ['theme', 'DefinedTheme', '', 'Theme object (required)'],
127
+ ['theme', 'DefinedTheme', '-', 'Theme object (required)'],
128
128
  [
129
129
  'mode',
130
130
  "'system' | 'light' | 'dark'",
131
131
  "'system'",
132
132
  'Color mode. system follows OS preference.',
133
133
  ],
134
- ['children', 'ReactNode', '', 'App content'],
134
+ ['children', 'ReactNode', '-', 'App content'],
135
135
  ],
136
136
  },
137
137
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.4-canary.02643db",
4
4
  "displayName": "CLI",
5
5
  "description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
6
6
  "author": "Meta Open Source",
@@ -75,9 +75,9 @@
75
75
  "zod": "^4.4.3"
76
76
  },
77
77
  "peerDependencies": {
78
- "@astryxdesign/core": "*",
79
- "@astryxdesign/lab": "*",
80
- "@astryxdesign/theme-neutral": "*",
78
+ "@astryxdesign/core": "0.1.4-canary.02643db",
79
+ "@astryxdesign/lab": "0.1.4-canary.02643db",
80
+ "@astryxdesign/theme-neutral": "0.1.4-canary.02643db",
81
81
  "gpt-tokenizer": "^2.0.0"
82
82
  },
83
83
  "peerDependenciesMeta": {
@@ -92,9 +92,9 @@
92
92
  }
93
93
  },
94
94
  "devDependencies": {
95
- "@astryxdesign/core": "*",
96
- "@astryxdesign/lab": "*",
97
- "@astryxdesign/theme-neutral": "*",
95
+ "@astryxdesign/core": "0.1.4-canary.02643db",
96
+ "@astryxdesign/lab": "0.1.4-canary.02643db",
97
+ "@astryxdesign/theme-neutral": "0.1.4-canary.02643db",
98
98
  "gpt-tokenizer": "^2.0.0"
99
99
  },
100
100
  "scripts": {
@@ -8,6 +8,7 @@
8
8
  */
9
9
 
10
10
  import * as fs from 'node:fs';
11
+ import * as path from 'node:path';
11
12
  import {ERROR_CODES} from '../lib/error-codes.mjs';
12
13
  import {findCoreDir, discoverExternalPackages} from '../utils/paths.mjs';
13
14
  import {
@@ -560,7 +561,7 @@ export async function component(name, options = {}) {
560
561
 
561
562
  // Examples: blocks in the component's own directory, or
562
563
  // componentsUsed match for sub-components without a directory.
563
- const ownDir = allBlocks.filter(b => b.category.split('/').pop() === dirName);
564
+ const ownDir = allBlocks.filter(b => path.basename(b.category) === dirName);
564
565
  const examples = ownDir.length > 0
565
566
  ? ownDir
566
567
  : allBlocks.filter(b => b.componentsUsed?.some(c => c === dirName));
@@ -63,6 +63,17 @@ const DEMO_IMAGE_PATTERNS = [
63
63
  /https?:\/\/(?:[\w-]+\.)*lookaside\.facebook\.com\/[^\s'"`)]+/g,
64
64
  ];
65
65
 
66
+ /**
67
+ * Normalize path into Unix path (using forward slashes) for consistent comparison
68
+ * across Windows, macOS, and Linux.
69
+ *
70
+ * @param {string} p - The file path to normalize.
71
+ * @returns {string} The normalized Unix path.
72
+ */
73
+ function toPosixPath(p) {
74
+ return p.replace(/\\/g, '/');
75
+ }
76
+
66
77
  /**
67
78
  * Replace demo image references with a self-contained placeholder data URI so
68
79
  * scaffolded pages render with zero setup. Builders drop in their own images.
@@ -144,7 +155,7 @@ async function discoverBlocks() {
144
155
  const tsxPath = path.join(path.dirname(docPath), basename + '.tsx');
145
156
  if (!fs.existsSync(tsxPath)) continue;
146
157
  const doc = await loadDocModule(docPath);
147
- const relPath = path.relative(BLOCKS_DIR, path.dirname(docPath));
158
+ const relPath = toPosixPath(path.relative(BLOCKS_DIR, path.dirname(docPath)));
148
159
  blocks.push({
149
160
  type: 'block',
150
161
  dirName: basename,
@@ -180,7 +191,7 @@ async function discoverExternalBlocks(cwd = process.cwd()) {
180
191
  const tsxPath = path.join(path.dirname(docPath), basename + '.tsx');
181
192
  if (!fs.existsSync(tsxPath)) continue;
182
193
  const doc = await loadDocModule(docPath);
183
- const relPath = path.relative(ext.blocksDir, path.dirname(docPath));
194
+ const relPath = toPosixPath(path.relative(ext.blocksDir, path.dirname(docPath)));
184
195
  blocks.push({
185
196
  type: 'block',
186
197
  dirName: basename,
@@ -428,7 +439,7 @@ export async function findShowcase(componentName, cwd, options) {
428
439
 
429
440
  // Priority 1: own directory (components/Badge/ for "Badge")
430
441
  const dirMatch = showcases.find(b => {
431
- const catDir = b.category.split('/').pop()?.toLowerCase();
442
+ const catDir = path.basename(b.category).toLowerCase();
432
443
  return catDir === lc;
433
444
  });
434
445
  if (dirMatch) return toResult(dirMatch);
@@ -134,4 +134,47 @@ describe('drop-xds-prefix-imports', () => {
134
134
  expect(output).toContain(`import {useState} from 'react';`);
135
135
  expect(output).toContain('const x = 1;');
136
136
  });
137
+
138
+ it('aliases to Astryx<Name> when the bare name collides with a local export function', async () => {
139
+ const input = [
140
+ `import {XDSCodeBlock} from '@xds/core/CodeBlock';`,
141
+ `export function CodeBlock({code}: {code: string}) {`,
142
+ ` return <XDSCodeBlock code={code} />;`,
143
+ `}`,
144
+ ].join('\n');
145
+ const output = await applyTransform(input);
146
+ // Import aliased to AstryxCodeBlock; local declaration untouched.
147
+ expect(output).toContain('CodeBlock as AstryxCodeBlock');
148
+ expect(output).toContain('@xds/core/CodeBlock');
149
+ expect(output).toContain('export function CodeBlock({code}');
150
+ expect(output).toContain('<AstryxCodeBlock code={code} />');
151
+ // No duplicate CodeBlock binding (not imported bare).
152
+ expect(output).not.toMatch(/import \{CodeBlock\}/);
153
+ });
154
+
155
+ it('aliases on collision with a local const/class binding', async () => {
156
+ const input = [
157
+ `import {XDSCard} from '@xds/core';`,
158
+ `const Card = 42;`,
159
+ `export const value = <XDSCard />;`,
160
+ `export const other = Card;`,
161
+ ].join('\n');
162
+ const output = await applyTransform(input);
163
+ expect(output).toContain('import {Card as AstryxCard}');
164
+ expect(output).toContain('const Card = 42;');
165
+ expect(output).toContain('<AstryxCard />');
166
+ expect(output).toContain('export const other = Card;');
167
+ });
168
+
169
+ it('un-prefixes normally when there is NO local collision', async () => {
170
+ const input = [
171
+ `import {XDSCodeBlock} from '@xds/core/CodeBlock';`,
172
+ `export const App = () => <XDSCodeBlock code="x" />;`,
173
+ ].join('\n');
174
+ const output = await applyTransform(input);
175
+ expect(output).toContain('{CodeBlock}');
176
+ expect(output).toContain('@xds/core/CodeBlock');
177
+ expect(output).toContain('<CodeBlock code="x" />');
178
+ expect(output).not.toContain('AstryxCodeBlock');
179
+ });
137
180
  });
@@ -64,4 +64,40 @@ describe('migrate-xds-css-surfaces', () => {
64
64
  const output = await applyTransform(input);
65
65
  expect(output).toBe(input);
66
66
  });
67
+
68
+ it('rewrites @import of @xds/* package stylesheets', async () => {
69
+ const input = [
70
+ `@import '@xds/core/reset.css';`,
71
+ `@import '@xds/core/xds.css';`,
72
+ `@import '@xds/theme-default/theme.css';`,
73
+ ].join('\n');
74
+ const output = await applyTransform(input);
75
+ expect(output).toContain(`@import '@astryxdesign/core/reset.css';`);
76
+ // xds.css is renamed to astryx.css (file rename, not just scope swap).
77
+ expect(output).toContain(`@import '@astryxdesign/core/astryx.css';`);
78
+ // theme-default collapses to theme-neutral.
79
+ expect(output).toContain(
80
+ `@import '@astryxdesign/theme-neutral/theme.css';`,
81
+ );
82
+ expect(output).not.toContain('@xds/');
83
+ });
84
+
85
+ it('collapses theme-daily @import to theme-neutral and preserves quote style', async () => {
86
+ const input = `@import "@xds/theme-daily/theme.css";`;
87
+ const output = await applyTransform(input);
88
+ expect(output).toBe(`@import "@astryxdesign/theme-neutral/theme.css";`);
89
+ });
90
+
91
+ it('rewrites @import url() form', async () => {
92
+ const input = `@import url('@xds/core/reset.css');`;
93
+ const output = await applyTransform(input);
94
+ expect(output).toContain(`@astryxdesign/core/reset.css`);
95
+ expect(output).not.toContain('@xds/');
96
+ });
97
+
98
+ it('does not touch @import of non-xds packages', async () => {
99
+ const input = `@import '@acme/widgets/styles.css';`;
100
+ const output = await applyTransform(input);
101
+ expect(output).toBe(input);
102
+ });
67
103
  });
@@ -48,4 +48,45 @@ describe('migrate-xds-module-specifiers', () => {
48
48
  const output = await applyTransform(input, 'test.ts');
49
49
  expect(output).toBe(input);
50
50
  });
51
+
52
+ it('remaps defaultTheme -> neutralTheme when collapsing theme-default', async () => {
53
+ const output = await applyTransform(
54
+ `import {defaultTheme} from '@xds/theme-default';`,
55
+ 'test.ts',
56
+ );
57
+ // Package collapses to theme-neutral; binding aliased so local usage works.
58
+ expect(output).toContain('neutralTheme as defaultTheme');
59
+ expect(output).toContain('@astryxdesign/theme-neutral');
60
+ expect(output).not.toContain('@xds/');
61
+ expect(output).not.toContain('theme-default');
62
+ });
63
+
64
+ it('remaps defaultTheme -> neutralTheme for theme-daily and /built subpath', async () => {
65
+ const output = await applyTransform(
66
+ `import {defaultTheme} from '@xds/theme-daily/built';`,
67
+ 'test.ts',
68
+ );
69
+ expect(output).toContain('neutralTheme as defaultTheme');
70
+ expect(output).toContain('@astryxdesign/theme-neutral/built');
71
+ });
72
+
73
+ it('preserves an existing alias when remapping defaultTheme', async () => {
74
+ const output = await applyTransform(
75
+ `import {defaultTheme as dt} from '@xds/theme-default';`,
76
+ 'test.ts',
77
+ );
78
+ expect(output).toContain('neutralTheme as dt');
79
+ expect(output).toContain('@astryxdesign/theme-neutral');
80
+ });
81
+
82
+ it('does NOT remap neutralTheme import from theme-neutral (no rename needed)', async () => {
83
+ const output = await applyTransform(
84
+ `import {neutralTheme} from '@xds/theme-neutral';`,
85
+ 'test.ts',
86
+ );
87
+ expect(output).toContain('neutralTheme');
88
+ expect(output).toContain('@astryxdesign/theme-neutral');
89
+ expect(output).not.toContain('defaultTheme');
90
+ expect(output).not.toContain('neutralTheme as');
91
+ });
51
92
  });
@@ -85,35 +85,87 @@ export default function transformer(file, api) {
85
85
  // local alias and only the imported name is rewritten.
86
86
  const localRenames = new Map();
87
87
 
88
+ // Collision detection: un-prefixing `XDSCodeBlock` -> `CodeBlock` breaks if
89
+ // the file already has a top-level binding named `CodeBlock` (e.g. its own
90
+ // `export function CodeBlock`). Collect every existing top-level binding name
91
+ // up front so we can alias to `Astryx<Name>` instead of producing a duplicate
92
+ // declaration. We gather: import locals, and top-level function/class/var
93
+ // declaration names (the realistic collision sources for component wrappers).
94
+ const existingBindings = new Set();
95
+ root.find(j.ImportDeclaration).forEach(path => {
96
+ for (const spec of path.node.specifiers || []) {
97
+ if (spec.local && spec.local.name) existingBindings.add(spec.local.name);
98
+ }
99
+ });
100
+ const collectDeclName = node => {
101
+ if (!node) return;
102
+ if (
103
+ (node.type === 'FunctionDeclaration' ||
104
+ node.type === 'ClassDeclaration') &&
105
+ node.id
106
+ ) {
107
+ existingBindings.add(node.id.name);
108
+ } else if (node.type === 'VariableDeclaration') {
109
+ for (const d of node.declarations) {
110
+ if (d.id && d.id.type === 'Identifier') existingBindings.add(d.id.name);
111
+ }
112
+ }
113
+ };
114
+ root.find(j.Program).forEach(path => {
115
+ for (const stmt of path.node.body) {
116
+ collectDeclName(stmt);
117
+ // Unwrap `export function X` / `export const X`.
118
+ if (stmt.type === 'ExportNamedDeclaration' && stmt.declaration) {
119
+ collectDeclName(stmt.declaration);
120
+ }
121
+ if (stmt.type === 'ExportDefaultDeclaration' && stmt.declaration) {
122
+ collectDeclName(stmt.declaration);
123
+ }
124
+ }
125
+ });
126
+
88
127
  // 1. Rewrite import specifiers from @xds/core
89
128
  root.find(j.ImportDeclaration).forEach(path => {
90
129
  const source = path.node.source.value;
91
130
  if (typeof source !== 'string' || !XDS_CORE_SOURCE.test(source)) return;
92
131
 
93
- for (const spec of path.node.specifiers || []) {
94
- if (spec.type !== 'ImportSpecifier') continue; // skip default/namespace
132
+ path.node.specifiers = (path.node.specifiers || []).map(spec => {
133
+ if (spec.type !== 'ImportSpecifier') return spec; // default/namespace
95
134
  const importedName = spec.imported.name;
96
135
  const bare = bareName(importedName);
97
- if (!bare) continue;
136
+ if (!bare) return spec;
98
137
 
99
138
  const localName = spec.local.name;
100
139
  const wasAliased = localName !== importedName;
101
140
 
102
- // Rewrite the imported name to the bare alias.
103
- spec.imported.name = bare;
104
-
141
+ // We REPLACE the specifier node (rather than mutating .imported/.local)
142
+ // because recast preserves the original printed form of a mutated
143
+ // ImportSpecifier and will drop a newly-introduced `as local` alias.
144
+ // Building a fresh node makes recast print the full `imported as local`.
105
145
  if (wasAliased) {
106
146
  // `import {XDSButton as Btn}` -> `import {Button as Btn}`.
107
- // Local binding unchanged, so no usage rewrites needed.
108
147
  hasChanges = true;
109
- } else {
110
- // `import {XDSButton}` -> `import {Button}`. The local binding is the
111
- // prefixed name; rename it and all its references.
112
- spec.local.name = bare;
113
- localRenames.set(importedName, bare);
148
+ return j.importSpecifier(j.identifier(bare), j.identifier(localName));
149
+ }
150
+ if (bare !== importedName && existingBindings.has(bare)) {
151
+ // COLLISION: the bare name is already a top-level binding in this file
152
+ // (e.g. a local `export function CodeBlock` alongside imported
153
+ // `XDSCodeBlock`). Un-prefixing directly would create a duplicate
154
+ // declaration, so alias the import to `Astryx<Name>` and rename the
155
+ // import's references to that alias, leaving the local binding intact.
156
+ const alias = `Astryx${bare}`;
157
+ localRenames.set(importedName, alias);
158
+ existingBindings.add(alias);
114
159
  hasChanges = true;
160
+ return j.importSpecifier(j.identifier(bare), j.identifier(alias));
115
161
  }
116
- }
162
+ // `import {XDSButton}` -> `import {Button}`. The local binding is the
163
+ // prefixed name; rename it and all its references.
164
+ localRenames.set(importedName, bare);
165
+ existingBindings.add(bare);
166
+ hasChanges = true;
167
+ return j.importSpecifier(j.identifier(bare), j.identifier(bare));
168
+ });
117
169
  });
118
170
 
119
171
  // 2. Rewrite re-exports from @xds/core
@@ -18,6 +18,10 @@
18
18
  * [data-xds-media (media attribute selector)
19
19
  * @layer xds-theme (cascade layer name — incl. comma-separated
20
20
  * @layer xds-base `@layer a, b;` statement lists and nested blocks)
21
+ * @import '@xds/...' (package stylesheet imports — scope rewrite, plus
22
+ * the @xds/core/xds.css -> @astryxdesign/core/
23
+ * astryx.css file rename and the theme-default /
24
+ * theme-daily -> theme-neutral collapse)
21
25
  *
22
26
  * It deliberately does NOT blindly replace every `xds` substring: a bare
23
27
  * `xds` in a comment, a custom-property value, or an unrelated identifier is
@@ -30,9 +34,10 @@ export const meta = {
30
34
  description:
31
35
  'Rewrites the documented XDS CSS surfaces to their Astryx equivalents: ' +
32
36
  'the `.xds-*` class-selector prefix, `[data-xds-theme]` / ' +
33
- '`[data-xds-theme-prose]` / `[data-xds-media]` attribute selectors, and ' +
34
- '`@layer xds-theme` / `@layer xds-base` cascade-layer names all become ' +
35
- 'their `astryx-*` / `data-astryx-*` forms.',
37
+ '`[data-xds-theme-prose]` / `[data-xds-media]` attribute selectors, ' +
38
+ '`@layer xds-theme` / `@layer xds-base` cascade-layer names, and ' +
39
+ '`@import` of @xds/* package stylesheets (scope rewrite, xds.css->astryx.css, ' +
40
+ 'theme-default/theme-daily->theme-neutral) all become their Astryx forms.',
36
41
  pr: '#3092',
37
42
  fileExtensions: ['.css', '.scss'],
38
43
  };
@@ -52,6 +57,32 @@ function rewriteLayerPrelude(prelude) {
52
57
  );
53
58
  }
54
59
 
60
+ // Rewrite a single @import package-stylesheet specifier value (without quotes)
61
+ // from an @xds/* path to its @astryxdesign/* equivalent. Handles the two
62
+ // non-mechanical cases beyond the scope swap:
63
+ // @xds/core/xds.css -> @astryxdesign/core/astryx.css (file rename)
64
+ // @xds/theme-default/* -> @astryxdesign/theme-neutral/* (collapse)
65
+ // @xds/theme-daily/* -> @astryxdesign/theme-neutral/* (collapse)
66
+ // Returns the original value unchanged if it is not an @xds/* specifier.
67
+ function rewriteImportSpecifier(spec) {
68
+ if (!spec.startsWith('@xds/')) return spec;
69
+ // Theme package collapse (default/daily -> neutral).
70
+ let next = spec
71
+ .replace(/^@xds\/theme-default(\/|$)/, '@astryxdesign/theme-neutral$1')
72
+ .replace(/^@xds\/theme-daily(\/|$)/, '@astryxdesign/theme-neutral$1');
73
+ if (next === spec) {
74
+ // Not a collapsed theme — plain scope swap.
75
+ next = spec.replace(/^@xds\//, '@astryxdesign/');
76
+ }
77
+ // Core stylesheet file rename: xds.css -> astryx.css (only the core bundle;
78
+ // reset.css and others keep their names).
79
+ next = next.replace(
80
+ /^@astryxdesign\/core\/xds\.css$/,
81
+ '@astryxdesign/core/astryx.css',
82
+ );
83
+ return next;
84
+ }
85
+
55
86
  // Ordered, non-overlapping replacements. Each pattern is intentionally narrow
56
87
  // so we never touch a bare `xds` substring outside these surfaces.
57
88
  const REPLACEMENTS = [
@@ -62,6 +93,15 @@ const REPLACEMENTS = [
62
93
  // Cascade-layer preludes: `@layer <names>` up to the block `{` or `;`.
63
94
  // Rewrite only the recognized xds-* layer tokens inside the prelude.
64
95
  {re: /@layer\b[^{;]*/g, to: match => rewriteLayerPrelude(match)},
96
+ // Package stylesheet imports: `@import '@xds/...'` or `@import url('@xds/...')`.
97
+ // Rewrite only the quoted @xds/* specifier, preserving the quote style.
98
+ {
99
+ re: /@import\s+(?:url\(\s*)?(['"])(@xds\/[^'"]+)\1/g,
100
+ to: (match, quote, spec) => {
101
+ const next = rewriteImportSpecifier(spec);
102
+ return next === spec ? match : match.replace(spec, next);
103
+ },
104
+ },
65
105
  ];
66
106
 
67
107
  export default function transformer(file /*, api */) {
@@ -51,12 +51,57 @@ function rewriteLiteral(node) {
51
51
  return true;
52
52
  }
53
53
 
54
+ // @xds/theme-default and @xds/theme-daily both collapse to
55
+ // @astryxdesign/theme-neutral, whose exported theme binding is `neutralTheme`
56
+ // (not `defaultTheme`). When we rewrite an import from one of those packages,
57
+ // remap a `defaultTheme` named import to `neutralTheme`, aliasing back to the
58
+ // original local name so downstream usages keep working unchanged:
59
+ // import {defaultTheme} from '@xds/theme-default'
60
+ // -> import {neutralTheme as defaultTheme} from '@astryxdesign/theme-neutral'
61
+ // An already-aliased `{defaultTheme as x}` just has its imported name remapped.
62
+ const THEME_EXPORT_RENAMES = new Map([['defaultTheme', 'neutralTheme']]);
63
+ const COLLAPSED_THEME_SOURCES = new Set([
64
+ '@xds/theme-default',
65
+ '@xds/theme-daily',
66
+ ]);
67
+
68
+ function isCollapsedThemeSource(value) {
69
+ if (typeof value !== 'string') return false;
70
+ for (const src of COLLAPSED_THEME_SOURCES) {
71
+ if (value === src || value.startsWith(src + '/')) return true;
72
+ }
73
+ return false;
74
+ }
75
+
76
+ function remapThemeExportNames(importPath, j) {
77
+ let changed = false;
78
+ importPath.node.specifiers = (importPath.node.specifiers || []).map(spec => {
79
+ if (spec.type !== 'ImportSpecifier') return spec;
80
+ const importedName = spec.imported.name;
81
+ const renamed = THEME_EXPORT_RENAMES.get(importedName);
82
+ if (!renamed) return spec;
83
+ // Preserve the original local binding (so downstream usages keep working),
84
+ // remapping only the imported name. Build a FRESH specifier node: recast
85
+ // preserves the printed form of a mutated ImportSpecifier and would drop a
86
+ // newly-introduced `as local` alias, so mutating in place loses it.
87
+ const localName = spec.local.name;
88
+ changed = true;
89
+ return j.importSpecifier(j.identifier(renamed), j.identifier(localName));
90
+ });
91
+ return changed;
92
+ }
93
+
54
94
  export default function transformer(file, api) {
55
95
  const j = api.jscodeshift;
56
96
  const root = j(file.source);
57
97
  let hasChanges = false;
58
98
 
59
99
  root.find(j.ImportDeclaration).forEach(path => {
100
+ // Remap collapsed-theme export names BEFORE rewriting the source specifier
101
+ // (the check keys off the original @xds/theme-default|daily path).
102
+ if (isCollapsedThemeSource(path.node.source.value)) {
103
+ hasChanges = remapThemeExportNames(path, j) || hasChanges;
104
+ }
60
105
  hasChanges = rewriteLiteral(path.node.source) || hasChanges;
61
106
  });
62
107
 
@@ -29,7 +29,8 @@ import {ERROR_CODES} from '../lib/error-codes.mjs';
29
29
 
30
30
  const AGENTS_MD = 'AGENTS.md';
31
31
  const CLAUDE_MD = 'CLAUDE.md';
32
- const CLAUDE_DIR_MD = path.join('.claude', 'CLAUDE.md');
32
+ const CLAUDE_DIR_MD = '.claude/CLAUDE.md'; // cross-platform literal
33
+
33
34
 
34
35
  const MARKER_START = '<!-- ASTRYX:START -->';
35
36
  const MARKER_END = '<!-- ASTRYX:END -->';
@@ -78,13 +78,13 @@ describe('findShowcase() priority', () => {
78
78
  it('Badge resolves to Badge dir, not a sibling that uses Badge', async () => {
79
79
  const result = await findShowcase('Badge');
80
80
  expect(result).not.toBeNull();
81
- expect(result.filePath).toMatch(/\/Badge\//);
81
+ expect(result.filePath).toMatch(/[/\\]Badge[/\\]/);
82
82
  });
83
83
 
84
84
  it('Avatar resolves to Avatar dir, not AvatarStatusDot', async () => {
85
85
  const result = await findShowcase('Avatar');
86
86
  expect(result).not.toBeNull();
87
- expect(result.filePath).toMatch(/\/Avatar\//);
87
+ expect(result.filePath).toMatch(/[/\\]Avatar[/\\]/);
88
88
  expect(result.filePath).not.toMatch(/AvatarStatusDot/);
89
89
  });
90
90
 
@@ -92,7 +92,7 @@ describe('findShowcase() priority', () => {
92
92
  const result = await findShowcase('ClickableCard');
93
93
  expect(result).not.toBeNull();
94
94
  expect(result.name).toBe('ClickableCard');
95
- expect(result.filePath).toMatch(/\/Card\//);
95
+ expect(result.filePath).toMatch(/[/\\]Card[/\\]/);
96
96
  });
97
97
 
98
98
  it('SelectableCard resolves via componentsUsed in Card/', async () => {
@@ -104,7 +104,7 @@ describe('findShowcase() priority', () => {
104
104
  it('Stack resolves to Stack dir despite componentsUsed elsewhere', async () => {
105
105
  const result = await findShowcase('Stack');
106
106
  expect(result).not.toBeNull();
107
- expect(result.filePath).toMatch(/\/Stack\//);
107
+ expect(result.filePath).toMatch(/[/\\]Stack[/\\]/);
108
108
  });
109
109
 
110
110
  it('returns null for nonexistent component', async () => {
@@ -4,6 +4,7 @@ import {describe, it, expect, beforeEach, afterEach, vi} from 'vitest';
4
4
  import * as fs from 'node:fs';
5
5
  import * as path from 'node:path';
6
6
  import * as os from 'node:os';
7
+ import {fileURLToPath} from 'node:url';
7
8
  import {Command} from 'commander';
8
9
 
9
10
  import {registerDoctor} from './doctor.mjs';
@@ -128,7 +129,7 @@ describe('doctor — individual checks', () => {
128
129
  // serve a file written to an arbitrary tmp path at runtime. Write the
129
130
  // fixture inside the package tree so Vite can resolve it, then clean up.
130
131
  const fixtureDir = fs.mkdtempSync(
131
- path.join(path.dirname(new URL(import.meta.url).pathname), '__doctor_cfg_'),
132
+ path.join(path.dirname(fileURLToPath(import.meta.url)), '__doctor_cfg_'),
132
133
  );
133
134
  const configPath = path.join(fixtureDir, 'astryx.config.mjs');
134
135
  try {
@@ -145,7 +146,7 @@ describe('doctor — individual checks', () => {
145
146
 
146
147
  it('config: FAIL when astryx.config.mjs throws on import', async () => {
147
148
  const fixtureDir = fs.mkdtempSync(
148
- path.join(path.dirname(new URL(import.meta.url).pathname), '__doctor_cfg_'),
149
+ path.join(path.dirname(fileURLToPath(import.meta.url)), '__doctor_cfg_'),
149
150
  );
150
151
  const configPath = path.join(fixtureDir, 'astryx.config.mjs');
151
152
  try {
@@ -160,7 +161,7 @@ describe('doctor — individual checks', () => {
160
161
 
161
162
  it('config: FAIL when default export is not an object', async () => {
162
163
  const fixtureDir = fs.mkdtempSync(
163
- path.join(path.dirname(new URL(import.meta.url).pathname), '__doctor_cfg_'),
164
+ path.join(path.dirname(fileURLToPath(import.meta.url)), '__doctor_cfg_'),
164
165
  );
165
166
  const configPath = path.join(fixtureDir, 'astryx.config.mjs');
166
167
  try {
@@ -335,10 +335,13 @@ export function resolveImportPath(coreDir, componentName) {
335
335
  ? JSON.parse(fs.readFileSync(pkgPath, 'utf-8'))
336
336
  : null;
337
337
 
338
+ const exportKeys = Object.keys(pkg?.exports || {});
339
+
338
340
  // Priority 1: exact subpath export matching the component name (e.g. ./Heading)
339
341
  // This allows convenience re-export directories to win over the source directory.
340
- if (pkg?.exports?.[`./${componentName}`]) {
341
- return `@astryxdesign/core/${componentName}`;
342
+ const exactMatch = exportKeys.find(k => k.toLowerCase() === `./${componentName}`.toLowerCase());
343
+ if (exactMatch) {
344
+ return `@astryxdesign/core/${exactMatch.slice(2)}`;
342
345
  }
343
346
 
344
347
  const sourcePath = findComponentSource(coreDir, componentName);
@@ -348,8 +351,9 @@ export function resolveImportPath(coreDir, componentName) {
348
351
  const relToSrc = path.relative(srcDir, sourcePath);
349
352
  const topDir = relToSrc.split(path.sep)[0];
350
353
 
351
- if (pkg?.exports?.[`./${topDir}`]) {
352
- return `@astryxdesign/core/${topDir}`;
354
+ const topMatch = exportKeys.find(k => k.toLowerCase() === `./${topDir}`.toLowerCase());
355
+ if (topMatch) {
356
+ return `@astryxdesign/core/${topMatch.slice(2)}`;
353
357
  }
354
358
 
355
359
  return '@astryxdesign/core';
@@ -7,9 +7,20 @@
7
7
  import {discoverComponents, findComponentReadme, resolveImportPath} from './component-discovery.mjs';
8
8
  import {loadDocs} from './component-loader.mjs';
9
9
 
10
- /** Derive the theme component key from a theming target (strips 'xds-' prefix). */
10
+ /**
11
+ * Derive the `defineTheme` component-override key from a theming target.
12
+ *
13
+ * Override keys are the component's stable class name with the `astryx-`
14
+ * namespace prefix stripped — `generateThemeRules` re-adds the prefix when it
15
+ * builds the `.astryx-*` selector. So `astryx-base-table` → key `base-table`
16
+ * (→ `.astryx-base-table`), and `astryx-button` → key `button`.
17
+ *
18
+ * Keep the `astryx-` literal in sync with packages/core/src/naming.ts
19
+ * (NAMESPACE / classPrefix), the same way build-theme.mjs mirrors it.
20
+ * <!-- SYNC: packages/core/src/naming.ts (namespace prefix source of truth) -->
21
+ */
11
22
  function targetKey(target) {
12
- return target.className.replace(/^xds-/, '');
23
+ return target.className.replace(/^astryx-/, '');
13
24
  }
14
25
 
15
26
  function dataAttrForName(name) {
@@ -51,3 +51,45 @@ describe('formatFull sub-component rendering', () => {
51
51
  expect(out).not.toContain('astryx component XDSButtonGroup');
52
52
  });
53
53
  });
54
+
55
+ describe('formatFull theming override keys', () => {
56
+ // Regression guard: the `defineTheme` component-override key is the stable
57
+ // class name with the `astryx-` prefix stripped — `generateThemeRules`
58
+ // re-adds the prefix to build the `.astryx-*` selector. targetKey() used to
59
+ // strip a dead `xds-` prefix (from before the astryx rename), so the printed
60
+ // example advertised `astryx-*` keys. Those double-prefix to
61
+ // `.astryx-astryx-*` at runtime and silently match nothing. See issue #3458.
62
+ it('prints override keys without the astryx- prefix (single-word component)', () => {
63
+ const docs = {
64
+ name: 'Button',
65
+ description: 'A button.',
66
+ theming: {targets: [{className: 'astryx-button', visualProps: ['variant']}]},
67
+ };
68
+ const out = formatFull(docs);
69
+
70
+ expect(out).toContain("'button': {");
71
+ // The full DOM class must not appear as an override key.
72
+ expect(out).not.toContain("'astryx-button': {");
73
+ });
74
+
75
+ it('prints override keys without the astryx- prefix (compound Table classes)', () => {
76
+ const docs = {
77
+ name: 'Table',
78
+ description: 'A table.',
79
+ theming: {
80
+ targets: [
81
+ {className: 'astryx-base-table'},
82
+ {className: 'astryx-table-cell'},
83
+ ],
84
+ },
85
+ };
86
+ const out = formatFull(docs);
87
+
88
+ // Correct keys: class name minus the astryx- prefix.
89
+ expect(out).toContain("'base-table': {");
90
+ expect(out).toContain("'table-cell': {");
91
+ // The verbatim DOM class names must not be advertised as override keys.
92
+ expect(out).not.toContain("'astryx-base-table': {");
93
+ expect(out).not.toContain("'astryx-table-cell': {");
94
+ });
95
+ });
@@ -97,7 +97,7 @@ describe('discoverExternalPackages', () => {
97
97
  fs.writeFileSync(
98
98
  path.join(scopedDir, 'package.json'),
99
99
  JSON.stringify({
100
- name: '@acme/xds-widgets',
100
+ name: '@acme/astryx-widgets',
101
101
  astryx: {docs: './lib', category: 'Widgets'},
102
102
  }),
103
103
  );
@@ -105,7 +105,7 @@ describe('discoverExternalPackages', () => {
105
105
  const result = discoverExternalPackages(tmpDir);
106
106
  expect(result).toEqual([
107
107
  {
108
- name: '@acme/xds-widgets',
108
+ name: '@acme/astryx-widgets',
109
109
  category: 'Widgets',
110
110
  docsDir: path.join(scopedDir, 'lib'),
111
111
  blocksDir: null,
@@ -0,0 +1,14 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @type {import('../../../../../core/src/docs-types').TemplateDoc} */
4
+ export const doc = {
5
+ type: 'block',
6
+ exampleFor: 'BaseTypeahead',
7
+ name: 'BaseTypeahead — Custom Search Bar',
8
+ displayName: 'BaseTypeahead — Custom Search Bar',
9
+ description:
10
+ 'BaseTypeahead embedded inside a custom-styled wrapper. The wrapper provides its own border and icon chrome; anchorRef positions the dropdown relative to it. Use this pattern when Typeahead\'s built-in field layout does not fit your composition.',
11
+ isReady: true,
12
+ aspectRatio: 16 / 9,
13
+ componentsUsed: ['BaseTypeahead', 'Icon', 'Layout', 'Text'],
14
+ };
@@ -0,0 +1,58 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ import {useRef, useState} from 'react';
6
+ import {BaseTypeahead, createStaticSource} from '@astryxdesign/core/Typeahead';
7
+ import type {SearchableItem} from '@astryxdesign/core/Typeahead';
8
+ import {Icon} from '@astryxdesign/core/Icon';
9
+ import {HStack, VStack} from '@astryxdesign/core/Layout';
10
+ import {Text} from '@astryxdesign/core/Text';
11
+ import {MagnifyingGlassIcon} from '@heroicons/react/24/outline';
12
+
13
+ const frameworks: SearchableItem[] = [
14
+ {id: 'react', label: 'React'},
15
+ {id: 'vue', label: 'Vue'},
16
+ {id: 'angular', label: 'Angular'},
17
+ {id: 'svelte', label: 'Svelte'},
18
+ {id: 'solid', label: 'SolidJS'},
19
+ {id: 'remix', label: 'Remix'},
20
+ {id: 'next', label: 'Next.js'},
21
+ {id: 'nuxt', label: 'Nuxt'},
22
+ ];
23
+
24
+ const source = createStaticSource(frameworks);
25
+
26
+ export default function BaseTypeaheadCustomSearch() {
27
+ const [value, setValue] = useState<SearchableItem | null>(null);
28
+ const wrapperRef = useRef<HTMLElement>(null);
29
+
30
+ return (
31
+ <VStack gap={3} style={{width: 320}}>
32
+ <HStack
33
+ ref={wrapperRef}
34
+ gap={2}
35
+ vAlign="center"
36
+ style={{
37
+ border: '1px solid var(--color-border)',
38
+ borderRadius: 'var(--radius-control)',
39
+ padding: '6px 10px',
40
+ background: 'var(--color-surface)',
41
+ }}>
42
+ <Icon icon={MagnifyingGlassIcon} size="sm" color="secondary" />
43
+ <BaseTypeahead
44
+ searchSource={source}
45
+ value={value}
46
+ onChange={setValue}
47
+ anchorRef={wrapperRef}
48
+ placeholder="Search frameworks…"
49
+ hasEntriesOnFocus
50
+ debounceMs={0}
51
+ />
52
+ </HStack>
53
+ <Text type="supporting" color="secondary">
54
+ {value != null ? `Selected: ${value.label}` : 'No selection'}
55
+ </Text>
56
+ </VStack>
57
+ );
58
+ }
@@ -0,0 +1,14 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @type {import('../../../../../core/src/docs-types').TemplateDoc} */
4
+ export const doc = {
5
+ type: 'block',
6
+ exampleFor: 'CodeBlock',
7
+ name: 'Code — Terminal',
8
+ displayName: 'Code — Terminal',
9
+ description:
10
+ 'A dark terminal-style command block: a bash CodeBlock wrapped in SyntaxTheme with the GitHub Dark preset, copy button on, and no line numbers. Use for shell sessions or CLI output that should read as a terminal even on light pages — reach for a dark syntax preset instead of hand-rolling a dark box with custom CSS.',
11
+ isReady: true,
12
+ aspectRatio: 16 / 9,
13
+ componentsUsed: ['CodeBlock', 'SyntaxTheme'],
14
+ };
@@ -0,0 +1,24 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ import {SyntaxTheme} from '@astryxdesign/core/theme';
6
+ import {githubDark} from '@astryxdesign/core/theme/syntax';
7
+ import {CodeBlock} from '@astryxdesign/core/CodeBlock';
8
+
9
+ const commands = `$ astryx init --features agents
10
+ ✓ AI agent docs installed → .claude/CLAUDE.md
11
+ $ pnpm astryx component CodeBlock --dense`;
12
+
13
+ export default function CodeBlockTerminal() {
14
+ return (
15
+ <SyntaxTheme theme={githubDark}>
16
+ <CodeBlock
17
+ code={commands}
18
+ language="bash"
19
+ hasCopyButton
20
+ style={{width: '100%', maxWidth: 480}}
21
+ />
22
+ </SyntaxTheme>
23
+ );
24
+ }
@@ -7,7 +7,7 @@ export const doc = {
7
7
  name: 'MetadataListItem — Basic',
8
8
  displayName: 'MetadataListItem — Basic',
9
9
  description:
10
- 'Labeled keyvalue rows inside a MetadataList. Values accept any content, from plain text to components like Badge.',
10
+ 'Labeled key-value rows inside a MetadataList. Values accept any content, from plain text to components like Badge.',
11
11
  isReady: true,
12
12
  aspectRatio: 16 / 9,
13
13
  componentsUsed: ['MetadataList', 'MetadataListItem', 'Badge'],
@@ -7,7 +7,7 @@ export const doc = {
7
7
  name: 'TabList — With Actions',
8
8
  displayName: 'TabList — With Actions',
9
9
  description:
10
- 'Page header pattern with tabs on the left and action buttons pushed to the right. When hasDivider is true, pair with a smaller button size (sm) so actions don\u2019t overpower the tab row.',
10
+ 'Page header pattern with tabs on the left and action buttons pushed to the right. When hasDivider is true, pair with a smaller button size (sm) so actions don\'t overpower the tab row.',
11
11
  isReady: true,
12
12
  aspectRatio: 4 / 3,
13
13
  componentsUsed: ['TabList', 'Tab', 'Button'],
@@ -0,0 +1,14 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @type {import('../../../../../core/src/docs-types').TemplateDoc} */
4
+ export const doc = {
5
+ type: 'block',
6
+ exampleFor: 'useTableRowExpansion',
7
+ name: 'useTableRowExpansion — Tree Table',
8
+ displayName: 'useTableRowExpansion — Tree Table',
9
+ description:
10
+ 'A tree table using useTableRowExpansion with inherited columns. Child rows use the same columns as parents, indented by depth. Click the chevron or right-click to expand/collapse.',
11
+ isReady: true,
12
+ aspectRatio: 16 / 9,
13
+ componentsUsed: ['Table'],
14
+ };
@@ -0,0 +1,99 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ import {useState} from 'react';
6
+ import {
7
+ Table,
8
+ useTableRowExpansion,
9
+ useTableRowExpansionState,
10
+ proportional,
11
+ pixel,
12
+ } from '@astryxdesign/core/Table';
13
+
14
+ interface FileNode extends Record<string, unknown> {
15
+ id: string;
16
+ name: string;
17
+ type: 'folder' | 'file';
18
+ size: string;
19
+ children?: FileNode[];
20
+ }
21
+
22
+ const fileTree: FileNode[] = [
23
+ {
24
+ id: 'src',
25
+ name: 'src',
26
+ type: 'folder',
27
+ size: '—',
28
+ children: [
29
+ {
30
+ id: 'src/components',
31
+ name: 'components',
32
+ type: 'folder',
33
+ size: '—',
34
+ children: [
35
+ {
36
+ id: 'src/components/Button.tsx',
37
+ name: 'Button.tsx',
38
+ type: 'file',
39
+ size: '4.2 KB',
40
+ children: [],
41
+ },
42
+ {
43
+ id: 'src/components/Table.tsx',
44
+ name: 'Table.tsx',
45
+ type: 'file',
46
+ size: '12.8 KB',
47
+ children: [],
48
+ },
49
+ ],
50
+ },
51
+ {
52
+ id: 'src/index.ts',
53
+ name: 'index.ts',
54
+ type: 'file',
55
+ size: '0.4 KB',
56
+ children: [],
57
+ },
58
+ ],
59
+ },
60
+ {
61
+ id: 'package.json',
62
+ name: 'package.json',
63
+ type: 'file',
64
+ size: '1.8 KB',
65
+ children: [],
66
+ },
67
+ ];
68
+
69
+ const columns = [
70
+ {key: 'name', header: 'Name', width: proportional(2)},
71
+ {key: 'type', header: 'Type', width: pixel(80)},
72
+ {key: 'size', header: 'Size', width: pixel(90)},
73
+ ];
74
+
75
+ export default function TableRowExpansionTable() {
76
+ const [expandedKeys, setExpandedKeys] = useState<Set<string>>(
77
+ new Set(['src']),
78
+ );
79
+
80
+ const {data, expansionConfig} = useTableRowExpansionState<FileNode>({
81
+ baseData: fileTree,
82
+ getChildren: item => item.children ?? [],
83
+ getRowKey: item => item.id,
84
+ expandedKeys,
85
+ setExpandedKeys,
86
+ });
87
+
88
+ const expansion = useTableRowExpansion(expansionConfig);
89
+
90
+ return (
91
+ <Table
92
+ data={data}
93
+ columns={columns}
94
+ idKey="id"
95
+ hasHover
96
+ plugins={{expansion}}
97
+ />
98
+ );
99
+ }
@@ -7,7 +7,7 @@ export const doc = {
7
7
  name: 'ToggleButtonGroup — Vertical',
8
8
  displayName: 'ToggleButtonGroup — Vertical',
9
9
  description:
10
- 'A vertically stacked ToggleButtonGroup using the vertical orientation, shown with both single-select and multi-select behavior ideal for sidebar-style option lists and vertical toolbars.',
10
+ 'A vertically stacked ToggleButtonGroup using the vertical orientation, shown with both single-select and multi-select behavior, ideal for sidebar-style option lists and vertical toolbars.',
11
11
  isReady: true,
12
12
  aspectRatio: 3 / 4,
13
13
  componentsUsed: ['ToggleButton', 'ToggleButtonGroup', 'Layout', 'Text'],
@@ -94,13 +94,13 @@ export const stoneTheme = defineTheme({
94
94
  // Core semantic — all neutrals H=291
95
95
  // Stone 900 T=16 C=1.4, Stone 500 T=55 C=4, Stone 300 T=86 C=1.6, Stone 100 T=96 C=1
96
96
  '--color-accent': ['#25252a', '#f3f3f5'], // light: Stone Neutral T15
97
- '--color-accent-muted': ['#25252a14', '#f3f3f5'], // light: Stone Neutral T15 · 8%
97
+ '--color-accent-muted': ['#25252a14', '#f3f3f520'], // light: Stone Neutral T15 · 8% / dark: T96 · 12.5%
98
98
  '--color-neutral': ['#25252a0f', '#f3f3f51a'], // light: Stone Neutral T15 · 6% / dark: T96 · 10%
99
99
  '--color-background-surface': ['#ffffff', '#1b1b1f'], // dark: Stone Neutral T10
100
100
  '--color-background-body': ['#f3f3f5', '#111015'], // dark: Stone Neutral T5
101
- '--color-overlay': ['#25252a80', '#28282a'], // light: Stone Neutral T15 · 50%
102
- '--color-overlay-hover': ['#25252a0d', '#f3f3f5'], // light: Stone Neutral T15 · 5%
103
- '--color-overlay-pressed': ['#25252a1a', '#f3f3f5'], // light: Stone Neutral T15 · 10%
101
+ '--color-overlay': ['#25252a80', '#28282acc'], // light: Stone Neutral T15 · 50% / dark: 80%
102
+ '--color-overlay-hover': ['#25252a0d', '#f3f3f50d'], // light: Stone Neutral T15 · 5% / dark: T96 · 5%
103
+ '--color-overlay-pressed': ['#25252a1a', '#f3f3f51a'], // light: Stone Neutral T15 · 10% / dark: T96 · 10%
104
104
  '--color-background-muted': ['#e2e2e8', '#3b3b3f'], // light: Stone Neutral T90
105
105
 
106
106
  // Text — H=291
@@ -136,12 +136,12 @@ export const stoneTheme = defineTheme({
136
136
  '--color-warning-muted': ['#f4e1b7', '#d7c59c'], // Yellow T90 / T80
137
137
 
138
138
  // Border — H=291
139
- '--color-border': ['#e2e2e8', '#f3f3f5'], // light: Stone Neutral T90
139
+ '--color-border': ['#e2e2e8', '#f3f3f51a'], // light: Stone Neutral T90 / dark: T96 · 10%
140
140
  '--color-border-emphasized': ['#83838a', '#5e5e61'], // T55 C=4 / T40 C=2
141
141
 
142
142
  // Effects — H=291
143
143
  '--color-skeleton': ['#d4d4da', '#5e5e64'], // T85 / T40 from H=291 C=3
144
- '--color-shadow': ['#25252a1a', '#000000'], // light: Stone Neutral T15 · 10%
144
+ '--color-shadow': ['#25252a1a', '#0000004d'], // light: Stone Neutral T15 · 10% / dark: 30%
145
145
  '--color-tint-hover': ['black', 'white'],
146
146
 
147
147
  // Typography override