@zeyos/zx 5.6.0 → 5.7.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 (215) hide show
  1. package/CHANGELOG.md +154 -0
  2. package/README.md +73 -7
  3. package/bin/zx-css.js +328 -0
  4. package/dist/types/components/account-menu/account-menu.d.ts +4 -2
  5. package/dist/types/components/activity-list/activity-list.d.ts +14 -8
  6. package/dist/types/components/agent-thread/ag-ui.d.ts +340 -0
  7. package/dist/types/components/agent-thread/agent-thread.d.ts +142 -14
  8. package/dist/types/components/agent-thread/ui-message-stream.d.ts +401 -0
  9. package/dist/types/components/app-sidebar/app-sidebar.d.ts +14 -8
  10. package/dist/types/components/breadcrumb/breadcrumb.d.ts +3 -3
  11. package/dist/types/components/calendar/calendar-model.d.ts +9 -2
  12. package/dist/types/components/calendar/calendar.d.ts +12 -4
  13. package/dist/types/components/chart/chart.d.ts +25 -13
  14. package/dist/types/components/code-editor/code-editor.d.ts +7 -2
  15. package/dist/types/components/composer/composer.d.ts +206 -4
  16. package/dist/types/components/composer/queue.d.ts +76 -0
  17. package/dist/types/components/copy/copy-button.d.ts +6 -4
  18. package/dist/types/components/copy/copy-input.d.ts +10 -6
  19. package/dist/types/components/datebox/date-range-box.d.ts +33 -0
  20. package/dist/types/components/datebox/placeholder.d.ts +7 -0
  21. package/dist/types/components/dock/dock.d.ts +12 -3
  22. package/dist/types/components/entity-ref/entity-ref.d.ts +5 -3
  23. package/dist/types/components/field-upload/field-upload.d.ts +3 -2
  24. package/dist/types/components/file-item/file-item.d.ts +3 -2
  25. package/dist/types/components/file-list/file-list.d.ts +14 -8
  26. package/dist/types/components/filter/filter-model.d.ts +31 -1
  27. package/dist/types/components/filter/filter.d.ts +20 -2
  28. package/dist/types/components/finder/finder.d.ts +14 -6
  29. package/dist/types/components/flag/flag.d.ts +99 -0
  30. package/dist/types/components/grid/grid.d.ts +1 -1
  31. package/dist/types/components/kanban-view/kanban-view.d.ts +8 -66
  32. package/dist/types/components/launcher/launcher.d.ts +2 -0
  33. package/dist/types/components/multi-value-editor/multi-value-editor.d.ts +3 -2
  34. package/dist/types/components/number-field/number-field.d.ts +17 -6
  35. package/dist/types/components/prompt-starters/prompt-starters.d.ts +107 -0
  36. package/dist/types/components/prose/prose.d.ts +9 -6
  37. package/dist/types/components/questionnaire/conditions.d.ts +270 -0
  38. package/dist/types/components/questionnaire/items.d.ts +52 -30
  39. package/dist/types/components/questionnaire/questionnaire.d.ts +44 -4
  40. package/dist/types/components/rating/rating.d.ts +5 -3
  41. package/dist/types/components/select/country.d.ts +106 -0
  42. package/dist/types/components/select/field-adapter.d.ts +2 -1
  43. package/dist/types/components/select/locale.d.ts +102 -0
  44. package/dist/types/components/select/select.d.ts +41 -2
  45. package/dist/types/components/slider/slider.d.ts +1 -0
  46. package/dist/types/components/sort-control/sort-control.d.ts +7 -3
  47. package/dist/types/components/source-list/source-list.d.ts +7 -5
  48. package/dist/types/components/split-view/split-view.d.ts +5 -3
  49. package/dist/types/components/surface/catalog.d.ts +260 -0
  50. package/dist/types/components/surface/elicit.d.ts +81 -0
  51. package/dist/types/components/surface/mcp.d.ts +165 -0
  52. package/dist/types/components/surface/schema.d.ts +314 -0
  53. package/dist/types/components/surface/stream.d.ts +118 -0
  54. package/dist/types/components/surface/surface.d.ts +718 -0
  55. package/dist/types/components/surface/text.d.ts +277 -0
  56. package/dist/types/components/surface/validate.d.ts +339 -0
  57. package/dist/types/components/table/table.d.ts +55 -3
  58. package/dist/types/components/table/window.d.ts +203 -0
  59. package/dist/types/components/toolbar/toolbar.d.ts +10 -6
  60. package/dist/types/components/tooltip/tooltip.d.ts +2 -2
  61. package/dist/types/components/tree/tree.d.ts +20 -13
  62. package/dist/types/core/component.d.ts +10 -0
  63. package/dist/types/core/date.d.ts +8 -1
  64. package/dist/types/core/dom.d.ts +1 -0
  65. package/dist/types/core/http.d.ts +10 -0
  66. package/dist/types/core/i18n.d.ts +38 -0
  67. package/dist/types/core/messages.d.ts +344 -1
  68. package/dist/types/core/storage.d.ts +7 -2
  69. package/dist/types/elements/define.d.ts +21 -46
  70. package/dist/types/elements/definitions.d.ts +147 -0
  71. package/dist/types/elements/kit.d.ts +7 -0
  72. package/dist/types/elements/reflect.d.ts +6 -3
  73. package/dist/types/index.d.ts +10 -1
  74. package/dist/types/internal/date-locale.d.ts +7 -0
  75. package/dist/types/internal/json-patch.d.ts +146 -0
  76. package/dist/types/locales/de.d.ts +13 -0
  77. package/dist/types/locales/en.d.ts +2 -0
  78. package/dist/types/locales/index.d.ts +823 -0
  79. package/dist/types/zeyos/view.d.ts +8 -1
  80. package/dist/zx-zeyos.esm.js +16802 -15180
  81. package/dist/zx-zeyos.esm.min.js +5 -5
  82. package/dist/zx.core.css +1276 -0
  83. package/dist/zx.core.min.css +1 -0
  84. package/dist/zx.css +498 -134
  85. package/dist/zx.esm.js +40778 -29654
  86. package/dist/zx.esm.min.js +36 -23
  87. package/dist/zx.global.js +40778 -29654
  88. package/dist/zx.global.min.js +36 -23
  89. package/dist/zx.layered.css +17302 -0
  90. package/dist/zx.layered.min.css +1 -0
  91. package/dist/zx.min.css +1 -1
  92. package/docs/agent-catalog.json +12501 -0
  93. package/docs/agent-surfaces.md +340 -0
  94. package/docs/api.json +851 -121
  95. package/docs/llms.md +1018 -71
  96. package/docs/llms.txt +30 -9
  97. package/package.json +29 -6
  98. package/src/components/account-menu/account-menu.js +6 -3
  99. package/src/components/activity-item/activity-item.js +2 -1
  100. package/src/components/activity-list/activity-list.js +16 -10
  101. package/src/components/agent-thread/ag-ui.js +1439 -0
  102. package/src/components/agent-thread/agent-thread.js +359 -54
  103. package/src/components/agent-thread/ui-message-stream.js +1281 -0
  104. package/src/components/app-sidebar/app-sidebar.js +18 -8
  105. package/src/components/approval-card/approval-card.js +3 -2
  106. package/src/components/block-view/block-view.js +7 -6
  107. package/src/components/breadcrumb/breadcrumb.js +8 -5
  108. package/src/components/calendar/calendar-model.js +8 -2
  109. package/src/components/calendar/calendar.js +53 -18
  110. package/src/components/chart/chart.js +54 -23
  111. package/src/components/code-editor/code-editor.js +45 -8
  112. package/src/components/code-editor/field-adapter.js +1 -1
  113. package/src/components/composer/composer.css +80 -1
  114. package/src/components/composer/composer.js +390 -16
  115. package/src/components/composer/queue.js +78 -0
  116. package/src/components/context-menu/context-menu.js +12 -1
  117. package/src/components/copy/copy-button.js +9 -7
  118. package/src/components/copy/copy-input.js +10 -6
  119. package/src/components/date-picker/date-picker.js +2 -1
  120. package/src/components/date-picker/date-range-picker.js +8 -7
  121. package/src/components/datebox/date-range-box.js +3 -9
  122. package/src/components/datebox/datebox.js +18 -21
  123. package/src/components/datebox/placeholder.js +18 -0
  124. package/src/components/dialog/dialog.js +1 -1
  125. package/src/components/dock/dock.js +34 -13
  126. package/src/components/entity-ref/entity-ref.js +16 -5
  127. package/src/components/field-upload/field-upload.js +81 -38
  128. package/src/components/file-item/file-item.js +70 -40
  129. package/src/components/file-list/file-list.js +15 -9
  130. package/src/components/filter/filter-model.js +46 -8
  131. package/src/components/filter/filter.css +3 -3
  132. package/src/components/filter/filter.js +29 -10
  133. package/src/components/filter-panel/filter-panel.js +13 -5
  134. package/src/components/finder/finder.js +50 -26
  135. package/src/components/flag/flag.css +40 -0
  136. package/src/components/flag/flag.js +177 -0
  137. package/src/components/form/form.js +1 -1
  138. package/src/components/grid/grid.js +22 -8
  139. package/src/components/kanban-view/kanban-view.js +51 -81
  140. package/src/components/launcher/launcher.js +17 -2
  141. package/src/components/list-toolbar/list-toolbar.js +2 -1
  142. package/src/components/master-panel/master-panel.js +1 -1
  143. package/src/components/menu-button/menu-button.js +4 -0
  144. package/src/components/message/message.js +3 -0
  145. package/src/components/multi-value-editor/multi-value-editor.js +10 -9
  146. package/src/components/navigation-bar/navigation-bar.js +3 -3
  147. package/src/components/number-field/number-field.js +29 -13
  148. package/src/components/prompt-starters/prompt-starters.css +91 -0
  149. package/src/components/prompt-starters/prompt-starters.js +206 -0
  150. package/src/components/prose/prose.js +14 -10
  151. package/src/components/questionnaire/conditions.js +666 -0
  152. package/src/components/questionnaire/items.js +150 -41
  153. package/src/components/questionnaire/questionnaire.js +126 -32
  154. package/src/components/rating/rating.js +5 -4
  155. package/src/components/run-status/run-status.js +2 -2
  156. package/src/components/select/country.js +136 -0
  157. package/src/components/select/field-adapter.js +7 -2
  158. package/src/components/select/locale.js +219 -0
  159. package/src/components/select/select.css +20 -22
  160. package/src/components/select/select.js +94 -12
  161. package/src/components/sheet/sheet-stack.js +10 -1
  162. package/src/components/slider/slider.js +7 -2
  163. package/src/components/sort-control/sort-control.js +15 -5
  164. package/src/components/source-list/source-list.js +7 -4
  165. package/src/components/split-view/split-view.js +5 -3
  166. package/src/components/surface/catalog.js +1334 -0
  167. package/src/components/surface/elicit.js +107 -0
  168. package/src/components/surface/mcp.js +243 -0
  169. package/src/components/surface/schema.js +644 -0
  170. package/src/components/surface/stream.js +245 -0
  171. package/src/components/surface/surface.css +308 -0
  172. package/src/components/surface/surface.js +2291 -0
  173. package/src/components/surface/text.js +513 -0
  174. package/src/components/surface/validate.js +2218 -0
  175. package/src/components/tabbox/tabbox.js +9 -0
  176. package/src/components/table/table.css +63 -3
  177. package/src/components/table/table.js +167 -28
  178. package/src/components/table/window.js +317 -0
  179. package/src/components/toolbar/toolbar.js +12 -7
  180. package/src/components/tooltip/tooltip.css +2 -3
  181. package/src/components/tooltip/tooltip.js +32 -5
  182. package/src/components/tree/tree.js +53 -23
  183. package/src/core/component.js +25 -1
  184. package/src/core/date.js +62 -16
  185. package/src/core/dom.js +22 -2
  186. package/src/core/format.js +15 -13
  187. package/src/core/http.js +29 -20
  188. package/src/core/i18n.js +83 -10
  189. package/src/core/keyboard.js +79 -8
  190. package/src/core/messages.js +376 -2
  191. package/src/core/overlay-host.js +1 -0
  192. package/src/core/storage.js +59 -6
  193. package/src/elements/define.js +178 -130
  194. package/src/elements/definitions.js +229 -0
  195. package/src/elements/kit.js +444 -0
  196. package/src/elements/reflect.js +8 -3
  197. package/src/index.js +10 -1
  198. package/src/internal/date-locale.js +11 -0
  199. package/src/internal/json-patch.js +405 -0
  200. package/src/locales/de.js +911 -0
  201. package/src/locales/en.js +2 -0
  202. package/src/locales/index.js +7 -0
  203. package/src/zeyos/calendar.js +2 -1
  204. package/src/zeyos/form.js +2 -1
  205. package/src/zeyos/launcher.js +7 -6
  206. package/src/zeyos/module-bar.js +2 -1
  207. package/src/zeyos/schema.js +37 -23
  208. package/src/zeyos/select.js +4 -3
  209. package/src/zeyos/table.js +2 -13
  210. package/src/zeyos/view.js +57 -17
  211. package/styles/core.css +11 -0
  212. package/styles/tokens/semantic.css +1 -0
  213. package/styles/zeyos.css +2 -0
  214. package/styles/zx.css +4 -8
  215. package/styles/zx.layered.css +1 -0
