@astryxdesign/cli 0.7.13 → 0.7.14-canary.108f354

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 (164) hide show
  1. package/README.md +18 -18
  2. package/api/component/__fixtures__/resolutions/modules.txt +1 -1
  3. package/api/doctor/doctor.mjs +3 -7
  4. package/api/experimental.d.mts +2 -0
  5. package/api/experimental.mjs +12 -0
  6. package/api/icon/_adapter.d.mts +10 -0
  7. package/api/icon/_adapter.mjs +31 -2
  8. package/api/icon/_authoring.d.mts +2 -1
  9. package/api/icon/_authoring.mjs +91 -6
  10. package/api/icon/_options.mjs +1 -0
  11. package/api/icon/_records.d.mts +18 -0
  12. package/api/icon/_records.mjs +26 -0
  13. package/api/icon/add/add.mjs +7 -1
  14. package/api/icon/definitions/definitions.d.mts +12 -0
  15. package/api/icon/definitions/definitions.mjs +83 -0
  16. package/api/icon/icon.doc.mjs +5 -4
  17. package/api/icon/icon.mjs +5 -16
  18. package/api/icon/icon.type.d.mts +29 -2
  19. package/api/icon/icon.type.mjs +17 -3
  20. package/api/icon/iconAdd.doc.mjs +1 -1
  21. package/api/icon/iconMap.doc.mjs +2 -2
  22. package/api/icon/iconNewSet.doc.mjs +8 -2
  23. package/api/icon/map/map.mjs +21 -2
  24. package/api/icon/new-set/new-set.mjs +14 -2
  25. package/api/icon/search/search.mjs +2 -15
  26. package/api/icon/use/use.mjs +4 -3
  27. package/api/integration/validate-integration.mjs +6 -1
  28. package/api/integration/validate-integration.type.d.mts +12 -0
  29. package/api/integration/validate-integration.type.mjs +5 -0
  30. package/api/theme-edit/_adapter.d.mts +116 -0
  31. package/api/theme-edit/_adapter.mjs +1683 -0
  32. package/api/theme-edit/_catalog.d.mts +59 -0
  33. package/api/theme-edit/_catalog.mjs +564 -0
  34. package/api/theme-edit/_check.d.mts +49 -0
  35. package/api/theme-edit/_check.mjs +845 -0
  36. package/api/theme-edit/_color.d.mts +29 -0
  37. package/api/theme-edit/_color.mjs +300 -0
  38. package/api/theme-edit/_compiler.d.mts +61 -0
  39. package/api/theme-edit/_compiler.mjs +522 -0
  40. package/api/theme-edit/_css-properties.d.mts +10 -0
  41. package/api/theme-edit/_css-properties.mjs +556 -0
  42. package/api/theme-edit/_parts.d.mts +111 -0
  43. package/api/theme-edit/_parts.mjs +409 -0
  44. package/api/theme-edit/_png.d.mts +40 -0
  45. package/api/theme-edit/_png.mjs +187 -0
  46. package/api/theme-edit/_preview.d.mts +121 -0
  47. package/api/theme-edit/_preview.mjs +720 -0
  48. package/api/theme-edit/_project.d.mts +83 -0
  49. package/api/theme-edit/_project.mjs +289 -0
  50. package/api/theme-edit/_settings.d.mts +222 -0
  51. package/api/theme-edit/_settings.mjs +861 -0
  52. package/api/theme-edit/_tables.d.mts +132 -0
  53. package/api/theme-edit/_tables.mjs +700 -0
  54. package/api/theme-edit/theme-edit.d.mts +93 -0
  55. package/api/theme-edit/theme-edit.mjs +145 -0
  56. package/api/theme-edit/theme-edit.type.d.mts +413 -0
  57. package/api/theme-edit/theme-edit.type.mjs +233 -0
  58. package/api/theme-edit/themeEditHow.doc.d.mts +6 -0
  59. package/api/theme-edit/themeEditHow.doc.mjs +88 -0
  60. package/api/theme-edit/themeEditNew.doc.d.mts +6 -0
  61. package/api/theme-edit/themeEditNew.doc.mjs +89 -0
  62. package/api/theme-edit/themeEditPreviewAdd.doc.d.mts +6 -0
  63. package/api/theme-edit/themeEditPreviewAdd.doc.mjs +100 -0
  64. package/api/theme-edit/themeEditPreviewApp.doc.d.mts +6 -0
  65. package/api/theme-edit/themeEditPreviewApp.doc.mjs +84 -0
  66. package/api/theme-edit/themeEditPreviewList.doc.d.mts +6 -0
  67. package/api/theme-edit/themeEditPreviewList.doc.mjs +53 -0
  68. package/api/theme-edit/themeEditPreviewRemove.doc.d.mts +6 -0
  69. package/api/theme-edit/themeEditPreviewRemove.doc.mjs +66 -0
  70. package/api/theme-edit/themeEditSet.doc.d.mts +6 -0
  71. package/api/theme-edit/themeEditSet.doc.mjs +165 -0
  72. package/api/theme-edit/themeEditShow.doc.d.mts +6 -0
  73. package/api/theme-edit/themeEditShow.doc.mjs +86 -0
  74. package/api/theme-edit/themeEditUndo.doc.d.mts +6 -0
  75. package/api/theme-edit/themeEditUndo.doc.mjs +124 -0
  76. package/assets/docs/color.doc.mjs +5 -5
  77. package/assets/docs/tree/icon-sets.doc.mjs +6 -2
  78. package/assets/docs/tree/tokens-border.doc.mjs +1 -1
  79. package/assets/docs/tree/tokens-color.doc.mjs +2 -2
  80. package/assets/docs/tree/tokens-data.doc.mjs +2 -2
  81. package/assets/docs/tree/tokens-duration.doc.mjs +1 -1
  82. package/assets/docs/tree/tokens-ease.doc.mjs +1 -1
  83. package/assets/docs/tree/tokens-focus.doc.mjs +1 -1
  84. package/assets/docs/tree/tokens-font-weight.doc.mjs +1 -1
  85. package/assets/docs/tree/tokens-radius.doc.mjs +1 -1
  86. package/assets/docs/tree/tokens-shadow.doc.mjs +1 -1
  87. package/assets/docs/tree/tokens-size.doc.mjs +1 -1
  88. package/assets/docs/tree/tokens-spacing.doc.mjs +1 -1
  89. package/assets/docs/tree/tokens-syntax.doc.mjs +1 -1
  90. package/assets/docs/tree/tokens-text-size.doc.mjs +1 -1
  91. package/assets/docs/tree/tokens-type-scale.doc.mjs +1 -1
  92. package/assets/docs/tree/tokens-typography.doc.mjs +1 -1
  93. package/assets/icons/definitions/bank.doc.mjs +1 -1
  94. package/assets/icons/definitions/save.doc.mjs +1 -1
  95. package/assets/preview-app/README.md +6 -0
  96. package/assets/preview-app/css.d.ts +5 -0
  97. package/assets/preview-app/gitignore +1 -0
  98. package/assets/preview-app/next.config.mjs +6 -0
  99. package/assets/preview-app/package.json +23 -0
  100. package/assets/preview-app/src/app/globals.css +5 -0
  101. package/assets/preview-app/src/app/layout.tsx +21 -0
  102. package/assets/preview-app/src/app/page.tsx +94 -0
  103. package/assets/preview-app/src/app/providers.tsx +16 -0
  104. package/assets/preview-app/tsconfig.json +27 -0
  105. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.doc.mjs +2 -1
  106. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider02Overrides.doc.mjs +2 -1
  107. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider03RtlDirection.doc.mjs +2 -1
  108. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider04Calendar.doc.mjs +2 -1
  109. package/assets/templates/blocks/components/Text/useTruncationHookUsage.doc.mjs +14 -0
  110. package/assets/templates/blocks/components/Text/useTruncationHookUsage.tsx +112 -0
  111. package/authoring/doctypes/_schema.d.mts +1 -0
  112. package/authoring/doctypes/_schema.mjs +1 -0
  113. package/authoring/doctypes/command/command.doc.mjs +7 -0
  114. package/authoring/doctypes/command/type.ts +3 -0
  115. package/authoring/doctypes/icon-set/parse.d.mts +7 -0
  116. package/authoring/doctypes/icon-set/parse.mjs +18 -8
  117. package/clients/cli/commands/doctor.mjs +33 -3
  118. package/clients/cli/commands/experimental/icon.mjs +67 -14
  119. package/clients/cli/commands/experimental/index.mjs +2 -0
  120. package/clients/cli/commands/experimental/theme.mjs +684 -0
  121. package/clients/cli/commands/experimental-icon-new-set.doc.mjs +7 -1
  122. package/clients/cli/commands/experimental-icon.doc.mjs +3 -2
  123. package/clients/cli/commands/experimental-theme-add.doc.mjs +78 -0
  124. package/clients/cli/commands/experimental-theme-compile.doc.mjs +97 -0
  125. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +84 -0
  126. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +66 -0
  127. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +121 -0
  128. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +66 -0
  129. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +104 -0
  130. package/clients/cli/commands/experimental-theme-editor.doc.mjs +49 -0
  131. package/clients/cli/commands/experimental-theme-eject.doc.mjs +71 -0
  132. package/clients/cli/commands/experimental-theme-list.doc.mjs +49 -0
  133. package/clients/cli/commands/experimental-theme-palette-generate.doc.mjs +73 -0
  134. package/clients/cli/commands/experimental-theme-palette.doc.mjs +37 -0
  135. package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +86 -0
  136. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +66 -0
  137. package/clients/cli/commands/experimental-theme-preview-list.doc.mjs +48 -0
  138. package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +59 -0
  139. package/clients/cli/commands/experimental-theme-preview.doc.mjs +40 -0
  140. package/clients/cli/commands/experimental-theme-remove.doc.mjs +55 -0
  141. package/clients/cli/commands/experimental-theme-targets.doc.mjs +61 -0
  142. package/clients/cli/commands/experimental-theme-template.doc.mjs +61 -0
  143. package/clients/cli/commands/experimental-theme-use.doc.mjs +55 -0
  144. package/clients/cli/commands/experimental-theme.doc.mjs +57 -0
  145. package/clients/cli/commands/experimental.doc.mjs +10 -3
  146. package/clients/cli/commands/theme.mjs +101 -34
  147. package/clients/cli/index.mjs +18 -0
  148. package/clients/cli/lib/define-command.mjs +3 -0
  149. package/foundation/discovery/icon-set-checks.d.mts +16 -1
  150. package/foundation/discovery/icon-set-checks.mjs +68 -7
  151. package/foundation/discovery/icon-set-discovery.d.mts +21 -6
  152. package/foundation/discovery/icon-set-discovery.mjs +17 -8
  153. package/foundation/discovery/template-icon-meanings.d.mts +39 -0
  154. package/foundation/discovery/template-icon-meanings.mjs +95 -0
  155. package/foundation/discovery/theming-targets.d.mts +6 -0
  156. package/foundation/discovery/theming-targets.mjs +33 -0
  157. package/foundation/response/error-codes.d.mts +12 -1
  158. package/foundation/response/error-codes.doc.mjs +66 -0
  159. package/foundation/response/error-codes.mjs +55 -0
  160. package/foundation/response/response-types.doc.mjs +55 -0
  161. package/foundation/text/template-meanings-line.d.mts +16 -0
  162. package/foundation/text/template-meanings-line.mjs +37 -0
  163. package/foundation/xle/browser.d.mts +2 -2
  164. package/package.json +6 -6
