@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
@@ -311,6 +311,8 @@ export class Tabbox extends Component {
311
311
  disableTab(name) {
312
312
  const record = this._require(name);
313
313
  if (record.definition.disabled) return this;
314
+ const held = record.tab.contains(document.activeElement);
315
+ const wasStop = record.tab.tabIndex === 0;
314
316
  if (record === this._active) {
315
317
  const replacement = this._enabledTabs().find((item) => item !== record) ?? null;
316
318
  if (replacement) {
@@ -327,6 +329,10 @@ export class Tabbox extends Component {
327
329
  record.definition.disabled = true;
328
330
  record.tab.setAttribute('aria-disabled', 'true');
329
331
  record.tab.tabIndex = -1;
332
+ if (held || wasStop) {
333
+ const replacement = this._active ?? this._enabledTabs()[0];
334
+ if (replacement) this._setFocused(replacement, held);
335
+ }
330
336
  return this;
331
337
  }
332
338
 
@@ -393,6 +399,8 @@ export class Tabbox extends Component {
393
399
  const record = this._find(name);
394
400
  if (!record) return false;
395
401
  const index = this._tabs.indexOf(record);
402
+ const held = record.tab.contains(document.activeElement);
403
+ const wasStop = record.tab.tabIndex === 0;
396
404
  const remaining = this._tabs.filter((item) => item !== record);
397
405
  const enabled = remaining.filter((item) => !item.definition.disabled);
398
406
  const replacement = enabled.find((item) => this._tabs.indexOf(item) > index) ?? enabled.at(-1) ?? null;
@@ -411,6 +419,7 @@ export class Tabbox extends Component {
411
419
  this._active = null;
412
420
  if (replacement) this._applyActive(replacement);
413
421
  }
422
+ if ((held || wasStop) && replacement) this._setFocused(replacement, held);
414
423
  if (emitClose) this.emit('close', { name: record.definition.name });
415
424
  return true;
416
425
  }
@@ -377,7 +377,8 @@
377
377
  border-block-end: 0;
378
378
  }
379
379
 
380
- .zx-table__scroll[data-zebra="true"] .zx-table__body tr:nth-child(even):not([aria-selected="true"]) {
380
+ .zx-table__scroll[data-zebra="true"] .zx-table__body tr:nth-child(even):not([aria-selected="true"]),
381
+ .zx-table__scroll[data-zebra="index"] .zx-table__body tr[data-stripe]:not([aria-selected="true"]) {
381
382
  --zx-table-row-fill: var(--zx-color-bg-page);
382
383
  background: var(--zx-table-row-fill);
383
384
  }
@@ -401,7 +402,8 @@
401
402
  /* State is never lost under the pointer: a selected, current or striped row lays the hover step
402
403
  over its own fill instead of trading it for the hover fill. */
403
404
  .zx-table__body tr[data-row][aria-selected="true"]:hover,
404
- .zx-table__scroll[data-zebra="true"] .zx-table__body tr[data-row]:nth-child(even):not([aria-selected="true"]):hover {
405
+ .zx-table__scroll[data-zebra="true"] .zx-table__body tr[data-row]:nth-child(even):not([aria-selected="true"]):hover,
406
+ .zx-table__scroll[data-zebra="index"] .zx-table__body tr[data-stripe]:not([aria-selected="true"]):hover {
405
407
  background: linear-gradient(var(--zx-table-row-hover-bg, var(--zx-color-bg-hover)),
406
408
  var(--zx-table-row-hover-bg, var(--zx-color-bg-hover))), var(--zx-table-row-fill);
407
409
  }
@@ -433,7 +435,8 @@
433
435
  }
434
436
 
435
437
  /* The stripe's own rule paints this fill, and the hover step lays over it, so nothing more. */
436
- .zx-table[data-variant="plain"] .zx-table__scroll[data-zebra="true"] .zx-table__body tr:nth-child(even):not([aria-selected="true"]) {
438
+ .zx-table[data-variant="plain"] .zx-table__scroll[data-zebra="true"] .zx-table__body tr:nth-child(even):not([aria-selected="true"]),
439
+ .zx-table[data-variant="plain"] .zx-table__scroll[data-zebra="index"] .zx-table__body tr[data-stripe]:not([aria-selected="true"]) {
437
440
  --zx-table-row-fill: transparent;
438
441
  }
439
442
 
@@ -803,3 +806,60 @@
803
806
  background: var(--zx-color-bg-hover);
804
807
  color: var(--zx-color-text);
805
808
  }
809
+
810
+ /* --- Windowed rendering (Table virtual) ----------------------------------------------------- */
811
+
812
+ /* A windowed table cannot grow with its rows, so the window height is the most it takes unless
813
+ `height` says otherwise. Scroll anchoring stays off: the rows it would anchor to are the ones
814
+ the window replaces, and the spacers already keep everything in place. */
815
+ .zx-table[data-virtual] .zx-table__scroll {
816
+ max-block-size: 100dvh;
817
+ overflow-anchor: none;
818
+ }
819
+
820
+ /* One height for every row: text is cut short rather than wrapped into a taller row. */
821
+ .zx-table[data-virtual]:not([data-stacked]) .zx-table__body > tr[data-row] > :is(td[data-column]:not([data-editing]), .zx-table__section-cell) {
822
+ overflow: hidden;
823
+ text-overflow: ellipsis;
824
+ white-space: nowrap;
825
+ }
826
+
827
+ /* After the row, stacked, and empty rules above, which a spacer must take nothing from. Its height
828
+ is set inline from the rows it stands in for. */
829
+ .zx-table .zx-table__body > tr.zx-table__spacer {
830
+ padding: 0;
831
+ border: 0;
832
+ }
833
+
834
+ .zx-table .zx-table__body > tr.zx-table__spacer > td {
835
+ padding: 0;
836
+ border: 0;
837
+ }
838
+
839
+ /* What a row is tall in this table, in a box the window can watch. */
840
+ .zx-table__row-probe {
841
+ position: absolute;
842
+ inset-block-start: 0;
843
+ inline-size: 0;
844
+ block-size: var(--zx-row-height);
845
+ visibility: hidden;
846
+ }
847
+
848
+ .zx-table[data-edit-mode] .zx-table__row-probe {
849
+ block-size: max(var(--zx-row-height), calc(var(--zx-control-height) + 1px));
850
+ }
851
+
852
+ /* Paper has no scroll position to keep: the drawn rows print without the height of the others. */
853
+ @media print {
854
+ .zx-table .zx-table__body > tr.zx-table__spacer {
855
+ display: none;
856
+ }
857
+
858
+ .zx-table[data-virtual] .zx-table__scroll {
859
+ max-block-size: none;
860
+ }
861
+
862
+ .zx-scope .zx-table__scroll[data-zebra="index"] .zx-table__body tr[data-stripe]:not([aria-selected="true"]) {
863
+ background: transparent;
864
+ }
865
+ }
@@ -10,6 +10,7 @@ import { NumberField } from '../number-field/number-field.js';
10
10
  import { Select } from '../select/select.js';
11
11
  import { Toggle } from '../toggle/toggle.js';
12
12
  import { sortRows } from './sort.js';
13
+ import { RowWindow } from './window.js';
13
14
 
14
15
  /** @typedef {Record<string, any>} TableRow */
15
16
  /** @typedef {'asc'|'desc'} TableSortDirection */
@@ -114,6 +115,15 @@ import { sortRows } from './sort.js';
114
115
  * @property {false|number} [growing=false] Number of rows to render at first, with a control that
115
116
  * appends the next batch on demand. A result set an ERP query returns happily — tens of thousands
116
117
  * of rows — costs more to lay out than anyone will ever scroll through.
118
+ * @property {boolean} [virtual=false] Windowed rendering: only the rows in view and one viewport of
119
+ * overscan above and below are in the DOM, with spacer rows keeping the scroll height. The table
120
+ * stays one grid over all of its rows, so this implies `interactive`, the header checkbox and
121
+ * Ctrl/Cmd+A take every row, drawn or not, and the row that has focus or is being edited stays drawn
122
+ * wherever it is. It needs a bounded scroll region: give it `height`,
123
+ * or the region stops at the height of the window. Every row takes the height of one measured row,
124
+ * rows of differing height are not supported, and column widths cannot follow content that is not
125
+ * drawn, so `auto` columns share the width evenly. Find-in-page does not see rows that are not
126
+ * drawn. Wins over `growing`.
117
127
  * @property {false|'sm'|'md'|'lg'|'xl'} [responsive=false] Width below which each row stacks into a
118
128
  * card of label/value pairs instead of scrolling sideways. Measured on the table's own container,
119
129
  * not the viewport, so a table inside a split pane stacks when *it* is narrow.
@@ -281,7 +291,9 @@ const FOCUSABLE = 'input, textarea, select, button, [tabindex]:not([tabindex="-1
281
291
  * does not scroll). Enter activates the row exactly as a click does (`rowclick`), Space toggles the
282
292
  * row's selection when `selectable` (and activates otherwise), Shift+Arrow extends a `multi`
283
293
  * selection, and Ctrl/Cmd+A selects every rendered row. The focused row survives `setData`, sorting,
284
- * expansion, and `updateRow`. Column headers keep their sort buttons in the Tab order.
294
+ * expansion, and `updateRow`. Column headers keep their sort buttons in the Tab order. With `virtual`
295
+ * all of this runs over every row, drawn or not: the keys draw the row they move to, and a selection
296
+ * reaches rows that are not in the DOM.
285
297
  * @fires Table#rowclick
286
298
  * @fires Table#rowdblclick
287
299
  * @fires Table#sort
@@ -313,6 +325,7 @@ export class Table extends Component {
313
325
  stickyHeader: true,
314
326
  responsive: false,
315
327
  growing: false,
328
+ virtual: false,
316
329
  height: null,
317
330
  emptyText: null,
318
331
  rowClass: null,
@@ -373,7 +386,13 @@ export class Table extends Component {
373
386
  this._editMessage = null;
374
387
  this._stacked = false;
375
388
  this._width = null;
376
- this._growStep = growStep(this.options.growing);
389
+ this._virtual = Boolean(this.options.virtual);
390
+ if (this._virtual && growStep(this.options.growing)) {
391
+ console.warn('[zx.Table] `growing` is ignored: `virtual` already decides which rows are drawn.');
392
+ }
393
+ this._growStep = this._virtual ? null : growStep(this.options.growing);
394
+ // Both keep only part of the rows in the DOM, so both have to say where each row really is.
395
+ this._indexed = Boolean(this._growStep || this._virtual);
377
396
  this._rendered = this._growStep ?? Infinity;
378
397
  this._more = null;
379
398
  // Keyboard focus. `_current` is the row (and, with cell focus, the column) holding the grid's
@@ -381,7 +400,7 @@ export class Table extends Component {
381
400
  this._focusMode = this._editMode === false ? 'row' : 'cell';
382
401
  // `_clickListened` is set by `addEventListener()`, which the base constructor runs for `on…`
383
402
  // options before this method; it is deliberately not reset here.
384
- this._interactive = Boolean(this.options.interactive || this.options.selectable
403
+ this._interactive = Boolean(this.options.interactive || this.options.selectable || this._virtual
385
404
  || this._editMode !== false || normalizeHierarchy(this.options.hierarchy, this._columns)
386
405
  || this._clickListened);
387
406
  this._current = null;
@@ -418,9 +437,26 @@ export class Table extends Component {
418
437
  class: 'zx-table__scroll',
419
438
  dataset: {
420
439
  stickyHeader: String(Boolean(this.options.stickyHeader)),
421
- zebra: String(Boolean(this.options.zebra))
440
+ // Stripes follow the row's place in the data while windowed: `:nth-child` would count the
441
+ // spacers, and the stripes would swap as the window moved.
442
+ zebra: this._virtual && this.options.zebra ? 'index' : String(Boolean(this.options.zebra))
422
443
  }
423
444
  }, this._table);
445
+ this._window = null;
446
+ if (this._virtual) {
447
+ root.dataset.virtual = '';
448
+ this._window = new RowWindow({
449
+ scroller: this._scroll,
450
+ body: this._tbody,
451
+ head: this._thead,
452
+ sticky: Boolean(this.options.stickyHeader),
453
+ draw: (entry) => this._createRow(entry.row, entry.index, entry),
454
+ release: (row) => this._releaseRow(row),
455
+ pins: () => this._windowPins(),
456
+ colspan: () => this._spanColspan(),
457
+ changed: () => { if (this._stacked) this._applyStackedRoles(true); }
458
+ });
459
+ }
424
460
  this._rowMoveMessage = this.options.rowReorder ? h('div', {
425
461
  class: 'zx-table__reorder-status', role: 'status', ariaLive: 'polite'
426
462
  }) : null;
@@ -449,6 +485,10 @@ export class Table extends Component {
449
485
  this._renderHeader();
450
486
  this._renderBody();
451
487
  this._watchWidth();
488
+ if (this._window) {
489
+ this._window.start();
490
+ this.listen(this._scroll, 'scroll', () => this._window.update(), { passive: true });
491
+ }
452
492
  this.listen(this._tbody, 'click', (event) => this._handleBodyClick(event));
453
493
  this.listen(this._tbody, 'dblclick', (event) => this._handleBodyDoubleClick(event));
454
494
  if (this.options.rowReorder) {
@@ -688,7 +728,8 @@ export class Table extends Component {
688
728
  const column = this._columns.find((candidate) => candidate.id === String(id));
689
729
  const index = this.getColumnOrder().indexOf(String(id));
690
730
  if (column && index >= 0) {
691
- this._columnStatus.textContent = `Moved ${tableColumnName(column)} to position ${index + 1} of ${this._columns.length}.`;
731
+ this._columnStatus.textContent = this._message('table.columnMoved', 'Moved %1 to position %2 of %3.',
732
+ [tableColumnName(column), index + 1, this._columns.length]);
692
733
  }
693
734
  }
694
735
  return this;
@@ -762,7 +803,8 @@ export class Table extends Component {
762
803
  if (this._rowMoveMessage) {
763
804
  const siblings = this._siblingIds(id);
764
805
  const index = siblings.findIndex((candidate) => Object.is(candidate, id));
765
- this._rowMoveMessage.textContent = `Moved row to position ${index + 1} of ${siblings.length}.`;
806
+ this._rowMoveMessage.textContent = this._message('table.rowMoved', 'Moved row to position %1 of %2.',
807
+ [index + 1, siblings.length]);
766
808
  }
767
809
  this._emitDataChange();
768
810
  queueMicrotask(() => this._rowHandle(id)?.focus());
@@ -1014,7 +1056,7 @@ export class Table extends Component {
1014
1056
  const index = this._data.findIndex((candidate) => Object.is(this._idFor(candidate), rowId));
1015
1057
  if (index < 0) return this;
1016
1058
  const row = this._data[index];
1017
- const tr = this._rowElements.get(rowId)?.[0];
1059
+ const tr = this._rowById(rowId);
1018
1060
  if (!tr) return this;
1019
1061
  const targets = this._editMode === 'row'
1020
1062
  ? this._visibleColumns().filter((candidate) => resolveEditable(candidate, row) !== false)
@@ -1179,9 +1221,87 @@ export class Table extends Component {
1179
1221
  * @returns {number}
1180
1222
  */
1181
1223
  getRenderedCount() {
1224
+ if (this._window) return this._window.drawn.size;
1182
1225
  return Math.min(this._rendered, this._projectedData().length);
1183
1226
  }
1184
1227
 
1228
+ /**
1229
+ * Scrolls a row into view. A windowed table draws it first, so a row that is not in the DOM can
1230
+ * be reached by id; rows outside the data, in a collapsed branch, or held back by `growing` cannot.
1231
+ * @param {unknown} id Row id.
1232
+ * @returns {boolean} Whether the row is in view now.
1233
+ */
1234
+ reveal(id) {
1235
+ if (this._window) return Boolean(this._rowById(id, true));
1236
+ const tr = this._rowElements.get(id)?.[0];
1237
+ tr?.scrollIntoView({ block: 'nearest' });
1238
+ return Boolean(tr);
1239
+ }
1240
+
1241
+ /**
1242
+ * The element of a row, drawing it first when a windowed table has not.
1243
+ * @param {unknown} id Row id.
1244
+ * @param {boolean} [scroll=false] Whether a row that is already drawn is scrolled into view too.
1245
+ * @returns {HTMLTableRowElement|undefined}
1246
+ */
1247
+ _rowById(id, scroll = false) {
1248
+ const drawn = this._rowElements.get(id)?.[0];
1249
+ if (!this._window || drawn && !scroll) return drawn;
1250
+ const position = this._hierarchyMeta?.get(id)?.visibleIndex;
1251
+ if (position === undefined) return undefined;
1252
+ return /** @type {HTMLTableRowElement|undefined} */ (this._window.reveal(position) ?? undefined);
1253
+ }
1254
+
1255
+ /**
1256
+ * Rows a windowed table keeps drawn wherever the scroll position is: the one holding the Tab stop,
1257
+ * which is the first row until something takes it, the one being edited, and the one being
1258
+ * dragged, whose removal would end the drag.
1259
+ * @returns {Array<number|undefined>} Row positions.
1260
+ */
1261
+ _windowPins() {
1262
+ const position = (id) => this._hierarchyMeta?.get(id)?.visibleIndex;
1263
+ return [
1264
+ this._currentPosition(),
1265
+ this._edit ? position(this._edit.id) : undefined,
1266
+ this._dragId == null ? undefined : position(this._dragId)
1267
+ ];
1268
+ }
1269
+
1270
+ /**
1271
+ * Where the row holding the Tab stop is in a windowed table. A row a collapsed branch hides hands
1272
+ * over to its nearest visible ancestor, and a row that is gone to whichever row took its place.
1273
+ * @returns {number} Row position.
1274
+ */
1275
+ _currentPosition() {
1276
+ if (!this._current) return 0;
1277
+ const meta = this._hierarchyMeta;
1278
+ const position = meta?.get(this._current.id)?.visibleIndex;
1279
+ if (position !== undefined) return position;
1280
+ const seen = new Set();
1281
+ let row = this._hierarchy ? this.getRow(this._current.id) : null;
1282
+ while (row) {
1283
+ const parentId = readRowValue(this._hierarchy.parentId, row);
1284
+ if (parentId == null || seen.has(parentId)) break;
1285
+ seen.add(parentId);
1286
+ const ancestor = meta?.get(parentId)?.visibleIndex;
1287
+ if (ancestor !== undefined) return ancestor;
1288
+ row = this.getRow(parentId);
1289
+ }
1290
+ return Math.min(Math.max(this._current.visibleIndex ?? 0, 0), Math.max(0, this._window.total - 1));
1291
+ }
1292
+
1293
+ /**
1294
+ * Forgets a row the window removed from the DOM.
1295
+ * @param {HTMLElement} tr Removed row.
1296
+ * @returns {void}
1297
+ */
1298
+ _releaseRow(tr) {
1299
+ const id = this._rowMeta.get(tr)?.id;
1300
+ const others = this._rowElements.get(id)?.filter((element) => element !== tr);
1301
+ if (others?.length) this._rowElements.set(id, others);
1302
+ else this._rowElements.delete(id);
1303
+ }
1304
+
1185
1305
  /**
1186
1306
  * Keeps the "show more" control in step with what is rendered.
1187
1307
  *
@@ -1255,6 +1375,8 @@ export class Table extends Component {
1255
1375
  this._stacked = stacked;
1256
1376
  this.el.toggleAttribute('data-stacked', stacked);
1257
1377
  this._applyStackedRoles(stacked);
1378
+ // A card is taller than a row, and no size the window watches changes when a table stacks.
1379
+ this._window?.schedule();
1258
1380
  this.emit('stackedchange', { stacked });
1259
1381
  }
1260
1382
 
@@ -1337,6 +1459,7 @@ export class Table extends Component {
1337
1459
  /** Restores an enhanced target and releases all component listeners. @returns {void} */
1338
1460
  destroy() {
1339
1461
  this._teardownEdit();
1462
+ this._window?.stop();
1340
1463
  this._width?.destroy();
1341
1464
  this._width = null;
1342
1465
  if (!this._restored && !this._createdRoot) {
@@ -1436,12 +1559,12 @@ export class Table extends Component {
1436
1559
  },
1437
1560
  h('button', {
1438
1561
  class: 'zx-table__column-move', type: 'button', disabled: index === 0,
1439
- ariaLabel: `Move ${name} earlier`,
1562
+ ariaLabel: this._message('table.moveColumnEarlier', 'Move %1 earlier', [name]),
1440
1563
  dataset: { columnId: column.id, columnAction: 'up' }
1441
1564
  }, icon('chevron-up', { size: ICON_SIZE.chevron })),
1442
1565
  h('button', {
1443
1566
  class: 'zx-table__column-move', type: 'button', disabled: index === this._columns.length - 1,
1444
- ariaLabel: `Move ${name} later`,
1567
+ ariaLabel: this._message('table.moveColumnLater', 'Move %1 later', [name]),
1445
1568
  dataset: { columnId: column.id, columnAction: 'down' }
1446
1569
  }, icon('chevron-down', { size: ICON_SIZE.chevron }))) : null;
1447
1570
  return h('div', { class: 'zx-table__column-option', dataset: { columnId: column.id } }, label, order);
@@ -1578,7 +1701,8 @@ export class Table extends Component {
1578
1701
  // message would make a successful drop look like a red editing error on editable grids.
1579
1702
  const status = this._rowMoveMessage ?? this._editMessage;
1580
1703
  if (status) status.textContent = this._grabbedId == null
1581
- ? 'Row dropped' : 'Row grabbed. Use the arrow keys to move it.';
1704
+ ? this._message('table.rowDropped', 'Row dropped', [])
1705
+ : this._message('table.rowGrabbed', 'Row grabbed. Use the arrow keys to move it.', []);
1582
1706
  return;
1583
1707
  }
1584
1708
  if (event.key === 'Escape' && this._grabbedId != null) {
@@ -1648,7 +1772,9 @@ export class Table extends Component {
1648
1772
  const columns = this._visibleColumns();
1649
1773
  const fractions = columns.map((column) => parseFraction(column.width));
1650
1774
  const total = fractions.reduce((sum, value) => sum + value, 0);
1651
- this._table.dataset.layout = total > 0 ? 'fixed' : 'auto';
1775
+ // A windowed table cannot size a column by content that is mostly not drawn: the widths would
1776
+ // move under the reader on every scroll.
1777
+ this._table.dataset.layout = total > 0 || this._virtual ? 'fixed' : 'auto';
1652
1778
  columns.forEach((column, index) => {
1653
1779
  const col = h('col');
1654
1780
  if (fractions[index] > 0) col.style.width = `${fractions[index] / total * 100}%`;
@@ -1661,9 +1787,9 @@ export class Table extends Component {
1661
1787
  /** @returns {void} */
1662
1788
  _renderHeader() {
1663
1789
  const row = h('tr', { class: 'zx-table__header-row' });
1664
- if (this._growStep) row.setAttribute('aria-rowindex', '1');
1790
+ if (this._indexed) row.setAttribute('aria-rowindex', '1');
1665
1791
  if (this.options.rowReorder) row.append(h('th', {
1666
- class: 'zx-table__reorder-header', scope: 'col', ariaLabel: 'Row order'
1792
+ class: 'zx-table__reorder-header', scope: 'col', ariaLabel: this._message('table.rowOrder', 'Row order', [])
1667
1793
  }));
1668
1794
  if (this.options.selectable === 'multi') {
1669
1795
  this._selectAll = h('input', {
@@ -1767,9 +1893,13 @@ export class Table extends Component {
1767
1893
  const projected = this._projectedData();
1768
1894
  this._hierarchyMeta = new Map(projected.map((entry) => [entry.id, entry]));
1769
1895
  if (this._data.length === 0) {
1896
+ this._window?.clear();
1770
1897
  fragment.append(h('tr', { class: 'zx-table__empty-row' },
1771
1898
  h('td', { class: 'zx-table__empty', colspan: this._spanColspan() }, this._emptyContent())
1772
1899
  ));
1900
+ } else if (this._window) {
1901
+ projected.forEach((entry, visibleIndex) => { entry.visibleIndex = visibleIndex; });
1902
+ this._window.fill(projected, fragment);
1773
1903
  } else {
1774
1904
  // Indices stay absolute: a row's index is its place in the data, not in what is on screen.
1775
1905
  this._visibleEntries().forEach((entry, visibleIndex) => {
@@ -1780,13 +1910,14 @@ export class Table extends Component {
1780
1910
  this._table.setAttribute('aria-colcount', String(this._visibleColumns().length
1781
1911
  + (this.options.selectable === 'multi' ? 1 : 0) + (this.options.rowReorder ? 1 : 0)));
1782
1912
  /*
1783
- * With `growing` on, the DOM holds a prefix of the data — so without this a screen reader
1784
- * announces "row 3 of 10" for a table of ten thousand. The header counts as a row.
1913
+ * With `growing` or `virtual` on, the DOM holds part of the data — so without this a screen
1914
+ * reader announces "row 3 of 10" for a table of ten thousand. The header counts as a row.
1785
1915
  */
1786
- if (this._growStep) this._table.setAttribute('aria-rowcount', String(projected.length + 1));
1916
+ if (this._indexed) this._table.setAttribute('aria-rowcount', String(projected.length + 1));
1787
1917
  this._syncSelectAll();
1788
1918
  this._syncGrowing();
1789
1919
  if (this._stacked) this._applyStackedRoles(true);
1920
+ this._window?.settle();
1790
1921
  this._syncRoving(focus);
1791
1922
  }
1792
1923
 
@@ -1814,8 +1945,9 @@ export class Table extends Component {
1814
1945
  _createRow(row, index, tree) {
1815
1946
  const id = this._idFor(row);
1816
1947
  const tr = /** @type {HTMLTableRowElement} */ (h('tr', { dataset: { row: '' } }));
1817
- // Only a prefix is in the DOM while growing, so each visible row states where it really is.
1818
- if (this._growStep) tr.setAttribute('aria-rowindex', String(tree.visibleIndex + 2));
1948
+ // Only part of the rows is in the DOM, so each drawn row states where it really is.
1949
+ if (this._indexed) tr.setAttribute('aria-rowindex', String(tree.visibleIndex + 2));
1950
+ if (this._virtual && tree.visibleIndex % 2 === 1) tr.dataset.stripe = '';
1819
1951
  const rowClass = typeof this.options.rowClass === 'function' ? this.options.rowClass(row) : '';
1820
1952
  if (rowClass) tr.classList.add(...String(rowClass).split(/\s+/).filter(Boolean));
1821
1953
  const kind = this._rowKind === null ? null : resolveRowKind(row, this._rowKind);
@@ -1866,7 +1998,8 @@ export class Table extends Component {
1866
1998
  dataset: { rowHandle: '' },
1867
1999
  ariaPressed: String(Object.is(this._grabbedId, id)),
1868
2000
  disabled: Boolean(this._sort && this.options.sortMode === 'local'),
1869
- title: this._sort && this.options.sortMode === 'local' ? 'Clear sorting to reorder rows' : null
2001
+ title: this._sort && this.options.sortMode === 'local'
2002
+ ? this._message('table.reorderBlocked', 'Clear sorting to reorder rows', []) : null
1870
2003
  }, icon('drag', { size: 14 }));
1871
2004
  tr.append(h('td', { class: 'zx-table__reorder-cell' }, handle));
1872
2005
  }
@@ -2188,7 +2321,7 @@ export class Table extends Component {
2188
2321
  ...props,
2189
2322
  class: textarea ? 'zx-table__editor-input zx-table__editor-textarea' : 'zx-table__editor-input',
2190
2323
  ...(textarea ? {} : { type: 'text' }),
2191
- ariaLabel: props.ariaLabel ?? `${tableColumnName(column)} row ${index + 1}`,
2324
+ ariaLabel: props.ariaLabel ?? this._message('table.cellInput', '%1 row %2', [tableColumnName(column), index + 1]),
2192
2325
  value: formatCellValue(column, value, row)
2193
2326
  }));
2194
2327
  host.append(input);
@@ -2220,7 +2353,7 @@ export class Table extends Component {
2220
2353
  * @returns {void}
2221
2354
  */
2222
2355
  _focusCell(id, columnId) {
2223
- const tr = this._rowElements.get(id)?.[0];
2356
+ const tr = this._rowById(id);
2224
2357
  const td = tr ? cellIn(tr, columnId) : null;
2225
2358
  td?.focus();
2226
2359
  }
@@ -2500,7 +2633,8 @@ export class Table extends Component {
2500
2633
  }
2501
2634
  }
2502
2635
  if (!tr) {
2503
- tr = rows[Math.min(Math.max(this._current?.visibleIndex ?? 0, 0), rows.length - 1)];
2636
+ tr = this._window ? this._window.drawn.get(this._currentPosition())
2637
+ : rows[Math.min(Math.max(this._current?.visibleIndex ?? 0, 0), rows.length - 1)];
2504
2638
  if (this._current) {
2505
2639
  const meta = this._rowMeta.get(tr);
2506
2640
  this._current = { ...this._current, id: meta.id, visibleIndex: meta.visibleIndex };
@@ -2656,16 +2790,21 @@ export class Table extends Component {
2656
2790
  }
2657
2791
 
2658
2792
  const rows = this._navRows();
2659
- const rowIndex = rows.indexOf(tr);
2793
+ const rowIndex = this._window ? meta.visibleIndex : rows.indexOf(tr);
2660
2794
  const byCell = cellMode && !onRow;
2661
2795
  const column = onCell ? cells.indexOf(/** @type {HTMLTableCellElement} */ (target))
2662
2796
  : Math.max(0, cells.indexOf(/** @type {HTMLTableCellElement} */ (this._cellFor(tr))));
2663
2797
  const next = tableGridTarget({ row: rowIndex, column }, key, {
2664
- rows: rows.length, columns: byCell ? cells.length : 1, page: this._pageSize(rows), ctrl: mod, cells: byCell
2798
+ rows: this._window?.total ?? rows.length,
2799
+ columns: byCell ? cells.length : 1,
2800
+ page: this._pageSize(rows),
2801
+ ctrl: mod,
2802
+ cells: byCell
2665
2803
  });
2666
2804
  if (!next) return;
2667
2805
  event.preventDefault();
2668
- const targetRow = rows[next.row];
2806
+ const targetRow = /** @type {HTMLTableRowElement} */ (this._window
2807
+ ? this._window.reveal(next.row) : rows[next.row]);
2669
2808
  if (!byCell) {
2670
2809
  targetRow.focus();
2671
2810
  } else if (next.row === rowIndex || key === 'Home' || key === 'End') {
@@ -2685,7 +2824,7 @@ export class Table extends Component {
2685
2824
  * Carries out one treegrid arrow-key action on a row.
2686
2825
  * @param {{action: string, column?: number}} action What `treegridArrowAction()` decided.
2687
2826
  * @param {HTMLTableRowElement} tr Focused row.
2688
- * @param {{id: unknown}} meta Row metadata.
2827
+ * @param {{id: unknown, visibleIndex?: number}} meta Row metadata.
2689
2828
  * @param {unknown} parentId Parent row id, or null at the root.
2690
2829
  * @returns {void}
2691
2830
  * @fires Table#rowtoggle
@@ -2693,10 +2832,10 @@ export class Table extends Component {
2693
2832
  _applyTreeAction(action, tr, meta, parentId) {
2694
2833
  if (action.action === 'expand') this.expandRow(meta.id);
2695
2834
  else if (action.action === 'collapse') this.collapseRow(meta.id);
2696
- else if (action.action === 'parent') this._rowElements.get(parentId)?.[0]?.focus();
2835
+ else if (action.action === 'parent') this._rowById(parentId)?.focus();
2697
2836
  else if (action.action === 'child') {
2698
2837
  const rows = this._navRows();
2699
- rows[rows.indexOf(tr) + 1]?.focus();
2838
+ (this._window ? this._window.reveal(meta.visibleIndex + 1) : rows[rows.indexOf(tr) + 1])?.focus();
2700
2839
  } else if (action.action === 'row') tr.focus();
2701
2840
  else if (action.action === 'cell') this._navCells(tr)[action.column ?? 0]?.focus();
2702
2841
  }