@@ -0,0 +1,317 @@
1
+ import { h } from '../../core/dom.js';
2
+
3
+ /** Row height assumed until a row has been measured: the default `--zx-row-height`. */
4
+ const ASSUMED_ROW_HEIGHT = 36;
5
+ /** Scroll-region height assumed until one has been measured. */
6
+ const ASSUMED_VIEWPORT = 600;
7
+
8
+ /**
9
+ * Which rows to draw for a scroll position: those in view, plus `overscan` viewports' worth above
10
+ * and below. Positions are zero-based and `end` is exclusive. The scroll position is clamped to
11
+ * what the rows can reach, so a list that just got shorter still draws its last rows while the
12
+ * browser catches up. Rows with no usable height yield one row, which is what gets measured.
13
+ * @param {{total: number, rowHeight: number, scrollTop: number, viewport: number, overscan?: number}} state
14
+ * Row count, height of one row, distance scrolled past the first row, height of the region the rows
15
+ * show through, and overscan in viewports.
16
+ * @returns {{start: number, end: number}} Half-open range of rows; empty for an empty table.
17
+ */
18
+ export function tableWindow({ total, rowHeight, scrollTop, viewport, overscan = 1 }) {
19
+ const count = Math.max(0, Math.trunc(Number(total) || 0));
20
+ const height = Number(rowHeight);
21
+ if (count === 0) return { start: 0, end: 0 };
22
+ if (!(height > 0)) return { start: 0, end: 1 };
23
+ const view = Math.max(Number(viewport) || 0, height);
24
+ const top = Math.min(Math.max(Number(scrollTop) || 0, 0), Math.max(0, count * height - view));
25
+ const first = Math.floor(top / height);
26
+ const last = Math.ceil((top + view) / height);
27
+ const extra = Math.ceil(view * Math.max(0, Number(overscan) || 0) / height);
28
+ return { start: Math.max(0, first - extra), end: Math.min(count, last + extra) };
29
+ }
30
+
31
+ /**
32
+ * Splits a table into what is drawn and what stands in for it: runs of rows and the gaps between
33
+ * them, in display order. A pinned row outside the window is drawn where it belongs, on its own,
34
+ * with a gap either side, so the rows stay in order and the scroll height stays right. Positions
35
+ * out of range are ignored.
36
+ * @param {number} total Row count.
37
+ * @param {number} start First row of the window.
38
+ * @param {number} end End of the window, exclusive.
39
+ * @param {Array<number|null|undefined>} [pinned=[]] Rows that stay drawn wherever they are.
40
+ * @returns {Array<{from: number, to: number}|{gap: number}>} Segments; a gap counts rows.
41
+ */
42
+ export function tableWindowSegments(total, start, end, pinned = []) {
43
+ const runs = end > start ? [{ from: start, to: end }] : [];
44
+ for (const index of pinned) {
45
+ if (!Number.isInteger(index) || index < 0 || index >= total) continue;
46
+ if (index < start || index >= end) runs.push({ from: index, to: index + 1 });
47
+ }
48
+ runs.sort((left, right) => left.from - right.from);
49
+
50
+ /** @type {Array<{from: number, to: number}|{gap: number}>} */
51
+ const segments = [];
52
+ /** @type {{from: number, to: number}|null} */
53
+ let run = null;
54
+ let cursor = 0;
55
+ for (const { from, to } of runs) {
56
+ if (run && from <= cursor) {
57
+ // Touching the previous run, or the same row pinned twice.
58
+ run.to = Math.max(run.to, to);
59
+ } else {
60
+ if (from > cursor) segments.push({ gap: from - cursor });
61
+ run = { from, to };
62
+ segments.push(run);
63
+ }
64
+ cursor = run.to;
65
+ }
66
+ if (cursor < total) segments.push({ gap: total - cursor });
67
+ return segments;
68
+ }
69
+
70
+ /**
71
+ * Where to scroll so a row is in view, moving as little as possible: a row already in view keeps
72
+ * the scroll position, and one outside it lands on the nearer edge.
73
+ * @param {{index: number, rowHeight: number, scrollTop: number, viewport: number}} state Row, height
74
+ * of one row, distance scrolled past the first row, and height of the region the rows show through.
75
+ * @returns {number} New distance past the first row.
76
+ */
77
+ export function tableWindowScroll({ index, rowHeight, scrollTop, viewport }) {
78
+ const top = index * rowHeight;
79
+ const bottom = top + rowHeight;
80
+ if (top < scrollTop) return top;
81
+ if (bottom > scrollTop + viewport) return Math.max(0, Math.min(top, bottom - viewport));
82
+ return scrollTop;
83
+ }
84
+
85
+ /**
86
+ * @typedef {Object} RowWindowHost
87
+ * @property {HTMLElement} scroller The element that scrolls.
88
+ * @property {HTMLElement} body Element the rows are children of.
89
+ * @property {HTMLElement} head Element above the rows.
90
+ * @property {boolean} sticky Whether `head` stays in place while the rows scroll under it.
91
+ * @property {(entry: any) => HTMLElement} draw Builds the row for an entry.
92
+ * @property {(row: HTMLElement) => void} release Forgets a row that left the DOM.
93
+ * @property {() => Array<number|undefined>} pins Positions that stay drawn wherever they are.
94
+ * @property {() => number} colspan Cells one row occupies.
95
+ * @property {() => void} changed Called after the drawn rows change.
96
+ */
97
+
98
+ /**
99
+ * Keeps a table body down to the rows around the scroll position. Spacer rows stand in for the rest,
100
+ * sized from one measured row, so the scroll height is the height of every row. Rows that stay in
101
+ * the window are never touched: moving one would blur it. Holds no listeners of its own except the
102
+ * `ResizeObserver` released by `stop()`.
103
+ */
104
+ export class RowWindow {
105
+ /** @param {RowWindowHost} host Table side of the arrangement. */
106
+ constructor(host) {
107
+ this.host = host;
108
+ /** @type {any[]} */
109
+ this.entries = [];
110
+ /** @type {Map<number, HTMLElement>} Drawn rows by position. */
111
+ this.drawn = new Map();
112
+ /** @type {HTMLElement[]} Spacer rows, reused by position. */
113
+ this.spacers = [];
114
+ this.rowHeight = ASSUMED_ROW_HEIGHT;
115
+ this.viewport = ASSUMED_VIEWPORT;
116
+ // Pixels of `head` that scroll away with the rows; none while it sticks.
117
+ this.offset = 0;
118
+ this.measured = false;
119
+ this.live = false;
120
+ this.frame = 0;
121
+ /** @type {ResizeObserver|null} */
122
+ this.observer = null;
123
+ // A sized box that answers to the row-height token, which no row can be trusted to report:
124
+ // rows come and go, and an observer attached to one goes with it.
125
+ this.probe = h('div', { class: 'zx-table__row-probe', ariaHidden: 'true' });
126
+ host.scroller.append(this.probe);
127
+ }
128
+
129
+ /** @returns {number} Rows in the table, drawn or not. */
130
+ get total() {
131
+ return this.entries.length;
132
+ }
133
+
134
+ /**
135
+ * Starts following the size of the scroll region and of a row. The first measurement arrives
136
+ * through the observer too, so it happens once the table is laid out and styled, however late it
137
+ * is attached. It waits for the next frame because a measurement may resize the scroll region
138
+ * itself, which an observer callback must not do.
139
+ * @returns {void}
140
+ */
141
+ start() {
142
+ this.live = true;
143
+ this.observer = new ResizeObserver(() => this.schedule());
144
+ this.observer.observe(this.host.scroller);
145
+ this.observer.observe(this.probe);
146
+ }
147
+
148
+ /** Measures on the next frame, however many times this is asked before it. @returns {void} */
149
+ schedule() {
150
+ cancelAnimationFrame(this.frame);
151
+ this.frame = requestAnimationFrame(() => this.measure());
152
+ }
153
+
154
+ /** Stops measuring. @returns {void} */
155
+ stop() {
156
+ this.live = false;
157
+ cancelAnimationFrame(this.frame);
158
+ this.observer?.disconnect();
159
+ this.observer = null;
160
+ }
161
+
162
+ /** Forgets every drawn row: the table is about to show none. @returns {void} */
163
+ clear() {
164
+ this.entries = [];
165
+ this.drawn = new Map();
166
+ this.spacers = [];
167
+ }
168
+
169
+ /**
170
+ * Draws the window for a new set of entries into a fragment. The caller replaces the old rows
171
+ * with it and has forgotten them already, so nothing is released here.
172
+ * @param {any[]} entries Every row, in display order.
173
+ * @param {DocumentFragment} fragment Receives the rows.
174
+ * @returns {void}
175
+ */
176
+ fill(entries, fragment) {
177
+ this.clear();
178
+ this.entries = entries;
179
+ this._lay(this._segments(), (node) => fragment.append(node));
180
+ }
181
+
182
+ /** Measures a table that has not been measured yet, once it can be. @returns {void} */
183
+ settle() {
184
+ if (this.live && !this.measured) this.measure();
185
+ }
186
+
187
+ /**
188
+ * Reads the height of a row and of the scroll region, and redraws if either changed. A table that
189
+ * is not laid out, detached or `display: none`, keeps what it knew.
190
+ * @returns {void}
191
+ */
192
+ measure() {
193
+ // A row from the middle of the window, with rows either side of it. The rows at its edges can
194
+ // measure differently when content sets their height: the last row of a table has no divider,
195
+ // and a pinned row sits between spacers.
196
+ const { start, end } = this._range();
197
+ const row = this.drawn.get(Math.floor((start + end - 1) / 2)) ?? this.drawn.values().next().value;
198
+ if (!row?.isConnected) return;
199
+ const { scroller, head, sticky } = this.host;
200
+ const rowHeight = row.getBoundingClientRect().height;
201
+ const region = scroller.clientHeight;
202
+ if (!(rowHeight > 0) || !(region > 0)) return;
203
+ const headHeight = head.getBoundingClientRect().height;
204
+ const viewport = Math.max(rowHeight, region - (sticky ? headHeight : 0));
205
+ const offset = sticky ? 0 : headHeight;
206
+ const changed = rowHeight !== this.rowHeight || viewport !== this.viewport || offset !== this.offset;
207
+ this.rowHeight = rowHeight;
208
+ this.viewport = viewport;
209
+ this.offset = offset;
210
+ this.measured = true;
211
+ if (changed) this.update();
212
+ }
213
+
214
+ /**
215
+ * Brings the drawn rows in line with the scroll position and the pins: rows that left are removed,
216
+ * rows that arrived are built, and rows that stayed are left exactly where they are.
217
+ * @returns {void}
218
+ */
219
+ update() {
220
+ if (this.total === 0) return;
221
+ const segments = this._segments();
222
+ const { drawn, spacers } = this;
223
+ const { body, release, changed } = this.host;
224
+ for (const [index, row] of drawn) {
225
+ if (segments.some((part) => 'from' in part && index >= part.from && index < part.to)) continue;
226
+ drawn.delete(index);
227
+ row.remove();
228
+ release(row);
229
+ }
230
+ // Out of the way first, so the only children left are rows that stay, in order, and laying the
231
+ // segments over them never has to move one.
232
+ for (const spacer of spacers) spacer.remove();
233
+ let cursor = body.firstChild;
234
+ this._lay(segments, (node) => {
235
+ if (node === cursor) cursor = cursor.nextSibling;
236
+ else body.insertBefore(node, cursor);
237
+ });
238
+ changed();
239
+ }
240
+
241
+ /**
242
+ * Draws a row if it is not, with the scroll region moved so it is in view.
243
+ * @param {number} index Row position.
244
+ * @returns {HTMLElement|null} The row, or null when there is none at that position.
245
+ */
246
+ reveal(index) {
247
+ if (index < 0 || index >= this.total) return null;
248
+ this.measure();
249
+ const position = this._position();
250
+ const next = tableWindowScroll({
251
+ index, rowHeight: this.rowHeight, scrollTop: position, viewport: this.viewport
252
+ });
253
+ if (next !== position) this.host.scroller.scrollTop = next + this.offset;
254
+ this.update();
255
+ return this.drawn.get(index) ?? null;
256
+ }
257
+
258
+ /** @returns {number} Distance the rows have scrolled past the first one. */
259
+ _position() {
260
+ return Math.max(0, this.host.scroller.scrollTop - this.offset);
261
+ }
262
+
263
+ /** @returns {{start: number, end: number}} The rows the scroll position calls for. */
264
+ _range() {
265
+ return tableWindow({
266
+ total: this.total, rowHeight: this.rowHeight, scrollTop: this._position(), viewport: this.viewport
267
+ });
268
+ }
269
+
270
+ /** @returns {Array<{from: number, to: number}|{gap: number}>} What the body should hold now. */
271
+ _segments() {
272
+ const { start, end } = this._range();
273
+ return tableWindowSegments(this.total, start, end, this.host.pins());
274
+ }
275
+
276
+ /**
277
+ * Walks the segments and hands each node to `place`, building rows that are not drawn.
278
+ * @param {Array<{from: number, to: number}|{gap: number}>} segments Segments in display order.
279
+ * @param {(node: HTMLElement) => void} place Puts one node after the previous one.
280
+ * @returns {void}
281
+ */
282
+ _lay(segments, place) {
283
+ let gaps = 0;
284
+ for (const part of segments) {
285
+ if ('gap' in part) {
286
+ place(this._spacer(gaps, part.gap));
287
+ gaps += 1;
288
+ continue;
289
+ }
290
+ for (let index = part.from; index < part.to; index += 1) {
291
+ let row = this.drawn.get(index);
292
+ if (!row) {
293
+ row = this.host.draw(this.entries[index]);
294
+ this.drawn.set(index, row);
295
+ }
296
+ place(row);
297
+ }
298
+ }
299
+ }
300
+
301
+ /**
302
+ * The spacer row standing in for a run of rows that are not drawn.
303
+ * @param {number} position Which gap this is, from the top.
304
+ * @param {number} rows Rows it stands in for.
305
+ * @returns {HTMLElement}
306
+ */
307
+ _spacer(position, rows) {
308
+ let spacer = this.spacers[position];
309
+ if (!spacer) {
310
+ spacer = h('tr', { class: 'zx-table__spacer', ariaHidden: 'true' },
311
+ h('td', { colspan: this.host.colspan() }));
312
+ this.spacers[position] = spacer;
313
+ }
314
+ /** @type {HTMLElement} */ (spacer.firstElementChild).style.blockSize = `${rows * this.rowHeight}px`;
315
+ return spacer;
316
+ }
317
+ }
@@ -43,9 +43,11 @@ const ITEM_SELECTOR = FOCUSABLE
43
43
  * @typedef {Object} ToolbarOptions
