apex-grid 3.6.0 → 4.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/CHANGELOG.md +301 -0
  2. package/LICENSE.md +2 -1
  3. package/README.md +117 -18
  4. package/components/cell.d.ts +13 -1
  5. package/components/cell.js +28 -13
  6. package/components/cell.js.map +1 -1
  7. package/components/grid.d.ts +175 -28
  8. package/components/grid.js +183 -63
  9. package/components/grid.js.map +1 -1
  10. package/components/header-row.d.ts +0 -6
  11. package/components/header-row.js +1 -19
  12. package/components/header-row.js.map +1 -1
  13. package/components/header.js +39 -2
  14. package/components/header.js.map +1 -1
  15. package/components/paginator.d.ts +20 -5
  16. package/components/paginator.js +54 -17
  17. package/components/paginator.js.map +1 -1
  18. package/components/row.js +149 -40
  19. package/components/row.js.map +1 -1
  20. package/components/toolbar.d.ts +5 -1
  21. package/components/toolbar.js +4 -1
  22. package/components/toolbar.js.map +1 -1
  23. package/components/virtualize-rows.d.ts +38 -0
  24. package/components/virtualize-rows.js +286 -0
  25. package/components/virtualize-rows.js.map +1 -0
  26. package/components/virtualizer.d.ts +71 -1
  27. package/components/virtualizer.js +105 -29
  28. package/components/virtualizer.js.map +1 -1
  29. package/controllers/dom.d.ts +10 -3
  30. package/controllers/dom.js +5 -5
  31. package/controllers/dom.js.map +1 -1
  32. package/controllers/navigation.d.ts +63 -0
  33. package/controllers/navigation.js +295 -21
  34. package/controllers/navigation.js.map +1 -1
  35. package/controllers/pagination.d.ts +7 -6
  36. package/controllers/pagination.js +27 -28
  37. package/controllers/pagination.js.map +1 -1
  38. package/controllers/row-pin.d.ts +6 -0
  39. package/controllers/row-pin.js +8 -2
  40. package/controllers/row-pin.js.map +1 -1
  41. package/controllers/row-reorder.d.ts +12 -4
  42. package/controllers/row-reorder.js +20 -6
  43. package/controllers/row-reorder.js.map +1 -1
  44. package/controllers/selection.d.ts +32 -10
  45. package/controllers/selection.js +33 -10
  46. package/controllers/selection.js.map +1 -1
  47. package/controllers/sort.js +2 -3
  48. package/controllers/sort.js.map +1 -1
  49. package/controllers/state.d.ts +18 -5
  50. package/controllers/state.js +53 -46
  51. package/controllers/state.js.map +1 -1
  52. package/custom-elements.json +1762 -339
  53. package/docs/assets/hierarchy.js +1 -1
  54. package/docs/assets/search.js +1 -1
  55. package/docs/classes/ApexGrid.html +166 -66
  56. package/docs/classes/ApexGridPaginator.html +39 -8
  57. package/docs/classes/ApexGridToolbar.html +9 -5
  58. package/docs/functions/localize.html +2 -2
  59. package/docs/hierarchy.html +1 -1
  60. package/docs/index.html +123 -20
  61. package/docs/interfaces/ApexPageChangedEvent.html +3 -1
  62. package/docs/interfaces/BaseApexCellContext.html +18 -5
  63. package/docs/interfaces/BaseApexEditorContext.html +20 -5
  64. package/docs/interfaces/BaseFilterExpression.html +1 -1
  65. package/docs/interfaces/CSVExportOptions.html +1 -1
  66. package/docs/interfaces/DataPipelineConfiguration.html +4 -9
  67. package/docs/interfaces/ExportOptions.html +1 -1
  68. package/docs/interfaces/GridSelectionConfiguration.html +19 -4
  69. package/docs/interfaces/PaginationConfiguration.html +11 -4
  70. package/docs/interfaces/PaginationState.html +4 -2
  71. package/docs/media/_token-values.scss +42 -16
  72. package/docs/media/package.json +12 -4
  73. package/docs/types/DataPipelineParams.html +2 -2
  74. package/docs/types/PaginationMode.html +5 -4
  75. package/docs/variables/EN_LOCALE.html +2 -2
  76. package/i18n/en.d.ts +2 -0
  77. package/i18n/en.js +2 -0
  78. package/i18n/en.js.map +1 -1
  79. package/i18n/es.js +2 -0
  80. package/i18n/es.js.map +1 -1
  81. package/ignite-ui.d.ts +1 -0
  82. package/ignite-ui.js +4 -0
  83. package/ignite-ui.js.map +1 -0
  84. package/internal/column-types.d.ts +11 -1
  85. package/internal/column-types.js +8 -6
  86. package/internal/column-types.js.map +1 -1
  87. package/internal/design-system.d.ts +32 -0
  88. package/internal/design-system.js +66 -0
  89. package/internal/design-system.js.map +1 -0
  90. package/internal/export.d.ts +6 -0
  91. package/internal/export.js +4 -0
  92. package/internal/export.js.map +1 -1
  93. package/internal/feature-module.d.ts +7 -0
  94. package/internal/feature-module.js.map +1 -1
  95. package/internal/flip.d.ts +28 -16
  96. package/internal/flip.js +42 -10
  97. package/internal/flip.js.map +1 -1
  98. package/internal/icons.d.ts +2 -16
  99. package/internal/icons.js +0 -8
  100. package/internal/icons.js.map +1 -1
  101. package/internal/ignite-ui.d.ts +10 -0
  102. package/internal/ignite-ui.js +118 -0
  103. package/internal/ignite-ui.js.map +1 -0
  104. package/internal/index.d.ts +4 -2
  105. package/internal/index.js +3 -2
  106. package/internal/index.js.map +1 -1
  107. package/internal/types.d.ts +75 -19
  108. package/internal/types.js.map +1 -1
  109. package/operations/filter/types.d.ts +1 -1
  110. package/operations/filter/types.js.map +1 -1
  111. package/package.json +7 -2
  112. package/styles/_token-blocks.css.d.ts +1 -0
  113. package/styles/_token-blocks.css.js +3 -0
  114. package/styles/_token-blocks.css.js.map +1 -0
  115. package/styles/_tokens.css.js +1 -1
  116. package/styles/_tokens.css.js.map +1 -1
  117. package/styles/body-cell/body-cell.css.js +1 -1
  118. package/styles/body-cell/body-cell.css.js.map +1 -1
  119. package/styles/body-cell/cell-renderers.css.js +1 -1
  120. package/styles/body-cell/cell-renderers.css.js.map +1 -1
  121. package/styles/body-row/body-row.css.js +1 -1
  122. package/styles/body-row/body-row.css.js.map +1 -1
  123. package/styles/document-tokens.css.js +1 -1
  124. package/styles/document-tokens.css.js.map +1 -1
  125. package/styles/grid/_grid.base.css.js +1 -1
  126. package/styles/grid/_grid.base.css.js.map +1 -1
  127. package/styles/grid/grid.css.js +1 -1
  128. package/styles/grid/grid.css.js.map +1 -1
  129. package/styles/group-header-row/group-header-row.css.js +1 -1
  130. package/styles/group-header-row/group-header-row.css.js.map +1 -1
  131. package/styles/header-cell/header-cell.css.js +1 -1
  132. package/styles/header-cell/header-cell.css.js.map +1 -1
  133. package/styles/header-row/header-row.base.css.js +1 -1
  134. package/styles/header-row/header-row.base.css.js.map +1 -1
  135. package/styles/ignite-ui/ignite-ui-dark.css.d.ts +1 -0
  136. package/styles/ignite-ui/ignite-ui-dark.css.js +3 -0
  137. package/styles/ignite-ui/ignite-ui-dark.css.js.map +1 -0
  138. package/styles/ignite-ui/ignite-ui-document.css.d.ts +1 -0
  139. package/styles/ignite-ui/ignite-ui-document.css.js +3 -0
  140. package/styles/ignite-ui/ignite-ui-document.css.js.map +1 -0
  141. package/styles/ignite-ui/ignite-ui.css.d.ts +1 -0
  142. package/styles/ignite-ui/ignite-ui.css.js +3 -0
  143. package/styles/ignite-ui/ignite-ui.css.js.map +1 -0
  144. package/styles/paginator/paginator.css.js +1 -1
  145. package/styles/paginator/paginator.css.js.map +1 -1
  146. package/styles/toolbar/toolbar.css.js +1 -1
  147. package/styles/toolbar/toolbar.css.js.map +1 -1
  148. package/tokens.css +14 -15
  149. package/operations/pagination.d.ts +0 -19
  150. package/operations/pagination.js +0 -12
  151. package/operations/pagination.js.map +0 -1
@@ -4,7 +4,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- var _a;
8
7
  import { consume } from '@lit/context';
9
8
  import { html, LitElement } from 'lit';
10
9
  import { property, query } from 'lit/decorators.js';
@@ -62,7 +61,7 @@ function scrollRowIntoRange(scroller, body, index) {
62
61
  const rowCentre = top + (index - first.index + 0.5) * height;
63
62
  scroller.scrollTop += rowCentre - (view.top + scroller.clientHeight / 2);
64
63
  }
