@zeyos/zx 5.7.1 → 5.8.0

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 (326) hide show
  1. package/CHANGELOG.md +296 -0
  2. package/README.md +47 -9
  3. package/dist/types/components/activity-item/activity-item.d.ts +14 -3
  4. package/dist/types/components/agent-avatar/agent-avatar.d.ts +165 -0
  5. package/dist/types/components/agent-avatar/agent-face.d.ts +93 -0
  6. package/dist/types/components/agent-thread/ag-ui.d.ts +21 -9
  7. package/dist/types/components/agent-thread/agent-thread.d.ts +26 -0
  8. package/dist/types/components/agent-thread/ui-message-stream.d.ts +3 -1
  9. package/dist/types/components/approval-card/approval-card.d.ts +31 -2
  10. package/dist/types/components/aurora/aurora.d.ts +31 -5
  11. package/dist/types/components/calendar/calendar.d.ts +39 -26
  12. package/dist/types/components/chart/chart.d.ts +250 -20
  13. package/dist/types/components/chart/color.d.ts +66 -0
  14. package/dist/types/components/chart/svg-adapter.d.ts +103 -0
  15. package/dist/types/components/chart/svg-geometry.d.ts +203 -0
  16. package/dist/types/components/check-button/check-button.d.ts +1 -4
  17. package/dist/types/components/checklist/checklist.d.ts +19 -5
  18. package/dist/types/components/code-editor/code-editor.d.ts +55 -1
  19. package/dist/types/components/composer/composer.d.ts +41 -6
  20. package/dist/types/components/context-menu/context-menu.d.ts +36 -8
  21. package/dist/types/components/copy/copy-button.d.ts +6 -0
  22. package/dist/types/components/copy/copy-input.d.ts +1 -0
  23. package/dist/types/components/date-picker/date-picker.d.ts +14 -0
  24. package/dist/types/components/date-picker/time-picker.d.ts +26 -17
  25. package/dist/types/components/datebox/datebox.d.ts +8 -4
  26. package/dist/types/components/dialog/dialog.d.ts +13 -2
  27. package/dist/types/components/empty-state/empty-state.d.ts +10 -1
  28. package/dist/types/components/field/field.d.ts +4 -2
  29. package/dist/types/components/form/form.d.ts +2 -1
  30. package/dist/types/components/kanban-view/kanban-card.d.ts +7 -0
  31. package/dist/types/components/kanban-view/kanban-view.d.ts +15 -3
  32. package/dist/types/components/launcher/launcher.d.ts +26 -0
  33. package/dist/types/components/master-panel/master-panel.d.ts +9 -4
  34. package/dist/types/components/menu-button/menu-button.d.ts +29 -5
  35. package/dist/types/components/message/message.d.ts +308 -5
  36. package/dist/types/components/modal/modal.d.ts +11 -0
  37. package/dist/types/components/modal/native-dialog.d.ts +40 -0
  38. package/dist/types/components/module-bar/module-bar.d.ts +9 -2
  39. package/dist/types/components/multi-value-editor/multi-value-editor.d.ts +5 -4
  40. package/dist/types/components/number-field/number-field.d.ts +7 -0
  41. package/dist/types/components/pagination/pagination.d.ts +341 -19
  42. package/dist/types/components/run-status/run-status.d.ts +26 -0
  43. package/dist/types/components/run-trace/run-trace.d.ts +10 -6
  44. package/dist/types/components/search/search.d.ts +16 -4
  45. package/dist/types/components/select/select.d.ts +19 -1
  46. package/dist/types/components/sheet/sheet.d.ts +18 -4
  47. package/dist/types/components/slider/slider.d.ts +2 -1
  48. package/dist/types/components/stat-tile/stat-tile.d.ts +20 -3
  49. package/dist/types/components/stepper/stepper.d.ts +17 -4
  50. package/dist/types/components/surface/catalog.d.ts +61 -17
  51. package/dist/types/components/surface/surface.d.ts +6 -4
  52. package/dist/types/components/table/table.d.ts +207 -5
  53. package/dist/types/components/table/window.d.ts +25 -1
  54. package/dist/types/components/toggle/toggle.d.ts +38 -6
  55. package/dist/types/components/tooltip/tooltip.d.ts +5 -4
  56. package/dist/types/components/tree/tree.d.ts +43 -6
  57. package/dist/types/components/truncate/truncate.d.ts +4 -2
  58. package/dist/types/components/value-list/value-list.d.ts +9 -2
  59. package/dist/types/core/date.d.ts +2 -1
  60. package/dist/types/core/drag-axis.d.ts +10 -5
  61. package/dist/types/core/export.d.ts +2 -2
  62. package/dist/types/core/format.d.ts +3 -1
  63. package/dist/types/core/icons.d.ts +36 -3
  64. package/dist/types/core/keyboard.d.ts +7 -3
  65. package/dist/types/core/messages.d.ts +3 -0
  66. package/dist/types/core/storage.d.ts +4 -3
  67. package/dist/types/core/util.d.ts +3 -1
  68. package/dist/types/elements/define.d.ts +5 -2
  69. package/dist/types/index.d.ts +6 -4
  70. package/dist/types/internal/agent-model.d.ts +99 -0
  71. package/dist/types/internal/app-rail.d.ts +37 -2
  72. package/dist/types/internal/collections.d.ts +18 -0
  73. package/dist/types/internal/menu-items.d.ts +27 -0
  74. package/dist/types/internal/overlay-content.d.ts +23 -0
  75. package/dist/types/internal/presence-loop.d.ts +5 -2
  76. package/dist/types/locales/index.d.ts +3 -0
  77. package/dist/types/zeyos/calendar.d.ts +43 -7
  78. package/dist/types/zeyos/connect.d.ts +4 -0
  79. package/dist/types/zeyos/form.d.ts +13 -5
  80. package/dist/types/zeyos/select.d.ts +5 -2
  81. package/dist/types/zeyos/table.d.ts +16 -8
  82. package/dist/types/zeyos/view.d.ts +2 -1
  83. package/dist/zx-zeyos.esm.js +2998 -451
  84. package/dist/zx-zeyos.esm.min.js +4 -4
  85. package/dist/zx.core.css +4 -0
  86. package/dist/zx.core.min.css +1 -1
  87. package/dist/zx.css +948 -48
  88. package/dist/zx.esm.js +7432 -3408
  89. package/dist/zx.esm.min.js +26 -26
  90. package/dist/zx.global.js +7432 -3408
  91. package/dist/zx.global.min.js +26 -26
  92. package/dist/zx.layered.css +950 -48
  93. package/dist/zx.layered.min.css +1 -1
  94. package/dist/zx.min.css +1 -1
  95. package/docs/agent-catalog.json +159 -1
  96. package/docs/agent-surfaces.md +21 -21
  97. package/docs/api.json +3122 -528
  98. package/docs/components/account-menu.md +24 -0
  99. package/docs/components/activity-item.md +23 -0
  100. package/docs/components/activity-list.md +28 -0
  101. package/docs/components/agent-avatar.md +59 -0
  102. package/docs/components/agent-thread.md +275 -0
  103. package/docs/components/app-icon.md +36 -0
  104. package/docs/components/app-sidebar.md +92 -0
  105. package/docs/components/approval-card.md +71 -0
  106. package/docs/components/aurora.md +34 -0
  107. package/docs/components/avatar.md +37 -0
  108. package/docs/components/badge.md +36 -0
  109. package/docs/components/block-view.md +34 -0
  110. package/docs/components/breadcrumb.md +20 -0
  111. package/docs/components/button.md +23 -0
  112. package/docs/components/calendar.md +68 -0
  113. package/docs/components/card-view.md +73 -0
  114. package/docs/components/card.md +25 -0
  115. package/docs/components/chart.md +109 -0
  116. package/docs/components/check-button.md +16 -0
  117. package/docs/components/checklist.md +19 -0
  118. package/docs/components/code-editor.md +38 -0
  119. package/docs/components/composer.md +107 -0
  120. package/docs/components/context-menu.md +32 -0
  121. package/docs/components/copy.md +37 -0
  122. package/docs/components/data-filter.md +16 -0
  123. package/docs/components/date-picker.md +31 -0
  124. package/docs/components/date-range.md +21 -0
  125. package/docs/components/datebox.md +31 -0
  126. package/docs/components/dialog.md +25 -0
  127. package/docs/components/dock.md +57 -0
  128. package/docs/components/dropdown.md +39 -0
  129. package/docs/components/elements.md +63 -0
  130. package/docs/components/empty-state.md +17 -0
  131. package/docs/components/entity-ref.md +26 -0
  132. package/docs/components/field-upload.md +18 -0
  133. package/docs/components/file-item.md +27 -0
  134. package/docs/components/file-list.md +23 -0
  135. package/docs/components/filter-panel.md +45 -0
  136. package/docs/components/filter.md +47 -0
  137. package/docs/components/finder.md +25 -0
  138. package/docs/components/form-widgets.md +42 -0
  139. package/docs/components/form.md +80 -0
  140. package/docs/components/grid.md +26 -0
  141. package/docs/components/groupbox.md +11 -0
  142. package/docs/components/helpers.md +359 -0
  143. package/docs/components/icons.md +87 -0
  144. package/docs/components/index.md +99 -0
  145. package/docs/components/kanban-view.md +42 -0
  146. package/docs/components/kbd.md +23 -0
  147. package/docs/components/kernel.md +41 -0
  148. package/docs/components/launcher.md +66 -0
  149. package/docs/components/layout.md +33 -0
  150. package/docs/components/list-toolbar.md +38 -0
  151. package/docs/components/loading.md +48 -0
  152. package/docs/components/menu-button.md +47 -0
  153. package/docs/components/message.md +76 -0
  154. package/docs/components/modal.md +27 -0
  155. package/docs/components/module-bar.md +71 -0
  156. package/docs/components/multi-value-editor.md +16 -0
  157. package/docs/components/navigation-bar.md +22 -0
  158. package/docs/components/number-field.md +34 -0
  159. package/docs/components/pagination.md +73 -0
  160. package/docs/components/panel.md +28 -0
  161. package/docs/components/prompt-starters.md +40 -0
  162. package/docs/components/prose.md +38 -0
  163. package/docs/components/questionnaire.md +115 -0
  164. package/docs/components/rating.md +19 -0
  165. package/docs/components/run-status.md +50 -0
  166. package/docs/components/run-trace.md +72 -0
  167. package/docs/components/search.md +11 -0
  168. package/docs/components/select.md +129 -0
  169. package/docs/components/sheet-stack.md +39 -0
  170. package/docs/components/sheet.md +77 -0
  171. package/docs/components/skeleton.md +27 -0
  172. package/docs/components/slider.md +29 -0
  173. package/docs/components/sort-control.md +21 -0
  174. package/docs/components/source-list.md +30 -0
  175. package/docs/components/split-view.md +12 -0
  176. package/docs/components/stat-tile.md +49 -0
  177. package/docs/components/stepper.md +27 -0
  178. package/docs/components/surface.md +152 -0
  179. package/docs/components/tabbox.md +33 -0
  180. package/docs/components/table-view.md +43 -0
  181. package/docs/components/table.md +232 -0
  182. package/docs/components/tag-picker.md +39 -0
  183. package/docs/components/timebox.md +16 -0
  184. package/docs/components/toggle.md +21 -0
  185. package/docs/components/tokens.md +82 -0
  186. package/docs/components/toolbar.md +26 -0
  187. package/docs/components/tooltip.md +16 -0
  188. package/docs/components/tree.md +48 -0
  189. package/docs/components/truncate.md +21 -0
  190. package/docs/components/value-list.md +14 -0
  191. package/docs/components/view-settings.md +56 -0
  192. package/docs/components/workspace-switcher.md +42 -0
  193. package/docs/components/zeyos.md +196 -0
  194. package/docs/llms-small.txt +299 -0
  195. package/docs/llms.md +697 -100
  196. package/docs/llms.txt +46 -19
  197. package/package.json +9 -4
  198. package/src/components/activity-item/activity-item.js +21 -2
  199. package/src/components/agent-avatar/agent-avatar.css +195 -0
  200. package/src/components/agent-avatar/agent-avatar.js +333 -0
  201. package/src/components/agent-avatar/agent-face.js +292 -0
  202. package/src/components/agent-thread/ag-ui.js +44 -11
  203. package/src/components/agent-thread/agent-thread.js +103 -11
  204. package/src/components/agent-thread/ui-message-stream.js +3 -1
  205. package/src/components/app-rail/app-rail.css +5 -0
  206. package/src/components/app-sidebar/app-sidebar.css +3 -0
  207. package/src/components/app-sidebar/app-sidebar.js +4 -3
  208. package/src/components/approval-card/approval-card.css +6 -0
  209. package/src/components/approval-card/approval-card.js +55 -7
  210. package/src/components/aurora/aurora.css +149 -14
  211. package/src/components/aurora/aurora.js +49 -6
  212. package/src/components/calendar/calendar.css +6 -2
  213. package/src/components/calendar/calendar.js +127 -47
  214. package/src/components/card-view/card-view.js +5 -6
  215. package/src/components/chart/chart.css +159 -1
  216. package/src/components/chart/chart.js +450 -62
  217. package/src/components/chart/color.js +297 -0
  218. package/src/components/chart/svg-adapter.js +576 -0
  219. package/src/components/chart/svg-geometry.js +323 -0
  220. package/src/components/check-button/check-button.js +3 -18
  221. package/src/components/checklist/checklist.js +46 -17
  222. package/src/components/checklist/field-adapter.js +4 -1
  223. package/src/components/code-editor/code-editor.css +33 -0
  224. package/src/components/code-editor/code-editor.js +97 -8
  225. package/src/components/code-editor/field-adapter.js +3 -0
  226. package/src/components/composer/composer.css +3 -0
  227. package/src/components/composer/composer.js +100 -22
  228. package/src/components/context-menu/context-menu.js +41 -5
  229. package/src/components/copy/copy-button.js +9 -1
  230. package/src/components/copy/copy-input.js +5 -0
  231. package/src/components/data-filter/filter-core.js +0 -1
  232. package/src/components/date-picker/date-picker.css +8 -0
  233. package/src/components/date-picker/date-picker.js +47 -8
  234. package/src/components/date-picker/date-range-picker.js +1 -1
  235. package/src/components/date-picker/month-picker.js +19 -3
  236. package/src/components/date-picker/time-picker.js +54 -19
  237. package/src/components/datebox/date-range-box.js +7 -3
  238. package/src/components/datebox/datebox.js +32 -6
  239. package/src/components/dialog/dialog.css +6 -0
  240. package/src/components/dialog/dialog.js +22 -30
  241. package/src/components/dropdown/dropdown.js +1 -18
  242. package/src/components/empty-state/empty-state.js +21 -2
  243. package/src/components/field/field.js +19 -3
  244. package/src/components/fieldset/fieldset.js +3 -1
  245. package/src/components/filter/filter.js +9 -0
  246. package/src/components/form/form.js +19 -2
  247. package/src/components/kanban-view/kanban-card.js +15 -2
  248. package/src/components/kanban-view/kanban-view.css +21 -0
  249. package/src/components/kanban-view/kanban-view.js +29 -16
  250. package/src/components/launcher/launcher.css +14 -0
  251. package/src/components/launcher/launcher.js +54 -9
  252. package/src/components/master-panel/master-panel.js +24 -22
  253. package/src/components/menu-button/menu-button.js +26 -4
  254. package/src/components/message/message.css +228 -29
  255. package/src/components/message/message.js +664 -30
  256. package/src/components/modal/modal.js +70 -25
  257. package/src/components/modal/native-dialog.js +91 -0
  258. package/src/components/module-bar/module-bar.css +3 -0
  259. package/src/components/module-bar/module-bar.js +17 -4
  260. package/src/components/multi-value-editor/multi-value-editor.css +7 -2
  261. package/src/components/multi-value-editor/multi-value-editor.js +3 -2
  262. package/src/components/navigation-bar/navigation-bar.js +13 -1
  263. package/src/components/number-field/field-adapter.js +3 -0
  264. package/src/components/number-field/number-field.js +2 -1
  265. package/src/components/pagination/pagination.css +26 -2
  266. package/src/components/pagination/pagination.js +551 -65
  267. package/src/components/prose/prose.js +7 -1
  268. package/src/components/rating/field-adapter.js +3 -0
  269. package/src/components/run-status/run-status.js +43 -3
  270. package/src/components/run-trace/run-trace.js +15 -7
  271. package/src/components/search/search.js +3 -18
  272. package/src/components/select/field-adapter.js +8 -1
  273. package/src/components/select/select.js +68 -13
  274. package/src/components/sheet/sheet.js +27 -8
  275. package/src/components/slider/field-adapter.js +3 -0
  276. package/src/components/slider/slider.js +4 -6
  277. package/src/components/stat-tile/stat-tile.js +24 -9
  278. package/src/components/stepper/stepper.css +15 -0
  279. package/src/components/stepper/stepper.js +34 -2
  280. package/src/components/surface/catalog.js +185 -28
  281. package/src/components/surface/surface.js +10 -5
  282. package/src/components/tabbox/tabbox.js +13 -1
  283. package/src/components/table/table.css +160 -2
  284. package/src/components/table/table.js +479 -52
  285. package/src/components/table/window.js +46 -4
  286. package/src/components/table-view/table-view.js +1 -10
  287. package/src/components/tag-picker/field-adapter.js +3 -0
  288. package/src/components/tag-picker/tag-picker.js +2 -0
  289. package/src/components/timebox/field-adapter.js +3 -0
  290. package/src/components/toggle/toggle.js +51 -27
  291. package/src/components/tooltip/tooltip.js +21 -14
  292. package/src/components/tree/tree.js +87 -14
  293. package/src/components/truncate/truncate.js +21 -5
  294. package/src/components/value-list/value-list.js +37 -9
  295. package/src/components/view-settings/view-settings.js +1 -5
  296. package/src/core/component.js +34 -2
  297. package/src/core/date.js +5 -4
  298. package/src/core/drag-axis.js +24 -7
  299. package/src/core/export.js +4 -4
  300. package/src/core/fontawesome.js +34 -3
  301. package/src/core/format.js +3 -1
  302. package/src/core/http.js +23 -11
  303. package/src/core/icons.js +51 -10
  304. package/src/core/keyboard.js +83 -9
  305. package/src/core/messages.js +3 -0
  306. package/src/core/position.js +2 -2
  307. package/src/core/storage.js +80 -31
  308. package/src/core/util.js +16 -5
  309. package/src/elements/define.js +82 -47
  310. package/src/elements/kit.js +46 -35
  311. package/src/index.js +8 -4
  312. package/src/internal/agent-model.js +152 -0
  313. package/src/internal/app-rail.js +53 -2
  314. package/src/internal/collections.js +25 -0
  315. package/src/internal/menu-items.js +59 -0
  316. package/src/internal/overlay-content.js +35 -0
  317. package/src/internal/presence-loop.js +61 -14
  318. package/src/locales/de.js +3 -0
  319. package/src/zeyos/calendar.js +81 -19
  320. package/src/zeyos/connect.js +5 -1
  321. package/src/zeyos/form.js +29 -10
  322. package/src/zeyos/select.js +36 -12
  323. package/src/zeyos/table.js +43 -11
  324. package/src/zeyos/view.js +2 -1
  325. package/styles/tokens/semantic.css +7 -1
  326. package/styles/zx.css +1 -0