44
44
  * @property {ToolbarItem[]} [items=[]] Controls, separators (`'-'`), and ready-made Elements.
45
45
  * @property {'start'|'end'|'between'} [align='start'] Horizontal distribution.
46
- * @property {string} [label='Toolbar'] Accessible name of the toolbar.
46
+ * @property {string|null} [label] Accessible name of the toolbar, by default the `toolbar.label`
47
+ * message ("Toolbar"). Null gives none.
47
48
  * @property {boolean} [overflow=true] Collapses items that no longer fit into a trailing menu.
48
- * @property {string} [overflowLabel='More'] Accessible name of the overflow menu trigger.
49
+ * @property {string|null} [overflowLabel] Accessible name of the overflow menu trigger, by default
50
+ * the `toolbar.more` message ("More"). Null gives none.
49
51
  * @property {boolean} [dense=false] Tighter spacing and small controls.
50
52
  * @property {(event: CustomEvent<{name: string|null, item: Element}>) => void} [onaction] Action listener.
51
53
  */
@@ -63,9 +65,10 @@ export class Toolbar extends Component {
63
65
  static defaults = {
64
66
  items: [],
65
67
  align: 'start',
66
- label: 'Toolbar',
68
+ // Undefined rather than null, which gives no name.
69
+ label: undefined,
67
70
  overflow: true,
68
- overflowLabel: 'More',
71
+ overflowLabel: undefined,
69
72
  dense: false
70
73
  };
71
74
 
@@ -105,8 +108,9 @@ export class Toolbar extends Component {
105
108
  });
