@zeyos/zx 5.3.0 → 5.5.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 (114) hide show
  1. package/CHANGELOG.md +125 -0
  2. package/README.md +49 -16
  3. package/dist/types/components/app-sidebar/app-sidebar.d.ts +33 -0
  4. package/dist/types/components/badge/badge.d.ts +5 -4
  5. package/dist/types/components/datebox/date-range-box.d.ts +15 -2
  6. package/dist/types/components/datebox/datebox.d.ts +37 -3
  7. package/dist/types/components/kbd/kbd.d.ts +41 -0
  8. package/dist/types/components/launcher/launcher.d.ts +4 -2
  9. package/dist/types/components/prose/prose.d.ts +69 -0
  10. package/dist/types/components/questionnaire/questionnaire.d.ts +0 -36
  11. package/dist/types/components/stat-tile/stat-tile.d.ts +20 -0
  12. package/dist/types/components/tag-picker/tag-picker.d.ts +11 -5
  13. package/dist/types/components/tree/tree.d.ts +44 -3
  14. package/dist/types/core/icons.d.ts +22 -1
  15. package/dist/types/index.d.ts +4 -2
  16. package/dist/types/internal/app-rail.d.ts +10 -3
  17. package/dist/types/internal/row-actions.d.ts +151 -0
  18. package/dist/zx-zeyos.esm.js +264 -82
  19. package/dist/zx-zeyos.esm.min.js +4 -4
  20. package/dist/zx.css +1288 -439
  21. package/dist/zx.esm.js +952 -392
  22. package/dist/zx.esm.min.js +6 -6
  23. package/dist/zx.global.js +952 -392
  24. package/dist/zx.global.min.js +6 -6
  25. package/dist/zx.min.css +1 -1
  26. package/docs/api.json +112 -4
  27. package/docs/llms.md +433 -38
  28. package/docs/llms.txt +21 -1
  29. package/package.json +1 -1
  30. package/src/components/account-menu/account-menu.js +2 -2
  31. package/src/components/app-rail/app-rail.css +11 -11
  32. package/src/components/app-sidebar/app-sidebar.css +90 -17
  33. package/src/components/app-sidebar/app-sidebar.js +120 -12
  34. package/src/components/badge/badge.css +33 -20
  35. package/src/components/badge/badge.js +5 -4
  36. package/src/components/breadcrumb/breadcrumb.css +28 -3
  37. package/src/components/breadcrumb/breadcrumb.js +2 -2
  38. package/src/components/button/button.css +24 -13
  39. package/src/components/button/button.js +20 -2
  40. package/src/components/calendar/calendar.css +14 -4
  41. package/src/components/card-view/card-view.js +2 -2
  42. package/src/components/chart/chart.js +20 -5
  43. package/src/components/check-button/check-button.css +11 -3
  44. package/src/components/check-button/check-button.js +3 -3
  45. package/src/components/context-menu/context-menu.css +7 -1
  46. package/src/components/date-picker/date-picker.css +6 -0
  47. package/src/components/date-picker/date-picker.js +5 -5
  48. package/src/components/date-picker/date-range-picker.css +6 -0
  49. package/src/components/date-picker/date-range-picker.js +3 -3
  50. package/src/components/date-picker/month-picker.js +3 -3
  51. package/src/components/date-picker/time-picker.css +6 -0
  52. package/src/components/datebox/date-range-box.js +30 -6
  53. package/src/components/datebox/datebox.js +44 -7
  54. package/src/components/dialog/dialog.css +0 -1
  55. package/src/components/dialog/dialog.js +2 -1
  56. package/src/components/dock/dock.js +2 -2
  57. package/src/components/dropdown/dropdown.css +2 -1
  58. package/src/components/entity-ref/entity-ref.css +8 -1
  59. package/src/components/file-item/file-item.css +1 -1
  60. package/src/components/finder/finder.js +2 -2
  61. package/src/components/groupbox/groupbox.js +2 -2
  62. package/src/components/kanban-view/kanban-view.css +8 -4
  63. package/src/components/kanban-view/kanban-view.js +3 -3
  64. package/src/components/kbd/kbd.css +64 -0
  65. package/src/components/kbd/kbd.js +121 -0
  66. package/src/components/launcher/launcher.css +30 -25
  67. package/src/components/launcher/launcher.js +15 -21
  68. package/src/components/list-toolbar/list-toolbar.css +7 -1
  69. package/src/components/menu-button/menu-button.css +9 -2
  70. package/src/components/message/message.css +6 -2
  71. package/src/components/message/message.js +2 -2
  72. package/src/components/module-bar/module-bar.css +11 -1
  73. package/src/components/multi-value-editor/multi-value-editor.js +4 -4
  74. package/src/components/navigation-bar/navigation-bar.css +3 -2
  75. package/src/components/pagination/pagination.js +2 -2
  76. package/src/components/panel/panel.js +2 -2
  77. package/src/components/prose/prose.css +53 -0
  78. package/src/components/prose/prose.js +152 -0
  79. package/src/components/questionnaire/questionnaire.css +7 -17
  80. package/src/components/questionnaire/questionnaire.js +16 -1
  81. package/src/components/rating/rating.css +3 -1
  82. package/src/components/search/search.js +2 -2
  83. package/src/components/select/glyphs.js +3 -3
  84. package/src/components/select/select.css +35 -7
  85. package/src/components/select/select.js +4 -4
  86. package/src/components/stat-tile/stat-tile.css +56 -2
  87. package/src/components/stat-tile/stat-tile.js +25 -2
  88. package/src/components/stepper/stepper.css +2 -1
  89. package/src/components/stepper/stepper.js +3 -3
  90. package/src/components/tabbox/tabbox.css +2 -2
  91. package/src/components/tabbox/tabbox.js +2 -2
  92. package/src/components/table/table.css +52 -16
  93. package/src/components/table/table.js +7 -5
  94. package/src/components/tag-picker/tag-picker.css +56 -43
  95. package/src/components/tag-picker/tag-picker.js +21 -16
  96. package/src/components/tree/tree.css +44 -0
  97. package/src/components/tree/tree.js +97 -9
  98. package/src/components/value-list/value-list.css +25 -4
  99. package/src/components/value-list/value-list.js +2 -1
  100. package/src/components/view/record-view.js +3 -3
  101. package/src/components/view-settings/view-settings.css +2 -1
  102. package/src/components/workspace-switcher/workspace-switcher.js +3 -3
  103. package/src/core/icons.js +34 -3
  104. package/src/elements/define.js +1 -0
  105. package/src/index.js +4 -2
  106. package/src/internal/app-rail.js +5 -1
  107. package/src/internal/row-actions.js +203 -0
  108. package/styles/base.css +26 -1
  109. package/styles/prose.css +306 -0
  110. package/styles/tokens/dark.css +108 -103
  111. package/styles/tokens/global.css +24 -9
  112. package/styles/tokens/semantic.css +520 -198
  113. package/styles/tokens/themes.css +9 -0
  114. package/styles/zx.css +3 -0
