@astryxdesign/cli 0.3.0-canary.e9fc2bb → 0.3.0-canary.ee705d8

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/api/template/template.test.mjs +26 -0
  2. package/assets/codemods/transforms/next/__tests__/next-codemods.test.mjs +92 -0
  3. package/assets/codemods/transforms/next/index.mjs +11 -1
  4. package/assets/codemods/transforms/next/rename-dropdown-menu-radio-dot-target.mjs +152 -0
  5. package/assets/codemods/transforms/v0.3.0/__tests__/migrate-table-rowexpansion-to-tree.test.mjs +201 -0
  6. package/assets/codemods/transforms/v0.3.0/index.mjs +8 -0
  7. package/assets/codemods/transforms/v0.3.0/migrate-table-rowexpansion-to-tree.mjs +214 -0
  8. package/assets/docs/getting-started.doc.mjs +3 -3
  9. package/assets/templates/blocks/components/Stepper/StepperHorizontal.doc.mjs +14 -0
  10. package/assets/templates/blocks/components/Stepper/StepperHorizontal.tsx +24 -0
  11. package/assets/templates/blocks/components/Stepper/StepperIndicatorModes.doc.mjs +14 -0
  12. package/assets/templates/blocks/components/Stepper/StepperIndicatorModes.tsx +68 -0
  13. package/assets/templates/blocks/components/Stepper/StepperMultiStepForm.doc.mjs +14 -0
  14. package/assets/templates/blocks/components/Stepper/StepperMultiStepForm.tsx +92 -0
  15. package/assets/templates/blocks/components/Stepper/StepperOnTrackVertical.doc.mjs +14 -0
  16. package/assets/templates/blocks/components/Stepper/StepperOnTrackVertical.tsx +41 -0
  17. package/assets/templates/blocks/components/Stepper/StepperShowcase.doc.mjs +15 -0
  18. package/assets/templates/blocks/components/Stepper/StepperShowcase.tsx +25 -0
  19. package/assets/templates/blocks/components/Stepper/StepperStatus.doc.mjs +14 -0
  20. package/assets/templates/blocks/components/Stepper/StepperStatus.tsx +50 -0
  21. package/assets/templates/blocks/components/Stepper/StepperVerticalOnboarding.doc.mjs +14 -0
  22. package/assets/templates/blocks/components/Stepper/StepperVerticalOnboarding.tsx +40 -0
  23. package/assets/templates/blocks/components/Table/TableRowExpansionTable.tsx +61 -58
  24. package/assets/templates/blocks/components/TextArea/TextAreaStates.tsx +1 -1
  25. package/assets/templates/themes/neutral/neutralTheme.ts +4 -1
  26. package/authoring/doctypes/base/type.ts +15 -0
  27. package/clients/cli/commands/build-theme.registry.test.mjs +14 -1
  28. package/foundation/discovery/template-adapter.d.mts +6 -3
  29. package/foundation/discovery/template-adapter.mjs +30 -14
  30. package/package.json +9 -9
@@ -0,0 +1,40 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ import {useState} from 'react';
6
+ import {Stepper, Step} from '@astryxdesign/lab';
7
+
8
+ export default function StepperVerticalOnboarding() {
9
+ const [active, setActive] = useState(2);
10
+ return (
11
+ <div style={{width: '100%', maxWidth: 400}}>
12
+ <Stepper
13
+ activeStep={active}
14
+ orientation="vertical"
15
+ onStepClick={setActive}>
16
+ <Step
17
+ step={0}
18
+ label="Create workspace"
19
+ description="Name and configure your workspace"
20
+ />
21
+ <Step
22
+ step={1}
23
+ label="Invite team members"
24
+ description="Add collaborators by email"
25
+ />
26
+ <Step
27
+ step={2}
28
+ label="Set up integrations"
29
+ description="Connect Slack, GitHub, Jira"
30
+ />
31
+ <Step
32
+ step={3}
33
+ label="Import data"
34
+ description="Bring in existing projects"
35
+ />
36
+ <Step step={4} label="Launch" description="Go live with your team" />
37
+ </Stepper>
38
+ </div>
39
+ );
40
+ }
@@ -6,90 +6,93 @@ import {useState} from 'react';
6
6
  import {
7
7
  Table,
8
8
  useTableRowExpansion,
9
- useTableRowExpansionState,
10
9
  proportional,
11
10
  pixel,
12
11
  } from '@astryxdesign/core/Table';
