@zeyos/zx 5.6.0 → 5.7.1

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 (227) hide show
  1. package/CHANGELOG.md +188 -0
  2. package/README.md +73 -7
  3. package/bin/zx-css.js +328 -0
  4. package/dist/types/components/account-menu/account-menu.d.ts +4 -2
  5. package/dist/types/components/activity-list/activity-list.d.ts +14 -8
  6. package/dist/types/components/agent-thread/ag-ui.d.ts +340 -0
  7. package/dist/types/components/agent-thread/agent-thread.d.ts +142 -14
  8. package/dist/types/components/agent-thread/ui-message-stream.d.ts +401 -0
  9. package/dist/types/components/app-sidebar/app-sidebar.d.ts +14 -8
  10. package/dist/types/components/breadcrumb/breadcrumb.d.ts +3 -3
  11. package/dist/types/components/calendar/calendar-model.d.ts +9 -2
  12. package/dist/types/components/calendar/calendar.d.ts +12 -4
  13. package/dist/types/components/chart/chart.d.ts +25 -13
  14. package/dist/types/components/checklist/checklist.d.ts +29 -0
  15. package/dist/types/components/code-editor/code-editor.d.ts +7 -2
  16. package/dist/types/components/composer/composer.d.ts +206 -4
  17. package/dist/types/components/composer/queue.d.ts +76 -0
  18. package/dist/types/components/copy/copy-button.d.ts +6 -4
  19. package/dist/types/components/copy/copy-input.d.ts +10 -6
  20. package/dist/types/components/datebox/date-range-box.d.ts +33 -0
  21. package/dist/types/components/datebox/placeholder.d.ts +7 -0
  22. package/dist/types/components/dialog/dialog.d.ts +2 -2
  23. package/dist/types/components/dock/dock.d.ts +12 -3
  24. package/dist/types/components/entity-ref/entity-ref.d.ts +5 -3
  25. package/dist/types/components/field-upload/field-upload.d.ts +3 -2
  26. package/dist/types/components/file-item/file-item.d.ts +3 -2
  27. package/dist/types/components/file-list/file-list.d.ts +14 -8
  28. package/dist/types/components/filter/filter-model.d.ts +31 -1
  29. package/dist/types/components/filter/filter.d.ts +20 -2
  30. package/dist/types/components/finder/finder.d.ts +14 -6
  31. package/dist/types/components/flag/flag.d.ts +99 -0
  32. package/dist/types/components/grid/grid.d.ts +1 -1
  33. package/dist/types/components/kanban-view/kanban-view.d.ts +8 -66
  34. package/dist/types/components/launcher/launcher.d.ts +2 -0
  35. package/dist/types/components/modal/modal.d.ts +34 -8
  36. package/dist/types/components/multi-value-editor/multi-value-editor.d.ts +3 -2
  37. package/dist/types/components/number-field/number-field.d.ts +41 -7
  38. package/dist/types/components/prompt-starters/prompt-starters.d.ts +107 -0
  39. package/dist/types/components/prose/prose.d.ts +9 -6
  40. package/dist/types/components/questionnaire/conditions.d.ts +270 -0
  41. package/dist/types/components/questionnaire/items.d.ts +52 -30
  42. package/dist/types/components/questionnaire/questionnaire.d.ts +44 -4
  43. package/dist/types/components/rating/rating.d.ts +5 -3
  44. package/dist/types/components/select/country.d.ts +106 -0
  45. package/dist/types/components/select/field-adapter.d.ts +2 -1
  46. package/dist/types/components/select/locale.d.ts +102 -0
  47. package/dist/types/components/select/select.d.ts +41 -2
  48. package/dist/types/components/sheet/sheet.d.ts +2 -2
  49. package/dist/types/components/slider/slider.d.ts +1 -0
  50. package/dist/types/components/sort-control/sort-control.d.ts +7 -3
  51. package/dist/types/components/source-list/source-list.d.ts +7 -5
  52. package/dist/types/components/split-view/split-view.d.ts +5 -3
  53. package/dist/types/components/surface/catalog.d.ts +260 -0
  54. package/dist/types/components/surface/elicit.d.ts +81 -0
  55. package/dist/types/components/surface/mcp.d.ts +165 -0
  56. package/dist/types/components/surface/schema.d.ts +314 -0
  57. package/dist/types/components/surface/stream.d.ts +118 -0
  58. package/dist/types/components/surface/surface.d.ts +718 -0
  59. package/dist/types/components/surface/text.d.ts +277 -0
  60. package/dist/types/components/surface/validate.d.ts +339 -0
  61. package/dist/types/components/table/table.d.ts +55 -3
  62. package/dist/types/components/table/window.d.ts +203 -0
  63. package/dist/types/components/toolbar/toolbar.d.ts +10 -6
  64. package/dist/types/components/tooltip/tooltip.d.ts +2 -2
  65. package/dist/types/components/tree/tree.d.ts +20 -13
  66. package/dist/types/core/component.d.ts +10 -0
  67. package/dist/types/core/date.d.ts +8 -1
  68. package/dist/types/core/dom.d.ts +15 -0
  69. package/dist/types/core/http.d.ts +10 -0
  70. package/dist/types/core/i18n.d.ts +38 -0
  71. package/dist/types/core/messages.d.ts +344 -1
  72. package/dist/types/core/storage.d.ts +7 -2
  73. package/dist/types/elements/define.d.ts +21 -46
  74. package/dist/types/elements/definitions.d.ts +147 -0
  75. package/dist/types/elements/kit.d.ts +7 -0
  76. package/dist/types/elements/reflect.d.ts +6 -3
  77. package/dist/types/index.d.ts +10 -1
  78. package/dist/types/internal/date-locale.d.ts +7 -0
  79. package/dist/types/internal/json-patch.d.ts +146 -0
  80. package/dist/types/locales/de.d.ts +13 -0
  81. package/dist/types/locales/en.d.ts +2 -0
  82. package/dist/types/locales/index.d.ts +823 -0
  83. package/dist/types/zeyos/view.d.ts +8 -1
  84. package/dist/zx-zeyos.esm.js +16852 -15131
  85. package/dist/zx-zeyos.esm.min.js +5 -5
  86. package/dist/zx.core.css +1276 -0
  87. package/dist/zx.core.min.css +1 -0
  88. package/dist/zx.css +520 -143
  89. package/dist/zx.esm.js +40940 -29684
  90. package/dist/zx.esm.min.js +36 -23
  91. package/dist/zx.global.js +40940 -29684
  92. package/dist/zx.global.min.js +36 -23
  93. package/dist/zx.layered.css +17315 -0
  94. package/dist/zx.layered.min.css +1 -0
  95. package/dist/zx.min.css +1 -1
  96. package/docs/agent-catalog.json +12501 -0
  97. package/docs/agent-surfaces.md +340 -0
  98. package/docs/api.json +909 -137
  99. package/docs/llms.md +1046 -80
  100. package/docs/llms.txt +30 -9
  101. package/package.json +29 -6
  102. package/src/components/account-menu/account-menu.js +6 -3
  103. package/src/components/activity-item/activity-item.js +2 -1
  104. package/src/components/activity-list/activity-list.js +16 -10
  105. package/src/components/agent-thread/ag-ui.js +1439 -0
  106. package/src/components/agent-thread/agent-thread.js +359 -54
  107. package/src/components/agent-thread/ui-message-stream.js +1281 -0
  108. package/src/components/app-sidebar/app-sidebar.js +18 -8
  109. package/src/components/approval-card/approval-card.js +3 -2
  110. package/src/components/block-view/block-view.js +7 -6
  111. package/src/components/breadcrumb/breadcrumb.js +8 -5
  112. package/src/components/button/button.css +24 -11
  113. package/src/components/calendar/calendar-model.js +8 -2
  114. package/src/components/calendar/calendar.js +53 -18
  115. package/src/components/chart/chart.js +54 -23
  116. package/src/components/checklist/checklist.css +9 -1
  117. package/src/components/checklist/checklist.js +59 -3
  118. package/src/components/checklist/field-adapter.js +2 -11
  119. package/src/components/code-editor/code-editor.js +45 -8
  120. package/src/components/code-editor/field-adapter.js +1 -1
  121. package/src/components/composer/composer.css +80 -1
  122. package/src/components/composer/composer.js +390 -16
  123. package/src/components/composer/queue.js +78 -0
  124. package/src/components/context-menu/context-menu.js +12 -1
  125. package/src/components/copy/copy-button.js +9 -7
  126. package/src/components/copy/copy-input.js +10 -6
  127. package/src/components/date-picker/date-picker.js +2 -1
  128. package/src/components/date-picker/date-range-picker.js +8 -7
  129. package/src/components/datebox/date-range-box.js +3 -9
  130. package/src/components/datebox/datebox.js +18 -21
  131. package/src/components/datebox/placeholder.js +18 -0
  132. package/src/components/dialog/dialog.js +4 -5
  133. package/src/components/dock/dock.js +34 -13
  134. package/src/components/entity-ref/entity-ref.js +16 -5
  135. package/src/components/field-upload/field-upload.js +81 -38
  136. package/src/components/file-item/file-item.js +70 -40
  137. package/src/components/file-list/file-list.js +15 -9
  138. package/src/components/filter/filter-model.js +46 -8
  139. package/src/components/filter/filter.css +3 -3
  140. package/src/components/filter/filter.js +29 -10
  141. package/src/components/filter-panel/filter-panel.js +13 -5
  142. package/src/components/finder/finder.js +50 -26
  143. package/src/components/flag/flag.css +40 -0
  144. package/src/components/flag/flag.js +177 -0
  145. package/src/components/form/form.js +1 -1
  146. package/src/components/grid/grid.js +22 -8
  147. package/src/components/kanban-view/kanban-view.js +51 -81
  148. package/src/components/launcher/launcher.js +17 -2
  149. package/src/components/list-toolbar/list-toolbar.js +2 -1
  150. package/src/components/master-panel/master-panel.js +1 -1
  151. package/src/components/menu-button/menu-button.js +4 -0
  152. package/src/components/message/message.js +3 -0
  153. package/src/components/modal/modal.js +62 -8
  154. package/src/components/multi-value-editor/multi-value-editor.js +10 -9
  155. package/src/components/navigation-bar/navigation-bar.js +3 -3
  156. package/src/components/number-field/number-field.js +98 -29
  157. package/src/components/prompt-starters/prompt-starters.css +91 -0
  158. package/src/components/prompt-starters/prompt-starters.js +206 -0
  159. package/src/components/prose/prose.js +14 -10
  160. package/src/components/questionnaire/conditions.js +666 -0
  161. package/src/components/questionnaire/items.js +150 -41
  162. package/src/components/questionnaire/questionnaire.js +126 -32
  163. package/src/components/rating/rating.js +5 -4
  164. package/src/components/run-status/run-status.js +2 -2
  165. package/src/components/select/country.js +136 -0
  166. package/src/components/select/field-adapter.js +7 -2
  167. package/src/components/select/locale.js +219 -0
  168. package/src/components/select/select.css +20 -22
  169. package/src/components/select/select.js +94 -12
  170. package/src/components/sheet/sheet-stack.js +10 -1
  171. package/src/components/sheet/sheet.js +12 -5
  172. package/src/components/slider/slider.js +7 -2
  173. package/src/components/sort-control/sort-control.js +15 -5
  174. package/src/components/source-list/source-list.js +7 -4
  175. package/src/components/split-view/split-view.js +5 -3
  176. package/src/components/surface/catalog.js +1334 -0
  177. package/src/components/surface/elicit.js +107 -0
  178. package/src/components/surface/mcp.js +243 -0
  179. package/src/components/surface/schema.js +644 -0
  180. package/src/components/surface/stream.js +245 -0
  181. package/src/components/surface/surface.css +308 -0
  182. package/src/components/surface/surface.js +2291 -0
  183. package/src/components/surface/text.js +513 -0
  184. package/src/components/surface/validate.js +2218 -0
  185. package/src/components/tabbox/tabbox.js +9 -0
  186. package/src/components/table/table.css +63 -3
  187. package/src/components/table/table.js +167 -28
  188. package/src/components/table/window.js +317 -0
  189. package/src/components/toolbar/toolbar.js +12 -7
  190. package/src/components/tooltip/tooltip.css +2 -3
  191. package/src/components/tooltip/tooltip.js +32 -5
  192. package/src/components/tree/tree.js +53 -23
  193. package/src/core/component.js +25 -1
  194. package/src/core/date.js +62 -16
  195. package/src/core/dom.js +67 -4
  196. package/src/core/format.js +15 -13
  197. package/src/core/http.js +29 -20
  198. package/src/core/i18n.js +83 -10
  199. package/src/core/icons.js +13 -2
  200. package/src/core/keyboard.js +79 -8
  201. package/src/core/messages.js +376 -2
  202. package/src/core/overlay-host.js +1 -0
  203. package/src/core/position.js +3 -2
  204. package/src/core/storage.js +59 -6
  205. package/src/elements/define.js +178 -130
  206. package/src/elements/definitions.js +229 -0
  207. package/src/elements/kit.js +444 -0
  208. package/src/elements/reflect.js +8 -3
  209. package/src/index.js +10 -1
  210. package/src/internal/date-locale.js +11 -0
  211. package/src/internal/json-patch.js +405 -0
  212. package/src/locales/de.js +911 -0
  213. package/src/locales/en.js +2 -0
  214. package/src/locales/index.js +7 -0
  215. package/src/zeyos/calendar.js +2 -1
  216. package/src/zeyos/form.js +2 -1
  217. package/src/zeyos/launcher.js +7 -6
  218. package/src/zeyos/module-bar.js +2 -1
  219. package/src/zeyos/schema.js +37 -23
  220. package/src/zeyos/select.js +4 -3
  221. package/src/zeyos/table.js +2 -13
  222. package/src/zeyos/view.js +57 -17
  223. package/styles/core.css +11 -0
  224. package/styles/tokens/semantic.css +1 -0
  225. package/styles/zeyos.css +2 -0
  226. package/styles/zx.css +4 -8
  227. package/styles/zx.layered.css +1 -0
