@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
@@ -42,24 +42,29 @@
42
42
  display: contents;
43
43
  }
44
44
 
45
- .zx-tag-picker__tag {
46
- display: inline-flex;
47
- align-items: center;
48
- gap: var(--zx-space-1);
49
- max-inline-size: 100%;
50
- padding-inline-start: var(--zx-space-2);
51
- border: 1px solid var(--zx-color-border);
45
+ /*
46
+ * A tag is a Badge — `badge()` with the item's tone, and this class added — so its height (from
47
+ * the row), its 12px medium type, its padding, its one fill and its tone pairs are the Badge's, and
48
+ * a label reads the same in the field as in a list row or a record header. What follows is the
49
+ * picker's own.
50
+ *
51
+ * An untoned tag is still a tag, so it keeps the tag's small corners rather than the status pill's;
52
+ * and it is the field's value, so it keeps the text ink rather than a status's muted one.
53
+ */
54
+ .zx-tag-picker .zx-tag-picker__tag {
52
55
  border-radius: var(--zx-radius-md);
53
- background: var(--zx-color-bg-muted);
54
- font-size: var(--zx-text-sm);
55
- line-height: 1.5;
56
56
  }
57
57
 
58
+ .zx-tag-picker .zx-tag-picker__tag:not([data-tone]) {
59
+ color: var(--zx-color-text);
60
+ }
61
+
62
+ /* A host colour (`colorKey`) tints the tag's one fill. */
58
63
  .zx-tag-picker__tag[data-colored="true"] {
59
- border-color: color-mix(in srgb, var(--zx-tag-color) 48%, var(--zx-color-border));
60
64
  background: color-mix(in srgb, var(--zx-tag-color) 14%, var(--zx-color-bg-muted));
61
65
  }
62
66
 
67
+ /* An option's icon sits on a tile of its colour, beside a label that has no fill of its own. */
63
68
  .zx-tag-picker__visual {
64
69
  display: inline-grid;
65
70
  place-items: center;
@@ -71,52 +76,59 @@
71
76
  color: var(--zx-tag-color, var(--zx-color-accent));
72
77
  }
73
78
 
74
- /* A categorical tone: the tag takes the Badge tone palette — the tone's tint as fill, its ink as
75
- text, no border — and an icon tile the same pair, so a label keeps one colour everywhere. */
76
- .zx-tag-picker__tag[data-tone] {
77
- border-color: transparent;
78
- background: var(--zx-tag-tone-bg);
79
- color: var(--zx-tag-tone-fg);
80
- }
81
-
79
+ /* A categorical tone gives an option's tile the Badge tone pair, so it matches the tag it becomes. */
82
80
  .zx-tag-picker__visual[data-tone] {
83
81
  background: var(--zx-tag-tone-bg);
84
82
  color: var(--zx-tag-tone-fg);
85
83
  }
86
84
 
87
- .zx-tag-picker .zx-tag-picker__tag[data-tone] .zx-tag-picker__remove {
85
+ .zx-tag-picker__visual[data-tone="blue"] { --zx-tag-tone-bg: var(--zx-color-tone-blue-bg); --zx-tag-tone-fg: var(--zx-color-tone-blue-fg); }
86
+ .zx-tag-picker__visual[data-tone="teal"] { --zx-tag-tone-bg: var(--zx-color-tone-teal-bg); --zx-tag-tone-fg: var(--zx-color-tone-teal-fg); }
87
+ .zx-tag-picker__visual[data-tone="green"] { --zx-tag-tone-bg: var(--zx-color-tone-green-bg); --zx-tag-tone-fg: var(--zx-color-tone-green-fg); }
88
+ .zx-tag-picker__visual[data-tone="amber"] { --zx-tag-tone-bg: var(--zx-color-tone-amber-bg); --zx-tag-tone-fg: var(--zx-color-tone-amber-fg); }
89
+ .zx-tag-picker__visual[data-tone="orange"] { --zx-tag-tone-bg: var(--zx-color-tone-orange-bg); --zx-tag-tone-fg: var(--zx-color-tone-orange-fg); }
90
+ .zx-tag-picker__visual[data-tone="red"] { --zx-tag-tone-bg: var(--zx-color-tone-red-bg); --zx-tag-tone-fg: var(--zx-color-tone-red-fg); }
91
+ .zx-tag-picker__visual[data-tone="pink"] { --zx-tag-tone-bg: var(--zx-color-tone-pink-bg); --zx-tag-tone-fg: var(--zx-color-tone-pink-fg); }
92
+ .zx-tag-picker__visual[data-tone="violet"] { --zx-tag-tone-bg: var(--zx-color-tone-violet-bg); --zx-tag-tone-fg: var(--zx-color-tone-violet-fg); }
93
+ .zx-tag-picker__visual[data-tone="slate"] { --zx-tag-tone-bg: var(--zx-color-tone-slate-bg); --zx-tag-tone-fg: var(--zx-color-tone-slate-fg); }
94
+
95
+ /* Inside a tag the icon is a bare glyph in the tag's ink: the tag is already the fill, and a tile
96
+ on top of it would be a second one. A host colour still marks the glyph. */
97
+ .zx-tag-picker .zx-tag-picker__tag .zx-tag-picker__visual {
98
+ inline-size: auto;
99
+ block-size: auto;
100
+ background: none;
88
101
  color: inherit;
89
102
  }
90
103
 
91
- .zx-tag-picker .zx-tag-picker__tag[data-tone] .zx-tag-picker__remove:hover {
92
- background: color-mix(in srgb, currentColor 14%, transparent);
93
- color: inherit;
104
+ .zx-tag-picker .zx-tag-picker__tag[data-colored="true"] .zx-tag-picker__visual {
105
+ color: var(--zx-tag-color);
94
106
  }
95
107
 
96
- :is(.zx-tag-picker__tag, .zx-tag-picker__visual)[data-tone="blue"] { --zx-tag-tone-bg: var(--zx-color-tone-blue-bg); --zx-tag-tone-fg: var(--zx-color-tone-blue-fg); }
97
- :is(.zx-tag-picker__tag, .zx-tag-picker__visual)[data-tone="teal"] { --zx-tag-tone-bg: var(--zx-color-tone-teal-bg); --zx-tag-tone-fg: var(--zx-color-tone-teal-fg); }
98
- :is(.zx-tag-picker__tag, .zx-tag-picker__visual)[data-tone="green"] { --zx-tag-tone-bg: var(--zx-color-tone-green-bg); --zx-tag-tone-fg: var(--zx-color-tone-green-fg); }
99
- :is(.zx-tag-picker__tag, .zx-tag-picker__visual)[data-tone="amber"] { --zx-tag-tone-bg: var(--zx-color-tone-amber-bg); --zx-tag-tone-fg: var(--zx-color-tone-amber-fg); }
100
- :is(.zx-tag-picker__tag, .zx-tag-picker__visual)[data-tone="orange"] { --zx-tag-tone-bg: var(--zx-color-tone-orange-bg); --zx-tag-tone-fg: var(--zx-color-tone-orange-fg); }
101
- :is(.zx-tag-picker__tag, .zx-tag-picker__visual)[data-tone="red"] { --zx-tag-tone-bg: var(--zx-color-tone-red-bg); --zx-tag-tone-fg: var(--zx-color-tone-red-fg); }
102
- :is(.zx-tag-picker__tag, .zx-tag-picker__visual)[data-tone="pink"] { --zx-tag-tone-bg: var(--zx-color-tone-pink-bg); --zx-tag-tone-fg: var(--zx-color-tone-pink-fg); }
103
- :is(.zx-tag-picker__tag, .zx-tag-picker__visual)[data-tone="violet"] { --zx-tag-tone-bg: var(--zx-color-tone-violet-bg); --zx-tag-tone-fg: var(--zx-color-tone-violet-fg); }
104
- :is(.zx-tag-picker__tag, .zx-tag-picker__visual)[data-tone="slate"] { --zx-tag-tone-bg: var(--zx-color-tone-slate-bg); --zx-tag-tone-fg: var(--zx-color-tone-slate-fg); }
108
+ /* The remove button replaces the tag's end padding. */
109
+ .zx-tag-picker .zx-tag-picker__tag:has(> .zx-tag-picker__remove) {
110
+ padding-inline-end: 0;
111
+ }
105
112
 
106
- .zx-tag-picker__tag:not(:has(.zx-tag-picker__remove)) {
107
- padding-inline-end: var(--zx-space-2);
113
+ /* The × is stretched to the tag's height and held 1px in from it, so with the tag's own 1px edge
114
+ its hover fill sits 2px inside the tag on every side and never touches the tag's edge. */
115
+ .zx-tag-picker .zx-tag-picker__remove {
116
+ inline-size: 18px;
117
+ block-size: auto;
118
+ min-block-size: 0;
119
+ align-self: stretch;
120
+ margin-block: 1px;
121
+ margin-inline-end: 1px;
122
+ border-radius: var(--zx-radius-sm);
108
123
  }
109
124
 
110
- .zx-tag-picker__tag-label {
111
- overflow: hidden;
112
- text-overflow: ellipsis;
113
- white-space: nowrap;
125
+ .zx-tag-picker .zx-tag-picker__tag[data-tone] .zx-tag-picker__remove {
126
+ color: inherit;
114
127
  }
115
128
 
116
- .zx-tag-picker .zx-tag-picker__remove {
117
- inline-size: 20px;
118
- block-size: 20px;
119
- border-radius: var(--zx-radius-sm);
129
+ .zx-tag-picker .zx-tag-picker__tag[data-tone] .zx-tag-picker__remove:hover {
130
+ background: color-mix(in srgb, currentColor 14%, transparent);
131
+ color: inherit;
120
132
  }
121
133
 
122
134
  .zx-tag-picker__input {
@@ -163,7 +175,8 @@
163
175
  max-inline-size: calc(100vw - var(--zx-space-4));
164
176
  overflow: hidden;
165
177
  border: 1px solid var(--zx-color-overlay-border);
166
- border-radius: var(--zx-radius-lg);
178
+ /* Concentric with the options inside it: their corner plus the inset around them. */
179
+ border-radius: var(--zx-radius-panel);
167
180
  background-color: var(--zx-color-overlay-surface);
168
181
  background-image: var(--zx-overlay-surface-image);
169
182
  background-clip: padding-box;
@@ -1,9 +1,9 @@
1
1
  import { Component } from '../../core/component.js';
2
2
  import { h, restoreTarget, snapshotTarget } from '../../core/dom.js';
3
- import { icon } from '../../core/icons.js';
3
+ import { ICON_SIZE, icon } from '../../core/icons.js';
4
4
  import { position } from '../../core/position.js';
5
5
  import { uid } from '../../core/util.js';
6
- import { normalizeBadgeTone } from '../badge/badge.js';
6
+ import { badge, normalizeBadgeTone } from '../badge/badge.js';
7
7
  import { itemColor } from '../select/color.js';
8
8
  import { matchItems } from '../select/filter.js';
9
9
 
@@ -21,8 +21,9 @@ import { matchItems } from '../select/filter.js';
21
21
  * or a token reference such as `var(--zx-color-tone-blue-fg)`.
22
22
  * @property {TagValueReader} [toneKey='tone'] Optional item tone property or reader: a categorical
23
23
  * tone name from the Badge palette (`blue`, `teal`, `green`, `amber`, `orange`, `red`, `pink`,
24
- * `violet`, `slate`). A toned tag takes the palette's fill and ink, as a Badge with that `tone`
25
- * does; a tone wins over a colour, and unknown names are ignored.
24
+ * `violet`, `slate`). Every tag is built by `badge()`, so a toned tag is the Badge with that `tone`
25
+ * — the same shape, size, fill and ink it has in a list row or a record header; a tone wins over a
26
+ * colour, and unknown names are ignored.
26
27
  * @property {Array<TagValueReader>|null} [searchKeys=null] Fields searched by local filtering.
27
28
  * @property {'local'|((query: string) => Promise<TagItem[]>|TagItem[])} [filter='local'] Filtering mode.
28
29
  * @property {number} [minQuery=0] Minimum async query length.
@@ -136,7 +137,7 @@ export class TagPicker extends Component {
136
137
  type: 'button',
137
138
  tabIndex: -1,
138
139
  ariaLabel: this._message('tagPicker.toggle', 'Toggle options')
139
- }, icon('chevron-down', { size: 15 }));
140
+ }, icon('chevron-down', { size: ICON_SIZE.chevron }));
140
141
  const control = h('div', { ref: 'control', class: 'zx-tag-picker__control' },
141
142
  tags, input, toggle);
142
143
 
@@ -420,25 +421,29 @@ export class TagPicker extends Component {
420
421
 
421
422
  /* ------------------------------------------------------------------ rendering -- */
422
423
 
423
- /** @returns {void} */
424
+ /**
425
+ * Draws the selection. A tag is a Badge — `badge({ tone })` with the picker's own class — so it
426
+ * has one construction wherever a label appears, and only the remove button is the picker's.
427
+ * @returns {void}
428
+ */
424
429
  _renderTags() {
425
430
  const tags = this._selected.map((item) => {
426
431
  const label = this._labelOf(item);
427
432
  const tone = this._toneOf(item);
428
433
  const color = tone ? null : this._colorOf(item);
429
- const content = this.options.renderTag ? this.options.renderTag(item)
430
- : [this._iconOf(item), h('span', { class: 'zx-tag-picker__tag-label' }, label)];
431
- const tag = h('span', {
432
- class: 'zx-tag-picker__tag',
433
- dataset: { colored: String(Boolean(color)), tone: tone ?? undefined },
434
- style: color ? { '--zx-tag-color': color } : null
435
- }, content);
434
+ const content = this.options.renderTag ? [this.options.renderTag(item)]
435
+ : [this._iconOf(item), h('span', { class: 'zx-badge__label zx-tag-picker__tag-label' }, label)];
436
+ const tag = badge({ tone });
437
+ tag.classList.add('zx-tag-picker__tag');
438
+ tag.dataset.colored = String(Boolean(color));
439
+ if (color) tag.style.setProperty('--zx-tag-color', color);
440
+ tag.append(...content.filter((node) => node !== null && node !== undefined));
436
441
  if (!this._readonly && !this._disabled) {
437
442
  tag.append(h('button', {
438
443
  class: 'zx-icon-btn zx-tag-picker__remove',
439
444
  type: 'button',
440
445
  ariaLabel: this._message('tagPicker.remove', 'Remove %1', [label])
441
- }, icon('x', { size: 11 })));
446
+ }, icon('x', { size: ICON_SIZE.chip })));
442
447
  }
443
448
  return tag;
444
449
  });
@@ -463,7 +468,7 @@ export class TagPicker extends Component {
463
468
  ariaSelected: String(selected)
464
469
  },
465
470
  h('span', { class: 'zx-tag-picker__check', ariaHidden: 'true' },
466
- selected ? icon('check', { size: 13 }) : null),
471
+ selected ? icon('check', { size: ICON_SIZE.check }) : null),
467
472
  h('span', { class: 'zx-tag-picker__option-label' },
468
473
  this.options.renderItem ? this.options.renderItem(item)
469
474
  : [this._iconOf(item), h('span', {}, this._labelOf(item))]));
