@astryxdesign/cli 0.7.9-canary.4d7dca6 → 0.7.9-canary.4e963df

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 (61) hide show
  1. package/README.md +1 -1
  2. package/api/component/__fixtures__/resolutions/modules.txt +5 -5
  3. package/api/search/_candidate-score.mjs +25 -23
  4. package/api/search/_words.d.mts +44 -7
  5. package/api/search/_words.mjs +113 -21
  6. package/api/swizzle/_adapter.d.mts +10 -0
  7. package/api/swizzle/_adapter.mjs +24 -1
  8. package/api/swizzle/copy/copy.d.mts +17 -1
  9. package/api/swizzle/copy/copy.mjs +249 -9
  10. package/api/swizzle/swizzle.doc.mjs +1 -1
  11. package/api/swizzle/swizzle.type.mjs +1 -1
  12. package/api/theme/build/build.mjs +342 -72
  13. package/api/theme/build/core-interception.mjs +92 -29
  14. package/api/theme/build/icon-imports.d.mts +35 -4
  15. package/api/theme/build/icon-imports.mjs +299 -38
  16. package/assets/discover/official-packages.json +4 -0
  17. package/assets/docs/author-a-theme.doc.mjs +3 -1
  18. package/assets/docs/icons.doc.mjs +29 -0
  19. package/assets/docs/motion.doc.mjs +1 -1
  20. package/assets/docs/tree/calendars.doc.mjs +1 -1
  21. package/assets/templates/blocks/components/Calendar/useCalendarDaysHookUsage.doc.mjs +14 -0
  22. package/assets/templates/blocks/components/Calendar/useCalendarDaysHookUsage.tsx +71 -0
  23. package/assets/templates/blocks/components/Hooks/useInputContainerHookUsage.doc.mjs +15 -0
  24. package/assets/templates/blocks/components/Hooks/useInputContainerHookUsage.tsx +93 -0
  25. package/assets/templates/blocks/components/Hooks/useMergedRefsHookUsage.doc.mjs +14 -0
  26. package/assets/templates/blocks/components/Hooks/useMergedRefsHookUsage.tsx +78 -0
  27. package/assets/templates/blocks/components/Hooks/useScrollLockHookUsage.doc.mjs +14 -0
  28. package/assets/templates/blocks/components/Hooks/useScrollLockHookUsage.tsx +80 -0
  29. package/assets/templates/blocks/components/Hooks/useScrollOverflowHookUsage.doc.mjs +14 -0
  30. package/assets/templates/blocks/components/Hooks/useScrollOverflowHookUsage.tsx +94 -0
  31. package/assets/templates/blocks/components/Icon/useIconHookUsage.doc.mjs +19 -0
  32. package/assets/templates/blocks/components/Icon/useIconHookUsage.tsx +68 -0
  33. package/assets/templates/blocks/components/Link/useLinkComponentHookUsage.doc.mjs +14 -0
  34. package/assets/templates/blocks/components/Link/useLinkComponentHookUsage.tsx +89 -0
  35. package/assets/templates/blocks/components/Overlay/useOverlayHookUsage.doc.mjs +21 -0
  36. package/assets/templates/blocks/components/Overlay/useOverlayHookUsage.tsx +49 -0
  37. package/assets/templates/blocks/components/Table/useTableSortableStateHookUsage.doc.mjs +14 -0
  38. package/assets/templates/blocks/components/Table/useTableSortableStateHookUsage.tsx +61 -0
  39. package/assets/templates/blocks/components/usePanGesture/PanDraggableBox.doc.mjs +15 -0
  40. package/assets/templates/blocks/components/usePanGesture/PanDraggableBox.tsx +98 -0
  41. package/assets/templates/blocks/components/usePanGesture/PanPlayingCard.doc.mjs +14 -0
  42. package/assets/templates/blocks/components/usePanGesture/PanPlayingCard.tsx +147 -0
  43. package/assets/theme.template.ts +14 -2
  44. package/authoring/doctypes/base/type.ts +41 -0
  45. package/authoring/doctypes/component/component.doc.mjs +7 -1
  46. package/authoring/doctypes/component/type.ts +5 -0
  47. package/authoring/index.d.ts +2 -0
  48. package/clients/cli/commands/swizzle.mjs +10 -0
  49. package/clients/cli/lib/component-format.mjs +49 -0
  50. package/foundation/config/project.mjs +27 -9
  51. package/foundation/discovery/component-discovery.mjs +17 -6
  52. package/foundation/env/search-path.d.mts +12 -0
  53. package/foundation/env/search-path.mjs +71 -43
  54. package/foundation/integrations/manifest-writer.d.mts +3 -4
  55. package/foundation/integrations/manifest-writer.mjs +5 -3
  56. package/foundation/response/response-types.doc.mjs +1 -1
  57. package/foundation/text/levenshtein.d.mts +4 -1
  58. package/foundation/text/levenshtein.mjs +44 -1
  59. package/package.json +9 -9
  60. package/api/swizzle/_github.d.mts +0 -8
  61. package/api/swizzle/_github.mjs +0 -22