package/docs/llms.txt CHANGED
@@ -18,7 +18,27 @@ exports and as `window.zx.*`.
18
18
  - [API reference](llms.md): per-component constructor options, methods, and events for all public components plus the core helpers.
19
19
  - [Changelog](../CHANGELOG.md): what changed in each release, including behaviour changes an upgrade has to account for.
20
20
 
21
+ ## Start here: choosing
22
+ - Start every screen from the closest **layout**, never from a blank page. Gallery:
23
+ https://zx.zeyos.com/layouts (`layouts.html#<id>` opens one); source
24
+ `https://zx.zeyos.com/layouts/<id>.layout.js` + `<id>.layout.css`; the shell helpers
25
+ `layouts/kit.js` + `kit.css`, and `layouts/overview.js` + `overview.css` (`createOverview()`,
26
+ the toolbar-chips-drawers-pager composition every record screen uses). They are site modules,
27
+ not package exports: copy them beside the application.
28
+ - Templates (complete applications on one shell): `mail`, `issue-tracker`, `wiki`, `ai-chat`,
29
+ `agent-workspace`, `invoice-editor`, `item-inventory`, `workflows`, `infrastructure`, `crm`.
30
+ Patterns (single screens): `master-detail`, `record-collection` (any list of records),
31
+ `dashboard`, `inbox`, `record-page`, `agent-chat`, `record-wizard`, `checkout-wizard`,
32
+ `settings-workspace`, `system-states` (every empty, loading, error, and confirmation state),
33
+ `zeyos-invoices`.
34
+ - The agent reference's **"Choosing what to build with"** section maps each screen to its layout
35
+ and each job to its component, lists the theming decisions (theme, accent preset, geometry
36
+ tokens, material, motion, colour roles), and what never to build by hand. Read it before
37
+ building anything.
38
+
21
39
  ## Components
40
+ - Foundations: `.zx-prose` (the reading register for authored content) and `.zx-callout`;
41
+ `kbd()` (keycaps for every shortcut hint).
22
42
  - Inputs: `button()`, `buttonGroup()`, `badge()`/`badgeGroup()`, `CheckButton`,
23
43
  `Toggle`, `Search`,
24
44
  `Select` (APG combobox; `filter: false|'local'|async`; priority, status, permission, and
@@ -60,7 +80,7 @@ exports and as `window.zx.*`.
60
80
  - Helpers: `formatNumber`/`formatCurrency`/`formatPercent`/`formatFileSize`/`formatRelativeTime` (locale-aware, cached `Intl`), `debounce`/`throttle`, `groupBy`/`sortBy`/`uniqueBy`, `escapeRegExp`/`highlightMatch`, `storage()` (namespaced JSON, degrades to memory), `toCsv`/`downloadBlob`/`copyToClipboard`, `truncate()`/`isTruncated()` (line clamp with the full value on hover).
61
81
 
62
82
  ## Theming
63
- Load `zx.css` once; set `data-zx-theme` (`light`|`dark`|`auto`) on any ancestor. There is one geometry: spacing steps are multiples of `--zx-space-unit` (4px), radius steps are fractions of `--zx-radius` (4px: 2/3/4/6px), and controls are `--zx-control-height` (30px) tall — override those to tighten or loosen an application. Define a product theme by overriding semantic `--zx-color-*` / `--zx-control-*` tokens under `[data-zx-theme="name"]`. The theme studio controls accent, neutral tint, spacing, font, type size, radius, control height, and CSS-first glass material. Compact menus, pickers, tooltips, column menus, and toasts share responsive compact glass; Launcher, Modal, Dialog, and floating Sheets share a calmer reading panel. Both preserve scoped theme inheritance and refract Aurora/page content; docked Sheets and dense data surfaces remain opaque. Never use tier-1 palette tokens or raw color literals in application CSS.
83
+ Load `zx.css` once; set `data-zx-theme` (`light`|`dark`|`auto`) on any ancestor. There is one geometry: spacing steps are multiples of `--zx-space-unit` (4px), radius steps are fractions of `--zx-radius` (4px: 2/3/4/6px), and controls are `--zx-control-height` (30px) tall — override those to tighten or loosen an application. Define a product theme by overriding semantic `--zx-color-*` / `--zx-control-*` tokens under `[data-zx-theme="name"]`. The theme studio controls accent, neutral tint, spacing, font, type size, radius, control height, and the CSS-first material: Glass (the default, a thin lit pane), Deep glass, Frost (milk glass), Smoke (tinted), Paper, Satin and Enamel (opaque, no blur), or Flat — each a token-override recipe composed from the theme's glass ingredients (`--zx-color-glass-rim/-ring/-lift/-shade/-edge/-tint`). Compact menus, pickers, tooltips, column menus, and toasts share responsive compact glass; Launcher, Modal, Dialog, and floating Sheets share a calmer reading panel. Both preserve scoped theme inheritance and refract Aurora/page content; docked Sheets and dense data surfaces remain opaque. Never use tier-1 palette tokens or raw color literals in application CSS.
64
84
 
65
85
  ## Talking to ZeyOS
66
86
  Use the dedicated ZeyOS client library **`@zeyos/client`** (`npm install @zeyos/client`) for ZeyOS business data: `createZeyosClient({ platform, auth })`, typed `client.api.list/get/create/update<Resource>` over the full OpenAPI surface, and `normalizeListResult`. Zx accepts the client by injection and does not bundle it. See the `website/layouts/zeyos-invoices.layout.js` layout for a Zx-components-on-@zeyos/client reference. Zx also ships a minimal `Http`/`zeyosService` for ad-hoc in-app `remotecall`, but `@zeyos/client` is the recommended default.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeyos/zx",
3
- "version": "5.3.0",
3
+ "version": "5.5.0",
4
4
  "description": "Dependency-free JavaScript implementation of the Xenon Design System.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,6 +1,6 @@
1
1
  import { Component } from '../../core/component.js';
2
2
  import { h } from '../../core/dom.js';
3
- import { icon } from '../../core/icons.js';
3
+ import { ICON_SIZE, icon } from '../../core/icons.js';
4
4
  import { Avatar } from '../avatar/avatar.js';
5
5
  import { MenuButton } from '../menu-button/menu-button.js';
6
6
 
@@ -89,7 +89,7 @@ export class AccountMenu extends Component {
89
89
  h('span', { class: 'zx-account-menu__identity' },
90
90
  h('span', { ref: 'name', class: 'zx-account-menu__name' }),
91
91
  h('span', { ref: 'secondary', class: 'zx-account-menu__secondary' })),
92
- h('span', { class: 'zx-account-menu__chevron', ariaHidden: 'true' }, icon('chevron-down'))));
92
+ h('span', { class: 'zx-account-menu__chevron', ariaHidden: 'true' }, icon('chevron-down', { size: ICON_SIZE.chevron }))));
93
93
  return root;