@@ -481,7 +486,7 @@ export class TagPicker extends Component {
481
486
  ariaSelected: 'false',
482
487
  dataset: { create: 'true' }
483
488
  },
484
- h('span', { class: 'zx-tag-picker__check', ariaHidden: 'true' }, icon('plus', { size: 13 })),
489
+ h('span', { class: 'zx-tag-picker__check', ariaHidden: 'true' }, icon('plus', { size: ICON_SIZE.check })),
485
490
  h('span', { class: 'zx-tag-picker__option-label' },
486
491
  this._message('tagPicker.create', 'Create “%1”', [query])));
487
492
  this._entries.push({ item: null, element: option, create: true });
@@ -100,6 +100,50 @@
100
100
  font-variant-numeric: tabular-nums;
101
101
  }
102
102
 
103
+ /* Row actions. The row is the reveal host (`data-zx-reveal-host` in base.css): the strip keeps its
104
+ room at the row's end and shows while the row is pointed at, focused or selected. Each control
105
+ is a square a little smaller than a control, pulled into the row's padding so the row keeps its
106
+ height. */
107
+ .zx-tree__actions {
108
+ display: inline-flex;
109
+ flex: none;
110
+ align-items: center;
111
+ gap: 2px;
112
+ margin-inline: auto calc(var(--zx-space-1) - var(--zx-space-2));
113
+ }
114
+
115
+ .zx-tree__badge + .zx-tree__actions {
116
+ margin-inline-start: 0;
117
+ }
118
+
119
+ .zx-tree .zx-tree__action {
120
+ display: inline-grid;
121
+ place-items: center;
122
+ inline-size: calc(var(--zx-control-height) - var(--zx-space-1) - 2px);
123
+ block-size: calc(var(--zx-control-height) - var(--zx-space-1) - 2px);
124
+ min-block-size: 0;
125
+ margin-block: calc(1px - var(--zx-space-1));
126
+ padding: 0;
127
+ border: 0;
128
+ border-radius: var(--zx-radius-sm);
129
+ background: none;
130
+ color: var(--zx-color-text-muted);
131
+ }
132
+
133
+ .zx-tree .zx-tree__action:is(:hover, [aria-expanded="true"]):not(:disabled) {
134
+ background: var(--zx-color-bg-hover);
135
+ color: var(--zx-color-text);
136
+ }
137
+
138
+ .zx-tree .zx-tree__action:focus-visible {
139
+ outline-color: transparent;
140
+ box-shadow: inset var(--zx-focus-ring);
141
+ }
142
+
143
+ .zx-tree .zx-tree__action .zx-btn__label:empty {
144
+ display: none;
145
+ }
146
+
103
147
  .zx-tree__empty {
104
148
  padding: var(--zx-space-5);
105
149
  color: var(--zx-color-text-muted);
@@ -1,13 +1,15 @@
1
1
  import { Component } from '../../core/component.js';
2
2
  import { h, restoreTarget, snapshotTarget } from '../../core/dom.js';
3
- import { icon } from '../../core/icons.js';
3
+ import { ICON_SIZE, icon } from '../../core/icons.js';
4
4
  import { typeahead } from '../../core/keyboard.js';
5
5
  import { uid } from '../../core/util.js';
6
+ import { renderRowActions, rowActionMenu, setRowActionsTabbable } from '../../internal/row-actions.js';
6
7
  import {
7
8
  createReaders, descendants, filterTree, findNode, flattenVisible, isBranch, pathTo, walk
8
9
  } from './hierarchy.js';
9
10
 
10
11
  /** @typedef {import('./hierarchy.js').TreeNode} TreeNode */
12
+ /** @typedef {import('../../internal/row-actions.js').RowAction} RowAction */
11
13
  /**
12
14
  * @typedef {Object} TreeOptions
13
15
  * @property {TreeNode[]} [items=[]] Nested nodes.
@@ -21,6 +23,13 @@ import {
21
23
  * @property {unknown[]} [checked=[]] Initially checked node IDs.
22
24
  * @property {boolean} [icons=true] Whether to render folder and file icons.
23
25
  * @property {((node: TreeNode) => Node|string)|null} [renderLabel=null] Label renderer.
26
+ * @property {((node: TreeNode) => Array<RowAction|Node>)|null} [rowActions=null] A row's actions:
27
+ * `{icon, label, onSelect(node), disabled?, danger?}` descriptors, or nodes placed as given. They
28
+ * rest out of sight and show while the row is pointed at, focused or selected; one or two show
29
+ * as icon buttons, more fold after the first into a "More actions" menu. Every descriptor is also
30
+ * in the row's context menu, and the focused row's actions follow it in the Tab order.
31
+ * @property {string} [moreLabel='More actions'] Name of a row's overflow menu; every action name
32
+ * is followed by the row's name ("More actions: Q3 plan").
24
33
  * @property {((node: TreeNode) => Promise<TreeNode[]>|TreeNode[])|null} [load=null] Lazy child loader.
25
34
  * @property {string} [filter=''] Label substring the tree is filtered by.
26
35
  * @property {string} [label='Tree'] Accessible name of the tree.
@@ -66,6 +75,8 @@ export class TreeView extends Component {
66
75
  checked: [],
67
76
  icons: true,
68
77
  renderLabel: null,
78
+ rowActions: null,
79
+ moreLabel: 'More actions',
69
80
  load: null,
70
81
  filter: '',
71
82
  label: 'Tree',
@@ -85,6 +96,9 @@ export class TreeView extends Component {
85
96
  this._loading = new Map();
86
97
  this._focusId = null;
87
98
  this._filter = '';
99
+ /** @type {Array<import('../../internal/row-actions.js').RowActionStrip|undefined>} Per visible row. */
100
+ this._strips = [];
101
+ this._rowMenu = null;
88
102
  this._createdRoot = this.el === null;
89
103
  this._snapshot = this._createdRoot ? null : snapshotTarget(this.el);
90
104
 
@@ -131,6 +145,22 @@ export class TreeView extends Component {
131
145
  // Focusing the container hands focus straight to the active row.
132
146
  if (this._rows.length > 0 && !this._rowElement(this._focusId)) this._focusRow(0);
133
147
  });