106
109
  const trigger = /** @type {HTMLButtonElement} */ (this.#overflow.toElement());
107
110
  trigger.classList.add('zx-toolbar__overflow');
108
- trigger.setAttribute('aria-label', String(this.options.overflowLabel));
109
- trigger.setAttribute('title', String(this.options.overflowLabel));
111
+ const { overflowLabel = this.msg('toolbar.more') } = this.options;
112
+ trigger.setAttribute('aria-label', String(overflowLabel ?? ''));
113
+ trigger.setAttribute('title', String(overflowLabel ?? ''));
110
114
  if (this.options.dense) trigger.setAttribute('data-size', 'sm');
111
115
  trigger.hidden = true;
112
116
  }
@@ -142,7 +146,8 @@ export class Toolbar extends Component {
142
146
  Array.from(root.children) : items;
143
147
 
144
148
  root.setAttribute('role', 'toolbar');
145
- root.setAttribute('aria-label', String(this.options.label));
149
+ const { label = this.msg('toolbar.label') } = this.options;
150
+ root.setAttribute('aria-label', String(label ?? ''));
146
151
  root.dataset.align = normalizeAlign(this.options.align);
147
152
  root.dataset.overflow = this.options.overflow ? 'true' : 'false';
148
153
  if (this.options.dense) root.dataset.dense = 'true';
@@ -24,9 +24,8 @@
24
24
  line-height: 1.45;
25
25
  text-align: start;
26
26
  overflow-wrap: anywhere;
27
- /* A tooltip describes its anchor; it must never become a target of its own. Without this, the
28
- bubble would steal the hover that keeps it open the moment it covered the anchor. */
29
- pointer-events: none;
27
+ /* The bubble keeps its description visible while a pointer moves across it. */
28
+ pointer-events: auto;
30
29
  user-select: none;
31
30
  }
