@astryxdesign/cli 0.7.9-canary.df15de7 → 0.7.9-canary.e191eed

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 (27) hide show
  1. package/api/component/__fixtures__/resolutions/modules.txt +3 -3
  2. package/api/theme/build/build.mjs +342 -72
  3. package/api/theme/build/core-interception.mjs +92 -29
  4. package/api/theme/build/icon-imports.d.mts +35 -4
  5. package/api/theme/build/icon-imports.mjs +299 -38
  6. package/assets/discover/official-packages.json +8 -0
  7. package/assets/docs/author-a-theme.doc.mjs +2 -0
  8. package/assets/docs/icons.doc.mjs +29 -0
  9. package/assets/templates/blocks/components/Calendar/useCalendarDaysHookUsage.doc.mjs +14 -0
  10. package/assets/templates/blocks/components/Calendar/useCalendarDaysHookUsage.tsx +71 -0
  11. package/assets/templates/blocks/components/Hooks/useInputContainerHookUsage.doc.mjs +15 -0
  12. package/assets/templates/blocks/components/Hooks/useInputContainerHookUsage.tsx +93 -0
  13. package/assets/templates/blocks/components/Hooks/useScrollLockHookUsage.doc.mjs +14 -0
  14. package/assets/templates/blocks/components/Hooks/useScrollLockHookUsage.tsx +80 -0
  15. package/assets/templates/blocks/components/Overlay/useOverlayHookUsage.doc.mjs +21 -0
  16. package/assets/templates/blocks/components/Overlay/useOverlayHookUsage.tsx +49 -0
  17. package/assets/templates/blocks/components/Table/useTableSortableStateHookUsage.doc.mjs +14 -0
  18. package/assets/templates/blocks/components/Table/useTableSortableStateHookUsage.tsx +61 -0
  19. package/assets/templates/themes/neutral/neutralPaletteRefs.generated.ts +2 -2
  20. package/assets/templates/themes/neutral/neutralTheme.ts +30 -4
  21. package/assets/theme.template.ts +12 -0
  22. package/authoring/doctypes/base/type.ts +41 -0
  23. package/authoring/doctypes/component/component.doc.mjs +7 -1
  24. package/authoring/doctypes/component/type.ts +5 -0
  25. package/authoring/index.d.ts +2 -0
  26. package/clients/cli/lib/component-format.mjs +49 -0
  27. package/package.json +9 -9