65
- class ApexGridCell extends LitElement {
64
+ export default class ApexGridCell extends LitElement {
66
65
  constructor() {
67
66
  super(...arguments);
68
67
  this.active = false;
@@ -77,6 +76,7 @@ class ApexGridCell extends LitElement {
77
76
  this.#staged = false;
78
77
  this.#resumed = null;
79
78
  this.#reconnected = false;
79
+ this.#rebound = false;
80
80
  this.#handleClick = (event) => {
81
81
  if (this.isEditing) {
82
82
  event.stopPropagation();
@@ -170,17 +170,20 @@ class ApexGridCell extends LitElement {
170
170
  }
171
171
  static { this.styles = styles; }
172
172
  static register() {
173
- registerComponent(_a);
173
+ registerComponent(ApexGridCell);
174
174
  }
175
175
  get context() {
176
+ const data = this.row.data;
177
+ const key = this.column.key;
176
178
  const ctx = {
177
179
  parent: this,
178
180
  row: this.row,
179
181
  column: this.column,
180
182
  value: this.value,
183
+ data,
181
184
  };
182
185
  if (this.isEditable) {
183
- ctx.commit = (next) => this.editingController.commitImmediate(this.row.data, this.column.key, next);
186
+ ctx.commit = (next) => this.editingController.commitImmediate(data, key, next);
184
187
  }
185
188
  return ctx;
186
189
  }
@@ -199,12 +202,15 @@ class ApexGridCell extends LitElement {
199
202
  const pin = this.state.rowPin;
200
203
  return pin.hasPinnedRows && pin.enabled && pin.isPinned(this.row.data);
201
204
  }
205
+ get #recycledBody() {
206
+ return Boolean(this.state.host.rowRecycling) && !this.#inPinnedBand;
207
+ }
202
208
  #decoratedKeys;
203
- static #ERROR_ID = 'apex-cell-error';
204
209
  #errors;
205
210
  #staged;
206
211
  #resumed;
207
212
  #reconnected;
213
+ #rebound;
208
214
  connectedCallback() {
209
215
  this.#reconnected = this.hasUpdated && !this.isUpdatePending;
210
216
  super.connectedCallback();
@@ -238,8 +244,9 @@ class ApexGridCell extends LitElement {
238
244
  return false;
239
245
  }
240
246
  willUpdate(changed) {
247
+ this.#rebound = this.hasUpdated && changed.has('record');
241
248
  this.#applyStaged();
242
- if (changed.has('editing')) {
249
+ if (changed.has('editing') || this.#rebound) {
243
250
  this.#resumed = this.editing
244
251
  ? this.editingController.heldDraft(this.row.data, this.column.key)
245
252
  : null;
@@ -289,13 +296,11 @@ class ApexGridCell extends LitElement {
289
296
  this.#errors = errors && errors.length > 0 ? errors : null;
290
297
  if (this.#errors) {
291
298
  this.setAttribute('aria-invalid', 'true');
292
- this.setAttribute('aria-errormessage', _a.#ERROR_ID);
293
299
  this.setAttribute('data-invalid', '');
294
300
  this.setAttribute('title', this.#errors.join('; '));
295
301
  }
296
302
  else {
297
303
  this.removeAttribute('aria-invalid');
298
- this.removeAttribute('aria-errormessage');
299
304
  this.removeAttribute('data-invalid');
300
305
  this.removeAttribute('title');
301
306
  }
@@ -305,12 +310,13 @@ class ApexGridCell extends LitElement {
305
310
  return null;
306
311
  return html `<span
307
312
  part="cell-error"
308
- id=${_a.#ERROR_ID}
309
313
  role="alert"
310
314
  >${this.#errors.join('; ')}</span
311
315
  >`;
312
316
  }
313
317
  #applyDecoration() {
318
+ if (!this.state?.hasCellDecorators && !this.#decoratedKeys.length)
319
+ return;
314
320
  const decoration = this.state && this.row
315
321
  ? this.state.decorateCell({
316
322
  row: this.row.data,
@@ -341,8 +347,13 @@ class ApexGridCell extends LitElement {
341
347
  if (!changed.has('editing'))
342
348
  return;
343
349
  const editor = this.editorElement;
344
- editor?.focus();
345
- if (editor instanceof HTMLInputElement) {
350
+ const resumed = this.#resumed !== null || this.#rebound;
351
+ if (resumed && this.#recycledBody && !this.state.navigation.ownsFocus)
352
+ return;
353
+ if (resumed)
354
+ editor?.getBoundingClientRect();
355
+ editor?.focus(resumed ? { preventScroll: true } : undefined);
356
+ if (!resumed && editor instanceof HTMLInputElement) {
346
357
  if (editor.type === 'text' || editor.type === 'number') {
347
358
  editor.select();
348
359
  }
@@ -351,6 +362,8 @@ class ApexGridCell extends LitElement {
351
362
  }
352
363
  if (changed.get('editing') === true && this.#refocusAfterEdit) {
353
364
  this.#refocusAfterEdit = false;
365
+ if (this.#rebound && this.editingController.activeCell)
366
+ return;
354
367
  this.focus();
355
368
  }
356
369
  }
@@ -482,6 +495,7 @@ class ApexGridCell extends LitElement {
482
495
  row: this.row,
483
496
  column: this.column,
484
497
  value: this.#editorValue,
498
+ data: this.row.data,
485
499
  commit: (next) => this.editingController.commitCell(next),
486
500
  cancel: () => this.editingController.cancelCell(),
487
501
  setDraft: (next) => this.editingController.setDraft(next),
@@ -586,11 +600,12 @@ class ApexGridCell extends LitElement {
586
600
  return html `${this.renderCellBody()}${error}`;
587
601
  }
588
602
  }
589
- _a = ApexGridCell;
590
- export default ApexGridCell;
591
603
  __decorate([
592
604
  property({ attribute: false })
593
605
  ], ApexGridCell.prototype, "value", void 0);
606
+ __decorate([
607
+ property({ attribute: false })
608
+ ], ApexGridCell.prototype, "record", void 0);
594
609
  __decorate([
595
610
  property({ attribute: false })
596
611
  ], ApexGridCell.prototype, "column", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"cell.js","sourceRoot":"","sources":["../../src/components/cell.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAuB,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAwB,MAAM,yBAAyB,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAQlE,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAU9D,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,OAAQ,KAA4B,CAAC,IAAI,KAAK,QAAQ;QACrD,KAA0B,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CACjD,CAAC;AACJ,CAAC;AAGD,SAAS,YAAY,CAAmB,IAAoB;IAC1D,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC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;eA/vBkB,YAAY;AAexB;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;2CACA;AAMxB;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;4CACQ;AAOhC;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CACrB;AAOf;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;6CACpB;AAIhB;IAFN,OAAO,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACvD,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;2CACG;AAQxB;IADT,KAAK,CAAC,2BAA2B,CAAC;mDACU;AAgDtC;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CACzB;AAWb;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;8CACV;AASd;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAChB;AAUtB;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;iDACR;AAShB;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAChB","sourcesContent":["import { consume } from '@lit/context';\nimport { html, LitElement, type PropertyValues } from 'lit';\nimport { property, query } from 'lit/decorators.js';\nimport { gridStateContext, type StateController } from '../controllers/state.js';\nimport { getColumnTypeRenderer } from '../internal/column-types.js';\nimport { registerComponent } from '../internal/register.js';\nimport { GRID_CELL_TAG, GRID_ROW_TAG } from '../internal/tags.js';\nimport type {\n ActiveNode,\n ApexCellContext,\n ApexEditorContext,\n ColumnConfiguration,\n PropertyType,\n} from '../internal/types.js';\nimport { styles } from '../styles/body-cell/body-cell.css.js';\nimport type ApexGridRow from './row.js';\n\n/**\n * A spreadsheet-style error value (e.g. the enterprise formula engine's\n * `#VALUE!` / `#DIV/0!`). Duck-typed so core carries no dependency on the\n * enterprise layer: any value that is an object carrying a `#...` string `code`\n * is rendered as that code, even in a typed (currency / number) column whose\n * numeric renderer would otherwise coerce it to `NaN` and show nothing.\n */\nfunction isErrorLike(value: unknown): value is { code: string } {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as { code?: unknown }).code === 'string' &&\n (value as { code: string }).code.startsWith('#')\n );\n}\n\n/** The body rows rendered under `body` (the rows' shared parent). */\nfunction renderedRows<T extends object>(body: Element | null): ApexGridRow<T>[] {\n if (!body) return [];\n return Array.from(body.children).filter(\n (element) => element.localName === GRID_ROW_TAG\n ) as unknown as ApexGridRow<T>[];\n}\n\n/**\n * The cell Tab moves to from column `key` of view row `from`: the neighbouring\n * column (`keys`) of that row or, past the row edge, the first (or last) column\n * of the nearest row in that direction that renders cells, skipping full-width\n * rows. `null` at the edge of the grid's `count` view rows.\n */\nfunction tabTarget<T extends object>(\n count: number,\n from: number,\n keys: ColumnConfiguration<T>['key'][],\n key: ColumnConfiguration<T>['key'],\n step: 1 | -1,\n isFullWidth: (index: number) => boolean\n): ActiveNode<T> | null {\n const column = keys[keys.indexOf(key) + step];\n if (column !== undefined) return { row: from, column };\n const wrapColumn = keys[step > 0 ? 0 : keys.length - 1];\n for (let index = from + step; index >= 0 && index < count; index += step) {\n if (!isFullWidth(index)) return { row: index, column: wrapColumn };\n }\n return null;\n}\n\n/**\n * The view row nearest `start` (clamped to the `count` rows) that renders\n * cells, looking in the `step` direction first. `-1` when none does.\n */\nfunction nearestCellRow(\n count: number,\n start: number,\n step: 1 | -1,\n isFullWidth: (index: number) => boolean\n): number {\n const origin = Math.min(Math.max(start, 0), count - 1);\n for (let distance = 0; distance < count; distance++) {\n for (const index of [origin + distance * step, origin - distance * step]) {\n if (index >= 0 && index < count && !isFullWidth(index)) return index;\n }\n }\n return -1;\n}\n\n/** The rendered cell for `node` under `body`, if its row is rendered. */\nfunction findRenderedCell<T extends object>(body: Element | null, node: ActiveNode<T>) {\n return renderedRows<T>(body)\n .find((row) => row.index === node.row)\n ?.cells.find((cell) => cell.column.key === node.column);\n}\n\n/**\n * Scrolls `scroller` (the grid host, which owns the body's scrolling) so view\n * row `index`, outside the rows rendered under `body`, lands about mid-view,\n * placing it from the rendered rows' positions and average height. The\n * virtualizer then renders it on the scroll and the landed cell is aligned\n * exactly. (The virtualizer's own `element(index).scrollIntoView()` pin does\n * not work with the grid host as the scroller: it jumps to the end of the\n * range and renders no rows.)\n */\nfunction scrollRowIntoRange(scroller: HTMLElement, body: Element | null, index: number) {\n const rows = renderedRows(body).sort((a, b) => a.index - b.index);\n const first = rows.at(0);\n const last = rows.at(-1);\n if (!first || !last) return;\n const top = first.getBoundingClientRect().top;\n const height = (last.getBoundingClientRect().bottom - top) / (last.index - first.index + 1);\n const view = scroller.getBoundingClientRect();\n const rowCentre = top + (index - first.index + 0.5) * height;\n scroller.scrollTop += rowCentre - (view.top + scroller.clientHeight / 2);\n}\n\n/**\n * Component representing a DOM cell of the Apex grid.\n *\n * @csspart cell - The cell host element.\n * @csspart editor - The editor wrapper rendered while the cell is in edit mode.\n */\nexport default class ApexGridCell<T extends object> extends LitElement {\n public static get tagName() {\n return GRID_CELL_TAG;\n }\n\n public static override styles = styles;\n\n public static register(): void {\n registerComponent(ApexGridCell);\n }\n\n /**\n * The value which will be rendered by the component.\n */\n @property({ attribute: false })\n public value!: PropertyType<T>;\n\n /**\n * A reference to the column configuration object.\n */\n @property({ attribute: false })\n public column!: ColumnConfiguration<T>;\n\n /**\n * Indicates whether this is the active cell in the grid.\n *\n */\n @property({ type: Boolean, reflect: true })\n public active = false;\n\n /**\n * Whether the cell is currently in edit mode. Set by the parent row from the\n * editing controller's state so cells re-render on edit state changes.\n */\n @property({ type: Boolean, reflect: true })\n public editing = false;\n\n @consume({ context: gridStateContext, subscribe: true })\n @property({ attribute: false })\n public state!: StateController<T>;\n\n /**\n * The parent row component holding this cell.\n */\n public row!: ApexGridRow<T>;\n\n @query('input, [data-apex-editor]')\n protected editorElement!: HTMLElement | null;\n\n protected get context(): ApexCellContext<T> {\n const ctx = {\n parent: this,\n row: this.row,\n column: this.column,\n value: this.value,\n } as unknown as {\n parent: ApexGridCell<T>;\n row: ApexGridRow<T>;\n column: ColumnConfiguration<T>;\n value: PropertyType<T>;\n commit?: (value: unknown) => Promise<boolean>;\n };\n // Only expose `commit` when the column is editable — non-editable\n // interactive widgets should render as read-only.\n if (this.isEditable) {\n ctx.commit = (next: unknown) =>\n this.editingController.commitImmediate(this.row.data, this.column.key, next);\n }\n return ctx as unknown as ApexCellContext<T>;\n }\n\n protected get editingController() {\n return this.state.editing;\n }\n\n protected get isEditing(): boolean {\n return this.editing;\n }\n\n protected get isEditable(): boolean {\n if (!this.editingController) return false;\n return this.editingController.isEditable(this.column);\n }\n\n /** Whether the cell's row renders in a pinned band rather than the body. */\n get #inPinnedBand(): boolean {\n const pin = this.state.rowPin;\n return pin.hasPinnedRows && pin.enabled && pin.isPinned(this.row.data);\n }\n\n /**\n * 1-based column index used to populate `aria-colindex`. Accounts for the\n * auto-rendered selection + expansion columns ahead of the data columns.\n */\n @property({ attribute: false, type: Number })\n public colindex = 0;\n\n /**\n * The parent row's view index, set by the row. Changing it re-decorates the\n * cell (decoration such as a range selection is positional), so a row that\n * moves with the same data (sort, filter, an expand above it) never keeps a\n * stale highlight.\n *\n * @internal\n */\n @property({ attribute: false })\n public rowIndex = -1;\n\n /**\n * Reactive token forwarded from {@link StateController.decorationVersion}.\n * Changing it re-applies module-driven cell decoration (e.g. while dragging a\n * selection range) without re-rendering the cell content. Stays `0` for the\n * community grid, so cells are never re-decorated there.\n */\n @property({ attribute: false, type: Number })\n public decorationVersion = 0;\n\n /**\n * Reactive token forwarded from {@link StateController.dataVersion}, bumped\n * once per pipeline run. Re-renders only a cell that reads its row beyond\n * its own value (see {@link shouldUpdate}).\n *\n * @internal\n */\n @property({ attribute: false })\n public dataVersion = 0;\n\n /**\n * Reactive token forwarded from {@link EditingController.validationVersion}.\n * Changing it re-runs {@link willUpdate} so the cell re-reads its validation\n * errors and toggles `aria-invalid` / the inline error node. Stays `0` until\n * the first validation failure.\n */\n @property({ attribute: false, type: Number })\n public validationVersion = 0;\n\n /** Decoration attribute keys applied on the previous update, for cleanup. */\n #decoratedKeys: string[] = [];\n\n /** DOM id of the inline error node, referenced by `aria-errormessage`. */\n static readonly #ERROR_ID = 'apex-cell-error';\n\n /** Validation errors resolved in {@link willUpdate}, consumed in render. */\n #errors: readonly string[] | null = null;\n\n /** Whether {@link value} currently shows a staged row-mode value. */\n #staged = false;\n\n /**\n * The held draft the editor resumed from when it opened on an edit already\n * in progress (see {@link #editorValue}), or `null`.\n */\n #resumed: { value: unknown } | null = null;\n\n /** Set by a reconnect, whose context re-request is a bare requestUpdate(). */\n #reconnected = false;\n\n public override connectedCallback(): void {\n // A moved row reconnects its cells; the state context consumer then\n // requests an update with nothing changed, which needs no render.\n this.#reconnected = this.hasUpdated && !this.isUpdatePending;\n super.connectedCallback();\n this.setAttribute('role', 'gridcell');\n this.addEventListener('click', this.#handleClick);\n this.addEventListener('dblclick', this.#handleDoubleClick);\n this.addEventListener('keydown', this.#handleCellKeydown);\n this.addEventListener('focusout', this.#handleCellFocusOut);\n }\n\n public override disconnectedCallback(): void {\n this.removeEventListener('click', this.#handleClick);\n this.removeEventListener('dblclick', this.#handleDoubleClick);\n this.removeEventListener('keydown', this.#handleCellKeydown);\n this.removeEventListener('focusout', this.#handleCellFocusOut);\n super.disconnectedCallback();\n }\n\n /**\n * Skips the render when only positional or decoration tokens changed: the\n * decoration is host attributes, so it is reconciled here and the cell\n * template (type renderers, user templates) is not re-run. A cell that reads\n * its row beyond {@link value} (a `cellTemplate`, which may read other fields\n * or the row index, or the tree group cell, whose chevron shows the row's\n * expansion) still renders when the row index or the data token moves.\n */\n protected override shouldUpdate(changed: PropertyValues<this>): boolean {\n const reconnected = this.#reconnected;\n this.#reconnected = false;\n // A bare requestUpdate() (empty map) renders, as Lit callers expect.\n if (!this.hasUpdated || (!changed.size && !reconnected)) return true;\n const tree = this.state?.tree;\n const readsRow =\n this.column.cellTemplate || (tree?.enabled && tree.isGroupColumn(this.column.key));\n for (const key of changed.keys()) {\n const token = key === 'rowIndex' || key === 'dataVersion';\n if (key !== 'decorationVersion' && (readsRow || !token)) return true;\n }\n if (changed.has('decorationVersion') || changed.has('rowIndex')) this.#applyDecoration();\n return false;\n }\n\n protected override willUpdate(changed: PropertyValues<this>) {\n this.#applyStaged();\n if (changed.has('editing')) {\n this.#resumed = this.editing\n ? this.editingController.heldDraft(this.row.data, this.column.key)\n : null;\n }\n if (this.colindex > 0) {\n this.setAttribute('aria-colindex', String(this.colindex));\n } else {\n this.removeAttribute('aria-colindex');\n }\n // Roving tabindex: the active cell is the grid body's single tab stop, so\n // real focus (not just `aria-current`) tracks keyboard navigation and\n // screen readers follow arrow-key movement cell to cell.\n this.tabIndex = this.active ? 0 : -1;\n if (this.active) {\n this.setAttribute('aria-current', 'true');\n } else {\n this.removeAttribute('aria-current');\n }\n // Reflect tree-expanded state on the group cell so the SCSS chevron\n // rotation triggers from this attribute (cheaper than per-render style\n // mutations and keeps the SVG transform purely declarative).\n const tree = this.state?.tree;\n const isGroup = tree?.enabled && this.row?.data && tree.isGroupColumn(this.column.key);\n if (isGroup && tree.isExpanded(this.row.data)) {\n this.setAttribute('data-tree-expanded', '');\n } else {\n this.removeAttribute('data-tree-expanded');\n }\n\n this.#applyValidation();\n this.#applyDecoration();\n }\n\n /**\n * Row mode: while the row is in edit, shows the cell's staged value in\n * place of the record's (display and a re-opened editor alike), and the\n * record's again once the row commits or cancels. One property read for\n * cells of rows not in edit.\n */\n #applyStaged(): void {\n const staged = this.state?.editing?.activeRow\n ? this.editingController.stagedValues(this.row.data)\n : null;\n const key = this.column.key;\n if (staged?.has(key)) {\n this.value = staged.get(key) as PropertyType<T>;\n this.#staged = true;\n } else if (this.#staged) {\n this.#staged = false;\n this.value = this.row.data[key] as PropertyType<T>;\n }\n }\n\n /**\n * Reflects the cell's validation state from the editing controller: stores the\n * current error messages for {@link render} and toggles `aria-invalid` +\n * `aria-errormessage` + `data-invalid` on the host. Inert for cells whose\n * column has no validators (the lookup returns `null`).\n */\n #applyValidation(): void {\n const errors =\n this.state && this.row?.data\n ? (this.editingController?.getCellErrors(this.row.data, this.column.key) ?? null)\n : null;\n this.#errors = errors && errors.length > 0 ? errors : null;\n\n if (this.#errors) {\n this.setAttribute('aria-invalid', 'true');\n this.setAttribute('aria-errormessage', ApexGridCell.#ERROR_ID);\n this.setAttribute('data-invalid', '');\n this.setAttribute('title', this.#errors.join('; '));\n } else {\n this.removeAttribute('aria-invalid');\n this.removeAttribute('aria-errormessage');\n this.removeAttribute('data-invalid');\n this.removeAttribute('title');\n }\n }\n\n /**\n * The inline error node surfaced when the cell is invalid. `role=\"alert\"`\n * announces the message when it appears, covering the cross-shadow gap where\n * an `aria-errormessage` IDREF on the host can't reach this node.\n */\n protected renderError() {\n if (!this.#errors) return null;\n return html`<span\n part=\"cell-error\"\n id=${ApexGridCell.#ERROR_ID}\n role=\"alert\"\n >${this.#errors.join('; ')}</span\n >`;\n }\n\n /**\n * Reflects module-contributed decoration attributes (see {@link CellDecorator})\n * onto the cell host, reconciling against the previous update so attributes\n * that are no longer present are removed. Inert for the community grid:\n * `state.decorateCell` returns `null` with no modules, so nothing is set.\n */\n #applyDecoration(): void {\n const decoration =\n this.state && this.row\n ? this.state.decorateCell({\n row: this.row.data,\n // A pinned row is outside the body view (`pageItems`), so its\n // band-local index must not match a body row's.\n rowIndex: this.#inPinnedBand ? -1 : this.rowIndex,\n column: this.column,\n value: this.value as unknown,\n })\n : null;\n const next = decoration?.attributes ?? {};\n\n // Remove anything we set last time that's gone (or explicitly cleared).\n for (const key of this.#decoratedKeys) {\n if (next[key] == null) this.removeAttribute(key);\n }\n\n const applied: string[] = [];\n for (const [key, value] of Object.entries(next)) {\n if (value == null) {\n this.removeAttribute(key);\n } else {\n this.setAttribute(key, value);\n applied.push(key);\n }\n }\n this.#decoratedKeys = applied;\n }\n\n protected override updated(changed: PropertyValues<this>) {\n if (this.isEditing) {\n // Focus and select only on entering edit mode: a mid-edit re-render\n // (validation, decoration) must keep the caret and the user's focus.\n if (!changed.has('editing')) return;\n const editor = this.editorElement;\n editor?.focus();\n if (editor instanceof HTMLInputElement) {\n if (editor.type === 'text' || editor.type === 'number') {\n editor.select();\n }\n }\n return;\n }\n // A keyboard-committed (or cancelled) edit removes the focused editor from\n // the DOM; hand focus back to the cell host so grid navigation continues\n // from where the user was. Pointer-driven exits (blur / outside click)\n // never set the flag, so they don't steal focus from the click target.\n if (changed.get('editing') === true && this.#refocusAfterEdit) {\n this.#refocusAfterEdit = false;\n this.focus();\n }\n }\n\n #handleClick = (event: MouseEvent) => {\n if (this.isEditing) {\n // Don't let clicks inside the editor bubble into navigation / outside-click commits.\n event.stopPropagation();\n return;\n }\n if (!this.isEditable) return;\n // Boolean cells handle interaction in their display widget — clicking the\n // checkbox commits inline via `ctx.commit`. We never enter edit mode for\n // booleans, which avoids the visual reflow between display/editor markup\n // and lets a single click toggle the value.\n if (this.column.type === 'boolean') return;\n if (this.editingController.trigger !== 'click') return;\n this.#startEdit();\n };\n\n #handleDoubleClick = (event: MouseEvent) => {\n if (this.isEditing) {\n event.stopPropagation();\n return;\n }\n if (!this.isEditable) return;\n if (this.column.type === 'boolean') return;\n if (this.editingController.trigger !== 'doubleClick') return;\n this.#startEdit();\n };\n\n #startEdit() {\n if (!this.row) return;\n // By record, so a pinned row edits its own record, not the body row at\n // its band-local index.\n this.editingController.editRecord(this.row.data, this.column.key);\n }\n\n /** Set by keyboard-driven commit/cancel so `updated` refocuses the cell host. */\n #refocusAfterEdit = false;\n\n /** Commits the open editor's draft (held by the editing controller). */\n #commit = (): Promise<boolean> => this.editingController.commitCell();\n\n #cancel = () => {\n this.editingController.cancelCell();\n };\n\n /**\n * Tab while editing: commits the draft and, once the commit is accepted,\n * moves the active cell and focus to the next cell (Shift+Tab: the previous\n * one), wrapping across rows, and scrolls it into view. The landed cell\n * stays closed (Enter or F2 opens it); a rejected commit keeps the editor\n * open. With no cell to land on (grid edge, only full-width rows such as\n * group headers beyond), focus stays on the edited record's cell.\n *\n * The target is resolved after the commit settles, from the edited record's\n * position in {@link ApexGrid.pageItems}: a commit can re-sort or regroup\n * the rows (the edited value is a sort or group key), so the record may now\n * sit at another index, outside the rows the virtualizer renders; the target\n * row is scrolled into view before it is focused. When the commit removed\n * the record from the view (filtered out, moved into a collapsed group, or\n * replaced by a listener writing a new object), focus stays in the grid on\n * the cell nearest the edited position.\n */\n #commitAndTab(event: KeyboardEvent): void {\n event.preventDefault();\n if (this.#inPinnedBand) {\n // Pinned rows sit outside the body's keyboard model: commit and keep\n // focus on this cell.\n this.#refocusAfterEdit = true;\n void this.#commit();\n return;\n }\n const step = event.shiftKey ? -1 : 1;\n const host = this.state.host;\n const body = this.row.parentElement as\n | (HTMLElement & { updateComplete?: Promise<unknown> })\n | null;\n const record = this.row.data;\n const origin = this.row.index;\n const key = this.column.key;\n const columns = this.row.columns;\n const keys = this.row.cells.map((cell) => cell.column.key);\n // The grid, then the rows' container (the virtualizer re-renders its rows\n // in its own update), then the rows themselves (a row that now holds a\n // full-width record drops its cells in its own update).\n const settle = async () => {\n await host.updateComplete;\n await body?.updateComplete;\n await Promise.all(renderedRows<T>(body).map((row) => row.updateComplete));\n };\n void this.#commit().then(async (committed) => {\n if (!committed) return;\n await settle();\n const items = host.pageItems;\n const isFullWidth = (index: number) =>\n items[index] == null ||\n this.state.presentRow(items[index], { columns, rowIndex: index }) !== null;\n const from = items.indexOf(record);\n let target: ActiveNode<T> | null;\n if (from >= 0) {\n target = tabTarget(items.length, from, keys, key, step, isFullWidth) ?? {\n row: from,\n column: key,\n };\n } else {\n const row = nearestCellRow(items.length, origin, step, isFullWidth);\n target = row < 0 ? null : { row, column: key };\n }\n if (!target) {\n body?.focus({ preventScroll: true });\n return;\n }\n this.state.active = target;\n await settle();\n let cell = findRenderedCell(body, target);\n // The target row is outside the rendered range: scroll towards it and\n // let the virtualizer render (two frames), re-aiming from the newly\n // rendered rows when the estimate fell short.\n for (let attempt = 0; !cell && attempt < 3; attempt++) {\n scrollRowIntoRange(host as unknown as HTMLElement, body, target.row);\n await new Promise(requestAnimationFrame);\n await new Promise(requestAnimationFrame);\n await settle();\n cell = findRenderedCell(body, target);\n }\n if (!cell) {\n body?.focus({ preventScroll: true });\n return;\n }\n cell.focus({ preventScroll: true });\n cell.scrollIntoView({ block: 'nearest', inline: 'nearest' });\n // The virtualizer's own layout pass, a frame or two later, can move or\n // re-create the landed row (an items change from the commit, such as a\n // quick filter dropping the record), which drops focus to the document.\n // Land again while the active cell is still the target.\n await new Promise(requestAnimationFrame);\n await new Promise(requestAnimationFrame);\n const active = this.state.active;\n const dropped = !document.activeElement || document.activeElement === document.body;\n if (dropped && active.row === target.row && active.column === target.column) {\n findRenderedCell(body, target)?.focus({ preventScroll: true });\n }\n });\n }\n\n #handleKeydown = (event: KeyboardEvent) => {\n event.stopPropagation();\n switch (event.key) {\n case 'Enter':\n event.preventDefault();\n this.#refocusAfterEdit = true;\n this.#commit();\n return;\n case 'Escape':\n event.preventDefault();\n this.#refocusAfterEdit = true;\n this.#cancel();\n return;\n case 'Tab':\n this.#commitAndTab(event);\n return;\n default:\n return;\n }\n };\n\n /**\n * Cell-level keydown that catches keys bubbling out of registry-built\n * editors (the default editor stops propagation on its own input).\n *\n * - Escape always cancels the edit.\n * - Tab commits the draft (or just closes when nothing was typed) and\n * moves to the next cell.\n *\n * Per-editor `keydown` handlers that need to consume Enter (e.g. the\n * built-in `<select>` editor) still get the first crack — they call\n * `event.stopPropagation()` and we never see those keys here.\n */\n #handleCellKeydown = (event: KeyboardEvent) => {\n if (!this.isEditing) return;\n if (event.key === 'Escape') {\n event.preventDefault();\n this.#refocusAfterEdit = true;\n this.#cancel();\n return;\n }\n if (event.key === 'Tab') this.#commitAndTab(event);\n };\n\n /**\n * Cell-level focus-out, the single focus-loss commit path: commits the\n * editor's draft when focus truly leaves the cell (clicking another cell or\n * a control outside the grid, blurring to the document body). In row mode\n * the value is staged and the row stays open.\n *\n * With no draft (nothing typed or picked) `commitCell()` resolves to the\n * current data value, so losing focus closes the editor without writing.\n * A failed validation keeps the editor open with its error.\n */\n #handleCellFocusOut = (event: FocusEvent) => {\n if (!this.isEditing) return;\n const next = event.relatedTarget as Node | null;\n if (next && (this.contains(next) || this.shadowRoot?.contains(next))) return;\n // A pointer exit never hands focus back to the cell, even after an\n // earlier keyboard commit that failed validation set the flag.\n this.#refocusAfterEdit = false;\n this.#commit();\n };\n\n /** Number and currency columns share the built-in number editor. */\n get #isNumeric(): boolean {\n const type = this.column.type;\n return type === 'number' || type === 'currency';\n }\n\n #handleTextInput = (event: Event) => {\n const target = event.target as HTMLInputElement;\n if (this.#isNumeric) {\n // An empty (or non-parseable) number field clears the value to null rather\n // than committing NaN, which would render as the text \"NaN\".\n const numeric = target.valueAsNumber;\n this.editingController.setDraft(\n target.value === '' || Number.isNaN(numeric) ? null : numeric\n );\n return;\n }\n this.editingController.setDraft(target.value);\n };\n\n #handleCheckboxChange = async (event: Event) => {\n const target = event.target as HTMLInputElement;\n // Booleans commit immediately: toggling is the whole interaction. A\n // rejected toggle flips back so the box never shows an unsaved state.\n if (!(await this.editingController.commitCell(target.checked))) {\n target.checked = !target.checked;\n }\n };\n\n /**\n * The value the editor shows: the cell value, or the held draft when the\n * editor opened on an edit already in progress (its record paged or\n * scrolled back into view), so what it shows is what a commit writes. Read\n * once on opening, so a later re-render never rewrites what the user is\n * typing.\n */\n get #editorValue(): unknown {\n return this.#resumed ? this.#resumed.value : this.value;\n }\n\n protected renderDefaultEditor() {\n const value = this.#editorValue;\n if (this.column.type === 'boolean') {\n return html`<input\n type=\"checkbox\"\n part=\"editor\"\n data-apex-editor\n ?checked=${Boolean(value)}\n @change=${this.#handleCheckboxChange}\n @keydown=${this.#handleKeydown}\n />`;\n }\n if (this.#isNumeric) {\n return html`<input\n type=\"number\"\n part=\"editor\"\n data-apex-editor\n .value=${value == null ? '' : String(value)}\n @input=${this.#handleTextInput}\n @keydown=${this.#handleKeydown}\n />`;\n }\n return html`<input\n type=\"text\"\n part=\"editor\"\n data-apex-editor\n .value=${value == null ? '' : String(value)}\n @input=${this.#handleTextInput}\n @keydown=${this.#handleKeydown}\n />`;\n }\n\n protected renderEditor() {\n const template = this.column.editorTemplate;\n const ctx = {\n parent: this,\n row: this.row,\n column: this.column,\n value: this.#editorValue,\n commit: (next: unknown) => this.editingController.commitCell(next),\n cancel: () => this.editingController.cancelCell(),\n setDraft: (next: unknown) => this.editingController.setDraft(next),\n };\n if (template) {\n return template(ctx as unknown as ApexEditorContext<T> as never);\n }\n const typeRenderer = getColumnTypeRenderer<T>(this.column.type);\n if (typeRenderer?.editor) {\n return typeRenderer.editor(ctx as never);\n }\n return this.renderDefaultEditor();\n }\n\n /**\n * Renders the tree affordance — depth-based indent + a chevron toggle (or\n * leaf spacer) — that prefixes the group cell when {@link ApexGrid.tree}\n * is enabled. Returns `nothing` for every other cell.\n */\n protected renderTreeAffordance() {\n const tree = this.state?.tree;\n if (!tree?.enabled) return null;\n if (!this.row?.data) return null;\n if (!tree.isGroupColumn(this.column.key)) return null;\n\n const data = this.row.data;\n const meta = tree.getMeta(data);\n if (!meta) return null;\n\n const indent = meta.depth * tree.childIndent;\n const expanded = tree.isExpanded(data);\n const handleClick = (event: MouseEvent) => {\n event.stopPropagation();\n if (!meta.hasChildren) return;\n void tree.toggleRow(data);\n };\n\n const chevron = meta.hasChildren\n ? html`<button\n type=\"button\"\n part=\"tree-toggle\"\n aria-label=${\n expanded ? this.state.localize('row.collapse') : this.state.localize('row.expand')\n }\n aria-expanded=${expanded ? 'true' : 'false'}\n @click=${handleClick}\n >\n <svg\n part=\"tree-chevron\"\n viewBox=\"0 0 24 24\"\n aria-hidden=\"true\"\n width=\"14\"\n height=\"14\"\n >\n <path\n d=\"M9 6l6 6-6 6\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n </button>`\n : html`<span part=\"tree-spacer\" aria-hidden=\"true\"></span>`;\n\n return html`<span\n part=\"tree-indent\"\n aria-hidden=\"true\"\n style=${`inline-size: ${indent}px`}\n ></span>${chevron}`;\n }\n\n /**\n * Resolves the value to display for the cell. Synthesized tree parents\n * (those that appear only as a path segment with no backing data) render\n * their last path segment in the group column and nothing elsewhere.\n */\n protected resolveDisplayValue(): unknown {\n const tree = this.state?.tree;\n if (tree?.enabled && this.row?.data && tree.isSynthesized(this.row.data)) {\n return tree.isGroupColumn(this.column.key) ? tree.getLabel(this.row.data) : '';\n }\n return this.value;\n }\n\n protected renderCellBody() {\n if (this.column.cellTemplate) {\n return this.column.cellTemplate(this.context as ApexCellContext<T> as never);\n }\n // A formula error is a first-class cell value: render its code as text so it\n // stays visible in typed columns (a currency/number renderer would coerce it\n // to NaN and show an empty cell).\n const value = this.resolveDisplayValue();\n if (isErrorLike(value)) {\n return html`${value.code}`;\n }\n const typeRenderer = getColumnTypeRenderer<T>(this.column.type);\n if (typeRenderer?.display) {\n // Synthesized parents have no real backing data — route them through\n // a plain text render instead of the typed renderer.\n const tree = this.state?.tree;\n if (tree?.enabled && this.row?.data && tree.isSynthesized(this.row.data)) {\n return html`${this.resolveDisplayValue()}`;\n }\n return typeRenderer.display(this.context as never);\n }\n return html`${this.resolveDisplayValue()}`;\n }\n\n protected override render() {\n const error = this.renderError();\n if (this.isEditing) {\n return html`${this.renderEditor()}${error}`;\n }\n const affordance = this.renderTreeAffordance();\n if (affordance) {\n return html`${affordance}<span part=\"tree-cell-content\"\n >${this.renderCellBody()}</span\n >${error}`;\n }\n return html`${this.renderCellBody()}${error}`;\n }\n}\n\ndeclare global {\n interface HTMLElementTag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AAK,EAAE,CAAC;8CACV;AASd;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAChB;AAUtB;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;iDACR;AAShB;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAChB","sourcesContent":["import { consume } from '@lit/context';\nimport { html, LitElement, type PropertyValues } from 'lit';\nimport { property, query } from 'lit/decorators.js';\nimport { gridStateContext, type StateController } from '../controllers/state.js';\nimport { getColumnTypeRenderer } from '../internal/column-types.js';\nimport { registerComponent } from '../internal/register.js';\nimport { GRID_CELL_TAG, GRID_ROW_TAG } from '../internal/tags.js';\nimport type {\n ActiveNode,\n ApexCellContext,\n ApexEditorContext,\n ColumnConfiguration,\n PropertyType,\n} from '../internal/types.js';\nimport { styles } from '../styles/body-cell/body-cell.css.js';\nimport type ApexGridRow from './row.js';\n\n/**\n * A spreadsheet-style error value (e.g. the enterprise formula engine's\n * `#VALUE!` / `#DIV/0!`). Duck-typed so core carries no dependency on the\n * enterprise layer: any value that is an object carrying a `#...` string `code`\n * is rendered as that code, even in a typed (currency / number) column whose\n * numeric renderer would otherwise coerce it to `NaN` and show nothing.\n */\nfunction isErrorLike(value: unknown): value is { code: string } {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as { code?: unknown }).code === 'string' &&\n (value as { code: string }).code.startsWith('#')\n );\n}\n\n/** The body rows rendered under `body` (the rows' shared parent). */\nfunction renderedRows<T extends object>(body: Element | null): ApexGridRow<T>[] {\n if (!body) return [];\n return Array.from(body.children).filter(\n (element) => element.localName === GRID_ROW_TAG\n ) as unknown as ApexGridRow<T>[];\n}\n\n/**\n * The cell Tab moves to from column `key` of view row `from`: the neighbouring\n * column (`keys`) of that row or, past the row edge, the first (or last) column\n * of the nearest row in that direction that renders cells, skipping full-width\n * rows. `null` at the edge of the grid's `count` view rows.\n */\nfunction tabTarget<T extends object>(\n count: number,\n from: number,\n keys: ColumnConfiguration<T>['key'][],\n key: ColumnConfiguration<T>['key'],\n step: 1 | -1,\n isFullWidth: (index: number) => boolean\n): ActiveNode<T> | null {\n const column = keys[keys.indexOf(key) + step];\n if (column !== undefined) return { row: from, column };\n const wrapColumn = keys[step > 0 ? 0 : keys.length - 1];\n for (let index = from + step; index >= 0 && index < count; index += step) {\n if (!isFullWidth(index)) return { row: index, column: wrapColumn };\n }\n return null;\n}\n\n/**\n * The view row nearest `start` (clamped to the `count` rows) that renders\n * cells, looking in the `step` direction first. `-1` when none does.\n */\nfunction nearestCellRow(\n count: number,\n start: number,\n step: 1 | -1,\n isFullWidth: (index: number) => boolean\n): number {\n const origin = Math.min(Math.max(start, 0), count - 1);\n for (let distance = 0; distance < count; distance++) {\n for (const index of [origin + distance * step, origin - distance * step]) {\n if (index >= 0 && index < count && !isFullWidth(index)) return index;\n }\n }\n return -1;\n}\n\n/** The rendered cell for `node` under `body`, if its row is rendered. */\nfunction findRenderedCell<T extends object>(body: Element | null, node: ActiveNode<T>) {\n return renderedRows<T>(body)\n .find((row) => row.index === node.row)\n ?.cells.find((cell) => cell.column.key === node.column);\n}\n\n/**\n * Scrolls `scroller` (the grid host, which owns the body's scrolling) so view\n * row `index`, outside the rows rendered under `body`, lands about mid-view,\n * placing it from the rendered rows' positions and average height. The\n * virtualizer then renders it on the scroll and the landed cell is aligned\n * exactly. (The virtualizer's own `element(index).scrollIntoView()` pin does\n * not work with the grid host as the scroller: it jumps to the end of the\n * range and renders no rows.)\n */\nfunction scrollRowIntoRange(scroller: HTMLElement, body: Element | null, index: number) {\n const rows = renderedRows(body).sort((a, b) => a.index - b.index);\n const first = rows.at(0);\n const last = rows.at(-1);\n if (!first || !last) return;\n const top = first.getBoundingClientRect().top;\n const height = (last.getBoundingClientRect().bottom - top) / (last.index - first.index + 1);\n const view = scroller.getBoundingClientRect();\n const rowCentre = top + (index - first.index + 0.5) * height;\n scroller.scrollTop += rowCentre - (view.top + scroller.clientHeight / 2);\n}\n\n/**\n * Component representing a DOM cell of the Apex grid.\n *\n * @csspart cell - The cell host element.\n * @csspart editor - The editor wrapper rendered while the cell is in edit mode.\n */\nexport default class ApexGridCell<T extends object> extends LitElement {\n public static get tagName() {\n return GRID_CELL_TAG;\n }\n\n public static override styles = styles;\n\n public static register(): void {\n registerComponent(ApexGridCell);\n }\n\n /**\n * The value which will be rendered by the component.\n */\n @property({ attribute: false })\n public value!: PropertyType<T>;\n\n /**\n * The record (row data object) the cell shows, set by the row next to\n * {@link value}. A row element can be re-bound to another record without\n * being rebuilt (a pinned band does when a row above it is unpinned), and\n * `value` alone cannot tell: two records may hold the same value. A change\n * here is a full update that drops every per-record state of the cell.\n *\n * @internal\n */\n @property({ attribute: false })\n public record!: T;\n\n /**\n * A reference to the column configuration object.\n */\n @property({ attribute: false })\n public column!: ColumnConfiguration<T>;\n\n /**\n * Indicates whether this is the active cell in the grid.\n *\n */\n @property({ type: Boolean, reflect: true })\n public active = false;\n\n /**\n * Whether the cell is currently in edit mode. Set by the parent row from the\n * editing controller's state so cells re-render on edit state changes.\n */\n @property({ type: Boolean, reflect: true })\n public editing = false;\n\n @consume({ context: gridStateContext, subscribe: true })\n @property({ attribute: false })\n public state!: StateController<T>;\n\n /**\n * The parent row component holding this cell.\n */\n public row!: ApexGridRow<T>;\n\n @query('input, [data-apex-editor]')\n protected editorElement!: HTMLElement | null;\n\n protected get context(): ApexCellContext<T> {\n // Captured now: by the time a template commits (after an await, say) this\n // cell and its row may show another record.\n const data = this.row.data;\n const key = this.column.key;\n const ctx = {\n parent: this,\n row: this.row,\n column: this.column,\n value: this.value,\n data,\n } as unknown as {\n parent: ApexGridCell<T>;\n row: ApexGridRow<T>;\n column: ColumnConfiguration<T>;\n value: PropertyType<T>;\n data: T;\n commit?: (value: unknown) => Promise<boolean>;\n };\n // Only expose `commit` when the column is editable — non-editable\n // interactive widgets should render as read-only.\n if (this.isEditable) {\n ctx.commit = (next: unknown) => this.editingController.commitImmediate(data, key, next);\n }\n return ctx as unknown as ApexCellContext<T>;\n }\n\n protected get editingController() {\n return this.state.editing;\n }\n\n protected get isEditing(): boolean {\n return this.editing;\n }\n\n protected get isEditable(): boolean {\n if (!this.editingController) return false;\n return this.editingController.isEditable(this.column);\n }\n\n /** Whether the cell's row renders in a pinned band rather than the body. */\n get #inPinnedBand(): boolean {\n const pin = this.state.rowPin;\n return pin.hasPinnedRows && pin.enabled && pin.isPinned(this.row.data);\n }\n\n /** Whether the cell's row is a body row of a grid that recycles its rows. */\n get #recycledBody(): boolean {\n return Boolean(this.state.host.rowRecycling) && !this.#inPinnedBand;\n }\n\n /**\n * 1-based column index used to populate `aria-colindex`. Accounts for the\n * auto-rendered selection + expansion columns ahead of the data columns.\n */\n @property({ attribute: false, type: Number })\n public colindex = 0;\n\n /**\n * The parent row's view index, set by the row. Changing it re-decorates the\n * cell (decoration such as a range selection is positional), so a row that\n * moves with the same data (sort, filter, an expand above it) never keeps a\n * stale highlight.\n *\n * @internal\n */\n @property({ attribute: false })\n public rowIndex = -1;\n\n /**\n * Reactive token forwarded from {@link StateController.decorationVersion}.\n * Changing it re-applies module-driven cell decoration (e.g. while dragging a\n * selection range) without re-rendering the cell content. Stays `0` for the\n * community grid, so cells are never re-decorated there.\n */\n @property({ attribute: false, type: Number })\n public decorationVersion = 0;\n\n /**\n * Reactive token forwarded from {@link StateController.dataVersion}, bumped\n * once per pipeline run. Re-renders only a cell that reads its row beyond\n * its own value (see {@link shouldUpdate}).\n *\n * @internal\n */\n @property({ attribute: false })\n public dataVersion = 0;\n\n /**\n * Reactive token forwarded from {@link EditingController.validationVersion}.\n * Changing it re-runs {@link willUpdate} so the cell re-reads its validation\n * errors and toggles `aria-invalid` / the inline error node. Stays `0` until\n * the first validation failure.\n */\n @property({ attribute: false, type: Number })\n public validationVersion = 0;\n\n /** Decoration attribute keys applied on the previous update, for cleanup. */\n #decoratedKeys: string[] = [];\n\n /** Validation errors resolved in {@link willUpdate}, consumed in render. */\n #errors: readonly string[] | null = null;\n\n /** Whether {@link value} currently shows a staged row-mode value. */\n #staged = false;\n\n /**\n * The held draft the editor resumed from when it opened on an edit already\n * in progress (see {@link #editorValue}), or `null`.\n */\n #resumed: { value: unknown } | null = null;\n\n /** Set by a reconnect, whose context re-request is a bare requestUpdate(). */\n #reconnected = false;\n\n /** Whether the current update re-binds the cell to another {@link record}. */\n #rebound = false;\n\n public override connectedCallback(): void {\n // A moved row reconnects its cells; the state context consumer then\n // requests an update with nothing changed, which needs no render.\n this.#reconnected = this.hasUpdated && !this.isUpdatePending;\n super.connectedCallback();\n this.setAttribute('role', 'gridcell');\n this.addEventListener('click', this.#handleClick);\n this.addEventListener('dblclick', this.#handleDoubleClick);\n this.addEventListener('keydown', this.#handleCellKeydown);\n this.addEventListener('focusout', this.#handleCellFocusOut);\n }\n\n public override disconnectedCallback(): void {\n this.removeEventListener('click', this.#handleClick);\n this.removeEventListener('dblclick', this.#handleDoubleClick);\n this.removeEventListener('keydown', this.#handleCellKeydown);\n this.removeEventListener('focusout', this.#handleCellFocusOut);\n super.disconnectedCallback();\n }\n\n /**\n * Skips the render when only positional or decoration tokens changed: the\n * decoration is host attributes, so it is reconciled here and the cell\n * template (type renderers, user templates) is not re-run. A cell that reads\n * its row beyond {@link value} (a `cellTemplate`, which may read other fields\n * or the row index, or the tree group cell, whose chevron shows the row's\n * expansion) still renders when the row index or the data token moves.\n * A {@link record} change is never a token: the cell renders in full.\n */\n protected override shouldUpdate(changed: PropertyValues<this>): boolean {\n const reconnected = this.#reconnected;\n this.#reconnected = false;\n // A bare requestUpdate() (empty map) renders, as Lit callers expect.\n if (!this.hasUpdated || (!changed.size && !reconnected)) return true;\n const tree = this.state?.tree;\n const readsRow =\n this.column.cellTemplate || (tree?.enabled && tree.isGroupColumn(this.column.key));\n for (const key of changed.keys()) {\n const token = key === 'rowIndex' || key === 'dataVersion';\n if (key !== 'decorationVersion' && (readsRow || !token)) return true;\n }\n if (changed.has('decorationVersion') || changed.has('rowIndex')) this.#applyDecoration();\n return false;\n }\n\n protected override willUpdate(changed: PropertyValues<this>) {\n // A re-bind needs no reset of its own: the staged value, the resumed\n // draft, the validation errors, the decoration and the tree attribute are\n // all recomputed below from the record the cell shows now, and a pending\n // refocus is checked against the re-bind in `updated`.\n this.#rebound = this.hasUpdated && changed.has('record');\n this.#applyStaged();\n if (changed.has('editing') || this.#rebound) {\n this.#resumed = this.editing\n ? this.editingController.heldDraft(this.row.data, this.column.key)\n : null;\n }\n if (this.colindex > 0) {\n this.setAttribute('aria-colindex', String(this.colindex));\n } else {\n this.removeAttribute('aria-colindex');\n }\n // Roving tabindex: the active cell is the grid body's single tab stop, so\n // real focus (not just `aria-current`) tracks keyboard navigation and\n // screen readers follow arrow-key movement cell to cell.\n this.tabIndex = this.active ? 0 : -1;\n if (this.active) {\n this.setAttribute('aria-current', 'true');\n } else {\n this.removeAttribute('aria-current');\n }\n // Reflect tree-expanded state on the group cell so the SCSS chevron\n // rotation triggers from this attribute (cheaper than per-render style\n // mutations and keeps the SVG transform purely declarative).\n const tree = this.state?.tree;\n const isGroup = tree?.enabled && this.row?.data && tree.isGroupColumn(this.column.key);\n if (isGroup && tree.isExpanded(this.row.data)) {\n this.setAttribute('data-tree-expanded', '');\n } else {\n this.removeAttribute('data-tree-expanded');\n }\n\n this.#applyValidation();\n this.#applyDecoration();\n }\n\n /**\n * Row mode: while the row is in edit, shows the cell's staged value in\n * place of the record's (display and a re-opened editor alike), and the\n * record's again once the row commits or cancels. One property read for\n * cells of rows not in edit.\n */\n #applyStaged(): void {\n const staged = this.state?.editing?.activeRow\n ? this.editingController.stagedValues(this.row.data)\n : null;\n const key = this.column.key;\n if (staged?.has(key)) {\n this.value = staged.get(key) as PropertyType<T>;\n this.#staged = true;\n } else if (this.#staged) {\n this.#staged = false;\n this.value = this.row.data[key] as PropertyType<T>;\n }\n }\n\n /**\n * Reflects the cell's validation state from the editing controller: stores the\n * current error messages for {@link render} and toggles `aria-invalid` +\n * `data-invalid` on the host. Inert for cells whose\n * column has no validators (the lookup returns `null`).\n */\n #applyValidation(): void {\n const errors =\n this.state && this.row?.data\n ? (this.editingController?.getCellErrors(this.row.data, this.column.key) ?? null)\n : null;\n this.#errors = errors && errors.length > 0 ? errors : null;\n\n if (this.#errors) {\n this.setAttribute('aria-invalid', 'true');\n this.setAttribute('data-invalid', '');\n this.setAttribute('title', this.#errors.join('; '));\n } else {\n this.removeAttribute('aria-invalid');\n this.removeAttribute('data-invalid');\n this.removeAttribute('title');\n }\n }\n\n /**\n * The inline error node surfaced when the cell is invalid. `role=\"alert\"`\n * announces the message when it appears, covering the cross-shadow gap where\n * an `aria-errormessage` IDREF on the host can't reach this node, so the\n * host sets none (it would dangle).\n */\n protected renderError() {\n if (!this.#errors) return null;\n return html`<span\n part=\"cell-error\"\n role=\"alert\"\n >${this.#errors.join('; ')}</span\n >`;\n }\n\n /**\n * Reflects module-contributed decoration attributes (see {@link CellDecorator})\n * onto the cell host, reconciling against the previous update so attributes\n * that are no longer present are removed. Returns at once when no module\n * decorates cells and nothing is left to clear (the community grid).\n */\n #applyDecoration(): void {\n if (!this.state?.hasCellDecorators && !this.#decoratedKeys.length) return;\n const decoration =\n this.state && this.row\n ? this.state.decorateCell({\n row: this.row.data,\n // A pinned row is outside the body view (`pageItems`), so its\n // band-local index must not match a body row's.\n rowIndex: this.#inPinnedBand ? -1 : this.rowIndex,\n column: this.column,\n value: this.value as unknown,\n })\n : null;\n const next = decoration?.attributes ?? {};\n\n // Remove anything we set last time that's gone (or explicitly cleared).\n for (const key of this.#decoratedKeys) {\n if (next[key] == null) this.removeAttribute(key);\n }\n\n const applied: string[] = [];\n for (const [key, value] of Object.entries(next)) {\n if (value == null) {\n this.removeAttribute(key);\n } else {\n this.setAttribute(key, value);\n applied.push(key);\n }\n }\n this.#decoratedKeys = applied;\n }\n\n protected override updated(changed: PropertyValues<this>) {\n if (this.isEditing) {\n // Focus and select only on entering edit mode: a mid-edit re-render\n // (validation, decoration) must keep the caret and the user's focus.\n if (!changed.has('editing')) return;\n const editor = this.editorElement;\n // An editor rendered again for an edit already in progress (a held\n // draft, or a re-bind that brought the edited record to this cell) is\n // not a new edit: no scroll jump, and the draft is not selected over.\n // A fresh edit keeps the focus scroll that brings a partly hidden cell\n // into view.\n const resumed = this.#resumed !== null || this.#rebound;\n // Under row recycling a body row re-binds wherever the record lands, and\n // focus may have left the grid meanwhile: such an editor takes focus\n // only while the body holds it.\n if (resumed && this.#recycledBody && !this.state.navigation.ownsFocus) return;\n // WebKit scrolls a text input focused before its first layout into view\n // once laid out, `preventScroll` or not: lay it out first.\n if (resumed) editor?.getBoundingClientRect();\n editor?.focus(resumed ? { preventScroll: true } : undefined);\n if (!resumed && editor instanceof HTMLInputElement) {\n if (editor.type === 'text' || editor.type === 'number') {\n editor.select();\n }\n }\n return;\n }\n // A keyboard-committed (or cancelled) edit removes the focused editor from\n // the DOM; hand focus back to the cell host so grid navigation continues\n // from where the user was. Pointer-driven exits (blur / outside click)\n // never set the flag, so they don't steal focus from the click target.\n if (changed.get('editing') === true && this.#refocusAfterEdit) {\n this.#refocusAfterEdit = false;\n // Re-bound away from a record whose edit is still open: the edit\n // resumes on the record's new cell, which keeps the focus.\n if (this.#rebound && this.editingController.activeCell) return;\n // The default focus scroll brings the cell back into view when the\n // grid was scrolled while the editor was open.\n this.focus();\n }\n }\n\n #handleClick = (event: MouseEvent) => {\n if (this.isEditing) {\n // Don't let clicks inside the editor bubble into navigation / outside-click commits.\n event.stopPropagation();\n return;\n }\n if (!this.isEditable) return;\n // Boolean cells handle interaction in their display widget — clicking the\n // checkbox commits inline via `ctx.commit`. We never enter edit mode for\n // booleans, which avoids the visual reflow between display/editor markup\n // and lets a single click toggle the value.\n if (this.column.type === 'boolean') return;\n if (this.editingController.trigger !== 'click') return;\n this.#startEdit();\n };\n\n #handleDoubleClick = (event: MouseEvent) => {\n if (this.isEditing) {\n event.stopPropagation();\n return;\n }\n if (!this.isEditable) return;\n if (this.column.type === 'boolean') return;\n if (this.editingController.trigger !== 'doubleClick') return;\n this.#startEdit();\n };\n\n #startEdit() {\n if (!this.row) return;\n // By record, so a pinned row edits its own record, not the body row at\n // its band-local index.\n this.editingController.editRecord(this.row.data, this.column.key);\n }\n\n /** Set by keyboard-driven commit/cancel so `updated` refocuses the cell host. */\n #refocusAfterEdit = false;\n\n /** Commits the open editor's draft (held by the editing controller). */\n #commit = (): Promise<boolean> => this.editingController.commitCell();\n\n #cancel = () => {\n this.editingController.cancelCell();\n };\n\n /**\n * Tab while editing: commits the draft and, once the commit is accepted,\n * moves the active cell and focus to the next cell (Shift+Tab: the previous\n * one), wrapping across rows, and scrolls it into view. The landed cell\n * stays closed (Enter or F2 opens it); a rejected commit keeps the editor\n * open. With no cell to land on (grid edge, only full-width rows such as\n * group headers beyond), focus stays on the edited record's cell.\n *\n * The target is resolved after the commit settles, from the edited record's\n * position in {@link ApexGrid.pageItems}: a commit can re-sort or regroup\n * the rows (the edited value is a sort or group key), so the record may now\n * sit at another index, outside the rows the virtualizer renders; the target\n * row is scrolled into view before it is focused. When the commit removed\n * the record from the view (filtered out, moved into a collapsed group, or\n * replaced by a listener writing a new object), focus stays in the grid on\n * the cell nearest the edited position.\n */\n #commitAndTab(event: KeyboardEvent): void {\n event.preventDefault();\n if (this.#inPinnedBand) {\n // Pinned rows sit outside the body's keyboard model: commit and keep\n // focus on this cell.\n this.#refocusAfterEdit = true;\n void this.#commit();\n return;\n }\n const step = event.shiftKey ? -1 : 1;\n const host = this.state.host;\n const body = this.row.parentElement as\n | (HTMLElement & { updateComplete?: Promise<unknown> })\n | null;\n const record = this.row.data;\n const origin = this.row.index;\n const key = this.column.key;\n const columns = this.row.columns;\n const keys = this.row.cells.map((cell) => cell.column.key);\n // The grid, then the rows' container (the virtualizer re-renders its rows\n // in its own update), then the rows themselves (a row that now holds a\n // full-width record drops its cells in its own update).\n const settle = async () => {\n await host.updateComplete;\n await body?.updateComplete;\n await Promise.all(renderedRows<T>(body).map((row) => row.updateComplete));\n };\n void this.#commit().then(async (committed) => {\n if (!committed) return;\n await settle();\n const items = host.pageItems;\n const isFullWidth = (index: number) =>\n items[index] == null ||\n this.state.presentRow(items[index], { columns, rowIndex: index }) !== null;\n const from = items.indexOf(record);\n let target: ActiveNode<T> | null;\n if (from >= 0) {\n target = tabTarget(items.length, from, keys, key, step, isFullWidth) ?? {\n row: from,\n column: key,\n };\n } else {\n const row = nearestCellRow(items.length, origin, step, isFullWidth);\n target = row < 0 ? null : { row, column: key };\n }\n if (!target) {\n body?.focus({ preventScroll: true });\n return;\n }\n this.state.active = target;\n await settle();\n let cell = findRenderedCell(body, target);\n // The target row is outside the rendered range: scroll towards it and\n // let the virtualizer render (two frames), re-aiming from the newly\n // rendered rows when the estimate fell short.\n for (let attempt = 0; !cell && attempt < 3; attempt++) {\n scrollRowIntoRange(host as unknown as HTMLElement, body, target.row);\n await new Promise(requestAnimationFrame);\n await new Promise(requestAnimationFrame);\n await settle();\n cell = findRenderedCell(body, target);\n }\n if (!cell) {\n body?.focus({ preventScroll: true });\n return;\n }\n cell.focus({ preventScroll: true });\n cell.scrollIntoView({ block: 'nearest', inline: 'nearest' });\n // The virtualizer's own layout pass, a frame or two later, can move or\n // re-create the landed row (an items change from the commit, such as a\n // quick filter dropping the record), which drops focus to the document.\n // Land again while the active cell is still the target.\n await new Promise(requestAnimationFrame);\n await new Promise(requestAnimationFrame);\n const active = this.state.active;\n const dropped = !document.activeElement || document.activeElement === document.body;\n if (dropped && active.row === target.row && active.column === target.column) {\n findRenderedCell(body, target)?.focus({ preventScroll: true });\n }\n });\n }\n\n #handleKeydown = (event: KeyboardEvent) => {\n event.stopPropagation();\n switch (event.key) {\n case 'Enter':\n event.preventDefault();\n this.#refocusAfterEdit = true;\n this.#commit();\n return;\n case 'Escape':\n event.preventDefault();\n this.#refocusAfterEdit = true;\n this.#cancel();\n return;\n case 'Tab':\n this.#commitAndTab(event);\n return;\n default:\n return;\n }\n };\n\n /**\n * Cell-level keydown that catches keys bubbling out of registry-built\n * editors (the default editor stops propagation on its own input).\n *\n * - Escape always cancels the edit.\n * - Tab commits the draft (or just closes when nothing was typed) and\n * moves to the next cell.\n *\n * Per-editor `keydown` handlers that need to consume Enter (e.g. the\n * built-in `<select>` editor) still get the first crack — they call\n * `event.stopPropagation()` and we never see those keys here.\n */\n #handleCellKeydown = (event: KeyboardEvent) => {\n if (!this.isEditing) return;\n if (event.key === 'Escape') {\n event.preventDefault();\n this.#refocusAfterEdit = true;\n this.#cancel();\n return;\n }\n if (event.key === 'Tab') this.#commitAndTab(event);\n };\n\n /**\n * Cell-level focus-out, the single focus-loss commit path: commits the\n * editor's draft when focus truly leaves the cell (clicking another cell or\n * a control outside the grid, blurring to the document body). In row mode\n * the value is staged and the row stays open.\n *\n * With no draft (nothing typed or picked) `commitCell()` resolves to the\n * current data value, so losing focus closes the editor without writing.\n * A failed validation keeps the editor open with its error.\n */\n #handleCellFocusOut = (event: FocusEvent) => {\n if (!this.isEditing) return;\n const next = event.relatedTarget as Node | null;\n if (next && (this.contains(next) || this.shadowRoot?.contains(next))) return;\n // A pointer exit never hands focus back to the cell, even after an\n // earlier keyboard commit that failed validation set the flag.\n this.#refocusAfterEdit = false;\n this.#commit();\n };\n\n /** Number and currency columns share the built-in number editor. */\n get #isNumeric(): boolean {\n const type = this.column.type;\n return type === 'number' || type === 'currency';\n }\n\n #handleTextInput = (event: Event) => {\n const target = event.target as HTMLInputElement;\n if (this.#isNumeric) {\n // An empty (or non-parseable) number field clears the value to null rather\n // than committing NaN, which would render as the text \"NaN\".\n const numeric = target.valueAsNumber;\n this.editingController.setDraft(\n target.value === '' || Number.isNaN(numeric) ? null : numeric\n );\n return;\n }\n this.editingController.setDraft(target.value);\n };\n\n #handleCheckboxChange = async (event: Event) => {\n const target = event.target as HTMLInputElement;\n // Booleans commit immediately: toggling is the whole interaction. A\n // rejected toggle flips back so the box never shows an unsaved state.\n if (!(await this.editingController.commitCell(target.checked))) {\n target.checked = !target.checked;\n }\n };\n\n /**\n * The value the editor shows: the cell value, or the held draft when the\n * editor opened on an edit already in progress (its record paged or\n * scrolled back into view), so what it shows is what a commit writes. Read\n * once on opening, so a later re-render never rewrites what the user is\n * typing.\n */\n get #editorValue(): unknown {\n return this.#resumed ? this.#resumed.value : this.value;\n }\n\n protected renderDefaultEditor() {\n const value = this.#editorValue;\n if (this.column.type === 'boolean') {\n return html`<input\n type=\"checkbox\"\n part=\"editor\"\n data-apex-editor\n ?checked=${Boolean(value)}\n @change=${this.#handleCheckboxChange}\n @keydown=${this.#handleKeydown}\n />`;\n }\n if (this.#isNumeric) {\n return html`<input\n type=\"number\"\n part=\"editor\"\n data-apex-editor\n .value=${value == null ? '' : String(value)}\n @input=${this.#handleTextInput}\n @keydown=${this.#handleKeydown}\n />`;\n }\n return html`<input\n type=\"text\"\n part=\"editor\"\n data-apex-editor\n .value=${value == null ? '' : String(value)}\n @input=${this.#handleTextInput}\n @keydown=${this.#handleKeydown}\n />`;\n }\n\n protected renderEditor() {\n const template = this.column.editorTemplate;\n const ctx = {\n parent: this,\n row: this.row,\n column: this.column,\n value: this.#editorValue,\n data: this.row.data,\n commit: (next: unknown) => this.editingController.commitCell(next),\n cancel: () => this.editingController.cancelCell(),\n setDraft: (next: unknown) => this.editingController.setDraft(next),\n };\n if (template) {\n return template(ctx as unknown as ApexEditorContext<T> as never);\n }\n const typeRenderer = getColumnTypeRenderer<T>(this.column.type);\n if (typeRenderer?.editor) {\n return typeRenderer.editor(ctx as never);\n }\n return this.renderDefaultEditor();\n }\n\n /**\n * Renders the tree affordance — depth-based indent + a chevron toggle (or\n * leaf spacer) — that prefixes the group cell when {@link ApexGrid.tree}\n * is enabled. Returns `nothing` for every other cell.\n */\n protected renderTreeAffordance() {\n const tree = this.state?.tree;\n if (!tree?.enabled) return null;\n if (!this.row?.data) return null;\n if (!tree.isGroupColumn(this.column.key)) return null;\n\n const data = this.row.data;\n const meta = tree.getMeta(data);\n if (!meta) return null;\n\n const indent = meta.depth * tree.childIndent;\n const expanded = tree.isExpanded(data);\n const handleClick = (event: MouseEvent) => {\n event.stopPropagation();\n if (!meta.hasChildren) return;\n void tree.toggleRow(data);\n };\n\n const chevron = meta.hasChildren\n ? html`<button\n type=\"button\"\n part=\"tree-toggle\"\n aria-label=${\n expanded ? this.state.localize('row.collapse') : this.state.localize('row.expand')\n }\n aria-expanded=${expanded ? 'true' : 'false'}\n @click=${handleClick}\n >\n <svg\n part=\"tree-chevron\"\n viewBox=\"0 0 24 24\"\n aria-hidden=\"true\"\n width=\"14\"\n height=\"14\"\n >\n <path\n d=\"M9 6l6 6-6 6\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n </button>`\n : html`<span part=\"tree-spacer\" aria-hidden=\"true\"></span>`;\n\n return html`<span\n part=\"tree-indent\"\n aria-hidden=\"true\"\n style=${`inline-size: ${indent}px`}\n ></span>${chevron}`;\n }\n\n /**\n * Resolves the value to display for the cell. Synthesized tree parents\n * (those that appear only as a path segment with no backing data) render\n * their last path segment in the group column and nothing elsewhere.\n */\n protected resolveDisplayValue(): unknown {\n const tree = this.state?.tree;\n if (tree?.enabled && this.row?.data && tree.isSynthesized(this.row.data)) {\n return tree.isGroupColumn(this.column.key) ? tree.getLabel(this.row.data) : '';\n }\n return this.value;\n }\n\n protected renderCellBody() {\n if (this.column.cellTemplate) {\n return this.column.cellTemplate(this.context as ApexCellContext<T> as never);\n }\n // A formula error is a first-class cell value: render its code as text so it\n // stays visible in typed columns (a currency/number renderer would coerce it\n // to NaN and show an empty cell).\n const value = this.resolveDisplayValue();\n if (isErrorLike(value)) {\n return html`${value.code}`;\n }\n const typeRenderer = getColumnTypeRenderer<T>(this.column.type);\n if (typeRenderer?.display) {\n // Synthesized parents have no real backing data — route them through\n // a plain text render instead of the typed renderer.\n const tree = this.state?.tree;\n if (tree?.enabled && this.row?.data && tree.isSynthesized(this.row.data)) {\n return html`${this.resolveDisplayValue()}`;\n }\n return typeRenderer.display(this.context as never);\n }\n return html`${this.resolveDisplayValue()}`;\n }\n\n protected override render() {\n const error = this.renderError();\n if (this.isEditing) {\n return html`${this.renderEditor()}${error}`;\n }\n const affordance = this.renderTreeAffordance();\n if (affordance) {\n return html`${affordance}<span part=\"tree-cell-content\"\n >${this.renderCellBody()}</span\n >${error}`;\n }\n return html`${this.renderCellBody()}${error}`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n [ApexGridCell.tagName]: ApexGridCell<object>;\n }\n}\n"]}