32
31
 
@@ -42,8 +42,8 @@ const TRIGGERS = new Set(['hover', 'focus', 'both', 'manual']);
42
42
  *
43
43
  * The bubble is a manual popover in the top layer, positioned by `position()` from the kernel, so
44
44
  * it escapes clipping and stacking contexts and flips near a viewport edge. It never takes focus
45
- * and never receives pointer events: it describes the anchor rather than adding a target of its
46
- * own. While open, the anchor carries `aria-describedby` pointing at the bubble; closing restores
45
+ * but remains visible while the pointer is over either the anchor or the bubble. While open, the
46
+ * anchor carries `aria-describedby` pointing at the bubble; closing restores
47
47
  * whatever the anchor had before — including nothing at all.
48
48
  *
49
49
  * A hover opens it after `delay`; keyboard focus opens it at once, because a keyboard user has no
@@ -83,6 +83,9 @@ export class Tooltip extends Component {
83
83
  #closeTimer = 0;
84
84
  /** True between `pointerdown` and `pointerup`, so a click-induced focus cannot re-open. */
85
85
  #pointerActive = false;
86
+ #anchorHovered = false;
87
+ #bubbleHovered = false;
88
+ #focused = false;
86
89
  /** Whether the tooltip dismisses itself (every trigger but `manual`). */
87
90
  #dismissible = false;
88
91
  /** @type {import('../../core/overlay-stack.js').OverlayHandle|null} */
@@ -116,18 +119,37 @@ export class Tooltip extends Component {
116
119
  this.listen(this.#anchor, 'pointerenter', (event) => {
117
120
  // A touch tooltip has no "move away" gesture to close it, so it would stick open.
118
121
  if (/** @type {PointerEvent} */ (event).pointerType === 'touch') return;
122
+ this.#anchorHovered = true;
119
123
  this.#scheduleShow(Number(this.options.delay));
120
124
  });
121
- this.listen(this.#anchor, 'pointerleave', () => this.#scheduleHide(Number(this.options.hideDelay)));
125
+ this.listen(this.#anchor, 'pointerleave', (event) => {
126
+ if (/** @type {PointerEvent} */ (event).pointerType === 'touch') return;
127
+ this.#anchorHovered = false;
128
+ this.#scheduleHide(Number(this.options.hideDelay));
129
+ });
122
130
  }