148
+ // Focus arriving on a row's action makes that row the tree's tab stop, without moving focus.
149
+ this.listen(root, 'focusin', (event) => {
150
+ const strip = this._stripOf(event.target);
151
+ const row = strip ? this._rows[this._rowIndex(strip.closest('.zx-tree__row'))] : null;
152
+ if (row && !Object.is(row.id, this._focusId)) {
153
+ this._focusId = row.id;
154
+ this._syncRows();
155
+ }
156
+ });
157
+ if (typeof this.options.rowActions === 'function') {
158
+ this._rowMenu = rowActionMenu(root, '.zx-tree__row', (element) => {
159
+ const index = this._rowIndex(element);
160
+ const strip = this._strips[index];
161
+ return strip ? { actions: strip.actions, subject: this._subject(this._rows[index]) } : null;
162
+ });
163
+ }
134
164
 
135
165
  // Runs the same expansion logic as setFilter() so an initial filter behaves identically.
136
166
  if (String(this.options.filter ?? '') !== '') this.setFilter(this.options.filter);
@@ -409,21 +439,23 @@ export class TreeView extends Component {
409
439
  _renderRows() {
410
440
  const items = this._visibleItems();
411
441
  this._rows = flattenVisible(items, this._readers, this._expanded);
442
+ for (const strip of this._strips.splice(0)) strip?.destroy();
412
443
 
413
444
  if (this._rows.length === 0) {
414
445
  this.el.replaceChildren(h('div', { class: 'zx-tree__empty' },
415
446
  this._message('tree.empty', this.options.emptyText)));
416
447
  return;
417
448
  }
418
- this.el.replaceChildren(...this._rows.map((row) => this._renderRow(row)));
449
+ this.el.replaceChildren(...this._rows.map((row, index) => this._renderRow(row, index)));
419
450
  this._syncRows();
420
451
  }
421
452
 
422
453
  /**
423
454
  * @param {{node: TreeNode, id: unknown, level: number, posinset: number, setsize: number}} row Row spec.
455
+ * @param {number} index Visible position.
424
456
  * @returns {HTMLElement}
425
457
  */
426
- _renderRow(row) {
458
+ _renderRow(row, index) {
427
459
  const branch = isBranch(row.node, this._readers);
428
460
  const expanded = branch && this._expanded.has(row.id);
429
461
  const element = h('div', {
@@ -439,7 +471,7 @@ export class TreeView extends Component {
439
471
  element.style.setProperty('--zx-tree-level', String(row.level - 1));
440
472
 
441
473
  const twisty = h('span', { class: 'zx-tree__twisty', ariaHidden: 'true' },
442
- branch ? icon('chevron-right', { size: 12 }) : null);
474
+ branch ? icon('chevron-right', { size: ICON_SIZE.chevron }) : null);
443
475
  twisty.dataset.action = 'twisty';
444
476
  element.append(twisty);
445
477
 
@@ -462,10 +494,28 @@ export class TreeView extends Component {
462
494
  const content = this.options.renderLabel
463
495
  ? this.options.renderLabel(row.node)
464
496
  : this._readers.label(row.node);
465
- element.append(h('span', { class: 'zx-tree__label' }, content));
466
-
467
- if (row.node.badge != null) {
468
- element.append(h('span', { class: 'zx-tree__badge' }, String(row.node.badge)));
497
+ const label = h('span', { class: 'zx-tree__label' }, content);
498
+ element.append(label);
499
+
500
+ const badge = row.node.badge != null ? h('span', { class: 'zx-tree__badge' }, String(row.node.badge)) : null;
501
+ if (badge) element.append(badge);
502
+
503
+ const strip = typeof this.options.rowActions === 'function'
504
+ ? renderRowActions(this.options.rowActions(this._subject(row)), {
505
+ block: 'tree',
506
+ name: this._readers.label(row.node),
507
+ moreLabel: String(this.options.moreLabel ?? 'More actions'),
508
+ run: (action) => action.onSelect(this._subject(row))
509
+ })
510
+ : null;
511
+ if (strip) {
512
+ this._strips[index] = strip;
513
+ // The row keeps the name its label (and count) gives it; the action names stay out of it.
514
+ label.id = uid('zx-tree-label');
515
+ if (badge) badge.id = uid('zx-tree-badge');
516
+ element.setAttribute('aria-labelledby', badge ? `${label.id} ${badge.id}` : label.id);
517
+ element.setAttribute('data-zx-reveal-host', '');
518
+ element.append(strip.element);
469
519
  }
470
520
  return element;
471
521
  }
@@ -489,6 +539,8 @@ export class TreeView extends Component {
489
539
  element.toggleAttribute('data-branch', branch);
490
540
  element.toggleAttribute('data-loading', this._loading.has(row.id));
491
541
  element.tabIndex = index === focusIndex ? 0 : -1;
542
+ // The row holding the tab stop lends it to its actions: Tab walks them, then leaves the tree.
543
+ setRowActionsTabbable(this._strips[index]?.element, index === focusIndex);
492
544
 
493
545
  const box = /** @type {HTMLInputElement|null} */ (element.querySelector('.zx-tree__checkbox'));
494
546
  if (box) {
@@ -513,6 +565,15 @@ export class TreeView extends Component {
513
565
 
514
566
  /** @param {MouseEvent} event @returns {void} */
515
567
  _onClick(event) {
568
+ const strip = this._stripOf(event.target);
569
+ if (strip) {
570
+ // An action acts on its row; it neither selects nor focuses it.
571
+ const control = /** @type {HTMLElement|null} */ (/** @type {Element} */ (event.target).closest('[data-row-action]'));
572
+ const index = this._rowIndex(strip.closest('.zx-tree__row'));
573
+ const action = control ? this._strips[index]?.actions[Number(control.dataset.rowAction)] : null;
574
+ if (action && !action.disabled) action.onSelect(this._subject(this._rows[index]));
575
+ return;
576
+ }
516
577
  const element = /** @type {Element} */ (event.target).closest('.zx-tree__row');
517
578
  if (!element) return;
518
579
  const index = this._rowIndex(element);
@@ -540,6 +601,7 @@ export class TreeView extends Component {
540
601
 
541
602
  /** @param {MouseEvent} event @returns {void} */
542
603
  _onDoubleClick(event) {
604
+ if (this._stripOf(event.target)) return;
543
605
  const element = /** @type {Element} */ (event.target).closest('.zx-tree__row');
544
606
  if (!element) return;
545
607
  const row = this._rows[this._rowIndex(element)];
@@ -553,6 +615,9 @@ export class TreeView extends Component {
553
615
 
554
616
  /** @param {KeyboardEvent} event @returns {void} */
555
617
  _onKeydown(event) {
618
+ // Keys pressed on a row's action belong to that control: Enter runs it, the menu's arrows move
619
+ // through the menu, and nothing walks the tree.
620
+ if (this._stripOf(event.target)) return;
556
621
  const index = this._rows.findIndex((row) => Object.is(row.id, this._focusId));
557
622
  if (index < 0 || this._rows.length === 0) return;
558
623
  const row = this._rows[index];
@@ -716,7 +781,27 @@ export class TreeView extends Component {
716
781
  return [...this._rows.slice(from + 1), ...this._rows.slice(0, from + 1)];
717
782
  }
718
783
 
719
- /** @param {Element} element @returns {number} */
784
+ /**
785
+ * The action strip an event target sits in, if any.
786
+ * @param {EventTarget|null} target Event target.
787
+ * @returns {HTMLElement|null}
788
+ */
789
+ _stripOf(target) {
790
+ const element = target && /** @type {Node} */ (target).nodeType === 1 ? /** @type {Element} */ (target) : null;
791
+ const strip = /** @type {HTMLElement|null} */ (element?.closest('.zx-tree__actions') ?? null);
792
+ return strip && this.el.contains(strip) ? strip : null;
793
+ }
794
+
795
+ /**
796
+ * What a row's actions receive: the node in the working tree, not a filtered copy.
797
+ * @param {{node: TreeNode, id: unknown}|undefined} row Visible row.
798
+ * @returns {TreeNode|null}
799
+ */
800
+ _subject(row) {
801
+ return row ? this.getNode(row.id) ?? row.node : null;
802
+ }
803
+
804
+ /** @param {Element|null} element @returns {number} */
720
805
  _rowIndex(element) {
721
806
  return [...this.el.querySelectorAll('.zx-tree__row')].indexOf(element);
722
807
  }
@@ -754,6 +839,9 @@ export class TreeView extends Component {
754
839
  /** Restores an enhanced target to the markup it had before the takeover. @returns {void} */
755
840
  destroy() {
756
841
  const root = this.el;
842
+ for (const strip of this._strips?.splice(0) ?? []) strip?.destroy();
843
+ this._rowMenu?.destroy();
844
+ this._rowMenu = null;
757
845
  super.destroy();
758
846
  if (!this._createdRoot && root) restoreTarget(root, this._snapshot);
759
847
  }
@@ -28,9 +28,12 @@
28
28
  min-block-size: calc(var(--zx-control-height) - var(--zx-space-2));
29
29
  max-inline-size: 100%;
30
30
  padding-inline: var(--zx-space-2);
31
- border: 1px solid var(--zx-color-border);
31
+ /* One fill, not a fill and a line: the edge stays, transparent, to keep the chip's size. */
32
+ border: 1px solid transparent;
32
33
  border-radius: var(--zx-radius-md);
33
- background: var(--zx-color-bg-muted);
34
+ /* A text-colour step, not the muted surface: it reads on the control's own fill in both themes,
35
+ where the hairline used to do the separating. */
36
+ background: color-mix(in srgb, var(--zx-color-text) 8%, transparent);
34
37
  color: var(--zx-color-text);
35
38
  cursor: grab;
36
39
  }
@@ -45,11 +48,14 @@
45
48
  text-wrap: nowrap;
46
49
  }
47
50
 
51
+ /* Stretched to the chip's line and held 1px in from it, so the hover fill sits 2px inside the chip
52
+ at top and bottom, however tall the control makes the chip. */
48
53
  .zx-value-list__remove {
49
54
  display: inline-grid;
55
+ align-self: stretch;
50
56
  place-items: center;
51
57
  min-inline-size: 1.25rem;
52
- min-block-size: 1.25rem;
58
+ margin-block: 1px;
53
59
  border-radius: var(--zx-radius-sm);
54
60
  color: var(--zx-color-text-muted);
55
61
  cursor: pointer;
@@ -64,7 +70,9 @@
64
70
  flex: 1 1 8rem;
65
71
  min-inline-size: 6rem;
66
72
  border: 0;
67
- background: inherit;
73
+ /* Nothing of its own: the control's fill is translucent in dark, and an inherited copy of it
74
+ would be painted over the original as a second, lighter box. */
75
+ background: none;
68
76
  box-shadow: none;
69
77
  }
70
78
 
@@ -106,3 +114,16 @@
106
114
  .zx-value-list[data-disabled="true"] .zx-value-list__remove {
107
115
  display: none;
108
116
  }
117
+
118
+ /* Someone who asked for more contrast, or whose colours are forced, gets the chip's edge back. */
119
+ @media (prefers-contrast: more) {
120
+ .zx-value-list__chip {
121
+ border-color: var(--zx-color-border-strong);
122
+ }
123
+ }
124
+
125
+ @media (forced-colors: active) {
126
+ .zx-value-list__chip {
127
+ border-color: CanvasText;
128
+ }
129
+ }
@@ -1,5 +1,6 @@
1
1
  import { Component } from '../../core/component.js';
2
2
  import { h } from '../../core/dom.js';
3
+ import { ICON_SIZE, icon } from '../../core/icons.js';
3
4
  import { printf } from '../../core/i18n.js';
4
5
  import { uid } from '../../core/util.js';
5
6
 
@@ -206,7 +207,7 @@ export class ValueList extends Component {
206
207
  class: 'zx-value-list__remove',
207
208
  dataset: { remove: '' },
208
209
  ariaHidden: 'true'
209
- }, '×') : null));
210
+ }, icon('x', { size: ICON_SIZE.chip })) : null));
210
211
  this._list.replaceChildren(...chips);
211
212
  if (focusIndex >= 0) chips[Math.min(focusIndex, chips.length - 1)]?.focus();
212
213
  }
@@ -1,7 +1,7 @@
1
1
  // @ts-check
2
2
  import { Component } from '../../core/component.js';
3
3
  import { h, resolveElement, restoreTarget, snapshotTarget } from '../../core/dom.js';
4
- import { icon } from '../../core/icons.js';
4
+ import { ICON_SIZE, icon } from '../../core/icons.js';
5
5
  import { printf } from '../../core/i18n.js';
6
6
  import { sortRows } from '../table/sort.js';
7
7
 
@@ -784,14 +784,14 @@ export class RecordView extends Component {
784
784
  ariaLabel: this._message('recordView.moveFieldUp', 'Move %1 up', field.label),
785
785
  disabled: index === 0,
786
786
  dataset: { viewFieldAction: 'up', fieldId: field.id }
787
- }, icon('chevron-up', { size: 11 }));
787
+ }, icon('chevron-up', { size: ICON_SIZE.chevron }));
788
788
  const down = h('button', {
789
789
  class: 'zx-record-view__field-move',
790
790
  type: 'button',
791
791
  ariaLabel: this._message('recordView.moveFieldDown', 'Move %1 down', field.label),
792
792
  disabled: index === fields.length - 1,
793
793
  dataset: { viewFieldAction: 'down', fieldId: field.id }
794
- }, icon('chevron-down', { size: 11 }));
794
+ }, icon('chevron-down', { size: ICON_SIZE.chevron }));
795
795
  return h('div', { class: 'zx-record-view__field-option' },
796
796
  h('label', {}, toggle, h('span', {}, field.label)),
797
797
  h('span', { class: 'zx-record-view__field-order' }, up, down));