package/bin/zx-css.js ADDED
@@ -0,0 +1,328 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Writes a stylesheet holding only the components an application uses.
4
+ *
5
+ * A subset is resolved from the source, not listed by hand. A component's subset is its own
6
+ * stylesheet plus the stylesheet of every block it reaches: every component module in its static
7
+ * import graph, and every `zx-<block>` class named by a module in that graph, because a component
8
+ * may draw another's markup without importing it. The result keeps the order of `styles/zx.css`,
9
+ * holds each file once, and starts with the core sheet.
10
+ *
11
+ * Runs on Node alone: the package has no runtime dependencies and this is part of the package.
12
+ */
13
+ import { existsSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from 'node:fs';
14
+ import { dirname, posix, resolve } from 'node:path';
15
+ import { fileURLToPath } from 'node:url';
16
+ import { parseArgs } from 'node:util';
17
+
18
+ const PACKAGE_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
19
+ const ENTRY_SHEET = 'styles/zx.css';
20
+ const CORE_SHEET = 'styles/core.css';
21
+ const COMPONENT_SHEETS = 'src/components/';
22
+
23
+ const USAGE = `Usage:
24
+ zx-css <component...> --out <file> [--min] [--layer]
25
+ zx-css <component...> --list
26
+
27
+ --out <file> write the stylesheet to this file
28
+ --min strip comments and whitespace
29
+ --layer put everything in @layer zx, so unlayered application rules win
30
+ --list print the files the subset contains, in order, without writing`;
31
+
32
+ const SHEET_IMPORT = /@import url\("([^"]+)"\);/g;
33
+ const MODULE_IMPORT = /^[ \t]*(?:import\s+|(?:import|export)\b[^'"`;]*?\bfrom\s+)['"](\.{1,2}\/[^'"]+)['"]/gm;
34
+ // A preceding `-` rules out `--zx-*` properties and `data-zx-*` attributes.
35
+ const CLASS_NAME = /(?<![\w$-])zx-([a-z0-9-]+)/g;
36
+ // The class `Component` puts on a root from `static cssName`, which the source never spells out.
37
+ const ROOT_CLASS_NAME = /\bstatic cssName = '([a-z0-9-]+)'/g;
38
+ const CSS_CLASS = /\.zx-([a-z0-9-]+)/;
39
+ // `zx-<type>` also names the DOM event a component dispatches, and hearing one draws nothing.
40
+ const EVENT_NAMES = /\bfor \(const type of \[[^\]]*\]\)|\w*[Ll]isten\w*\([^,()]*,\s*'zx-[a-z-]+'/g;
41
+
42
+ /**
43
+ * @typedef {Object} SubsetOptions
44
+ * @property {string} [root] Package root holding `styles/` and `src/`. Defaults to this package.
45
+ */
46
+
47
+ /**
48
+ * @typedef {Object} BuildOptions
49
+ * @property {string} [root] Package root holding `styles/` and `src/`. Defaults to this package.
50
+ * @property {boolean} [min=false] Strip comments and whitespace.
51
+ * @property {boolean} [layer=false] Put the stylesheet in `@layer zx`.
52
+ */
53
+
54
+ /**
55
+ * @param {string} root Package root.
56
+ * @param {string} file File path relative to the root.
57
+ * @returns {string} File contents.
58
+ */
59
+ function read(root, file) {
60
+ return readFileSync(resolve(root, file), 'utf8');
61
+ }
62
+
63
+ /**
64
+ * @param {string} root Package root.
65
+ * @param {string} sheet Stylesheet path relative to the root.
66
+ * @returns {string[]} The sheets it imports, relative to the root, in order.
67
+ */
68
+ function importsOf(root, sheet) {
69
+ return [...read(root, sheet).matchAll(SHEET_IMPORT)]
70
+ .map((match) => posix.join(posix.dirname(sheet), match[1]));
71
+ }
72
+
73
+ /**
74
+ * @param {string} root Package root.
75
+ * @returns {string[]} The component stylesheets, in `zx.css` order.
76
+ */
77
+ function componentSheets(root) {
78
+ const imports = importsOf(root, ENTRY_SHEET);
79
+ if (imports[0] !== CORE_SHEET) throw new Error(`${ENTRY_SHEET} must import ${CORE_SHEET} first`);
80
+ return imports.filter((sheet) => sheet.startsWith(COMPONENT_SHEETS));
81
+ }
82
+
83
+ /**
84
+ * @param {string} sheet Stylesheet path.
85
+ * @returns {string} The component name, which is the file's name.
86
+ */
87
+ function nameOf(sheet) {
88
+ return posix.basename(sheet, '.css');
89
+ }
90
+
91
+ /**
92
+ * Lists the names `resolveSubset` accepts: one for each component stylesheet in `styles/zx.css`.
93
+ * @param {SubsetOptions} [options] Package root.
94
+ * @returns {string[]} Component names, sorted.
95
+ */
96
+ export function componentNames({ root = PACKAGE_ROOT } = {}) {
97
+ return componentSheets(root).map(nameOf).sort();
98
+ }
99
+
100
+ /**
101
+ * @param {string} root Package root.
102
+ * @param {string} sheet Stylesheet path relative to the root.
103
+ * @returns {string} Stylesheet source without comments.
104
+ */
105
+ function rulesOf(root, sheet) {
106
+ return read(root, sheet).replace(/\/\*[\s\S]*?\*\//g, '');
107
+ }
108
+
109
+ /**
110
+ * Finds the block that opens each selector of a stylesheet.
111
+ * @param {string} css Stylesheet source without comments.
112
+ * @returns {Set<string>} Block names.
113
+ */
114
+ function leadingBlocks(css) {
115
+ const blocks = new Set();
116
+ const tokens = css.split(/([{};])/);
117
+ for (let index = 1; index < tokens.length; index += 2) {
118
+ if (tokens[index] !== '{' || tokens[index - 1].trimStart().startsWith('@')) continue;
119
+ for (const selector of tokens[index - 1].split(',')) {
120
+ const block = CSS_CLASS.exec(selector)?.[1];
121
+ if (block) blocks.add(block);
122
+ }
123
+ }
124
+ return blocks;
125
+ }
126
+
127
+ /**
128
+ * Maps each block to the component stylesheets that define it. A sheet named after a block is that
129
+ * block's home; `.zx-grid` is the exception, since `grid.css` styles the Grid component and never
130
+ * the class, which is why the sheet has to name the block to claim it. Any other block, such as
131
+ * `.zx-btn` in `button.css`, belongs to the sheets whose selectors open with it, unless the core
132
+ * sheet defines it, in which case every subset already has it. Sheets that only style a block in
133
+ * context, like `.zx-field .zx-select`, do not claim it.
134
+ * @param {string} root Package root.
135
+ * @param {string[]} sheets Component stylesheets.
136
+ * @returns {Map<string, string[]>} Block name to stylesheets.
137
+ */
138
+ function blockHomes(root, sheets) {
139
+ const core = new Set(importsOf(root, CORE_SHEET)
140
+ .flatMap((sheet) => [...leadingBlocks(rulesOf(root, sheet))]));
141
+ /** @type {Map<string, string[]>} */
142
+ const homes = new Map();
143
+ const sources = sheets.map((sheet) => ({ sheet, css: rulesOf(root, sheet) }));
144
+ for (const { sheet, css } of sources) {
145
+ const ownClass = new RegExp(`\\.zx-${nameOf(sheet)}(?![a-z0-9-])`);
146
+ if (ownClass.test(css)) homes.set(nameOf(sheet), [sheet]);
147
+ }
148
+ const named = new Set(homes.keys());
149
+ for (const { sheet, css } of sources) {
150
+ for (const block of leadingBlocks(css)) {
151
+ if (named.has(block) || core.has(block)) continue;
152
+ homes.set(block, [...(homes.get(block) ?? []), sheet]);
153
+ }
154
+ }
155
+ return homes;
156
+ }
157
+
158
+ /**
159
+ * @param {string} source Module source.
160
+ * @returns {string} The source without its comment lines, which describe other blocks as often as
161
+ * they name this one's. Trailing comments stay: reaching too far costs bytes, not correctness.
162
+ */
163
+ function withoutCommentLines(source) {
164
+ return source.replace(/^\s*(?:\/\*|\*|\/\/).*$/gm, '');
165
+ }
166
+
167
+ /**
168
+ * Walks the static import graph.
169
+ * @param {string} root Package root.
170
+ * @param {string[]} entries Entry modules.
171
+ * @returns {Map<string, string>} Every module reached, with its source.
172
+ */
173
+ function moduleGraph(root, entries) {
174
+ const modules = new Map();
175
+ const queue = [...entries];
176
+ for (const module of queue) {
177
+ if (modules.has(module)) continue;
178
+ const source = withoutCommentLines(read(root, module));
179
+ modules.set(module, source);
180
+ for (const [, specifier] of source.matchAll(MODULE_IMPORT)) {
181
+ const target = posix.join(posix.dirname(module), specifier);
182
+ if (existsSync(resolve(root, target))) queue.push(target);
183
+ }
184
+ }
185
+ return modules;
186
+ }
187
+
188
+ /**
189
+ * @param {string} root Package root.
190
+ * @param {string} sheet Component stylesheet.
191
+ * @returns {string|null} Its module: the file beside it, or the presenter of the same name that
192
+ * several components share from `src/internal/`.
193
+ */
194
+ function moduleOf(root, sheet) {
195
+ const candidates = [sheet.replace(/\.css$/, '.js'), `src/internal/${nameOf(sheet)}.js`];
196
+ return candidates.find((file) => existsSync(resolve(root, file))) ?? null;
197
+ }
198
+
199
+ /**
200
+ * Resolves the stylesheets a set of components needs.
201
+ * @param {string[]} names Component names, see `componentNames()`.
202
+ * @param {SubsetOptions} [options] Package root.
203
+ * @returns {string[]} Stylesheets relative to the root: the core sheet, then the components in
204
+ * `zx.css` order, each once.
205
+ * @throws {Error} When a name is not a component, listing the ones that are.
206
+ */
207
+ export function resolveSubset(names, { root = PACKAGE_ROOT } = {}) {
208
+ const sheets = componentSheets(root);
209
+ const sheetOf = new Map(sheets.map((sheet) => [nameOf(sheet), sheet]));
210
+ const unknown = names.filter((name) => !sheetOf.has(name));
211
+ if (unknown.length) {
212
+ throw new Error(`Unknown component: ${unknown.join(', ')}\n`
213
+ + `Known components: ${componentNames({ root }).join(', ')}`);
214
+ }
215
+
216
+ const requested = names.map((name) => /** @type {string} */ (sheetOf.get(name)));
217
+ const reached = new Set(requested);
218
+ const homes = blockHomes(root, sheets);
219
+ const entries = requested.map((sheet) => moduleOf(root, sheet)).filter((module) => module !== null);
220
+ for (const [module, source] of moduleGraph(root, entries)) {
221
+ const own = module.replace(/\.js$/, '.css');
222
+ if (sheets.includes(own)) reached.add(own);
223
+ const code = source.replace(EVENT_NAMES, '');
224
+ for (const pattern of [CLASS_NAME, ROOT_CLASS_NAME]) {
225
+ for (const [, token] of code.matchAll(pattern)) {
226
+ for (const sheet of homes.get(token.replace(/-+$/, '')) ?? []) reached.add(sheet);
227
+ }
228
+ }
229
+ }
230
+ return [CORE_SHEET, ...sheets.filter((sheet) => reached.has(sheet))];
231
+ }
232
+
233
+ /**
234
+ * Inlines a stylesheet's imports.
235
+ * @param {string} root Package root.
236
+ * @param {string} sheet Stylesheet path relative to the root.
237
+ * @returns {string} Stylesheet with no `@import` left.
238
+ */
239
+ function inlineSheet(root, sheet) {
240
+ return read(root, sheet).replace(SHEET_IMPORT, (statement, href) => (
241
+ inlineSheet(root, posix.join(posix.dirname(sheet), href))
242
+ ));
243
+ }
244
+
245
+ /**
246
+ * Strips comments and the whitespace that means nothing, leaving strings as they are. Whitespace
247
+ * inside a selector or value can be a combinator or a separator, so it collapses but stays.
248
+ * @param {string} css Stylesheet.
249
+ * @returns {string} Minified stylesheet.
250
+ */
251
+ function minify(css) {
252
+ let output = '';
253
+ let space = false;
254
+ for (let index = 0; index < css.length;) {
255
+ const char = css[index];
256
+ if (css.startsWith('/*', index)) {
257
+ const end = css.indexOf('*/', index + 2);
258
+ index = end < 0 ? css.length : end + 2;
259
+ space = true;
260
+ } else if (/\s/.test(char)) {
261
+ index += 1;
262
+ space = true;
263
+ } else {
264
+ let end = index + 1;
265
+ if (char === '"' || char === "'") {
266
+ while (end < css.length && css[end] !== char) end += css[end] === '\\' ? 2 : 1;
267
+ end += 1;
268
+ }
269
+ if (space && output && !'{};,'.includes(output.at(-1)) && !'{};,'.includes(char)) output += ' ';
270
+ if (char === '}' && output.endsWith(';')) output = output.slice(0, -1);
271
+ output += css.slice(index, end);
272
+ index = end;
273
+ space = false;
274
+ }
275
+ }
276
+ return output;
277
+ }
278
+
279
+ /**
280
+ * Builds the stylesheet for a set of components.
281
+ * @param {string[]} names Component names.
282
+ * @param {BuildOptions} [options] Package root and output form.
283
+ * @returns {string} Stylesheet with no `@import` left.
284
+ * @throws {Error} When a name is not a component.
285
+ */
286
+ export function buildSubset(names, { root = PACKAGE_ROOT, min = false, layer = false } = {}) {
287
+ const css = resolveSubset(names, { root }).map((sheet) => inlineSheet(root, sheet)).join('\n');
288
+ const output = layer ? `@layer zx {\n${css}\n}\n` : css;
289
+ return min ? minify(output) : output;
290
+ }
291
+
292
+ /**
293
+ * Runs the command line.
294
+ * @param {string[]} args Arguments after the program name.
295
+ * @returns {number} Exit code.
296
+ */
297
+ function main(args) {
298
+ try {
299
+ const { values, positionals } = parseArgs({
300
+ args,
301
+ allowPositionals: true,
302
+ options: {
303
+ out: { type: 'string' },
304
+ min: { type: 'boolean' },
305
+ layer: { type: 'boolean' },
306
+ list: { type: 'boolean' }
307
+ }
308
+ });
309
+ if (!positionals.length || (!values.out && !values.list)) throw new Error(USAGE);
310
+ if (values.list) {
311
+ console.log(resolveSubset(positionals).join('\n'));
312
+ return 0;
313
+ }
314
+ const out = resolve(/** @type {string} */ (values.out));
315
+ const css = buildSubset(positionals, { min: values.min, layer: values.layer });
316
+ mkdirSync(dirname(out), { recursive: true });
317
+ writeFileSync(out, css);
318
+ console.log(`${values.out}: ${positionals.join(', ')} (${(Buffer.byteLength(css) / 1000).toFixed(1)} kB)`);
319
+ return 0;
320
+ } catch (error) {
321
+ console.error(error instanceof Error ? error.message : String(error));
322
+ return 1;
323
+ }
324
+ }
325
+
326
+ if (process.argv[1] && realpathSync(process.argv[1]) === fileURLToPath(import.meta.url)) {
327
+ process.exitCode = main(process.argv.slice(2));
328
+ }
@@ -42,7 +42,8 @@ export type AccountMenuOptions = {
42
42
  */
43
43
  compact?: boolean;
44
44
  /**
45
- * Trigger label; defaults to `Account menu for <name>`.
45
+ * Trigger label; null reads the `accountMenu.labelFor` message
46
+ * ("Account menu for <name>"), or `accountMenu.label` without a name.
46
47
  */
47
48
  label?: string | null;
48
49
  /**
@@ -80,7 +81,8 @@ export type AccountMenuOptions = {
80
81
  * @property {AccountIdentity} [account={}] Account presentation supplied by the application.
81
82
  * @property {MenuButtonItem[]} [items=[]] Account actions and `'-'` separators.
82
83
  * @property {boolean} [compact=false] Whether only the avatar is visually shown in the trigger.
83
- * @property {string|null} [label=null] Trigger label; defaults to `Account menu for <name>`.
84
+ * @property {string|null} [label=null] Trigger label; null reads the `accountMenu.labelFor` message
85
+ * ("Account menu for <name>"), or `accountMenu.label` without a name.
84
86
  * @property {'bottom-start'|'bottom-end'|'top-start'|'top-end'|'bottom'|'top'|'right-start'|'right-end'|'left-start'|'left-end'|'right'|'left'} [placement='top-start'] Popup placement.
85
87
  * @property {(event: CustomEvent<{value: unknown, item: object}>) => void} [onselect] Preventable action listener.
86
88
  * @property {(event: CustomEvent<Record<string, never>>) => void} [onopen] Open listener.
@@ -28,9 +28,10 @@ export type ActivityListOptions = {
28
28
  */
29
29
  groupLabel?: ActivityGroupLabel | null;
30
30
  /**
31
- * Accessible collection name.
31
+ * Accessible collection name; null reads the
32
+ * `activityList.label` message ("Activity").
32
33
  */
33
- label?: string;
34
+ label?: string | null;
34
35
  /**
35
36
  * Entry layout, reflected as `data-variant` on
36
37
  * the root. `'compact'` also makes an avatar descriptor without a `size` small.
@@ -45,11 +46,13 @@ export type ActivityListOptions = {
45
46
  */
46
47
  loadingCount?: number;
47
48
  /**
48
- * Loading status text.
49
+ * Loading status text, by default the `activityList.loading`
50
+ * message ("Loading activity"). Null shows none.
49
51
  */
50
- loadingText?: string;
52
+ loadingText?: string | null;
51
53
  /**
52
- * Empty-state content.
54
+ * Empty-state content, by default the
55
+ * `activityList.empty` message ("No activity yet"). Null shows none.
53
56
  */
54
57
  emptyText?: ActivityListContent;
55
58
  /**
@@ -85,13 +88,16 @@ export type ActivityListOptions = {
85
88
  * @property {ActivityItemOptions[]} [items=[]] Initial activities in host-supplied chronological order.
86
89
  * @property {ActivityGroupReader} [groupBy=null] Property or resolver used for stable grouping.
87
90
  * @property {ActivityGroupLabel|null} [groupLabel=null] Group-heading renderer.
88
- * @property {string} [label='Activity'] Accessible collection name.
91
+ * @property {string|null} [label=null] Accessible collection name; null reads the
92
+ * `activityList.label` message ("Activity").
89
93
  * @property {ActivityListVariant} [variant='default'] Entry layout, reflected as `data-variant` on
90
94
  * the root. `'compact'` also makes an avatar descriptor without a `size` small.
91
95
  * @property {boolean} [loading=false] Whether initial or incremental activity is loading.
92
96
  * @property {number} [loadingCount=3] Placeholder rows shown for an empty loading list.
93
- * @property {string} [loadingText='Loading activity'] Loading status text.
94
- * @property {ActivityListContent} [emptyText='No activity yet'] Empty-state content.
97
+ * @property {string|null} [loadingText] Loading status text, by default the `activityList.loading`
98
+ * message ("Loading activity"). Null shows none.
99
+ * @property {ActivityListContent} [emptyText] Empty-state content, by default the
100
+ * `activityList.empty` message ("No activity yet"). Null shows none.
95
101
  * @property {1|2|3|4|5|6} [groupHeadingLevel=2] Semantic group-heading level.
96
102
  * @property {1|2|3|4|5|6} [itemHeadingLevel=3] Default item-heading level.
97
103
  * @property {(event:CustomEvent<{items:ActivityItemOptions[]}>)=>void} [ondatachange]