123
131
 
132
+ this.listen(this.el, 'pointerenter', (event) => {
133
+ if (/** @type {PointerEvent} */ (event).pointerType === 'touch') return;
134
+ this.#bubbleHovered = true;
135
+ this.#cancelTimers();
136
+ });
137
+ this.listen(this.el, 'pointerleave', () => {
138
+ this.#bubbleHovered = false;
139
+ this.#scheduleHide(Number(this.options.hideDelay));
140
+ });
141
+
124
142
  if (trigger === 'focus' || trigger === 'both') {
125
143
  this.listen(this.#anchor, 'focusin', () => {
126
144
  // Focus that came from a click is not a request for a tooltip; the pointer already closed it.
127
145
  if (this.#pointerActive || !isFocusVisible(this.#anchor)) return;
146
+ this.#focused = true;
128
147
  this.#scheduleShow(0);
129
148
  });
130
- this.listen(this.#anchor, 'focusout', () => this.#scheduleHide(Number(this.options.hideDelay)));
149
+ this.listen(this.#anchor, 'focusout', () => {
150
+ this.#focused = false;
151
+ this.#scheduleHide(Number(this.options.hideDelay));
152
+ });
131
153
  }
132
154
 
133
155
  // A press on the anchor closes the bubble and cancels a pending open, and the focus that
@@ -200,7 +222,10 @@ export class Tooltip extends Component {
200
222
  inside: [this.#anchor],
201
223
  onEscape: this.#dismissible ? () => { this.hide(); } : undefined,
202
224
  onOutsidePointer: this.#dismissible ? () => this.hide() : undefined,
203
- onFocusOutside: this.#dismissible ? () => this.hide() : undefined,
225
+ onFocusOutside: this.#dismissible ? () => {
226
+ this.#focused = false;
227
+ this.#scheduleHide(Number(this.options.hideDelay));
228
+ } : undefined,
204
229
  onParentClose: () => this.hide()
205
230
  });