@@ -0,0 +1,93 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ import {useRef, useState} from 'react';
6
+ import * as stylex from '@stylexjs/stylex';
7
+ import {InputClearButton} from '@astryxdesign/core/Field';
8
+ import {useInputContainer} from '@astryxdesign/core/hooks';
9
+ import {Icon} from '@astryxdesign/core/Icon';
10
+ import {
11
+ colorVars,
12
+ focusVars,
13
+ radiusVars,
14
+ spacingVars,
15
+ } from '@astryxdesign/core/theme/tokens.stylex';
16
+ import {MagnifyingGlassIcon} from '@heroicons/react/24/outline';
17
+
18
+ const styles = stylex.create({
19
+ field: {
20
+ display: 'flex',
21
+ alignItems: 'center',
22
+ gap: spacingVars['--spacing-2'],
23
+ width: 320,
24
+ minHeight: 40,
25
+ paddingInline: spacingVars['--spacing-3'],
26
+ borderWidth: 1,
27
+ borderStyle: 'solid',
28
+ borderColor: colorVars['--color-border-emphasized'],
29
+ borderRadius: radiusVars['--radius-element'],
30
+ cursor: 'text',
31
+ outlineWidth: {
32
+ default: 0,
33
+ ':has(> input:focus-visible)': focusVars['--focus-outline-width'],
34
+ },
35
+ outlineStyle: {
36
+ default: 'none',
37
+ ':has(> input:focus-visible)': focusVars['--focus-outline-style'],
38
+ },
39
+ outlineColor: {
40
+ default: null,
41
+ ':has(> input:focus-visible)': focusVars['--focus-outline-color'],
42
+ },
43
+ outlineOffset: {
44
+ default: 0,
45
+ ':has(> input:focus-visible)': focusVars['--focus-outline-offset'],
46
+ },
47
+ },
48
+ input: {
49
+ flexGrow: 1,
50
+ minWidth: 0,
51
+ borderStyle: 'none',
52
+ outlineStyle: 'none',
53
+ backgroundColor: 'transparent',
54
+ color: 'inherit',
55
+ fontFamily: 'inherit',
56
+ fontSize: 'inherit',
57
+ },
58
+ });
59
+
60
+ export default function UseInputContainerHookUsage() {
61
+ const containerRef = useRef<HTMLDivElement>(null);
62
+ const inputRef = useRef<HTMLInputElement>(null);
63
+ const [query, setQuery] = useState('');
64
+ const {onClick, onMouseUp} = useInputContainer({containerRef, inputRef});
65
+
66
+ return (
67
+ <div
68
+ ref={containerRef}
69
+ onClick={onClick}
70
+ onMouseUp={onMouseUp}
71
+ {...stylex.props(styles.field)}>
72
+ <Icon icon={MagnifyingGlassIcon} color="secondary" />
73
+ <input
74
+ ref={inputRef}
75
+ type="text"
76
+ aria-label="Search"
77
+ placeholder="Search"
78
+ value={query}
79
+ onChange={event => setQuery(event.target.value)}
80
+ {...stylex.props(styles.input)}
81
+ />
82
+ {query !== '' && (
83
+ <InputClearButton
84
+ label="Clear search"
85
+ onClick={() => {
86
+ setQuery('');
87
+ inputRef.current?.focus();
88
+ }}
89
+ />
90
+ )}
91
+ </div>
92
+ );
93
+ }
@@ -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: 'useScrollLock',
7
+ name: 'useScrollLock — Full-screen Mobile Menu',
8
+ displayName: 'useScrollLock — Full-screen Mobile Menu',
9
+ description:
10
+ 'A custom full-screen menu opened from a Menu button. useScrollLock pins the page behind it while it is open, so the page does not scroll or shift sideways, and closing the menu returns the reader to the same scroll position.',
11
+ isReady: true,
12
+ aspectRatio: 4 / 3,
13
+ componentsUsed: ['Button', 'Link', 'Layout'],
14
+ };
@@ -0,0 +1,80 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ import {useEffect, useState} from 'react';
6
+ import * as stylex from '@stylexjs/stylex';
7
+ import {Button} from '@astryxdesign/core/Button';
8
+ import {useFocusTrap, useScrollLock} from '@astryxdesign/core/hooks';
9
+ import {VStack} from '@astryxdesign/core/Layout';
10
+ import {Link} from '@astryxdesign/core/Link';
11
+ import {colorVars, spacingVars} from '@astryxdesign/core/theme/tokens.stylex';
12
+
13
+ const styles = stylex.create({
14
+ menu: {
15
+ width: '100%',
16
+ height: '100%',
17
+ maxWidth: 'none',
18
+ maxHeight: 'none',
19
+ margin: 0,
20
+ borderWidth: 0,
21
+ overflowY: 'auto',
22
+ padding: spacingVars['--spacing-4'],
23
+ color: colorVars['--color-text-primary'],
24
+ backgroundColor: colorVars['--color-background-surface'],
25
+ },
26
+ });
27
+
28
+ const MENU_ITEMS = ['Products', 'Pricing', 'Customers', 'Support'];
29
+
30
+ export default function UseScrollLockHookUsage() {
31
+ const [isOpen, setIsOpen] = useState(false);
32
+ useScrollLock(isOpen);
33
+ const {containerRef, focusFirst} = useFocusTrap<HTMLDialogElement>({
34
+ isActive: isOpen,
35
+ onEscape: close,
36
+ });
37
+
38
+ // The dialog leaves the top layer before the state change, so the page is
39
+ // no longer inert when the focus trap hands focus back to Menu.
40
+ function close() {
41
+ containerRef.current?.close();
42
+ setIsOpen(false);
43
+ }
44
+
45
+ useEffect(() => {
46
+ const dialog = containerRef.current;
47
+ if (isOpen && dialog != null && !dialog.open) {
48
+ dialog.showModal();
49
+ focusFirst();
50
+ }
51
+ }, [isOpen, containerRef, focusFirst]);
52
+
53
+ return (
54
+ <>
55
+ <Button label="Menu" onClick={() => setIsOpen(true)} />
56
+ <dialog
57
+ ref={containerRef}
58
+ aria-label="Menu"
59
+ onCancel={event => {
60
+ event.preventDefault();
61
+ close();
62
+ }}
63
+ {...stylex.props(styles.menu)}>
64
+ <nav aria-label="Site menu">
65
+ <VStack gap={4} hAlign="start">
66
+ <Button label="Close menu" variant="secondary" onClick={close} />
67
+ {MENU_ITEMS.map(item => (
68
+ <Link
69
+ key={item}
70
+ href={`#menu-${item.toLowerCase()}`}
71
+ onClick={close}>
72
+ {item}
73
+ </Link>
74
+ ))}
75
+ </VStack>
76
+ </nav>
77
+ </dialog>
78
+ </>
79
+ );
80
+ }
@@ -0,0 +1,21 @@
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: 'useOverlay',
7
+ name: 'useOverlay — Product Quick View',
8
+ displayName: 'useOverlay — Product Quick View',
9
+ description:
10
+ 'A product card that is its own overlay container: useOverlay returns the ref and props to spread on the Card and a bottom strip to render once over the image. Hovering the card, or moving keyboard focus into it, slides in a Quick view button along the bottom of the image, and leaving hides it again. The image is a link that the strip leaves clickable above it, and Tab lands on it first so the next Tab reaches Quick view.',
11
+ isReady: true,
12
+ aspectRatio: 4 / 3,
13
+ componentsUsed: [
14
+ 'Overlay',
15
+ 'Card',
16
+ 'AspectRatio',
17
+ 'Button',
18
+ 'Layout',
19
+ 'Text',
20
+ ],
21
+ };
@@ -0,0 +1,49 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ import type {RefObject} from 'react';
6
+ import {AspectRatio} from '@astryxdesign/core/AspectRatio';
7
+ import {Button} from '@astryxdesign/core/Button';
8
+ import {Card} from '@astryxdesign/core/Card';
9
+ import {VStack} from '@astryxdesign/core/Layout';
10
+ import {useOverlay} from '@astryxdesign/core/Overlay';
11
+ import {Text} from '@astryxdesign/core/Text';
12
+
13
+ export default function UseOverlayHookUsage() {
14
+ const overlay = useOverlay({
15
+ showOn: 'hover',
16
+ position: 'bottom',
17
+ align: 'center',
18
+ content: <Button label="Quick view" variant="secondary" size="sm" />,
19
+ });
20
+
21
+ return (
22
+ <Card
23
+ width={280}
24
+ padding={0}
25
+ ref={overlay.containerRef as RefObject<HTMLDivElement | null>}
26
+ {...overlay.containerProps}>
27
+ <div style={{position: 'relative'}}>
28
+ <a href="#ceramic-mug">
29
+ <AspectRatio ratio={1}>
30
+ <img
31
+ src="/template-assets/light-product-1.png"
32
+ alt="Ceramic mug"
33
+ style={{width: '100%', height: '100%', objectFit: 'cover'}}
34
+ />
35
+ </AspectRatio>
36
+ </a>
37
+ {overlay.element}
38
+ </div>
39
+ <VStack gap={1} padding={3}>
40
+ <Text type="body" weight="bold">
41
+ Ceramic mug
42
+ </Text>
43
+ <Text type="supporting" color="secondary">
44
+ $24
45
+ </Text>
46
+ </VStack>
47
+ </Card>
48
+ );
49
+ }
@@ -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: 'useTableSortableState',
7
+ name: 'useTableSortableState — Multi-Sort Orders',
8
+ displayName: 'useTableSortableState — Multi-Sort Orders',
9
+ description:
10
+ 'Orders with no sort code of their own: useTableSortableState owns the sort state, returns the sorted orders, and hands useTableSortable a ready config. Click Customer, then Shift-click Total, to sort by customer and then by total within each customer. A line above the orders reads the current sort state from the hook.',
11
+ isReady: true,
12
+ aspectRatio: 4 / 3,
13
+ componentsUsed: ['Table', 'Layout', 'Text'],
14
+ };
@@ -0,0 +1,61 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ import {VStack} from '@astryxdesign/core/Layout';
6
+ import {
7
+ Table,
8
+ useTableSortable,
9
+ useTableSortableState,
10
+ } from '@astryxdesign/core/Table';
11
+ import type {TableColumn} from '@astryxdesign/core/Table';
12
+ import {Text} from '@astryxdesign/core/Text';
13
+
14
+ interface Order extends Record<string, unknown> {
15
+ id: string;
16
+ customer: string;
17
+ total: number;
18
+ }
19
+
20
+ const orders: Order[] = [
21
+ {id: '1042', customer: 'Chen', total: 85},
22
+ {id: '1043', customer: 'Ana', total: 120},
23
+ {id: '1044', customer: 'Ben', total: 40},
24
+ {id: '1045', customer: 'Ana', total: 35},
25
+ {id: '1046', customer: 'Chen', total: 15},
26
+ {id: '1047', customer: 'Ben', total: 210},
27
+ {id: '1048', customer: 'Ana', total: 60},
28
+ ];
29
+
30
+ const columns: TableColumn<Order>[] = [
31
+ {key: 'id', header: 'Order'},
32
+ {key: 'customer', header: 'Customer', sortable: true},
33
+ {key: 'total', header: 'Total ($)', sortable: true, align: 'end'},
34
+ ];
35
+
36
+ export default function UseTableSortableStateHookUsage() {
37
+ const {sortedData, sort, sortConfig} = useTableSortableState<Order>({
38
+ data: orders,
39
+ isMultiSortEnabled: true,
40
+ });
41
+ const sortablePlugin = useTableSortable<Order>(sortConfig);
42
+
43
+ return (
44
+ <VStack gap={3}>
45
+ <Text type="supporting" color="secondary">
46
+ Sorted by:{' '}
47
+ {sort.length === 0
48
+ ? 'none'
49
+ : sort
50
+ .map(({sortKey, direction}) => `${sortKey} ${direction}`)
51
+ .join(', then ')}
52
+ </Text>
53
+ <Table
54
+ data={sortedData}
55
+ columns={columns}
56
+ idKey="id"
57
+ plugins={{sortable: sortablePlugin}}
58
+ />
59
+ </VStack>
60
+ );
61
+ }
@@ -15,8 +15,8 @@ export const neutralPaletteRefs = {
15
15
  dark: {25: '#2b422b', 80: '#aad4a9', 85: '#bce0bb'},
16
16
  },
