@astryxdesign/cli 0.6.3-canary.aa04154 → 0.6.3-canary.abbb293

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 (38) hide show
  1. package/api/docs/_adapter.d.mts +49 -7
  2. package/api/docs/_adapter.mjs +284 -33
  3. package/api/docs/docs.doc.mjs +4 -3
  4. package/api/docs/docs.type.d.mts +21 -5
  5. package/api/docs/docs.type.mjs +21 -5
  6. package/api/docs/integration-tree.test.mjs +9 -1
  7. package/api/docs/reference-blocks.test.mjs +406 -0
  8. package/api/doctor/doctor.mjs +5 -1
  9. package/api/integration/authoring-checks.mjs +14 -1
  10. package/api/template/table-floating-bulk-actions.test.mjs +66 -0
  11. package/assets/docs/styling-libraries.doc.mjs +1 -1
  12. package/assets/docs/theme.doc.mjs +1 -1
  13. package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.doc.mjs +1 -1
  14. package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.tsx +1 -3
  15. package/assets/templates/blocks/components/Table/TableBulkActionsTable.doc.mjs +14 -0
  16. package/assets/templates/blocks/components/Table/TableBulkActionsTable.tsx +71 -0
  17. package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.doc.mjs +19 -0
  18. package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.tsx +139 -0
  19. package/authoring/doctypes/_schema.d.mts +72 -0
  20. package/authoring/doctypes/_schema.mjs +25 -1
  21. package/authoring/doctypes/load-contract.test.mjs +25 -0
  22. package/authoring/doctypes/reference/reference.doc.mjs +31 -4
  23. package/authoring/doctypes/reference/type.ts +20 -5
  24. package/clients/cli/commands/docs.mjs +2 -2
  25. package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
  26. package/foundation/discovery/authoring-self-docs.d.mts +12 -0
  27. package/foundation/discovery/authoring-self-docs.mjs +20 -8
  28. package/foundation/discovery/authoring-self-docs.test.mjs +7 -2
  29. package/foundation/discovery/docs-discovery.d.mts +4 -1
  30. package/foundation/discovery/docs-discovery.mjs +40 -6
  31. package/foundation/discovery/docs-discovery.test.mjs +40 -0
  32. package/foundation/doc-compiler/lenses.d.mts +5 -3
  33. package/foundation/doc-compiler/lenses.mjs +48 -3
  34. package/foundation/doc-compiler/links.d.mts +30 -3
  35. package/foundation/doc-compiler/links.mjs +46 -5
  36. package/foundation/doc-compiler/links.test.mjs +53 -0
  37. package/foundation/integrations/cli-requirement.test.mjs +17 -42
  38. package/package.json +9 -9