@@ -0,0 +1,59 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * Every component name an element tree uses.
6
+ * @param {unknown} v
7
+ * @param {Set<string>} [out]
8
+ * @returns {Set<string>}
9
+ */
10
+ export function elementNames(v: unknown, out?: Set<string>): Set<string>;
11
+ /**
12
+ * The page module source for a list of items. Each item renders on its own,
13
+ * so one component that throws leaves the rest of the page. With a theme,
14
+ * each item renders inside `<Theme>`; a theme with both modes follows the
15
+ * viewer's scheme, and a bar of three CSS-only switches (auto, light, dark)
16
+ * flips it, since the file runs no script.
17
+ * @param {object} spec
18
+ * @param {CatalogItem[]} spec.items
19
+ * @param {Record<string, string>} spec.imports component name -> module specifier
20
+ * @param {{module: string, css: string[], mode: 'system' | 'light' | 'dark'} | null} spec.theme
21
+ * module and css are import specifiers relative to the page
22
+ * @param {'catalog' | 'sheet' | 'page'} spec.layout
23
+ * @param {string} [spec.title]
24
+ * @returns {string}
25
+ */
26
+ export function pageSource({ items, imports, theme, layout, title }: {
27
+ items: CatalogItem[];
28
+ imports: Record<string, string>;
29
+ theme: {
30
+ module: string;
31
+ css: string[];
32
+ mode: "system" | "light" | "dark";
33
+ } | null;
34
+ layout: "catalog" | "sheet" | "page";
35
+ title?: string | undefined;
36
+ }): string;
37
+ /** Components without playground defaults, set up by hand. @type {Array<[string, Array<[string, Tree]>]>} */
38
+ export const EXTRA: Array<[string, Array<[string, Tree]>]>;
39
+ /** Overlays rendered open, so their surfaces, borders and shadows show. */
40
+ export const OPEN_OVERLAYS: Array<[string, Array<[string, Tree]>]>;
41
+ /** The sample app page every preview shows. */
42
+ export const SAMPLE_PAGE: Tree;
43
+ /** Components left off the contact sheet: they cover the page, or only lay out others. */
44
+ export const SHEET_SKIP: Set<string>;
45
+ /** Components first on the contact sheet, in this order. */
46
+ export const SHEET_ORDER: string[];
47
+ /** The light and dark switches, and the contact sheet grid. */
48
+ export const SHEET_CSS: string;
49
+ export type Tree = {
50
+ __element: string;
51
+ props?: Record<string, unknown>;
52
+ children?: unknown;
53
+ };
54
+ export type CatalogItem = {
55
+ name: string;
56
+ label: string;
57
+ tree: unknown;
58
+ group?: string;
59
+ };
@@ -0,0 +1,564 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file The pages `astryx experimental theme` renders: a catalog of every
5
+ * component (to learn what each part reads, and for the contact sheet) and a
6
+ * sample app page (the preview). Each page is written as a page module and
7
+ * rendered by the same machinery as `astryx experimental render`, with the
8
+ * project's own React and Core.
9
+ *
10
+ * Pages are element trees (`{__element, props, children}`), the shape of a
11
+ * component doc's playground defaults, so a component the installed Core
12
+ * does not have renders as nothing instead of breaking the page.
13
+ *
14
+ * @position api/theme-edit — page sources for the part data and previews
15
+ */
16
+
17
+ /**
18
+ * @typedef {{__element: string, props?: Record<string, unknown>, children?: unknown}} Tree
19
+ * @typedef {{name: string, label: string, tree: unknown, group?: string}} CatalogItem
20
+ */
21
+
22
+ /** @param {string} name @param {Record<string, unknown>} [props] @param {...unknown} children @returns {Tree} */
23
+ const h = (name, props = {}, ...children) => ({
24
+ __element: name,
25
+ props,
26
+ ...(children.length ? {children} : {}),
27
+ });
28
+
29
+ /** Components without playground defaults, set up by hand. @type {Array<[string, Array<[string, Tree]>]>} */
30
+ export const EXTRA = [
31
+ [
32
+ 'Heading',
33
+ [1, 2, 3, 4].map(level => [
34
+ `level ${level}`,
35
+ h('Heading', {level}, `Heading ${level}`),
36
+ ]),
37
+ ],
38
+ [
39
+ 'TextInput',
40
+ [
41
+ ['', h('TextInput', {label: 'Name', value: 'Jordan'})],
42
+ [
43
+ 'disabled',
44
+ h('TextInput', {label: 'Disabled', value: '-', isDisabled: true}),
45
+ ],
46
+ ],
47
+ ],
48
+ ['TextArea', [['', h('TextArea', {label: 'Notes', value: 'Some notes'})]]],
49
+ ['NumberInput', [['', h('NumberInput', {label: 'Count', value: 3})]]],
50
+ [
51
+ 'CheckboxInput',
52
+ [
53
+ ['on', h('CheckboxInput', {label: 'Checked', value: true})],
54
+ ['off', h('CheckboxInput', {label: 'Unchecked', value: false})],
55
+ ],
56
+ ],
57
+ [
58
+ 'Switch',
59
+ [
60
+ ['on', h('Switch', {label: 'On', value: true})],
61
+ ['off', h('Switch', {label: 'Off', value: false})],
62
+ ],
63
+ ],
64
+ [
65
+ 'ProgressBar',
66
+ ['accent', 'success', 'warning', 'error'].map(v => [
67
+ v,
68
+ h('ProgressBar', {label: v, variant: v, value: 60}),
69
+ ]),
70
+ ],
71
+ [
72
+ 'TabList',
73
+ [
74
+ [
75
+ '',
76
+ h(
77
+ 'TabList',
78
+ {value: 'a'},
79
+ h('Tab', {value: 'a', label: 'Selected'}),
80
+ h('Tab', {value: 'b', label: 'Other'}),
81
+ ),
82
+ ],
83
+ ],
84
+ ],
85
+ [
86
+ 'SegmentedControl',
87
+ [
88
+ [
89
+ '',
90
+ h(
91
+ 'SegmentedControl',
92
+ {label: 'Range', value: 'a'},
93
+ h('SegmentedControlItem', {value: 'a', label: 'Day'}),
94
+ h('SegmentedControlItem', {value: 'b', label: 'Week'}),
95
+ ),
96
+ ],
97
+ ],
98
+ ],
99
+ [
100
+ 'TopNav',
101
+ [
102
+ [
103
+ '',
104
+ h(
105
+ 'TopNav',
106
+ {label: 'Top', heading: 'App'},
107
+ h('TopNavItem', {label: 'Selected', href: '#', isSelected: true}),
108
+ h('TopNavItem', {label: 'Other', href: '#'}),
109
+ ),
110
+ ],
111
+ ],
112
+ ],
113
+ [
114
+ 'SideNav',
115
+ [
116
+ [
117
+ '',
118
+ h(
119
+ 'SideNav',
120
+ {label: 'Side'},
121
+ h('SideNavItem', {label: 'Selected', href: '#', isSelected: true}),
122
+ h('SideNavItem', {label: 'Other', href: '#'}),
123
+ ),
124
+ ],
125
+ ],
126
+ ],
127
+ [
128
+ 'StatusDot',
129
+ ['success', 'warning', 'error', 'accent', 'neutral'].map(v => [
130
+ v,
131
+ h('StatusDot', {variant: v, label: v}),
132
+ ]),
133
+ ],
134
+ ];
135
+
136
+ /** Overlays rendered open, so their surfaces, borders and shadows show. */
137
+ export const OPEN_OVERLAYS =
138
+ /** @type {Array<[string, Array<[string, Tree]>]>} */ ([
139
+ [
140
+ 'Dialog',
141
+ [
142
+ [
143
+ 'open',
144
+ {
145
+ __element: 'Dialog',
146
+ props: {isOpen: true, isInline: true, width: 360},
147
+ children: [
148
+ {
149
+ __element: 'VStack',
150
+ props: {gap: 2},
151
+ children: [
152
+ {
153
+ __element: 'Heading',
154
+ props: {level: 3},
155
+ children: ['Dialog title'],
156
+ },
157
+ {
158
+ __element: 'Text',
159
+ props: {type: 'body'},
160
+ children: ['Are you sure you want to proceed?'],
161
+ },
162
+ ],
163
+ },
164
+ ],
165
+ },
166
+ ],
167
+ ],
168
+ ],
169
+ [
170
+ 'AlertDialog',
171
+ [
172
+ [
173
+ 'open',
174
+ {
175
+ __element: 'AlertDialog',
176
+ props: {
177
+ isOpen: true,
178
+ isInline: true,
179
+ title: 'Delete item?',
180
+ description: 'This cannot be undone.',
181
+ actionLabel: 'Delete',
182
+ },
183
+ },
184
+ ],
185
+ ],
186
+ ],
187
+ [
188
+ 'Popover',
189
+ [
190
+ [
191
+ 'open',
192
+ {
193
+ __element: 'Popover',
194
+ props: {
195
+ isOpen: true,
196
+ content: {
197
+ __element: 'Text',
198
+ props: {type: 'body'},
199
+ children: ['Popover content'],
200
+ },
201
+ },
202
+ children: [
203
+ {
204
+ __element: 'Button',
205
+ props: {label: 'Anchor', variant: 'secondary'},
206
+ },
207
+ ],
208
+ },
209
+ ],
210
+ ],
211
+ ],
212
+ [
213
+ 'Tooltip',
214
+ [
215
+ [
216
+ 'open',
217
+ {
218
+ __element: 'Tooltip',
219
+ props: {isOpen: true, content: 'Tooltip text'},
220
+ children: [
221
+ {
222
+ __element: 'Button',
223
+ props: {label: 'Hover me', variant: 'secondary'},
224
+ },
225
+ ],
226
+ },
227
+ ],
228
+ ],
229
+ ],
230
+ [
231
+ 'HoverCard',
232
+ [
233
+ [
234
+ 'open',
235
+ {
236
+ __element: 'HoverCard',
237
+ props: {
238
+ isOpen: true,
239
+ content: {
240
+ __element: 'Text',
241
+ props: {type: 'body'},
242
+ children: ['More details'],
243
+ },
244
+ },
245
+ children: [
246
+ {
247
+ __element: 'Link',
248
+ props: {href: '#'},
249
+ children: ['Hover for details'],
250
+ },
251
+ ],
252
+ },
253
+ ],
254
+ ],
255
+ ],
256
+ ]);
257
+
258
+ const ROWS = [
259
+ {id: 1, task: 'Review Q4 roadmap', owner: 'Alex', status: 'In progress'},
260
+ {id: 2, task: 'Ship onboarding flow', owner: 'Sam', status: 'Done'},
261
+ {id: 3, task: 'Fix login timeout', owner: 'Riley', status: 'Blocked'},
262
+ ];
263
+
264
+ /** The sample app page every preview shows. */
265
+ export const SAMPLE_PAGE = h(
266
+ 'AppShell',
267
+ {
268
+ height: 'auto',
269
+ contentPadding: 4,
270
+ topNav: h('TopNav', {
271
+ label: 'Main',
272
+ heading: h('Text', {weight: 'bold'}, 'Open Items'),
273
+ startContent: h(
274
+ 'HStack',
275
+ {gap: 1},
276
+ h('TopNavItem', {label: 'Inbox', href: '#', isSelected: true}),
277
+ h('TopNavItem', {label: 'Projects', href: '#'}),
278
+ h('TopNavItem', {label: 'Reports', href: '#'}),
279
+ ),
280
+ endContent: h('Button', {
281
+ label: 'New item',
282
+ variant: 'primary',
283
+ size: 'sm',
284
+ }),
285
+ }),
286
+ sideNav: h(
287
+ 'SideNav',
288
+ {label: 'Sections'},
289
+ h('SideNavItem', {label: 'My tasks', href: '#', isSelected: true}),
290
+ h('SideNavItem', {label: 'Team', href: '#'}),
291
+ h('SideNavItem', {label: 'Archive', href: '#'}),
292
+ ),
293
+ },
294
+ h(
295
+ 'VStack',
296
+ {gap: 4},
297
+ h(
298
+ 'VStack',
299
+ {gap: 1},
300
+ h('Heading', {level: 1, type: 'display-2'}, 'Plan the week ahead'),
301
+ h(
302
+ 'Text',
303
+ {type: 'supporting'},
304
+ 'Everything your team is working on, in one place.',
305
+ ),
306
+ ),
307
+ h('Heading', {level: 2}, 'My tasks'),
308
+ h('Banner', {
309
+ status: 'info',
310
+ title: 'Weekly sync moved to Thursday',
311
+ description: 'The agenda doc is updated.',
312
+ collapsible: false,
313
+ }),
314
+ h(
315
+ 'TabList',
316
+ {value: 'open'},
317
+ h('Tab', {value: 'open', label: 'Open'}),
318
+ h('Tab', {value: 'done', label: 'Done'}),
319
+ h('Tab', {value: 'all', label: 'All'}),
320
+ ),
321
+ h(
322
+ 'HStack',
323
+ {gap: 4, align: 'start'},
324
+ h(
325
+ 'Card',
326
+ {width: 340},
327
+ h(
328
+ 'VStack',
329
+ {gap: 3},
330
+ h(
331
+ 'HStack',
332
+ {gap: 2, align: 'center'},
333
+ h('Heading', {level: 3}, 'New task'),
334
+ h('Badge', {variant: 'info', label: 'Draft'}),
335
+ h('Badge', {variant: 'neutral', label: 'Personal'}),
336
+ ),
337
+ h('TextInput', {label: 'Title', value: 'Prepare launch notes'}),
338
+ h('Switch', {label: 'Notify my team', value: true}),
339
+ h('CheckboxInput', {label: 'Add to calendar', value: true}),
340
+ h('ProgressBar', {label: 'Progress', value: 60, hasValueLabel: true}),
341
+ h(
342
+ 'HStack',
343
+ {gap: 2},
344
+ h('Button', {label: 'Save', variant: 'primary'}),
345
+ h('Button', {label: 'Preview', variant: 'secondary'}),
346
+ h('Button', {label: 'Cancel', variant: 'ghost'}),
347
+ h('Button', {label: 'Delete', variant: 'destructive'}),
348
+ ),
349
+ ),
350
+ ),
351
+ h(
352
+ 'Card',
353
+ {width: 400},
354
+ h(
355
+ 'VStack',
356
+ {gap: 3},
357
+ h('Heading', {level: 3}, 'This week'),
358
+ h('Table', {
359
+ data: ROWS,
360
+ idKey: 'id',
361
+ columns: [
362
+ {key: 'task', header: 'Task'},
363
+ {key: 'owner', header: 'Owner'},
364
+ {key: 'status', header: 'Status'},
365
+ ],
366
+ }),
367
+ h(
368
+ 'HStack',
369
+ {gap: 2, align: 'center'},
370
+ h('StatusDot', {variant: 'success', label: 'ok'}),
371
+ h('Badge', {variant: 'success', label: '2 done'}),
372
+ h('StatusDot', {variant: 'warning', label: 'risk'}),
373
+ h('Badge', {variant: 'warning', label: '1 at risk'}),
374
+ h('StatusDot', {variant: 'error', label: 'blocked'}),
375
+ h('Badge', {variant: 'error', label: '1 blocked'}),
376
+ ),
377
+ ),
378
+ ),
379
+ ),
380
+ ),
381
+ );
382
+
383
+ /** Components left off the contact sheet: they cover the page, or only lay out others. */
384
+ export const SHEET_SKIP = new Set([
385
+ 'Lightbox',
386
+ 'CommandPalette',
387
+ 'Drawer',
388
+ 'BottomSheet',
389
+ 'Overlay',
390
+ 'Toast',
391
+ 'Tooltip',
392
+ 'HoverCard',
393
+ 'Popover',
394
+ 'Dialog',
395
+ 'AlertDialog',
396
+ 'AspectRatio',
397
+ 'Center',
398
+ 'Layout',
399
+ 'ScrollableArea',
400
+ 'Grid',
401
+ 'Stack',
402
+ ]);
403
+
404
+ /** Components first on the contact sheet, in this order. */
405
+ export const SHEET_ORDER = [
406
+ 'Heading',
407
+ 'Text',
408
+ 'Button',
409
+ 'Badge',
410
+ 'Banner',
411
+ 'Card',
412
+ 'TextInput',
413
+ 'TextArea',
414
+ 'NumberInput',
415
+ 'Selector',
416
+ 'CheckboxInput',
417
+ 'Switch',
418
+ 'ProgressBar',
419
+ 'TabList',
420
+ 'SegmentedControl',
421
+ 'TopNav',
422
+ 'SideNav',
423
+ 'Table',
424
+ 'StatusDot',
425
+ ];
426
+
427
+ /**
428
+ * Every component name an element tree uses.
429
+ * @param {unknown} v
430
+ * @param {Set<string>} [out]
431
+ * @returns {Set<string>}
432
+ */
433
+ export function elementNames(v, out = new Set()) {
434
+ if (Array.isArray(v)) for (const x of v) elementNames(x, out);
435
+ else if (v && typeof v === 'object') {
436
+ const el = /** @type {any} */ (v).__element;
437
+ if (typeof el === 'string') out.add(el);
438
+ for (const x of Object.values(v)) elementNames(x, out);
439
+ }
440
+ return out;
441
+ }
442
+
443
+ /**
444
+ * The page module source for a list of items. Each item renders on its own,
445
+ * so one component that throws leaves the rest of the page. With a theme,
446
+ * each item renders inside `<Theme>`; a theme with both modes follows the
447
+ * viewer's scheme, and a bar of three CSS-only switches (auto, light, dark)
448
+ * flips it, since the file runs no script.
449
+ * @param {object} spec
450
+ * @param {CatalogItem[]} spec.items
451
+ * @param {Record<string, string>} spec.imports component name -> module specifier
452
+ * @param {{module: string, css: string[], mode: 'system' | 'light' | 'dark'} | null} spec.theme
453
+ * module and css are import specifiers relative to the page
454
+ * @param {'catalog' | 'sheet' | 'page'} spec.layout
455
+ * @param {string} [spec.title]
456
+ * @returns {string}
457
+ */
458
+ export function pageSource({items, imports, theme, layout, title = ''}) {
459
+ /** @type {Map<string, string[]>} */
460
+ const byModule = new Map();
461
+ for (const [name, spec] of Object.entries(imports)) {
462
+ const list = byModule.get(spec) ?? [];
463
+ list.push(name);
464
+ byModule.set(spec, list);
465
+ }
466
+ const lines = [
467
+ '// Generated by astryx experimental theme. It is rebuilt on every run.',
468
+ "import * as React from 'react';",
469
+ "import {renderToStaticMarkup} from 'react-dom/server';",
470
+ ];
471
+ if (theme) {
472
+ lines.push("import {Theme} from '@astryxdesign/core/theme';");
473
+ lines.push(`import * as ThemeModule from ${JSON.stringify(theme.module)};`);
474
+ for (const c of theme.css) lines.push(`import ${JSON.stringify(c)};`);
475
+ }
476
+ const entries = [];
477
+ let i = 0;
478
+ for (const [spec, names] of byModule) {
479
+ lines.push(`import * as M${i} from ${JSON.stringify(spec)};`);
480
+ for (const n of names)
481
+ entries.push(`${JSON.stringify(n)}: M${i}[${JSON.stringify(n)}]`);
482
+ i++;
483
+ }
484
+ lines.push(`const C = {${entries.join(', ')}};`);
485
+ lines.push('const noop = () => {};');
486
+ lines.push(
487
+ 'const HANDLERS = ["onChange", "onClick", "onDismiss", "onOpenChange", "onSelect", "onValueChange"];',
488
+ );
489
+ lines.push(
490
+ 'function el(v) { if (Array.isArray(v)) return v.map(el); if (v && typeof v === "object" && v.__element) { const T = C[v.__element]; if (!T) return null; return React.createElement(T, fix(v.props ?? {}), ...[].concat(v.children ?? []).map(el)); } return v; }',
491
+ );
492
+ lines.push(
493
+ 'function fix(p) { const o = {}; for (const [k, v] of Object.entries(p)) o[k] = v && typeof v === "object" && !Array.isArray(v) && v.__element ? el(v) : v; for (const k of HANDLERS) if (!(k in o)) o[k] = noop; return o; }',
494
+ );
495
+ lines.push(`const ITEMS = ${JSON.stringify(items)};`);
496
+ lines.push(
497
+ theme
498
+ ? 'const theme = Object.values(ThemeModule).find(v => v && typeof v === "object" && typeof v.name === "string");'
499
+ : 'const theme = null;',
500
+ );
501
+ lines.push(`const MODE = ${JSON.stringify(theme?.mode ?? 'light')};`);
502
+ lines.push(
503
+ 'function html(tree) { try { const node = el(tree); return renderToStaticMarkup(theme ? React.createElement(Theme, {theme, mode: MODE}, node) : node); } catch { return null; } }',
504
+ );
505
+ lines.push(`const LAYOUT = ${JSON.stringify(layout)};`);
506
+ lines.push(`const TITLE = ${JSON.stringify(title)};`);
507
+ lines.push(`const SHEET_CSS = ${JSON.stringify(SHEET_CSS)};`);
508
+ lines.push(`const h = React.createElement;
509
+ export default function Page() {
510
+ if (LAYOUT === 'catalog') {
511
+ return h('div', null, ITEMS.map((it, i) => {
512
+ const markup = html(it.tree);
513
+ return markup == null ? null : h('section', {key: i, 'data-cat': it.name, dangerouslySetInnerHTML: {__html: markup}});
514
+ }));
515
+ }
516
+ const done = ITEMS.map(it => ({...it, markup: html(it.tree)})).filter(it => it.markup != null);
517
+ const bar = MODE === 'system'
518
+ ? h('div', {className: 'cs-bar'}, h('strong', null, TITLE),
519
+ ['auto', 'light', 'dark'].map(m => h('label', {key: m}, h('input', {type: 'radio', name: 'cs-mode', id: 'cs-' + m, defaultChecked: m === 'auto'}), ' ' + m)))
520
+ : h('div', {className: 'cs-bar'}, h('strong', null, TITLE), h('span', null, MODE + ' only'));
521
+ let body;
522
+ if (LAYOUT === 'page') {
523
+ body = done.map((it, i) => h('div', {key: i, dangerouslySetInnerHTML: {__html: it.markup}}));
524
+ } else {
525
+ const groups = [];
526
+ for (const it of done) {
527
+ let g = groups.find(x => x.name === (it.group ?? ''));
528
+ if (!g) { g = {name: it.group ?? '', cells: []}; groups.push(g); }
529
+ let c = g.cells.find(x => x.name === it.name);
530
+ if (!c) { c = {name: it.name, list: []}; g.cells.push(c); }
531
+ if (!c.list.some(x => x.label === it.label)) c.list.push(it);
532
+ }
533
+ body = groups.map(g => h('section', {key: g.name, className: 'cs-group'},
534
+ g.name ? h('h2', {className: 'cs-group-name'}, g.name) : null,
535
+ h('div', {className: g.name === 'pages' ? 'cs-pages' : 'cs-sheet'}, g.cells.map(c => h('div', {key: c.name, className: 'cs-cell'},
536
+ h('div', {className: 'cs-name'}, c.name),
537
+ h('div', {className: 'cs-row'}, c.list.map((x, j) => h('div', {key: j, className: 'cs-item'},
538
+ x.label ? h('div', {className: 'cs-label'}, x.label) : null,
539
+ h('div', {dangerouslySetInnerHTML: {__html: x.markup}})))))))));
540
+ }
541
+ const page = h('div', {className: 'cs-page', style: {background: 'var(--color-background-body)', color: 'var(--color-text-primary)', minHeight: '100vh'}}, bar, body);
542
+ return h('main', null, h('style', {dangerouslySetInnerHTML: {__html: SHEET_CSS}}), theme ? h(Theme, {theme, mode: MODE}, page) : page);
543
+ }`);
544
+ return `${lines.join('\n')}\n`;
545
+ }
546
+
547
+ /** The light and dark switches, and the contact sheet grid. */
548
+ export const SHEET_CSS = [
549
+ 'body{margin:0}',
550
+ '.cs-bar{position:sticky;top:0;z-index:100;display:flex;gap:14px;align-items:center;padding:8px 14px;font:12px ui-monospace,monospace;background:Canvas;color:CanvasText;border-bottom:1px solid #8884}',
551
+ 'body:has(#cs-light:checked),body:has(#cs-light:checked) [data-astryx-theme]{color-scheme:light!important}',
552
+ 'body:has(#cs-dark:checked),body:has(#cs-dark:checked) [data-astryx-theme]{color-scheme:dark!important}',
553
+ '.cs-group-name{font:600 14px ui-monospace,monospace;margin:16px 14px 0;opacity:.75}',
554
+ '.cs-sheet{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px;padding:14px}',
555
+ '.cs-pages{display:grid;grid-template-columns:minmax(0,1fr);gap:14px;padding:14px}',
556
+ '.cs-cell{border:1px dashed #8885;padding:10px;overflow:hidden;max-height:340px}',
557
+ '.cs-pages .cs-cell{max-height:none}',
558
+ '.cs-name{font:600 12px ui-monospace,monospace;opacity:.6;margin-bottom:8px}',
559
+ '.cs-row{display:flex;flex-wrap:wrap;gap:10px;align-items:flex-start}',
560
+ '.cs-label{font:10px ui-monospace,monospace;opacity:.5}',
561
+ '.cs-item{max-width:100%;position:relative}',
562
+ // Overlays shown open in place: a layer the page would open with script.
563
+ '.cs-cell [popover]{display:block!important;position:relative!important;inset:auto!important;margin:8px 0 0!important;translate:none!important;transform:none!important}',
564
+ ].join('');
@@ -0,0 +1,49 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * Check one setting and give it back ready to store, or refuse.
6
+ * @param {import('./_settings.mjs').Ctx} ctx
7
+ * @param {string} slug
8
+ * @param {import('./_settings.mjs').ThemeData} data
9
+ * @param {string} thing
10
+ * @param {string | undefined} value
11
+ * @param {SetFlags} flags
12
+ * @param {boolean} [unset] an undo of one setting: only the identity of the setting is checked
13
+ * @returns {import('./_settings.mjs').Setting}
14
+ */
15
+ export function checkSetting(ctx: import("./_settings.mjs").Ctx, slug: string, data: import("./_settings.mjs").ThemeData, thing: string, value: string | undefined, flags: SetFlags, unset?: boolean): import("./_settings.mjs").Setting;
16
+ /**
17
+ * Answer a plain-words question with exact commands: the parts it names,
18
+ * the aspects it asks about, and what each part really reads for them.
19
+ * @param {import('./_settings.mjs').Ctx} ctx
20
+ * @param {string} question
21
+ * @returns {{parts: string[], aspects: string[], results: Array<{text: string, commands: string[]}>}}
22
+ */
23
+ export function answerHow(ctx: import("./_settings.mjs").Ctx, question: string): {
24
+ parts: string[];
25
+ aspects: string[];
26
+ results: Array<{
27
+ text: string;
28
+ commands: string[];
29
+ }>;
30
+ };
31
+ /**
32
+ * The tokens most parts read for one aspect, for a whole-theme change.
33
+ * @param {import('./_settings.mjs').Ctx} ctx
34
+ * @param {string} aspect
35
+ * @returns {Array<{text: string, commands: string[]}>}
36
+ */
37
+ export function wholeThemeTokens(ctx: import("./_settings.mjs").Ctx, aspect: string): Array<{
38
+ text: string;
39
+ commands: string[];
40
+ }>;
41
+ /** The aspects `how` answers at the whole-theme level. */
42
+ export const ASPECTS: string[];
43
+ export type SetFlags = {
44
+ on?: string | undefined;
45
+ when?: string | undefined;
46
+ state?: string | undefined;
47
+ mode?: string | undefined;
48
+ only?: boolean | undefined;
49
+ };