12
+ import {VStack, HStack} from '@astryxdesign/core/Stack';
13
+ import {Text, Heading} from '@astryxdesign/core/Text';
14
+ import {Badge} from '@astryxdesign/core/Badge';
13
15
 
14
- interface FileNode extends Record<string, unknown> {
16
+ interface Order extends Record<string, unknown> {
15
17
  id: string;
16
- name: string;
17
- type: 'folder' | 'file';
18
- size: string;
19
- children?: FileNode[];
18
+ customer: string;
19
+ status: string;
20
+ total: string;
21
+ items: {name: string; qty: number; price: string}[];
20
22
  }
21
23
 
22
- const fileTree: FileNode[] = [
24
+ const orders: Order[] = [
23
25
  {
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
- },
26
+ id: 'ord-1001',
27
+ customer: 'Ada Lovelace',
28
+ status: 'Shipped',
29
+ total: '$248.00',
30
+ items: [
31
+ {name: 'Mechanical keyboard', qty: 1, price: '$180.00'},
32
+ {name: 'Wrist rest', qty: 2, price: '$34.00'},
58
33
  ],
59
34
  },
60
35
  {
61
- id: 'package.json',
62
- name: 'package.json',
63
- type: 'file',
64
- size: '1.8 KB',
65
- children: [],
36
+ id: 'ord-1002',
37
+ customer: 'Alan Turing',
38
+ status: 'Processing',
39
+ total: '$52.00',
40
+ items: [{name: 'USB-C cable', qty: 4, price: '$13.00'}],
41
+ },
42
+ {
43
+ id: 'ord-1003',
44
+ customer: 'Grace Hopper',
45
+ status: 'Delivered',
46
+ total: '$1,200.00',
47
+ items: [{name: 'Standing desk', qty: 1, price: '$1,200.00'}],
66
48
  },
67
49
  ];
68
50
 
69
51
  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)},
52
+ {key: 'customer', header: 'Customer', width: proportional(2)},
53
+ {key: 'status', header: 'Status', width: pixel(130)},
54
+ {key: 'total', header: 'Total', width: pixel(110)},
73
55
  ];
74
56
 