@@ -0,0 +1,406 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file A topic section's `reference` block (spec:AST-047 FR9). A read
5
+ * includes the doc it names from that doc's own source, narrowed by its
6
+ * projection, and still returns only the stable block kinds. A block that
7
+ * cannot include what it names fails the authoring check.
8
+ */
9
+
10
+ import * as fs from 'node:fs';
11
+ import * as path from 'node:path';
12
+ import {afterEach, beforeEach, describe, expect, it} from 'vitest';
13
+ import {docs} from './docs.mjs';
14
+ import {
15
+ builtinCatalog,
16
+ docsLinkProblems,
17
+ linkResolver,
18
+ loadDocsCatalog,
19
+ projectTree,
20
+ } from './_adapter.mjs';
21
+ import {integrationDocConflicts} from '../integration/authoring-checks.mjs';
22
+ import {checkDocsTree} from '../doctor/doctor.mjs';
23
+ import {createDocId} from '../../foundation/identity/provider-identity.mjs';
24
+ import {CLI_PROVIDER_ID} from '../../foundation/identity/providers.mjs';
25
+ import {runCli} from '../../test-utils/run-cli.mjs';
26
+
27
+ const SLOW = 60_000;
28
+
29
+ /** The block kinds a read returns: a token reference and a reference block are inlined. */
30
+ const READ_KINDS = new Set(['prose', 'heading', 'code', 'table', 'list']);
31
+
32
+ /** The primary fixture: two fields of the CLI's integration manifest schema. */
33
+ const MANIFEST_FIELDS = {
34
+ type: 'reference',
35
+ target: '@astryxdesign/cli:schema:integration',
36
+ projection: {fields: ['components', 'docs']},
37
+ };
38
+
39
+ /** A topic whose sections include canonical CLI docs. */
40
+ const SETUP = {
41
+ type: 'generic',
42
+ name: 'acme-setup',
43
+ title: 'Acme setup',
44
+ description: 'Set up the Acme kit.',
45
+ sections: [
46
+ {
47
+ id: 'manifest',
48
+ title: 'Point the manifest at your folders',
49
+ content: [
50
+ {type: 'prose', text: 'Add these fields to astryx.integration.mjs.'},
51
+ MANIFEST_FIELDS,
52
+ ],
53
+ },
54
+ {
55
+ id: 'check',
56
+ title: 'Check the docs',
57
+ content: [
58
+ {type: 'prose', text: 'Run the check before you publish.'},
59
+ {
60
+ type: 'reference',
61
+ target: '@astryxdesign/cli:command:doctor integration docs',
62
+ presentation: 'compact',
63
+ },
64
+ ],
65
+ },
66
+ {
67
+ id: 'more',
68
+ title: 'Read more',
69
+ content: [
70
+ {
71
+ type: 'reference',
72
+ target: '@astryxdesign/cli:function:docs',
73
+ presentation: 'summary',
74
+ },
75
+ {type: 'reference', target: '@astryxdesign/cli:generic:theme'},
76
+ ],
77
+ },
78
+ ],
79
+ };
80
+
81
+ /** A topic whose reference blocks each name something they cannot include. */
82
+ const BROKEN = {
83
+ type: 'generic',
84
+ name: 'acme-broken',
85
+ title: 'Acme broken',
86
+ description: 'References that include nothing.',
87
+ sections: [
88
+ {
89
+ id: 'gaps',
90
+ title: 'Gaps',
91
+ content: [
92
+ {
93
+ type: 'reference',
94
+ target: '@astryxdesign/cli:schema:integration',
95
+ projection: {fields: ['components', 'nope']},
96
+ },
97
+ {type: 'reference', target: '@astryxdesign/cli:schema:nothing'},
98
+ {
99
+ type: 'reference',
100
+ target: '@astryxdesign/cli:command:doctor',
101
+ projection: {fields: ['--json']},
102
+ },
103
+ {
104
+ type: 'reference',
105
+ target: '@astryxdesign/cli:schema:config',
106
+ projection: {sections: ['fields']},
107
+ },
108
+ {
109
+ type: 'reference',
110
+ target: '@astryxdesign/cli:generic:theme',
111
+ presentation: 'full',
112
+ },
113
+ ],
114
+ },
115
+ ],
116
+ };
117
+
118
+ /** @type {string} */
119
+ let tmpDir;
120
+
121
+ beforeEach(() => {
122
+ tmpDir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-reference-test-'));
123
+ });
124
+
125
+ afterEach(() => {
126
+ fs.rmSync(tmpDir, {recursive: true, force: true});
127
+ });
128
+
129
+ /**
130
+ * A consumer project that configures `@acme/kit`, which ships these docs.
131
+ * @param {Record<string, object>} files doc file name -> doc
132
+ */
133
+ function scaffold(files) {
134
+ fs.writeFileSync(path.join(tmpDir, 'package.json'), '{"name": "consumer"}\n');
135
+ fs.writeFileSync(
136
+ path.join(tmpDir, 'astryx.config.mjs'),
137
+ "export default {integrations: ['@acme/kit']};\n",
138
+ );
139
+ const kit = path.join(tmpDir, 'node_modules', '@acme', 'kit');
140
+ fs.mkdirSync(path.join(kit, 'docs'), {recursive: true});
141
+ fs.writeFileSync(
142
+ path.join(kit, 'package.json'),
143
+ JSON.stringify({name: '@acme/kit', version: '1.0.0'}),
144
+ );
145
+ fs.writeFileSync(
146
+ path.join(kit, 'astryx.integration.mjs'),
147
+ "export default {docs: './docs'};\n",
148
+ );
149
+ for (const [file, doc] of Object.entries(files)) {
150
+ fs.writeFileSync(
151
+ path.join(kit, 'docs', file),
152
+ `export const docs = ${JSON.stringify(doc, null, 2)};\n`,
153
+ );
154
+ }
155
+ }
156
+
157
+ /**
158
+ * @param {string} topic
159
+ * @param {string} [section]
160
+ */
161
+ async function read(topic, section) {
162
+ return (await docs(topic, section, {cwd: tmpDir})).data;
163
+ }
164
+
165
+ describe('a reference block in a topic section', () => {
166
+ it(
167
+ 'includes the fields a schema reference names, then where they come from',
168
+ async () => {
169
+ scaffold({'acme-setup.doc.mjs': SETUP});
170
+ const section = await read('acme-setup', 'manifest');
171
+ expect(section.content.map(block => block.type)).toEqual([
172
+ 'prose',
173
+ 'table',
174
+ 'prose',
175
+ ]);
176
+ const table = section.content[1];
177
+ expect(table.headers).toEqual([
178
+ 'Field',
179
+ 'Type',
180
+ 'Required',
181
+ 'Description',
182
+ ]);
183
+ // The fields the block names, in the order it names them.
184
+ expect(table.rows.map(row => row[0])).toEqual(['components', 'docs']);
185
+ expect(section.content[2]).toEqual({
186
+ type: 'prose',
187
+ text: 'From Astryx Integration: `astryx docs authoring integration`',
188
+ });
189
+ },
190
+ SLOW,
191
+ );
192
+
193
+ it(
194
+ "reads the included fields from the schema's own doc, not a copy",
195
+ async () => {
196
+ scaffold({'acme-setup.doc.mjs': SETUP});
197
+ const included = (await read('acme-setup', 'manifest')).content[1].rows;
198
+ const schema = (await docs('authoring', 'integration')).data.content.find(
199
+ block => block.type === 'table',
200
+ );
201
+ expect(included).toEqual(
202
+ MANIFEST_FIELDS.projection.fields.map(name =>
203
+ schema.rows.find(row => row[0] === name),
204
+ ),
205
+ );
206
+ },
207
+ SLOW,
208
+ );
209
+
210
+ it(
211
+ 'returns only the stable block kinds in every read, in JSON and in each language',
212
+ async () => {
213
+ scaffold({'acme-setup.doc.mjs': SETUP});
214
+ for (const lang of [null, 'zh']) {
215
+ const whole = (await docs('acme-setup', undefined, {cwd: tmpDir, lang}))
216
+ .data;
217
+ const kinds = new Set(
218
+ whole.sections.flatMap(section => section.content.map(b => b.type)),
219
+ );
220
+ expect([...kinds].filter(kind => !READ_KINDS.has(kind))).toEqual([]);
221
+ for (const {id} of whole.sections) {
222
+ const one = (await docs('acme-setup', id, {cwd: tmpDir, lang})).data;
223
+ expect(one.content.every(block => READ_KINDS.has(block.type))).toBe(
224
+ true,
225
+ );
226
+ }
227
+ }
228
+ },
229
+ SLOW,
230
+ );
231
+
232
+ it(
233
+ 'includes a whole command doc, without code when compact; a summary and a topic show as one line',
234
+ async () => {
235
+ scaffold({'acme-setup.doc.mjs': SETUP});
236
+ const check = (await read('acme-setup', 'check')).content;
237
+ expect(check.some(block => block.type === 'code')).toBe(false);
238
+ expect(check.find(block => block.type === 'table')?.headers).toEqual([
239
+ 'Argument',
240
+ 'Description',
241
+ ]);
242
+ // The included doc's own links resolve against its own provider.
243
+ expect(
244
+ check.some(
245
+ block =>
246
+ block.type === 'prose' &&
247
+ block.text.includes(
248
+ 'Read it with `astryx docs cli/api/functions/integration-doc-conflicts`.',
249
+ ),
250
+ ),
251
+ ).toBe(true);
252
+ expect(check.at(-1)).toEqual({
253
+ type: 'prose',
254
+ text: 'From astryx doctor integration docs: `astryx docs cli/commands/doctor-integration-docs`',
255
+ });
256
+ const more = (await read('acme-setup', 'more')).content;
257
+ expect(more).toHaveLength(2);
258
+ expect(more[0].text).toMatch(
259
+ /^docs\(\): Read the reference docs: .* Read it with `astryx docs cli\/api\/functions\/docs`\.$/,
260
+ );
261
+ expect(more[1].text).toMatch(
262
+ /^Theme System: .* Read it with `astryx docs theme`\.$/,
263
+ );
264
+ },
265
+ SLOW,
266
+ );
267
+
268
+ it(
269
+ 'prints the included content in text',
270
+ async () => {
271
+ scaffold({'acme-setup.doc.mjs': SETUP});
272
+ const {status, stdout} = await runCli(
273
+ ['docs', 'acme-setup', 'manifest'],
274
+ tmpDir,
275
+ );
276
+ expect(status).toBe(0);
277
+ expect(stdout).toMatch(/^Field +\| Type +\| Required +\| Description/m);
278
+ expect(stdout).toMatch(/^components +\| string +\| no +\| /m);
279
+ expect(stdout).toContain(
280
+ 'From Astryx Integration: `astryx docs authoring integration`',
281
+ );
282
+ },
283
+ SLOW,
284
+ );
285
+ });
286
+
287
+ describe('a reference block that includes what it names', () => {
288
+ it(
289
+ 'passes the authoring check',
290
+ async () => {
291
+ scaffold({'acme-setup.doc.mjs': SETUP});
292
+ const {data} = await integrationDocConflicts('@acme/kit', {cwd: tmpDir});
293
+ expect(data.issues).toEqual([]);
294
+ const cli = await runCli(
295
+ ['doctor', 'integration', 'docs', '@acme/kit'],
296
+ tmpDir,
297
+ );
298
+ expect(cli.status).toBe(0);
299
+ },
300
+ SLOW,
301
+ );
302
+ });
303
+
304
+ describe('what a reference block names', () => {
305
+ it('resolves a CLI authoring schema by identity, to its section of `astryx docs authoring`', async () => {
306
+ const resolve = await linkResolver(builtinCatalog(), CLI_PROVIDER_ID);
307
+ expect(await resolve('schema:integration')).toMatchObject({
308
+ id: createDocId(CLI_PROVIDER_ID, 'schema', 'integration'),
309
+ route: 'authoring',
310
+ title: 'Astryx Integration',
311
+ command: 'astryx docs authoring integration',
312
+ });
313
+ const opened = await docs('authoring', 'integration');
314
+ expect(opened.type).toBe('docs.detail.section');
315
+ expect(opened.data.id).toBe('integration');
316
+ });
317
+
318
+ it(
319
+ "leaves no reference in the CLI's own docs that cannot include what it names",
320
+ async () => {
321
+ const catalog = builtinCatalog();
322
+ expect(
323
+ await docsLinkProblems(catalog, await projectTree(catalog), {
324
+ references: true,
325
+ }),
326
+ ).toEqual([]);
327
+ },
328
+ SLOW,
329
+ );
330
+ });
331
+
332
+ describe('a reference block that cannot include what it names', () => {
333
+ it(
334
+ 'fails the authoring check, once for each part it cannot include',
335
+ async () => {
336
+ scaffold({'acme-broken.doc.mjs': BROKEN});
337
+ const {data} = await integrationDocConflicts('@acme/kit', {cwd: tmpDir});
338
+ const errors = data.issues.filter(
339
+ issue => issue.code === 'invalid_doc_reference',
340
+ );
341
+ expect(errors.every(issue => issue.severity === 'error')).toBe(true);
342
+ const messages = errors.map(issue => issue.message);
343
+ expect(messages).toHaveLength(5);
344
+ expect(messages[0]).toMatch(
345
+ /^acme-broken § gaps: projection\.fields: "nope" is not a field of Astryx Integration/,
346
+ );
347
+ expect(messages[1]).toMatch(
348
+ /"@astryxdesign\/cli:schema:nothing" names no doc/,
349
+ );
350
+ expect(messages[2]).toMatch(
351
+ /projection\.fields: names the fields of a schema doc/,
352
+ );
353
+ expect(messages[3]).toMatch(/projection\.sections: /);
354
+ expect(messages[4]).toMatch(
355
+ /"@astryxdesign\/cli:generic:theme" is a topic/,
356
+ );
357
+ // They are not also reported as links that print as written.
358
+ expect(
359
+ data.issues.filter(issue => issue.code === 'invalid_doc_graph'),
360
+ ).toEqual([]);
361
+ const cli = await runCli(
362
+ ['doctor', 'integration', 'docs', '@acme/kit'],
363
+ tmpDir,
364
+ );
365
+ expect(cli.status).toBe(1);
366
+ },
367
+ SLOW,
368
+ );
369
+
370
+ it(
371
+ 'marks the missing content where a read would show it',
372
+ async () => {
373
+ scaffold({'acme-broken.doc.mjs': BROKEN});
374
+ const texts = (await read('acme-broken', 'gaps')).content
375
+ .filter(block => block.type === 'prose')
376
+ .map(block => block.text);
377
+ expect(texts).toContain(
378
+ '[reference: field "nope" not found in "@astryxdesign/cli:schema:integration"]',
379
+ );
380
+ expect(texts).toContain(
381
+ '[reference: "@astryxdesign/cli:schema:nothing" names no doc]',
382
+ );
383
+ // The field it could include is still there.
384
+ const table = (await read('acme-broken', 'gaps')).content.find(
385
+ block => block.type === 'table',
386
+ );
387
+ expect(table.rows.map(row => row[0])).toEqual(['components']);
388
+ },
389
+ SLOW,
390
+ );
391
+
392
+ it(
393
+ "warns in a project's doctor, which an app cannot fix",
394
+ async () => {
395
+ scaffold({'acme-broken.doc.mjs': BROKEN});
396
+ const check = await checkDocsTree({
397
+ docsCatalog: await loadDocsCatalog(tmpDir),
398
+ });
399
+ expect(check.status).toBe('warn');
400
+ expect(check.message).toContain(
401
+ '"nope" is not a field of Astryx Integration',
402
+ );
403
+ },
404
+ SLOW,
405
+ );
406
+ });
@@ -1032,13 +1032,17 @@ export async function checkDocsTree(_ctx, options = {}) {
1032
1032
  }
