@astryxdesign/cli 0.1.4-canary.ff77e1c → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/CHANGELOG.md +1 -2
  2. package/docs/getting-started.doc.mjs +0 -4
  3. package/docs/migration.doc.mjs +0 -134
  4. package/docs/styling.doc.mjs +0 -53
  5. package/docs/working-with-ai.doc.mjs +1 -1
  6. package/package.json +10 -15
  7. package/src/api/component.mjs +1 -2
  8. package/src/api/doctor.mjs +2 -13
  9. package/src/api/template.mjs +3 -14
  10. package/src/codemods/__tests__/registry.test.mjs +0 -1
  11. package/src/codemods/__tests__/runner.test.mjs +0 -38
  12. package/src/codemods/registry.mjs +0 -1
  13. package/src/codemods/runner.mjs +0 -2
  14. package/src/commands/agent-docs.mjs +6 -9
  15. package/src/commands/agent-docs.test.mjs +0 -33
  16. package/src/commands/build-theme.mjs +14 -112
  17. package/src/commands/component-resolution.test.mjs +4 -4
  18. package/src/commands/doctor.test.mjs +0 -34
  19. package/src/commands/init.mjs +1 -1
  20. package/src/commands/swizzle.mjs +0 -34
  21. package/src/commands/swizzle.routing.test.mjs +0 -67
  22. package/src/lib/component-discovery.mjs +4 -8
  23. package/templates/blocks/components/AspectRatio/AspectRatioCircleImage.tsx +6 -1
  24. package/templates/blocks/components/AspectRatio/AspectRatioImageGallery.tsx +7 -2
  25. package/templates/blocks/components/AspectRatio/AspectRatioShowcase.tsx +5 -2
  26. package/templates/blocks/components/AspectRatio/AspectRatioSquareImage.tsx +6 -1
  27. package/templates/blocks/components/AspectRatio/AspectRatioWidescreen.tsx +6 -1
  28. package/templates/blocks/components/Collapsible/CollapsibleWithoutCard.tsx +23 -25
  29. package/templates/blocks/components/CommandPaletteGroup/CommandPaletteGroupShowcase.tsx +48 -27
  30. package/templates/blocks/components/CommandPaletteItem/CommandPaletteItemShowcase.tsx +54 -31
  31. package/templates/pages/classic-gallery/page.tsx +1 -1
  32. package/templates/pages/dashboard/page.tsx +1 -1
  33. package/templates/pages/documentation/page.tsx +1 -1
  34. package/templates/pages/kanban-board/page.tsx +13 -37
  35. package/templates/pages/mixed-gallery/page.tsx +1 -1
  36. package/templates/pages/payment-form/page.tsx +6 -2
  37. package/templates/pages/product-detail/page.tsx +11 -3
  38. package/templates/pages/product-gallery/page.tsx +1 -1
  39. package/templates/pages/settings/page.tsx +1 -1
  40. package/templates/pages/side-gallery/page.tsx +1 -1
  41. package/templates/pages/table-page/page.tsx +1 -1
  42. package/templates/pages/table-page-chart/page.tsx +14 -4
  43. package/templates/pages/table-page-heatmap-status/page.tsx +1 -1
  44. package/templates/pages/table-page-shoe-store-heatmap/page.tsx +19 -5
  45. package/src/codemods/transforms/v0.1.5/__tests__/rename-switch-label-spacing-default-to-hug.test.mjs +0 -93
  46. package/src/codemods/transforms/v0.1.5/index.mjs +0 -19
  47. package/src/codemods/transforms/v0.1.5/rename-switch-label-spacing-default-to-hug.mjs +0 -140
  48. package/src/commands/build-theme.color-scheme.test.mjs +0 -153
  49. package/src/commands/build-theme.variants.test.mjs +0 -193
  50. package/templates/blocks/components/BaseTypeahead/BaseTypeaheadCustomSearch.doc.mjs +0 -14
  51. package/templates/blocks/components/BaseTypeahead/BaseTypeaheadCustomSearch.tsx +0 -58
  52. package/templates/blocks/components/CodeBlock/CodeBlockTerminal.doc.mjs +0 -14
  53. package/templates/blocks/components/CodeBlock/CodeBlockTerminal.tsx +0 -24
  54. package/templates/blocks/components/Collapsible/CollapsibleDividedAccordion.doc.mjs +0 -13
  55. package/templates/blocks/components/Collapsible/CollapsibleDividedAccordion.tsx +0 -33
  56. package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputBasic.doc.mjs +0 -15
  57. package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputBasic.tsx +0 -39
  58. package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputShowcase.doc.mjs +0 -15
  59. package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputShowcase.tsx +0 -39
  60. package/templates/blocks/components/CommandPaletteList/CommandPaletteListBasic.doc.mjs +0 -15
  61. package/templates/blocks/components/CommandPaletteList/CommandPaletteListBasic.tsx +0 -27
  62. package/templates/blocks/components/CommandPaletteList/CommandPaletteListShowcase.doc.mjs +0 -15
  63. package/templates/blocks/components/CommandPaletteList/CommandPaletteListShowcase.tsx +0 -38
  64. package/templates/blocks/components/ContextMenuItem/ContextMenuItemBasic.doc.mjs +0 -14
  65. package/templates/blocks/components/ContextMenuItem/ContextMenuItemBasic.tsx +0 -44
  66. package/templates/blocks/components/ContextMenuItem/ContextMenuItemShowcase.doc.mjs +0 -15
  67. package/templates/blocks/components/ContextMenuItem/ContextMenuItemShowcase.tsx +0 -107
  68. package/templates/blocks/components/NavHeadingMenu/NavHeadingMenuShowcase.doc.mjs +0 -15
  69. package/templates/blocks/components/NavHeadingMenu/NavHeadingMenuShowcase.tsx +0 -47
  70. package/templates/pages/incident-console/page.tsx +0 -580
  71. package/templates/pages/incident-console/template.doc.mjs +0 -12
  72. package/templates/pages/messaging-shell/page.tsx +0 -676
  73. package/templates/pages/messaging-shell/template.doc.mjs +0 -12