@@ -160,7 +160,8 @@ button.zx-view-settings__handle {
160
160
  flex: none;
161
161
  place-items: center;
162
162
  inline-size: var(--zx-control-height);
163
- color: var(--zx-color-text-placeholder);
163
+ /* An icon that says something (the field cannot be hidden): the subtle icon role, at 3:1. */
164
+ color: var(--zx-color-text-subtle);
164
165
  }
165
166
 
166
167
  .zx-view-settings__add {
@@ -1,7 +1,7 @@
1
1
  import { Component } from '../../core/component.js';
2
2
  import { h, restoreTarget, snapshotTarget } 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 { APP_ICON_TONES, appIcon } from '../app-icon/app-icon.js';
6
6
  import { avatarInitials, avatarTone } from '../avatar/avatar.js';
7
7
  import { MenuButton } from '../menu-button/menu-button.js';
@@ -124,7 +124,7 @@ export class WorkspaceSwitcher extends Component {
124
124
  h('span', { class: 'zx-workspace-switcher__text' },
125
125
  h('span', { ref: 'name', class: 'zx-workspace-switcher__name' }),
126
126
  h('span', { ref: 'secondary', class: 'zx-workspace-switcher__secondary' })),
127
- h('span', { class: 'zx-workspace-switcher__chevron', ariaHidden: 'true' }, icon('chevron-down'))));
127
+ h('span', { class: 'zx-workspace-switcher__chevron', ariaHidden: 'true' }, icon('chevron-down', { size: ICON_SIZE.chevron }))));
128
128
  return root;
129
129
  }
130
130
 
@@ -269,7 +269,7 @@ export class WorkspaceSwitcher extends Component {
269
269
  description: workspace.secondary || undefined,
270
270
  badge: workspace.badge ?? undefined,
271
271
  disabled: workspace.disabled,
272
- adornment: h('span', { class: 'zx-workspace-switcher__check', ariaHidden: 'true' }, icon('check'))
272
+ adornment: h('span', { class: 'zx-workspace-switcher__check', ariaHidden: 'true' }, icon('check', { size: ICON_SIZE.check }))
273
273
  };
274
274
  this._entries.set(entry, workspace);
275
275
  rows.push([entries.length, workspace]);