17
17
  neutral: {
18
- light: {0: '#000000', 5: '#111111', 10: '#1b1b1b', 30: '#474747', 45: '#6a6a6a', 60: '#919191', 85: '#d4d4d4', 90: '#e2e2e2', 95: '#f1f1f1', 100: '#ffffff'},
19
- dark: {0: '#000000', 5: '#111111', 10: '#1b1b1b', 15: '#262626', 20: '#303030', 35: '#525252', 65: '#9e9e9e', 85: '#d4d4d4', 90: '#e2e2e2', 95: '#f1f1f1', 100: '#ffffff'},
18
+ light: {0: '#000000', 5: '#111111', 10: '#1b1b1b', 30: '#474747', 35: '#525252', 45: '#6a6a6a', 60: '#919191', 85: '#d4d4d4', 90: '#e2e2e2', 95: '#f1f1f1', 100: '#ffffff'},
19
+ dark: {0: '#000000', 5: '#111111', 10: '#1b1b1b', 15: '#262626', 20: '#303030', 30: '#474747', 35: '#525252', 65: '#9e9e9e', 75: '#b9b9b9', 80: '#c6c6c6', 85: '#d4d4d4', 90: '#e2e2e2', 95: '#f1f1f1', 100: '#ffffff'},
20
20
  },