@@ -37,7 +37,8 @@ import { uid } from '../../core/util.js';
37
37
  * control has none.
38
38
  * @property {() => void} [destroy] Release adapter-owned resources.
39
39
  * @property {Element} [labelTarget] The element the field's label, description, and validity
40
- * belong to when it is not `el` — the text input inside a composite control. Left out, a
40
+ * belong to when it is not `el` — the text input inside a composite control. The field's label
41
+ * names it through `aria-labelledby`, over any name the component gave it. Left out, a
41
42
  * wrapper that cannot be labelled hands them to the first unnamed form control inside it.
42
43
  */
43
44
 
@@ -105,7 +106,7 @@ export class Field extends Component {
105
106
  // `adapter` (FieldAdapter), `initialValue`, `controlId` (the control's DOM id), and `name` (the
106
107
  // field name, '' when there is none) are assigned in render(); declaring them as class fields
107
108
  // would re-initialize them to undefined after the base constructor (which calls render())
108
- // returns — see AGENTS.md.
109
+ // returns.
109
110
 
110
111
  /** @returns {HTMLElement} */
111
112
  render() {
@@ -172,7 +173,22 @@ export class Field extends Component {
172
173
  this._labelled = labelled;
173
174
  if (labelled !== control && isLabelable(labelled) && !labelled.id) labelled.id = `${this.controlId}-input`;
174
175
  label.htmlFor = isLabelable(labelled) ? labelled.id : control.id;
175
- if (!isLabelable(labelled)) labelled.setAttribute('aria-labelledby', labelId);
176
+ // The field's label names the control. A wrapper has no `<label for>`; the input inside a
177
+ // composite usually carries a name of its own — an `aria-label`, which beats `<label for>`,
178
+ // or a visually hidden label of its own that would be read as well — so both are pointed at
179
+ // the label explicitly. A plain native control keeps `<label for>` alone.
180
+ if (!isLabelable(labelled) || labelled !== control || labelled.hasAttribute('aria-label')) {
181
+ labelled.setAttribute('aria-labelledby', labelId);
182
+ }
183
+ // A group (a rating's radios, a duration's segments) cannot be the target of `<label for>`, so
184
+ // a click on the label is turned into the adapter's own focus.
185
+ if (!isLabelable(labelled)) {
186
+ this.listen(label, 'click', (event) => {
187
+ if (event.defaultPrevented) return;
188
+ event.preventDefault();
189
+ this.adapter.focus();
190
+ });
191
+ }
176
192
  this._baseDescribedBy = labelled.getAttribute('aria-describedby') ?? '';
177
193
  controlSlot.append(control);
178
194
  this._descriptionId = String(this.options.description ?? '') ? descriptionId : '';
@@ -197,7 +197,9 @@ export class Fieldset extends Component {
197
197
  * @returns {this}
198
198
  */
199
199
  clear() {
200
- for (const field of [...this._fields.values()]) this._releaseField(field);
200
+ // Borrowed fields go back last-adopted first: each one's saved next sibling may be an
201
+ // earlier-adopted one, which has to be back in place before it can serve as the anchor.
202
+ for (const field of [...this._fields.values()].reverse()) this._releaseField(field);
201
203
  this._fields.clear();
202
204
  return this;
203
205
  }
@@ -678,6 +678,9 @@ export class Filter extends Component {
678
678
  _setNodeValue(id, value) {
679
679
  const node = findNode(this._value.root, id);
680
680
  if (node?.kind !== 'condition') return;
681
+ // One edit can reach here twice — a value <select> fires `input` and then `change`, a text
682
+ // input its `change` on blur after the last `input` — and only the first carries news.
683
+ if (sameFilterValue(node.value, value)) return;
681
684
  node.value = value;
682
685
  const result = this.validate();
683
686
  this.el.dataset.valid = String(result.valid);
@@ -974,6 +977,12 @@ function conditionNodes(node) { if (!node) return []; if (node.kind === 'conditi
974
977
  function parseScalar(value, type) { if (value === '') return null; if (['number', 'money'].includes(type)) { const number = Number(value); return Number.isFinite(number) ? number : null; } if (type === 'boolean') return value === 'true'; return value; }
975
978
  /** @param {unknown} value @returns {any} */
976
979
  function parseValueJson(value) { return cloneFilterValue(value === undefined ? null : value); }
980
+ /**
981
+ * Whether two JSON-safe condition values are the same value: equal scalars, or arrays and
982
+ * objects with the same content.
983
+ * @param {unknown} left @param {unknown} right @returns {boolean}
984
+ */
985
+ function sameFilterValue(left, right) { return Object.is(left, right) || JSON.stringify(left ?? null) === JSON.stringify(right ?? null); }
977
986
  /** @param {any} root @param {string} id @returns {any|null} */
978
987
  function findNode(root, id) { if (!root || root.id === id) return root ?? null; if (root.kind === 'group') for (const child of root.children) { const match = findNode(child, id); if (match) return match; } return null; }
979
988
  /** @param {any} root @param {string} id @returns {any|null} */
@@ -218,7 +218,8 @@ export class Form extends Component {
218
218
  }
219
219
 
220
220
  /**
221
- * Validates and emits a preventable submit event.
221
+ * Validates and emits a preventable submit event. A disabled field — disabled itself, or inside
222
+ * a disabled `<fieldset>` — is not validated, so it can neither block the submit nor take focus.
222
223
  * @returns {boolean} True when valid and not prevented.
223
224
  * @fires Form#submit
224
225
  * @fires Form#invalid
@@ -228,6 +229,10 @@ export class Form extends Component {
228
229
  let firstInvalid = null;
229
230
  for (const fieldset of this._fieldsets) {
230
231
  for (const [id, field] of Object.entries(fieldset.getFields())) {
232
+ if (isDisabledField(field)) {
233
+ field.clearHighlight();
234
+ continue;
235
+ }
231
236
  const value = field.getValue();
232
237
  let message = '';
233
238
  if (field.options.required && isEmpty(value)) {
@@ -271,7 +276,9 @@ export class Form extends Component {
271
276
 
272
277
  /** @returns {void} */
273
278
  destroy() {
274
- for (const fieldset of this._fieldsets ?? []) {
279
+ // Borrowed fieldsets go back last-adopted first: each one's saved next sibling may be an
280
+ // earlier-adopted one, which has to be back in place before it can serve as the anchor.
281
+ for (const fieldset of [...(this._fieldsets ?? [])].reverse()) {
275
282
  if (this._ownedFieldsets.has(fieldset)) fieldset.destroy();
276
283
  else {
277
284
  const origin = this._origins.get(fieldset);
@@ -290,6 +297,16 @@ export class Form extends Component {
290
297
  }
291
298
  }
292
299
 
300
+ /**
301
+ * Whether a field is disabled: through `Field#setDisabled()` (or its `disabled` option), or by a
302
+ * disabled `<fieldset>` around it.
303
+ * @param {import('../field/field.js').Field} field
304
+ * @returns {boolean}
305
+ */
306
+ function isDisabledField(field) {
307
+ return field.el.dataset.disabled === 'true' || Boolean(field.el.closest?.('fieldset:disabled'));
308
+ }
309
+
293
310
  /** @param {unknown} value @returns {boolean} */
294
311
  function isEmpty(value) {
295
312
  return value == null || value === '' || value === false || (Array.isArray(value) && value.length === 0);
@@ -1,6 +1,8 @@
1
1
  // @ts-check
2
2
  import { h, safeHref } from '../../core/dom.js';
3
3
  import { icon } from '../../core/icons.js';
4
+ import { agentAvatarOptions, authorFace } from '../../internal/agent-model.js';
5
+ import { AgentAvatar } from '../agent-avatar/agent-avatar.js';
4
6
  import { AVATAR_TONES, avatarInitials, avatarTone } from '../avatar/avatar.js';
5
7
  import { badge } from '../badge/badge.js';
6
8
 
@@ -31,6 +33,9 @@ import { badge } from '../badge/badge.js';
31
33
  * @property {import('../avatar/avatar.js').AvatarTone} tone Fallback tint: a descriptor's own
32
34
  * `tone` when it names one of `AVATAR_TONES`, otherwise `avatarTone(name)` — the colour the same
33
35
  * person has in every Avatar.
36
+ * @property {Record<string, string>|null} face An agent's face traits — `seed`, `tone`, `body`,
37
+ * `eyes`, `material` — when the descriptor carries `face`; the card draws its AgentAvatar instead of
38
+ * initials or a picture.
34
39
  */
35
40
 
36
41
  /** Semantic intents an indicator may carry, in the order they are documented. */
@@ -137,6 +142,7 @@ export function createKanbanProgress(progress, label, valueText) {
137
142
  * resolve to the same shape, and an unsafe image URL degrades to initials rather than failing.
138
143
  * A descriptor may name its `tone`; otherwise the tone is derived from the name exactly as Avatar
139
144
  * derives it.
145
+ * A descriptor with `face` (AgentAvatar traits, or `true`) is an agent, drawn as its face.
140
146
  * @param {unknown} value Raw field value.
141
147
  * @returns {KanbanAssignee[]} Normalized people, in the order supplied.
142
148
  */
@@ -154,7 +160,9 @@ export function resolveKanbanAssignees(value) {
154
160
  const src = safeHref(source.src ?? source.image ?? null);
155
161
  const initials = source.initials == null ? avatarInitials(name) : String(source.initials);
156
162
  const tone = AVATAR_TONES.includes(source.tone) ? source.tone : avatarTone(name);
157
- return { name, src, initials, tone };
163
+ // Records come from the server: a face contributes its trait strings and nothing else.
164
+ const face = source.face == null ? null : authorFace({ face: source.face });
165
+ return { name, src, initials, tone, face };
158
166
  }).filter(Boolean));
159
167
  }
160
168
 
@@ -192,7 +200,12 @@ export function createKanbanAvatars(people, max, groupLabel, overflowLabel) {
192
200
  const shown = people.slice(0, split.shown);
193
201
  const hidden = split.hidden;
194
202
  // Each face carries its tone, so the initials sit on the tint the person has in every Avatar.
195
- const faces = shown.map((person) => h('span', {
203
+ const faces = shown.map((person) => person.face ? h('span', {
204
+ class: 'zx-kanban-view__avatar', ariaHidden: 'true', title: person.name || undefined,
205
+ dataset: { agent: '' }
206
+ // A face at rest holds no listener and no loop entry, so it goes with the card that holds it.
207
+ }, new AgentAvatar(null, agentAvatarOptions(person.face, { name: person.name, size: 'sm', label: null, activity: null, animate: false })).toElement())
208
+ : h('span', {
196
209
  class: 'zx-kanban-view__avatar', ariaHidden: 'true', title: person.name || undefined,
197
210
  dataset: { tone: person.tone ?? avatarTone(person.name) }
198
211
  }, person.src
@@ -810,6 +810,27 @@
810
810
  color: var(--zx-color-text-muted);
811
811
  }
812
812
 
813
+ /* An agent is its own silhouette: no disc, no ring, and no overlap, so no face cuts into another. */
814
+ .zx-kanban-view__avatar[data-agent] {
815
+ overflow: visible;
816
+ border-radius: 0;
817
+ box-shadow: none;
818
+ background: none;
819
+ }
820
+
821
+ .zx-kanban-view__avatar[data-agent],
822
+ .zx-kanban-view__avatar[data-agent] + .zx-kanban-view__avatar {
823
+ margin-inline-start: 1px;
824
+ }
825
+
826
+ .zx-kanban-view__avatars > .zx-kanban-view__avatar[data-agent]:first-child {
827
+ margin-inline-start: 0;
828
+ }
829
+
830
+ .zx-kanban-view__avatar[data-agent] > .zx-agent-avatar {
831
+ --zx-agent-avatar-size: 1.5rem;
832
+ }
833
+
813
834
  .zx-kanban-view__avatar-image {
814
835
  inline-size: 100%;
815
836
  block-size: 100%;
@@ -3,6 +3,7 @@ import { h, restoreTarget, snapshotTarget } from '../../core/dom.js';
3
3
  import { ICON_SIZE, icon } from '../../core/icons.js';
4
4
  import { printf, translate } from '../../core/i18n.js';
5
5
  import { uid } from '../../core/util.js';
6
+ import { sameArray } from '../../internal/collections.js';
6
7
  import { badge } from '../badge/badge.js';
7
8
  import { createRecordCard, resolveRecordActions } from '../card-view/record-card.js';
8
9
  import { ContextMenu } from '../context-menu/context-menu.js';
@@ -160,7 +161,9 @@ import {
160
161
  * @property {Record<string,string>} [priorityTones={}] Maps a priority value to a semantic tone.
161
162
  * @property {KanbanCardField} [progress=null] Completion source; a number or `{value,max,label}`.
162
163
  * @property {number} [progressMax=100] Amount that counts as finished.
163
- * @property {KanbanCardField} [assignees=null] Responsible people; a name, a list, or descriptors.
164
+ * @property {KanbanCardField} [assignees=null] Responsible people; a name, a list, or descriptors
165
+ * (`{name, src?, initials?, tone?}`). A descriptor with `face` — AgentAvatar traits, or `true` —
166
+ * is an agent, drawn as its generated face.
164
167
  * @property {number} [maxAvatars=3] Faces drawn before the overflow chip.
165
168
  * @property {boolean} [multiMove=true] Move the whole selection when a selected card is picked up.
166
169
  * @property {boolean} [autoScroll=true] Scroll the board and columns while dragging near an edge.
@@ -209,7 +212,11 @@ import {
209
212
 
210
213
  /** @typedef {{record:KanbanRecord,id:unknown,index:number,column:string,lane:string|null}} KanbanCardMeta */
211
214
  /** @typedef {{column:string,lane:string|null,list:HTMLElement}} KanbanSectionMeta */
212
- /** @typedef {{ids:unknown[],from:KanbanMovePoint,to:KanbanMovePoint}} KanbanKeyboardMove */
215
+ /**
216
+ * A keyboard move in progress: the ids moving, where the grabbed card was, where it was picked up
217
+ * and where it would land now (both counted among the visible cards that are not moving).
218
+ * @typedef {{ids:unknown[],from:KanbanMovePoint,origin:KanbanMovePoint,to:KanbanMovePoint}} KanbanKeyboardMove
219
+ */
213
220
  /** @typedef {((record:KanbanRecord,index:number)=>unknown)|null} KanbanCardReader */
214
221
  /**
215
222
  * @typedef {Object} KanbanCardSources
@@ -259,8 +266,9 @@ const SCROLL_SPEED = 18;
259
266
  export class KanbanView extends RecordView {
260
267
  static cssName = 'kanban-view';
261
268
 
269
+ // Marked pure: a bare spread in a static initialiser keeps the class in every bundle of the entry.
262
270
  /** @type {Readonly<KanbanViewOptions & RecordViewOptions>} */
263
- static defaults = {
271
+ static defaults =/* @__PURE__ */ (() => ({
264
272
  ...RecordView.defaults,
265
273
  selectionTrigger: 'checkbox',
266
274
  columnBy: 'status',
@@ -315,7 +323,7 @@ export class KanbanView extends RecordView {
315
323
  variant: 'outlined',
316
324
  // Undefined rather than null, which leaves the board unnamed.
317
325
  label: undefined
318
- };
326
+ }))();
319
327
 
320
328
  /**
321
329
  * Creates a Kanban record view.
@@ -1958,13 +1966,17 @@ export class KanbanView extends RecordView {
1958
1966
  const card = /** @type {HTMLElement|null} */ (handle.closest('.zx-record-card'));
1959
1967
  if (card) delete card.dataset.grabbed;
1960
1968
  this._syncKeyboardTarget();
1961
- this._commitInteractionMove(move.ids, move.to);
1969
+ // Dropped where it was picked up, nothing moves — not even a selection that was not one
1970
+ // unbroken run, which committing that position would close up.
1971
+ if (!sameMovePoint(move.to, move.origin)) this._commitInteractionMove(move.ids, move.to);
1962
1972
  } else {
1963
1973
  const from = this._recordLocation(meta.id);
1964
1974
  if (!from) return;
1965
1975
  const ids = this._movingIds(meta.id);
1966
- const start = { ...from, index: this._visibleIndex(meta.id) };
1967
- this._keyboardMove = { ids, from: { ...from }, to: start };
1976
+ // The target is counted among the cards that stay, so the grabbed card starts after the
1977
+ // ones before it that are not coming along.
1978
+ const start = { ...from, index: this._visibleIndex(meta.id, new Set(ids)) };
1979
+ this._keyboardMove = { ids, from: { ...from }, origin: { ...start }, to: start };
1968
1980
  handle.setAttribute('aria-pressed', 'true');
1969
1981
  const card = handle.closest('.zx-record-card');
1970
1982
  if (card) /** @type {HTMLElement} */ (card).dataset.grabbed = 'true';
@@ -2271,12 +2283,18 @@ export class KanbanView extends RecordView {
2271
2283
  }).length;
2272
2284
  }
2273
2285
 
2274
- /** @param {unknown} id Record id. @returns {number} Position among visible cards in its bucket. */
2275
- _visibleIndex(id) {
2286
+ /**
2287
+ * @param {unknown} id Record id.
2288
+ * @param {Set<unknown>} [excluded] Cards that do not count, such as the others moving with it.
2289
+ * @returns {number} Position among the visible cards in its bucket.
2290
+ */
2291
+ _visibleIndex(id, excluded = new Set()) {
2276
2292
  const location = this._recordLocation(id);
2277
2293
  if (!location) return 0;
2278
- const visible = this._recordsIn(location.column, location.lane)
2279
- .filter((entry) => this._visibleIds.has(this._viewRecordId(entry.record)));
2294
+ const visible = this._recordsIn(location.column, location.lane).filter((entry) => {
2295
+ const candidate = this._viewRecordId(entry.record);
2296
+ return this._visibleIds.has(candidate) && (Object.is(candidate, id) || !hasId(excluded, candidate));
2297
+ });
2280
2298
  const position = visible.findIndex((entry) => Object.is(this._viewRecordId(entry.record), id));
2281
2299
  return position < 0 ? visible.length : position;
2282
2300
  }
@@ -2661,11 +2679,6 @@ function sameMovePoint(left, right) {
2661
2679
  return left.column === right.column && left.lane === right.lane && left.index === right.index;
2662
2680
  }
2663
2681
 
2664
- /** @param {unknown[]} left @param {unknown[]} right @returns {boolean} */
2665
- function sameArray(left, right) {
2666
- return left.length === right.length && left.every((value, index) => Object.is(value, right[index]));
2667
- }
2668
-
2669
2682
  /** @param {Set<unknown>|unknown[]} haystack @param {unknown} needle @returns {boolean} */
2670
2683
  function hasId(haystack, needle) {
2671
2684
  for (const candidate of haystack) if (Object.is(candidate, needle)) return true;
@@ -232,6 +232,20 @@
232
232
  }
233
233
 
234
234
  .zx-launcher__icon { display: inline-flex; flex: none; }
235
+
236
+ /* An agent item draws its face: a little larger than a glyph in a row, a tile's size in a grid. */
237
+ .zx-launcher__icon > .zx-agent-avatar { --zx-agent-avatar-size: var(--zx-space-5); }
238
+ .zx-launcher__option[data-kind="application"] .zx-launcher__icon > .zx-agent-avatar { --zx-agent-avatar-size: var(--zx-space-7); }
239
+
240
+ /* An agent's activity word: part of the option's name, not of what is shown. */
241
+ .zx-launcher__word {
242
+ position: absolute;
243
+ inline-size: 1px;
244
+ block-size: 1px;
245
+ overflow: hidden;
246
+ clip-path: inset(50%);
247
+ white-space: nowrap;
248
+ }
235
249
  .zx-launcher__copy { display: grid; min-inline-size: 0; gap: 2px; }
236
250
  .zx-launcher__label { overflow: hidden; font-weight: var(--zx-weight-medium); text-overflow: ellipsis; white-space: nowrap; }
237
251
  .zx-launcher__description { overflow: hidden; color: var(--zx-color-text-muted); font-size: var(--zx-text-sm); text-overflow: ellipsis; white-space: nowrap; }
@@ -1,10 +1,13 @@
1
1
  import { Component } from '../../core/component.js';
2
+ import { AgentAvatar } from '../agent-avatar/agent-avatar.js';
3
+ import { AGENT_ITEM_KEYS, agentAvatarOptions } from '../../internal/agent-model.js';
2
4
  import { h, safeHref } from '../../core/dom.js';
3
5
  import { ICON_SIZE, icon } from '../../core/icons.js';
4
6
  import { printf } from '../../core/i18n.js';
5
7
  import { connectedOverlayHost, overlayScope } from '../../core/overlay-host.js';
6
8
  import { pushOverlay } from '../../core/overlay-stack.js';
7
9
  import { uid } from '../../core/util.js';
10
+ import { closeDialog, isDialogOpen, modalDialogs, showDialogModal } from '../modal/native-dialog.js';
8
11
  import { kbd } from '../kbd/kbd.js';
9
12
 
10
13
  /**
@@ -15,6 +18,9 @@ import { kbd } from '../kbd/kbd.js';
15
18
  * @property {string|string[]} [keywords] Additional search text.
16
19
  * @property {string} [group] Result group.
17
20
  * @property {string|Node|((item: LauncherItem) => Node|null)} [icon] Decorative icon name, node, or factory.
21
+ * @property {import('../../internal/app-rail.js').AppNavAgent|true} [agent] Draws the item as an
22
+ * agent: its AgentAvatar, still, in place of `icon` — these options, or `true` to derive it from
23
+ * the label. An activity's word joins the option's accessible name.
18
24
  * @property {string|number} [badge] Compact metadata.
19
25
  * @property {string|number} [hint] Muted text at the end of the row, such as a current value or a project.
20
26
  * @property {string|string[]|{label: string|string[], keys?: string}} [shortcut] Key labels drawn as
@@ -161,6 +167,12 @@ export class Launcher extends Component {
161
167
  throw new TypeError('Launcher target must be a <dialog> element');
162
168
  }
163
169
  this._createdRoot = this.el === null;
170
+ /**
171
+ * The faces of agent items, one per item id, reused while results redraw on every keystroke and
172
+ * destroyed with the launcher.
173
+ * @type {Map<string, {signature: string, avatar: AgentAvatar}>}
174
+ */
175
+ this._agentFaces = new Map();
164
176
  /** @type {import('../../core/overlay-stack.js').OverlayHandle|null} Entry on the overlay stack while open. */
165
177
  this._overlay = null;
166
178
  const dialog = /** @type {HTMLDialogElement} */ (this.el ?? h('dialog'));
@@ -310,7 +322,7 @@ export class Launcher extends Component {
310
322
  // Native close is queued; a newer presentation owns its state and requests now.
311
323
  const presentation = this._closingPresentations.shift();
312
324
  if (presentation !== undefined && presentation !== this._presentation) return;
313
- if (dialog.open) return;
325
+ if (isDialogOpen(dialog)) return;
314
326
  this._releaseOverlay();
315
327
  dialog.dataset.state = 'closed';
316
328
  input.setAttribute('aria-expanded', 'false');
@@ -318,7 +330,7 @@ export class Launcher extends Component {
318
330
  // The next opening starts on the root, so an application that sets the query or the items
319
331
  // before opening sets them on the level that will show. Reopened in the meantime, the
320
332
  // launcher keeps the page it was opened on.
321
- if (this._pages.length && !dialog.open) {
333
+ if (this._pages.length && !isDialogOpen(dialog)) {
322
334
  this._unwind();
323
335
  this._announcePending = false;
324
336
  this._syncPage();
@@ -359,7 +371,8 @@ export class Launcher extends Component {
359
371
  }
360
372
  const before = this._pages.map((entry) => entry.page);
361
373
  const opener = document.activeElement;
362
- this.el.showModal();
374
+ // Without `showModal()` — a DOM implementation used for unit tests — the `open` attribute.
375
+ showDialogModal(this.el);
363
376
  this._presentation += 1;
364
377
  /*
365
378
  * A modal on the overlay stack, like every Modal: Escape and presses inside it then reach no
@@ -406,7 +419,7 @@ export class Launcher extends Component {
406
419
  close() {
407
420
  if (this.isOpen()) {
408
421
  this._closingPresentations.push(this._presentation);
409
- this.el.close();
422
+ closeDialog(this.el);
410
423
  }
411
424
  return this;
412
425
  }
@@ -418,7 +431,7 @@ export class Launcher extends Component {
418
431
 
419
432
  /** Reports whether the launcher is open. @returns {boolean} */
420
433
  isOpen() {
421
- return Boolean(this.el.open);
434
+ return isDialogOpen(this.el);
422
435
  }
423
436
 
424
437
  /** Focuses and selects the query field. @returns {this} */
@@ -489,9 +502,11 @@ export class Launcher extends Component {
489
502
  this._destroyed = true;
490
503
  const original = this._original;
491
504
  this._abortRequest();
492
- if (this.isOpen()) this.el.close();
505
+ if (this.isOpen()) closeDialog(this.el);
493
506
  // The queued close that would release it never arrives once listeners are aborted.
494
507
  this._releaseOverlay();
508
+ for (const { avatar } of this._agentFaces.values()) avatar.destroy();
509
+ this._agentFaces.clear();
495
510
  super.destroy();
496
511
  if (!this._createdRoot && original) {
497
512
  for (const attribute of Array.from(this.el.attributes)) this.el.removeAttribute(attribute.name);
@@ -790,13 +805,17 @@ export class Launcher extends Component {
790
805
  const href = page ? null : safeHref(item.href);
791
806
  const tag = href ? 'a' : 'button';
792
807
  const children = [];
793
- const visual = launcherItemIcon(item);
808
+ const face = this._agentFace(item);
809
+ const visual = face ? face.toElement() : launcherItemIcon(item);
794
810
  if (visual) children.push(h('span', {
795
811
  class: 'zx-launcher__icon',
796
812
  ariaHidden: 'true'
797
813
  }, visual));
814
+ // An agent's activity is in its face and dot; the option's name says it too, after the label.
815
+ const word = face?.getActivityWord() ?? null;
798
816
  children.push(h('span', { class: 'zx-launcher__copy' },
799
- h('span', { class: 'zx-launcher__label' }, item.label),
817
+ h('span', { class: 'zx-launcher__label' }, item.label,
818
+ word ? h('span', { class: 'zx-launcher__word' }, `, ${word}`) : null),
800
819
  item.description ? h('span', { class: 'zx-launcher__description' }, item.description) : null));
801
820
  if (item.badge != null) children.push(h('span', { class: 'zx-launcher__badge' }, String(item.badge)));
802
821
  if (item.hint != null && item.hint !== '') {
@@ -830,6 +849,29 @@ export class Launcher extends Component {
830
849
  }, children));
831
850
  }
832
851
 
852
+ /**
853
+ * The AgentAvatar an agent item draws, kept per item id and rebuilt only when the item changes.
854
+ * @private
855
+ * @param {LauncherItem} item
856
+ * @returns {AgentAvatar|null}
857
+ */
858
+ _agentFace(item) {
859
+ if (!item.agent) return null;
860
+ const key = String(item.id);
861
+ const size = normalizeLauncherKind(item.kind) === 'application' ? 'md' : 'sm';
862
+ const options = agentAvatarOptions(item.agent, { size, label: null, animate: false },
863
+ { fallback: { name: String(item.label) }, carry: AGENT_ITEM_KEYS });
864
+ if (!options) return null;
865
+ const signature = JSON.stringify(options);
866
+ let entry = this._agentFaces.get(key);
867
+ if (!entry || entry.signature !== signature) {
868
+ entry?.avatar.destroy();
869
+ entry = { signature, avatar: new AgentAvatar(null, options) };
870
+ this._agentFaces.set(key, entry);
871
+ }
872
+ return entry.avatar;
873
+ }
874
+
833
875
  /** @returns {void} */
834
876
  _renderStatus() {
835
877
  if (this._busy) {
@@ -867,6 +909,9 @@ export class Launcher extends Component {
867
909
  /** @param {KeyboardEvent} event @returns {void} */
868
910
  _onKeydown(event) {
869
911
  if (event.key === 'Escape') {
912
+ // Claimed, so the key ends here: a dialog the launcher was opened from leaves a prevented
913
+ // Escape alone, and would otherwise close in the same keystroke.
914
+ event.preventDefault();
870
915
  this.close();
871
916
  return;
872
917
  }
@@ -992,7 +1037,7 @@ export class Launcher extends Component {
992
1037
  if (active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement
993
1038
  || active instanceof HTMLSelectElement
994
1039
  || (active instanceof HTMLElement && active.isContentEditable)) return;
995
- const modal = document.querySelector('dialog:modal');
1040
+ const modal = modalDialogs(document)[0];
996
1041
  if (modal && modal !== this.el) return;
997
1042
  event.preventDefault();
998
1043
  this.open();
@@ -1,5 +1,5 @@
1
1
  import { Component } from '../../core/component.js';
2
- import { h } from '../../core/dom.js';
2
+ import { h, restoreTarget, snapshotTarget } from '../../core/dom.js';
3
3
  import { isElement } from '../../core/util.js';
4
4
  import { button } from '../button/button.js';
5
5
 
@@ -63,8 +63,10 @@ export class MasterPanel extends Component {
63
63
  const root = /** @type {HTMLElement} */ (this.el ?? h('section'));
64
64
  this.el = root;
65
65
  this._createdRoot = created;
66
- this._original = created ? null : snapshot(root);
66
+ this._snapshot = created ? null : snapshotTarget(root);
67
67
  this._cleaned = false;
68
+ /** @type {WeakMap<Element, (event: MouseEvent) => void>} Click callbacks of descriptor buttons. */
69
+ this._clicks = new WeakMap();
68
70
 
69
71
  const originalContent = created ? [] : Array.from(root.childNodes);
70
72
  const header = h('header', { class: 'zx-master-panel__header' },
@@ -86,6 +88,9 @@ export class MasterPanel extends Component {
86
88
  hidden: true
87
89
  });
88
90
  root.replaceChildren(header, content, footer);
91
+ // One listener for every descriptor button, present and future: buttons that setButtons()
92
+ // replaces take their callbacks with them instead of piling up listeners until destroy().
93
+ this.listen(this.refs.buttons, 'click', (event) => this._onButtonClick(/** @type {MouseEvent} */ (event)));
89
94
 
90
95
  const moduleName = normalizeModule(this.options.module);
91
96
  root.dataset.module = moduleName;
@@ -133,7 +138,7 @@ export class MasterPanel extends Component {
133
138
  const onclick = descriptor.onclick;
134
139
  delete descriptor.onclick;
135
140
  const element = button(descriptor);
136
- if (typeof onclick === 'function') this.listen(element, 'click', onclick);
141
+ if (typeof onclick === 'function') this._clicks.set(element, onclick);
137
142
  return element;
138
143
  });
139
144
  this.refs.buttons.replaceChildren(...elements);
@@ -156,27 +161,24 @@ export class MasterPanel extends Component {
156
161
  if (this._cleaned) return;
157
162
  this._cleaned = true;
158
163
  super.destroy();
159
- if (!this._createdRoot && this._original) restore(this.el, this._original);
164
+ if (!this._createdRoot) restoreTarget(this.el, this._snapshot);
160
165
  }
161
- }
162
166
 
163
- /** @param {Element} element @returns {{attributes: Array<[string, string]>, children: Node[]}} */
164
- function snapshot(element) {
165
- return {
166
- attributes: Array.from(element.attributes, (attribute) => [attribute.name, attribute.value]),
167
- children: Array.from(element.childNodes)
168
- };
169
- }
170
-
171
- /**
172
- * @param {Element} element
173
- * @param {{attributes: Array<[string, string]>, children: Node[]}} original
174
- * @returns {void}
175
- */
176
- function restore(element, original) {
177
- for (const attribute of Array.from(element.attributes)) element.removeAttribute(attribute.name);
178
- for (const [name, value] of original.attributes) element.setAttribute(name, value);
179
- element.replaceChildren(...original.children);
167
+ /**
168
+ * Runs the callback of the descriptor button a click landed in, with the button as `this`.
169
+ * @param {MouseEvent} event Click inside the action area.
170
+ * @returns {void}
171
+ */
172
+ _onButtonClick(event) {
173
+ const area = this.refs.buttons;
174
+ for (let node = /** @type {Element|null} */ (event.target); node && node !== area; node = node.parentElement) {
175
+ const callback = this._clicks.get(node);
176
+ if (callback) {
177
+ callback.call(node, event);
178
+ return;
179
+ }
180
+ }
181
+ }
180
182
  }
181
183
 
182
184
  /** @param {Element} target @param {MasterPanelContent} content @param {string} label @returns {void} */
@@ -4,8 +4,10 @@ import { uid } from '../../core/util.js';
4
4
  import { icon } from '../../core/icons.js';
5
5
  import { rovingTabindex, typeahead } from '../../core/keyboard.js';
6
6
  import {
7
+ applyCheckedState,
7
8
  isMenuItem,
8
9
  MENU_ITEM_SELECTOR,
10
+ nextCheckedState,
9
11
  renderMenuEntries
10
12
  } from '../../internal/menu-items.js';
11
13
  import { Dropdown } from '../dropdown/dropdown.js';
@@ -19,11 +21,19 @@ import { Dropdown } from '../dropdown/dropdown.js';
19
21
  * @property {'default'|'primary'|'danger'|'ghost'} [kind='default'] Trigger button kind.
20
22
  * @property {MenuButtonItem[]} [items=[]] Menu items and separators.
21
23
  * @property {'bottom-start'|'bottom-end'|'top-start'|'top-end'|'bottom'|'top'|'right-start'|'right-end'|'left-start'|'left-end'|'right'|'left'} [placement='bottom-start'] Menu placement.
22
- * @property {(event: CustomEvent<{value: unknown, item: MenuItem}>) => void} [onselect] Select event listener.
24
+ * @property {(event: CustomEvent<MenuButtonSelectDetail>) => void} [onselect] Select event listener.
23
25
  * @property {(event: CustomEvent<Record<string, never>>) => void} [onopen] Open event listener.
24
26
  * @property {(event: CustomEvent<Record<string, never>>) => void} [onclose] Close event listener.
25
27
  */
26
28
 
29
+ /**
30
+ * @typedef {Object} MenuButtonSelectDetail
31
+ * @property {unknown} value The chosen item's value.
32
+ * @property {MenuItem} item The chosen item, as the application gave it.
33
+ * @property {boolean} [checked] For a `menuitemcheckbox` or `menuitemradio`, the state choosing it
34
+ * gives the item: a checkbox toggles, a radio is checked. Absent for a plain item.
35
+ */
36
+
27
37
  /**
28
38
  * @typedef {Object} MenuButtonOpenOptions
29
39
  * @property {boolean|HTMLElement} [returnFocus=true] Where focus goes when this opening ends with a
@@ -37,6 +47,11 @@ import { Dropdown } from '../dropdown/dropdown.js';
37
47
  * Choosing an item closes the menu and puts focus back on the trigger before the `select` event
38
48
  * and the item's `onselect` run, so whatever they open — a dialog, a sheet — records the trigger
39
49
  * as the place to return to, and focus they move themselves stays where they put it.
50
+ *
51
+ * Choosing a `menuitemcheckbox` toggles its `aria-checked`, and choosing a `menuitemradio` checks
52
+ * it and unchecks the other radio items of its section (between separators or headings); the new
53
+ * state arrives as `detail.checked`. A `select` listener that prevents the event keeps the state as
54
+ * it was, and one that calls `setItems()` renders the state it wants instead.
40
55
  * @fires MenuButton#select
41
56
  * @fires MenuButton#open
42
57
  * @fires MenuButton#close
@@ -391,13 +406,19 @@ export class MenuButton extends Component {
391
406
  const active = document.activeElement;
392
407
  const reclaim = Boolean(target) && (!active || active === document.body || this.#panel.contains(active));
393
408
  if (reclaim) target?.focus();
394
- const selected = this.emit('select', { value: item.value, item });
409
+ const entries = this.#items;
410
+ const checked = nextCheckedState(item, element.getAttribute('aria-checked') === 'true');
411
+ const selected = this.emit('select', checked === undefined
412
+ ? { value: item.value, item }
413
+ : { value: item.value, item, checked });
395
414
  if (selected.defaultPrevented) {
396
415
  event?.preventDefault();
397
416
  // The menu stays open, so focus returns to the item, unless a listener has moved it again.
398
417
  if (reclaim && document.activeElement === target && element instanceof HTMLElement) element.focus();
399
418
  return;
400
419
  }
420
+ // A listener that replaced the items has rendered the state it wants already.
421
+ if (checked !== undefined && this.#items === entries) applyCheckedState(this.#panel, entries, index, checked);
401
422
  try {
402
423
  item.onselect?.(item.value, item, this);
403
424
  } finally {
@@ -423,9 +444,10 @@ export class MenuButton extends Component {
423
444
  }
424
445
 
425
446
  /**
426
- * Fired when an enabled item is activated.
447
+ * Fired when an enabled item is activated. Preventing it keeps the menu open and a checkbox or
448
+ * radio item's state unchanged.
427
449
  * @event MenuButton#select
428
- * @type {CustomEvent<{value: unknown, item: MenuItem}>}
450
+ * @type {CustomEvent<MenuButtonSelectDetail>}
429
451
  */
430
452
 
431
453
  /**