@@ -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
+ }
@@ -0,0 +1,15 @@
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: 'usePanGesture',
7
+ alsoExampleFor: ['createPanGesture'],
8
+ name: 'usePanGesture — A draggable box',
9
+ displayName: 'usePanGesture — A draggable box',
10
+ description:
11
+ 'The smallest pan example, in two forms side by side: the usePanGesture hook and the createPanGesture factory. The factory takes any element, React or not. Each card names its API, follows a drag from a finger, a mouse or a pen, and springs back, with the same StyleX styles. A starting point for a draggable tile, a swipe or any drag-and-release gesture.',
12
+ isReady: true,
13
+ aspectRatio: 4 / 3,
14
+ componentsUsed: ['Card', 'Center', 'HStack'],
15
+ };
@@ -0,0 +1,98 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ import {useCallback, useRef, useState, type Ref} from 'react';
6
+ import * as stylex from '@stylexjs/stylex';
7
+ import {createPanGesture} from '@astryxdesign/core';
8
+ import {Card} from '@astryxdesign/core/Card';
9
+ import {Center} from '@astryxdesign/core/Center';
10
+ import {HStack} from '@astryxdesign/core/HStack';
11
+ import {usePanGesture, type PanGestureEvent} from '@astryxdesign/core/hooks';
12
+ import {
13
+ colorVars,
14
+ durationVars,
15
+ easeVars,
16
+ radiusVars,
17
+ } from '@astryxdesign/core/theme/tokens.stylex';
18
+
19
+ const styles = stylex.create({
20
+ // A wash under the stage, so the box on top reads in light and dark themes.
21
+ stage: {
22
+ backgroundColor: colorVars['--color-neutral'],
23
+ borderRadius: radiusVars['--radius-container'],
24
+ },
25
+ box: {cursor: 'grab', userSelect: 'none'},
26
+ // Let go, the box springs back, unless the person reduces motion.
27
+ springBack: {
28
+ transition: {
29
+ default: `translate ${durationVars['--duration-medium']} ${easeVars['--ease-move']}`,
30
+ '@media (prefers-reduced-motion: reduce)': 'none',
31
+ },
32
+ },
33
+ drag: (x: number, y: number) => ({translate: `${x}px ${y}px`}),
34
+ });
35
+
36
+ type Drag = {x: number; y: number; held: boolean};
37
+ const REST: Drag = {x: 0, y: 0, held: false};
38
+
39
+ /** The box follows a held drag and goes back to rest when it ends. */
40
+ function nextDrag({state, translation}: PanGestureEvent): Drag {
41
+ const held = state === 'began' || state === 'changed';
42
+ return held ? {...translation, held} : REST;
43
+ }
44
+
45
+ /** The same stage and card for both forms; the card names its API. */
46
+ function DraggableBox(props: {
47
+ name: string;
48
+ ref: Ref<HTMLDivElement>;
49
+ drag: Drag;
50
+ }) {
51
+ const {name, ref, drag} = props;
52
+ return (
53
+ <Center width="min(280px, 80vw)" height={180} xstyle={styles.stage}>
54
+ <Card
55
+ ref={ref}
56
+ padding={6}
57
+ elevation="med"
58
+ xstyle={[
59
+ styles.box,
60
+ styles.drag(drag.x, drag.y),
61
+ !drag.held && styles.springBack,
62
+ ]}>
63
+ {name}
64
+ </Card>
65
+ </Center>
66
+ );
67
+ }
68
+
69
+ function WithHook() {
70
+ const box = useRef<HTMLDivElement>(null);
71
+ const [drag, setDrag] = useState(REST);
72
+ usePanGesture(box, {onPan: event => setDrag(nextDrag(event))});
73
+ return <DraggableBox name="usePanGesture" ref={box} drag={drag} />;
74
+ }
75
+
76
+ function WithFactory() {
77
+ const [drag, setDrag] = useState(REST);
78
+ // A callback ref: its cleanup takes the pan down with the box.
79
+ const draggable = useCallback((box: HTMLDivElement | null) => {
80
+ if (box == null) {
81
+ return undefined;
82
+ }
83
+ const pan = createPanGesture(box, {
84
+ onPan: event => setDrag(nextDrag(event)),
85
+ });
86
+ return () => pan.destroy();
87
+ }, []);
88
+ return <DraggableBox name="createPanGesture" ref={draggable} drag={drag} />;
89
+ }
90
+
91
+ export default function PanDraggableBox() {
92
+ return (
93
+ <HStack gap={6} wrap="wrap" justify="center">
94
+ <WithHook />
95
+ <WithFactory />
96
+ </HStack>
97
+ );
98
+ }
@@ -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: 'usePanGesture',
7
+ name: 'usePanGesture — A playing card (advanced)',
8
+ displayName: 'usePanGesture — A playing card (advanced)',
9
+ description:
10
+ 'An advanced usePanGesture example: a playing card follows a drag, settles back on a gentle release and flies off on a quick flick, while a Discard button deals the next card from the keyboard and announces it. Drag, settle and throw are StyleX styles driven by React state. A pattern for swipe-to-dismiss, card decks and flick gestures.',
11
+ isReady: true,
12
+ aspectRatio: 4 / 3,
13
+ componentsUsed: ['Button', 'Card', 'Center', 'Text', 'VStack'],
14
+ };
@@ -0,0 +1,147 @@
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 {Button} from '@astryxdesign/core/Button';
8
+ import {Card} from '@astryxdesign/core/Card';
9
+ import {Center} from '@astryxdesign/core/Center';
10
+ import {useAnnounce, usePanGesture} from '@astryxdesign/core/hooks';
11
+ import {Text} from '@astryxdesign/core/Text';
12
+ import {VStack} from '@astryxdesign/core/VStack';
13
+ import {
14
+ colorVars,
15
+ durationVars,
16
+ easeVars,
17
+ radiusVars,
18
+ } from '@astryxdesign/core/theme/tokens.stylex';
19
+
20
+ const DECK = [
21
+ {face: 'A\u2660', name: 'Ace of spades'},
22
+ {face: 'K\u2665', name: 'King of hearts'},
23
+ {face: 'Q\u2663', name: 'Queen of clubs'},
24
+ {face: 'J\u2666', name: 'Jack of diamonds'},
25
+ ];
26
+ /** A release faster than this (px/s) throws the card away. */
27
+ const THROW_SPEED = 1000;
28
+ /** How far a thrown card travels while it fades, px. */
29
+ const THROW_DISTANCE = 160;
30
+ const EXIT = `${durationVars['--duration-exit']} ${easeVars['--ease-exit']}`;
31
+
32
+ const styles = stylex.create({
33
+ // A wash under the stage, so the card on top reads in light and dark themes.
34
+ stage: {
35
+ backgroundColor: colorVars['--color-neutral'],
36
+ borderRadius: radiusVars['--radius-container'],
37
+ overflow: 'hidden',
38
+ },
39
+ card: {cursor: 'grab', userSelect: 'none'},
40
+ // A gentle release settles the card back, unless the person reduces motion.
41
+ settle: {
42
+ transition: {
43
+ default: `translate ${durationVars['--duration-medium']} ${easeVars['--ease-move']}`,
44
+ '@media (prefers-reduced-motion: reduce)': 'none',
45
+ },
46
+ },
47
+ // A flick throws it off to one side as it fades.
48
+ thrown: {
49
+ opacity: 0,
50
+ transition: {
51
+ default: `translate ${EXIT}, opacity ${EXIT}`,
52
+ '@media (prefers-reduced-motion: reduce)': 'none',
53
+ },
54
+ },
55
+ drag: (x: number, y: number) => ({translate: `${x}px ${y}px`}),
56
+ });
57
+
58
+ type Pose = {x: number; y: number; motion: 'rest' | 'settle' | 'thrown'};
59
+
60
+ export default function PanPlayingCard() {
61
+ const card = useRef<HTMLDivElement>(null);
62
+ const [top, setTop] = useState(0);
63
+ const [pose, setPose] = useState<Pose>({x: 0, y: 0, motion: 'rest'});
64
+ const announce = useAnnounce();
65
+ /** A throw is in flight: the next card is dealt when it ends. */
66
+ const throwing = useRef(false);
67
+ /** The drag in progress met a throw: the rest of it moves nothing. */
68
+ const ignoringDrag = useRef(false);
69
+ const shown = DECK[top % DECK.length];
70
+
71
+ function discard(direction: number) {
72
+ const element = card.current;
73
+ // One throw at a time: a second Discard during it would deal twice.
74
+ if (element == null || throwing.current) {
75
+ return;
76
+ }
77
+ throwing.current = true;
78
+ ignoringDrag.current = true;
79
+ setPose({x: direction * THROW_DISTANCE, y: 0, motion: 'thrown'});
80
+ // The next card's face and its place at the center commit together.
81
+ const dealNext = () => {
82
+ throwing.current = false;
83
+ announce(`${shown.name} discarded`);
84
+ setTop(value => value + 1);
85
+ setPose({x: 0, y: 0, motion: 'rest'});
86
+ };
87
+ if (matchMedia('(prefers-reduced-motion: reduce)').matches) {
88
+ dealNext();
89
+ return;
90
+ }
91
+ // Once the throw's style applies, deal when its transitions settle: at
92
+ // the theme's duration, or at once when a stylesheet stops them.
93
+ requestAnimationFrame(() => {
94
+ const ends = element.getAnimations().map(animation => animation.finished);
95
+ void Promise.allSettled(ends).then(dealNext);
96
+ });
97
+ }
98
+
99
+ usePanGesture(card, {
100
+ onPan: ({state, translation, velocity}) => {
101
+ // A drag that meets a throw is ignored to its end, or the next card
102
+ // would jump to it.
103
+ if (state === 'began') {
104
+ ignoringDrag.current = throwing.current;
105
+ }
106
+ if (ignoringDrag.current) {
107
+ return;
108
+ }
109
+ if (state === 'began' || state === 'changed') {
110
+ setPose({...translation, motion: 'rest'});
111
+ } else if (state === 'ended' && Math.abs(velocity.x) > THROW_SPEED) {
112
+ discard(Math.sign(velocity.x));
113
+ } else {
114
+ setPose({x: 0, y: 0, motion: 'settle'});
115
+ }
116
+ },
117
+ });
118
+
119
+ return (
120
+ <VStack gap={4} padding={4} width="min(360px, 80vw)">
121
+ <Center height={280} xstyle={styles.stage}>
122
+ <Card
123
+ ref={card}
124
+ // An image's name is all a screen reader announces, so it names the
125
+ // card.
126
+ role="img"
127
+ aria-label={shown.name}
128
+ width={80}
129
+ height={112}
130
+ elevation="med"
131
+ xstyle={[
132
+ styles.card,
133
+ styles.drag(pose.x, pose.y),
134
+ pose.motion !== 'rest' && styles[pose.motion],
135
+ ]}>
136
+ <Center height="100%">
137
+ <Text size="3xl" weight="bold">
138
+ {shown.face}
139
+ </Text>
140
+ </Center>
141
+ </Card>
142
+ </Center>
143
+ {/* The drag's keyboard and assistive-technology path (WCAG 2.5.7). */}
144
+ <Button label="Discard the top card" onClick={() => discard(1)} />
145
+ </VStack>
146
+ );
147
+ }
@@ -181,8 +181,8 @@ export const myTheme = defineTheme({
181
181
  radius: {base: 4, multiplier: 1},
182
182
 
183
183
  /**
184
- * Motion. Two knobs set how its CSS feels (touch springs don't read them
185
- * yet):
184
+ * Motion. Two knobs set how it feels. tempo also times the touch springs;
185
+ * character sets only the CSS curves for now:
186
186
  * tempo — 1 is Astryx's own; 0.75 the quickest, 1.5 the slowest.
187
187
  * character — 'crisp' | 'standard' | 'expressive': the entrance and move
188
188
  * curves (--ease-entrance, --ease-move). --ease-exit, the curve for
@@ -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,
@@ -90,6 +90,16 @@ export function registerSwizzle(program) {
90
90
  ].join('\n'),
91
91
  ),
92
92
  ];
93
+ // Files the copy wrote outside the component folder: the owner modules
94
+ // and their unexported style modules (spec:AST-110 FR4).
95
+ const shared = (result.data.files ?? []).filter(f => f.startsWith('../'));
96
+ if (shared.length > 0) {
97
+ out.push(
98
+ text(
99
+ `Shared modules: ${shared.join(', ')} (copied whole; their imports between each other stay relative)`,
100
+ ),
101
+ );
102
+ }
93
103
 
94
104
  // StyleX build requirement — swizzled StyleX source throws on import
95
105
  // ("Unexpected 'stylex.create' call at runtime") unless the consumer's
@@ -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;
@@ -383,6 +383,15 @@ export function providerLedgerOf(project) {
383
383
  return PROVIDER_LEDGERS.get(project) ?? new Map();
384
384
  }
385
385
 
386
+ /**
387
+ * True when an integration's templates root exists, the only place its
388
+ * templates come from (discoverIntegrationTemplatesForOne).
389
+ * @param {any} integration
390
+ * @returns {boolean}
391
+ */
392
+ const hasTemplatesRoot = integration =>
393
+ integration?.templates != null && fs.existsSync(integration.templates);
394
+
386
395
  /**
387
396
  * The single API for reading resolved project configuration. Construct via the
388
397
  * async {@link Project.load} factory.
@@ -1259,15 +1268,24 @@ export class Project {
1259
1268
  * @returns {Promise<ProjectIntegrationIssue[]>}
1260
1269
  */
1261
1270
  async issues() {
1262
- // Template replacement validity depends on the combined Core + integration
1263
- // catalog. Resolve it first so issue results never depend on which discovery
1264
- // method the caller happened to invoke earlier.
1265
- await this.templates();
1266
- // Component replacement validity likewise depends on Core plus every
1267
- // integration's components.
1268
- await this.componentReplacements();
1269
- for (const integration of this.#loadedIntegrations) {
1270
- await this.#collectIssues(integration);
1271
+ // Each issue these passes find belongs to an integration, because Core's
1272
+ // templates and components declare no replacement. A project with no
1273
+ // integration skips them.
1274
+ if (this.#loadedIntegrations.length > 0) {
1275
+ // Template replacement validity depends on the combined Core +
1276
+ // integration catalog. Resolve it first so issue results never depend
1277
+ // on which discovery method the caller happened to invoke earlier. Only
1278
+ // an integration's own templates can replace one, so with none, Core's
1279
+ // templates stay unread.
1280
+ if (this.#loadedIntegrations.some(hasTemplatesRoot)) {
1281
+ await this.templates();
1282
+ }
1283
+ // Component replacement validity likewise depends on Core plus every
1284
+ // integration's components.
1285
+ await this.componentReplacements();
1286
+ for (const integration of this.#loadedIntegrations) {
1287
+ await this.#collectIssues(integration);
1288
+ }
1271
1289
  }
1272
1290
  // Return a stable copy so callers can't mutate internal state.
1273
1291
  return this.#issues.map(i => ({...i}));
@@ -766,12 +766,7 @@ function caseSpelledComponentSource(srcDir, name) {
766
766
  */
767
767
  export function resolveImportPath(coreDir, componentName) {
768
768
  const srcDir = path.join(coreDir, 'src');
769
- const pkgPath = path.join(coreDir, 'package.json');
770
- const pkg = pathExists(pkgPath)
771
- ? JSON.parse(fs.readFileSync(pkgPath, 'utf-8'))
772
- : null;
773
-
774
- const exportKeys = Object.keys(pkg?.exports || {});
769
+ const exportKeys = exportKeysOf(coreDir);
775
770
 
776
771
  // Priority 1: exact subpath export matching the component name (e.g. ./Heading)
777
772
  // This allows convenience re-export directories to win over the source directory.
@@ -799,6 +794,22 @@ export function resolveImportPath(coreDir, componentName) {
799
794
  return '@astryxdesign/core';
800
795
  }
801
796
 
797
+ /**
798
+ * The subpaths the package's `exports` map names, read once per operation:
799
+ * a search resolves the import of every component.
800
+ * @param {string} coreDir
801
+ * @returns {string[]}
802
+ */
803
+ function exportKeysOf(coreDir) {
804
+ const pkgPath = path.join(coreDir, 'package.json');
805
+ return oncePerListing(`export-keys\0${pkgPath}`, () => {
806
+ const pkg = pathExists(pkgPath)
807
+ ? JSON.parse(fs.readFileSync(pkgPath, 'utf-8'))
808
+ : null;
809
+ return Object.keys(pkg?.exports || {});
810
+ });
811
+ }
812
+
802
813
  /**
803
814
  * Does a package's `exports` map publish this subpath?
804
815
  *