@@ -1,19 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file v0.1.5 transform manifest
5
- *
6
- * Lists all codemods for the v0.1.5 release in the order they should run.
7
- */
8
-
9
- import renameSwitchLabelSpacingDefaultToHug, {
10
- meta as renameSwitchLabelSpacingDefaultToHugMeta,
11
- } from './rename-switch-label-spacing-default-to-hug.mjs';
12
-
13
- export default [
14
- {
15
- name: 'rename-switch-label-spacing-default-to-hug',
16
- transform: renameSwitchLabelSpacingDefaultToHug,
17
- meta: renameSwitchLabelSpacingDefaultToHugMeta,
18
- },
19
- ];
@@ -1,140 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file Codemod: Rename Switch labelSpacing "default" to "hug"
5
- * @see https://github.com/facebook/astryx/issues/2889
6
- *
7
- * The `labelSpacing="default"` value is renamed to `labelSpacing="hug"` so
8
- * the name describes the behavior (label and switch hug each other), matching
9
- * the behavioral register of the sibling `spread` value and the existing
10
- * `hug`/`fill` layout vocabulary on TabList and SegmentedControl. The old
11
- * `default` value keeps working as a deprecated alias, so this codemod is a
12
- * cleanup, not a build fix.
13
- *
14
- * Transforms (scoped to Switch):
15
- * - <Switch labelSpacing="default" /> → <Switch labelSpacing="hug" />
16
- * - <Switch labelSpacing={'default'} /> → <Switch labelSpacing={'hug'} />
17
- * - <Switch labelSpacing={cond ? 'default' : x}> → <Switch labelSpacing={cond ? 'hug' : x}>
18
- * - Storybook argTypes: labelSpacing: { options: [..., 'default', ...] }
19
- * → replaces 'default' with 'hug' (files importing Switch)
20
- * - Object properties: { labelSpacing: 'default' } / { labelSpacing: 'default' as const }
21
- * → { labelSpacing: 'hug' } (files importing Switch)
22
- *
23
- * The transform deliberately does NOT touch bare `'default'` strings that are
24
- * not a `labelSpacing` value (an extremely common string otherwise), so it is
25
- * safe to run across an entire codebase.
26
- */
27
-
28
- export const meta = {
29
- title: 'Rename Switch labelSpacing "default" to "hug"',
30
- description:
31
- 'Renames the `labelSpacing="default"` value to `labelSpacing="hug"` on ' +
32
- 'Switch. The old value keeps working as a deprecated alias. Also updates ' +
33
- 'Storybook labelSpacing argTypes options and object-literal `labelSpacing` ' +
34
- 'props in files that import Switch.',
35
- pr: '#2889',
36
- };
37
-
38
- const OLD_VALUE = 'default';
39
- const NEW_VALUE = 'hug';
40
-
41
- /** Prop whose value is being renamed. */
42
- const TARGET_PROP = 'labelSpacing';
43
-
44
- /** Components whose `labelSpacing` prop accepts a SwitchLabelSpacing value. */
45
- const TARGET_COMPONENTS = new Set(['Switch']);
46
-
47
- export default function transformer(file, api) {
48
- const j = api.jscodeshift;
49
- const root = j(file.source);
50
- let hasChanges = false;
51
-
52
- /** Rewrite a string-literal node when it equals the old value. */
53
- function renameStringLiteral(node) {
54
- if (!node) return false;
55
- if (
56
- (node.type === 'StringLiteral' || node.type === 'Literal') &&
57
- node.value === OLD_VALUE
58
- ) {
59
- node.value = NEW_VALUE;
60
- if (node.raw) node.raw = `'${NEW_VALUE}'`;
61
- return true;
62
- }
63
- return false;
64
- }
65
-
66
- /** Recursively rewrite the old value inside ternary/logical expressions. */
67
- function renameInExpression(node) {
68
- if (!node) return false;
69
- let changed = false;
70
- if (node.type === 'StringLiteral' || node.type === 'Literal') {
71
- changed = renameStringLiteral(node) || changed;
72
- } else if (node.type === 'ConditionalExpression') {
73
- changed = renameInExpression(node.consequent) || changed;
74
- changed = renameInExpression(node.alternate) || changed;
75
- } else if (node.type === 'LogicalExpression') {
76
- changed = renameInExpression(node.left) || changed;
77
- changed = renameInExpression(node.right) || changed;
78
- } else if (node.type === 'TSAsExpression') {
79
- // `'default' as const` → rewrite the inner expression
80
- changed = renameInExpression(node.expression) || changed;
81
- }
82
- return changed;
83
- }
84
-
85
- // --- 1. JSX attribute: labelSpacing="default" / labelSpacing={'default'} on Switch ---
86
- root.find(j.JSXOpeningElement).forEach(path => {
87
- const name = path.node.name;
88
- const componentName = name.type === 'JSXIdentifier' ? name.name : null;
89
- if (!componentName || !TARGET_COMPONENTS.has(componentName)) return;
90
-
91
- path.node.attributes.forEach(attr => {
92
- if (attr.type !== 'JSXAttribute') return;
93
- if (!attr.name || attr.name.name !== TARGET_PROP) return;
94
-
95
- const value = attr.value;
96
- if (!value) return;
97
-
98
- if (value.type === 'StringLiteral' || value.type === 'Literal') {
99
- if (renameStringLiteral(value)) hasChanges = true;
100
- } else if (value.type === 'JSXExpressionContainer') {
101
- if (renameInExpression(value.expression)) hasChanges = true;
102
- }
103
- });
104
- });
105
-
106
- // Object-property / argTypes transforms only run in files that use a target
107
- // component — keeps unrelated `{ labelSpacing: 'default' }` strings safe.
108
- const importsTarget =
109
- root
110
- .find(j.ImportSpecifier)
111
- .filter(p => TARGET_COMPONENTS.has(p.node.imported?.name))
112
- .size() > 0;
113
-
114
- if (importsTarget) {
115
- const PropertyType = j.ObjectProperty ?? j.Property;
116
-
117
- // --- 2. Object property: { labelSpacing: 'default' } / 'default' as const ---
118
- root.find(PropertyType, {key: {name: TARGET_PROP}}).forEach(path => {
119
- if (renameInExpression(path.node.value)) hasChanges = true;
120
- });
121
-
122
- // --- 3. Storybook argTypes: labelSpacing: { options: [..., 'default', ...] } ---
123
- root.find(PropertyType, {key: {name: TARGET_PROP}}).forEach(path => {
124
- const value = path.node.value;
125
- if (!value || value.type !== 'ObjectExpression') return;
126
-
127
- const optionsProp = value.properties.find(
128
- p => p.key && (p.key.name === 'options' || p.key.value === 'options'),
129
- );
130
- if (optionsProp && optionsProp.value.type === 'ArrayExpression') {
131
- optionsProp.value.elements.forEach(el => {
132
- if (renameStringLiteral(el)) hasChanges = true;
133
- });
134
- }
135
- });
136
- }
137
-
138
- if (!hasChanges) return undefined;
139
- return root.toSource({quote: 'single'});
140
- }
@@ -1,153 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file Regression test for the `color-scheme` declaration `astryx theme build`
5
- * emits alongside `light-dark()` token output (see #3658).
6
- *
7
- * `astryx theme build` injects a `color-scheme` declaration into
8
- * `@layer astryx-theme` whenever the generated CSS contains `light-dark()`,
9
- * so LightningCSS/browsers can resolve it. That declaration must mirror
10
- * reset.css's own `html[data-theme]` -> `color-scheme` mapping (a bare
11
- * `:root { color-scheme: light dark; }` alone permanently pins the page to
12
- * "light dark", defeating `<Theme mode="light|dark">` forcing regardless of
13
- * `@layer astryx-theme` being declared after `@layer reset` in layer order):
14
- *
15
- * :root { color-scheme: light dark; }
16
- * html[data-theme="light"] { color-scheme: light; }
17
- * html[data-theme="dark"] { color-scheme: dark; }
18
- *
19
- * Themes that never use `light-dark()` have no `color-scheme` ambiguity to
20
- * resolve, so none of the three rules should be emitted for them.
21
- *
22
- * Building `astryx theme build` requires a compiled @astryxdesign/core (there is no in-CLI
23
- * fallback generator), so this suite builds core once in beforeAll via the
24
- * shared ensureCoreBuilt() helper — which serializes concurrent Vitest workers
25
- * behind a lock — to stay self-sufficient regardless of CI job ordering.
26
- */
27
-
28
- import {describe, it, expect, beforeAll, beforeEach, afterEach} from 'vitest';
29
- import {execFileSync} from 'node:child_process';
30
- import * as fs from 'node:fs';
31
- import * as path from 'node:path';
32
- import * as os from 'node:os';
33
- import {fileURLToPath} from 'node:url';
34
- import {ensureCoreBuilt} from './ensure-core-built.mjs';
35
-
36
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
37
- const CLI_BIN = path.resolve(__dirname, '../../bin/astryx.mjs');
38
-
39
- const COLOR_SCHEME_ROOT_DECL = ':root { color-scheme: light dark; }';
40
- const COLOR_SCHEME_LIGHT_DECL = 'html[data-theme="light"] { color-scheme: light; }';
41
- const COLOR_SCHEME_DARK_DECL = 'html[data-theme="dark"] { color-scheme: dark; }';
42
-
43
- function runCli(args, cwd) {
44
- try {
45
- const out = execFileSync('node', [CLI_BIN, ...args], {
46
- cwd,
47
- encoding: 'utf-8',
48
- stdio: ['ignore', 'pipe', 'pipe'],
49
- env: {...process.env, FORCE_COLOR: '0'},
50
- });
51
- return {code: 0, stdout: out, stderr: ''};
52
- } catch (e) {
53
- return {
54
- code: e.status ?? 1,
55
- stdout: e.stdout?.toString() ?? '',
56
- stderr: e.stderr?.toString() ?? '',
57
- };
58
- }
59
- }
60
-
61
- function writeTheme(dir, name, tokens) {
62
- fs.mkdirSync(dir, {recursive: true});
63
- // The CLI writes <basename>.css next to the source file, so use the
64
- // theme name as the filename for unambiguous fixtures.
65
- const file = path.join(dir, `${name}.mjs`);
66
- fs.writeFileSync(
67
- file,
68
- `export default { name: ${JSON.stringify(name)}, tokens: ${JSON.stringify(tokens)} };\n`,
69
- );
70
- return file;
71
- }
72
-
73
- // `astryx theme build` imports the compiled @astryxdesign/core/theme entry. Build core
74
- // once if it isn't already present so the suite works in any CI job.
75
- beforeAll(() => {
76
- ensureCoreBuilt();
77
- }, 200_000);
78
-
79
- let tmpDir;
80
- beforeEach(() => {
81
- tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-build-theme-color-scheme-'));
82
- });
83
- afterEach(() => {
84
- fs.rmSync(tmpDir, {recursive: true, force: true});
85
- });
86
-
87
- describe('theme build color-scheme output', () => {
88
- it('emits the mode-aware color-scheme rules in @layer astryx-theme for a light-dark() theme', () => {
89
- const project = path.join(tmpDir, 'project');
90
- const themesDir = path.join(project, 'themes');
91
- // A raw light-dark() token value is what triggers the color-scheme
92
- // injection in build-theme.mjs (it checks the generated CSS for the
93
- // literal substring). `defineTheme.test.ts` already covers the separate
94
- // [light, dark] tuple -> light-dark() conversion; this fixture writes
95
- // the string directly so this test stays focused on the CLI's own
96
- // color-scheme decision, not on that conversion.
97
- const themeFile = writeTheme(themesDir, 'with-light-dark', {
98
- '--color-accent': 'light-dark(#0077B6, #48CAE4)',
99
- });
100
-
101
- const result = runCli(
102
- ['theme', 'build', path.relative(project, themeFile)],
103
- project,
104
- );
105
-
106
- expect(result.code).toBe(0);
107
-
108
- const cssPath = path.join(themesDir, 'with-light-dark.css');
109
- expect(fs.existsSync(cssPath)).toBe(true);
110
- const css = fs.readFileSync(cssPath, 'utf-8');
111
-
112
- expect(css).toContain('light-dark(#0077B6, #48CAE4)');
113
-
114
- // All 3 rules must be present...
115
- expect(css).toContain(COLOR_SCHEME_ROOT_DECL);
116
- expect(css).toContain(COLOR_SCHEME_LIGHT_DECL);
117
- expect(css).toContain(COLOR_SCHEME_DARK_DECL);
118
-
119
- // ...and specifically inside @layer astryx-theme, not @layer reset (the
120
- // declaration must sit alongside the light-dark() token/component output
121
- // it resolves, not the zero-specificity prose defaults).
122
- const themeLayerStart = css.indexOf('@layer astryx-theme');
123
- expect(themeLayerStart).toBeGreaterThanOrEqual(0);
124
- const themeLayerBody = css.slice(themeLayerStart);
125
- expect(themeLayerBody).toContain(COLOR_SCHEME_ROOT_DECL);
126
- expect(themeLayerBody).toContain(COLOR_SCHEME_LIGHT_DECL);
127
- expect(themeLayerBody).toContain(COLOR_SCHEME_DARK_DECL);
128
- });
129
-
130
- it('omits all color-scheme rules for a theme with no light-dark() tokens', () => {
131
- const project = path.join(tmpDir, 'project');
132
- const themesDir = path.join(project, 'themes');
133
- const themeFile = writeTheme(themesDir, 'no-light-dark', {
134
- '--color-accent': '#0077B6',
135
- });
136
-
137
- const result = runCli(
138
- ['theme', 'build', path.relative(project, themeFile)],
139
- project,
140
- );
141
-
142
- expect(result.code).toBe(0);
143
-
144
- const cssPath = path.join(themesDir, 'no-light-dark.css');
145
- expect(fs.existsSync(cssPath)).toBe(true);
146
- const css = fs.readFileSync(cssPath, 'utf-8');
147
-
148
- expect(css).not.toContain('light-dark(');
149
- expect(css).not.toContain(COLOR_SCHEME_ROOT_DECL);
150
- expect(css).not.toContain(COLOR_SCHEME_LIGHT_DECL);
151
- expect(css).not.toContain(COLOR_SCHEME_DARK_DECL);
152
- });
153
- });
@@ -1,193 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file Regression test for the custom-variant type augmentations emitted by
5
- * `astryx theme build` (#3391 companion: #3371).
6
- *
7
- * When a theme declares a custom component prop value (e.g.
8
- * `button['variant:accentOutline']`), the build emits a `<name>.variants.d.ts`
9
- * with a module augmentation so the custom value type-checks. This suite pins
10
- * the two bugs that made that augmentation dead code:
11
- *
12
- * 1. The augmentation targeted a non-existent, `XDS`-prefixed interface
13
- * (`XDSButtonVariantMap`) instead of core's real `ButtonVariantMap`, so it
14
- * created a new unused interface and never widened the prop union.
15
- * 2. Props with no augmentation point (closed literal-union types such as
16
- * Button `size` or Heading `type`/`level`) still got a `declare module`
17
- * block against a `*Map` interface that doesn't exist.
18
- * 3. The generated `.variants.d.ts` was never referenced by the main
19
- * `<name>.d.ts`, so even a correct augmentation never loaded.
20
- *
21
- * Building `astryx theme build` requires a compiled @astryxdesign/core, so this
22
- * suite builds core once in beforeAll (mirrors build-theme.prose.test.mjs).
23
- */
24
-
25
- import {describe, it, expect, beforeAll, beforeEach, afterEach} from 'vitest';
26
- import {execFileSync} from 'node:child_process';
27
- import * as fs from 'node:fs';
28
- import * as path from 'node:path';
29
- import * as os from 'node:os';
30
- import {fileURLToPath} from 'node:url';
31
- import {ensureCoreBuilt} from './ensure-core-built.mjs';
32
-
33
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
34
- const CLI_BIN = path.resolve(__dirname, '../../bin/astryx.mjs');
35
-
36
- function runCli(args, cwd) {
37
- try {
38
- const out = execFileSync('node', [CLI_BIN, ...args], {
39
- cwd,
40
- encoding: 'utf-8',
41
- stdio: ['ignore', 'pipe', 'pipe'],
42
- env: {...process.env, FORCE_COLOR: '0'},
43
- });
44
- return {code: 0, stdout: out, stderr: ''};
45
- } catch (e) {
46
- return {
47
- code: e.status ?? 1,
48
- stdout: e.stdout?.toString() ?? '',
49
- stderr: e.stderr?.toString() ?? '',
50
- };
51
- }
52
- }
53
-
54
- function writeTheme(dir, contents) {
55
- fs.mkdirSync(dir, {recursive: true});
56
- const file = path.join(dir, 'variants-theme.mjs');
57
- fs.writeFileSync(file, contents);
58
- return file;
59
- }
60
-
61
- // Build core through the shared lock helper — this suite previously ran its
62
- // own unguarded `if (!exists) pnpm -F core build`, and when Vitest scheduled
63
- // it alongside the other build-theme suites on a fresh checkout, the
64
- // concurrent builds collided on packages/core/dist (core's build starts by
65
- // wiping dist), nondeterministically breaking whichever suite was mid-read.
66
- beforeAll(() => {
67
- ensureCoreBuilt();
68
- }, 200_000);
69
-
70
- let tmpDir;
71
- beforeEach(() => {
72
- tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-build-theme-variants-'));
73
- });
74
- afterEach(() => {
75
- fs.rmSync(tmpDir, {recursive: true, force: true});
76
- });
77
-
78
- describe('theme build custom-variant augmentations', () => {
79
- it('targets the real (un-prefixed) core interface for a custom variant', () => {
80
- const themeFile = writeTheme(
81
- tmpDir,
82
- `export default {
83
- name: 'variants-theme',
84
- tokens: { '--color-bg': '#fff' },
85
- components: {
86
- button: { 'variant:accentOutline': { backgroundColor: 'transparent' } },
87
- },
88
- };\n`,
89
- );
90
-
91
- const result = runCli(
92
- ['theme', 'build', path.relative(tmpDir, themeFile)],
93
- tmpDir,
94
- );
95
- expect(result.code).toBe(0);
96
-
97
- const variantsPath = path.join(tmpDir, 'variants-theme.variants.d.ts');
98
- expect(fs.existsSync(variantsPath)).toBe(true);
99
- const dts = fs.readFileSync(variantsPath, 'utf-8');
100
-
101
- // Targets core's actual augmentation point…
102
- expect(dts).toContain("declare module '@astryxdesign/core/Button'");
103
- expect(dts).toMatch(/interface ButtonVariantMap\b/);
104
- expect(dts).toContain("'accentOutline': true;");
105
- // …and NOT the old, non-existent XDS-prefixed interface.
106
- expect(dts).not.toMatch(/XDSButtonVariantMap/);
107
- });
108
-
109
- it('skips props with no augmentation point (Button size, Heading type)', () => {
110
- const themeFile = writeTheme(
111
- tmpDir,
112
- `export default {
113
- name: 'variants-theme',
114
- tokens: { '--color-bg': '#fff' },
115
- components: {
116
- button: {
117
- 'variant:accentOutline': { backgroundColor: 'transparent' },
118
- 'size:jumbo': { paddingBlock: '40px' },
119
- },
120
- heading: { 'type:hero': { fontSize: '80px' } },
121
- },
122
- };\n`,
123
- );
124
-
125
- const result = runCli(
126
- ['theme', 'build', path.relative(tmpDir, themeFile)],
127
- tmpDir,
128
- );
129
- expect(result.code).toBe(0);
130
-
131
- const variantsPath = path.join(tmpDir, 'variants-theme.variants.d.ts');
132
- expect(fs.existsSync(variantsPath)).toBe(true);
133
- const dts = fs.readFileSync(variantsPath, 'utf-8');
134
-
135
- // The augmentable variant is emitted…
136
- expect(dts).toMatch(/interface ButtonVariantMap\b/);
137
- // …but closed literal-union props get no dead augmentation.
138
- expect(dts).not.toMatch(/ButtonSizeMap/);
139
- expect(dts).not.toMatch(/HeadingTypeMap/);
140
- expect(dts).not.toContain("declare module '@astryxdesign/core/Heading'");
141
- });
142
-
143
- it('does not emit a .variants.d.ts when every custom value is non-augmentable', () => {
144
- const themeFile = writeTheme(
145
- tmpDir,
146
- `export default {
147
- name: 'variants-theme',
148
- tokens: { '--color-bg': '#fff' },
149
- components: {
150
- button: { 'size:jumbo': { paddingBlock: '40px' } },
151
- },
152
- };\n`,
153
- );
154
-
155
- const result = runCli(
156
- ['theme', 'build', path.relative(tmpDir, themeFile)],
157
- tmpDir,
158
- );
159
- expect(result.code).toBe(0);
160
- expect(
161
- fs.existsSync(path.join(tmpDir, 'variants-theme.variants.d.ts')),
162
- ).toBe(false);
163
- });
164
-
165
- it('references the variants file from the main .d.ts so the augmentation loads', () => {
166
- const themeFile = writeTheme(
167
- tmpDir,
168
- `export default {
169
- name: 'variants-theme',
170
- tokens: { '--color-bg': '#fff' },
171
- components: {
172
- button: { 'variant:accentOutline': { backgroundColor: 'transparent' } },
173
- },
174
- };\n`,
175
- );
176
-
177
- const result = runCli(
178
- ['theme', 'build', path.relative(tmpDir, themeFile)],
179
- tmpDir,
180
- );
181
- expect(result.code).toBe(0);
182
-
183
- const dts = fs.readFileSync(
184
- path.join(tmpDir, 'variants-theme.d.ts'),
185
- 'utf-8',
186
- );
187
- // A triple-slash reference to the variants file, so importing the theme's
188
- // types also loads the module augmentation.
189
- expect(dts).toMatch(
190
- /\/\/\/\s*<reference path="\.\/variants-theme\.variants\.d\.ts"\s*\/>/,
191
- );
192
- });
193
- });
@@ -1,14 +0,0 @@
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
- };
@@ -1,58 +0,0 @@
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
- }
@@ -1,14 +0,0 @@
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
- };
@@ -1,24 +0,0 @@
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
- }
@@ -1,13 +0,0 @@
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: 'Collapsible',
7
- name: 'Collapsible — Divided Accordion',
8
- displayName: 'Collapsible — Divided Accordion',
9
- description: 'FAQ-style accordion using the dividers prop on CollapsibleGroup: built-in row hairlines and density padding with zero custom CSS. Use for FAQs, settings lists, and nav sections.',
10
- isReady: true,
11
- aspectRatio: 4 / 3,
12
- componentsUsed: ['Collapsible', 'CollapsibleGroup', 'Text'],
13
- };
@@ -1,33 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- 'use client';
4
-
5
- import {Collapsible, CollapsibleGroup} from '@astryxdesign/core/Collapsible';
6
- import {Text} from '@astryxdesign/core/Text';
7
-
8
- export default function CollapsibleDividedAccordion() {
9
- return (
10
- <div style={{width: '100%', maxWidth: 400}}>
11
- <CollapsibleGroup type="single" dividers="between" defaultValue="reset">
12
- <Collapsible trigger="How do I reset my password?" value="reset">
13
- <Text type="body">
14
- Go to Settings → Security → Change Password. You'll receive a
15
- confirmation email within a few minutes.
16
- </Text>
17
- </Collapsible>
18
- <Collapsible trigger="Can I change my username?" value="username">
19
- <Text type="body">
20
- Usernames can be changed once every 30 days from your profile
21
- settings.
22
- </Text>
23
- </Collapsible>
24
- <Collapsible trigger="How do I delete my account?" value="delete">
25
- <Text type="body">
26
- Account deletion is permanent. Your data will be removed within 30
27
- days.
28
- </Text>
29
- </Collapsible>
30
- </CollapsibleGroup>
31
- </div>
32
- );
33
- }