206
231
  this.emit('open');
@@ -217,6 +242,7 @@ export class Tooltip extends Component {
217
242
  if (!this.isOpen()) return this;
218
243
  this.#position?.destroy();
219
244
  this.#position = null;
245
+ this.#bubbleHovered = false;
220
246
  this.el.dataset.state = 'closed';
221
247
  this.el.replaceChildren();
222
248
  this.#restoreDescribedBy();
@@ -323,6 +349,7 @@ export class Tooltip extends Component {
323
349
  /** @param {number} delay @returns {void} */
324
350
  #scheduleHide(delay) {
325
351
  this.#cancelTimers();
352
+ if (this.#anchorHovered || this.#bubbleHovered || this.#focused) return;
326
353
  if (!this.isOpen()) return;
327
354
  const ms = Number.isFinite(delay) ? Math.max(0, delay) : 0;
328
355
  if (ms === 0) {
@@ -28,12 +28,14 @@ import {
28
28
  * rest out of sight and show while the row is pointed at, focused or selected; one or two show
29
29
  * as icon buttons, more fold after the first into a "More actions" menu. Every descriptor is also
30
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").
31
+ * @property {string|null} [moreLabel=null] Name of a row's overflow menu; every action name is
32
+ * followed by the row's name ("More actions: Q3 plan"). Null reads the `tree.more` message.
33
33
  * @property {((node: TreeNode) => Promise<TreeNode[]>|TreeNode[])|null} [load=null] Lazy child loader.
34
34
  * @property {string} [filter=''] Label substring the tree is filtered by.
35
- * @property {string} [label='Tree'] Accessible name of the tree.
36
- * @property {string} [emptyText='Nothing to show'] Text shown when the tree is empty.
35
+ * @property {string|null} [label=null] Accessible name of the tree; null reads the `tree.label`
36
+ * message ("Tree").
37
+ * @property {string|null} [emptyText] Text shown when the tree is empty, by default the
38
+ * `tree.noItems` message ("Nothing to show"). Null shows none.
37
39
  * @property {number|string|null} [height=null] Scroll height in pixels or any CSS length.
38
40
  * @property {Record<string, string>|Record<string, Record<string, string>>} [msg] Localized messages.
39
41
  * @property {(event: CustomEvent<{node: TreeNode, id: unknown, ids: unknown[]}>) => void} [onselect] Selection listener.
@@ -76,11 +78,12 @@ export class TreeView extends Component {
76
78
  icons: true,
77
79
  renderLabel: null,
78
80
  rowActions: null,
79
- moreLabel: 'More actions',
81
+ moreLabel: null,
80
82
  load: null,
81
83
  filter: '',
82
- label: 'Tree',
83
- emptyText: 'Nothing to show',
84
+ label: null,
85
+ // Undefined rather than null, which shows nothing.
86
+ emptyText: undefined,
84
87
  height: null
85
88
  };
86
89
 
@@ -94,6 +97,9 @@ export class TreeView extends Component {
94
97
  this._checked = new Set();
95
98
  /** @type {Map<unknown, Promise<boolean>>} In-flight lazy loads, keyed by node ID. */
96
99
  this._loading = new Map();
100
+ this._loadGeneration = 0;
101
+ this._destroyed = false;
102
+ this._expanding = new Map();
97
103
  this._focusId = null;
98
104
  this._filter = '';
99
105
  /** @type {Array<import('../../internal/row-actions.js').RowActionStrip|undefined>} Per visible row. */
@@ -108,7 +114,7 @@ export class TreeView extends Component {
108
114
  this._childrenKey = this.options.childrenKey ?? 'children';
109
115
 
110
116
  root.setAttribute('role', 'tree');
111
- root.setAttribute('aria-label', String(this.options.label ?? 'Tree'));
117
+ root.setAttribute('aria-label', String(this.options.label ?? this.msg('tree.label')));
112
118
  root.tabIndex = 0;
113
119
  if (this.options.selection === 'multi') root.setAttribute('aria-multiselectable', 'true');
114
120
  if (this.options.height !== null) {
@@ -176,6 +182,9 @@ export class TreeView extends Component {
176
182
  * @returns {this}
177
183
  */
178
184
  setItems(items) {
185
+ this._loadGeneration += 1;
186
+ this._loading.clear();
187
+ this._expanding.clear();
179
188
  this._items = cloneNodes(items);
180
189
  this._renderRows();
181
190
  return this;
@@ -233,6 +242,7 @@ export class TreeView extends Component {
233
242
  * @fires TreeView#expand
234
243
  */
235
244
  async expand(id) {
245
+ if (this._destroyed) return this;
236
246
  const node = this.getNode(id);
237
247
  if (!node || !isBranch(node, this._readers)) return this;
238
248
  const loaded = this._readers.children(node);
@@ -240,7 +250,11 @@ export class TreeView extends Component {
240
250
  // An ID can already be in the expanded set without its children having been fetched
241
251
  // (`expanded` option, expandAll, `*`, filtering) — that still has to trigger the loader.
242
252
  if (this._expanded.has(id) && !needsLoad) return this;
253
+ const operation = {};
254
+ this._expanding.set(id, operation);
243
255
  const ok = await this._ensureChildren(node, id);
256
+ if (this._destroyed || this._expanding.get(id) !== operation) return this;
257
+ this._expanding.delete(id);
244
258
  if (!ok) return this;
245
259
  this._expanded.add(id);
246
260
  this._renderRows();
@@ -255,6 +269,7 @@ export class TreeView extends Component {
255
269
  * @fires TreeView#collapse
256
270
  */
257
271
  collapse(id) {
272
+ this._expanding.delete(id);
258
273
  if (!this._expanded.delete(id)) return this;
259
274
  const node = this.getNode(id);
260
275
  this._renderRows();
@@ -286,6 +301,7 @@ export class TreeView extends Component {
286
301
 
287
302
  /** Collapses every branch. @returns {this} */
288
303
  collapseAll() {
304
+ this._expanding.clear();
289
305
  this._expanded.clear();
290
306
  this._renderRows();
291
307
  return this;
@@ -442,8 +458,8 @@ export class TreeView extends Component {
442
458
  for (const strip of this._strips.splice(0)) strip?.destroy();
443
459
 
444
460
  if (this._rows.length === 0) {
445
- this.el.replaceChildren(h('div', { class: 'zx-tree__empty' },
446
- this._message('tree.empty', this.options.emptyText)));
461
+ const { emptyText = this.msg('tree.noItems') } = this.options;
462
+ this.el.replaceChildren(h('div', { class: 'zx-tree__empty' }, this._message('tree.empty', emptyText)));
447
463
  return;
448
464
  }
449
465
  this.el.replaceChildren(...this._rows.map((row, index) => this._renderRow(row, index)));
@@ -504,7 +520,7 @@ export class TreeView extends Component {
504
520
  ? renderRowActions(this.options.rowActions(this._subject(row)), {
505
521
  block: 'tree',
506
522
  name: this._readers.label(row.node),
507
- moreLabel: String(this.options.moreLabel ?? 'More actions'),
523
+ moreLabel: String(this.options.moreLabel ?? this.msg('tree.more')),
508
524
  run: (action) => action.onSelect(this._subject(row))
509
525
  })
510
526
  : null;
@@ -584,7 +600,12 @@ export class TreeView extends Component {
584
600
  const action = /** @type {Element} */ (event.target).closest('[data-action]');
585
601
  if (action?.dataset.action === 'twisty') {
586
602
  // toggle() re-renders every row, so focus has to be put back on this one afterwards.
587
- if (isBranch(row.node, this._readers)) void this.toggle(row.id).then(() => this._focusNodeId(row.id));
603
+ const generation = this._loadGeneration;
604
+ if (isBranch(row.node, this._readers)) void this.toggle(row.id).then(() => {
605
+ if (!this._destroyed && generation === this._loadGeneration && Object.is(this._focusId, row.id)) {
606
+ this._focusNodeId(row.id);
607
+ }
608
+ });
588
609
  return;
589
610
  }
590
611
  const node = this.getNode(row.id) ?? row.node;
@@ -633,12 +654,18 @@ export class TreeView extends Component {
633
654
  event.preventDefault();
634
655
  this._focusRow(Math.max(0, index - 1));
635
656
  return;
636
- case 'ArrowRight':
657
+ case 'ArrowRight': {
637
658
  event.preventDefault();
638
659
  // Re-find the row by ID after the async expand: positional indices can have shifted.
639
- if (branch && !expanded) void this.expand(row.id).then(() => this._focusNodeId(row.id));
660
+ const generation = this._loadGeneration;
661
+ if (branch && !expanded) void this.expand(row.id).then(() => {
662
+ if (!this._destroyed && generation === this._loadGeneration && Object.is(this._focusId, row.id)) {
663
+ this._focusNodeId(row.id);
664
+ }
665
+ });
640
666
  else if (expanded) this._focusRow(Math.min(this._rows.length - 1, index + 1));
641
667
  return;
668
+ }
642
669
  case 'ArrowLeft': {
643
670
  event.preventDefault();
644
671
  if (expanded) {
@@ -706,33 +733,32 @@ export class TreeView extends Component {
706
733
  * Loads a branch's children through the configured loader, once.
707
734
  * @param {TreeNode} node Branch node.
708
735
  * @param {unknown} id Node ID.
709
- * @returns {Promise<void>}
736
+ * @returns {Promise<boolean>}
710
737
  */
711
738
  async _ensureChildren(node, id) {
712
739
  const loaded = this._readers.children(node);
713
740
  if (!this.options.load || (loaded && loaded.length > 0)) return true;
714
741
  // One in-flight request per branch: concurrent expansions must not call the loader twice.
715
- if (this._loading.has(id)) {
716
- await this._loading.get(id);
717
- return Array.isArray(this._readers.children(node));
718
- }
742
+ if (this._loading.has(id)) return this._loading.get(id);
743
+ const generation = this._loadGeneration;
719
744
  const request = (async () => {
720
745
  try {
721
746
  const children = await this.options.load(node);
747
+ if (this._destroyed || generation !== this._loadGeneration) return false;
722
748
  node[this._childrenKey] = Array.isArray(children) ? children : [];
723
749
  // A branch that turns out to be empty must stop advertising children.
724
750
  if (node[this._childrenKey].length === 0) node.hasChildren = false;
725
751
  return true;
726
752
  } catch (error) {
727
- this.emit('error', { error, node, id });
753
+ if (!this._destroyed && generation === this._loadGeneration) this.emit('error', { error, node, id });
728
754
  return false;
729
- } finally {
730
- this._loading.delete(id);
731
755
  }
732
756
  })();
733
757
  this._loading.set(id, request);
734
- this._syncRows();
758
+ if (!this._destroyed && generation === this._loadGeneration) this._syncRows();
735
759
  const ok = await request;
760
+ if (this._destroyed || generation !== this._loadGeneration) return false;
761
+ if (this._loading.get(id) === request) this._loading.delete(id);
736
762
  this._syncRows();
737
763
  return ok;
738
764
  }
@@ -838,6 +864,10 @@ export class TreeView extends Component {
838
864
 
839
865
  /** Restores an enhanced target to the markup it had before the takeover. @returns {void} */
840
866
  destroy() {
867
+ this._destroyed = true;
868
+ this._loadGeneration += 1;
869
+ this._loading.clear();
870
+ this._expanding.clear();
841
871
  const root = this.el;
842
872
  for (const strip of this._strips?.splice(0) ?? []) strip?.destroy();
843
873
  this._rowMenu?.destroy();