75
57
  export default function TableRowExpansionTable() {
76
58
  const [expandedKeys, setExpandedKeys] = useState<Set<string>>(
77
- new Set(['src']),
59
+ new Set(['ord-1001']),
78
60
  );
79
61
 
80
- const {data, expansionConfig} = useTableRowExpansionState<FileNode>({
81
- baseData: fileTree,
82
- getChildren: item => item.children ?? [],
83
- getRowKey: item => item.id,
62
+ const expansion = useTableRowExpansion<Order>({
84
63
  expandedKeys,
85
- setExpandedKeys,
64
+ onToggle: key =>
65
+ setExpandedKeys(prev => {
66
+ const next = new Set(prev);
67
+ if (next.has(key)) {
68
+ next.delete(key);
69
+ } else {
70
+ next.add(key);
71
+ }
72
+ return next;
73
+ }),
74
+ getRowKey: item => item.id,
75
+ // The detail panel renders arbitrary content below the row: here, the
76
+ // order's line items. Any component composes here (charts, forms, tables).
77
+ renderExpanded: item => (
78
+ <VStack gap={2}>
79
+ <Heading level={4}>Line items</Heading>
80
+ {item.items.map(line => (
81
+ <HStack key={line.name} gap={3}>
82
+ <Badge label={`x${line.qty}`} variant="info" />
83
+ <Text type="body">{line.name}</Text>
84
+ <Text type="body" color="secondary">
85
+ {line.price}
86
+ </Text>
87
+ </HStack>
88
+ ))}
89
+ </VStack>
90
+ ),
86
91
  });
87
92
 
88
- const expansion = useTableRowExpansion(expansionConfig);
89
-
90
93
  return (
91
94
  <Table
92
- data={data}
95
+ data={orders}
93
96
  columns={columns}
94
97
  idKey="id"
95
98
  hasHover
@@ -20,7 +20,7 @@ export default function TextAreaStates() {
20
20
  />
21
21
  <TextArea
22
22
  label="Disabled field"
23
- value="This field is read-only and cannot be edited."
23
+ value="This field is disabled and cannot be edited."
24
24
  onChange={() => {}}
25
25
  isDisabled
26
26
  />
@@ -323,8 +323,11 @@ export const neutralTheme = defineTheme({
323
323
 
324
324
  // =========================================================================
325
325
  // Radius — slightly larger than default (kept as-is)
326
+ // --radius-none and --radius-full are always fixed and must never be
327
+ // scaled by a theme (see defineTheme's radius config docs) — 0 and
328
+ // 9999px respectively, matching @astryxdesign/core's own defaults.
326
329
  // =========================================================================
327
- '--radius-none': '0.25rem',
330
+ '--radius-none': '0px',
328
331
  '--radius-inner': '0.375rem',
329
332
  '--radius-element': '0.625rem',
330
333
  '--radius-container': '0.75rem',
@@ -260,6 +260,8 @@ export interface ComponentSlotElement {
260
260
  * { property: 'padding', vars: ['--_card-padding'] },
261
261
  * ```
262
262
  */
263
+ // SYNC: apps/docsite/scripts/generate-data.mjs (interface DerivedVar) — see the
264
+ // note on ComponentThemingTarget below.
263
265
  export interface ComponentThemingDerivedVar {
264
266
  /** The standard CSS property name (camelCase) that theme authors write.
265
267
  * e.g. `'borderRadius'`, `'padding'`, `'paddingBlock'` */
@@ -291,6 +293,10 @@ export interface ComponentThemingDerivedVar {
291
293
  * {className: 'astryx-card'}
292
294
  * ```
293
295
  */
296
+ // SYNC: When adding a field here, add it to the docsite's generated-registry
297
+ // copy too — apps/docsite/scripts/generate-data.mjs (interface ThemingTarget).
298
+ // `next build` type-checks the emitted componentRegistry.ts against that copy,
299
+ // so a field present in a .doc.mjs but missing there fails the docsite build.
294
300
  export interface ComponentThemingTarget {
295
301
  /** The stable CSS class name rendered by the component.
296
302
  * Always starts with `astryx-`.
@@ -310,6 +316,15 @@ export interface ComponentThemingTarget {
310
316
  * `[data-checked="checked"]`. Legacy state classes are still emitted for
311
317
  * compatibility. Omit if the element has no state-driven selectors. */
312
318
  states?: string[];
319
+ /** Set when this target has been RENAMED and this entry is the old name.
320
+ * The component still emits the class (via `themeProps`'s `legacyNames`),
321
+ * so existing themes keep working, but the docsite should steer readers to
322
+ * the replacement. The value is the class name that supersedes this one,
323
+ * without the `astryx-` prefix — e.g. `"checkbox-indicator"`.
324
+ *
325
+ * A theme target is public API; renaming one without this is a silent
326
+ * break for every theme styling it. */
327
+ deprecatedFor?: string;
313
328
  }
314
329
 
315
330
  /**
@@ -60,7 +60,10 @@ function renderedClassLiterals() {
60
60
  const full = path.join(dir, entry.name);
61
61
  if (entry.isDirectory()) {
62
62
  walk(full);
63
- } else if (entry.name.endsWith('.tsx') && !entry.name.endsWith('.test.tsx')) {
63
+ } else if (
64
+ (entry.name.endsWith('.tsx') || entry.name.endsWith('.ts')) &&
65
+ !entry.name.includes('.test.')
66
+ ) {
64
67
  const text = fs.readFileSync(full, 'utf8');
65
68
  for (const re of [
66
69
  /themeProps\(\s*'([^']+)'/g,
@@ -71,6 +74,16 @@ function renderedClassLiterals() {
71
74
  classes.add(m[1]);
72
75
  }
73
76
  }
77
+ // Renamed targets emit their old name too, via themeProps'
78
+ // `legacyNames`. Those classes are just as rendered as the primary
79
+ // one, so a doc entry for the old name is still backed by real output.
80
+ const legacyRe = /legacyNames:\s*\[([^\]]*)\]/g;
81
+ let lm;
82
+ while ((lm = legacyRe.exec(text)) !== null) {
83
+ for (const nm of lm[1].matchAll(/'([^']+)'/g)) {
84
+ classes.add(nm[1]);
85
+ }
86
+ }
74
87
  }
75
88
  }
76
89
  };
@@ -11,11 +11,14 @@ export function pkgOf(t: {
11
11
  package?: string;
12
12
  }): string;
13
13
  /**
14
- * Replace demo image references with a self-contained placeholder data URI so
15
- * scaffolded pages render with zero setup. Builders drop in their own images.
14
+ * Replace demo asset references with a placeholder so scaffolded pages
15
+ * render with zero setup. Images get a self-contained data URI; videos
16
+ * (which have no equivalent inline placeholder — see VIDEO_EXTENSIONS) are
17
+ * stripped to an empty src instead of being mis-replaced with image data.
18
+ * Builders drop in their own media either way.
16
19
  *
17
20
  * @param {string} source - Template source code.
18
- * @returns {string} Source with demo image references replaced.
21
+ * @returns {string} Source with demo asset references replaced.
19
22
  */
20
23
  export function stripTemplateAssetRefs(source: string): string;
21
24
  /**
@@ -153,19 +153,33 @@ const PLACEHOLDER_IMAGE =
153
153
  'data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20400%20300%22%20preserveAspectRatio%3D%22xMidYMid%20slice%22%3E%3Crect%20width%3D%22400%22%20height%3D%22300%22%20fill%3D%22%23f5f6f8%22%2F%3E%3Cg%20transform%3D%22translate%28200%20150%29%22%20fill%3D%22none%22%20stroke%3D%22%23c2cad6%22%20stroke-width%3D%225%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Crect%20x%3D%22-44%22%20y%3D%22-44%22%20width%3D%2288%22%20height%3D%2288%22%20rx%3D%2216%22%2F%3E%3Ccircle%20cx%3D%2218%22%20cy%3D%22-18%22%20r%3D%222.5%22%20fill%3D%22%23c2cad6%22%20stroke%3D%22none%22%2F%3E%3Cpath%20d%3D%22M-34%2030%20L-8%200%20L10%2018%20L20%208%20L34%2024%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E';
154
154
 
155
155
  /**
156
- * Demo-image sources to strip from scaffolded projects. Template demo imagery
156
+ * Extensions that need a video-safe placeholder rather than the image data
157
+ * URI (see stripTemplateAssetRefs). There's no equivalent self-contained
158
+ * inline placeholder for video: unlike an SVG data URI, a `<video src>`
159
+ * needs actual encoded media, and hand-authoring a valid tiny MP4/WebM
160
+ * blob isn't something we can do reliably here — an unverifiable, possibly
161
+ * still-broken binary would just trade one silent failure for another.
162
+ * Rather than mis-render image data as video (the original bug) or guess at
163
+ * binary bytes, video sources are stripped to an empty string so the
164
+ * scaffolded example is honest about needing the builder to supply their
165
+ * own file, instead of silently pointing at something that can't play.
166
+ *
167
+ * @type {Set<string>}
168
+ */
169
+ const VIDEO_EXTENSIONS = new Set(['mp4', 'webm', 'mov', 'ogv']);
170
+
171
+ /**
172
+ * Demo-asset sources to strip from scaffolded projects. Template demo imagery
157
173
  * is self-hosted under the docsite's `/template-assets/*` dir (committed there,
158
174
  * mirrored into the sandbox preview by scripts/sync-templates.js). Those paths
159
175
  * only resolve inside the Astryx docsite/sandbox, so on scaffold they're
160
- * replaced with a self-contained placeholder — a scaffolded project has no
161
- * `/template-assets/` dir and would otherwise 404. Genuine third-party URLs
162
- * (e.g. brand logos from paypalobjects.com) are intentionally left untouched.
176
+ * replaced — a scaffolded project has no `/template-assets/` dir and would
177
+ * otherwise 404. Genuine third-party URLs (e.g. brand logos from
178
+ * paypalobjects.com) are intentionally left untouched.
163
179
  *
164
- * @type {RegExp[]}
180
+ * @type {RegExp}
165
181
  */
166
- const DEMO_IMAGE_PATTERNS = [
167
- /\/template-assets\/[\w-]+\.\w+/g,
168
- ];
182
+ const DEMO_ASSET_PATTERN = /\/template-assets\/[\w-]+\.(\w+)/g;
169
183
 
170
184
  /**
171
185
  * Normalize path into Unix path (using forward slashes) for consistent comparison
@@ -179,16 +193,18 @@ function toPosixPath(p) {
179
193
  }
180
194
 
181
195
  /**
182
- * Replace demo image references with a self-contained placeholder data URI so
183
- * scaffolded pages render with zero setup. Builders drop in their own images.
196
+ * Replace demo asset references with a placeholder so scaffolded pages
197
+ * render with zero setup. Images get a self-contained data URI; videos
198
+ * (which have no equivalent inline placeholder — see VIDEO_EXTENSIONS) are
199
+ * stripped to an empty src instead of being mis-replaced with image data.
200
+ * Builders drop in their own media either way.
184
201
  *
185
202
  * @param {string} source - Template source code.
186
- * @returns {string} Source with demo image references replaced.
203
+ * @returns {string} Source with demo asset references replaced.
187
204
  */
188
205
  export function stripTemplateAssetRefs(source) {
189
- return DEMO_IMAGE_PATTERNS.reduce(
190
- (out, pattern) => out.replace(pattern, PLACEHOLDER_IMAGE),
191
- source,
206
+ return source.replace(DEMO_ASSET_PATTERN, (match, extension) =>
207
+ VIDEO_EXTENSIONS.has(extension.toLowerCase()) ? '' : PLACEHOLDER_IMAGE,
192
208
  );
193
209
  }
194
210
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.3.0-canary.e9fc2bb",
3
+ "version": "0.3.0-canary.ee705d8",
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",
@@ -84,10 +84,10 @@
84
84
  "zod": "^4.4.3"
85
85
  },
86
86
  "peerDependencies": {
87
- "@astryxdesign/charts": "0.3.0-canary.e9fc2bb",
88
- "@astryxdesign/core": "0.3.0-canary.e9fc2bb",
89
- "@astryxdesign/lab": "0.3.0-canary.e9fc2bb",
90
- "@astryxdesign/theme-neutral": "0.3.0-canary.e9fc2bb",
87
+ "@astryxdesign/charts": "0.3.0-canary.ee705d8",
88
+ "@astryxdesign/core": "0.3.0-canary.ee705d8",
89
+ "@astryxdesign/lab": "0.3.0-canary.ee705d8",
90
+ "@astryxdesign/theme-neutral": "0.3.0-canary.ee705d8",
91
91
  "gpt-tokenizer": "^3.4.0"
92
92
  },
93
93
  "peerDependenciesMeta": {
@@ -105,10 +105,10 @@
105
105
  }
106
106
  },
107
107
  "devDependencies": {
108
- "@astryxdesign/charts": "0.3.0-canary.e9fc2bb",
109
- "@astryxdesign/core": "0.3.0-canary.e9fc2bb",
110
- "@astryxdesign/lab": "0.3.0-canary.e9fc2bb",
111
- "@astryxdesign/theme-neutral": "0.3.0-canary.e9fc2bb",
108
+ "@astryxdesign/charts": "0.3.0-canary.ee705d8",
109
+ "@astryxdesign/core": "0.3.0-canary.ee705d8",
110
+ "@astryxdesign/lab": "0.3.0-canary.ee705d8",
111
+ "@astryxdesign/theme-neutral": "0.3.0-canary.ee705d8",
112
112
  "gpt-tokenizer": "^3.4.0"
113
113
  },
114
114
  "scripts": {