1033
1033
  }
1034
1034
  // Every link between docs names a doc that exists (spec:AST-047 FR9):
1035
- // typed fields, reference and workflow blocks, and inline links.
1035
+ // typed fields, reference and workflow blocks, and inline links. A
1036
+ // reference block also includes all it names.
1036
1037
  for (const node of tree.nodes.values()) {
1037
1038
  for (const edge of typedEdges(tree, node).unresolved) {
1038
1039
  problems.push(`${node.route}: ${edge}`);
1039
1040
  }
1040
1041
  }
1041
1042
  problems.push(...(await docsLinkProblems(catalog, tree)));
1043
+ problems.push(
1044
+ ...(await docsLinkProblems(catalog, tree, {references: true})),
1045
+ );
1042
1046
  }
1043
1047
  // New findings warn: a project that passed before keeps passing
1044
1048
  // (0.6 compatibility), and the warning names what to fix.
@@ -15,7 +15,10 @@
15
15
  */
16
16
 
17
17
  import {getCliInvocation} from '../../foundation/env/package-manager.mjs';
18
- import {packageDocsProblems} from '../docs/_adapter.mjs';
18
+ import {
19
+ packageDocsProblems,
20
+ packageReferenceProblems,
21
+ } from '../docs/_adapter.mjs';
19
22
  import {findCoreDir} from '../../foundation/fs/paths.mjs';