94
94
  }
95
95
 
@@ -53,7 +53,8 @@
53
53
  border-color: transparent;
54
54
  border-radius: var(--zx-radius-md);
55
55
  background: transparent;
56
- color: inherit;
56
+ /* Navigation rests one ink step under the content and comes up to the full text colour below. */
57
+ color: var(--zx-color-text-chrome);
57
58
  padding: 0;
58
59
  text-decoration: none;
59
60
  }
@@ -91,6 +92,7 @@
91
92
  padding-inline: 3px;
92
93
  color: var(--zx-color-on-accent);
93
94
  font-size: 10px;
95
+ font-variant-numeric: tabular-nums;
94
96
  line-height: 15px;
95
97
  text-align: center;
96
98
  }
@@ -181,7 +183,8 @@
181
183
  label. Either way a single-line row is one control tall, and a wrapped one grows. */
182
184
  padding-block: min(var(--zx-space-1), (var(--zx-app-rail-item-height) - var(--zx-app-rail-icon)) / 2);
183
185
  padding-inline: var(--zx-app-rail-pad-x);
184
- color: var(--zx-color-text);
186
+ /* A slice of the navigation, so it rests in the navigation's ink as the tree does. */
187
+ color: var(--zx-color-text-chrome);
185
188
  font-size: var(--zx-text-md);
186
189
  font-weight: 500;
187
190
  line-height: 1.35;
@@ -193,13 +196,14 @@
193
196
  .zx-app-rail__flyout-item { min-block-size: 40px; }
194
197
  }
195
198
 
199
+ /* The icon follows the label's ink. */
196
200
  .zx-app-rail__flyout-item-icon {
197
201
  grid-column: 1;
198
202
  display: flex;
199
203
  align-items: center;
200
204
  justify-content: center;
201
205
  inline-size: var(--zx-app-rail-icon);
202
- color: var(--zx-color-text-muted);
206
+ color: inherit;
203
207
  }
204
208
 
205
209
  .zx-app-rail__flyout-item-label {
@@ -226,26 +230,23 @@
226
230
  }
227
231
 
228
232
  .zx-app-rail__flyout-item:hover { background: var(--zx-app-rail-hover); }
229
- .zx-app-rail__flyout-item:hover .zx-app-rail__flyout-item-icon,
230
- .zx-app-rail__flyout-item:hover .zx-app-rail__flyout-item-disclosure { color: var(--zx-color-text); }
233
+ .zx-app-rail__flyout-item:is(:hover, :focus-visible) { color: var(--zx-color-text); }
234
+ .zx-app-rail__flyout-item:is(:hover, :focus-visible) .zx-app-rail__flyout-item-disclosure { color: var(--zx-color-text); }
231
235
  .zx-app-rail__flyout-item:active { background: var(--zx-app-rail-press); }
232
236
 
233
237
  /* An open nested branch holds the hover fill: the chain that leads to the panel in front stays
234
238
  readable while the pointer is two panels away. The rail item does the same thing. */
235
239
  .zx-app-rail__flyout-item[aria-expanded="true"]:not([aria-current="page"]) {
236
240
  background: var(--zx-app-rail-hover);
241
+ color: var(--zx-color-text);
237
242
  }
238
- .zx-app-rail__flyout-item[aria-expanded="true"]:not([aria-current="page"]) .zx-app-rail__flyout-item-icon,
239
243
  .zx-app-rail__flyout-item[aria-expanded="true"]:not([aria-current="page"]) .zx-app-rail__flyout-item-disclosure {
240
244
  color: var(--zx-color-text);
241
245
  }
