@astryxdesign/cli 0.1.6-canary.fec872b → 0.1.6
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/package.json +9 -13
- package/src/api/template.mjs +28 -104
- package/src/api/validate-integration.mjs +8 -0
- package/src/codemods/__tests__/registry.test.mjs +0 -1
- package/src/codemods/registry.mjs +0 -1
- package/src/config.mjs +14 -5
- package/src/integration.mjs +15 -4
- package/src/lib/component-discovery.mjs +5 -15
- package/src/lib/component-format.mjs +13 -45
- package/src/lib/component-format.test.mjs +1 -95
- package/src/lib/component-loader.mjs +2 -104
- package/src/lib/config-schema.mjs +30 -0
- package/src/lib/hook-format.mjs +3 -8
- package/src/lib/xle/registry.mjs +5 -0
- package/src/template.mjs +67 -9
- package/src/types/config.d.ts +66 -11
- package/src/types/integration.d.ts +18 -7
- package/src/types/template-api.d.ts +50 -14
- package/templates/blocks/components/Avatar/AvatarGroup.tsx +7 -5
- package/templates/blocks/components/Avatar/AvatarShowcase.tsx +6 -4
- package/templates/blocks/components/Avatar/AvatarUserCard.tsx +5 -3
- package/templates/blocks/components/Avatar/AvatarWithImage.tsx +6 -8
- package/templates/blocks/components/Avatar/AvatarWithStatus.tsx +5 -3
- package/templates/blocks/components/ChatComposerInput/ChatComposerInputControlledInput.tsx +1 -1
- package/templates/blocks/components/ChatComposerInput/ChatComposerInputDisabled.tsx +1 -1
- package/templates/blocks/components/ChatComposerInput/ChatComposerInputMentionTrigger.tsx +1 -1
- package/templates/blocks/components/ChatComposerInput/ChatComposerInputMultipleTriggers.tsx +1 -1
- package/templates/blocks/components/ChatComposerInput/ChatComposerInputShowcase.tsx +1 -1
- package/templates/blocks/components/ChatComposerInput/ChatComposerInputSlashCommands.tsx +1 -1
- package/templates/pages/ide/page.tsx +41 -35
- package/templates/pages/theme-showcase/page.tsx +7 -7
- package/templates/themes/neutral/neutralTheme.ts +32 -63
- package/docs/integration-authoring.md +0 -105
- package/docs/internationalization.doc.mjs +0 -243
- package/src/api/integration-block-exports.test.mjs +0 -240
- package/src/api/template-suffix.test.mjs +0 -246
- package/src/codemods/transforms/v0.1.7/__tests__/migrate-table-tableprops-to-direct-props.test.mjs +0 -120
- package/src/codemods/transforms/v0.1.7/index.mjs +0 -19
- package/src/codemods/transforms/v0.1.7/migrate-table-tableprops-to-direct-props.mjs +0 -188
- package/src/doc.mjs +0 -27
- package/src/doc.test.mjs +0 -383
- package/src/lib/component-discovery.importpath.test.mjs +0 -59
- package/src/lib/componentDocOverlay.test.mjs +0 -111
- package/src/schemas/doc-schema.mjs +0 -226
- package/src/schemas/template-schema.mjs +0 -47
- package/src/types/doc.d.ts +0 -23
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenLiveRegion.doc.mjs +0 -14
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenLiveRegion.tsx +0 -41
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenShowcase.doc.mjs +0 -13
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenShowcase.tsx +0 -78
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenStructuralHeading.doc.mjs +0 -14
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenStructuralHeading.tsx +0 -38
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenSupplementaryContext.doc.mjs +0 -14
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenSupplementaryContext.tsx +0 -47
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file Guards translated/compressed component docs against dropping props.
|
|
5
|
-
* @input packages/core/src/{Name}/{Name}.doc.mjs — its `docs`, `docsZh`, `docsDense`.
|
|
6
|
-
* @output Vitest failures naming every prop that exists in `docs` but vanishes
|
|
7
|
-
* from a translated view.
|
|
8
|
-
* @position Regression gate for component-loader.mjs.
|
|
9
|
-
*
|
|
10
|
-
* A `docsZh` that carries its own `props` array used to REPLACE the base doc
|
|
11
|
-
* wholesale, so any prop the translation had not caught up with simply ceased
|
|
12
|
-
* to exist: `astryx component Button --zh` silently omitted `isInterruptible`
|
|
13
|
-
* and `isIconOnly`. A reader of the translated docs cannot discover a prop that
|
|
14
|
-
* is not there, and CLAUDE.md tells every AI agent to read these docs.
|
|
15
|
-
*
|
|
16
|
-
* Translations are now an overlay: a prop the translation does not cover falls
|
|
17
|
-
* back to its English entry rather than disappearing. Same principle as the
|
|
18
|
-
* reference-doc overlays in #2182 — an overlay covering a subset must not
|
|
19
|
-
* destroy what it does not cover.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
import {describe, it, expect} from 'vitest';
|
|
23
|
-
import * as fs from 'node:fs';
|
|
24
|
-
import * as path from 'node:path';
|
|
25
|
-
import {pathToFileURL} from 'node:url';
|
|
26
|
-
import {loadDocs} from './component-loader.mjs';
|
|
27
|
-
|
|
28
|
-
const CORE_SRC = path.join(
|
|
29
|
-
import.meta.dirname,
|
|
30
|
-
'..',
|
|
31
|
-
'..',
|
|
32
|
-
'..',
|
|
33
|
-
'core',
|
|
34
|
-
'src',
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
/** Component dirs that ship a doc file. */
|
|
38
|
-
function componentDocs() {
|
|
39
|
-
const out = [];
|
|
40
|
-
for (const dir of fs.readdirSync(CORE_SRC)) {
|
|
41
|
-
const docPath = path.join(CORE_SRC, dir, `${dir}.doc.mjs`);
|
|
42
|
-
if (!fs.existsSync(docPath)) continue;
|
|
43
|
-
if (!fs.readdirSync(path.join(CORE_SRC, dir)).includes(`${dir}.doc.mjs`)) {
|
|
44
|
-
continue; // case-exact match only
|
|
45
|
-
}
|
|
46
|
-
out.push({name: dir, docPath});
|
|
47
|
-
}
|
|
48
|
-
return out;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** Prop names on a doc, across single- and multi-component shapes. */
|
|
52
|
-
function propNames(doc) {
|
|
53
|
-
const names = new Set();
|
|
54
|
-
for (const p of doc?.props ?? []) names.add(p.name);
|
|
55
|
-
for (const c of doc?.components ?? []) {
|
|
56
|
-
for (const p of c.props ?? []) names.add(`${c.name ?? '?'}.${p.name}`);
|
|
57
|
-
}
|
|
58
|
-
return names;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
describe('translated component docs never drop a prop', () => {
|
|
62
|
-
const comps = componentDocs();
|
|
63
|
-
|
|
64
|
-
it('finds component docs to check', () => {
|
|
65
|
-
expect(comps.length).toBeGreaterThan(0);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
for (const {name, docPath} of comps) {
|
|
69
|
-
for (const locale of ['zh', 'dense']) {
|
|
70
|
-
it(`${name} --${locale}: documents every prop the English doc documents`, async () => {
|
|
71
|
-
const mod = await import(pathToFileURL(docPath).href);
|
|
72
|
-
const key = locale === 'zh' ? 'docsZh' : 'docsDense';
|
|
73
|
-
if (!mod[key]) return; // no overlay, nothing to drift
|
|
74
|
-
|
|
75
|
-
const english = propNames(mod.docs);
|
|
76
|
-
const translated = propNames(
|
|
77
|
-
await loadDocs(docPath, {[locale]: true}),
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
const dropped = [...english].filter(p => !translated.has(p));
|
|
81
|
-
expect(
|
|
82
|
-
dropped,
|
|
83
|
-
`${name}.doc.mjs ${key} drops ${dropped.length} prop(s) from the ` +
|
|
84
|
-
`--${locale} view: ${dropped.join(', ')}. A reader of the ` +
|
|
85
|
-
`translated docs cannot discover a prop that is not there. An ` +
|
|
86
|
-
`untranslated prop must fall back to its English entry, not vanish.`,
|
|
87
|
-
).toEqual([]);
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
describe('the reported symptom', () => {
|
|
94
|
-
it('astryx component Button --zh still lists isInterruptible and isIconOnly', async () => {
|
|
95
|
-
const docPath = path.join(CORE_SRC, 'Button', 'Button.doc.mjs');
|
|
96
|
-
const zh = await loadDocs(docPath, {zh: true});
|
|
97
|
-
const names = propNames(zh);
|
|
98
|
-
expect(names.has('isInterruptible')).toBe(true);
|
|
99
|
-
expect(names.has('isIconOnly')).toBe(true);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('keeps the translated descriptions it does have', async () => {
|
|
103
|
-
const docPath = path.join(CORE_SRC, 'Button', 'Button.doc.mjs');
|
|
104
|
-
const mod = await import(pathToFileURL(docPath).href);
|
|
105
|
-
const zh = await loadDocs(docPath, {zh: true});
|
|
106
|
-
|
|
107
|
-
const translated = mod.docsZh.props.find(p => p.name === 'variant');
|
|
108
|
-
const merged = zh.props.find(p => p.name === 'variant');
|
|
109
|
-
expect(merged.description).toBe(translated.description);
|
|
110
|
-
});
|
|
111
|
-
});
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file Doc load-boundary schemas.
|
|
5
|
-
*
|
|
6
|
-
* The Zod schemas doc discovery runs a loaded doc value through (see
|
|
7
|
-
* `loadComponentDoc`). {@link ComponentDocSchema} accepts BOTH the new stamped
|
|
8
|
-
* formats and the legacy loose `export const docs = {...}` shape, so existing
|
|
9
|
-
* docs keep loading unchanged. Kept free of any `@astryxdesign/core` import so
|
|
10
|
-
* the hot path that loads them (doc discovery, `astryx init`) does not require
|
|
11
|
-
* core's built `dist/`. The authoring factories live in
|
|
12
|
-
* `@astryxdesign/core/authoring` and are re-exported from `../doc.mjs` for the
|
|
13
|
-
* public `@astryxdesign/cli/doc` surface.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import {z} from 'zod';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* A single documented prop. Mirrors `PropDoc` from
|
|
20
|
-
* `@astryxdesign/core/docs-types`. Only `name`, `type`, and `description` are
|
|
21
|
-
* required; everything else is optional. Extra fields (e.g. `slotElements`)
|
|
22
|
-
* pass through so the schema does not have to track every evolution of the
|
|
23
|
-
* rich playground/element surface.
|
|
24
|
-
*/
|
|
25
|
-
const PropSchema = z
|
|
26
|
-
.object({
|
|
27
|
-
name: z.string().min(1, 'prop name is required'),
|
|
28
|
-
type: z.string().min(1, 'prop type is required'),
|
|
29
|
-
description: z.string(),
|
|
30
|
-
default: z.string().optional(),
|
|
31
|
-
required: z.boolean().optional(),
|
|
32
|
-
})
|
|
33
|
-
.passthrough();
|
|
34
|
-
|
|
35
|
-
/** A single documented function/hook parameter (mirrors `HookParamDoc`). */
|
|
36
|
-
const ParamSchema = z
|
|
37
|
-
.object({
|
|
38
|
-
name: z.string().min(1, 'param name is required'),
|
|
39
|
-
type: z.string().min(1, 'param type is required'),
|
|
40
|
-
description: z.string(),
|
|
41
|
-
default: z.string().optional(),
|
|
42
|
-
required: z.boolean().optional(),
|
|
43
|
-
})
|
|
44
|
-
.passthrough();
|
|
45
|
-
|
|
46
|
-
/** A single documented function/hook return field (mirrors `HookReturnDoc`). */
|
|
47
|
-
const ReturnSchema = z
|
|
48
|
-
.object({
|
|
49
|
-
name: z.string().min(1, 'return name is required'),
|
|
50
|
-
type: z.string().min(1, 'return type is required'),
|
|
51
|
-
description: z.string(),
|
|
52
|
-
})
|
|
53
|
-
.passthrough();
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Fields shared by every doc kind. Deliberately permissive on the rich blobs
|
|
57
|
-
* (usage/theming/playground) — those are large and still evolving, so they are
|
|
58
|
-
* `z.unknown()` passthrough rather than enumerated.
|
|
59
|
-
*
|
|
60
|
-
* `group` vs `parent` are distinct concepts and intentionally separate fields:
|
|
61
|
-
* - `group` is a FLAT sidebar bucket label. Many docs can share a group; it
|
|
62
|
-
* is not an inheritance key.
|
|
63
|
-
* - `parent` is a DIRECTED inheritance/composition pointer — a doc naming the
|
|
64
|
-
* doc it belongs to (e.g. a sub-component naming its parent component). The
|
|
65
|
-
* legacy `subComponentOf` field is a synonym; both map to the same concept.
|
|
66
|
-
*
|
|
67
|
-
* `relatedDocs` is a single flat curated cross-reference list. It replaces the
|
|
68
|
-
* legacy split `relatedComponents` + `relatedHooks`; a downstream reader can
|
|
69
|
-
* merge the legacy pair into it.
|
|
70
|
-
*/
|
|
71
|
-
const BaseDocFields = {
|
|
72
|
-
/** Name of the documented unit, without any prefix. Required. */
|
|
73
|
-
name: z.string().min(1, 'name is required'),
|
|
74
|
-
/** Human-readable display name for gallery/sidebar. */
|
|
75
|
-
displayName: z.string().optional(),
|
|
76
|
-
/** One-line/short description. */
|
|
77
|
-
description: z.string().optional(),
|
|
78
|
-
/** Usage documentation (description, best practices, anatomy, slotElements). */
|
|
79
|
-
usage: z.unknown().optional(),
|
|
80
|
-
/** Flat sidebar grouping label (not an inheritance key). */
|
|
81
|
-
group: z.string().optional(),
|
|
82
|
-
/** Overview-page functional category. */
|
|
83
|
-
category: z.string().optional(),
|
|
84
|
-
/** CLI fuzzy-search keywords. */
|
|
85
|
-
keywords: z.array(z.string()).optional(),
|
|
86
|
-
/** Directed inheritance/composition pointer to the doc this belongs to. */
|
|
87
|
-
parent: z.string().optional(),
|
|
88
|
-
/** Flat curated cross-reference list of related doc names. */
|
|
89
|
-
relatedDocs: z.array(z.string()).optional(),
|
|
90
|
-
/** Hide the whole doc from human-facing UI (stays importable/discoverable). */
|
|
91
|
-
hidden: z.boolean().optional(),
|
|
92
|
-
/** Exclude from the categorized overview page (kept in sidebar/CLI). */
|
|
93
|
-
isHiddenFromOverview: z.boolean().optional(),
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* New-format schema for a stamped component doc (`type: 'component'`). The
|
|
98
|
-
* top-level component keys are enumerated, but nested blobs stay loose so real
|
|
99
|
-
* docs are not rejected. `.passthrough()` keeps unknown top-level fields
|
|
100
|
-
* (translations, element descriptors, ...) flowing through.
|
|
101
|
-
*/
|
|
102
|
-
export const ComponentDocKindSchema = z
|
|
103
|
-
.object({
|
|
104
|
-
...BaseDocFields,
|
|
105
|
-
type: z.literal('component'),
|
|
106
|
-
props: z.array(PropSchema),
|
|
107
|
-
theming: z.unknown().optional(),
|
|
108
|
-
playground: z.unknown().optional(),
|
|
109
|
-
examples: z.array(z.unknown()).optional(),
|
|
110
|
-
})
|
|
111
|
-
.passthrough();
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* New-format schema for a stamped function doc (`type: 'function'`). Covers any
|
|
115
|
-
* function, including hooks: an inputs (`params`) + outputs (`returns`) surface.
|
|
116
|
-
*/
|
|
117
|
-
export const FunctionDocKindSchema = z
|
|
118
|
-
.object({
|
|
119
|
-
...BaseDocFields,
|
|
120
|
-
type: z.literal('function'),
|
|
121
|
-
params: z.array(ParamSchema),
|
|
122
|
-
returns: z.array(ReturnSchema),
|
|
123
|
-
})
|
|
124
|
-
.passthrough();
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* New-format schema for a stamped generic doc (`type: 'generic'`) — reference
|
|
128
|
-
* and topic docs. Just the shared base plus the discriminant.
|
|
129
|
-
*/
|
|
130
|
-
export const GenericDocKindSchema = z
|
|
131
|
-
.object({
|
|
132
|
-
...BaseDocFields,
|
|
133
|
-
type: z.literal('generic'),
|
|
134
|
-
})
|
|
135
|
-
.passthrough();
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* The stamped-doc contract: one of the three new per-kind schemas, discriminated
|
|
139
|
-
* by the injected `type`. Used when a loaded doc carries a `type` field.
|
|
140
|
-
*/
|
|
141
|
-
export const StampedDocSchema = z.discriminatedUnion('type', [
|
|
142
|
-
ComponentDocKindSchema,
|
|
143
|
-
FunctionDocKindSchema,
|
|
144
|
-
GenericDocKindSchema,
|
|
145
|
-
]);
|
|
146
|
-
|
|
147
|
-
// ── Legacy loose format (unchanged, kept for back-compat) ─────────────
|
|
148
|
-
//
|
|
149
|
-
// The pre-factory docs are authored as a loose, untyped object with no `type`
|
|
150
|
-
// discriminant and validated by shape. Enumerated top-level fields observed
|
|
151
|
-
// across the existing loose docs:
|
|
152
|
-
// name, displayName, description, group, category, keywords,
|
|
153
|
-
// isHiddenFromOverview, hidden, hiddenComponents, usage, props, components,
|
|
154
|
-
// subComponentOf, playground, theming, examples, params, returns,
|
|
155
|
-
// relatedComponents, relatedHooks, relatedDocs, parent, importPath.
|
|
156
|
-
|
|
157
|
-
const LegacyBaseDocSchema = z.object({
|
|
158
|
-
name: z.string().min(1, 'name is required'),
|
|
159
|
-
displayName: z.string().optional(),
|
|
160
|
-
description: z.string().optional(),
|
|
161
|
-
group: z.string().optional(),
|
|
162
|
-
category: z.string().optional(),
|
|
163
|
-
keywords: z.array(z.string()).optional(),
|
|
164
|
-
isHiddenFromOverview: z.boolean().optional(),
|
|
165
|
-
hidden: z.boolean().optional(),
|
|
166
|
-
hiddenComponents: z.array(z.string()).optional(),
|
|
167
|
-
usage: z.unknown().optional(),
|
|
168
|
-
playground: z.unknown().optional(),
|
|
169
|
-
theming: z.unknown().optional(),
|
|
170
|
-
examples: z.array(z.unknown()).optional(),
|
|
171
|
-
showcase: z.unknown().optional(),
|
|
172
|
-
// `parent` and legacy `subComponentOf` are synonyms; both accepted here so a
|
|
173
|
-
// parent-based doc that omits a stamped `type` still validates.
|
|
174
|
-
parent: z.string().optional(),
|
|
175
|
-
relatedDocs: z.array(z.string()).optional(),
|
|
176
|
-
relatedComponents: z.array(z.string()).optional(),
|
|
177
|
-
relatedHooks: z.array(z.string()).optional(),
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
/** Legacy: directory exporting a single primary component (props inline). */
|
|
181
|
-
const LegacySingleComponentDocSchema = LegacyBaseDocSchema.extend({
|
|
182
|
-
props: z.array(PropSchema),
|
|
183
|
-
}).passthrough();
|
|
184
|
-
|
|
185
|
-
/** Legacy: directory exporting multiple components (props on each entry). */
|
|
186
|
-
const LegacyMultiComponentDocSchema = LegacyBaseDocSchema.extend({
|
|
187
|
-
components: z.array(z.unknown()),
|
|
188
|
-
}).passthrough();
|
|
189
|
-
|
|
190
|
-
/** Legacy: a standalone hook doc — inputs (`params`) + outputs (`returns`). */
|
|
191
|
-
const LegacyHookDocSchema = LegacyBaseDocSchema.extend({
|
|
192
|
-
params: z.array(ParamSchema),
|
|
193
|
-
returns: z.array(ReturnSchema),
|
|
194
|
-
}).passthrough();
|
|
195
|
-
|
|
196
|
-
/** Legacy: a sub-component doc parented via `subComponentOf`. */
|
|
197
|
-
const LegacySubComponentDocSchema = LegacyBaseDocSchema.extend({
|
|
198
|
-
subComponentOf: z.string().min(1, 'subComponentOf is required'),
|
|
199
|
-
description: z.string(),
|
|
200
|
-
props: z.array(PropSchema),
|
|
201
|
-
}).passthrough();
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* The permissive legacy union. `subComponentOf` is listed first so a doc that
|
|
205
|
-
* carries both `subComponentOf` and `props` is validated as a sub-component
|
|
206
|
-
* (the more specific shape); hook (`params`/`returns`) before multi/single.
|
|
207
|
-
*/
|
|
208
|
-
export const LegacyDocSchema = z.union([
|
|
209
|
-
LegacySubComponentDocSchema,
|
|
210
|
-
LegacyHookDocSchema,
|
|
211
|
-
LegacyMultiComponentDocSchema,
|
|
212
|
-
LegacySingleComponentDocSchema,
|
|
213
|
-
]);
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* The LOAD-boundary contract for a doc. Handles BOTH formats:
|
|
217
|
-
* - NEW: a stamped doc (`type: 'component' | 'function' | 'generic'`,
|
|
218
|
-
* produced by the factories) is validated against the matching per-kind
|
|
219
|
-
* schema in {@link StampedDocSchema}.
|
|
220
|
-
* - OLD: a loose, unstamped doc is validated against the permissive
|
|
221
|
-
* {@link LegacyDocSchema} union (the three legacy shapes + standalone hook).
|
|
222
|
-
*
|
|
223
|
-
* Discovery validates the SHAPE, not "was it made by the factory". Both formats
|
|
224
|
-
* normalize into the same internal shape consumers already expect.
|
|
225
|
-
*/
|
|
226
|
-
export const ComponentDocSchema = z.union([StampedDocSchema, LegacyDocSchema]);
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file Template load-boundary schemas.
|
|
5
|
-
*
|
|
6
|
-
* The Zod schemas that integration template discovery runs a module's default
|
|
7
|
-
* export through (see `loadModuleWithSchema`). Kept free of any
|
|
8
|
-
* `@astryxdesign/core` import so the hot path that loads them (template
|
|
9
|
-
* discovery, `astryx init`) does not require core's built `dist/`. The
|
|
10
|
-
* authoring factories live in `@astryxdesign/core/authoring` and are re-exported
|
|
11
|
-
* from `../template.mjs` for the public `@astryxdesign/cli/template` surface.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import {z} from 'zod';
|
|
15
|
-
|
|
16
|
-
const PreviewSchema = z
|
|
17
|
-
.object({
|
|
18
|
-
image: z.string().optional(),
|
|
19
|
-
aspectRatio: z.string().optional(),
|
|
20
|
-
})
|
|
21
|
-
.strict();
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Shared authored-template shape. `type` is injected by the create* helpers,
|
|
25
|
-
* so authors never write it. Inline source/sourceFile are intentionally NOT
|
|
26
|
-
* part of v1 — a template's source is the required same-stem sibling file.
|
|
27
|
-
* Exported so integration template discovery can validate the stamped result.
|
|
28
|
-
*/
|
|
29
|
-
export const BaseTemplateSchema = z
|
|
30
|
-
.object({
|
|
31
|
-
name: z.string().min(1, 'name is required'),
|
|
32
|
-
description: z.string().min(1, 'description is required'),
|
|
33
|
-
category: z.string().optional(),
|
|
34
|
-
componentsUsed: z.array(z.string()).optional(),
|
|
35
|
-
preview: PreviewSchema.optional(),
|
|
36
|
-
})
|
|
37
|
-
.strict();
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* The metadata envelope integration template discovery validates: a stamped
|
|
41
|
-
* template doc. This is the LOAD-boundary contract — a hand-written plain
|
|
42
|
-
* object that matches this shape is accepted (discovery does not check "was it
|
|
43
|
-
* made by the factory", only the shape).
|
|
44
|
-
*/
|
|
45
|
-
export const TemplateEnvelopeSchema = BaseTemplateSchema.extend({
|
|
46
|
-
type: z.enum(['page', 'block']),
|
|
47
|
-
});
|
package/src/types/doc.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The doc-authoring surface moved to `@astryxdesign/core/authoring`. Re-exported
|
|
5
|
-
* here so existing `@astryxdesign/cli/doc` type imports keep resolving. The Zod
|
|
6
|
-
* load-boundary schemas remain in the CLI (see `src/doc.mjs`).
|
|
7
|
-
*/
|
|
8
|
-
export type {
|
|
9
|
-
AstryxBaseDocInput,
|
|
10
|
-
AstryxPropInput,
|
|
11
|
-
AstryxParamInput,
|
|
12
|
-
AstryxReturnInput,
|
|
13
|
-
AstryxComponentDocInput,
|
|
14
|
-
AstryxFunctionDocInput,
|
|
15
|
-
AstryxGenericDocInput,
|
|
16
|
-
AstryxComponentDoc,
|
|
17
|
-
} from '@astryxdesign/core/authoring';
|
|
18
|
-
|
|
19
|
-
export {
|
|
20
|
-
createComponentDoc,
|
|
21
|
-
createFunctionDoc,
|
|
22
|
-
createDoc,
|
|
23
|
-
} from '@astryxdesign/core/authoring';
|
|
@@ -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: 'VisuallyHidden',
|
|
7
|
-
name: 'VisuallyHidden — Live Region',
|
|
8
|
-
displayName: 'VisuallyHidden — Live Region',
|
|
9
|
-
description:
|
|
10
|
-
'A polite aria-live region announces visual-only state changes to assistive technology.',
|
|
11
|
-
isReady: true,
|
|
12
|
-
aspectRatio: 4 / 3,
|
|
13
|
-
componentsUsed: ['VisuallyHidden', 'Button', 'HStack', 'VStack', 'Text'],
|
|
14
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
'use client';
|
|
4
|
-
|
|
5
|
-
import {useState} from 'react';
|
|
6
|
-
import {VisuallyHidden} from '@astryxdesign/core/VisuallyHidden';
|
|
7
|
-
import {Button} from '@astryxdesign/core/Button';
|
|
8
|
-
import {HStack, VStack} from '@astryxdesign/core/Layout';
|
|
9
|
-
import {Text} from '@astryxdesign/core/Text';
|
|
10
|
-
|
|
11
|
-
const columns = ['Backlog', 'In progress', 'Done'] as const;
|
|
12
|
-
|
|
13
|
-
export default function VisuallyHiddenLiveRegion() {
|
|
14
|
-
const [column, setColumn] = useState(0);
|
|
15
|
-
const current = columns[column];
|
|
16
|
-
|
|
17
|
-
function move() {
|
|
18
|
-
setColumn(c => (c + 1) % columns.length);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<VStack gap={4} hAlign="start">
|
|
23
|
-
<Text type="supporting" color="secondary">
|
|
24
|
-
Drag-and-drop and other visual-only changes are silent to screen
|
|
25
|
-
readers. A live region narrates them.
|
|
26
|
-
</Text>
|
|
27
|
-
<HStack gap={3} vAlign="center">
|
|
28
|
-
<Button label="Move task" variant="secondary" onClick={move} />
|
|
29
|
-
<Text type="body">
|
|
30
|
-
Task is in{' '}
|
|
31
|
-
<Text as="span" weight="bold">
|
|
32
|
-
{current}
|
|
33
|
-
</Text>
|
|
34
|
-
</Text>
|
|
35
|
-
</HStack>
|
|
36
|
-
<VisuallyHidden as="div" aria-live="polite">
|
|
37
|
-
{`Task moved to ${current}`}
|
|
38
|
-
</VisuallyHidden>
|
|
39
|
-
</VStack>
|
|
40
|
-
);
|
|
41
|
-
}
|
|
@@ -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: 'VisuallyHidden',
|
|
7
|
-
name: 'VisuallyHidden',
|
|
8
|
-
displayName: 'VisuallyHidden',
|
|
9
|
-
isReady: true,
|
|
10
|
-
aspectRatio: 16 / 9,
|
|
11
|
-
isShowcase: true,
|
|
12
|
-
componentsUsed: ['VisuallyHidden', 'IconButton', 'Card', 'HStack', 'VStack', 'Text', 'Icon'],
|
|
13
|
-
};
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
'use client';
|
|
4
|
-
|
|
5
|
-
import {VisuallyHidden} from '@astryxdesign/core/VisuallyHidden';
|
|
6
|
-
import {IconButton} from '@astryxdesign/core/IconButton';
|
|
7
|
-
import {Card} from '@astryxdesign/core/Card';
|
|
8
|
-
import {HStack, VStack} from '@astryxdesign/core/Layout';
|
|
9
|
-
import {Text} from '@astryxdesign/core/Text';
|
|
10
|
-
import {Icon} from '@astryxdesign/core/Icon';
|
|
11
|
-
import {
|
|
12
|
-
ArrowDownTrayIcon,
|
|
13
|
-
ShareIcon,
|
|
14
|
-
TrashIcon,
|
|
15
|
-
} from '@heroicons/react/24/outline';
|
|
16
|
-
import {SpeakerWaveIcon} from '@heroicons/react/24/solid';
|
|
17
|
-
|
|
18
|
-
const actions = [
|
|
19
|
-
{label: 'Download', icon: ArrowDownTrayIcon},
|
|
20
|
-
{label: 'Share', icon: ShareIcon},
|
|
21
|
-
{label: 'Delete', icon: TrashIcon},
|
|
22
|
-
] as const;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* VisuallyHidden is invisible by design, so this hero teaches the concept by
|
|
26
|
-
* contrast: the icon-only buttons are all a sighted user sees, while the
|
|
27
|
-
* caption spells out the accessible name each one exposes. A live
|
|
28
|
-
* <VisuallyHidden> region below announces the same names to assistive tech,
|
|
29
|
-
* so the demo genuinely exercises the component it documents.
|
|
30
|
-
*/
|
|
31
|
-
export default function VisuallyHiddenShowcase() {
|
|
32
|
-
return (
|
|
33
|
-
<VStack gap={5} hAlign="center">
|
|
34
|
-
<HStack gap={6} vAlign="stretch" wrap="wrap" hAlign="center">
|
|
35
|
-
<Card variant="muted">
|
|
36
|
-
<VStack gap={4} hAlign="center">
|
|
37
|
-
<Text type="supporting" color="secondary">
|
|
38
|
-
What you see
|
|
39
|
-
</Text>
|
|
40
|
-
<HStack gap={2}>
|
|
41
|
-
{actions.map(({label, icon}) => (
|
|
42
|
-
<IconButton
|
|
43
|
-
key={label}
|
|
44
|
-
label={label}
|
|
45
|
-
icon={<Icon icon={icon} />}
|
|
46
|
-
variant="ghost"
|
|
47
|
-
/>
|
|
48
|
-
))}
|
|
49
|
-
</HStack>
|
|
50
|
-
</VStack>
|
|
51
|
-
</Card>
|
|
52
|
-
|
|
53
|
-
<Card variant="muted">
|
|
54
|
-
<VStack gap={4} hAlign="start">
|
|
55
|
-
<HStack gap={2} vAlign="center">
|
|
56
|
-
<Icon icon={SpeakerWaveIcon} size="sm" />
|
|
57
|
-
<Text type="supporting" color="secondary">
|
|
58
|
-
What a screen reader hears
|
|
59
|
-
</Text>
|
|
60
|
-
</HStack>
|
|
61
|
-
<VStack gap={2}>
|
|
62
|
-
{actions.map(({label}) => (
|
|
63
|
-
<Text key={label} type="body">
|
|
64
|
-
{label}, button
|
|
65
|
-
</Text>
|
|
66
|
-
))}
|
|
67
|
-
</VStack>
|
|
68
|
-
</VStack>
|
|
69
|
-
</Card>
|
|
70
|
-
</HStack>
|
|
71
|
-
|
|
72
|
-
{/* A real live region: silent to sighted users, announced by AT. */}
|
|
73
|
-
<VisuallyHidden as="div" aria-live="polite">
|
|
74
|
-
Actions available: Download, Share, Delete.
|
|
75
|
-
</VisuallyHidden>
|
|
76
|
-
</VStack>
|
|
77
|
-
);
|
|
78
|
-
}
|
|
@@ -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: 'VisuallyHidden',
|
|
7
|
-
name: 'VisuallyHidden — Structural Heading',
|
|
8
|
-
displayName: 'VisuallyHidden — Structural Heading',
|
|
9
|
-
description:
|
|
10
|
-
'Give a visually implicit section an accessible name so screen-reader users can navigate to it.',
|
|
11
|
-
isReady: true,
|
|
12
|
-
aspectRatio: 4 / 3,
|
|
13
|
-
componentsUsed: ['VisuallyHidden', 'Card', 'HStack', 'VStack', 'Text', 'Badge'],
|
|
14
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
'use client';
|
|
4
|
-
|
|
5
|
-
import {VisuallyHidden} from '@astryxdesign/core/VisuallyHidden';
|
|
6
|
-
import {Card} from '@astryxdesign/core/Card';
|
|
7
|
-
import {HStack, VStack} from '@astryxdesign/core/Layout';
|
|
8
|
-
import {Text} from '@astryxdesign/core/Text';
|
|
9
|
-
import {Badge} from '@astryxdesign/core/Badge';
|
|
10
|
-
|
|
11
|
-
const items = [
|
|
12
|
-
{name: 'astryx-core', status: 'Passing', variant: 'success'},
|
|
13
|
-
{name: 'astryx-charts', status: 'Failing', variant: 'error'},
|
|
14
|
-
{name: 'astryx-cli', status: 'Passing', variant: 'success'},
|
|
15
|
-
] as const;
|
|
16
|
-
|
|
17
|
-
export default function VisuallyHiddenStructuralHeading() {
|
|
18
|
-
return (
|
|
19
|
-
<VStack gap={3} hAlign="start">
|
|
20
|
-
<Text type="supporting" color="secondary">
|
|
21
|
-
The layout makes this group obvious to sighted users. A hidden heading
|
|
22
|
-
gives screen-reader users the same landmark to jump to.
|
|
23
|
-
</Text>
|
|
24
|
-
{/* No visible heading is needed here, but AT users navigate by heading. */}
|
|
25
|
-
<VisuallyHidden as="h2">Build status</VisuallyHidden>
|
|
26
|
-
<VStack gap={2}>
|
|
27
|
-
{items.map(({name, status, variant}) => (
|
|
28
|
-
<Card key={name} variant="muted" padding={3}>
|
|
29
|
-
<HStack gap={3} vAlign="center">
|
|
30
|
-
<Text type="body">{name}</Text>
|
|
31
|
-
<Badge label={status} variant={variant} />
|
|
32
|
-
</HStack>
|
|
33
|
-
</Card>
|
|
34
|
-
))}
|
|
35
|
-
</VStack>
|
|
36
|
-
</VStack>
|
|
37
|
-
);
|
|
38
|
-
}
|
package/templates/blocks/components/VisuallyHidden/VisuallyHiddenSupplementaryContext.doc.mjs
DELETED
|
@@ -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: 'VisuallyHidden',
|
|
7
|
-
name: 'VisuallyHidden — Supplementary Context',
|
|
8
|
-
displayName: 'VisuallyHidden — Supplementary Context',
|
|
9
|
-
description:
|
|
10
|
-
'Add screen-reader-only context to terse visual data, like spelling out what a trend arrow means.',
|
|
11
|
-
isReady: true,
|
|
12
|
-
aspectRatio: 4 / 3,
|
|
13
|
-
componentsUsed: ['VisuallyHidden', 'Card', 'HStack', 'VStack', 'Text', 'Icon'],
|
|
14
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
'use client';
|
|
4
|
-
|
|
5
|
-
import {VisuallyHidden} from '@astryxdesign/core/VisuallyHidden';
|
|
6
|
-
import {Card} from '@astryxdesign/core/Card';
|
|
7
|
-
import {HStack, VStack} from '@astryxdesign/core/Layout';
|
|
8
|
-
import {Text} from '@astryxdesign/core/Text';
|
|
9
|
-
import {Icon} from '@astryxdesign/core/Icon';
|
|
10
|
-
import {ArrowUpIcon, ArrowDownIcon} from '@heroicons/react/24/solid';
|
|
11
|
-
|
|
12
|
-
const stats = [
|
|
13
|
-
{label: 'Revenue', value: '$48.2k', delta: '+12%', direction: 'up'},
|
|
14
|
-
{label: 'Churn', value: '2.1%', delta: '-4%', direction: 'down'},
|
|
15
|
-
] as const;
|
|
16
|
-
|
|
17
|
-
export default function VisuallyHiddenSupplementaryContext() {
|
|
18
|
-
return (
|
|
19
|
-
<HStack gap={4} wrap="wrap">
|
|
20
|
-
{stats.map(({label, value, delta, direction}) => (
|
|
21
|
-
<Card key={label} variant="muted">
|
|
22
|
-
<VStack gap={1}>
|
|
23
|
-
<Text type="supporting" color="secondary">
|
|
24
|
-
{label}
|
|
25
|
-
</Text>
|
|
26
|
-
<Text type="display-3">{value}</Text>
|
|
27
|
-
<HStack gap={1} vAlign="center">
|
|
28
|
-
<Icon
|
|
29
|
-
icon={direction === 'up' ? ArrowUpIcon : ArrowDownIcon}
|
|
30
|
-
size="sm"
|
|
31
|
-
color={direction === 'up' ? 'accent' : 'secondary'}
|
|
32
|
-
/>
|
|
33
|
-
<Text type="body">
|
|
34
|
-
{delta}
|
|
35
|
-
{/* The arrow is decorative; spell out the trend for AT. */}
|
|
36
|
-
<VisuallyHidden>
|
|
37
|
-
{direction === 'up' ? ' increase' : ' decrease'} from last
|
|
38
|
-
month
|
|
39
|
-
</VisuallyHidden>
|
|
40
|
-
</Text>
|
|
41
|
-
</HStack>
|
|
42
|
-
</VStack>
|
|
43
|
-
</Card>
|
|
44
|
-
))}
|
|
45
|
-
</HStack>
|
|
46
|
-
);
|
|
47
|
-
}
|