@astryxdesign/cli 0.1.4-canary.3b5f42e → 0.1.4-canary.3d64ef2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -1
- package/docs/getting-started.doc.mjs +4 -0
- package/docs/migration.doc.mjs +134 -0
- package/docs/styling.doc.mjs +53 -0
- package/package.json +14 -9
- package/src/api/doctor.mjs +13 -2
- package/src/codemods/__tests__/runner.test.mjs +38 -0
- package/src/codemods/runner.mjs +2 -0
- package/src/commands/agent-docs.mjs +7 -5
- package/src/commands/agent-docs.test.mjs +33 -0
- package/src/commands/build-theme.mjs +110 -13
- package/src/commands/build-theme.variants.test.mjs +204 -0
- package/src/commands/doctor.test.mjs +34 -0
- package/src/commands/init.mjs +1 -1
- package/src/commands/swizzle.mjs +34 -0
- package/src/commands/swizzle.routing.test.mjs +67 -0
- package/templates/blocks/components/CodeBlock/CodeBlockTerminal.doc.mjs +1 -1
- package/templates/blocks/components/Collapsible/CollapsibleDividedAccordion.doc.mjs +13 -0
- package/templates/blocks/components/Collapsible/CollapsibleDividedAccordion.tsx +33 -0
- package/templates/blocks/components/CommandPaletteGroup/CommandPaletteGroupShowcase.tsx +27 -48
- package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputBasic.doc.mjs +15 -0
- package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputBasic.tsx +39 -0
- package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputShowcase.doc.mjs +15 -0
- package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputShowcase.tsx +39 -0
- package/templates/blocks/components/CommandPaletteItem/CommandPaletteItemShowcase.tsx +31 -54
- package/templates/blocks/components/CommandPaletteList/CommandPaletteListBasic.doc.mjs +15 -0
- package/templates/blocks/components/CommandPaletteList/CommandPaletteListBasic.tsx +27 -0
- package/templates/blocks/components/CommandPaletteList/CommandPaletteListShowcase.doc.mjs +15 -0
- package/templates/blocks/components/CommandPaletteList/CommandPaletteListShowcase.tsx +38 -0
- package/templates/blocks/components/ContextMenuItem/ContextMenuItemBasic.doc.mjs +14 -0
- package/templates/blocks/components/ContextMenuItem/ContextMenuItemBasic.tsx +44 -0
- package/templates/blocks/components/ContextMenuItem/ContextMenuItemShowcase.doc.mjs +15 -0
- package/templates/blocks/components/ContextMenuItem/ContextMenuItemShowcase.tsx +107 -0
- package/templates/blocks/components/NavHeadingMenu/NavHeadingMenuShowcase.tsx +18 -16
- package/templates/pages/table-page-chart/page.tsx +3 -13
- package/templates/pages/table-page-shoe-store-heatmap/page.tsx +4 -18
|
@@ -0,0 +1,204 @@
|
|
|
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
|
+
|
|
32
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
33
|
+
const CLI_BIN = path.resolve(__dirname, '../../bin/astryx.mjs');
|
|
34
|
+
const REPO_ROOT = path.resolve(__dirname, '../../../..');
|
|
35
|
+
const CORE_THEME_ENTRY = path.join(
|
|
36
|
+
REPO_ROOT,
|
|
37
|
+
'packages/core/dist/theme/index.js',
|
|
38
|
+
);
|
|
39
|
+
// The fix reads core's shipped component declarations to decide whether an
|
|
40
|
+
// interface is augmentable; those .d.ts files come from the same core build.
|
|
41
|
+
const CORE_BUTTON_DTS = path.join(
|
|
42
|
+
REPO_ROOT,
|
|
43
|
+
'packages/core/dist/Button/index.d.ts',
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
function runCli(args, cwd) {
|
|
47
|
+
try {
|
|
48
|
+
const out = execFileSync('node', [CLI_BIN, ...args], {
|
|
49
|
+
cwd,
|
|
50
|
+
encoding: 'utf-8',
|
|
51
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
52
|
+
env: {...process.env, FORCE_COLOR: '0'},
|
|
53
|
+
});
|
|
54
|
+
return {code: 0, stdout: out, stderr: ''};
|
|
55
|
+
} catch (e) {
|
|
56
|
+
return {
|
|
57
|
+
code: e.status ?? 1,
|
|
58
|
+
stdout: e.stdout?.toString() ?? '',
|
|
59
|
+
stderr: e.stderr?.toString() ?? '',
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function writeTheme(dir, contents) {
|
|
65
|
+
fs.mkdirSync(dir, {recursive: true});
|
|
66
|
+
const file = path.join(dir, 'variants-theme.mjs');
|
|
67
|
+
fs.writeFileSync(file, contents);
|
|
68
|
+
return file;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
beforeAll(() => {
|
|
72
|
+
if (!fs.existsSync(CORE_THEME_ENTRY) || !fs.existsSync(CORE_BUTTON_DTS)) {
|
|
73
|
+
execFileSync('pnpm', ['-F', '@astryxdesign/core', 'build'], {
|
|
74
|
+
cwd: REPO_ROOT,
|
|
75
|
+
stdio: 'pipe',
|
|
76
|
+
timeout: 180_000,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}, 200_000);
|
|
80
|
+
|
|
81
|
+
let tmpDir;
|
|
82
|
+
beforeEach(() => {
|
|
83
|
+
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-build-theme-variants-'));
|
|
84
|
+
});
|
|
85
|
+
afterEach(() => {
|
|
86
|
+
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe('theme build custom-variant augmentations', () => {
|
|
90
|
+
it('targets the real (un-prefixed) core interface for a custom variant', () => {
|
|
91
|
+
const themeFile = writeTheme(
|
|
92
|
+
tmpDir,
|
|
93
|
+
`export default {
|
|
94
|
+
name: 'variants-theme',
|
|
95
|
+
tokens: { '--color-bg': '#fff' },
|
|
96
|
+
components: {
|
|
97
|
+
button: { 'variant:accentOutline': { backgroundColor: 'transparent' } },
|
|
98
|
+
},
|
|
99
|
+
};\n`,
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const result = runCli(
|
|
103
|
+
['theme', 'build', path.relative(tmpDir, themeFile)],
|
|
104
|
+
tmpDir,
|
|
105
|
+
);
|
|
106
|
+
expect(result.code).toBe(0);
|
|
107
|
+
|
|
108
|
+
const variantsPath = path.join(tmpDir, 'variants-theme.variants.d.ts');
|
|
109
|
+
expect(fs.existsSync(variantsPath)).toBe(true);
|
|
110
|
+
const dts = fs.readFileSync(variantsPath, 'utf-8');
|
|
111
|
+
|
|
112
|
+
// Targets core's actual augmentation point…
|
|
113
|
+
expect(dts).toContain("declare module '@astryxdesign/core/Button'");
|
|
114
|
+
expect(dts).toMatch(/interface ButtonVariantMap\b/);
|
|
115
|
+
expect(dts).toContain("'accentOutline': true;");
|
|
116
|
+
// …and NOT the old, non-existent XDS-prefixed interface.
|
|
117
|
+
expect(dts).not.toMatch(/XDSButtonVariantMap/);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('skips props with no augmentation point (Button size, Heading type)', () => {
|
|
121
|
+
const themeFile = writeTheme(
|
|
122
|
+
tmpDir,
|
|
123
|
+
`export default {
|
|
124
|
+
name: 'variants-theme',
|
|
125
|
+
tokens: { '--color-bg': '#fff' },
|
|
126
|
+
components: {
|
|
127
|
+
button: {
|
|
128
|
+
'variant:accentOutline': { backgroundColor: 'transparent' },
|
|
129
|
+
'size:jumbo': { paddingBlock: '40px' },
|
|
130
|
+
},
|
|
131
|
+
heading: { 'type:hero': { fontSize: '80px' } },
|
|
132
|
+
},
|
|
133
|
+
};\n`,
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
const result = runCli(
|
|
137
|
+
['theme', 'build', path.relative(tmpDir, themeFile)],
|
|
138
|
+
tmpDir,
|
|
139
|
+
);
|
|
140
|
+
expect(result.code).toBe(0);
|
|
141
|
+
|
|
142
|
+
const variantsPath = path.join(tmpDir, 'variants-theme.variants.d.ts');
|
|
143
|
+
expect(fs.existsSync(variantsPath)).toBe(true);
|
|
144
|
+
const dts = fs.readFileSync(variantsPath, 'utf-8');
|
|
145
|
+
|
|
146
|
+
// The augmentable variant is emitted…
|
|
147
|
+
expect(dts).toMatch(/interface ButtonVariantMap\b/);
|
|
148
|
+
// …but closed literal-union props get no dead augmentation.
|
|
149
|
+
expect(dts).not.toMatch(/ButtonSizeMap/);
|
|
150
|
+
expect(dts).not.toMatch(/HeadingTypeMap/);
|
|
151
|
+
expect(dts).not.toContain("declare module '@astryxdesign/core/Heading'");
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('does not emit a .variants.d.ts when every custom value is non-augmentable', () => {
|
|
155
|
+
const themeFile = writeTheme(
|
|
156
|
+
tmpDir,
|
|
157
|
+
`export default {
|
|
158
|
+
name: 'variants-theme',
|
|
159
|
+
tokens: { '--color-bg': '#fff' },
|
|
160
|
+
components: {
|
|
161
|
+
button: { 'size:jumbo': { paddingBlock: '40px' } },
|
|
162
|
+
},
|
|
163
|
+
};\n`,
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
const result = runCli(
|
|
167
|
+
['theme', 'build', path.relative(tmpDir, themeFile)],
|
|
168
|
+
tmpDir,
|
|
169
|
+
);
|
|
170
|
+
expect(result.code).toBe(0);
|
|
171
|
+
expect(
|
|
172
|
+
fs.existsSync(path.join(tmpDir, 'variants-theme.variants.d.ts')),
|
|
173
|
+
).toBe(false);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it('references the variants file from the main .d.ts so the augmentation loads', () => {
|
|
177
|
+
const themeFile = writeTheme(
|
|
178
|
+
tmpDir,
|
|
179
|
+
`export default {
|
|
180
|
+
name: 'variants-theme',
|
|
181
|
+
tokens: { '--color-bg': '#fff' },
|
|
182
|
+
components: {
|
|
183
|
+
button: { 'variant:accentOutline': { backgroundColor: 'transparent' } },
|
|
184
|
+
},
|
|
185
|
+
};\n`,
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
const result = runCli(
|
|
189
|
+
['theme', 'build', path.relative(tmpDir, themeFile)],
|
|
190
|
+
tmpDir,
|
|
191
|
+
);
|
|
192
|
+
expect(result.code).toBe(0);
|
|
193
|
+
|
|
194
|
+
const dts = fs.readFileSync(
|
|
195
|
+
path.join(tmpDir, 'variants-theme.d.ts'),
|
|
196
|
+
'utf-8',
|
|
197
|
+
);
|
|
198
|
+
// A triple-slash reference to the variants file, so importing the theme's
|
|
199
|
+
// types also loads the module augmentation.
|
|
200
|
+
expect(dts).toMatch(
|
|
201
|
+
/\/\/\/\s*<reference path="\.\/variants-theme\.variants\.d\.ts"\s*\/>/,
|
|
202
|
+
);
|
|
203
|
+
});
|
|
204
|
+
});
|
|
@@ -63,6 +63,33 @@ function installPkg(name, version = '1.0.0') {
|
|
|
63
63
|
return dir;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Mirror pnpm's layout: the real package lives under node_modules/.pnpm and
|
|
68
|
+
* the entry in the scope directory is a symlink to it.
|
|
69
|
+
*/
|
|
70
|
+
function installPkgPnpmStyle(name, version = '1.0.0') {
|
|
71
|
+
const realDir = path.join(
|
|
72
|
+
tmpDir,
|
|
73
|
+
'node_modules',
|
|
74
|
+
'.pnpm',
|
|
75
|
+
`${name.replace('/', '+')}@${version}`,
|
|
76
|
+
'node_modules',
|
|
77
|
+
...name.split('/'),
|
|
78
|
+
);
|
|
79
|
+
fs.mkdirSync(realDir, {recursive: true});
|
|
80
|
+
fs.writeFileSync(
|
|
81
|
+
path.join(realDir, 'package.json'),
|
|
82
|
+
JSON.stringify({name, version, main: 'index.js'}),
|
|
83
|
+
);
|
|
84
|
+
fs.writeFileSync(path.join(realDir, 'index.js'), 'module.exports = {};');
|
|
85
|
+
const linkPath = path.join(tmpDir, 'node_modules', ...name.split('/'));
|
|
86
|
+
fs.mkdirSync(path.dirname(linkPath), {recursive: true});
|
|
87
|
+
// 'junction' keeps this working on Windows without elevated permissions;
|
|
88
|
+
// it is ignored on posix.
|
|
89
|
+
fs.symlinkSync(realDir, linkPath, 'junction');
|
|
90
|
+
return linkPath;
|
|
91
|
+
}
|
|
92
|
+
|
|
66
93
|
function find(checks, id) {
|
|
67
94
|
return checks.find(c => c.id === id);
|
|
68
95
|
}
|
|
@@ -119,6 +146,13 @@ describe('doctor — individual checks', () => {
|
|
|
119
146
|
expect(res.status).toBe('pass');
|
|
120
147
|
});
|
|
121
148
|
|
|
149
|
+
it('themes: detects pnpm-style symlinked theme packages (#3530)', () => {
|
|
150
|
+
installPkgPnpmStyle('@astryxdesign/theme-neutral', '0.1.2');
|
|
151
|
+
const res = checkThemes({cwd: tmpDir, configTheme: 'default'});
|
|
152
|
+
expect(res.status).toBe('pass');
|
|
153
|
+
expect(res.message).toContain('@astryxdesign/theme-neutral');
|
|
154
|
+
});
|
|
155
|
+
|
|
122
156
|
it('config: INFO when no astryx.config.mjs', async () => {
|
|
123
157
|
const res = await checkConfig({cwd: tmpDir, configPath: null});
|
|
124
158
|
expect(res.status).toBe('info');
|
package/src/commands/init.mjs
CHANGED
|
@@ -198,7 +198,7 @@ export function registerInit(program) {
|
|
|
198
198
|
.option('--features <list>', 'Comma-separated features to install (agents, theme, template)')
|
|
199
199
|
.option('--all', 'Install all features, no prompts')
|
|
200
200
|
.option('--remove-agents', 'Remove AI agent docs from all agent doc files')
|
|
201
|
-
.option('--agent <tool>', 'Target AI tool for agent docs: claude, cursor, codex, all')
|
|
201
|
+
.option('--agent <tool>', 'Target AI tool for agent docs: claude, cursor, codex, hermes, all')
|
|
202
202
|
.option('--agent-docs-path <path...>', 'Explicit file path(s) for agent docs')
|
|
203
203
|
.action(async (options) => {
|
|
204
204
|
const targetDir = process.cwd();
|
package/src/commands/swizzle.mjs
CHANGED
|
@@ -26,6 +26,7 @@ import {jsonOut, humanLog} from '../lib/json.mjs';
|
|
|
26
26
|
import {cliError} from '../lib/cli-error.mjs';
|
|
27
27
|
import {ERROR_CODES} from '../lib/error-codes.mjs';
|
|
28
28
|
import {checkGhCli} from '../utils/github.mjs';
|
|
29
|
+
import {getRunPrefix} from '../utils/package-manager.mjs';
|
|
29
30
|
import {Project} from '../lib/project.mjs';
|
|
30
31
|
import {
|
|
31
32
|
CORE_PACKAGE,
|
|
@@ -339,6 +340,10 @@ export function registerSwizzle(program) {
|
|
|
339
340
|
// Copy all non-test, non-doc, non-README files
|
|
340
341
|
const files = fs.readdirSync(componentDir);
|
|
341
342
|
let copied = 0;
|
|
343
|
+
// Track whether any copied source uses StyleX. Swizzled StyleX source
|
|
344
|
+
// needs a build-time StyleX compiler in the consumer's app or it renders
|
|
345
|
+
// unstyled with no error — so we surface a setup note after copying.
|
|
346
|
+
let usesStyleX = false;
|
|
342
347
|
|
|
343
348
|
for (const file of files) {
|
|
344
349
|
// Skip test files, doc files, and README
|
|
@@ -355,6 +360,13 @@ export function registerSwizzle(program) {
|
|
|
355
360
|
content = rewriteImports(content, owner.ownerPackage);
|
|
356
361
|
}
|
|
357
362
|
|
|
363
|
+
if (
|
|
364
|
+
(file.endsWith('.ts') || file.endsWith('.tsx')) &&
|
|
365
|
+
content.includes('@stylexjs/stylex')
|
|
366
|
+
) {
|
|
367
|
+
usesStyleX = true;
|
|
368
|
+
}
|
|
369
|
+
|
|
358
370
|
fs.writeFileSync(path.join(outputDir, file), content);
|
|
359
371
|
copied++;
|
|
360
372
|
}
|
|
@@ -376,6 +388,7 @@ export function registerSwizzle(program) {
|
|
|
376
388
|
outputDir: relOutput,
|
|
377
389
|
filesCopied: copied,
|
|
378
390
|
files: copiedFiles.map(f => f),
|
|
391
|
+
usesStyleX,
|
|
379
392
|
};
|
|
380
393
|
if (feedback) payload.feedback = feedback;
|
|
381
394
|
return jsonOut('swizzle.copy', payload);
|
|
@@ -387,6 +400,27 @@ export function registerSwizzle(program) {
|
|
|
387
400
|
);
|
|
388
401
|
humanLog('You can now customize the component source freely.\n');
|
|
389
402
|
|
|
403
|
+
// StyleX build requirement. Swizzled components ship raw StyleX source,
|
|
404
|
+
// which needs a build-time StyleX compiler in the consumer's app to
|
|
405
|
+
// produce atomic CSS. Without it the component compiles but renders
|
|
406
|
+
// unstyled, with no error — a confusing silent failure, so call it out.
|
|
407
|
+
if (usesStyleX) {
|
|
408
|
+
humanLog(
|
|
409
|
+
'⚠ These components use StyleX and require a StyleX compiler in your build.',
|
|
410
|
+
);
|
|
411
|
+
humanLog(
|
|
412
|
+
' Without one they render unstyled (no error). See setup per framework:',
|
|
413
|
+
);
|
|
414
|
+
humanLog(` ${getRunPrefix()} astryx docs styling`);
|
|
415
|
+
humanLog(
|
|
416
|
+
' Next.js note: the StyleX Babel plugin disables SWC and breaks next/font —',
|
|
417
|
+
);
|
|
418
|
+
humanLog(
|
|
419
|
+
' use an SWC-based StyleX transform instead (covered in the guide).',
|
|
420
|
+
);
|
|
421
|
+
humanLog('');
|
|
422
|
+
}
|
|
423
|
+
|
|
390
424
|
// Maintainer feedback note. If we couldn't swizzle cleanly, the team
|
|
391
425
|
// wants to know — point users at the issue tracker. Skipped when the
|
|
392
426
|
// owning package ships no issues URL.
|
|
@@ -277,3 +277,70 @@ describe('swizzle — ambiguous ownership', () => {
|
|
|
277
277
|
expect(out).toContain(`from '@astryxdesign/core/theme'`);
|
|
278
278
|
});
|
|
279
279
|
});
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Build a fake @astryxdesign/core with a component that imports StyleX directly
|
|
283
|
+
* (so the swizzle StyleX-build note should fire) and one that doesn't.
|
|
284
|
+
*/
|
|
285
|
+
function buildStyleXCore(project) {
|
|
286
|
+
const core = path.join(project, 'node_modules', '@astryxdesign', 'core');
|
|
287
|
+
// StyleX component.
|
|
288
|
+
const styledDir = path.join(core, 'src', 'Styled');
|
|
289
|
+
fs.mkdirSync(styledDir, {recursive: true});
|
|
290
|
+
fs.writeFileSync(
|
|
291
|
+
path.join(core, 'package.json'),
|
|
292
|
+
'{"name":"@astryxdesign/core","version":"0.0.13"}',
|
|
293
|
+
);
|
|
294
|
+
fs.writeFileSync(
|
|
295
|
+
path.join(styledDir, 'Styled.tsx'),
|
|
296
|
+
[
|
|
297
|
+
`import * as stylex from '@stylexjs/stylex';`,
|
|
298
|
+
`const styles = stylex.create({base: {color: 'red'}});`,
|
|
299
|
+
`export const Styled = () => null;`,
|
|
300
|
+
'',
|
|
301
|
+
].join('\n'),
|
|
302
|
+
);
|
|
303
|
+
// Plain component (no StyleX).
|
|
304
|
+
const plainDir = path.join(core, 'src', 'Plain');
|
|
305
|
+
fs.mkdirSync(plainDir, {recursive: true});
|
|
306
|
+
fs.writeFileSync(
|
|
307
|
+
path.join(plainDir, 'Plain.tsx'),
|
|
308
|
+
`export const Plain = () => null;\n`,
|
|
309
|
+
);
|
|
310
|
+
return core;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
describe('swizzle — StyleX build setup note (#3373)', () => {
|
|
314
|
+
it('reports usesStyleX and prints a setup note for StyleX components', () => {
|
|
315
|
+
buildStyleXCore(project);
|
|
316
|
+
writeProjectPackageJson(project);
|
|
317
|
+
|
|
318
|
+
// JSON payload carries the machine-readable flag.
|
|
319
|
+
const jsonResult = runCli(['--json', 'swizzle', 'Styled', '-f'], project);
|
|
320
|
+
expect(jsonResult.code).toBe(0);
|
|
321
|
+
const env = JSON.parse(jsonResult.stdout);
|
|
322
|
+
expect(env.data.usesStyleX).toBe(true);
|
|
323
|
+
|
|
324
|
+
// Human output surfaces the compiler requirement + Next.js caveat.
|
|
325
|
+
const humanResult = runCli(['swizzle', 'Styled', '-f'], project);
|
|
326
|
+
expect(humanResult.code).toBe(0);
|
|
327
|
+
expect(humanResult.stdout).toMatch(/StyleX compiler/i);
|
|
328
|
+
expect(humanResult.stdout).toMatch(/unstyled/i);
|
|
329
|
+
expect(humanResult.stdout).toMatch(/next\/font/i);
|
|
330
|
+
expect(humanResult.stdout).toMatch(/astryx docs styling/);
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
it('does not print the StyleX note for components without StyleX', () => {
|
|
334
|
+
buildStyleXCore(project);
|
|
335
|
+
writeProjectPackageJson(project);
|
|
336
|
+
|
|
337
|
+
const jsonResult = runCli(['--json', 'swizzle', 'Plain', '-f'], project);
|
|
338
|
+
expect(jsonResult.code).toBe(0);
|
|
339
|
+
const env = JSON.parse(jsonResult.stdout);
|
|
340
|
+
expect(env.data.usesStyleX).toBe(false);
|
|
341
|
+
|
|
342
|
+
const humanResult = runCli(['swizzle', 'Plain', '-f'], project);
|
|
343
|
+
expect(humanResult.code).toBe(0);
|
|
344
|
+
expect(humanResult.stdout).not.toMatch(/StyleX compiler/i);
|
|
345
|
+
});
|
|
346
|
+
});
|
|
@@ -7,7 +7,7 @@ export const doc = {
|
|
|
7
7
|
name: 'Code — Terminal',
|
|
8
8
|
displayName: 'Code — Terminal',
|
|
9
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
|
|
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
11
|
isReady: true,
|
|
12
12
|
aspectRatio: 16 / 9,
|
|
13
13
|
componentsUsed: ['CodeBlock', 'SyntaxTheme'],
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
}
|
|
@@ -3,66 +3,45 @@
|
|
|
3
3
|
'use client';
|
|
4
4
|
|
|
5
5
|
import {useMemo} from 'react';
|
|
6
|
-
import {
|
|
7
|
-
CommandPalette,
|
|
8
|
-
CommandPaletteList,
|
|
9
|
-
CommandPaletteGroup,
|
|
10
|
-
CommandPaletteItem,
|
|
11
|
-
} from '@astryxdesign/core/CommandPalette';
|
|
6
|
+
import {CommandPalette} from '@astryxdesign/core/CommandPalette';
|
|
12
7
|
import {createStaticSource} from '@astryxdesign/core/Typeahead';
|
|
13
|
-
import {Stack} from '@astryxdesign/core/Layout';
|
|
14
|
-
import {Text} from '@astryxdesign/core/Text';
|
|
15
8
|
|
|
16
9
|
export default function CommandPaletteGroupShowcase() {
|
|
17
10
|
const source = useMemo(
|
|
18
11
|
() =>
|
|
19
12
|
createStaticSource([
|
|
20
|
-
{
|
|
13
|
+
{
|
|
14
|
+
id: 'index',
|
|
15
|
+
label: 'index.tsx',
|
|
16
|
+
auxiliaryData: {group: 'Recent Files'},
|
|
17
|
+
},
|
|
21
18
|
{id: 'app', label: 'App.tsx', auxiliaryData: {group: 'Recent Files'}},
|
|
22
|
-
{
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
{
|
|
20
|
+
id: 'settings',
|
|
21
|
+
label: 'Open Settings',
|
|
22
|
+
auxiliaryData: {group: 'Commands'},
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: 'terminal',
|
|
26
|
+
label: 'Toggle Terminal',
|
|
27
|
+
auxiliaryData: {group: 'Commands'},
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: 'theme',
|
|
31
|
+
label: 'Color Theme',
|
|
32
|
+
auxiliaryData: {group: 'Preferences'},
|
|
33
|
+
},
|
|
25
34
|
{id: 'font', label: 'Font Size', auxiliaryData: {group: 'Preferences'}},
|
|
26
35
|
]),
|
|
27
36
|
[],
|
|
28
37
|
);
|
|
29
38
|
|
|
30
39
|
return (
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
isOpen
|
|
38
|
-
isInline
|
|
39
|
-
onOpenChange={() => {}}
|
|
40
|
-
searchSource={source}
|
|
41
|
-
/>
|
|
42
|
-
</Stack>
|
|
43
|
-
<Stack direction="vertical" gap={1}>
|
|
44
|
-
<Text type="supporting" color="secondary">
|
|
45
|
-
Composed form (CommandPaletteGroup + CommandPaletteItem)
|
|
46
|
-
</Text>
|
|
47
|
-
<CommandPaletteList>
|
|
48
|
-
<CommandPaletteGroup heading="Navigation">
|
|
49
|
-
<CommandPaletteItem value="home" onSelect={() => {}}>
|
|
50
|
-
Home
|
|
51
|
-
</CommandPaletteItem>
|
|
52
|
-
<CommandPaletteItem value="dashboard" onSelect={() => {}}>
|
|
53
|
-
Dashboard
|
|
54
|
-
</CommandPaletteItem>
|
|
55
|
-
</CommandPaletteGroup>
|
|
56
|
-
<CommandPaletteGroup heading="Actions">
|
|
57
|
-
<CommandPaletteItem value="new-file" onSelect={() => {}}>
|
|
58
|
-
New File
|
|
59
|
-
</CommandPaletteItem>
|
|
60
|
-
<CommandPaletteItem value="save" onSelect={() => {}}>
|
|
61
|
-
Save All
|
|
62
|
-
</CommandPaletteItem>
|
|
63
|
-
</CommandPaletteGroup>
|
|
64
|
-
</CommandPaletteList>
|
|
65
|
-
</Stack>
|
|
66
|
-
</Stack>
|
|
40
|
+
<CommandPalette
|
|
41
|
+
isOpen
|
|
42
|
+
isInline
|
|
43
|
+
onOpenChange={() => {}}
|
|
44
|
+
searchSource={source}
|
|
45
|
+
/>
|
|
67
46
|
);
|
|
68
47
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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: 'CommandPaletteInput',
|
|
7
|
+
name: 'CommandPaletteInput — With End Content',
|
|
8
|
+
displayName: 'CommandPaletteInput — With End Content',
|
|
9
|
+
description:
|
|
10
|
+
'Custom placeholder and a keyboard shortcut badge in the trailing slot via endContent.',
|
|
11
|
+
isReady: true,
|
|
12
|
+
isShowcase: false,
|
|
13
|
+
aspectRatio: 4 / 3,
|
|
14
|
+
componentsUsed: ['CommandPalette', 'CommandPaletteInput', 'Kbd'],
|
|
15
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
import {useMemo} from 'react';
|
|
6
|
+
import {
|
|
7
|
+
CommandPalette,
|
|
8
|
+
CommandPaletteInput,
|
|
9
|
+
} from '@astryxdesign/core/CommandPalette';
|
|
10
|
+
import {Kbd} from '@astryxdesign/core/Kbd';
|
|
11
|
+
import {createStaticSource} from '@astryxdesign/core/Typeahead';
|
|
12
|
+
|
|
13
|
+
export default function CommandPaletteInputBasic() {
|
|
14
|
+
const source = useMemo(
|
|
15
|
+
() =>
|
|
16
|
+
createStaticSource([
|
|
17
|
+
{id: 'home', label: 'Home'},
|
|
18
|
+
{id: 'settings', label: 'Settings'},
|
|
19
|
+
{id: 'profile', label: 'Profile'},
|
|
20
|
+
{id: 'help', label: 'Help'},
|
|
21
|
+
]),
|
|
22
|
+
[],
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<CommandPalette
|
|
27
|
+
isOpen
|
|
28
|
+
isInline
|
|
29
|
+
onOpenChange={() => {}}
|
|
30
|
+
searchSource={source}
|
|
31
|
+
input={
|
|
32
|
+
<CommandPaletteInput
|
|
33
|
+
placeholder="Search commands, files, or actions..."
|
|
34
|
+
endContent={<Kbd keys="mod+k" />}
|
|
35
|
+
/>
|
|
36
|
+
}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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: 'CommandPaletteInput',
|
|
7
|
+
name: 'CommandPaletteInput',
|
|
8
|
+
displayName: 'Command Palette Input',
|
|
9
|
+
description:
|
|
10
|
+
'Command palette search input with a custom placeholder and a keyboard shortcut hint in the endContent slot.',
|
|
11
|
+
isReady: true,
|
|
12
|
+
isShowcase: true,
|
|
13
|
+
aspectRatio: 4 / 3,
|
|
14
|
+
componentsUsed: ['CommandPalette', 'CommandPaletteInput', 'Kbd'],
|
|
15
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
import {useMemo} from 'react';
|
|
6
|
+
import {
|
|
7
|
+
CommandPalette,
|
|
8
|
+
CommandPaletteInput,
|
|
9
|
+
} from '@astryxdesign/core/CommandPalette';
|
|
10
|
+
import {Kbd} from '@astryxdesign/core/Kbd';
|
|
11
|
+
import {createStaticSource} from '@astryxdesign/core/Typeahead';
|
|
12
|
+
|
|
13
|
+
export default function CommandPaletteInputShowcase() {
|
|
14
|
+
const source = useMemo(
|
|
15
|
+
() =>
|
|
16
|
+
createStaticSource([
|
|
17
|
+
{id: 'home', label: 'Home'},
|
|
18
|
+
{id: 'settings', label: 'Settings'},
|
|
19
|
+
{id: 'profile', label: 'Profile'},
|
|
20
|
+
{id: 'help', label: 'Help'},
|
|
21
|
+
]),
|
|
22
|
+
[],
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<CommandPalette
|
|
27
|
+
isOpen
|
|
28
|
+
isInline
|
|
29
|
+
onOpenChange={() => {}}
|
|
30
|
+
searchSource={source}
|
|
31
|
+
input={
|
|
32
|
+
<CommandPaletteInput
|
|
33
|
+
placeholder="Search commands, files, or actions..."
|
|
34
|
+
endContent={<Kbd keys="mod+k" />}
|
|
35
|
+
/>
|
|
36
|
+
}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
}
|