242
246
 
243
247
  .zx-app-rail__flyout-item[data-active-descendant="true"][aria-expanded="false"] {
244
- font-weight: var(--zx-weight-semibold);
245
- }
246
-
247
- .zx-app-rail__flyout-item[data-active-descendant="true"][aria-expanded="false"] .zx-app-rail__flyout-item-icon {
248
248
  color: var(--zx-color-text);
249
+ font-weight: var(--zx-weight-semibold);
249
250
  }
250
251
 
251
252
  /* The current page, as in the tree: the neutral current fill, the full text colour and a heavier
@@ -260,7 +261,6 @@
260
261
  background: var(--zx-app-rail-press);
261
262
  }
262
263
 
263
- .zx-app-rail__flyout-item[aria-current="page"] .zx-app-rail__flyout-item-icon,
264
264
  .zx-app-rail__flyout-item[aria-current="page"] .zx-app-rail__flyout-item-disclosure {
265
265
  color: var(--zx-color-text);
266
266
  }
@@ -113,10 +113,10 @@
113
113
  single icon keeps the column on every row so the labels stay in one line down the list. Each
114
114
  list answers for its own rows only — a branch of plain labels under iconned parents drops the
115
115
  column without taking it from the parents. */
116
- .zx-app-sidebar__list:not(:has(> .zx-app-sidebar__row > .zx-app-sidebar__item .zx-app-sidebar__item-icon,
117
- > .zx-app-sidebar__section > .zx-app-sidebar__section-list > .zx-app-sidebar__row > .zx-app-sidebar__item .zx-app-sidebar__item-icon)),
118
- .zx-app-sidebar__section-list:not(:has(> .zx-app-sidebar__row > .zx-app-sidebar__item .zx-app-sidebar__item-icon)),
119
- .zx-app-sidebar__sublist:not(:has(> .zx-app-sidebar__row > .zx-app-sidebar__item .zx-app-sidebar__item-icon)) {
116
+ .zx-app-sidebar__list:not(:has(> .zx-app-sidebar__row > :is(.zx-app-sidebar__item, .zx-app-sidebar__line) .zx-app-sidebar__item-icon,
117
+ > .zx-app-sidebar__section > .zx-app-sidebar__section-list > .zx-app-sidebar__row > :is(.zx-app-sidebar__item, .zx-app-sidebar__line) .zx-app-sidebar__item-icon)),
118
+ .zx-app-sidebar__section-list:not(:has(> .zx-app-sidebar__row > :is(.zx-app-sidebar__item, .zx-app-sidebar__line) .zx-app-sidebar__item-icon)),
119
+ .zx-app-sidebar__sublist:not(:has(> .zx-app-sidebar__row > :is(.zx-app-sidebar__item, .zx-app-sidebar__line) .zx-app-sidebar__item-icon)) {
120
120
  --zx-app-sidebar-icon: 0px;
121
121
  --zx-app-sidebar-item-gap: 0px;
122
122
  }
@@ -139,11 +139,11 @@
139
139
  /* Children with icons of their own step in by the shorter icon indent instead: their icons sit
140
140
  just past the guide rather than under the parent's label. Text-only children keep lining up
141
141
  with the words above them. */
142
- .zx-app-sidebar__row[data-level="1"]:has(> .zx-app-sidebar__sublist > .zx-app-sidebar__row > .zx-app-sidebar__item .zx-app-sidebar__item-icon) {
142
+ .zx-app-sidebar__row[data-level="1"]:has(> .zx-app-sidebar__sublist > .zx-app-sidebar__row > :is(.zx-app-sidebar__item, .zx-app-sidebar__line) .zx-app-sidebar__item-icon) {
143
143
  --zx-app-sidebar-step-1: max(var(--zx-app-sidebar-indent), var(--zx-app-sidebar-icon-indent));
144
144
  }
145
145
 
146
- .zx-app-sidebar__row[data-level="2"]:has(> .zx-app-sidebar__sublist > .zx-app-sidebar__row > .zx-app-sidebar__item .zx-app-sidebar__item-icon) {
146
+ .zx-app-sidebar__row[data-level="2"]:has(> .zx-app-sidebar__sublist > .zx-app-sidebar__row > :is(.zx-app-sidebar__item, .zx-app-sidebar__line) .zx-app-sidebar__item-icon) {
147
147
  --zx-app-sidebar-step-2: calc(var(--zx-app-sidebar-step-1) + max(var(--zx-app-sidebar-indent), var(--zx-app-sidebar-icon-indent)));
148
148
  }
149
149
 
@@ -226,7 +226,9 @@
226
226
  label. Either way a single-line row is one control tall, and a wrapped one grows. */
227
227
  padding-block: min(var(--zx-space-1), (var(--zx-app-sidebar-item-height) - var(--zx-app-sidebar-icon)) / 2);
228
228
  padding-inline: var(--zx-app-sidebar-pad-x);
229
- color: var(--zx-color-text);
229
+ /* Navigation rests one ink step under the content, so the eye lands on the page beside it; the
230
+ row comes up to the full text colour when pointed at, focused, or current. */
231
+ color: var(--zx-color-text-chrome);
230
232
  font-size: var(--zx-text-md);
231
233
  font-weight: 500;
232
234
  line-height: 1.35;
@@ -240,16 +242,19 @@
240
242
  .zx-app-sidebar__item { min-block-size: 40px; }
241
243
  }
242
244
 
245
+ .zx-app-sidebar__row[data-level="2"] > .zx-app-sidebar__line > .zx-app-sidebar__item,
243
246
  .zx-app-sidebar__row[data-level="2"] > .zx-app-sidebar__item { padding-inline-start: calc(var(--zx-app-sidebar-pad-x) + var(--zx-app-sidebar-step-1)); }
247
+ .zx-app-sidebar__row[data-level="3"] > .zx-app-sidebar__line > .zx-app-sidebar__item,
244
248
  .zx-app-sidebar__row[data-level="3"] > .zx-app-sidebar__item { padding-inline-start: calc(var(--zx-app-sidebar-pad-x) + var(--zx-app-sidebar-step-2)); }
245
249
 
250
+ /* The icon is drawn in the label's ink, so the row reads as one thing at rest and comes up as one. */
246
251
  .zx-app-sidebar__item-icon {
247
252
  grid-column: 1;
248
253
  display: flex;
249
254
  align-items: center;
250
255
  justify-content: center;
251
256
  inline-size: var(--zx-app-sidebar-icon);
252
- color: var(--zx-color-text-muted);
257
+ color: inherit;
253
258
  }
254
259
 
255
260
  /* No nowrap and no ellipsis: the row grows instead. `hyphens` is what makes that bearable for a
@@ -280,19 +285,16 @@
280
285
  }
281
286
 
282
287
  .zx-app-sidebar__item:hover { background: var(--zx-app-sidebar-hover); }
283
- .zx-app-sidebar__item:hover .zx-app-sidebar__item-icon,
284
- .zx-app-sidebar__item:hover .zx-app-sidebar__item-disclosure { color: var(--zx-color-text); }
288
+ .zx-app-sidebar__item:is(:hover, :focus-visible) { color: var(--zx-color-text); }
289
+ .zx-app-sidebar__item:is(:hover, :focus-visible) .zx-app-sidebar__item-disclosure { color: var(--zx-color-text); }
285
290
  .zx-app-sidebar__item:active { background: var(--zx-app-sidebar-press); }
286
291
 
287
292
  /* A branch that is closed over the active route carries the heavier label, so the way back to
288
293
  the current page is visible without opening it; a branch that is open says so with its chevron
289
294
  and shows the active row itself. */
290
295
  .zx-app-sidebar__item[data-active-descendant="true"][aria-expanded="false"] {
291
- font-weight: var(--zx-weight-semibold);
292
- }
293
-
294
- .zx-app-sidebar__item[data-active-descendant="true"][aria-expanded="false"] .zx-app-sidebar__item-icon {
295
296
  color: var(--zx-color-text);
297
+ font-weight: var(--zx-weight-semibold);
296
298
  }
297
299
 
298
300
  /* The current page: a neutral fill, the full text colour, a heavier label. Focus is a ring on top
@@ -309,7 +311,6 @@
309
311
  background: var(--zx-app-sidebar-press);
310
312
  }
311
313
 
312
- .zx-app-sidebar__item[aria-current="page"] .zx-app-sidebar__item-icon,
313
314
  .zx-app-sidebar__item[aria-current="page"] .zx-app-sidebar__item-disclosure {
314
315
  color: var(--zx-color-text);
315
316
  }
@@ -327,6 +328,73 @@
327
328
  .zx-app-sidebar__item[aria-disabled="true"]:hover,
328
329
  .zx-app-sidebar__item[aria-disabled="true"]:active { background: transparent; }
329
330
 
331
+ /*
332
+ * Row actions. A destination with actions puts its control and the action strip on one line, the
333
+ * reveal host (`data-zx-reveal-host` in base.css): the strip rests out of sight over the end of the
334
+ * control and shows while the line is pointed at, holds focus or has its menu open. The control
335
+ * keeps room for the strip, so the label, the count and the chevron never run underneath it.
336
+ */
337
+ .zx-app-sidebar__line {
338
+ --zx-app-sidebar-action-size: calc(var(--zx-control-height) - var(--zx-space-1) - 2px);
339
+ display: grid;
340
+ grid-template-columns: minmax(0, 1fr);
341
+ }
342
+
343
+ .zx-app-sidebar__line > .zx-app-sidebar__item {
344
+ grid-area: 1 / 1;
345
+ padding-inline-end: calc(var(--zx-app-sidebar-pad-x) + var(--zx-space-1)
346
+ + var(--zx-app-sidebar-actions, 1) * (var(--zx-app-sidebar-action-size) + 2px));
347
+ }
348
+
349
+ .zx-app-sidebar__actions {
350
+ position: relative;
351
+ grid-area: 1 / 1;
352
+ display: inline-flex;
353
+ align-items: center;
354
+ align-self: center;
355
+ justify-self: end;
356
+ gap: 2px;
357
+ margin-inline-end: var(--zx-space-1);
358
+ }
359
+
360
+ /* The current page is where the reader is: its actions stay in view, as a selected tree row's do. */
361
+ .zx-app-sidebar__line:has(> [aria-current="page"]) > .zx-app-sidebar__actions {
362
+ opacity: 1;
363
+ }
364
+
365
+ /* Pointing at the strip is still pointing at the row. */
366
+ .zx-app-sidebar__line:has(> .zx-app-sidebar__actions:hover) > .zx-app-sidebar__item:not([aria-current="page"], [aria-disabled="true"]) {
367
+ background: var(--zx-app-sidebar-hover);
368
+ color: var(--zx-color-text);
369
+ }
370
+
371
+ .zx-app-sidebar .zx-app-sidebar__action {
372
+ display: inline-grid;
373
+ place-items: center;
374
+ inline-size: var(--zx-app-sidebar-action-size);
375
+ block-size: var(--zx-app-sidebar-action-size);
376
+ min-block-size: 0;
377
+ padding: 0;
378
+ border: 0;
379
+ border-radius: var(--zx-radius-sm);
380
+ background: none;
381
+ color: var(--zx-color-text-muted);
382
+ }
383
+
384
+ .zx-app-sidebar .zx-app-sidebar__action:is(:hover, [aria-expanded="true"]):not(:disabled) {
385
+ background: var(--zx-app-sidebar-hover);
386
+ color: var(--zx-color-text);
387
+ }
388
+
389
+ .zx-app-sidebar .zx-app-sidebar__action:focus-visible {
390
+ outline-color: transparent;
391
+ box-shadow: inset var(--zx-focus-ring);
392
+ }
393
+
394
+ .zx-app-sidebar .zx-app-sidebar__action .zx-btn__label:empty {
395
+ display: none;
396
+ }
397
+
330
398
  .zx-app-sidebar__footer {
331
399
  border-block-start: 1px solid var(--zx-color-border);
332
400
  padding: var(--zx-space-2) var(--zx-space-3);
@@ -379,7 +447,8 @@
379
447
  display: inline-grid;
380
448
  justify-self: center;
381
449
  gap: 2px;
382
- border-radius: var(--zx-radius-md);
450
+ /* Concentric with the options inside it: their corner plus the 2px between them. */
451
+ border-radius: calc(var(--zx-radius-sm) + 2px);
383
452
  background: var(--zx-color-bg-hover);
384
453
  padding: 2px;
385
454
  }
@@ -499,7 +568,11 @@
499
568
  * the loss of the label.
500
569
  */
501
570
  .zx-app-sidebar__rail .zx-app-rail__item {
502
- color: var(--zx-color-text-muted);
571
+ color: var(--zx-color-text-chrome);
572
+ }
573
+
574
+ .zx-app-sidebar__rail .zx-app-rail__item:focus-visible {
575
+ color: var(--zx-color-text);
503
576
  }
504
577
 
505
578
  .zx-app-sidebar__rail .zx-app-rail__item:not([aria-current="page"]):hover,
@@ -1,8 +1,9 @@
1
1
  import { Component } from '../../core/component.js';
2
2
  import { h } from '../../core/dom.js';
3
3
  import { printf } from '../../core/i18n.js';
4
- import { icon } from '../../core/icons.js';
4
+ import { ICON_SIZE, icon } from '../../core/icons.js';
5
5
  import { uid } from '../../core/util.js';
6
+ import { renderRowActions, rowActionMenu, setRowActionsTabbable } from '../../internal/row-actions.js';
6
7
  import {
7
8
  AppRailPresenter as MinimizedPresenter, appNavIcon, normalizeAppItems
8
9
  } from '../../internal/app-rail.js';
@@ -54,6 +55,8 @@ const PRESENTATIONS = Object.freeze(['expanded', 'compact', 'collapsed']);
54
55
  * switch between presentations. Turn it off when the choice lives elsewhere — an account menu,
55
56
  * through `presentationChoice()`.
56
57
  * @property {string} [label='Applications'] Navigation accessible label.
58
+ * @property {string} [moreLabel='More actions'] Name of a destination's overflow menu when its
59
+ * `actions` fold; every action name is followed by the destination's label.
57
60
  * @property {Node|string|number|{toElement: () => Node|null}|null} [header=null] Expanded header content;
58
61
  * in the modules layout, content above every module's menu.
59
62
  * @property {Node|string|number|{toElement: () => Node|null}|null} [footer=null] Expanded sticky footer content.
@@ -103,6 +106,7 @@ export class AppSidebar extends Component {
103
106
  presentations: ['expanded', 'compact', 'collapsed'],
104
107
  presentationSwitch: true,
105
108
  label: 'Applications',
109
+ moreLabel: 'More actions',
106
110
  header: null,
107
111
  footer: null,
108
112
  railHeader: null,
@@ -153,6 +157,12 @@ export class AppSidebar extends Component {
153
157
  }
154
158
  this._shownId = this._modules ? this._resolveShown(this.options.module) : null;
155
159
  this._modeAbort = null;
160
+ /** @type {Map<string, import('../../internal/row-actions.js').RowActionStrip>} Destinations' actions, by id. */
161
+ this._strips = new Map();
162
+ /** @type {import('../context-menu/context-menu.js').ContextMenu|null} */
163
+ this._rowMenu = null;
164
+ /** @type {HTMLElement|null} The list the row menu is attached to. */
165
+ this._rowMenuList = null;
156
166
  root.replaceChildren();
157
167
  return root;
158
168
  }
@@ -456,6 +466,7 @@ export class AppSidebar extends Component {
456
466
  this._modeAbort?.abort();
457
467
  this._modeAbort = null;
458
468
  for (const tooltip of this._stripTooltips.splice(0)) tooltip.destroy();
469
+ this._dropRowActions({ menu: true });
459
470
  this._rail?.destroy();
460
471
  this._rail = null;
461
472
  super.destroy();
@@ -470,6 +481,7 @@ export class AppSidebar extends Component {
470
481
  _renderMode() {
471
482
  this._modeAbort?.abort();
472
483
  this._modeAbort = new AbortController();
484
+ this._dropRowActions({ menu: true });
473
485
  for (const tooltip of this._stripTooltips.splice(0)) tooltip.destroy();
474
486
  this._presentationGroup = null;
475
487
  this._rail?.destroy();
@@ -515,7 +527,7 @@ export class AppSidebar extends Component {
515
527
  class: 'zx-app-sidebar__collapse zx-icon-btn',
516
528
  type: 'button',
517
529
  ariaLabel: this._message('appSidebar.minimize', 'Minimize application sidebar')
518
- }, icon(this._side === 'right' ? 'chevron-right' : 'chevron-left')));
530
+ }, icon(this._side === 'right' ? 'chevron-right' : 'chevron-left', { size: ICON_SIZE.chevron })));
519
531
  button.hidden = !this.options.collapsible;
