@ember-lattice/ember 1.0.0 → 1.1.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.
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import Component from '@glimmer/component';
2
2
  import { tracked, cached } from '@glimmer/tracking';
3
- import { warn } from '@ember/debug';
3
+ import { assert, warn } from '@ember/debug';
4
4
  import { getOwner } from '@ember/owner';
5
- import { fn, hash } from '@ember/helper';
5
+ import { hash, fn } from '@ember/helper';
6
6
  import { guidFor } from '@ember/object/internals';
7
7
  import { on } from '@ember/modifier';
8
8
  import { renderSettled } from '@ember/renderer';
@@ -12,10 +12,11 @@ import { modifier } from 'ember-modifier';
12
12
  import is from '@sindresorhus/is';
13
13
  import { ScaledScroll, VirtualizerState, sizerSize, bindScaledInput, VirtualScroll, defaultRangeExtractor } from '@ember-lattice/virtual';
14
14
  import { g, i, n } from 'decorator-transforms/runtime';
15
- import { latticeLocale, applyFlexWidths, autoSizeColumns } from '@ember-lattice/core';
15
+ import { createSortedRowModel, emberReactivityBindings, sortFns, rowSortingFeature, rowSelectionFeature, columnVisibilityFeature, columnSizingFeature, columnResizingFeature, columnPinningFeature, columnOrderingFeature, tableFeatures, constructTable, latticeLocale, applyFlexWidths, autoSizeColumns } from '@ember-lattice/core';
16
+ import { Checkbox } from '@ember-joinery/primitives';
16
17
  import { precompileTemplate } from '@ember/template-compilation';
17
18
  import { setComponentTemplate } from '@ember/component';
18
- import { Checkbox } from '@ember-joinery/primitives';
19
+ import templateOnly from '@ember/component/template-only';
19
20
  import { registerDestructor } from '@ember/destroyable';
20
21
  import { Typeahead, isTypeaheadKey, getNextMatch } from '@ember-joinery/primitives/typeahead';
21
22
  import { isRTL } from '@ember-joinery/primitives/direction';
@@ -73,7 +74,7 @@ function tsvRowCount(text) {
73
74
  return text === '' ? 0 : rows;
74
75
  }
75
76
 
76
- // The APG grid keys that move the active cell (docs/m2-grid-contract.md, section 3).
77
+ // The APG grid keys that move the active cell (docs/prd/2026-12-01-m2-grid-contract/index.html, section 3).
77
78
 
78
79
  /** A cell position, as 1-based `aria-rowindex` and `aria-colindex`. */
79
80
 