20
23
  import {
21
24
  discoverIntegrationComponents,
@@ -371,6 +374,16 @@ export async function integrationDocConflicts(pkg, options = {}) {
371
374
  )) {
372
375
  issues.push({code: 'invalid_doc_graph', severity: 'warning', message});
373
376
  }
377
+
378
+ // A reference block includes content rather than linking to it, so one
379
+ // that cannot include what it names loses that content for every reader:
380
+ // an error, where a link that names no doc still prints as written.
381
+ for (const message of await packageReferenceProblems(
382
+ /** @type {{name: string}} */ (resolved.integration),
383
+ discovered,
384
+ )) {
385
+ issues.push({code: 'invalid_doc_reference', severity: 'error', message});
386
+ }
374
387
  }
375
388
 
376
389
  return {
@@ -0,0 +1,66 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Regression coverage for the floating bulk-actions Table block.
5
+ * @input The shipped TableFloatingBulkActionsTable source.
6
+ * @output Assertions for width, logical scrolling, local stacking, and shared toolbar geometry.
7
+ * @position Template contract test for the website example layout.
8
+ */
9
+
10
+ import fs from 'node:fs';
11
+ import path from 'node:path';
12
+ import {fileURLToPath} from 'node:url';
13
+ import {describe, expect, it} from 'vitest';
14
+
15
+ const sourcePath = path.resolve(
16
+ path.dirname(fileURLToPath(import.meta.url)),
17
+ '../../assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.tsx',
18
+ );
19
+ const source = fs.readFileSync(sourcePath, 'utf8');
20
+ const pageStyles = source.match(/page:\s*\{([\s\S]*?)\n\s{2}\},/)?.[1];
21
+ const tableRegionStyles = source.match(
22
+ /tableRegion:\s*\{([\s\S]*?)\n\s{2}\},/,
23
+ )?.[1];
24
+ const toolbarStyles = source.match(/toolbar:\s*\{([\s\S]*?)\n\s{2}\},/)?.[1];
25
+ const columns = source.match(
26
+ /const columns:[\s\S]*?=\s*\[([\s\S]*?)\n\];/,
27
+ )?.[1];
28
+
29
+ describe('Table floating bulk-actions template', () => {
30
+ it('caps the demo height without capping its width', () => {
31
+ expect(pageStyles).toContain('maxBlockSize: 640');
32
+ expect(pageStyles).not.toContain('maxWidth');
33
+ expect(pageStyles).not.toContain('marginInline');
34
+ });
35
+
36
+ it('uses the shared logical-axis scroll behavior', () => {
37
+ expect(source).toContain(
38
+ "import {ScrollableArea} from '@astryxdesign/core/ScrollableArea'",
39
+ );
40
+ expect(source).toMatch(
41
+ /<ScrollableArea[\s\S]*?axis="block"[\s\S]*?label="Bulk actions example"[\s\S]*?overscroll="contain"/,
42
+ );
43
+ expect(source).not.toContain('role="region"');
44
+ expect(source).not.toContain('tabIndex={0}');
45
+ expect(source).not.toContain('aria-label="Metrics"');
46
+ expect(pageStyles).not.toContain('overflowY');
47
+ expect(pageStyles).not.toContain('overscrollBehavior');
48
+ });
49
+
50
+ it('keeps the floating toolbar inside an isolated local stacking context', () => {
51
+ expect(pageStyles).toContain("isolation: 'isolate'");
52
+ expect(toolbarStyles).toContain('zIndex: 1');
53
+ expect(toolbarStyles).not.toContain('zIndex: 20');
54
+ });
55
+
56
+ it('shares one reserved-space variable across the placement geometry', () => {
57
+ expect(tableRegionStyles).toContain("'--table-bulk-actions-space'");
58
+ expect(source.match(/var\(--table-bulk-actions-space\)/g)).toHaveLength(4);
59
+ });
60
+
61
+ it('keeps the email column compact enough to avoid horizontal overflow', () => {
62
+ expect(columns).toContain(
63
+ "{key: 'email', header: 'Email', width: proportional(1)}",
64
+ );
65
+ });
66
+ });
@@ -150,7 +150,7 @@ const styles = stylex.create({
150
150
  content: [
151
151
  {
152
152
  type: 'prose',
153
- text: 'The Tailwind v4 bridge at `@astryxdesign/core/tailwind-theme.css` maps Tailwind theme variables to system CSS variables with `@theme inline`, so utility classes like `text-primary`, `bg-surface`, `border-border`, `rounded-lg`, and `shadow-md` stay in sync with the active theme.',
153
+ text: 'The Tailwind v4 bridge at `@astryxdesign/core/tailwind-theme.css` maps Tailwind theme variables to system CSS variables with `@theme reference inline`, so utility classes like `text-primary`, `bg-surface`, `border-border`, `rounded-lg`, and `shadow-md` stay in sync with the active theme without emitting competing runtime declarations.',
154
154
  },
155
155
  {
156
156
  type: 'code',
@@ -76,7 +76,7 @@ function App() {
76
76
  [
77
77
  'Neutral',
78
78
  "import {neutralTheme} from '@astryxdesign/theme-neutral'",
79
- 'Muted, minimal aesthetic with system fonts. A good starting point.',
79
+ 'Muted, minimal aesthetic with Figtree typography. A good starting point.',
80
80
  ],
81
81
  [
82
82
  'Butter',
@@ -10,5 +10,5 @@ export const doc = {
10
10
  'A "select all" toggle at the top of a checkbox list that switches to an indeterminate dash when only some items are checked, useful for bulk actions like exporting documents or assigning permissions where users often want everything at once.',
11
11
  isReady: true,
12
12
  aspectRatio: 16 / 9,
13
- componentsUsed: ['CheckboxList', 'Divider'],
13
+ componentsUsed: ['CheckboxList'],
14
14
  };
@@ -4,7 +4,6 @@
4
4
 
5
5
  import {useState} from 'react';
6
6
  import {CheckboxList, CheckboxListItem} from '@astryxdesign/core/CheckboxList';
7
- import {Divider} from '@astryxdesign/core/Divider';
8
7
 
9
8
  const DOCUMENTS = [
10
9
  {id: 'transactions', label: 'Transaction history'},
@@ -27,7 +26,7 @@ export default function CheckboxListSelectAllPattern() {
27
26
  : ('indeterminate' as const);
28
27
 
29
28
  return (
30
- <CheckboxList label="Include in export">
29
+ <CheckboxList label="Include in export" hasDividers>
31
30
  <CheckboxListItem
32
31
  label="Select all"
33
32
  isChecked={selectAllState}
@@ -35,7 +34,6 @@ export default function CheckboxListSelectAllPattern() {
35
34
  setSelected(checked ? [...ALL_IDS] : []);
36
35
  }}
37
36
  />
38
- <Divider />
39
37
  {DOCUMENTS.map(doc => (
40
38
  <CheckboxListItem
41
39
  key={doc.id}
@@ -0,0 +1,14 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */
4
+ export const doc = {
5
+ type: 'block',
6
+ exampleFor: 'useTableSelection',
7
+ name: 'Table: Bulk Actions',
8
+ displayName: 'Table: Bulk Actions',
9
+ description:
10
+ 'Controlled row selection with the reusable TableSelectionToolbar rendered in flow above the table. Product actions occupy the logical start; synchronized selection count and complete clear action occupy the logical end.',
11
+ isReady: true,
12
+ aspectRatio: 16 / 9,
13
+ componentsUsed: ['Table', 'TableSelectionToolbar', 'Button'],
14
+ };
@@ -0,0 +1,71 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ import {useState} from 'react';
6
+ import {Button} from '@astryxdesign/core/Button';
7
+ import {
8
+ Table,
9
+ TableSelectionToolbar,
10
+ useTableSelection,
11
+ useTableSelectionState,
12
+ proportional,
13
+ } from '@astryxdesign/core/Table';
14
+ import type {TableColumn} from '@astryxdesign/core/Table';
15
+
16
+ interface User extends Record<string, unknown> {
17
+ id: string;
18
+ name: string;
19
+ email: string;
20
+ role: string;
21
+ }
22
+
23
+ const users: User[] = [
24
+ {id: '1', name: 'Alice', email: 'alice@example.com', role: 'Engineer'},
25
+ {id: '2', name: 'Bob', email: 'bob@example.com', role: 'Designer'},
26
+ {id: '3', name: 'Charlie', email: 'charlie@example.com', role: 'Manager'},
27
+ {id: '4', name: 'Diana', email: 'diana@example.com', role: 'Engineer'},
28
+ {id: '5', name: 'Eve', email: 'eve@example.com', role: 'Admin'},
29
+ ];
30
+
31
+ const columns: TableColumn<User>[] = [
32
+ {key: 'name', header: 'Name', width: proportional(1)},
33
+ {key: 'email', header: 'Email', width: proportional(2)},
34
+ {key: 'role', header: 'Role', width: proportional(1)},
35
+ ];
36
+
37
+ export default function TableBulkActionsTable() {
38
+ const [selectedKeys, setSelectedKeys] = useState<Set<string>>(new Set());
39
+
40
+ const {selectionConfig, selectionState} = useTableSelectionState<User>({
41
+ data: users,
42
+ idKey: 'id',
43
+ selectedKeys,
44
+ setSelectedKeys,
45
+ });
46
+ const selectionPlugin = useTableSelection<User>(selectionConfig);
47
+
48
+ return (
49
+ <div>
50
+ <TableSelectionToolbar
51
+ selection={selectionState}
52
+ startContent={
53
+ <>
54
+ <Button label="Export" variant="ghost" onClick={() => {}} />
55
+ <Button
56
+ label="Delete"
57
+ variant="ghost"
58
+ onClick={selectionState.clearSelection}
59
+ />
60
+ </>
61
+ }
62
+ />
63
+ <Table
64
+ data={users}
65
+ columns={columns}
66
+ idKey="id"
67
+ plugins={{selection: selectionPlugin}}
68
+ />
69
+ </div>
70
+ );
71
+ }
@@ -0,0 +1,19 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */
4
+ export const doc = {
5
+ type: 'block',
6
+ exampleFor: 'useTableSelection',
7
+ name: 'Table: Floating Bulk Actions',
8
+ displayName: 'Table: Floating Bulk Actions',
9
+ description:
10
+ 'The reusable TableSelectionToolbar inside a capped, self-contained scroll region for a long non-sticky table below metric cards. The caller-owned sticky placement keeps actions 16px from the example scrollport without moving the table when selection changes.',
11
+ isReady: true,
12
+ aspectRatio: 16 / 9,
13
+ componentsUsed: [
14
+ 'Table',
15
+ 'TableSelectionToolbar',
16
+ 'Button',
17
+ 'ScrollableArea',
18
+ ],
19
+ };