520
532
  this._listenMode(button, 'click', () => this.collapse());
521
533
  return button;
@@ -527,7 +539,7 @@ export class AppSidebar extends Component {
527
539
  class: 'zx-app-sidebar__rail-toggle zx-icon-btn',
528
540
  type: 'button',
529
541
  ariaLabel: this._message('appSidebar.expand', 'Expand application sidebar')
530
- }, icon(this._side === 'right' ? 'chevron-left' : 'chevron-right')));
542
+ }, icon(this._side === 'right' ? 'chevron-left' : 'chevron-right', { size: ICON_SIZE.chevron })));
531
543
  this._railExpandButton = button;
532
544
  this._listenMode(button, 'click', () => this.expand());
533
545
  return button;
@@ -537,6 +549,8 @@ export class AppSidebar extends Component {
537
549
  _listenTree(list) {
538
550
  this._listenMode(list, 'click', (event) => this._onTreeClick(event));
539
551
  this._listenMode(list, 'keydown', (event) => this._onTreeKeydown(/** @type {KeyboardEvent} */ (event)));
552
+ // The actions of the row holding focus are Tab stops; every other row's wait for the pointer.
553
+ this._listenMode(list, 'focusin', (event) => this._syncActionStops(event.target));
540
554
  }
541
555
 
542
556
  /** @returns {void} */
@@ -920,11 +934,23 @@ export class AppSidebar extends Component {
920
934
  /** @returns {void} */
921
935
  _renderTree() {
922
936
  if (!this.refs.list) return;
923
- const focused = this.refs.list.contains(document.activeElement)
924
- ? /** @type {Element} */ (document.activeElement).closest('[data-app-nav-id]')
925
- ?.getAttribute('data-app-nav-id')
937
+ const active = /** @type {Element|null} */ (document.activeElement);
938
+ // Focus on a row's action comes back to the row's own control.
939
+ const focused = active && this.refs.list.contains(active)
940
+ ? (active.closest('[data-app-nav-id]') ?? rowControl(active.closest('.zx-app-sidebar__row')))
941
+ ?.getAttribute('data-app-nav-id') ?? null
926
942
  : null;
943
+ this._dropRowActions({ menu: this._rowMenuList !== this.refs.list });
927
944
  this.refs.list.replaceChildren(...this._treeItems().map((item) => this._treeRow(item, 1)));
945
+ if (this._strips.size > 0 && !this._rowMenu) {
946
+ this._rowMenuList = this.refs.list;
947
+ this._rowMenu = rowActionMenu(this.refs.list, '.zx-app-sidebar__line', (line) => {
948
+ const id = rowControl(line.parentElement)?.getAttribute('data-app-nav-id') ?? null;
949
+ const strip = id === null ? null : this._strips.get(id);
950
+ const item = strip ? findItem(this._items, id) : null;
951
+ return strip && item ? { actions: strip.actions, subject: item } : null;
952
+ });
953
+ }
928
954
  this._syncActive();
929
955
  if (focused !== null) {
930
956
  const replacement = [...this.refs.list.querySelectorAll('[data-app-nav-id]')]
@@ -949,10 +975,11 @@ export class AppSidebar extends Component {
949
975
  location: level === 1 ? 'root' : 'inline'
950
976
  });
951
977
  const control = navControl(item, hasChildren, expanded, childId, visual);
978
+ const strip = this._renderRowActions(item);
952
979
  const row = h('li', {
953
980
  class: 'zx-app-sidebar__row',
954
981
  dataset: { level }
955
- }, control);
982
+ }, strip ? actionLine(control, strip.element) : control);
956
983
  if (hasChildren) {
957
984
  row.append(h('ul', {
958
985
  class: 'zx-app-sidebar__sublist',
@@ -984,8 +1011,63 @@ export class AppSidebar extends Component {
984
1011
  (item.children ?? []).map((child) => this._treeRow(child, level))));
985
1012
  }
986
1013
 
1014
+ /**
1015
+ * Builds a destination's action strip, when it lists actions.
1016
+ * @param {AppNavItem} item Destination.
1017
+ * @returns {import('../../internal/row-actions.js').RowActionStrip|null}
1018
+ */
1019
+ _renderRowActions(item) {
1020
+ const entries = Array.isArray(item.actions) ? item.actions
1021
+ : item.actions && typeof item.actions === 'object' && 'nodeType' in item.actions ? [item.actions] : [];
1022
+ if (entries.length === 0) return null;
1023
+ const strip = renderRowActions(entries, {
1024
+ block: 'app-sidebar',
1025
+ name: item.label,
1026
+ moreLabel: String(this.options.moreLabel ?? 'More actions'),
1027
+ run: (action) => action.onSelect(item)
1028
+ });
1029
+ if (strip) this._strips.set(String(item.id), strip);
1030
+ return strip;
1031
+ }
1032
+
1033
+ /**
1034
+ * Makes the actions of the row holding focus Tab stops, and every other row's not.
1035
+ * @param {EventTarget|null} target What took focus.
1036
+ * @returns {void}
1037
+ */
1038
+ _syncActionStops(target) {
1039
+ const line = /** @type {Element|null} */ (target)?.closest?.('.zx-app-sidebar__line') ?? null;
1040
+ for (const strip of this._strips.values()) {
1041
+ setRowActionsTabbable(strip.element, Boolean(line?.contains(strip.element)));
1042
+ }
1043
+ }
1044
+
1045
+ /**
1046
+ * Destroys the destinations' action strips, and with `menu` the row menu bound to the list.
1047
+ * @param {{menu?: boolean}} [options={}]
1048
+ * @returns {void}
1049
+ */
1050
+ _dropRowActions({ menu = false } = {}) {
1051
+ for (const strip of this._strips?.values() ?? []) strip.destroy();
1052
+ this._strips?.clear();
1053
+ if (menu) {
1054
+ this._rowMenu?.destroy();
1055
+ this._rowMenu = null;
1056
+ this._rowMenuList = null;
1057
+ }
1058
+ }
1059
+
987
1060
  /** @param {Event} event @returns {void} */
988
1061
  _onTreeClick(event) {
1062
+ const actionControl = /** @type {HTMLElement|null} */ (/** @type {Element|null} */ (event.target)
1063
+ ?.closest?.('.zx-app-sidebar__actions [data-row-action]') ?? null);
1064
+ if (actionControl && this.refs.list.contains(actionControl)) {
1065
+ const id = rowControl(actionControl.closest('.zx-app-sidebar__row'))?.getAttribute('data-app-nav-id') ?? null;
1066
+ const action = id === null ? null : this._strips.get(id)?.actions[Number(actionControl.dataset.rowAction)];
1067
+ const item = action ? findItem(this._items, id) : null;
1068
+ if (action && item && !action.disabled) action.onSelect(item);
1069
+ return;
1070
+ }
989
1071
  const control = /** @type {Element|null} */ (event.target)?.closest?.('[data-app-nav-id]');
990
1072
  if (!control || !this.refs.list.contains(control)) return;
991
1073
  const item = findItem(this._items, control.getAttribute('data-app-nav-id'));
@@ -1007,7 +1089,7 @@ export class AppSidebar extends Component {
1007
1089
  if (event.key === 'ArrowRight' && item?.children?.length) {
1008
1090
  event.preventDefault();
1009
1091
  if (!this._expanded.has(String(item.id))) this.toggleBranch(item.id);
1010
- else visibleTreeControls(current.parentElement?.querySelector('.zx-app-sidebar__sublist'))[0]?.focus();
1092
+ else visibleTreeControls(current.closest('.zx-app-sidebar__row')?.querySelector(':scope > .zx-app-sidebar__sublist'))[0]?.focus();
1011
1093
  return;
1012
1094
  }
1013
1095
  if (event.key === 'ArrowLeft') {
@@ -1017,7 +1099,7 @@ export class AppSidebar extends Component {
1017
1099
  return;
1018
1100
  }
1019
1101
  const parentList = current.closest('.zx-app-sidebar__sublist');
1020
- const parentControl = parentList?.parentElement?.querySelector(':scope > [data-app-nav-id]');
1102
+ const parentControl = rowControl(parentList?.parentElement ?? null);
1021
1103
  if (parentControl instanceof HTMLElement) {
1022
1104
  event.preventDefault();
1023
1105
  parentControl.focus();
@@ -1093,7 +1175,7 @@ export class AppSidebar extends Component {
1093
1175
  if (!this.refs.list) return;
1094
1176
  const control = [...this.refs.list.querySelectorAll('[data-app-nav-id]')]
1095
1177
  .find((candidate) => candidate.getAttribute('data-app-nav-id') === key) ?? null;
1096
- const sublist = control?.parentElement?.querySelector(':scope > .zx-app-sidebar__sublist');
1178
+ const sublist = control?.closest('.zx-app-sidebar__row')?.querySelector(':scope > .zx-app-sidebar__sublist');
1097
1179
  if (sublist instanceof HTMLElement) sublist.dataset.branchMotion = 'expand';
1098
1180
  }
1099
1181
 
@@ -1162,7 +1244,33 @@ function navControl(item, disclosure, expanded, controls, visual) {
1162
1244
  h('span', { class: 'zx-app-sidebar__item-label' }, item.label),
1163
1245
  item.badge != null ? h('span', { class: 'zx-app-sidebar__item-badge' }, String(item.badge)) : null,
1164
1246
  disclosure ? h('span', { class: 'zx-app-sidebar__item-disclosure', ariaHidden: 'true' },
1165
- icon(expanded ? 'chevron-down' : 'chevron-right')) : null));
1247
+ icon(expanded ? 'chevron-down' : 'chevron-right', { size: ICON_SIZE.chevron })) : null));
1248
+ }
1249
+
1250
+ /**
1251
+ * A row's own control: the row's first child, or the first child of its action line.
1252
+ * @param {Element|null|undefined} row `li.zx-app-sidebar__row`.
1253
+ * @returns {HTMLElement|null}
1254
+ */
1255
+ function rowControl(row) {
1256
+ return /** @type {HTMLElement|null} */ (row?.querySelector(
1257
+ ':scope > [data-app-nav-id], :scope > .zx-app-sidebar__line > [data-app-nav-id]') ?? null);
1258
+ }
1259
+
1260
+ /**
1261
+ * A destination with actions: its control and the action strip on one line, which is the reveal
1262
+ * host — the row's sub-list sits outside it, so pointing at a child never shows the parent's
1263
+ * actions. The line tells the stylesheet how many controls to keep room for.
1264
+ * @param {HTMLElement} control Destination control.
1265
+ * @param {HTMLElement} strip Action strip.
1266
+ * @returns {HTMLElement}
1267
+ */
1268
+ function actionLine(control, strip) {
1269
+ return /** @type {HTMLElement} */ (h('div', {
1270
+ class: 'zx-app-sidebar__line',
1271
+ 'data-zx-reveal-host': '',
1272
+ style: { '--zx-app-sidebar-actions': String(strip.childElementCount) }
1273
+ }, control, strip));
1166
1274
  }
1167
1275
 
1168
1276
  /** @param {Element|null|undefined} root @returns {HTMLElement[]} */
@@ -1178,7 +1286,7 @@ function visibleTreeControl(control) {
1178
1286
  while (candidate) {
1179
1287
  const hiddenList = candidate.closest('.zx-app-sidebar__sublist[hidden]');
1180
1288
  if (!hiddenList) return candidate;
1181
- candidate = /** @type {HTMLElement|null} */ (hiddenList.parentElement?.firstElementChild ?? null);
1289
+ candidate = rowControl(hiddenList.parentElement);
1182
1290
  }
1183
1291
  return null;
1184
1292
  }