@@ -135,6 +136,25 @@ class GridStateHandle {
135
136
  grid = null;
136
137
  pending = {};
137
138
  listeners = new Set();
139
+ tableListeners = new Set();
140
+
141
+ /**
142
+ * The table of the grid, after the grid renders. Null before. With `@data`, the grid makes the
143
+ * table, so actions and `persistGridState(host)` get it here (ADR 0028).
144
+ */
145
+ get table() {
146
+ return this.grid?.engineTable ?? null;
147
+ }
148
+
149
+ /**
150
+ * Calls `listener` with the table when a grid attaches: after its first render, before the
151
+ * first paint. With a grid that is attached, it calls it now. Returns a function that stops it.
152
+ */
153
+ onTable(listener) {
154
+ if (this.grid) listener(this.grid.engineTable);
155
+ this.tableListeners.add(listener);
156
+ return () => void this.tableListeners.delete(listener);
157
+ }
138
158
 
139
159
  /** Before the grid renders, this is the state that waits for it. */
140
160
  read() {
@@ -188,6 +208,7 @@ class GridStateHandle {
188
208
  const pending = this.pending;
189
209
  this.pending = {};
190
210
  if (Object.keys(pending).length > 0) grid.applyState(pending);
211
+ for (const listener of this.tableListeners) listener(grid.engineTable);
191
212
  return () => {
192
213
  if (this.grid !== grid) return;
193
214
  // A grid that renders again with this handle gets the last state back.
@@ -274,7 +295,702 @@ function autoColumns(rows, options = {}) {
274
295
  });
275
296
  }
276
297
 
277
- // LatticeGrid: the Grid surface (docs/m2-grid-contract.md). Rows recycle in slots, full cells
298
+ // The declarations of one grid (ADR 0028). Glimmer has no context, so the grid yields its
299
+ // declarations (`<g.Column>`, `<g.ColumnGroup>`) curried with a registry, and each declaration
300
+ // adds itself in its constructor. The grid renders its declarations block before
301
+ // `div.lt-grid-root`, and reads the registry after the block, so the first render has the
302
+ // headers (ADR 0026).
303
+ //
304
+ // Glimmer's development build forbids a change of tracked state that the same render has
305
+ // already read. A registration sets `revision`, so nothing may read `items` earlier in a render
306
+ // than the block that registers: not in the first render, and not in a later one, where a
307
+ // declaration that the block adds inside an `{{#if}}` registers while the render revalidates
308
+ // the template in order. A registration never reads what it writes: the list is a plain array.
309
+ /**
310
+ * Template order. In the first render, the constructor order is the template order. A
311
+ * declaration that an `{{#if}}` adds later registers last, so the order comes from the markers:
312
+ * the comment node that each declaration renders where it stands in the template.
313
+ */
314
+ const byMarker = (a, b) => {
315
+ const position = a.marker.compareDocumentPosition(b.marker);
316
+ if (position & Node.DOCUMENT_POSITION_DISCONNECTED) return 0;
317
+ if (position & Node.DOCUMENT_POSITION_FOLLOWING) return -1;
318
+ if (position & Node.DOCUMENT_POSITION_PRECEDING) return 1;
319
+ return 0;
320
+ };
321
+ class ColumnRegistry {
322
+ #items = [];
323
+ #counter = 0;
324
+ #ordered = [];
325
+ #orderedAt = -1;
326
+ static {
327
+ g(this.prototype, "revision", [tracked], function () {
328
+ return 0;
329
+ });
330
+ }
331
+ #revision = (i(this, "revision"), void 0);
332
+ /** The declarations, in template order. */
333
+ get items() {
334
+ const revision = this.revision;
335
+ if (revision !== this.#orderedAt) {
336
+ this.#ordered = [...this.#items].sort(byMarker);
337
+ this.#orderedAt = revision;
338
+ }
339
+ return this.#ordered;
340
+ }
341
+ add(item) {
342
+ this.#items = [...this.#items, item];
343
+ this.revision = ++this.#counter;
344
+ }
345
+ remove(item) {
346
+ if (!this.#items.includes(item)) return;
347
+ this.#items = this.#items.filter(other => other !== item);
348
+ this.revision = ++this.#counter;
349
+ }
350
+ }
351
+
352
+ // The column def of a `<g.Column>` declaration (ADR 0028). The args map one to one to the
353
+ // options of a column def of `@ember-lattice/core`, so the template form and the engine form make
354
+ // the same table. A pure function: no Ember import.
355
+
356
+ /** A column def that the grid gives to `constructTable`. A structural type, as `GridTable`. */
357
+
358
+ /**
359
+ * The args of `<g.Column>`. Each arg maps to one option of the column def. The interface is open:
360
+ * `@ember-lattice/editing` and `@ember-lattice/ui` add their args to it (declaration merging),
361
+ * and `columnDefOf` puts them in the `meta` key of their package.
362
+ */
363
+
364
+ /**
365
+ * The key of a data row, for `@field`. With no row type (`unknown`, or `never` inside the grid),
366
+ * any text.
367
+ */
368
+
369
+ /**
370
+ * The args of `<g.Column>` for the rows of type `T`: `@field` is a key of `T`, and `@value` takes a
371
+ * `T`. `LatticeGrid` infers `T` from `@data`, so Glint checks a field name.
372
+ */
373
+
374
+ /** The named blocks of a declaration. */
375
+
376
+ const NO_BLOCKS = {
377
+ cell: false,
378
+ header: false,
379
+ headerEnd: false
380
+ };
381
+
382
+ /** The keys of `meta.lattice` that have an arg of the same name. */
383
+ const LATTICE_KEYS = ['format', 'align', 'tooltip', 'editMode', 'editTrigger', 'rowDrag', 'cellDescription', 'cellInvalid', 'cell', 'headerLabel'];
384
+
385
+ /**
386
+ * The args of other packages, by their `meta` key. The packages declare the types of the args
387
+ * (declaration merging). The grid does not import them: it copies each arg that the app gives.
388
+ */
389
+ const PACKAGE_KEYS = [
390
+ // @ember-lattice/editing
391
+ ['lattice', ['editor', 'editable', 'schema', 'parse', 'options', 'search', 'optionComponent']],
392
+ // @ember-lattice/ui
393
+ ['latticeUi', ['filter', 'onRename']]];
394
+
395
+ /** The column def options that have an arg with another name. */
396
+ const OPTIONS = [['size', 'size'], ['minSize', 'minSize'], ['maxSize', 'maxSize'], ['flex', 'flex'], ['sortFn', 'sortFn'], ['hideable', 'enableHiding'], ['pinnable', 'enablePinning'], ['filterFn', 'filterFn'], ['filterable', 'enableColumnFilter'], ['groupable', 'enableGrouping'], ['aggregate', 'aggregationFn']];
397
+
398
+ /** The column def of one `<g.Column>`. An arg that the app does not give is not in the def. */
399
+ function columnDefOf(args, blocks) {
400
+ const def = {
401
+ ...args.columnDef,
402
+ id: args.id,
403
+ header: args.label
404
+ };
405
+ if (args.value) def.accessorFn = args.value;else def.accessorKey = args.field ?? args.id;
406
+ // In the template form, sort and resize are opt-in: the app asks for them on the column.
407
+ def.enableSorting = args.sortable ?? false;
408
+ def.enableResizing = args.resizable ?? false;
409
+ for (const [arg, option] of OPTIONS) {
410
+ if (args[arg] !== undefined) def[option] = args[arg];
411
+ }
412
+ const lattice = {};
413
+ for (const key of LATTICE_KEYS) {
414
+ if (args[key] !== undefined) Object.assign(lattice, {
415
+ [key]: args[key]
416
+ });
417
+ }
418
+ if (args.headerEnd) lattice.header = args.headerEnd;
419
+ if (args.cellKind) lattice.cellKind = args.cellKind;
420
+ if (blocks.cell) lattice.cellBlock = true;
421
+ if (blocks.header) lattice.headerBlock = true;
422
+ if (blocks.headerEnd) lattice.headerEndBlock = true;
423
+ if (blocks.editor) lattice.editorBlock = true;
424
+ const own = args.columnDef?.['meta'] ?? {};
425
+ const meta = {
426
+ ...own,
427
+ ...args.meta
428
+ };
429
+ if (args.type) meta['columnType'] = args.type;
430
+ const extra = {
431
+ lattice: lattice
432
+ };
433
+ const open = args;
434
+ for (const [key, names] of PACKAGE_KEYS) {
435
+ for (const name of names) {
436
+ if (open[name] !== undefined) (extra[key] ??= {})[name] = open[name];
437
+ }
438
+ }
439
+ for (const [key, values] of Object.entries(extra)) {
440
+ const merged = {
441
+ ...own[key],
442
+ ...values
443
+ };
444
+ if (Object.keys(merged).length > 0) meta[key] = merged;
445
+ }
446
+ if (Object.keys(meta).length > 0) def.meta = meta;
447
+ return def;
448
+ }
449
+
450
+ /** The initial pinning and visibility of the declarations (`@pinned`, `@hidden`). */
451
+ function initialStateOf(args) {
452
+ const start = args.filter(a => a.pinned === 'start').map(a => a.id);
453
+ const end = args.filter(a => a.pinned === 'end').map(a => a.id);
454
+ const hidden = args.filter(a => a.hidden === true);
455
+ const state = {};
456
+ if (start.length > 0 || end.length > 0) state['columnPinning'] = {
457
+ start,
458
+ end
459
+ };
460
+ if (hidden.length > 0) state['columnVisibility'] = Object.fromEntries(hidden.map(a => [a.id, false]));
461
+ return state;
462
+ }
463
+
464
+ /** The IDs that two or more declarations have. */
465
+ function duplicateIds(args) {
466
+ const seen = new Set();
467
+ const twice = new Set();
468
+ for (const {
469
+ id
470
+ } of args) {
471
+ if (seen.has(id)) twice.add(id);
472
+ seen.add(id);
473
+ }
474
+ return [...twice];
475
+ }
476
+
477
+ /** The args that need an engine feature that is not in the default set of the grid. */
478
+ const NEEDS = [['groupable', 'columnGroupingFeature'], ['filterable', 'columnFilteringFeature'], ['filterFn', 'columnFilteringFeature'], ['aggregate', 'rowAggregationFeature']];
479
+
480
+ /** A column arg whose engine feature the table does not have. */
481
+
482
+ /**
483
+ * The args of the declarations that need a feature that is not in `features` (the keys of the
484
+ * table features). With no feature, the engine ignores the option, so the grid warns.
485
+ */
486
+ function missingFeatures(args, features) {
487
+ const has = new Set(features);
488
+ return args.flatMap(column => NEEDS.filter(([arg, feature]) => {
489
+ const value = column[arg];
490
+ return value !== undefined && value !== false && !has.has(feature);
491
+ }).map(([arg, feature]) => ({
492
+ id: column.id,
493
+ arg,
494
+ feature
495
+ })));
496
+ }
497
+
498
+ // The table of a grid in the template form (ADR 0028). With `@data`, the grid makes and owns the
499
+ // table. Its options `data`, `columns` and `state` are live: each read gives the current value of
500
+ // the grid args and of the declarations. So a tracked change needs no `setOptions` call, and the
501
+ // grid never writes table state during render (M2 contract, section 1).
502
+ /**
503
+ * The features of a template-form grid with no `@features` (DEC-4 of the template form PRD):
504
+ * sizing, resizing, sorting, visibility, ordering, pinning and row selection. `@features` adds
505
+ * more, for example grouping or filtering, with their row models.
506
+ */
507
+ const DEFAULT_GRID_FEATURES = {
508
+ coreReactivityFeature: emberReactivityBindings(),
509
+ columnOrderingFeature,
510
+ columnPinningFeature,
511
+ columnResizingFeature,
512
+ columnSizingFeature,
513
+ columnVisibilityFeature,
514
+ rowSelectionFeature,
515
+ rowSortingFeature,
516
+ sortedRowModel: createSortedRowModel(),
517
+ sortFns
518
+ };
519
+
520
+ /** The table state, by slice. */
521
+
522
+ const apply = (updater, old) => is.function(updater) ? updater(old) : updater;
523
+ const capital = key => key.charAt(0).toUpperCase() + key.slice(1);
524
+
525
+ /** Makes the live options: `data`, `columns` and `state` read the source on each read. */
526
+ function makeLive(options, source) {
527
+ Object.defineProperties(options, {
528
+ data: {
529
+ configurable: true,
530
+ enumerable: true,
531
+ get: () => source.data()
532
+ },
533
+ columns: {
534
+ configurable: true,
535
+ enumerable: true,
536
+ get: () => source.columns()
537
+ },
538
+ state: {
539
+ configurable: true,
540
+ enumerable: true,
541
+ get: () => source.state()
542
+ }
543
+ });
544
+ }
545
+ function makeOwnedTable(source) {
546
+ const features = tableFeatures({
547
+ ...DEFAULT_GRID_FEATURES,
548
+ ...source.features
549
+ });
550
+ const table = constructTable({
551
+ ...source.options,
552
+ features,
553
+ data: [],
554
+ columns: [],
555
+ initialState: source.initialState,
556
+ ...(source.getRowId && {
557
+ getRowId: source.getRowId
558
+ })
559
+ });
560
+ const internal = table;
561
+ makeLive(internal.options, source);
562
+
563
+ // `setOptions` makes a new options object: the new one gets the live options too.
564
+ const setOptions = internal.setOptions.bind(table);
565
+ internal.setOptions = updater => {
566
+ setOptions(updater);
567
+ makeLive(internal.options, source);
568
+ };
569
+
570
+ // `@onStateChange` gets the whole state after each change of a slice.
571
+ const keys = Object.keys(internal.initialState);
572
+ const snapshot = () => Object.fromEntries(keys.map(key => [key, internal.atoms[key]?.get()]));
573
+ for (const key of keys) {
574
+ const name = `on${capital(key)}Change`;
575
+ const own = internal.options[name];
576
+ if (typeof own !== 'function') continue;
577
+ internal.options[name] = updater => {
578
+ const next = apply(updater, internal.atoms[key]?.get());
579
+ own(updater);
580
+ source.onStateChange()?.({
581
+ ...snapshot(),
582
+ [key]: next
583
+ });
584
+ };
585
+ }
586
+ return table;
587
+ }
588
+
589
+ // Small caches for the getters of the grid. A getter that makes a value at its first read calls
590
+ // a method of one of these, so the getter writes nothing on the component.
591
+
592
+ /** A value that the first read makes. */
593
+ class Once {
594
+ #made = false;
595
+ #value;
596
+ get(make) {
597
+ if (!this.#made) {
598
+ this.#value = make();
599
+ this.#made = true;
600
+ }
601
+ return this.#value;
602
+ }
603
+ }
604
+
605
+ /** The same value while the key is the same: the memos of the table then hold. */
606
+ class SameForKey {
607
+ #key;
608
+ #value;
609
+ get(key, value) {
610
+ if (key !== this.#key) {
611
+ this.#key = key;
612
+ this.#value = value;
613
+ }
614
+ return this.#value;
615
+ }
616
+ }
617
+
618
+ /**
619
+ * The value that `make` gives for a key. A new key makes the value again. `release` gets the old
620
+ * value when a new key replaces it, and at `clear`.
621
+ */
622
+ class ForRef {
623
+ #made = false;
624
+ #key;
625
+ #value;
626
+ #release;
627
+ constructor(release) {
628
+ this.#release = release;
629
+ }
630
+ get(key, make) {
631
+ if (!this.#made || key !== this.#key) {
632
+ if (this.#made) this.#release?.(this.#value);
633
+ this.#key = key;
634
+ this.#value = make();
635
+ this.#made = true;
636
+ }
637
+ return this.#value;
638
+ }
639
+
640
+ /** Releases the value, if there is one. The next `get` makes a new value. */
641
+ clear() {
642
+ if (this.#made) this.#release?.(this.#value);
643
+ this.#made = false;
644
+ this.#key = undefined;
645
+ this.#value = undefined;
646
+ }
647
+ }
648
+
649
+ /**
650
+ * The anchor elements of the `<:cell>` blocks, by key. The block content of a cell renders into
651
+ * its anchor. An anchor has no box: the content is the content of the cell.
652
+ */
653
+ class Anchors {
654
+ #anchors = new Map();
655
+ get(key) {
656
+ let anchor = this.#anchors.get(key);
657
+ if (!anchor) {
658
+ anchor = document.createElement('span');
659
+ anchor.className = 'lt-cell-block';
660
+ anchor.style.display = 'contents';
661
+ this.#anchors.set(key, anchor);
662
+ }
663
+ return anchor;
664
+ }
665
+
666
+ /** Keeps only the anchors of these keys. */
667
+ keep(keys) {
668
+ for (const key of this.#anchors.keys()) if (!keys.has(key)) this.#anchors.delete(key);
669
+ }
670
+ }
671
+
672
+ // The row selection column: a Joinery `Checkbox` in each row.
673
+ class SelectCell extends Component {
674
+ get checked() {
675
+ return this.args.row.getIsSelected?.() ?? false;
676
+ }
677
+ get disabled() {
678
+ return this.args.row.getCanSelect?.() === false;
679
+ }
680
+ /** A grid slot has a fixed signature, so it reads only the owner text (ADR 0024). */
681
+ get label() {
682
+ return latticeLocale(getOwner(this)).t('grid.selectRow');
683
+ }
684
+ onChange = checked => this.args.row.toggleSelected?.(checked === true);
685
+ /** The cell is the tab stop: after a click, give it the focus, so the arrow keys work. */
686
+ focusCell = event => {
687
+ if (!(event.currentTarget instanceof Element)) return;
688
+ const cell = event.currentTarget.closest('[role="gridcell"]');
689
+ if (cell instanceof HTMLElement) cell.focus();
690
+ };
691
+ static {
692
+ setComponentTemplate(precompileTemplate("{{!-- The cell is the tab stop: the checkbox is not. --}}\n<Checkbox class=\"lt-select\" @checked={{this.checked}} @disabled={{this.disabled}} @onCheckedChange={{this.onChange}} aria-label={{this.label}} tabindex=\"-1\" {{on \"click\" this.focusCell}} as |c|>\n <c.Indicator>\u2713</c.Indicator>\n</Checkbox>", {
693
+ strictMode: true,
694
+ scope: () => ({
695
+ Checkbox,
696
+ on
697
+ })
698
+ }), this);
699
+ }
700
+ }
701
+ /** The column def of the selection column. */
702
+
703
+ /**
704
+ * A column def for row selection. Put it in the `columns` of the table. The table needs the
705
+ * `rowSelectionFeature`.
706
+ * The default header is the locale text of `locale` (`latticeLocale(owner)`), or English.
707
+ */
708
+ function selectionColumn(options = {}) {
709
+ return {
710
+ id: '__lattice_select',
711
+ header: options.header ?? (options.locale ?? latticeLocale(undefined)).t('grid.selectedHeader'),
712
+ size: options.size ?? 40,
713
+ enableSorting: false,
714
+ enableResizing: false,
715
+ // The checkbox has no local state: it reads the row, so it can reuse a row slot.
716
+ meta: {
717
+ lattice: {
718
+ cell: SelectCell,
719
+ cellKind: 'cheap',
720
+ align: 'center'
721
+ }
722
+ }
723
+ };
724
+ }
725
+
726
+ // The row number column: the display position of each row, pinned at the inline start.
727
+
728
+ /** The column def of the row number column. */
729
+
730
+ /**
731
+ * A column def for row numbers. Put it in the `columns` of the table. The grid pins it at the
732
+ * inline start and shows the 1-based display position of each row (ADR 0018).
733
+ * The default header is the locale text of `locale` (`latticeLocale(owner)`), or English.
734
+ */
735
+ function rowNumberColumn(options = {}) {
736
+ return {
737
+ id: '__lattice_row_number',
738
+ header: options.header ?? (options.locale ?? latticeLocale(undefined)).t('grid.rowNumberHeader'),
739
+ size: options.size ?? 56,
740
+ enableSorting: false,
741
+ enableResizing: false,
742
+ meta: {
743
+ lattice: {
744
+ rowNumber: true,
745
+ cellKind: 'cheap',
746
+ align: 'end'
747
+ }
748
+ }
749
+ };
750
+ }
751
+
752
+ // The declarations of the template form (ADR 0028): `<g.Column>`, `<g.ColumnGroup>`,
753
+ // `<g.SelectionColumn>` and `<g.RowNumberColumn>`. A declaration renders no element.
754
+ //
755
+ // The grid yields its declarations block in three modes, with the same names:
756
+ // - declare: before `div.lt-grid-root`. Each declaration adds itself to the registry, and
757
+ // renders one comment node that gives its place in the template.
758
+ // - portal: one time, after `div.lt-grid-root`. Glimmer cannot give a block to another component
759
+ // as a value, so the declaration of a column with a `<:cell>` block renders the block into the
760
+ // anchor element of each rendered cell of its column, with `in-element` (spike FW-1).
761
+ // - part: in the header cell of a column with a `<:header>` or `<:headerEnd>` block, and in the
762
+ // overlay for the editor of a column with an `<:editor>` block.
763
+ const eq$1 = (a, b) => a === b;
764
+ /** The part decides the type of the context: the grid gives the context of the part. */
765
+ const asHeader = ctx => ctx;
766
+ const asEditor = ctx => ctx;
767
+ /** Inside the grid, a data row has the row type of the app: Glint checks it at the call site. */
768
+ const anyRow = row => row;
769
+ /** A comment node: the place of a declaration in the template. */
770
+ const marker = () => document.createComment('');
771
+ // Declare mode ------------------------------------------------------------------------------
772
+
773
+ class ColumnDeclaration extends Component {
774
+ marker = marker();
775
+ children = null;
776
+ /** Plain fields: the template sets them before the grid reads `columnDef`. */
777
+ blocks = NO_BLOCKS;
778
+ constructor(owner, args) {
779
+ super(owner, args);
780
+ args.registry.add(this);
781
+ }
782
+ willDestroy() {
783
+ super.willDestroy();
784
+ this.args.registry.remove(this);
785
+ }
786
+ get columnArgs() {
787
+ return this.args;
788
+ }
789
+ /** The blocks are fixed for one invocation, so the first render sets them once. */
790
+ noteBlocks = (cell, header, headerEnd, editor) => {
791
+ this.blocks = {
792
+ cell,
793
+ header,
794
+ headerEnd,
795
+ editor
796
+ };
797
+ };
798
+ get columnDef() {
799
+ return columnDefOf(this.columnArgs, this.blocks);
800
+ }
801
+ static {
802
+ n(this.prototype, "columnDef", [cached]);
803
+ }
804
+ static {
805
+ setComponentTemplate(precompileTemplate("{{~this.marker~}}\n{{~this.noteBlocks (has-block \"cell\") (has-block \"header\") (has-block \"headerEnd\") (has-block \"editor\")~}}", {
806
+ strictMode: true
807
+ }), this);
808
+ }
809
+ }
810
+ class ColumnGroupDeclaration extends Component {
811
+ marker = marker();
812
+ children = new ColumnRegistry();
813
+ columnArgs = null;
814
+ constructor(owner, args) {
815
+ super(owner, args);
816
+ args.registry.add(this);
817
+ }
818
+ willDestroy() {
819
+ super.willDestroy();
820
+ this.args.registry.remove(this);
821
+ }
822
+ get columnDef() {
823
+ return {
824
+ id: this.args.id,
825
+ header: this.args.label,
826
+ columns: this.children.items.map(child => child.columnDef)
827
+ };
828
+ }
829
+ static {
830
+ n(this.prototype, "columnDef", [cached]);
831
+ }
832
+ static {
833
+ setComponentTemplate(precompileTemplate("{{~this.marker~}}\n{{~yield (hash Column=(component ColumnDeclaration registry=this.children) ColumnGroup=(component ColumnGroupDeclaration registry=this.children locale=@locale) SelectionColumn=(component SelectionColumnDeclaration registry=this.children locale=@locale) RowNumberColumn=(component RowNumberColumnDeclaration registry=this.children locale=@locale))~}}", {
834
+ strictMode: true,
835
+ scope: () => ({
836
+ hash,
837
+ ColumnDeclaration,
838
+ ColumnGroupDeclaration,
839
+ SelectionColumnDeclaration,
840
+ RowNumberColumnDeclaration
841
+ })
842
+ }), this);
843
+ }
844
+ }
845
+ class BuiltInDeclaration extends Component {
846
+ marker = marker();
847
+ children = null;
848
+ /** The args for the initial state: `@pinned` and `@hidden`. */
849
+ get columnArgs() {
850
+ const {
851
+ pinned,
852
+ hidden
853
+ } = this.args;
854
+ return {
855
+ id: this.columnDef.id,
856
+ label: this.args.label ?? '',
857
+ ...(pinned && {
858
+ pinned
859
+ }),
860
+ ...(hidden && {
861
+ hidden
862
+ })
863
+ };
864
+ }
865
+ constructor(owner, args) {
866
+ super(owner, args);
867
+ args.registry.add(this);
868
+ }
869
+ willDestroy() {
870
+ super.willDestroy();
871
+ this.args.registry.remove(this);
872
+ }
873
+ get options() {
874
+ return {
875
+ header: this.args.label,
876
+ size: this.args.size,
877
+ locale: this.args.locale ?? latticeLocale(undefined)
878
+ };
879
+ }
880
+ get columnDef() {
881
+ return {};
882
+ }
883
+ static {
884
+ setComponentTemplate(precompileTemplate("{{~this.marker~}}", {
885
+ strictMode: true
886
+ }), this);
887
+ }
888
+ }
889
+ class SelectionColumnDeclaration extends BuiltInDeclaration {
890
+ get columnDef() {
891
+ return selectionColumn(this.options);
892
+ }
893
+ static {
894
+ n(this.prototype, "columnDef", [cached]);
895
+ }
896
+ }
897
+ class RowNumberColumnDeclaration extends BuiltInDeclaration {
898
+ get columnDef() {
899
+ return rowNumberColumn(this.options);
900
+ }
901
+ static {
902
+ n(this.prototype, "columnDef", [cached]);
903
+ }
904
+ }
905
+ /** The declarations of declare mode, curried with a registry. */
906
+
907
+ /** Yields the declarations of declare mode. */const DeclareMode$1 = setComponentTemplate(precompileTemplate("{{~yield (hash Column=(component ColumnDeclaration registry=@registry) ColumnGroup=(component ColumnGroupDeclaration registry=@registry locale=@locale) SelectionColumn=(component SelectionColumnDeclaration registry=@registry locale=@locale) RowNumberColumn=(component RowNumberColumnDeclaration registry=@registry locale=@locale))~}}", {
908
+ strictMode: true,
909
+ scope: () => ({
910
+ hash,
911
+ ColumnDeclaration,
912
+ ColumnGroupDeclaration,
913
+ SelectionColumnDeclaration,
914
+ RowNumberColumnDeclaration
915
+ })
916
+ }), templateOnly());
917
+ // Portal mode and part mode ----------------------------------------------------------------
918
+ /** A declaration that renders nothing: the built-in columns in portal mode and part mode. */
919
+ const Nothing$1 = setComponentTemplate(precompileTemplate("", {
920
+ strictMode: true
921
+ }), templateOnly());
922
+ /** A cell of a column with a `<:cell>` block: the block renders into `anchor`. */
923
+
924
+ /** What portal mode reads from the grid. */
925
+
926
+ const PortalColumn = setComponentTemplate(precompileTemplate("{{~#if (has-block \"cell\")~}}\n {{~#each (@host.blockCellsOf @id) key=\"key\" as |t|~}}\n {{~#in-element t.anchor insertBefore=null~}}\n {{~yield (hash text=(@host.textFor t.row t.column) value=(@host.valueFor t.row t.column) data=(anyRow t.row.original) row=t.row column=t.column cell=(@host.cellFor t.row t.column) state=(@host.stateFor t.row.id t.column)) to=\"cell\"~}}\n {{~/in-element~}}\n {{~/each~}}\n{{~/if~}}", {
927
+ strictMode: true,
928
+ scope: () => ({
929
+ hash,
930
+ anyRow
931
+ })
932
+ }), templateOnly());
933
+ const PortalGroup = setComponentTemplate(precompileTemplate("{{~yield (hash Column=(component PortalColumn host=@host) ColumnGroup=(component PortalGroup host=@host) SelectionColumn=Nothing RowNumberColumn=Nothing)~}}", {
934
+ strictMode: true,
935
+ scope: () => ({
936
+ hash,
937
+ PortalColumn,
938
+ PortalGroup,
939
+ Nothing: Nothing$1
940
+ })
941
+ }), templateOnly());
942
+ /**
943
+ * Yields the declarations of portal mode: each column with a `<:cell>` block renders the block
944
+ * into the anchor of each of its rendered cells.
945
+ */
946
+ const PortalMode = setComponentTemplate(precompileTemplate("{{~yield (hash Column=(component PortalColumn host=@host) ColumnGroup=(component PortalGroup host=@host) SelectionColumn=Nothing RowNumberColumn=Nothing)~}}", {
947
+ strictMode: true,
948
+ scope: () => ({
949
+ hash,
950
+ PortalColumn,
951
+ PortalGroup,
952
+ Nothing: Nothing$1
953
+ })
954
+ }), templateOnly());
955
+ const PartColumn = setComponentTemplate(precompileTemplate("{{~#if (eq @id @target)~}}\n {{~#if (eq @part \"header\")~}}\n {{~yield (asHeader @ctx) to=\"header\"~}}\n {{~else if (eq @part \"headerEnd\")~}}\n {{~yield (asHeader @ctx) to=\"headerEnd\"~}}\n {{~else~}}\n {{~yield (asEditor @ctx) to=\"editor\"~}}\n {{~/if~}}\n{{~/if~}}", {
956
+ strictMode: true,
957
+ scope: () => ({
958
+ eq: eq$1,
959
+ asHeader,
960
+ asEditor
961
+ })
962
+ }), templateOnly());
963
+ const PartGroup = setComponentTemplate(precompileTemplate("{{~yield (hash Column=(component PartColumn target=@target part=@part ctx=@ctx) ColumnGroup=(component PartGroup target=@target part=@part ctx=@ctx) SelectionColumn=Nothing RowNumberColumn=Nothing)~}}", {
964
+ strictMode: true,
965
+ scope: () => ({
966
+ hash,
967
+ PartColumn,
968
+ PartGroup,
969
+ Nothing: Nothing$1
970
+ })
971
+ }), templateOnly());
972
+ /**
973
+ * Yields the declarations of part mode: only the column `@target` renders its `@part` block, the
974
+ * header, the header end or the editor.
975
+ */
976
+ const PartMode = setComponentTemplate(precompileTemplate("{{~yield (hash Column=(component PartColumn target=@target part=@part ctx=@ctx) ColumnGroup=(component PartGroup target=@target part=@part ctx=@ctx) SelectionColumn=Nothing RowNumberColumn=Nothing)~}}", {
977
+ strictMode: true,
978
+ scope: () => ({
979
+ hash,
980
+ PartColumn,
981
+ PartGroup,
982
+ Nothing: Nothing$1
983
+ })
984
+ }), templateOnly());
985
+ /** The column defs of a registry, and the args of its columns, in template order. */
986
+ function declaredColumns(registry) {
987
+ return registry.items.map(item => item.columnDef);
988
+ }
989
+ function declaredArgs(registry) {
990
+ return registry.items.flatMap(item => item.children ? declaredArgs(item.children) : item.columnArgs ? [item.columnArgs] : []);
991
+ }
992
+
993
+ // LatticeGrid: the Grid surface (docs/prd/2026-12-01-m2-grid-contract/index.html). Rows recycle in slots, full cells
278
994
  // are keyed by row ID, and the active row is held (ADR 0002). Pinned cells are sticky in one
279
995
  // scroll container (ADR 0004). Above the element height cap, the rows scroll scaled (ADR 0003).
280
996
  const DEFAULT_ROW_HEIGHT = 32;
@@ -380,10 +1096,24 @@ const colOptions = (sizes, startWidth, endWidth, rtl) => ({
380
1096
  scrollPaddingEnd: endWidth,
381
1097
  isRtl: rtl
382
1098
  });
1099
+ const or = (a, b) => Boolean(a) || Boolean(b);
1100
+ const NO_CELLS = [];
1101
+ /** The options of a table whose rows come from a `@rowModel`: the server does the work. */
1102
+ const MANUAL_OPTIONS = {
1103
+ manualSorting: true,
1104
+ manualFiltering: true,
1105
+ manualGrouping: true,
1106
+ manualPagination: true
1107
+ };
1108
+ /** The data of an owned table with no `@data` (a `@rowModel` function): one array, so the memos hold. */
1109
+ const NO_DATA = Object.freeze([]);
1110
+ /** The template form: the column has an `<:editor>` block. */
1111
+ const editorBlockOf = column => column.columnDef.meta?.lattice?.editorBlock === true;
383
1112
  /** A full cell is keyed by row ID (ADR 0002): a new component for each new row. */
384
1113
  const isFull = column => {
385
1114
  const lattice = column.columnDef.meta?.lattice;
386
- return lattice?.cell !== undefined && lattice.cellKind !== 'cheap';
1115
+ const custom = lattice?.cell !== undefined || lattice?.cellBlock === true;
1116
+ return custom && lattice?.cellKind !== 'cheap';
387
1117
  };
388
1118
  /** The fields of a center column outside the range. */
389
1119
  const HIDDEN = {
@@ -392,7 +1122,10 @@ const HIDDEN = {
392
1122
  pin: false,
393
1123
  style: htmlSafe(''),
394
1124
  component: null,
1125
+ block: false,
395
1126
  full: false,
1127
+ headerBlock: false,
1128
+ headerEndBlock: false,
396
1129
  headerSlot: null,
397
1130
  headerLabel: null,
398
1131
  rowNumber: false,
@@ -459,7 +1192,7 @@ class LatticeRow extends Component {
459
1192
  toggleDetail = () => this.args.grid.toggleDetail(this.args.view.row);
460
1193
  toggle = () => this.args.grid.toggleGroup(this.args.view.index);
461
1194
  static {
462
- setComponentTemplate(precompileTemplate("<div class=\"lt-row\" role=\"row\" aria-rowindex={{this.ariaRow}} aria-selected={{selectedOf @view.row}} aria-level={{@view.level}} aria-expanded={{@view.expanded}} data-row-id={{@view.id}} data-lt-slot={{@slot}} data-held={{if @view.held \"\"}} data-sticky={{if @view.sticky \"\"}} data-row-pinned={{@view.pinned}} data-index={{@view.index}} style={{@view.style}} {{@grid.measureRow @view.index @grid.measured}}>\n {{#if @view.fullWidth}}\n <div class=\"lt-cell lt-full-width-cell\" role=\"gridcell\" aria-colindex=\"1\" aria-colspan={{@grid.colCount}} tabindex={{@grid.rowTabIndex this.ariaRow}} style={{@grid.fullWidthStyle}}>\n {{#let @grid.fullWidthComponent as |FullWidth|}}\n {{#if FullWidth}}<FullWidth @row={{@view.row}} />{{/if}}\n {{/let}}\n </div>\n {{else}}\n {{#each @grid.layout.slots key=\"key\" as |slot|}}\n {{#if slot.rendered}}\n {{#if slot.gap}}\n <div class=\"lt-spacer\" aria-hidden=\"true\" style={{slot.gap}}></div>\n {{/if}}\n {{#let (@grid.spanOf @view.row slot) as |merge|}}\n {{#if merge.covered}}\n {{#if merge.spacer}}\n <div class=\"lt-spacer\" aria-hidden=\"true\" style={{merge.spacer}}></div>\n {{/if}}\n {{else}}\n <div class=\"lt-cell\" role={{if slot.rowNumber \"rowheader\" \"gridcell\"}} aria-colindex={{slot.aria}} aria-rowspan={{merge.rowSpan}} aria-colspan={{merge.colSpan}} aria-selected={{@grid.cellSelected @view.index slot.aria}} data-range-edge={{@grid.rangeEdge @view.index slot.aria}} data-column-id={{slot.column.id}} data-pinned={{isPinned slot.pin}} data-dirty={{if (@grid.isDirty @view.row slot.column) \"\"}} data-find-match={{@grid.findMatch @view.row slot.column}} data-note={{if (@grid.hasNote @view.row slot.column) \"\"}} aria-describedby={{@grid.describedBy @view.index slot @view.row}} aria-invalid={{@grid.invalidFor @view.row slot}} tabindex={{@grid.tabIndexFor this.ariaRow slot.aria}} style={{if merge merge.style slot.style}}>\n {{#if (this.groupCell slot.aria)}}\n <button type=\"button\" class=\"lt-group-toggle\" tabindex=\"-1\" aria-label={{if @view.group.expanded (@grid.l.t \"grid.collapse\") (@grid.l.t \"grid.expand\")}} {{on \"click\" this.toggle}}></button>\n <span class=\"lt-group-label\">{{@view.group.label}}</span>\n {{else}}\n {{#if (this.detailCell slot.aria)}}\n <button type=\"button\" class=\"lt-group-toggle lt-detail-toggle\" tabindex=\"-1\" aria-label={{@grid.l.t \"grid.details\"}} aria-expanded={{if (@grid.isDetailOpen @view.row) \"true\" \"false\"}} {{on \"click\" this.toggleDetail}}></button>\n {{/if}}\n {{#if slot.rowDrag}}\n <span class=\"lt-row-drag-handle\" aria-hidden=\"true\" {{on \"pointerdown\" (fn @grid.onRowDragStart @view.row @view.index)}}></span>\n {{/if}}\n {{#if (this.treeCell slot.aria)}}\n <button type=\"button\" class=\"lt-group-toggle\" tabindex=\"-1\" aria-label={{if (isOpen @view.expanded) (@grid.l.t \"grid.collapse\") (@grid.l.t \"grid.expand\")}} {{on \"click\" this.toggle}}></button>\n {{/if}}\n {{#if slot.rowNumber}}\n {{rowNumberOf @view.index}}\n {{else if slot.component}}\n {{#if slot.full}}\n {{#each (keyed @view.id) key=\"@identity\"}}\n <slot.component @cell={{cellOf @view.row slot.column}} @row={{@view.row}} @column={{slot.column}} @value={{@grid.valueFor @view.row slot.column}} @state={{@grid.stateFor @view.id slot.column}} />\n {{/each}}\n {{else}}\n <slot.component @cell={{cellOf @view.row slot.column}} @row={{@view.row}} @column={{slot.column}} @value={{@grid.valueFor @view.row slot.column}} @state={{@grid.stateFor @view.id slot.column}} />\n {{/if}}\n {{else}}\n {{@grid.textFor @view.row slot.column}}\n {{/if}}\n {{/if}}\n {{#if (@grid.isFillCorner @view.index slot.aria)}}\n <div class=\"lt-fill-handle\" aria-hidden=\"true\" {{on \"pointerdown\" @grid.onFillStart}}></div>\n {{/if}}\n </div>\n {{/if}}\n {{/let}}\n {{/if}}\n {{/each}}\n {{#if @grid.layout.tail}}\n <div class=\"lt-spacer\" aria-hidden=\"true\" style={{@grid.layout.tail}}></div>\n {{/if}}\n {{/if}}\n</div>", {
1195
+ setComponentTemplate(precompileTemplate("<div class=\"lt-row\" role=\"row\" aria-rowindex={{this.ariaRow}} aria-selected={{selectedOf @view.row}} aria-level={{@view.level}} aria-expanded={{@view.expanded}} data-row-id={{@view.id}} data-lt-slot={{@slot}} data-held={{if @view.held \"\"}} data-sticky={{if @view.sticky \"\"}} data-row-pinned={{@view.pinned}} data-index={{@view.index}} data-measured={{if @grid.measured \"\"}} style={{@view.style}} {{@grid.measureRow @view.index @grid.measured}}>\n {{#if @view.fullWidth}}\n <div class=\"lt-cell lt-full-width-cell\" role=\"gridcell\" aria-colindex=\"1\" aria-colspan={{@grid.colCount}} tabindex={{@grid.rowTabIndex this.ariaRow}} style={{@grid.fullWidthStyle}}>\n {{#let @grid.fullWidthComponent as |FullWidth|}}\n {{#if FullWidth}}<FullWidth @row={{@view.row}} />{{/if}}\n {{/let}}\n </div>\n {{else}}\n {{#each @grid.layout.slots key=\"key\" as |slot|}}\n {{#if slot.rendered}}\n {{#if slot.gap}}\n <div class=\"lt-spacer\" aria-hidden=\"true\" style={{slot.gap}}></div>\n {{/if}}\n {{#let (@grid.spanOf @view.row slot) as |merge|}}\n {{#if merge.covered}}\n {{#if merge.spacer}}\n <div class=\"lt-spacer\" aria-hidden=\"true\" style={{merge.spacer}}></div>\n {{/if}}\n {{else}}\n <div class=\"lt-cell\" role={{if slot.rowNumber \"rowheader\" \"gridcell\"}} aria-colindex={{slot.aria}} aria-rowspan={{merge.rowSpan}} aria-colspan={{merge.colSpan}} aria-selected={{@grid.cellSelected @view.index slot.aria}} data-range-edge={{@grid.rangeEdge @view.index slot.aria}} data-column-id={{slot.column.id}} data-pinned={{isPinned slot.pin}} data-dirty={{if (@grid.isDirty @view.row slot.column) \"\"}} data-find-match={{@grid.findMatch @view.row slot.column}} data-note={{if (@grid.hasNote @view.row slot.column) \"\"}} aria-describedby={{@grid.describedBy @view.index slot @view.row}} aria-invalid={{@grid.invalidFor @view.row slot}} tabindex={{@grid.tabIndexFor this.ariaRow slot.aria}} style={{if merge merge.style slot.style}}>\n {{#if (this.groupCell slot.aria)}}\n <button type=\"button\" class=\"lt-group-toggle\" tabindex=\"-1\" aria-label={{if @view.group.expanded (@grid.l.t \"grid.collapse\") (@grid.l.t \"grid.expand\")}} {{on \"click\" this.toggle}}></button>\n <span class=\"lt-group-label\">{{@view.group.label}}</span>\n {{else}}\n {{#if (this.detailCell slot.aria)}}\n <button type=\"button\" class=\"lt-group-toggle lt-detail-toggle\" tabindex=\"-1\" aria-label={{@grid.l.t \"grid.details\"}} aria-expanded={{if (@grid.isDetailOpen @view.row) \"true\" \"false\"}} {{on \"click\" this.toggleDetail}}></button>\n {{/if}}\n {{#if slot.rowDrag}}\n <span class=\"lt-row-drag-handle\" aria-hidden=\"true\" {{on \"pointerdown\" (fn @grid.onRowDragStart @view.row @view.index)}}></span>\n {{/if}}\n {{#if (this.treeCell slot.aria)}}\n <button type=\"button\" class=\"lt-group-toggle\" tabindex=\"-1\" aria-label={{if (isOpen @view.expanded) (@grid.l.t \"grid.collapse\") (@grid.l.t \"grid.expand\")}} {{on \"click\" this.toggle}}></button>\n {{/if}}\n {{#if slot.rowNumber}}\n {{rowNumberOf @view.index}}\n {{else if slot.block}}\n {{!-- The template form: the <:cell> block of the column renders into the anchor. --}}\n {{@grid.anchorFor @slot slot}}\n {{else if slot.component}}\n {{#if slot.full}}\n {{#each (keyed @view.id) key=\"@identity\"}}\n <slot.component @cell={{cellOf @view.row slot.column}} @row={{@view.row}} @column={{slot.column}} @value={{@grid.valueFor @view.row slot.column}} @state={{@grid.stateFor @view.id slot.column}} />\n {{/each}}\n {{else}}\n <slot.component @cell={{cellOf @view.row slot.column}} @row={{@view.row}} @column={{slot.column}} @value={{@grid.valueFor @view.row slot.column}} @state={{@grid.stateFor @view.id slot.column}} />\n {{/if}}\n {{else}}\n {{@grid.textFor @view.row slot.column}}\n {{/if}}\n {{/if}}\n {{#if (@grid.isFillCorner @view.index slot.aria)}}\n <div class=\"lt-fill-handle\" aria-hidden=\"true\" {{on \"pointerdown\" @grid.onFillStart}}></div>\n {{/if}}\n </div>\n {{/if}}\n {{/let}}\n {{/if}}\n {{/each}}\n {{#if @grid.layout.tail}}\n <div class=\"lt-spacer\" aria-hidden=\"true\" style={{@grid.layout.tail}}></div>\n {{/if}}\n {{/if}}\n</div>", {
463
1196
  strictMode: true,
464
1197
  scope: () => ({
465
1198
  selectedOf,
@@ -480,7 +1213,7 @@ class DetailRow extends Component {
480
1213
  return this.args.grid.headerRowCount + this.args.view.index + 1;
481
1214
  }
482
1215
  static {
483
- setComponentTemplate(precompileTemplate("<div class=\"lt-row lt-detail-row\" role=\"row\" aria-rowindex={{this.ariaRow}} data-row-id={{@view.id}} data-lt-slot={{@slot}} data-index={{@view.index}} data-held={{if @view.held \"\"}} style={{@view.style}} {{@grid.measureRow @view.index @grid.measured}}>\n <div class=\"lt-cell lt-full-width-cell\" role=\"gridcell\" aria-colindex=\"1\" aria-colspan={{@grid.colCount}} tabindex={{@grid.rowTabIndex this.ariaRow}} style={{@grid.fullWidthStyle}}>\n {{#let @grid.detailComponent as |Detail|}}\n {{#if Detail}}<Detail @row={{@view.master}} />{{/if}}\n {{/let}}\n </div>\n</div>", {
1216
+ setComponentTemplate(precompileTemplate("<div class=\"lt-row lt-detail-row\" role=\"row\" aria-rowindex={{this.ariaRow}} data-row-id={{@view.id}} data-lt-slot={{@slot}} data-index={{@view.index}} data-held={{if @view.held \"\"}} data-measured={{if @grid.measured \"\"}} style={{@view.style}} {{@grid.measureRow @view.index @grid.measured}}>\n <div class=\"lt-cell lt-full-width-cell\" role=\"gridcell\" aria-colindex=\"1\" aria-colspan={{@grid.colCount}} tabindex={{@grid.rowTabIndex this.ariaRow}} style={{@grid.fullWidthStyle}}>\n {{#let @grid.detailComponent as |Detail|}}\n {{#if Detail}}<Detail @row={{@view.master}} />{{/if}}\n {{/let}}\n </div>\n</div>", {
484
1217
  strictMode: true
485
1218
  }), this);
486
1219
  }
@@ -491,7 +1224,7 @@ class SkeletonRow extends Component {
491
1224
  return this.args.grid.headerRowCount + this.args.view.index + 1;
492
1225
  }
493
1226
  static {
494
- setComponentTemplate(precompileTemplate("<div class=\"lt-row\" role=\"row\" aria-rowindex={{this.ariaRow}} aria-busy={{if @view.failed undefined \"true\"}} aria-level={{@view.level}} data-failed={{if @view.failed \"\"}} data-lt-slot={{@slot}} data-held={{if @view.held \"\"}} style={{@view.style}}>\n {{#each @grid.layout.slots key=\"key\" as |slot|}}\n {{#if slot.rendered}}\n {{#if slot.gap}}\n <div class=\"lt-spacer\" aria-hidden=\"true\" style={{slot.gap}}></div>\n {{/if}}\n <div class=\"lt-cell\" role=\"gridcell\" aria-colindex={{slot.aria}} data-column-id={{slot.column.id}} data-pinned={{isPinned slot.pin}} data-loading tabindex={{@grid.tabIndexFor this.ariaRow slot.aria}} style={{slot.style}}></div>\n {{/if}}\n {{/each}}\n {{#if @grid.layout.tail}}\n <div class=\"lt-spacer\" aria-hidden=\"true\" style={{@grid.layout.tail}}></div>\n {{/if}}\n</div>", {
1227
+ setComponentTemplate(precompileTemplate("<div class=\"lt-row\" role=\"row\" aria-rowindex={{this.ariaRow}} aria-busy={{if @view.failed undefined \"true\"}} aria-level={{@view.level}} data-failed={{if @view.failed \"\"}} data-lt-slot={{@slot}} data-held={{if @view.held \"\"}} data-measured={{if @grid.measured \"\"}} style={{@view.style}}>\n {{#each @grid.layout.slots key=\"key\" as |slot|}}\n {{#if slot.rendered}}\n {{#if slot.gap}}\n <div class=\"lt-spacer\" aria-hidden=\"true\" style={{slot.gap}}></div>\n {{/if}}\n <div class=\"lt-cell\" role=\"gridcell\" aria-colindex={{slot.aria}} data-column-id={{slot.column.id}} data-pinned={{isPinned slot.pin}} data-loading tabindex={{@grid.tabIndexFor this.ariaRow slot.aria}} style={{slot.style}}></div>\n {{/if}}\n {{/each}}\n {{#if @grid.layout.tail}}\n <div class=\"lt-spacer\" aria-hidden=\"true\" style={{@grid.layout.tail}}></div>\n {{/if}}\n</div>", {
495
1228
  strictMode: true,
496
1229
  scope: () => ({
497
1230
  isPinned
@@ -542,18 +1275,205 @@ class LatticeGrid extends Component {
542
1275
  _element = null;
543
1276
  _scroller = null;
544
1277
  _suppressClick = false;
545
- rowState = new VirtualizerState({
546
- count: this.rowCount,
547
- estimateSize: () => this.rowHeight,
548
- overscan: this.args.overscan ?? DEFAULT_OVERSCAN$1,
549
- paddingStart: this.headerHeight,
550
- scrollPaddingStart: this.headerHeight,
551
- scrollScale: this.scale
552
- });
553
- colState = new VirtualizerState({
554
- ...colOptions(this.columns.centerSizes, this.columns.startWidth, this.columns.endWidth, false),
555
- initialRect: viewRect()
556
- });
1278
+ /**
1279
+ * The grid for its row components. The row type `T` is for Glint at the call site of the grid;
1280
+ * the rows of the grid do not read it.
1281
+ */
1282
+ get rowHost() {
1283
+ return this;
1284
+ }
1285
+ /** What the chrome blocks get: the table and the grid root. */
1286
+ get chromeApi() {
1287
+ return {
1288
+ table: this.engineTable,
1289
+ root: () => this._element?.closest('.lt-grid-root') ?? null
1290
+ };
1291
+ }
1292
+ /**
1293
+ * The table for the chrome blocks and the state handle. `@table` is a table from
1294
+ * `constructTable`, and the grid makes its own table with `constructTable`.
1295
+ */
1296
+ static {
1297
+ n(this.prototype, "chromeApi", [cached]);
1298
+ }
1299
+ get engineTable() {
1300
+ return this.table;
1301
+ }
1302
+ // The template form: the declarations of the block, and the table that the grid owns.
1303
+ registry = new ColumnRegistry();
1304
+ ownedTable = new Once();
1305
+ /**
1306
+ * The table: `@table`, or with `@data`, the table that the grid makes from its declarations. The
1307
+ * grid makes it at the first read, after its declarations block (ADR 0028).
1308
+ */
1309
+ get table() {
1310
+ const own = this.args.table;
1311
+ if (own) {
1312
+ assert('LatticeGrid: give @table or @data, not both', this.args.data === undefined);
1313
+ return own;
1314
+ }
1315
+ assert('LatticeGrid: give @table, @data, or a @rowModel function', this.args.data !== undefined || is.function(this.args.rowModel));
1316
+ return this.ownedTable.get(() => this.makeTable());
1317
+ }
1318
+ /**
1319
+ * The row model: `@rowModel`, or the model that the `@rowModel` function makes from the table.
1320
+ * The grid calls the function again only when it changes.
1321
+ */
1322
+ get rowModel() {
1323
+ const model = this.args.rowModel;
1324
+ if (!is.function(model)) return model;
1325
+ return this.builtModel.get(model, () => model(this.table));
1326
+ }
1327
+ // The grid owns a model that it made, so it disconnects it. The getter runs in a render, so the
1328
+ // disconnect runs after the render.
1329
+ builtModel = new ForRef(model => queueMicrotask(() => model.disconnect?.()));
1330
+ /**
1331
+ * The columns of the table that the grid owns: the declarations, then the columns that the row
1332
+ * model adds (the pivot columns of the server row model).
1333
+ */
1334
+ get ownedColumns() {
1335
+ const added = this.rowModel?.addedColumns ?? [];
1336
+ return added.length === 0 ? this.declaredColumns : [...this.declaredColumns, ...added];
1337
+ }
1338
+ /**
1339
+ * The column defs of the template form: the declarations, in template order, or with no
1340
+ * declarations, one column for each key of the first rows. The array is the same while the
1341
+ * declarations do not change, so the memos of the table hold.
1342
+ */
1343
+ static {
1344
+ n(this.prototype, "ownedColumns", [cached]);
1345
+ }
1346
+ get declaredColumns() {
1347
+ if (this.registry.items.length === 0) return this.autoColumns;
1348
+ const args = declaredArgs(this.registry);
1349
+ const ids = duplicateIds(args);
1350
+ assert(`LatticeGrid: two columns have the ID "${ids.join('", "')}"`, ids.length === 0);
1351
+ this.warnMissingFeatures(args);
1352
+ return declaredColumns(this.registry);
1353
+ }
1354
+ static {
1355
+ n(this.prototype, "declaredColumns", [cached]);
1356
+ }
1357
+ warnedFeatures = new Set();
1358
+ /**
1359
+ * In development, one warning for each column arg whose engine feature the grid does not have.
1360
+ * The engine ignores the option then. `warn` is a no-op in production builds.
1361
+ */
1362
+ warnMissingFeatures(args) {
1363
+ const features = Object.keys({
1364
+ ...DEFAULT_GRID_FEATURES,
1365
+ ...this.args.features
1366
+ });
1367
+ for (const {
1368
+ id,
1369
+ arg,
1370
+ feature
1371
+ } of missingFeatures(args, features)) {
1372
+ const key = `${id}\u0000${arg}`;
1373
+ if (this.warnedFeatures.has(key)) continue;
1374
+ this.warnedFeatures.add(key);
1375
+ warn(`LatticeGrid: the column "${id}" has @${arg}, and the grid has no ${feature}. ` + `Add ${feature} to @features, or the grid ignores @${arg}.`, false, {
1376
+ id: 'ember-lattice.missing-feature'
1377
+ });
1378
+ }
1379
+ }
1380
+ /** The auto columns change only when the keys of the first rows change. */
1381
+ get autoColumns() {
1382
+ const columns = autoColumns(this.args.data ?? NO_DATA);
1383
+ return this.autoMemo.get(columns.map(column => column.id).join('\u0000'), columns);
1384
+ }
1385
+ static {
1386
+ n(this.prototype, "autoColumns", [cached]);
1387
+ }
1388
+ autoMemo = new SameForKey();
1389
+ makeTable() {
1390
+ return makeOwnedTable({
1391
+ data: () => this.args.data ?? NO_DATA,
1392
+ columns: () => this.ownedColumns,
1393
+ state: () => this.args.state,
1394
+ features: this.args.features,
1395
+ // With a row model, the server sorts, filters, groups and pages the rows.
1396
+ options: {
1397
+ ...(this.args.rowModel && MANUAL_OPTIONS),
1398
+ ...this.args.tableOptions
1399
+ },
1400
+ initialState: {
1401
+ ...initialStateOf(declaredArgs(this.registry)),
1402
+ ...this.args.initialState
1403
+ },
1404
+ getRowId: this.args.getRowId,
1405
+ onStateChange: () => this.args.onStateChange
1406
+ });
1407
+ }
1408
+ // The cells of the `<:cell>` blocks (ADR 0028, ADR 0029). Each cell of a block column renders
1409
+ // the anchor element of its slot, and the declaration of the column renders its block into the
1410
+ // anchor with `in-element`. So a cell costs one block, not one render of all the declarations.
1411
+ // The anchor stays with the slot, so a scroll adds no element to style. The key of the block
1412
+ // decides when it renders again: a full cell keys it by the row ID in the slot, as a full cell
1413
+ // component is keyed; a cheap cell keys it by the slot, so its block stays.
1414
+ anchors = new Anchors();
1415
+ anchorKey(slot, cell) {
1416
+ return `${slot}\u0000${cell.key}`;
1417
+ }
1418
+ blockKey(view, slot, cell) {
1419
+ return cell.full ? `r\u0000${slot}\u0000${view.id}\u0000${cell.key}` : `s\u0000${slot}\u0000${cell.key}`;
1420
+ }
1421
+ /** The anchor of a block cell, in the cell element: one for each slot and column. */
1422
+ anchorFor = (slot, cell) => this.anchors.get(this.anchorKey(slot, cell));
1423
+ /** The block cells of the rendered rows, by column ID. */
1424
+ get blockCells() {
1425
+ const columns = this.layout.slots.filter(cell => cell.rendered && cell.block);
1426
+ const cells = new Map();
1427
+ const keys = new Set();
1428
+ this.slots.forEach((view, slot) => {
1429
+ const row = view ? asRowView(view) : undefined;
1430
+ if (!row || row.fullWidth) return;
1431
+ for (const cell of columns) {
1432
+ const anchorKey = this.anchorKey(slot, cell);
1433
+ const anchor = this.anchors.get(anchorKey);
1434
+ keys.add(anchorKey);
1435
+ const list = cells.get(cell.key) ?? [];
1436
+ list.push({
1437
+ key: this.blockKey(row, slot, cell),
1438
+ anchor,
1439
+ row: row.row,
1440
+ column: cell.column
1441
+ });
1442
+ cells.set(cell.key, list);
1443
+ }
1444
+ });
1445
+ // Only the anchors of rendered cells stay: the others go with their block content.
1446
+ this.anchors.keep(keys);
1447
+ return cells;
1448
+ }
1449
+ static {
1450
+ n(this.prototype, "blockCells", [cached]);
1451
+ }
1452
+ get hasBlockCells() {
1453
+ return this.layout.slots.some(cell => cell.block);
1454
+ }
1455
+ blockCellsOf = id => this.blockCells.get(id) ?? NO_CELLS;
1456
+ cellFor = (row, column) => cellOf(row, column);
1457
+ // The virtualizers read the columns and the rows, so the grid makes them at the first read
1458
+ // in the render: after the declarations block of the template form.
1459
+ lazyRowState = new Once();
1460
+ lazyColState = new Once();
1461
+ get rowState() {
1462
+ return this.lazyRowState.get(() => new VirtualizerState({
1463
+ count: this.rowCount,
1464
+ estimateSize: () => this.rowHeight,
1465
+ overscan: this.args.overscan ?? DEFAULT_OVERSCAN$1,
1466
+ paddingStart: this.headerHeight,
1467
+ scrollPaddingStart: this.headerHeight,
1468
+ scrollScale: this.scale
1469
+ }));
1470
+ }
1471
+ get colState() {
1472
+ return this.lazyColState.get(() => new VirtualizerState({
1473
+ ...colOptions(this.columns.centerSizes, this.columns.startWidth, this.columns.endWidth, false),
1474
+ initialRect: viewRect()
1475
+ }));
1476
+ }
557
1477
  /** The computed `--lt-row-height`, for the density presets when `@rowHeight` is not given. */
558
1478
  static {
559
1479
  g(this.prototype, "_cssRowHeight", [tracked], function () {
@@ -572,7 +1492,7 @@ class LatticeGrid extends Component {
572
1492
  if (next !== this._cssRowHeight) this._cssRowHeight = next;
573
1493
  }
574
1494
  get rows() {
575
- if (this.args.rowModel) return [];
1495
+ if (this.rowModel) return [];
576
1496
  const {
577
1497
  top,
578
1498
  center,
@@ -589,10 +1509,10 @@ class LatticeGrid extends Component {
589
1509
  n(this.prototype, "rows", [cached]);
590
1510
  }
591
1511
  get pinnedRows() {
592
- const table = this.args.table;
1512
+ const table = this.table;
593
1513
  const none = [];
594
- const top = this.args.rowModel ? none : table.getTopRows?.() ?? none;
595
- const bottom = this.args.rowModel ? none : table.getBottomRows?.() ?? none;
1514
+ const top = this.rowModel ? none : table.getTopRows?.() ?? none;
1515
+ const bottom = this.rowModel ? none : table.getBottomRows?.() ?? none;
596
1516
  const center = () => top.length + bottom.length > 0 && table.getCenterRows ? table.getCenterRows() : table.getRowModel().rows;
597
1517
  return {
598
1518
  top,
@@ -626,11 +1546,11 @@ class LatticeGrid extends Component {
626
1546
  }
627
1547
  /** The number of body rows: the rows of the row model, or of the table, and detail rows. */
628
1548
  get rowCount() {
629
- return this.args.rowModel?.displayCount ?? this.display.rows.length;
1549
+ return this.rowModel?.displayCount ?? this.display.rows.length;
630
1550
  }
631
1551
  /** The row at a 0-based index, or undefined when it is not loaded (or a detail row). */
632
1552
  rowAt(index) {
633
- const model = this.args.rowModel;
1553
+ const model = this.rowModel;
634
1554
  return model ? model.rowAt(index) : this.display.rows[index];
635
1555
  }
636
1556
  // Row drag (ADR 0018) -------------------------------------------------------------------------
@@ -694,7 +1614,7 @@ class LatticeGrid extends Component {
694
1614
  // Cell spanning (ADR 0018) ------------------------------------------------------------------
695
1615
  /** True when the table has the engine cell spanning feature (client rows only). */
696
1616
  get spanning() {
697
- return !this.args.rowModel && this.args.table.getCellSpanIndex !== undefined;
1617
+ return !this.rowModel && this.table.getCellSpanIndex !== undefined;
698
1618
  }
699
1619
  /**
700
1620
  * The span of a cell, or undefined for a cell of one row and one column. A cell that a cell
@@ -731,7 +1651,7 @@ class LatticeGrid extends Component {
731
1651
  spanAnchors(index) {
732
1652
  if (!this.spanning || index === undefined) return [];
733
1653
  const anchors = [];
734
- for (const spans of Object.values(this.args.table.getCellSpanIndex?.().rowSpans ?? {})) {
1654
+ for (const spans of Object.values(this.table.getCellSpanIndex?.().rowSpans ?? {})) {
735
1655
  let at = index;
736
1656
  while (at > 0 && spans[at] === 0) at--;
737
1657
  if (at !== index) anchors.push(at);
@@ -827,18 +1747,18 @@ class LatticeGrid extends Component {
827
1747
  return () => virtualizer.measureElement(null);
828
1748
  });
829
1749
  toggleGroup = index => {
830
- const model = this.args.rowModel;
1750
+ const model = this.rowModel;
831
1751
  if (model) model.toggleGroup?.(index);else this.rowAt(index)?.toggleExpanded?.();
832
1752
  };
833
1753
  /** True for a row that Enter opens and closes: a group row, or a tree row with sub rows. */
834
1754
  isToggleRow(index) {
835
- const model = this.args.rowModel;
1755
+ const model = this.rowModel;
836
1756
  if (model) return model.groupAt?.(index) !== undefined;
837
1757
  return this.rowAt(index)?.getCanExpand?.() ?? false;
838
1758
  }
839
1759
  /** Client rows have levels when the table has the engine expanding feature (ADR 0018). */
840
1760
  get clientTree() {
841
- return !this.args.rowModel && this.args.table.toggleAllRowsExpanded !== undefined;
1761
+ return !this.rowModel && this.table.toggleAllRowsExpanded !== undefined;
842
1762
  }
843
1763
  /** The group of a client group row: the label is the group value and the leaf row count. */
844
1764
  clientGroup(row, level) {
@@ -856,7 +1776,7 @@ class LatticeGrid extends Component {
856
1776
  };
857
1777
  }
858
1778
  get headerGroups() {
859
- return this.args.table.getHeaderGroups();
1779
+ return this.table.getHeaderGroups();
860
1780
  }
861
1781
  /** The header rows: the group rows, the leaf header row and the floating filter row. */
862
1782
  static {
@@ -873,7 +1793,7 @@ class LatticeGrid extends Component {
873
1793
  return this.headerRowCount * this.rowHeight;
874
1794
  }
875
1795
  get columns() {
876
- const table = this.args.table;
1796
+ const table = this.table;
877
1797
  const end = table.getEndVisibleLeafColumns?.() ?? [];
878
1798
  const allCenter = table.getCenterVisibleLeafColumns?.() ?? table.getVisibleLeafColumns?.() ?? table.getAllLeafColumns();
879
1799
  // The row number column is pinned at the start, before the pinned columns (ADR 0018).
@@ -935,7 +1855,11 @@ class LatticeGrid extends Component {
935
1855
  const active = this.activeCell;
936
1856
  return active.row === ariaRow && active.col === ariaCol ? 0 : -1;
937
1857
  };
938
- rowIdOf = row => this.args.getRowId?.(row) ?? row.id;
1858
+ rowIdOf = row => {
1859
+ // With `@data`, `@getRowId` is the table option: the table row ID is already its result.
1860
+ const id = this.args.data === undefined ? this.args.getRowId : undefined;
1861
+ return id?.(row) ?? row.id;
1862
+ };
939
1863
  valueFor = (row, column) => {
940
1864
  const pending = this.args.editing?.pendingValue(row.id, column.id);
941
1865
  return pending ? pending.value : row.getValue(column.id);
@@ -979,7 +1903,10 @@ class LatticeGrid extends Component {
979
1903
  size,
980
1904
  style: columnStyle(size, pin, inset, lattice?.align),
981
1905
  component,
1906
+ block: lattice?.cellBlock === true,
982
1907
  full: isFull(column),
1908
+ headerBlock: lattice?.headerBlock === true,
1909
+ headerEndBlock: lattice?.headerEndBlock === true,
983
1910
  headerSlot: lattice?.header ?? null,
984
1911
  headerLabel: lattice?.headerLabel ?? null,
985
1912
  rowNumber: lattice?.rowNumber === true,
@@ -1112,7 +2039,7 @@ class LatticeGrid extends Component {
1112
2039
  const measured = this.measured ? `; block-size: auto; min-block-size: ${px$2(this.rowHeight)}` : '';
1113
2040
  let style = htmlSafe(`transform: translateY(${px$2(top)}); inline-size: ${px$2(this.totalWidth)}${measured}`);
1114
2041
  const master = this.display.details.get(index);
1115
- if (master && !this.args.rowModel) {
2042
+ if (master && !this.rowModel) {
1116
2043
  const id = `detail:${this.rowIdOf(master)}`;
1117
2044
  return {
1118
2045
  row: undefined,
@@ -1123,7 +2050,7 @@ class LatticeGrid extends Component {
1123
2050
  style
1124
2051
  };
1125
2052
  }
1126
- const model = this.args.rowModel;
2053
+ const model = this.rowModel;
1127
2054
  const level = model?.tree ? model.levelAt?.(index) : undefined;
1128
2055
  const row = this.rowAt(index);
1129
2056
  if (!row) {
@@ -1291,7 +2218,7 @@ class LatticeGrid extends Component {
1291
2218
  setup = modifier(scroller => {
1292
2219
  this._scroller = scroller;
1293
2220
  this._element = scroller.parentElement;
1294
- if (this._element) GRIDS.set(this._element, this);
2221
+ if (this._element) GRIDS.set(this._element, this.rowHost);
1295
2222
  const unbind = bindScaledInput(scroller, this.scale);
1296
2223
  const grid = scroller.parentElement;
1297
2224
  const host = this.args.stateHost;
@@ -1486,7 +2413,7 @@ class LatticeGrid extends Component {
1486
2413
  return;
1487
2414
  }
1488
2415
  if (ctrl && event.key.toLowerCase() === 'a' && onCell) {
1489
- const table = this.args.table;
2416
+ const table = this.table;
1490
2417
  if (table.toggleAllRowsSelected && this.multiSelect) {
1491
2418
  event.preventDefault();
1492
2419
  table.toggleAllRowsSelected(true);
@@ -1622,7 +2549,7 @@ class LatticeGrid extends Component {
1622
2549
  }
1623
2550
  #liveMessage = (i(this, "liveMessage"), void 0);
1624
2551
  get countMessage() {
1625
- const count = this.args.rowModel ? this.args.rowModel.rowCount : this.rowCount;
2552
+ const count = this.rowModel ? this.rowModel.rowCount : this.rowCount;
1626
2553
  return count === null ? '' : this.l.plural('grid.rowCount', count);
1627
2554
  }
1628
2555
  announceSort(column) {
@@ -1732,11 +2659,11 @@ class LatticeGrid extends Component {
1732
2659
  // Ranges (the engine cell selection) ------------------------------------------------------
1733
2660
  /** True when the table has the cell selection feature: ranges of cells. */
1734
2661
  get cellSelectable() {
1735
- return this.args.table.getCellSelectionBounds !== undefined;
2662
+ return this.table.getCellSelectionBounds !== undefined;
1736
2663
  }
1737
2664
  /** Client rows use the engine ranges. With `@rowModel`, the grid owns one range. */
1738
2665
  get engineRanges() {
1739
- return this.cellSelectable && !this.args.rowModel;
2666
+ return this.cellSelectable && !this.rowModel;
1740
2667
  }
1741
2668
  /** The grid range with `@rowModel`: two corners as 0-based row and column indexes. */
1742
2669
  static {
@@ -1746,9 +2673,9 @@ class LatticeGrid extends Component {
1746
2673
  }
1747
2674
  #_range = (i(this, "_range"), void 0);
1748
2675
  /** The cell ranges, or the active cell as a range when there is no range. */get selection() {
1749
- const ranges = this.engineRanges ? this.args.table.getCellSelectionBounds?.() ?? [] : [];
2676
+ const ranges = this.engineRanges ? this.table.getCellSelectionBounds?.() ?? [] : [];
1750
2677
  if (ranges.length > 0) return [...ranges];
1751
- const own = this.args.rowModel ? this._range : null;
2678
+ const own = this.rowModel ? this._range : null;
1752
2679
  if (own) {
1753
2680
  const [r1, c1] = own.anchor;
1754
2681
  const [r2, c2] = own.focus;
@@ -1827,11 +2754,11 @@ class LatticeGrid extends Component {
1827
2754
  this._range = null;
1828
2755
  if (!this.engineRanges) return;
1829
2756
  const cell = this.cellRefAt(position.row - this.headerRowCount - 1, position.col - 1);
1830
- if (cell) this.args.table.setFocusedCell?.(cell.row.id, cell.column.id);
2757
+ if (cell) this.table.setFocusedCell?.(cell.row.id, cell.column.id);
1831
2758
  }
1832
2759
  /** Shift+arrows extend the last range; Ctrl+A selects all cells. */
1833
2760
  rangeKey(event) {
1834
- const table = this.args.table;
2761
+ const table = this.table;
1835
2762
  if (!this.cellSelectable) return false;
1836
2763
  if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'a') {
1837
2764
  event.preventDefault();
@@ -1938,7 +2865,7 @@ class LatticeGrid extends Component {
1938
2865
  get overlayMessage() {
1939
2866
  if (this.args.loading) return this.l.t('grid.loading');
1940
2867
  // A row model with no known count is still in its first load: no "No rows" yet.
1941
- const count = this.args.rowModel ? this.args.rowModel.rowCount : this.rowCount;
2868
+ const count = this.rowModel ? this.rowModel.rowCount : this.rowCount;
1942
2869
  return count === 0 ? this.l.t('grid.noRows') : '';
1943
2870
  }
1944
2871
  // Tooltips (ADR 0018) -------------------------------------------------------------------------
@@ -2209,7 +3136,7 @@ class LatticeGrid extends Component {
2209
3136
  const first = at(minRowIndex, minColumnIndex);
2210
3137
  const last = at(Math.min(maxRowIndex + down, this.rowCount - 1), Math.min(maxColumnIndex + right, this.colCount - 1));
2211
3138
  if (first && last) {
2212
- this.args.table.selectCellRange?.({
3139
+ this.table.selectCellRange?.({
2213
3140
  anchorRowId: first.row.id,
2214
3141
  anchorColumnId: first.column.id,
2215
3142
  focusRowId: last.row.id,
@@ -2588,12 +3515,12 @@ class LatticeGrid extends Component {
2588
3515
  };
2589
3516
  // Resize --------------------------------------------------------------------------------------
2590
3517
  /** A separator needs the column resizing feature, and `enableResizing` not false. */
2591
- canResize = column => this.args.table.setColumnSizing !== undefined && column.getSize !== undefined && column.getCanResize?.() === true;
3518
+ canResize = column => this.table.setColumnSizing !== undefined && column.getSize !== undefined && column.getCanResize?.() === true;
2592
3519
  resize(column, size) {
2593
3520
  // A resize takes a flex column out of flex, so the next flex pass keeps its size.
2594
3521
  this._fixedFlex.add(column.id);
2595
3522
  const next = Math.round(clamp(size, MIN_COLUMN_SIZE, MAX_COLUMN_SIZE));
2596
- this.args.table.setColumnSizing?.(old => ({
3523
+ this.table.setColumnSizing?.(old => ({
2597
3524
  ...old,
2598
3525
  [column.id]: next
2599
3526
  }));
@@ -2658,7 +3585,7 @@ class LatticeGrid extends Component {
2658
3585
  isFlex = column => (column.columnDef.flex ?? 0) > 0 && !this._fixedFlex.has(column.id);
2659
3586
  /** The table as core `applyFlexWidths` and `autoSizeColumns` read it. */
2660
3587
  get sizingTable() {
2661
- const table = this.args.table;
3588
+ const table = this.table;
2662
3589
  const sized = c => ({
2663
3590
  id: c.id,
2664
3591
  columnDef: {
@@ -2688,7 +3615,7 @@ class LatticeGrid extends Component {
2688
3615
  applyFlex() {
2689
3616
  const scroller = this._scroller;
2690
3617
  const all = this.columns.all;
2691
- if (!scroller || !this.args.table.setColumnSizing || !all.some(this.isFlex)) return;
3618
+ if (!scroller || !this.table.setColumnSizing || !all.some(this.isFlex)) return;
2692
3619
  const width = scroller.clientWidth;
2693
3620
  const key = `${width}:${all.map(c => this.isFlex(c) ? c.id : sizeOf(c)).join()}`;
2694
3621
  if (width <= 0 || key === this._flexKey) return;
@@ -2704,7 +3631,7 @@ class LatticeGrid extends Component {
2704
3631
  };
2705
3632
  /** Sizes columns to their widest rendered content (`GridStateHandle.autoSizeColumns`). */
2706
3633
  autoSizeColumns(columnIds) {
2707
- if (!this.args.table.setColumnSizing) return;
3634
+ if (!this.table.setColumnSizing) return;
2708
3635
  const sizes = autoSizeColumns(this.sizingTable, c => this.measureColumn(c.id), columnIds);
2709
3636
  for (const id of Object.keys(sizes)) this._fixedFlex.add(id);
2710
3637
  }
@@ -2736,8 +3663,8 @@ class LatticeGrid extends Component {
2736
3663
  // Auto-generated columns (contract section 11) ------------------------------------------------
2737
3664
  /** True when the table has no columns and has rows: the grid makes columns from the rows. */
2738
3665
  get wantsAutoColumns() {
2739
- const table = this.args.table;
2740
- return !this.args.rowModel && table.getAllLeafColumns().length === 0 && table.getRowModel().rows.length > 0;
3666
+ const table = this.table;
3667
+ return this.args.data === undefined && !this.rowModel && table.getAllLeafColumns().length === 0 && table.getRowModel().rows.length > 0;
2741
3668
  }
2742
3669
  /** Sets the auto columns after the render in which the first rows show. */
2743
3670
  syncAutoColumns = modifier((_el, [wanted]) => {
@@ -2745,8 +3672,8 @@ class LatticeGrid extends Component {
2745
3672
  });
2746
3673
  /** A table with no columns gets a column for each key of its first rows. */
2747
3674
  setAutoColumns() {
2748
- const table = this.args.table;
2749
- if (this.args.rowModel || table.getAllLeafColumns().length > 0) return;
3675
+ const table = this.table;
3676
+ if (this.rowModel || table.getAllLeafColumns().length > 0) return;
2750
3677
  // `setOptions` is not in `GridTable`: its updater type is the table options of the app.
2751
3678
  const setOptions = Reflect.get(table, 'setOptions');
2752
3679
  if (!is.function(setOptions)) return;
@@ -2765,7 +3692,7 @@ class LatticeGrid extends Component {
2765
3692
  return JSON.stringify(this.alignedColumns());
2766
3693
  }
2767
3694
  alignedColumns() {
2768
- const table = this.args.table;
3695
+ const table = this.table;
2769
3696
  const leaves = table.getAllLeafColumns();
2770
3697
  return {
2771
3698
  sizes: Object.fromEntries(leaves.map(c => [c.id, sizeOf(c)])),
@@ -2774,7 +3701,7 @@ class LatticeGrid extends Component {
2774
3701
  };
2775
3702
  }
2776
3703
  alignColumns(state) {
2777
- const table = this.args.table;
3704
+ const table = this.table;
2778
3705
  const leaves = table.getAllLeafColumns();
2779
3706
  const sizes = {};
2780
3707
  const visible = {};
@@ -2846,10 +3773,11 @@ class LatticeGrid extends Component {
2846
3773
  super.willDestroy();
2847
3774
  // A flex frame that is still to run finds no scroller and does nothing.
2848
3775
  this._leaveAlignment?.();
3776
+ this.builtModel.clear();
2849
3777
  }
2850
3778
  // Reorder -------------------------------------------------------------------------------------
2851
3779
  onHeaderPointerDown = (column, event) => {
2852
- const table = this.args.table;
3780
+ const table = this.table;
2853
3781
  this._suppressClick = false;
2854
3782
  if (event.button !== 0 || !table.setColumnOrder || this.inSlot(event)) return;
2855
3783
  const header = event.currentTarget;
@@ -2882,24 +3810,28 @@ class LatticeGrid extends Component {
2882
3810
  doc.addEventListener('pointercancel', end);
2883
3811
  };
2884
3812
  moveColumn(sourceId, targetId) {
2885
- const ids = this.args.table.getAllLeafColumns().map(c => c.id);
3813
+ const ids = this.table.getAllLeafColumns().map(c => c.id);
2886
3814
  const from = ids.indexOf(sourceId);
2887
3815
  const to = ids.indexOf(targetId);
2888
3816
  if (from < 0 || to < 0) return;
2889
3817
  ids.splice(from, 1);
2890
3818
  ids.splice(to, 0, sourceId);
2891
- this.args.table.setColumnOrder?.(ids);
3819
+ this.table.setColumnOrder?.(ids);
2892
3820
  }
2893
3821
  static {
2894
- setComponentTemplate(precompileTemplate("<div class=\"lt-grid-root\" dir={{this.dir}} style={{if (has-block \"sideBar\") SPLIT_STYLE}} {{this.saveOnOutsidePress @stopEditingWhenCellsLoseFocus}}>\n <div class=\"lt-grid\" role={{this.role}} aria-label={{@label}} aria-rowcount={{this.ariaRowCount}} aria-colcount={{this.colCount}} aria-multiselectable={{if this.multiselectable \"true\"}} aria-busy={{if @loading \"true\"}} data-lt-density={{this.density}} data-lt-borders=\"rows\" style={{this.gridStyle (has-block \"sideBar\")}} ...attributes {{on \"focusin\" this.onFocusIn}} {{on \"keydown\" this.onKeyDown}} {{on \"dblclick\" this.onDoubleClick}} {{on \"click\" this.onClick}} {{on \"mousedown\" this.onMouseDown}} {{on \"mouseover\" this.onMouseOver}} {{on \"mouseout\" this.onMouseOut}} {{on \"focusout\" this.onFocusOut}} {{on \"pointerdown\" this.onPointerDown}} {{on \"copy\" this.onCopy}} {{on \"cut\" this.onCut}} {{on \"paste\" this.onPaste}} {{on \"contextmenu\" (fn this.onContextMenu (has-block \"contextMenu\"))}} {{this.noteMenuBlock (has-block \"contextMenu\")}}>\n <div class=\"lt-scroller\" {{this.setup}} {{VirtualScroll this.rowState}} {{VirtualScroll this.colState}} {{this.syncRows this.rowCount this.rowHeight this.overscan this.headerHeight this.footerHeight this.pinnedTopHeight this.pinnedBottomHeight this.measured this.display}} {{this.syncModel @rowModel this.rangeStart this.rangeEnd @rowModel.queryKey}} {{this.syncAligned @aligned (if @aligned this.alignedKey)}} {{this.syncAutoColumns this.wantsAutoColumns}} {{this.syncCols this.columns.centerSizes this.columns.startWidth this.columns.endWidth this.rtl}}>\n <div class=\"lt-sizer\" style={{this.sizerStyle}}>\n <div class=\"lt-header\" role=\"rowgroup\">\n {{#each this.groupRows key=\"key\" as |group|}}\n <div class=\"lt-row lt-header-row\" role=\"row\" aria-rowindex={{group.aria}} style={{this.rowWidthStyle}}>\n {{#each group.cells key=\"key\" as |cell|}}\n {{#if cell.header.isPlaceholder}}\n <div class=\"lt-spacer\" aria-hidden=\"true\" style={{cell.style}}></div>\n {{else}}\n <div class=\"lt-header-cell lt-group-header\" role=\"columnheader\" aria-colindex={{cell.aria}} aria-colspan={{cell.colSpan}} data-column-id={{cell.header.column.id}} data-pinned={{isPinned cell.pin}} tabindex=\"-1\" style={{cell.style}}>\n <span class=\"lt-header-label\">{{cell.label}}</span>\n </div>\n {{/if}}\n {{/each}}\n </div>\n {{/each}}\n <div class=\"lt-row lt-header-row\" role=\"row\" aria-rowindex={{this.leafHeaderRow}} style={{this.rowWidthStyle}}>\n {{#each this.layout.slots key=\"key\" as |slot|}}\n {{#if slot.rendered}}\n {{#if slot.gap}}\n <div class=\"lt-spacer\" aria-hidden=\"true\" style={{slot.gap}}></div>\n {{/if}}\n <div class=\"lt-header-cell\" role=\"columnheader\" aria-colindex={{slot.aria}} aria-sort={{sortOf slot.column}} data-column-id={{slot.column.id}} data-pinned={{isPinned slot.pin}} aria-label={{if slot.headerSlot (this.headerLabelFor slot.column)}} tabindex={{this.tabIndexFor this.leafHeaderRow slot.aria}} style={{slot.style}} {{on \"click\" (fn this.onHeaderClick slot.column)}} {{on \"pointerdown\" (fn this.onHeaderPointerDown slot.column)}}>\n <span class=\"lt-header-label\">\n {{~#if slot.headerLabel~}}\n <slot.headerLabel @column={{slot.column}} @label={{this.headerLabelFor slot.column}} />\n {{~else~}}\n {{this.headerLabelFor slot.column}}\n {{~/if~}}\n </span>\n {{#if slot.headerSlot}}\n <span class=\"lt-header-slot\"><slot.headerSlot @column={{slot.column}} @grid={{this.headerApi}} /></span>\n {{/if}}\n {{#if (this.canResize slot.column)}}\n <div class=\"lt-resize-handle\" role=\"separator\" aria-orientation=\"vertical\" aria-valuenow={{slot.size}} aria-valuemin={{MIN_COLUMN_SIZE}} aria-valuemax={{MAX_COLUMN_SIZE}} aria-label={{this.l.t \"grid.resizeColumn\" column=(this.headerLabelFor slot.column)}} tabindex=\"-1\" {{on \"pointerdown\" (fn this.onResizeStart slot.column)}} {{on \"keydown\" (fn this.onResizeKey slot.column)}} {{on \"click\" this.stopClick}} {{on \"dblclick\" (fn this.onResizeDoubleClick slot.column)}}></div>\n {{/if}}\n </div>\n {{/if}}\n {{/each}}\n {{#if this.layout.tail}}\n <div class=\"lt-spacer\" aria-hidden=\"true\" style={{this.layout.tail}}></div>\n {{/if}}\n </div>\n {{#if @floatingFilter}}\n <div class=\"lt-row lt-header-row lt-floating-row\" role=\"row\" aria-rowindex={{this.floatingRow}} style={{this.rowWidthStyle}}>\n {{#each this.layout.slots key=\"key\" as |slot|}}\n {{#if slot.rendered}}\n {{#if slot.gap}}\n <div class=\"lt-spacer\" aria-hidden=\"true\" style={{slot.gap}}></div>\n {{/if}}\n <div class=\"lt-header-cell lt-floating-cell\" role=\"gridcell\" aria-colindex={{slot.aria}} data-column-id={{slot.column.id}} data-pinned={{isPinned slot.pin}} tabindex={{this.tabIndexFor this.floatingRow slot.aria}} style={{slot.style}}>\n <@floatingFilter @column={{slot.column}} @grid={{this.headerApi}} />\n </div>\n {{/if}}\n {{/each}}\n {{#if this.layout.tail}}\n <div class=\"lt-spacer\" aria-hidden=\"true\" style={{this.layout.tail}}></div>\n {{/if}}\n </div>\n {{/if}}\n </div>\n <div class=\"lt-body\" role=\"rowgroup\" style={{this.bodyStyle}}>\n {{#each this.slots key=\"@index\" as |view index|}}\n {{#if view}}\n {{#let (asRowView view) (asSkeleton view) (asDetail view) as |rowView skeleton detail|}}\n {{#if rowView}}\n <LatticeRow @grid={{this}} @view={{rowView}} @slot={{index}} />\n {{else if detail}}\n <DetailRow @grid={{this}} @view={{detail}} @slot={{index}} />\n {{else if skeleton}}\n <SkeletonRow @grid={{this}} @view={{skeleton}} @slot={{index}} />\n {{/if}}\n {{/let}}\n {{/if}}\n {{/each}}\n </div>\n {{#if @rowModel.totalRow}}\n <div class=\"lt-footer\" role=\"rowgroup\" style={{this.footerStyle}}>\n <div class=\"lt-row lt-total-row\" role=\"row\" aria-rowindex={{this.totalAriaRow}} style={{this.rowWidthStyle}}>\n {{#each this.layout.slots key=\"key\" as |slot|}}\n {{#if slot.rendered}}\n {{#if slot.gap}}\n <div class=\"lt-spacer\" aria-hidden=\"true\" style={{slot.gap}}></div>\n {{/if}}\n <div class=\"lt-cell\" role=\"gridcell\" aria-colindex={{slot.aria}} data-column-id={{slot.column.id}} data-pinned={{isPinned slot.pin}} style={{slot.style}}>{{totalText @rowModel.totalRow slot this.l}}</div>\n {{/if}}\n {{/each}}\n {{#if this.layout.tail}}\n <div class=\"lt-spacer\" aria-hidden=\"true\" style={{this.layout.tail}}></div>\n {{/if}}\n </div>\n </div>\n {{/if}}\n </div>\n </div>\n </div>\n {{#if (has-block \"sideBar\")}}\n <div class=\"lt-side-bar-region\">{{yield to=\"sideBar\"}}</div>\n {{/if}}\n {{#if this.overlayMessage}}\n <div class=\"lt-overlay-message\" role=\"status\" aria-label={{this.l.t \"grid.status\"}}>{{this.overlayMessage}}</div>\n {{/if}}\n {{#if this.tooltip}}\n <div class=\"lt-tooltip\" role=\"tooltip\" id={{this.tooltipId}} style={{this.tooltip.style}}>{{this.tooltip.text}}</div>\n {{/if}}\n {{#if this.note}}\n <div class=\"lt-note\" role=\"note\" id={{this.noteId}} {{this.placeNote this.note this.tooltip}}>{{this.note.text}}</div>\n {{/if}}\n {{#if this.cellDescriptions.length}}\n <div class=\"lt-cell-descriptions\" hidden>\n {{#each this.cellDescriptions as |description|}}\n <span id={{description.id}}>{{description.text}}</span>\n {{/each}}\n </div>\n {{/if}}\n <div class=\"lt-live\" role=\"status\" aria-label={{this.l.t \"grid.messages\"}} style={{LIVE_STYLE}}>\n <span data-live=\"message\">{{this.liveMessage}}</span>\n <span data-live=\"edit\">{{@editing.message}}</span>\n <span data-live=\"count\">{{this.countMessage}}</span>\n </div>\n {{!-- The keys of the editor do not reach role=grid: the overlay is outside it. --}}\n <div class=\"lt-overlay\" {{on \"keydown\" this.onEditorEscape capture=true}} {{on \"keydown\" this.onEditorKeyDown}} {{on \"focusout\" this.onEditorFocusOut}}>\n {{yield (hash target=this.contextTarget selection=this.selection close=this.closeMenu copyText=this.copyText pasteText=this.pasteText) to=\"contextMenu\"}}\n {{#if @editing}}\n {{#if @editing.active}}\n <div class=\"lt-editor\" data-lt-edit-state={{@editing.state}} data-lt-edit-mode={{this.editMode}} {{this.placeEditor this.editPosition}}>\n <@editing.Editor @cell={{@editing.active}} @id={{this.editorId}} @label={{this.headerLabelFor @editing.active.column}} @value={{@editing.draft}} @onChange={{@editing.setDraft}} @invalid={{this.editInvalid}} />\n {{#each @editing.errors as |error|}}\n <div class=\"lt-editor-error\" role=\"alert\">{{error}}</div>\n {{/each}}\n </div>\n {{/if}}\n {{#let @editing.RowEditor @editing.activeRow as |RowEditor row|}}\n {{#if RowEditor}}\n {{#if row}}\n <div class=\"lt-row-editor\" role=\"group\" aria-label={{this.l.t \"grid.editRow\" row=this.editRowNumber}} data-lt-edit-state={{@editing.state}} {{this.placeRowEditor this.editPosition}}>\n <RowEditor @row={{row}} @fields={{this.rowEditFields}} @values={{this.rowDraft}} @onChange={{this.setRowValue}} />\n {{#each @editing.errors as |error|}}\n <div class=\"lt-editor-error\" role=\"alert\">{{error}}</div>\n {{/each}}\n </div>\n {{/if}}\n {{/if}}\n {{/let}}\n {{/if}}\n </div>\n</div>", {
3822
+ setComponentTemplate(precompileTemplate("{{!-- The template form (ADR 0028): the declarations render first, and render no element. --}}\n{{~#if (has-block \"columns\")~}}\n <DeclareMode @registry={{this.registry}} @locale={{this.l}} as |g|>{{yield g to=\"columns\"}}</DeclareMode>\n{{else if (has-block)}}\n <DeclareMode @registry={{this.registry}} @locale={{this.l}} as |g|>{{yield g}}</DeclareMode>\n{{~/if~}}\n{{#if (has-block \"toolbar\")}}\n <div class=\"lt-toolbar-region\">{{yield this.chromeApi to=\"toolbar\"}}</div>\n{{/if}}\n<div class=\"lt-grid-root\" dir={{this.dir}} style={{if (has-block \"sideBar\") SPLIT_STYLE}} {{this.saveOnOutsidePress @stopEditingWhenCellsLoseFocus}}>\n <div class=\"lt-grid\" role={{this.role}} aria-label={{@label}} aria-rowcount={{this.ariaRowCount}} aria-colcount={{this.colCount}} aria-multiselectable={{if this.multiselectable \"true\"}} aria-busy={{if @loading \"true\"}} data-lt-density={{this.density}} data-lt-borders=\"rows\" style={{this.gridStyle (has-block \"sideBar\")}} ...attributes {{on \"focusin\" this.onFocusIn}} {{on \"keydown\" this.onKeyDown}} {{on \"dblclick\" this.onDoubleClick}} {{on \"click\" this.onClick}} {{on \"mousedown\" this.onMouseDown}} {{on \"mouseover\" this.onMouseOver}} {{on \"mouseout\" this.onMouseOut}} {{on \"focusout\" this.onFocusOut}} {{on \"pointerdown\" this.onPointerDown}} {{on \"copy\" this.onCopy}} {{on \"cut\" this.onCut}} {{on \"paste\" this.onPaste}} {{on \"contextmenu\" (fn this.onContextMenu (has-block \"contextMenu\"))}} {{this.noteMenuBlock (has-block \"contextMenu\")}}>\n <div class=\"lt-scroller\" {{this.setup}} {{VirtualScroll this.rowState}} {{VirtualScroll this.colState}} {{this.syncRows this.rowCount this.rowHeight this.overscan this.headerHeight this.footerHeight this.pinnedTopHeight this.pinnedBottomHeight this.measured this.display}} {{this.syncModel this.rowModel this.rangeStart this.rangeEnd this.rowModel.queryKey}} {{this.syncAligned @aligned (if @aligned this.alignedKey)}} {{this.syncAutoColumns this.wantsAutoColumns}} {{this.syncCols this.columns.centerSizes this.columns.startWidth this.columns.endWidth this.rtl}}>\n <div class=\"lt-sizer\" style={{this.sizerStyle}}>\n <div class=\"lt-header\" role=\"rowgroup\">\n {{#each this.groupRows key=\"key\" as |group|}}\n <div class=\"lt-row lt-header-row\" role=\"row\" aria-rowindex={{group.aria}} style={{this.rowWidthStyle}}>\n {{#each group.cells key=\"key\" as |cell|}}\n {{#if cell.header.isPlaceholder}}\n <div class=\"lt-spacer\" aria-hidden=\"true\" style={{cell.style}}></div>\n {{else}}\n <div class=\"lt-header-cell lt-group-header\" role=\"columnheader\" aria-colindex={{cell.aria}} aria-colspan={{cell.colSpan}} data-column-id={{cell.header.column.id}} data-pinned={{isPinned cell.pin}} tabindex=\"-1\" style={{cell.style}}>\n <span class=\"lt-header-label\">{{cell.label}}</span>\n </div>\n {{/if}}\n {{/each}}\n </div>\n {{/each}}\n <div class=\"lt-row lt-header-row\" role=\"row\" aria-rowindex={{this.leafHeaderRow}} style={{this.rowWidthStyle}}>\n {{#each this.layout.slots key=\"key\" as |slot|}}\n {{#if slot.rendered}}\n {{#if slot.gap}}\n <div class=\"lt-spacer\" aria-hidden=\"true\" style={{slot.gap}}></div>\n {{/if}}\n <div class=\"lt-header-cell\" role=\"columnheader\" aria-colindex={{slot.aria}} aria-sort={{sortOf slot.column}} data-column-id={{slot.column.id}} data-pinned={{isPinned slot.pin}} aria-label={{if (or slot.headerSlot slot.headerEndBlock) (this.headerLabelFor slot.column)}} tabindex={{this.tabIndexFor this.leafHeaderRow slot.aria}} style={{slot.style}} {{on \"click\" (fn this.onHeaderClick slot.column)}} {{on \"pointerdown\" (fn this.onHeaderPointerDown slot.column)}}>\n <span class=\"lt-header-label\">\n {{~#if slot.headerBlock~}}\n {{~#let (hash column=slot.column label=(this.headerLabelFor slot.column) grid=this.headerApi) as |ctx|~}}\n {{~#if (has-block \"columns\")~}}\n <PartMode @target={{slot.column.id}} @part=\"header\" @ctx={{ctx}} as |g|>{{yield g to=\"columns\"}}</PartMode>\n {{~else~}}\n <PartMode @target={{slot.column.id}} @part=\"header\" @ctx={{ctx}} as |g|>{{yield g}}</PartMode>\n {{~/if~}}\n {{~/let~}}\n {{~else if slot.headerLabel~}}\n <slot.headerLabel @column={{slot.column}} @label={{this.headerLabelFor slot.column}} />\n {{~else~}}\n {{this.headerLabelFor slot.column}}\n {{~/if~}}\n </span>\n {{#if slot.headerSlot}}\n <span class=\"lt-header-slot\"><slot.headerSlot @column={{slot.column}} @grid={{this.headerApi}} /></span>\n {{else if slot.headerEndBlock}}\n {{#let (hash column=slot.column label=(this.headerLabelFor slot.column) grid=this.headerApi) as |ctx|}}\n <span class=\"lt-header-slot\">\n {{~#if (has-block \"columns\")~}}\n <PartMode @target={{slot.column.id}} @part=\"headerEnd\" @ctx={{ctx}} as |g|>{{yield g to=\"columns\"}}</PartMode>\n {{~else~}}\n <PartMode @target={{slot.column.id}} @part=\"headerEnd\" @ctx={{ctx}} as |g|>{{yield g}}</PartMode>\n {{~/if~}}\n </span>\n {{/let}}\n {{/if}}\n {{#if (this.canResize slot.column)}}\n <div class=\"lt-resize-handle\" role=\"separator\" aria-orientation=\"vertical\" aria-valuenow={{slot.size}} aria-valuemin={{MIN_COLUMN_SIZE}} aria-valuemax={{MAX_COLUMN_SIZE}} aria-label={{this.l.t \"grid.resizeColumn\" column=(this.headerLabelFor slot.column)}} tabindex=\"-1\" {{on \"pointerdown\" (fn this.onResizeStart slot.column)}} {{on \"keydown\" (fn this.onResizeKey slot.column)}} {{on \"click\" this.stopClick}} {{on \"dblclick\" (fn this.onResizeDoubleClick slot.column)}}></div>\n {{/if}}\n </div>\n {{/if}}\n {{/each}}\n {{#if this.layout.tail}}\n <div class=\"lt-spacer\" aria-hidden=\"true\" style={{this.layout.tail}}></div>\n {{/if}}\n </div>\n {{#if @floatingFilter}}\n <div class=\"lt-row lt-header-row lt-floating-row\" role=\"row\" aria-rowindex={{this.floatingRow}} style={{this.rowWidthStyle}}>\n {{#each this.layout.slots key=\"key\" as |slot|}}\n {{#if slot.rendered}}\n {{#if slot.gap}}\n <div class=\"lt-spacer\" aria-hidden=\"true\" style={{slot.gap}}></div>\n {{/if}}\n <div class=\"lt-header-cell lt-floating-cell\" role=\"gridcell\" aria-colindex={{slot.aria}} data-column-id={{slot.column.id}} data-pinned={{isPinned slot.pin}} tabindex={{this.tabIndexFor this.floatingRow slot.aria}} style={{slot.style}}>\n <@floatingFilter @column={{slot.column}} @grid={{this.headerApi}} />\n </div>\n {{/if}}\n {{/each}}\n {{#if this.layout.tail}}\n <div class=\"lt-spacer\" aria-hidden=\"true\" style={{this.layout.tail}}></div>\n {{/if}}\n </div>\n {{/if}}\n </div>\n <div class=\"lt-body\" role=\"rowgroup\" style={{this.bodyStyle}}>\n {{#each this.slots key=\"@index\" as |view index|}}\n {{#if view}}\n {{#let (asRowView view) (asSkeleton view) (asDetail view) as |rowView skeleton detail|}}\n {{#if rowView}}\n <LatticeRow @grid={{this.rowHost}} @view={{rowView}} @slot={{index}} />\n {{else if detail}}\n <DetailRow @grid={{this.rowHost}} @view={{detail}} @slot={{index}} />\n {{else if skeleton}}\n <SkeletonRow @grid={{this.rowHost}} @view={{skeleton}} @slot={{index}} />\n {{/if}}\n {{/let}}\n {{/if}}\n {{/each}}\n </div>\n {{#if this.rowModel.totalRow}}\n <div class=\"lt-footer\" role=\"rowgroup\" style={{this.footerStyle}}>\n <div class=\"lt-row lt-total-row\" role=\"row\" aria-rowindex={{this.totalAriaRow}} style={{this.rowWidthStyle}}>\n {{#each this.layout.slots key=\"key\" as |slot|}}\n {{#if slot.rendered}}\n {{#if slot.gap}}\n <div class=\"lt-spacer\" aria-hidden=\"true\" style={{slot.gap}}></div>\n {{/if}}\n <div class=\"lt-cell\" role=\"gridcell\" aria-colindex={{slot.aria}} data-column-id={{slot.column.id}} data-pinned={{isPinned slot.pin}} style={{slot.style}}>{{totalText this.rowModel.totalRow slot this.l}}</div>\n {{/if}}\n {{/each}}\n {{#if this.layout.tail}}\n <div class=\"lt-spacer\" aria-hidden=\"true\" style={{this.layout.tail}}></div>\n {{/if}}\n </div>\n </div>\n {{/if}}\n </div>\n </div>\n </div>\n {{#if (has-block \"sideBar\")}}\n <div class=\"lt-side-bar-region\">{{yield this.chromeApi to=\"sideBar\"}}</div>\n {{/if}}\n {{#if this.overlayMessage}}\n <div class=\"lt-overlay-message\" role=\"status\" aria-label={{this.l.t \"grid.status\"}}>{{this.overlayMessage}}</div>\n {{/if}}\n {{#if this.tooltip}}\n <div class=\"lt-tooltip\" role=\"tooltip\" id={{this.tooltipId}} style={{this.tooltip.style}}>{{this.tooltip.text}}</div>\n {{/if}}\n {{#if this.note}}\n <div class=\"lt-note\" role=\"note\" id={{this.noteId}} {{this.placeNote this.note this.tooltip}}>{{this.note.text}}</div>\n {{/if}}\n {{#if this.cellDescriptions.length}}\n <div class=\"lt-cell-descriptions\" hidden>\n {{#each this.cellDescriptions as |description|}}\n <span id={{description.id}}>{{description.text}}</span>\n {{/each}}\n </div>\n {{/if}}\n <div class=\"lt-live\" role=\"status\" aria-label={{this.l.t \"grid.messages\"}} style={{LIVE_STYLE}}>\n <span data-live=\"message\">{{this.liveMessage}}</span>\n <span data-live=\"edit\">{{@editing.message}}</span>\n <span data-live=\"count\">{{this.countMessage}}</span>\n </div>\n {{!-- The keys of the editor do not reach role=grid: the overlay is outside it. --}}\n <div class=\"lt-overlay\" {{on \"keydown\" this.onEditorEscape capture=true}} {{on \"keydown\" this.onEditorKeyDown}} {{on \"focusout\" this.onEditorFocusOut}}>\n {{yield (hash table=this.table target=this.contextTarget selection=this.selection close=this.closeMenu copyText=this.copyText pasteText=this.pasteText) to=\"contextMenu\"}}\n {{#if @editing}}\n {{#if @editing.active}}\n <div class=\"lt-editor\" data-lt-edit-state={{@editing.state}} data-lt-edit-mode={{this.editMode}} {{this.placeEditor this.editPosition}}>\n {{#if (editorBlockOf @editing.active.column)}}\n {{#let (hash cell=@editing.active id=this.editorId label=(this.headerLabelFor @editing.active.column) value=@editing.draft onChange=@editing.setDraft invalid=this.editInvalid) as |ctx|}}\n {{#if (has-block \"columns\")}}\n <PartMode @target={{@editing.active.column.id}} @part=\"editor\" @ctx={{ctx}} as |g|>{{yield g to=\"columns\"}}</PartMode>\n {{else}}\n <PartMode @target={{@editing.active.column.id}} @part=\"editor\" @ctx={{ctx}} as |g|>{{yield g}}</PartMode>\n {{/if}}\n {{/let}}\n {{else}}\n <@editing.Editor @cell={{@editing.active}} @id={{this.editorId}} @label={{this.headerLabelFor @editing.active.column}} @value={{@editing.draft}} @onChange={{@editing.setDraft}} @invalid={{this.editInvalid}} />\n {{/if}}\n {{#each @editing.errors as |error|}}\n <div class=\"lt-editor-error\" role=\"alert\">{{error}}</div>\n {{/each}}\n </div>\n {{/if}}\n {{#let @editing.RowEditor @editing.activeRow as |RowEditor row|}}\n {{#if RowEditor}}\n {{#if row}}\n <div class=\"lt-row-editor\" role=\"group\" aria-label={{this.l.t \"grid.editRow\" row=this.editRowNumber}} data-lt-edit-state={{@editing.state}} {{this.placeRowEditor this.editPosition}}>\n <RowEditor @row={{row}} @fields={{this.rowEditFields}} @values={{this.rowDraft}} @onChange={{this.setRowValue}} />\n {{#each @editing.errors as |error|}}\n <div class=\"lt-editor-error\" role=\"alert\">{{error}}</div>\n {{/each}}\n </div>\n {{/if}}\n {{/if}}\n {{/let}}\n {{/if}}\n </div>\n</div>\n{{#if (has-block \"statusBar\")}}\n <div class=\"lt-status-bar-region\">{{yield this.chromeApi to=\"statusBar\"}}</div>\n{{/if}}\n{{!-- The template form: the <:cell> blocks render into the anchors of their cells. --}}\n{{~#if this.hasBlockCells~}}\n {{~#if (has-block \"columns\")~}}\n <PortalMode @host={{this}} as |g|>{{yield g to=\"columns\"}}</PortalMode>\n {{~else~}}\n <PortalMode @host={{this}} as |g|>{{yield g}}</PortalMode>\n {{~/if~}}\n{{~/if~}}", {
2895
3823
  strictMode: true,
2896
3824
  scope: () => ({
3825
+ DeclareMode: DeclareMode$1,
2897
3826
  SPLIT_STYLE,
2898
3827
  on,
2899
3828
  fn,
2900
3829
  VirtualScroll,
2901
3830
  isPinned,
2902
3831
  sortOf,
3832
+ or,
3833
+ hash,
3834
+ PartMode,
2903
3835
  MIN_COLUMN_SIZE,
2904
3836
  MAX_COLUMN_SIZE,
2905
3837
  asRowView,
@@ -2910,7 +3842,8 @@ class LatticeGrid extends Component {
2910
3842
  SkeletonRow,
2911
3843
  totalText,
2912
3844
  LIVE_STYLE,
2913
- hash
3845
+ editorBlockOf,
3846
+ PortalMode
2914
3847
  })
2915
3848
  }), this);
2916
3849
  }
@@ -2926,12 +3859,12 @@ class LatticeGrid extends Component {
2926
3859
  }
2927
3860
  /** All rows plus the header rows, or -1 when the row model does not know the count (ARIA). */
2928
3861
  get ariaRowCount() {
2929
- const model = this.args.rowModel;
3862
+ const model = this.rowModel;
2930
3863
  if (model && model.rowCount === null) return -1;
2931
3864
  return this.rowCount + this.headerRowCount + (model?.totalRow ? 1 : 0);
2932
3865
  }
2933
3866
  get footerHeight() {
2934
- return this.args.rowModel?.totalRow ? this.rowHeight : 0;
3867
+ return this.rowModel?.totalRow ? this.rowHeight : 0;
2935
3868
  }
2936
3869
  /** The grand total row is after the last row. */
2937
3870
  get totalAriaRow() {
@@ -2942,7 +3875,7 @@ class LatticeGrid extends Component {
2942
3875
  return htmlSafe(`position: sticky; inset-block-end: 0; z-index: 2; inline-size: ${px$2(this.totalWidth)}`);
2943
3876
  }
2944
3877
  get role() {
2945
- return this.args.rowModel?.tree || this.clientTree ? 'treegrid' : 'grid';
3878
+ return this.rowModel?.tree || this.clientTree ? 'treegrid' : 'grid';
2946
3879
  }
2947
3880
  get overscan() {
2948
3881
  return this.args.overscan ?? DEFAULT_OVERSCAN$1;
@@ -2955,87 +3888,7 @@ class LatticeGrid extends Component {
2955
3888
  };
2956
3889
  }
2957
3890
 
2958
- // The row selection column: a Joinery `Checkbox` in each row.
2959
- class SelectCell extends Component {
2960
- get checked() {
2961
- return this.args.row.getIsSelected?.() ?? false;
2962
- }
2963
- get disabled() {
2964
- return this.args.row.getCanSelect?.() === false;
2965
- }
2966
- /** A grid slot has a fixed signature, so it reads only the owner text (ADR 0024). */
2967
- get label() {
2968
- return latticeLocale(getOwner(this)).t('grid.selectRow');
2969
- }
2970
- onChange = checked => this.args.row.toggleSelected?.(checked === true);
2971
- /** The cell is the tab stop: after a click, give it the focus, so the arrow keys work. */
2972
- focusCell = event => {
2973
- if (!(event.currentTarget instanceof Element)) return;
2974
- const cell = event.currentTarget.closest('[role="gridcell"]');
2975
- if (cell instanceof HTMLElement) cell.focus();
2976
- };
2977
- static {
2978
- setComponentTemplate(precompileTemplate("{{!-- The cell is the tab stop: the checkbox is not. --}}\n<Checkbox class=\"lt-select\" @checked={{this.checked}} @disabled={{this.disabled}} @onCheckedChange={{this.onChange}} aria-label={{this.label}} tabindex=\"-1\" {{on \"click\" this.focusCell}} as |c|>\n <c.Indicator>\u2713</c.Indicator>\n</Checkbox>", {
2979
- strictMode: true,
2980
- scope: () => ({
2981
- Checkbox,
2982
- on
2983
- })
2984
- }), this);
2985
- }
2986
- }
2987
- /** The column def of the selection column. */
2988
-
2989
- /**
2990
- * A column def for row selection. Put it in the `columns` of the table. The table needs the
2991
- * `rowSelectionFeature`.
2992
- * The default header is the locale text of `locale` (`latticeLocale(owner)`), or English.
2993
- */
2994
- function selectionColumn(options = {}) {
2995
- return {
2996
- id: '__lattice_select',
2997
- header: options.header ?? (options.locale ?? latticeLocale(undefined)).t('grid.selectedHeader'),
2998
- size: options.size ?? 40,
2999
- enableSorting: false,
3000
- enableResizing: false,
3001
- // The checkbox has no local state: it reads the row, so it can reuse a row slot.
3002
- meta: {
3003
- lattice: {
3004
- cell: SelectCell,
3005
- cellKind: 'cheap',
3006
- align: 'center'
3007
- }
3008
- }
3009
- };
3010
- }
3011
-
3012
- // The row number column: the display position of each row, pinned at the inline start.
3013
-
3014
- /** The column def of the row number column. */
3015
-
3016
- /**
3017
- * A column def for row numbers. Put it in the `columns` of the table. The grid pins it at the
3018
- * inline start and shows the 1-based display position of each row (ADR 0018).
3019
- * The default header is the locale text of `locale` (`latticeLocale(owner)`), or English.
3020
- */
3021
- function rowNumberColumn(options = {}) {
3022
- return {
3023
- id: '__lattice_row_number',
3024
- header: options.header ?? (options.locale ?? latticeLocale(undefined)).t('grid.rowNumberHeader'),
3025
- size: options.size ?? 56,
3026
- enableSorting: false,
3027
- enableResizing: false,
3028
- meta: {
3029
- lattice: {
3030
- rowNumber: true,
3031
- cellKind: 'cheap',
3032
- align: 'end'
3033
- }
3034
- }
3035
- };
3036
- }
3037
-
3038
- // LatticeList: the List surface (docs/m3-list-board-contract.md, section 1). Items are measured
3891
+ // LatticeList: the List surface (docs/prd/2026-12-01-m3-list-board-contract/index.html, section 1). Items are measured
3039
3892
  // after render. Each item is keyed by its ID, so it keeps its element while it is in range, and
3040
3893
  // the active item stays rendered (held) when it leaves the range (ADR 0002, amendment 1).
3041
3894
  const DEFAULT_ESTIMATE = 48;
@@ -3469,9 +4322,99 @@ class LatticeList extends Component {
3469
4322
  }
3470
4323
  }
3471
4324
 
3472
- // LatticeBoard: the Board surface (docs/m3-list-board-contract.md, section 2). Each lane is a
4325
+ // The declarations of the board in the template form (ADR 0028, FR-10): `<b.Lane>` and
4326
+ // `<b.Card>`. A declaration renders no element.
4327
+ //
4328
+ // The board yields its block in three modes, with the same names:
4329
+ // - declare: before `div.lt-board`. Each `<b.Lane>` adds itself to the registry, and renders one
4330
+ // comment node that gives its place in the template. `<b.Card>` renders nothing.
4331
+ // - header: in the title of a lane with a `<:header>` block. Only that lane renders its block.
4332
+ // - card: in each card and in the drag preview. Only `<b.Card>` renders its block, with the item.
4333
+ // Glimmer cannot give a block to another component as a value, so the board renders the block
4334
+ // again in each place that needs the content of a declaration.
4335
+ /** The declarations that the board yields in the template form. */
4336
+ /** A lane in the registry of a board. */
4337
+ const laneRegistry = () => new ColumnRegistry();
4338
+ const eq = (a, b) => Object.is(a, b);
4339
+ // Declare mode ------------------------------------------------------------------------------
4340
+ class LaneDeclaration extends Component {
4341
+ /** A comment node: the place of the declaration in the template. */marker = document.createComment('');
4342
+ /** A plain field: the template sets it before the board reads the lanes. */
4343
+ hasHeader = false;
4344
+ constructor(owner, args) {
4345
+ super(owner, args);
4346
+ args.registry.add(this);
4347
+ }
4348
+ willDestroy() {
4349
+ super.willDestroy();
4350
+ this.args.registry.remove(this);
4351
+ }
4352
+ get key() {
4353
+ return this.args.key;
4354
+ }
4355
+ get label() {
4356
+ return this.args.label;
4357
+ }
4358
+ /** The blocks are fixed for one invocation, so the first render sets this once. */
4359
+ noteHeader = header => {
4360
+ this.hasHeader = header;
4361
+ };
4362
+ static {
4363
+ setComponentTemplate(precompileTemplate("{{~this.marker~}}\n{{~this.noteHeader (has-block \"header\")~}}", {
4364
+ strictMode: true
4365
+ }), this);
4366
+ }
4367
+ }
4368
+ /** A declaration that renders nothing in this mode. */
4369
+ const Nothing = setComponentTemplate(precompileTemplate("", {
4370
+ strictMode: true
4371
+ }), templateOnly());
4372
+ /** The declarations of declare mode. */
4373
+
4374
+ /** Yields the declarations of declare mode: each lane adds itself to the registry. */const DeclareMode = setComponentTemplate(precompileTemplate("{{~yield (hash Lane=(component LaneDeclaration registry=@registry) Card=Nothing)~}}", {
4375
+ strictMode: true,
4376
+ scope: () => ({
4377
+ hash,
4378
+ LaneDeclaration,
4379
+ Nothing
4380
+ })
4381
+ }), templateOnly());
4382
+ // Header mode and card mode -----------------------------------------------------------------
4383
+ const HeaderLane = setComponentTemplate(precompileTemplate("{{~#if (eq @key @target)~}}\n {{~yield @ctx to=\"header\"~}}\n{{~/if~}}", {
4384
+ strictMode: true,
4385
+ scope: () => ({
4386
+ eq
4387
+ })
4388
+ }), templateOnly());
4389
+ /** Yields the declarations of header mode: only the lane `@target` renders its `<:header>`. */
4390
+ const HeaderMode = setComponentTemplate(precompileTemplate("{{~yield (hash Lane=(component HeaderLane target=@target ctx=@ctx) Card=Nothing)~}}", {
4391
+ strictMode: true,
4392
+ scope: () => ({
4393
+ hash,
4394
+ HeaderLane,
4395
+ Nothing
4396
+ })
4397
+ }), templateOnly());
4398
+ const CardItem = setComponentTemplate(precompileTemplate("{{~yield @item~}}", {
4399
+ strictMode: true
4400
+ }), templateOnly());
4401
+ /** Yields the declarations of card mode: only `<b.Card>` renders its block, with `@item`. */
4402
+ const CardMode = setComponentTemplate(precompileTemplate("{{~yield (hash Lane=Nothing Card=(component CardItem item=@item))~}}", {
4403
+ strictMode: true,
4404
+ scope: () => ({
4405
+ hash,
4406
+ Nothing,
4407
+ CardItem
4408
+ })
4409
+ }), templateOnly());
4410
+
4411
+ // LatticeBoard: the Board surface (docs/prd/2026-12-01-m3-list-board-contract/index.html, section 2). Each lane is a
3473
4412
  // LatticeList listbox. A move is an edit: the board calls @onMove and does not change @items.
3474
4413
  // While the move promise is in progress, the card shows its new place (an override).
4414
+ //
4415
+ // Two forms give the lanes. The engine form gives `@lanes` and `@laneLabel`, and the block is the
4416
+ // content of a card. The template form (ADR 0028, FR-10) has no `@lanes`: the block declares the
4417
+ // lanes with `<b.Lane>` and the card content with `<b.Card>` (`./declarations.gts`).
3475
4418
  /** A press must move this far, in px, before it becomes a drag. */const DRAG_THRESHOLD = 4;
3476
4419
  /** The pointer scrolls a lane when it is this near (client px) to the top or the bottom edge. */
3477
4420
  const SCROLL_EDGE = 32;
@@ -3487,6 +4430,16 @@ const SIDES = {
3487
4430
  };
3488
4431
  const px = n => `${Math.round(n * 100) / 100}px`;
3489
4432
  const sameLane = (a, b) => Object.is(a, b);
4433
+ /** The default item ID: the `id` key of the item, as text. */
4434
+ function defaultItemId(item) {
4435
+ const id = is.object(item) ? item['id'] : undefined;
4436
+ assert('LatticeBoard: give @getItemId, or items with an `id` key', is.string(id) || is.number(id) || is.bigint(id));
4437
+ return String(id);
4438
+ }
4439
+ /** The keys that are in the list more than one time. */
4440
+ function duplicateKeys(keys) {
4441
+ return keys.filter((key, i) => keys.findIndex(other => sameLane(other, key)) !== i);
4442
+ }
3490
4443
  /** The rendered options of a lane, in index order. */
3491
4444
  const optionsIn = (lane, skip) => [...lane.querySelectorAll('.lt-list-item')].filter(el => el.dataset['itemId'] !== skip).sort((a, b) => Number(a.dataset['index']) - Number(b.dataset['index']));
3492
4445
  class LatticeBoard extends Component {
@@ -3520,6 +4473,8 @@ class LatticeBoard extends Component {
3520
4473
  _focusId = null;
3521
4474
  _suppressClick = false;
3522
4475
  _endDrag = null;
4476
+ /** The template form: the `<b.Lane>` declarations of the block. */
4477
+ registry = laneRegistry();
3523
4478
  constructor(owner, args) {
3524
4479
  super(owner, args);
3525
4480
  registerDestructor(this, () => this._endDrag?.());
@@ -3527,15 +4482,47 @@ class LatticeBoard extends Component {
3527
4482
  get boardId() {
3528
4483
  return guidFor(this);
3529
4484
  }
4485
+ /** True in the template form: the block declares the lanes and the card. */
4486
+ get declared() {
4487
+ return this.args.lanes === undefined;
4488
+ }
4489
+ /** The block value of its form: the type of the block depends on `@lanes` (`L`). */
4490
+ asBlock = value => value;
4491
+ // The template form reads the registry. Nothing reads it before the declarations block, which
4492
+ // renders before `div.lt-board`: a registration writes tracked state (ADR 0028).
4493
+ /** The lane keys, in order: `@lanes`, or the `<b.Lane>` declarations in template order. */
4494
+ get laneKeys() {
4495
+ const lanes = this.args.lanes;
4496
+ if (lanes !== undefined) return lanes;
4497
+ const keys = this.registry.items.map(lane => lane.key);
4498
+ const twice = duplicateKeys(keys);
4499
+ assert(`LatticeBoard "${this.args.label}": two lanes have the key "${twice.map(String).join('", "')}"`, twice.length === 0);
4500
+ return keys;
4501
+ }
4502
+ /** The template form: the declared lanes by key. */
4503
+ static {
4504
+ n(this.prototype, "laneKeys", [cached]);
4505
+ }
4506
+ get declaredLanes() {
4507
+ return new Map(this.registry.items.map(lane => [lane.key, lane]));
4508
+ }
4509
+ /** The label of a lane: `@laneLabel`, or the `@label` of its declaration. */
4510
+ static {
4511
+ n(this.prototype, "declaredLanes", [cached]);
4512
+ }
4513
+ labelOf(lane) {
4514
+ if (!this.declared) return this.args.laneLabel?.(lane) ?? String(lane);
4515
+ return this.declaredLanes.get(lane)?.label ?? String(lane);
4516
+ }
3530
4517
  get itemById() {
3531
- return new Map(this.args.items.map(item => [this.args.getItemId(item), item]));
4518
+ return new Map(this.args.items.map(item => [this.idOf(item), item]));
3532
4519
  }
3533
4520
  /** The items of each lane, from the data only. */
3534
4521
  static {
3535
4522
  n(this.prototype, "itemById", [cached]);
3536
4523
  }
3537
4524
  get baseLanes() {
3538
- const lanes = new Map(this.args.lanes.map(key => [key, []]));
4525
+ const lanes = new Map(this.laneKeys.map(key => [key, []]));
3539
4526
  for (const item of this.args.items) lanes.get(this.args.laneOf(item))?.push(item);
3540
4527
  return lanes;
3541
4528
  }
@@ -3564,18 +4551,28 @@ class LatticeBoard extends Component {
3564
4551
  }
3565
4552
  get laneViews() {
3566
4553
  const lanes = this.laneItems;
3567
- return this.args.lanes.map((key, i) => ({
3568
- key,
3569
- dataLane: String(key),
3570
- label: this.args.laneLabel(key),
3571
- titleId: `${this.boardId}-lane-${i}`,
3572
- items: lanes.get(key) ?? []
3573
- }));
4554
+ return this.laneKeys.map((key, i) => {
4555
+ const label = this.labelOf(key);
4556
+ const items = lanes.get(key) ?? [];
4557
+ const header = this.declared && this.declaredLanes.get(key)?.hasHeader === true;
4558
+ return {
4559
+ key,
4560
+ dataLane: String(key),
4561
+ label,
4562
+ titleId: `${this.boardId}-lane-${i}`,
4563
+ items,
4564
+ header: header ? {
4565
+ key,
4566
+ label,
4567
+ count: items.length
4568
+ } : null
4569
+ };
4570
+ });
3574
4571
  }
3575
4572
  static {
3576
4573
  n(this.prototype, "laneViews", [cached]);
3577
4574
  }
3578
- idOf = item => this.args.getItemId(item);
4575
+ idOf = item => this.args.getItemId?.(item) ?? defaultItemId(item);
3579
4576
  get headingLevel() {
3580
4577
  return this.args.headingLevel ?? 3;
3581
4578
  }
@@ -3618,7 +4615,7 @@ class LatticeBoard extends Component {
3618
4615
  }
3619
4616
  /** The params of a place in a message: the lane label, the position and the card count. */
3620
4617
  where(place) {
3621
- const lane = this.args.laneLabel(place.lane);
4618
+ const lane = this.labelOf(place.lane);
3622
4619
  return {
3623
4620
  lane,
3624
4621
  position: place.index + 1,
@@ -3652,7 +4649,7 @@ class LatticeBoard extends Component {
3652
4649
  if (failed) {
3653
4650
  this.message = this.l.t('board.moveFailed', {
3654
4651
  card: card.name,
3655
- lane: this.args.laneLabel(card.from.lane)
4652
+ lane: this.labelOf(card.from.lane)
3656
4653
  });
3657
4654
  }
3658
4655
  };
@@ -3711,7 +4708,7 @@ class LatticeBoard extends Component {
3711
4708
  return lane !== null && lane.parentElement === this._root ? target : null;
3712
4709
  }
3713
4710
  laneElement(lane) {
3714
- const index = this.args.lanes.indexOf(lane);
4711
+ const index = this.laneKeys.indexOf(lane);
3715
4712
  return this._root?.querySelectorAll(':scope > .lt-board-lane')[index] ?? null;
3716
4713
  }
3717
4714
  // In the capture phase: the lane listbox must not see Space (select) or the arrows of a move.
@@ -3813,7 +4810,7 @@ class LatticeBoard extends Component {
3813
4810
  /** Move to the next or the previous lane, at the height of the card in the view. */
3814
4811
  moveToLane(held, option, side) {
3815
4812
  const place = this.placeOf(held.id);
3816
- const lane = place === null ? undefined : this.args.lanes[this.args.lanes.indexOf(place.lane) + side];
4813
+ const lane = place === null ? undefined : this.laneKeys[this.laneKeys.indexOf(place.lane) + side];
3817
4814
  const laneEl = lane === undefined ? null : this.laneElement(lane);
3818
4815
  if (lane === undefined || laneEl === null) return;
3819
4816
  const top = option.getBoundingClientRect().top;
@@ -3971,7 +4968,7 @@ class LatticeBoard extends Component {
3971
4968
  let to = null;
3972
4969
  let line = 0;
3973
4970
  const laneEls = root.querySelectorAll(':scope > .lt-board-lane');
3974
- for (const [i, lane] of this.args.lanes.entries()) {
4971
+ for (const [i, lane] of this.laneKeys.entries()) {
3975
4972
  const laneEl = laneEls[i];
3976
4973
  const box = laneEl?.getBoundingClientRect();
3977
4974
  if (laneEl === undefined || box === undefined || x < box.left || x >= box.right) continue;
@@ -4016,16 +5013,19 @@ class LatticeBoard extends Component {
4016
5013
  this.stop(event);
4017
5014
  };
4018
5015
  static {
4019
- setComponentTemplate(precompileTemplate("<div class=\"lt-board\" role=\"region\" aria-label={{@label}} {{this.setup}} {{on \"keydown\" this.onKeyDown capture=true}} {{on \"click\" this.onClick capture=true}} {{on \"pointerdown\" this.onPointerDown}} {{on \"focusout\" this.onFocusOut}} ...attributes>\n {{#each this.laneViews key=\"dataLane\" as |lane|}}\n <div class=\"lt-board-lane\" role=\"group\" aria-labelledby={{lane.titleId}} data-lane={{lane.dataLane}}>\n {{!-- Glimmer has no dynamic tag, so the title is a heading by role at any level. --}}\n <div class=\"lt-board-lane-title\" id={{lane.titleId}} role=\"heading\" aria-level={{this.headingLevel}}>\n {{lane.label}}\n <span class=\"lt-board-lane-count\">{{lane.items.length}}</span>\n </div>\n <LatticeList @items={{lane.items}} @label={{lane.label}} @role=\"listbox\" @getItemId={{@getItemId}} @estimateSize={{@estimateSize}} @localeText={{@localeText}} as |item index|>\n {{!-- A touch pan on a card starts a drag: the browser does not scroll. --}}\n <div class=\"lt-board-card\" style=\"touch-action: none\" {{this.card (this.idOf item) this.heldId index}}>\n {{yield item}}\n </div>\n </LatticeList>\n {{#let (this.lineFor lane.key) as |line|}}\n {{#if line}}\n <div class=\"lt-board-drop-line\" style={{line}}></div>\n {{/if}}\n {{/let}}\n </div>\n {{/each}}\n <div class=\"lt-board-live\" aria-live=\"assertive\" {{visuallyHidden}}>{{this.message}}</div>\n {{#if this.drag}}\n <div class=\"lt-board-drag-preview\" aria-hidden=\"true\" style={{this.previewStyle}}>\n {{yield this.drag.item}}\n </div>\n {{/if}}\n</div>", {
5016
+ setComponentTemplate(precompileTemplate("{{!-- The template form (ADR 0028): the declarations render first, and render no element. --}}\n{{~#if this.declared~}}\n <DeclareMode @registry={{this.registry}} as |b|>{{yield (this.asBlock b)}}</DeclareMode>\n{{~/if~}}\n<div class=\"lt-board\" role=\"region\" aria-label={{@label}} {{this.setup}} {{on \"keydown\" this.onKeyDown capture=true}} {{on \"click\" this.onClick capture=true}} {{on \"pointerdown\" this.onPointerDown}} {{on \"focusout\" this.onFocusOut}} ...attributes>\n {{#each this.laneViews key=\"dataLane\" as |lane|}}\n <div class=\"lt-board-lane\" role=\"group\" aria-labelledby={{lane.titleId}} data-lane={{lane.dataLane}}>\n {{!-- Glimmer has no dynamic tag, so the title is a heading by role at any level. --}}\n <div class=\"lt-board-lane-title\" id={{lane.titleId}} role=\"heading\" aria-level={{this.headingLevel}}>\n {{#if lane.header}}\n <HeaderMode @target={{lane.key}} @ctx={{lane.header}} as |b|>{{yield (this.asBlock b)}}</HeaderMode>\n {{else}}\n {{lane.label}}\n <span class=\"lt-board-lane-count\">{{lane.items.length}}</span>\n {{/if}}\n </div>\n <LatticeList @items={{lane.items}} @label={{lane.label}} @role=\"listbox\" @getItemId={{this.idOf}} @estimateSize={{@estimateSize}} @localeText={{@localeText}} as |item index|>\n {{!-- A touch pan on a card starts a drag: the browser does not scroll. --}}\n <div class=\"lt-board-card\" style=\"touch-action: none\" {{this.card (this.idOf item) this.heldId index}}>\n {{#if this.declared}}\n <CardMode @item={{item}} as |b|>{{yield (this.asBlock b)}}</CardMode>\n {{else}}\n {{yield (this.asBlock item)}}\n {{/if}}\n </div>\n </LatticeList>\n {{#let (this.lineFor lane.key) as |line|}}\n {{#if line}}\n <div class=\"lt-board-drop-line\" style={{line}}></div>\n {{/if}}\n {{/let}}\n </div>\n {{/each}}\n <div class=\"lt-board-live\" aria-live=\"assertive\" {{visuallyHidden}}>{{this.message}}</div>\n {{#if this.drag}}\n <div class=\"lt-board-drag-preview\" aria-hidden=\"true\" style={{this.previewStyle}}>\n {{#if this.declared}}\n <CardMode @item={{this.drag.item}} as |b|>{{yield (this.asBlock b)}}</CardMode>\n {{else}}\n {{yield (this.asBlock this.drag.item)}}\n {{/if}}\n </div>\n {{/if}}\n</div>", {
4020
5017
  strictMode: true,
4021
5018
  scope: () => ({
5019
+ DeclareMode,
4022
5020
  on,
5021
+ HeaderMode,
4023
5022
  LatticeList,
5023
+ CardMode,
4024
5024
  visuallyHidden
4025
5025
  })
4026
5026
  }), this);
4027
5027
  }
4028
5028
  }
4029
5029
 
4030
- export { CellState, CellStateStore, GridAlignment, GridStateHandle, LatticeBoard, LatticeGrid, LatticeList, autoColumns, rowNumberColumn, selectionColumn };
5030
+ export { CellState, CellStateStore, DEFAULT_GRID_FEATURES, ColumnRegistry as DeclarationRegistry, GridAlignment, GridStateHandle, LatticeBoard, LatticeGrid, LatticeList, autoColumns, columnDefOf, rowNumberColumn, selectionColumn };
4031
5031
  //# sourceMappingURL=index.js.map