21
21
  orange: {
22
22
  light: {25: '#622700', 30: '#733100', 75: '#ff9e55', 85: '#ffc7a1'},
@@ -17,17 +17,17 @@ const neutralSyntax = defineSyntaxTheme({
17
17
  tokens: {
18
18
  keyword: [purple.light[30], purple.light[80]],
19
19
  string: [green.light[30], green.light[80]],
20
- comment: [neutral.light[45], neutral.dark[65]],
20
+ comment: [neutral.light[35], neutral.dark[75]],
21
21
  number: [orange.light[30], orange.dark[80]],
22
22
  function: [blue.light[30], blue.dark[80]],
23
23
  type: [purple.light[30], purple.light[80]],
24
24
  variable: [neutral.light[5], neutral.dark[90]],
25
- operator: [neutral.light[45], neutral.dark[65]],
25
+ operator: [neutral.light[35], neutral.dark[75]],
26
26
  constant: [orange.light[30], orange.dark[80]],
27
27
  tag: [red.light[30], red.dark[80]],
28
28
  attribute: [yellow.light[30], yellow.light[80]],
29
29
  property: [teal.light[30], teal.light[80]],
30
- punctuation: [neutral.light[45], neutral.dark[65]],
30
+ punctuation: [neutral.light[35], neutral.dark[75]],
31
31
  background: [neutral.light[100], neutral.dark[5]],
32
32
  },
33
33
  });
@@ -94,7 +94,7 @@ export const neutralTheme = defineTheme({
94
94
  '--color-background-muted': [neutral.light[95], neutral.dark[10]],
95
95
 
96
96
  '--color-accent': [neutral.light[10], neutral.dark[95]],
97
- '--color-accent-muted': [neutral.light[95], neutral.dark[15]],
97
+ '--color-accent-muted': [neutral.light[85], neutral.dark[30]],
98
98
  '--color-neutral': [
99
99
  withAlpha(neutral.light[0], '0F'),
100
100
  withAlpha(neutral.dark[100], '1A'),
@@ -273,6 +273,32 @@ export const neutralTheme = defineTheme({
273
273
  },
274
274
 
275
275
  components: {
276
+ // In dark mode, secondary text falls under 4.5:1 on the selected fill
277
+ // and under its hover. Selected rows use the next stop that clears both.
278
+ item: {
279
+ selected: {
280
+ '--color-text-secondary': `light-dark(${neutral.light[30]}, ${neutral.dark[80]})`,
281
+ },
282
+ },
283
+ 'tree-list-item': {
284
+ selected: {
285
+ '--color-text-secondary': `light-dark(${neutral.light[30]}, ${neutral.dark[80]})`,
286
+ },
287
+ },
288
+ // A dropzone's hint sits on the same fill while a file is dragged over.
289
+ // That state has no target, so the dropzone takes the lift at rest too.
290
+ 'file-input': {
291
+ 'mode:dropzone': {
292
+ '--color-text-secondary': `light-dark(${neutral.light[30]}, ${neutral.dark[80]})`,
293
+ },
294
+ },
295
+ // A numbered citation is a pill on the same fill.
296
+ citation: {
297
+ 'variant:number': {
298
+ '--color-text-secondary': `light-dark(${neutral.light[30]}, ${neutral.dark[80]})`,
299
+ },
300
+ },
301
+
276
302
  button: {
277
303
  'variant:destructive': {
278
304
  backgroundColor: 'var(--color-error-muted)',
@@ -346,6 +346,18 @@ export const myTheme = defineTheme({
346
346
  */
347
347
  // iconVariants: ['outline', 'filled'],
348
348
 
349
+ /**
350
+ * Choose which shared icon a component's own icon role uses, by slot, such
351
+ * as `code-block-copy` for CodeBlock's copy button. A value is an icon name,
352
+ * `null` to hide the icon, a partial `{icon, variant, size}` request, or a
353
+ * pure function of the slot's state that returns one.
354
+ * Keep a slot function in its own module and import it, so a built theme
355
+ * can import it too. Here `copySlot` is
356
+ * `({copied}) => ({icon: copied ? 'checkDouble' : 'copy'})`.
357
+ * Reference: `astryx docs icons`; each component's docs list its slots.
358
+ */
359
+ // componentIcons: {'code-block-copy': copySlot},
360
+
349
361
  /**
350
362
  * Replace the small components that DRAW control state — the checkbox box,
351
363
  * the radio dot, the mark on a chosen option — by indicator name rather than
@@ -549,6 +549,47 @@ export interface ComponentThemingVar {
549
549
  private?: boolean;
550
550
  }
551
551
 
552
+ /**
553
+ * A component icon slot: a themeable icon role the component owns, which a
554
+ * theme maps to a shared icon name through `defineTheme({componentIcons})`.
555
+ * Each entry corresponds to a slot in `ComponentIconSlotMap`.
556
+ *
557
+ * @example
558
+ * ```
559
+ * {
560
+ * slot: 'code-block-copy',
561
+ * description: 'The copy button icon.',
562
+ * fallback: '`copy`; `check` while copied',
563
+ * state: [{name: 'copied', type: 'boolean', description: 'True while the copied feedback shows.'}],
564
+ * whenNull: 'Hides the glyph. The button keeps its size, name, and tooltip.',
565
+ * }
566
+ * ```
567
+ */
568
+ // SYNC: When adding a field here, add it to the docsite's generated-registry
569
+ // copy too — apps/docsite/scripts/generate-data.mjs (interface ComponentIconSlot).
570
+ export interface ComponentIconSlotDoc {
571
+ /** The slot name, `<component-kebab>-<semantic-role>`. */
572
+ slot: string;
573
+ /** The icon's role in the component. */
574
+ description: string;
575
+ /** The icon the component renders when the theme maps nothing, per state. */
576
+ fallback: string;
577
+ /** The state a slot function receives. Omit for a stateless slot. */
578
+ state?: ComponentIconSlotStateDoc[];
579
+ /** What a slot value of `null` does for this component. */
580
+ whenNull: string;
581
+ }
582
+
583
+ /** One field of the state a component passes to a slot function. */
584
+ export interface ComponentIconSlotStateDoc {
585
+ /** The field name. */
586
+ name: string;
587
+ /** The field's TypeScript type. */
588
+ type: string;
589
+ /** When the field has each value. */
590
+ description: string;
591
+ }
592
+
552
593
  /**
553
594
  * Documents a hook parameter/option. Similar to ComponentPropDoc but for hook
554
595
  * arguments and options object fields.
@@ -102,7 +102,7 @@ export const doc = {
102
102
  },
103
103
  {
104
104
  name: 'theming',
105
- type: '{ container?: boolean; targets: ComponentThemingTarget[]; vars?: ComponentThemingVar[]; derived?: ComponentThemingDerivedVar[] }',
105
+ type: '{ container?: boolean; targets: ComponentThemingTarget[]; vars?: ComponentThemingVar[]; derived?: ComponentThemingDerivedVar[]; componentIcons?: ComponentIconSlotDoc[] }',
106
106
  description:
107
107
  'Theming configuration: the stable selector surface (astryx-* classes + data-attribute reflections) that themes target via @scope selectors in defineTheme.',
108
108
  fields: [
@@ -130,6 +130,12 @@ export const doc = {
130
130
  description:
131
131
  "Maps standard CSS properties to internal vars for theme-pipeline expansion. Ordered by priority: earlier entries emit first. The pipeline reads only Core components' entries, so an integration's have no effect.",
132
132
  },
133
+ {
134
+ name: 'theming.componentIcons',
135
+ type: 'ComponentIconSlotDoc[]',
136
+ description:
137
+ "The component's icon slots, which a theme maps through `defineTheme({componentIcons})`: each slot's name, role, fallback per state, the state a slot function receives, and what `null` does. Each entry corresponds to a slot in `ComponentIconSlotMap`.",
138
+ },
133
139
  ],
134
140
  },
135
141
  {
@@ -10,6 +10,7 @@ import type {
10
10
  ComponentAnatomyElement,
11
11
  ComponentBestPractice,
12
12
  ComponentExampleDoc,
13
+ ComponentIconSlotDoc,
13
14
  ComponentPlaygroundConfig,
14
15
  ComponentPropDoc,
15
16
  ComponentThemingDerivedVar,
@@ -162,6 +163,10 @@ export interface ComponentBaseDoc extends AuthoredDocGraphFields {
162
163
  * on this component, also emit the internal var.
163
164
  * @see ComponentThemingDerivedVar */
164
165
  derived?: ComponentThemingDerivedVar[];
166
+ /** Component icon slots this component resolves through the theme's
167
+ * `componentIcons`. Each entry corresponds to a slot in
168
+ * `ComponentIconSlotMap`. */
169
+ componentIcons?: ComponentIconSlotDoc[];
165
170
  };
166
171
  /** Component usage documentation — concise summary, best practices,
167
172
  * and optional visual anatomy. */
@@ -138,6 +138,8 @@ export type {
138
138
  ComponentThemingTarget,
139
139
  ComponentThemingVar,
140
140
  ComponentThemingDerivedVar,
141
+ ComponentIconSlotDoc,
142
+ ComponentIconSlotStateDoc,
141
143
  UsageDoc,
142
144
  // hook
143
145
  HookParamDoc,
@@ -163,6 +163,34 @@ function getTargetStates(target) {
163
163
  return target.states || [];
164
164
  }
165
165
 
166
+ /**
167
+ * Format a component's icon slots: the `componentIcons` keys a theme sets,
168
+ * with each slot's state, fallback, and what `null` does.
169
+ * @param {any[]} slots - `theming.componentIcons` entries.
170
+ * @returns {string}
171
+ */
172
+ function formatComponentIconSlots(slots) {
173
+ const lines = [
174
+ '**Component icon slots** - set in `defineTheme({componentIcons})` to a shared icon name, `null`, a partial `{icon, variant, size}` request, or a function of the slot state.\n',
175
+ '| Slot | State | Fallback | Role | `null` |',
176
+ '|------|-------|----------|------|--------|',
177
+ ];
178
+ for (const slot of slots) {
179
+ const state = slot.state?.length
180
+ ? slot.state
181
+ .map(
182
+ (/** @type {any} */ field) =>
183
+ `\`${mdCell(field.name)}: ${mdCell(field.type)}\` ${mdCell(field.description)}`,
184
+ )
185
+ .join('<br>')
186
+ : 'none';
187
+ lines.push(
188
+ `| \`${mdCell(slot.slot)}\` | ${state} | ${mdCell(slot.fallback)} | ${mdCell(slot.description)} | ${mdCell(slot.whenNull)} |`,
189
+ );
190
+ }
191
+ return lines.join('\n') + '\n';
192
+ }
193
+
166
194
  /**
167
195
  * Format the theming targets table, merging in theme variants if available.
168
196
  *
@@ -351,6 +379,10 @@ export function formatFull(docs, options = {}) {
351
379
  }
352
380
  }
353
381
 
382
+ if (docs.theming.componentIcons?.length) {
383
+ sections.push(formatComponentIconSlots(docs.theming.componentIcons));
384
+ }
385
+
354
386
  // Legacy componentKey (for backward compatibility)
355
387
  if (docs.theming.componentKey) {
356
388
  sections.push(`Component key: \`${docs.theming.componentKey}\`\n`);
@@ -507,6 +539,11 @@ export function formatCompact(docs, componentName, importHint) {
507
539
  sections.push(propLines.join('\n') + '\n');
508
540
  }
509
541
 
542
+ if (docs.theming?.componentIcons?.length) {
543
+ sections.push('## Component Icon Slots\n');
544
+ sections.push(formatComponentIconSlots(docs.theming.componentIcons));
545
+ }
546
+
510
547
  return sections.join('\n');
511
548
  }
512
549
 
@@ -626,6 +663,18 @@ export function formatBrief(docs, componentName, importHint, options = {}) {
626
663
  output.push(` Derived: ${derivedNames}`);
627
664
  }
628
665
 
666
+ // Component icon slots, with the state each slot function receives
667
+ if (docs.theming?.componentIcons?.length) {
668
+ const slots = docs.theming.componentIcons
669
+ .map((/** @type {any} */ slot) =>
670
+ slot.state?.length
671
+ ? `${slot.slot} {${slot.state.map((/** @type {any} */ field) => `${field.name}: ${field.type}`).join(', ')}}`
672
+ : slot.slot,
673
+ )
674
+ .join('; ');
675
+ output.push(` Icon slots: ${slots}`);
676
+ }
677
+
629
678
  // Theme targets (component class, preferred data attrs, props, states) with theme variant merging
630
679
  if (docs.theming?.targets?.length) {
631
680
  const {themeData = null} = options;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.7.9-canary.df15de7",
3
+ "version": "0.7.9-canary.e191eed",
4
4
  "displayName": "CLI",
5
5
  "description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
6
6
  "author": "Meta Open Source",
@@ -124,10 +124,10 @@
124
124
  "zod": "^4.4.3"
125
125
  },
126
126
  "peerDependencies": {
127
- "@astryxdesign/charts": "0.7.9-canary.df15de7",
128
- "@astryxdesign/core": "0.7.9-canary.df15de7",
129
- "@astryxdesign/lab": "0.7.9-canary.df15de7",
130
- "@astryxdesign/theme-neutral": "0.7.9-canary.df15de7"
127
+ "@astryxdesign/charts": "0.7.9-canary.e191eed",
128
+ "@astryxdesign/core": "0.7.9-canary.e191eed",
129
+ "@astryxdesign/lab": "0.7.9-canary.e191eed",
130
+ "@astryxdesign/theme-neutral": "0.7.9-canary.e191eed"
131
131
  },
132
132
  "peerDependenciesMeta": {
133
133
  "@astryxdesign/charts": {
@@ -144,10 +144,10 @@
144
144
  }
145
145
  },
146
146
  "devDependencies": {
147
- "@astryxdesign/charts": "0.7.9-canary.df15de7",
148
- "@astryxdesign/core": "0.7.9-canary.df15de7",
149
- "@astryxdesign/lab": "0.7.9-canary.df15de7",
150
- "@astryxdesign/theme-neutral": "0.7.9-canary.df15de7",
147
+ "@astryxdesign/charts": "0.7.9-canary.e191eed",
148
+ "@astryxdesign/core": "0.7.9-canary.e191eed",
149
+ "@astryxdesign/lab": "0.7.9-canary.e191eed",
150
+ "@astryxdesign/theme-neutral": "0.7.9-canary.e191eed",
151
151
  "@heroicons/react": "^2.2.0",
152
152
  "@stylexjs/stylex": "^0.19.0",
153
153
  "@types/babel__core": "^7.20.5",