@dxos/lit-grid 0.8.3 → 0.8.4-main.1da679c

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 (107) hide show
  1. package/dist/src/defs.d.ts +1 -0
  2. package/dist/src/defs.d.ts.map +1 -1
  3. package/dist/src/defs.js +1 -0
  4. package/dist/src/defs.js.map +1 -1
  5. package/dist/src/dx-grid-axis-resize-handle.d.ts.map +1 -1
  6. package/dist/src/dx-grid-axis-resize-handle.js +3 -5
  7. package/dist/src/dx-grid-axis-resize-handle.js.map +1 -1
  8. package/dist/src/dx-grid-multiselect-cell.d.ts.map +1 -1
  9. package/dist/src/dx-grid-multiselect-cell.js +2 -1
  10. package/dist/src/dx-grid-multiselect-cell.js.map +1 -1
  11. package/dist/src/dx-grid.d.ts +11 -6
  12. package/dist/src/dx-grid.d.ts.map +1 -1
  13. package/dist/src/dx-grid.js +229 -150
  14. package/dist/src/dx-grid.js.map +1 -1
  15. package/dist/src/dx-grid.lit-stories.d.ts +1 -0
  16. package/dist/src/dx-grid.lit-stories.d.ts.map +1 -1
  17. package/dist/src/dx-grid.lit-stories.js +19 -20
  18. package/dist/src/dx-grid.lit-stories.js.map +1 -1
  19. package/dist/src/playwright/dx-grid.spec.d.ts.map +1 -0
  20. package/dist/src/{testing/playwright → playwright}/dx-grid.spec.js +3 -3
  21. package/dist/src/playwright/dx-grid.spec.js.map +1 -0
  22. package/dist/src/playwright/playwright.config.d.ts +3 -0
  23. package/dist/src/playwright/playwright.config.d.ts.map +1 -0
  24. package/dist/src/playwright/playwright.config.js +15 -0
  25. package/dist/src/playwright/playwright.config.js.map +1 -0
  26. package/dist/src/testing/{playwright/dx-grid-manager.d.ts → dx-grid-manager.d.ts} +1 -1
  27. package/dist/src/testing/dx-grid-manager.d.ts.map +1 -0
  28. package/dist/src/testing/dx-grid-manager.js.map +1 -0
  29. package/dist/src/testing/index.d.ts +1 -1
  30. package/dist/src/testing/index.d.ts.map +1 -1
  31. package/dist/src/testing/index.js +1 -1
  32. package/dist/src/testing/index.js.map +1 -1
  33. package/dist/src/types.d.ts +7 -0
  34. package/dist/src/types.d.ts.map +1 -1
  35. package/dist/src/types.js.map +1 -1
  36. package/dist/src/util.d.ts +4 -1
  37. package/dist/src/util.d.ts.map +1 -1
  38. package/dist/src/util.js +11 -11
  39. package/dist/src/util.js.map +1 -1
  40. package/dist/tsconfig.tsbuildinfo +1 -1
  41. package/package.json +6 -5
  42. package/src/defs.ts +1 -0
  43. package/src/dx-grid-axis-resize-handle.pcss +7 -0
  44. package/src/dx-grid-axis-resize-handle.ts +1 -1
  45. package/src/dx-grid-multiselect-cell.pcss +2 -2
  46. package/src/dx-grid-multiselect-cell.ts +2 -1
  47. package/src/dx-grid.lit-stories.ts +6 -2
  48. package/src/dx-grid.pcss +133 -15
  49. package/src/dx-grid.ts +240 -100
  50. package/src/{testing/playwright → playwright}/dx-grid.spec.ts +5 -5
  51. package/src/playwright/playwright.config.ts +17 -0
  52. package/src/testing/{playwright/dx-grid-manager.ts → dx-grid-manager.ts} +2 -2
  53. package/src/testing/index.ts +1 -1
  54. package/src/types.ts +7 -0
  55. package/src/util.ts +13 -9
  56. package/dist/src/testing/playwright/dx-grid-manager.d.ts.map +0 -1
  57. package/dist/src/testing/playwright/dx-grid-manager.js.map +0 -1
  58. package/dist/src/testing/playwright/dx-grid.spec.d.ts.map +0 -1
  59. package/dist/src/testing/playwright/dx-grid.spec.js.map +0 -1
  60. package/dist/types/src/defs.d.ts +0 -3
  61. package/dist/types/src/defs.d.ts.map +0 -1
  62. package/dist/types/src/defs.js +0 -6
  63. package/dist/types/src/defs.js.map +0 -1
  64. package/dist/types/src/dx-grid-axis-resize-handle.d.ts +0 -16
  65. package/dist/types/src/dx-grid-axis-resize-handle.d.ts.map +0 -1
  66. package/dist/types/src/dx-grid-axis-resize-handle.js +0 -100
  67. package/dist/types/src/dx-grid-axis-resize-handle.js.map +0 -1
  68. package/dist/types/src/dx-grid-multiselect-cell.d.ts +0 -13
  69. package/dist/types/src/dx-grid-multiselect-cell.d.ts.map +0 -1
  70. package/dist/types/src/dx-grid-multiselect-cell.js +0 -56
  71. package/dist/types/src/dx-grid-multiselect-cell.js.map +0 -1
  72. package/dist/types/src/dx-grid.d.ts +0 -170
  73. package/dist/types/src/dx-grid.d.ts.map +0 -1
  74. package/dist/types/src/dx-grid.js +0 -1347
  75. package/dist/types/src/dx-grid.js.map +0 -1
  76. package/dist/types/src/dx-grid.lit-stories.d.ts +0 -46
  77. package/dist/types/src/dx-grid.lit-stories.d.ts.map +0 -1
  78. package/dist/types/src/dx-grid.lit-stories.js +0 -179
  79. package/dist/types/src/dx-grid.lit-stories.js.map +0 -1
  80. package/dist/types/src/index.d.ts +0 -5
  81. package/dist/types/src/index.d.ts.map +0 -1
  82. package/dist/types/src/index.js +0 -8
  83. package/dist/types/src/index.js.map +0 -1
  84. package/dist/types/src/testing/index.d.ts +0 -2
  85. package/dist/types/src/testing/index.d.ts.map +0 -1
  86. package/dist/types/src/testing/index.js +0 -5
  87. package/dist/types/src/testing/index.js.map +0 -1
  88. package/dist/types/src/testing/playwright/dx-grid-manager.d.ts +0 -24
  89. package/dist/types/src/testing/playwright/dx-grid-manager.d.ts.map +0 -1
  90. package/dist/types/src/testing/playwright/dx-grid-manager.js +0 -79
  91. package/dist/types/src/testing/playwright/dx-grid-manager.js.map +0 -1
  92. package/dist/types/src/testing/playwright/dx-grid.spec.d.ts +0 -2
  93. package/dist/types/src/testing/playwright/dx-grid.spec.d.ts.map +0 -1
  94. package/dist/types/src/testing/playwright/dx-grid.spec.js +0 -92
  95. package/dist/types/src/testing/playwright/dx-grid.spec.js.map +0 -1
  96. package/dist/types/src/types.d.ts +0 -137
  97. package/dist/types/src/types.d.ts.map +0 -1
  98. package/dist/types/src/types.js +0 -46
  99. package/dist/types/src/types.js.map +0 -1
  100. package/dist/types/src/util.d.ts +0 -39
  101. package/dist/types/src/util.d.ts.map +0 -1
  102. package/dist/types/src/util.js +0 -165
  103. package/dist/types/src/util.js.map +0 -1
  104. package/dist/types/tsconfig.tsbuildinfo +0 -1
  105. package/src/testing/playwright/playwright.config.cts +0 -18
  106. /package/dist/src/{testing/playwright → playwright}/dx-grid.spec.d.ts +0 -0
  107. /package/dist/src/testing/{playwright/dx-grid-manager.js → dx-grid-manager.js} +0 -0
@@ -8,18 +8,16 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  return c > 3 && r && Object.defineProperty(target, key, r), r;
9
9
  };
10
10
  import { LitElement, html, nothing } from 'lit';
11
- import { customElement, state, property } from 'lit/decorators.js';
12
- import { ref, createRef } from 'lit/directives/ref.js';
11
+ import { customElement, property, state } from 'lit/decorators.js';
12
+ import { createRef, ref } from 'lit/directives/ref.js';
13
13
  import { styleMap } from 'lit/directives/style-map.js';
14
- import { unsafeStatic, html as staticHtml } from 'lit/static-html.js';
15
- import { defaultColSize, defaultRowSize } from './defs';
16
- // eslint-disable-next-line unused-imports/no-unused-imports
14
+ import { html as staticHtml, unsafeStatic } from 'lit/static-html.js';
15
+ import { defaultColSize, defaultRowSize, focusUnfurlDefault } from './defs';
17
16
  import './dx-grid-axis-resize-handle';
18
17
  import { DxAxisResize, DxEditRequest, DxGridCellsSelect, separator, } from './types';
19
- import { toCellIndex, gap, resizeTolerance, sizeColMin, sizeColMax, sizeRowMin, sizeRowMax, shouldSelect, selectionProps, cellSelected, closestAction, closestCell, targetIsPlane, resolveRowPlane, resolveColPlane, resolveFrozenPlane, isSameCell, isReadonly, } from './util';
18
+ import { cellSelected, closestAction, closestCell, gap, isReadonly, isSameCell, resizeTolerance, resolveColPlane, resolveFrozenPlane, resolveRowPlane, selectionProps, shouldSelect, sizeColMax, sizeColMin, sizeRowMax, sizeRowMin, targetIsPlane, toCellIndex, } from './util';
20
19
  let DxGrid = class DxGrid extends LitElement {
21
20
  constructor() {
22
- var _a;
23
21
  super();
24
22
  this.gridId = 'default-grid-id';
25
23
  this.rowDefault = {
@@ -83,6 +81,11 @@ let DxGrid = class DxGrid extends LitElement {
83
81
  this.templatefrozenRowsStart = '';
84
82
  this.templatefrozenRowsEnd = '';
85
83
  //
84
+ // `frozen…Size` is used to measure space available for the non-fixed planes
85
+ //
86
+ this.frozenColsSize = 0;
87
+ this.frozenRowsSize = 0;
88
+ //
86
89
  // Focus, selection, and resize states
87
90
  //
88
91
  this.pointer = null;
@@ -133,8 +136,7 @@ let DxGrid = class DxGrid extends LitElement {
133
136
  }
134
137
  };
135
138
  this.handlePointerUp = (event) => {
136
- var _a;
137
- if (((_a = this.pointer) === null || _a === void 0 ? void 0 : _a.state) === 'selecting') {
139
+ if (this.pointer?.state === 'selecting') {
138
140
  const cell = closestCell(event.target);
139
141
  if (cell) {
140
142
  this.setSelectionEnd(cell);
@@ -144,8 +146,7 @@ let DxGrid = class DxGrid extends LitElement {
144
146
  this.pointer = null;
145
147
  };
146
148
  this.handlePointerMove = (event) => {
147
- var _a, _b;
148
- if (((_a = this.pointer) === null || _a === void 0 ? void 0 : _a.state) === 'panning') {
149
+ if (this.pointer?.state === 'panning') {
149
150
  const panEvent = event;
150
151
  panEvent.deltaX = this.pointer.pageX - event.pageX;
151
152
  panEvent.deltaY = this.pointer.pageY - event.pageY;
@@ -156,7 +157,7 @@ let DxGrid = class DxGrid extends LitElement {
156
157
  else if (shouldSelect(this.pointer, event)) {
157
158
  this.pointer = { state: 'selecting' };
158
159
  }
159
- else if (((_b = this.pointer) === null || _b === void 0 ? void 0 : _b.state) === 'selecting') {
160
+ else if (this.pointer?.state === 'selecting') {
160
161
  const cell = closestCell(event.target);
161
162
  if (cell &&
162
163
  cell.plane === this.selectionStart.plane &&
@@ -169,22 +170,20 @@ let DxGrid = class DxGrid extends LitElement {
169
170
  // Resize & reposition handlers, observer, ref
170
171
  //
171
172
  this.observer = new ResizeObserver((entries) => {
172
- var _a, _b, _c;
173
- const { inlineSize, blockSize } = (_c = (_b = (_a = entries === null || entries === void 0 ? void 0 : entries[0]) === null || _a === void 0 ? void 0 : _a.contentBoxSize) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : {
173
+ const { inlineSize, blockSize } = entries?.[0]?.contentBoxSize?.[0] ?? {
174
174
  inlineSize: 0,
175
175
  blockSize: 0,
176
176
  };
177
- if (Math.abs(inlineSize - this.sizeInline) > resizeTolerance ||
178
- Math.abs(blockSize - this.sizeBlock) > resizeTolerance) {
177
+ if (Math.abs(inlineSize - this.frozenColsSize - this.sizeInline) > resizeTolerance ||
178
+ Math.abs(blockSize - this.frozenRowsSize - this.sizeBlock) > resizeTolerance) {
179
179
  // console.info('[updating bounds]', 'resize', [inlineSize - this.sizeInline, blockSize - this.sizeBlock]);
180
- this.sizeInline = inlineSize;
181
- this.sizeBlock = blockSize;
180
+ this.sizeInline = inlineSize - this.frozenColsSize;
181
+ this.sizeBlock = blockSize - this.frozenRowsSize;
182
182
  this.updateVis();
183
183
  queueMicrotask(() => this.updatePos());
184
184
  }
185
185
  });
186
186
  this.gridRef = createRef();
187
- this.viewportRef = createRef();
188
187
  this.maybeUpdateVisInline = () => {
189
188
  if (this.posInline < this.binInlineMin || this.posInline >= this.binInlineMax) {
190
189
  this.updateVisInline();
@@ -196,20 +195,28 @@ let DxGrid = class DxGrid extends LitElement {
196
195
  }
197
196
  };
198
197
  this.handleTopLevelWheel = (event) => {
199
- var _a;
200
- if (event.gridId === ((_a = this.gridId) !== null && _a !== void 0 ? _a : 'never')) {
198
+ if (event.gridId === (this.gridId ?? 'never')) {
201
199
  if (this.overscroll === 'trap' ||
202
200
  (this.overscroll === 'inline' && event.overscrollInline === 0) ||
203
201
  (this.overscroll === 'block' && event.overscrollBlock === 0)) {
204
- event.preventDefault();
205
- event.stopPropagation();
202
+ const element = event.target;
203
+ const activeCell = element.closest('[data-dx-active]');
204
+ const contentEl = element.closest('.dx-grid__cell__content');
205
+ if (!(element &&
206
+ activeCell &&
207
+ contentEl &&
208
+ (contentEl.scrollWidth > contentEl.clientWidth || contentEl.scrollHeight > contentEl.clientHeight))) {
209
+ event.preventDefault();
210
+ event.stopPropagation();
211
+ }
206
212
  }
207
213
  }
208
214
  };
209
215
  this.handleWheel = (event) => {
210
216
  if (this.mode === 'browse') {
211
- const nextPosInline = this.posInline + event.deltaX;
212
- const nextPosBlock = this.posBlock + event.deltaY;
217
+ const { deltaX, deltaY } = this.getOverflowingCellModifiedDeltas(event);
218
+ const nextPosInline = this.posInline + deltaX;
219
+ const nextPosBlock = this.posBlock + deltaY;
213
220
  const maxPosInline = this.maxPosInline();
214
221
  const maxPosBlock = this.maxPosBlock();
215
222
  this.updatePos(nextPosInline, nextPosBlock, maxPosInline, maxPosBlock);
@@ -221,7 +228,7 @@ let DxGrid = class DxGrid extends LitElement {
221
228
  }
222
229
  };
223
230
  // Wheel, top-level and element-level
224
- (_a = document.defaultView) === null || _a === void 0 ? void 0 : _a.addEventListener('wheel', this.handleTopLevelWheel, { passive: false });
231
+ document.defaultView?.addEventListener('wheel', this.handleTopLevelWheel, { passive: false });
225
232
  this.addEventListener('wheel', this.handleWheel);
226
233
  // Custom event(s)
227
234
  this.addEventListener('dx-axis-resize-internal', this.handleAxisResizeInternal);
@@ -305,18 +312,16 @@ let DxGrid = class DxGrid extends LitElement {
305
312
  }
306
313
  }
307
314
  moveFocusBetweenPlanes(event, plane) {
308
- var _a, _b, _c, _d;
309
- const planeElement = (_a = this.gridRef.value) === null || _a === void 0 ? void 0 : _a.querySelector(`[data-dx-grid-plane="${plane}"]`);
315
+ const planeElement = this.gridRef.value?.querySelector(`[data-dx-grid-plane="${plane}"]`);
310
316
  if (planeElement) {
311
317
  const axis = event.key === 'ArrowUp' || event.key === 'ArrowDown' ? 'col' : 'row';
312
318
  const delta = event.key === 'ArrowLeft' || event.key === 'ArrowUp' ? -1 : 1;
313
- const planeAxis = planeElement === null || planeElement === void 0 ? void 0 : planeElement.getAttribute(`data-dx-grid-plane-${axis}`);
314
- const adjacentPlanes = Array.from((_c = (_b = this.gridRef.value) === null || _b === void 0 ? void 0 : _b.querySelectorAll(`[data-dx-grid-plane-${axis}="${planeAxis}"]`)) !== null && _c !== void 0 ? _c : [planeElement]).filter((el) => !!el);
315
- (_d = adjacentPlanes[(adjacentPlanes.length + adjacentPlanes.indexOf(planeElement) + delta) % adjacentPlanes.length]) === null || _d === void 0 ? void 0 : _d.focus({ preventScroll: true });
319
+ const planeAxis = planeElement?.getAttribute(`data-dx-grid-plane-${axis}`);
320
+ const adjacentPlanes = Array.from(this.gridRef.value?.querySelectorAll(`[data-dx-grid-plane-${axis}="${planeAxis}"]`) ?? [planeElement]).filter((el) => !!el);
321
+ adjacentPlanes[(adjacentPlanes.length + adjacentPlanes.indexOf(planeElement) + delta) % adjacentPlanes.length]?.focus({ preventScroll: true });
316
322
  }
317
323
  }
318
324
  moveFocusIntoPlane(plane) {
319
- var _a;
320
325
  if (this.focusedCell.plane !== plane) {
321
326
  const colPlane = resolveColPlane(plane);
322
327
  const rowPlane = resolveRowPlane(plane);
@@ -326,11 +331,10 @@ let DxGrid = class DxGrid extends LitElement {
326
331
  row: rowPlane === 'grid' ? this.visRowMin : 0,
327
332
  };
328
333
  }
329
- (_a = this.focusedCellElement()) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true });
334
+ this.focusedCellElement()?.focus({ preventScroll: true });
330
335
  }
331
336
  moveFocusToPlane() {
332
- var _a;
333
- (_a = this.focusedPlaneElement()) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true });
337
+ this.focusedPlaneElement()?.focus({ preventScroll: true });
334
338
  }
335
339
  handleKeydown(event) {
336
340
  if (this.focusActive && this.mode === 'browse') {
@@ -381,6 +385,13 @@ let DxGrid = class DxGrid extends LitElement {
381
385
  event.preventDefault();
382
386
  this.dispatchEditRequest();
383
387
  break;
388
+ case 'Backspace':
389
+ case 'Delete':
390
+ if (!event.defaultPrevented) {
391
+ event.preventDefault();
392
+ this.dispatchEditRequest('');
393
+ }
394
+ break;
384
395
  default:
385
396
  if (event.key.length === 1 && event.key.match(/\P{Cc}/u) && !(event.metaKey || event.ctrlKey)) {
386
397
  this.dispatchEditRequest(event.key);
@@ -394,19 +405,16 @@ let DxGrid = class DxGrid extends LitElement {
394
405
  // Accessors
395
406
  //
396
407
  colSize(c, plane) {
397
- var _a, _b, _c, _d, _e;
398
408
  const resolvedPlane = resolveColPlane(plane);
399
- return (_e = (_c = (_b = (_a = this.colSizes) === null || _a === void 0 ? void 0 : _a[resolvedPlane]) === null || _b === void 0 ? void 0 : _b[c]) !== null && _c !== void 0 ? _c : (_d = this.columnDefault[resolvedPlane]) === null || _d === void 0 ? void 0 : _d.size) !== null && _e !== void 0 ? _e : defaultColSize;
409
+ return this.colSizes?.[resolvedPlane]?.[c] ?? this.columnDefault[resolvedPlane]?.size ?? defaultColSize;
400
410
  }
401
411
  rowSize(r, plane) {
402
- var _a, _b, _c, _d, _e;
403
412
  const resolvedPlane = resolveRowPlane(plane);
404
- return (_e = (_c = (_b = (_a = this.rowSizes) === null || _a === void 0 ? void 0 : _a[resolvedPlane]) === null || _b === void 0 ? void 0 : _b[r]) !== null && _c !== void 0 ? _c : (_d = this.rowDefault[resolvedPlane]) === null || _d === void 0 ? void 0 : _d.size) !== null && _e !== void 0 ? _e : defaultRowSize;
413
+ return this.rowSizes?.[resolvedPlane]?.[r] ?? this.rowDefault[resolvedPlane]?.size ?? defaultRowSize;
405
414
  }
406
415
  cell(c, r, plane) {
407
- var _a, _b, _c, _d, _e;
408
416
  const index = `${c}${separator}${r}`;
409
- return (_c = (_b = (_a = this.cells) === null || _a === void 0 ? void 0 : _a[plane]) === null || _b === void 0 ? void 0 : _b[index]) !== null && _c !== void 0 ? _c : (_e = (_d = this.initialCells) === null || _d === void 0 ? void 0 : _d[plane]) === null || _e === void 0 ? void 0 : _e[index];
417
+ return this.cells?.[plane]?.[index] ?? this.initialCells?.[plane]?.[index];
410
418
  }
411
419
  cellActive(c, r, plane) {
412
420
  return this.focusedCell.plane === plane && this.focusedCell.col === c && this.focusedCell.row === r;
@@ -467,11 +475,11 @@ let DxGrid = class DxGrid extends LitElement {
467
475
  return this.intrinsicBlockSize - this.sizeBlock;
468
476
  }
469
477
  updatePosInline(inline, maxInline = this.maxPosInline()) {
470
- this.posInline = Math.max(0, Math.min(maxInline, inline !== null && inline !== void 0 ? inline : this.posInline));
478
+ this.posInline = Math.max(0, Math.min(maxInline, inline ?? this.posInline));
471
479
  this.maybeUpdateVisInline();
472
480
  }
473
481
  updatePosBlock(block, maxBlock = this.maxPosBlock()) {
474
- this.posBlock = Math.max(0, Math.min(maxBlock, block !== null && block !== void 0 ? block : this.posBlock));
482
+ this.posBlock = Math.max(0, Math.min(maxBlock, block ?? this.posBlock));
475
483
  this.maybeUpdateVisBlock();
476
484
  }
477
485
  updatePos(inline, block, maxInline, maxBlock) {
@@ -479,7 +487,6 @@ let DxGrid = class DxGrid extends LitElement {
479
487
  this.updatePosBlock(block, maxBlock);
480
488
  }
481
489
  updateVisInline() {
482
- var _a, _b;
483
490
  // todo: avoid starting from zero
484
491
  let axisCursor = 0;
485
492
  let pxCursor = this.colSize(axisCursor, 'grid');
@@ -509,15 +516,19 @@ let DxGrid = class DxGrid extends LitElement {
509
516
  this.templateGridColumns = [...Array(this.visColMax - this.visColMin)]
510
517
  .map((_, c0) => `${this.colSize(this.visColMin + c0, 'grid')}px`)
511
518
  .join(' ');
512
- this.templatefrozenColsStart = [...Array((_a = this.frozen.frozenColsStart) !== null && _a !== void 0 ? _a : 0)]
519
+ this.templatefrozenColsStart = [...Array(this.frozen.frozenColsStart ?? 0)]
513
520
  .map((_, c0) => `${this.colSize(c0, 'frozenColsStart')}px`)
514
521
  .join(' ');
515
- this.templatefrozenColsEnd = [...Array((_b = this.frozen.frozenColsEnd) !== null && _b !== void 0 ? _b : 0)]
522
+ this.templatefrozenColsEnd = [...Array(this.frozen.frozenColsEnd ?? 0)]
516
523
  .map((_, c0) => `${this.colSize(c0, 'frozenColsEnd')}px`)
517
524
  .join(' ');
525
+ this.frozenColsSize =
526
+ [...Array(this.frozen.frozenColsStart ?? 0)].reduce((sum, _, c0) => sum + this.colSize(c0, 'frozenColsStart'), 0) +
527
+ gap * Math.max(0, this.frozen.frozenColsStart ?? 0 - 1) +
528
+ [...Array(this.frozen.frozenColsEnd ?? 0)].reduce((sum, _, c0) => sum + this.colSize(c0, 'frozenColsEnd'), 0) +
529
+ gap * Math.max(0, this.frozen.frozenColsEnd ?? 0 - 1);
518
530
  }
519
531
  updateVisBlock() {
520
- var _a, _b;
521
532
  // todo: avoid starting from zero
522
533
  let axisCursor = 0;
523
534
  let pxCursor = this.rowSize(axisCursor, 'grid');
@@ -547,19 +558,23 @@ let DxGrid = class DxGrid extends LitElement {
547
558
  this.templateGridRows = [...Array(this.visRowMax - this.visRowMin)]
548
559
  .map((_, r0) => `${this.rowSize(this.visRowMin + r0, 'grid')}px`)
549
560
  .join(' ');
550
- this.templatefrozenRowsStart = [...Array((_a = this.frozen.frozenRowsStart) !== null && _a !== void 0 ? _a : 0)]
561
+ this.templatefrozenRowsStart = [...Array(this.frozen.frozenRowsStart ?? 0)]
551
562
  .map((_, r0) => `${this.rowSize(r0, 'frozenRowsStart')}px`)
552
563
  .join(' ');
553
- this.templatefrozenRowsEnd = [...Array((_b = this.frozen.frozenRowsEnd) !== null && _b !== void 0 ? _b : 0)]
564
+ this.templatefrozenRowsEnd = [...Array(this.frozen.frozenRowsEnd ?? 0)]
554
565
  .map((_, r0) => `${this.rowSize(r0, 'frozenRowsEnd')}px`)
555
566
  .join(' ');
567
+ this.frozenRowsSize =
568
+ [...Array(this.frozen.frozenRowsStart ?? 0)].reduce((sum, _, r0) => sum + this.rowSize(r0, 'frozenRowsStart'), 0) +
569
+ gap * Math.max(0, this.frozen.frozenRowsStart ?? 0 - 1) +
570
+ [...Array(this.frozen.frozenRowsEnd ?? 0)].reduce((sum, _, r0) => sum + this.rowSize(r0, 'frozenRowsEnd'), 0) +
571
+ gap * Math.max(0, this.frozen.frozenRowsEnd ?? 0 - 1);
556
572
  }
557
573
  updateVis() {
558
574
  this.updateVisInline();
559
575
  this.updateVisBlock();
560
576
  }
561
577
  updateCells(includeFixed) {
562
- var _a, _b, _c, _d, _e, _f, _g, _h;
563
578
  this.cells.grid = this.getCells({
564
579
  start: { col: this.visColMin, row: this.visRowMin },
565
580
  end: { col: this.visColMax, row: this.visRowMax },
@@ -578,25 +593,25 @@ let DxGrid = class DxGrid extends LitElement {
578
593
  }, plane);
579
594
  });
580
595
  if (includeFixed) {
581
- if (((_a = this.frozen.frozenColsStart) !== null && _a !== void 0 ? _a : 0) > 0 && ((_b = this.frozen.frozenRowsStart) !== null && _b !== void 0 ? _b : 0) > 0) {
596
+ if ((this.frozen.frozenColsStart ?? 0) > 0 && (this.frozen.frozenRowsStart ?? 0) > 0) {
582
597
  this.cells.fixedStartStart = this.getCells({
583
598
  start: { col: 0, row: 0 },
584
599
  end: { col: this.frozen.frozenColsStart, row: this.frozen.frozenRowsStart },
585
600
  }, 'fixedStartStart');
586
601
  }
587
- if (((_c = this.frozen.frozenColsEnd) !== null && _c !== void 0 ? _c : 0) > 0 && ((_d = this.frozen.frozenRowsStart) !== null && _d !== void 0 ? _d : 0) > 0) {
602
+ if ((this.frozen.frozenColsEnd ?? 0) > 0 && (this.frozen.frozenRowsStart ?? 0) > 0) {
588
603
  this.cells.fixedStartEnd = this.getCells({
589
604
  start: { col: 0, row: 0 },
590
605
  end: { col: this.frozen.frozenColsEnd, row: this.frozen.frozenRowsStart },
591
606
  }, 'fixedStartEnd');
592
607
  }
593
- if (((_e = this.frozen.frozenColsStart) !== null && _e !== void 0 ? _e : 0) > 0 && ((_f = this.frozen.frozenRowsEnd) !== null && _f !== void 0 ? _f : 0) > 0) {
608
+ if ((this.frozen.frozenColsStart ?? 0) > 0 && (this.frozen.frozenRowsEnd ?? 0) > 0) {
594
609
  this.cells.fixedEndStart = this.getCells({
595
610
  start: { col: 0, row: 0 },
596
611
  end: { col: this.frozen.frozenColsStart, row: this.frozen.frozenRowsEnd },
597
612
  }, 'fixedEndStart');
598
613
  }
599
- if (((_g = this.frozen.frozenColsEnd) !== null && _g !== void 0 ? _g : 0) > 0 && ((_h = this.frozen.frozenRowsEnd) !== null && _h !== void 0 ? _h : 0) > 0) {
614
+ if ((this.frozen.frozenColsEnd ?? 0) > 0 && (this.frozen.frozenRowsEnd ?? 0) > 0) {
600
615
  this.cells.fixedEndEnd = this.getCells({
601
616
  start: { col: 0, row: 0 },
602
617
  end: { col: this.frozen.frozenColsEnd, row: this.frozen.frozenRowsEnd },
@@ -634,12 +649,10 @@ let DxGrid = class DxGrid extends LitElement {
634
649
  return `[data-dx-grid-plane=${this.focusedCell.plane}]`;
635
650
  }
636
651
  focusedCellElement() {
637
- var _a;
638
- return (_a = this.gridRef.value) === null || _a === void 0 ? void 0 : _a.querySelector(this.focusedCellQuery());
652
+ return this.gridRef.value?.querySelector(this.focusedCellQuery());
639
653
  }
640
654
  focusedPlaneElement() {
641
- var _a;
642
- return (_a = this.gridRef.value) === null || _a === void 0 ? void 0 : _a.querySelector(this.focusedPlaneQuery());
655
+ return this.gridRef.value?.querySelector(this.focusedPlaneQuery());
643
656
  }
644
657
  //
645
658
  // `outOfVis` returns by how many rows/cols the focused cell is outside of the `vis` range for an axis, inset by a
@@ -798,22 +811,37 @@ let DxGrid = class DxGrid extends LitElement {
798
811
  // Resize handlers
799
812
  //
800
813
  axisResizeable(plane, axis, index) {
801
- var _a, _b, _c, _d, _e, _f, _g, _h;
802
814
  return axis === 'col'
803
- ? !!((_c = (_b = (_a = this.columns[plane]) === null || _a === void 0 ? void 0 : _a[index]) === null || _b === void 0 ? void 0 : _b.resizeable) !== null && _c !== void 0 ? _c : (_d = this.columnDefault[plane]) === null || _d === void 0 ? void 0 : _d.resizeable)
804
- : !!((_g = (_f = (_e = this.rows[plane]) === null || _e === void 0 ? void 0 : _e[index]) === null || _f === void 0 ? void 0 : _f.resizeable) !== null && _g !== void 0 ? _g : (_h = this.rowDefault[plane]) === null || _h === void 0 ? void 0 : _h.resizeable);
815
+ ? !!(this.columns[plane]?.[index]?.resizeable ?? this.columnDefault[plane]?.resizeable)
816
+ : !!(this.rows[plane]?.[index]?.resizeable ?? this.rowDefault[plane]?.resizeable);
817
+ }
818
+ clampAxisSize(plane, axis, index, requestedSize) {
819
+ const minSize = axis === 'col'
820
+ ? (this.columns[plane]?.[index]?.minSize ??
821
+ this.columnDefault[plane]?.minSize ??
822
+ sizeColMin)
823
+ : (this.rows[plane]?.[index]?.minSize ??
824
+ this.rowDefault[plane]?.minSize ??
825
+ sizeRowMin);
826
+ const maxSize = axis === 'col'
827
+ ? (this.columns[plane]?.[index]?.maxSize ??
828
+ this.columnDefault[plane]?.maxSize ??
829
+ sizeColMax)
830
+ : (this.rows[plane]?.[index]?.maxSize ??
831
+ this.rowDefault[plane]?.maxSize ??
832
+ sizeRowMax);
833
+ return Math.max(minSize, Math.min(maxSize, requestedSize));
805
834
  }
806
835
  handleAxisResizeInternal(event) {
807
836
  event.stopPropagation();
808
837
  const { plane, axis, delta, size, index, state } = event;
838
+ const nextSize = this.clampAxisSize(plane, axis, index, size + delta);
809
839
  if (axis === 'col') {
810
- const nextSize = Math.max(sizeColMin, Math.min(sizeColMax, size + delta));
811
840
  this.colSizes = { ...this.colSizes, [plane]: { ...this.colSizes[plane], [index]: nextSize } };
812
841
  this.updateVisInline();
813
842
  this.updateIntrinsicInlineSize();
814
843
  }
815
844
  else {
816
- const nextSize = Math.max(sizeRowMin, Math.min(sizeRowMax, size + delta));
817
845
  this.rowSizes = { ...this.colSizes, [plane]: { ...this.rowSizes[plane], [index]: nextSize } };
818
846
  this.updateVisBlock();
819
847
  this.updateIntrinsicBlockSize();
@@ -832,7 +860,6 @@ let DxGrid = class DxGrid extends LitElement {
832
860
  //
833
861
  // TODO(thure): This is for rendering presentational objects superimposed onto the canonical grid (e.g. DnD drop line for #8108).
834
862
  renderPresentationLayer(offsetInline, offsetBlock) {
835
- var _a, _b, _c, _d, _e, _f;
836
863
  const visibleCols = this.visColMax - this.visColMin;
837
864
  const visibleRows = this.visRowMax - this.visRowMin;
838
865
  return html `<div
@@ -840,32 +867,29 @@ let DxGrid = class DxGrid extends LitElement {
840
867
  class="dx-grid-layer--presentation"
841
868
  style=${styleMap({
842
869
  gridTemplateColumns: [
843
- ...[...Array((_a = this.frozen.frozenColsStart) !== null && _a !== void 0 ? _a : 0)].map((_, c0) => `${this.colSize(c0, 'frozenColsStart')}px`),
870
+ ...[...Array(this.frozen.frozenColsStart ?? 0)].map((_, c0) => `${this.colSize(c0, 'frozenColsStart')}px`),
844
871
  ...[...Array(visibleCols)].map((_, c0) => c0 === visibleCols - 1
845
872
  ? '1fr'
846
873
  : `${this.colSize(this.visColMin + c0, 'grid') + (c0 === 0 ? offsetInline : 0)}px`),
847
- ...[...Array((_b = this.frozen.frozenColsEnd) !== null && _b !== void 0 ? _b : 0)].map((_, c0) => `${this.colSize(c0, 'frozenColsEnd')}px`),
874
+ ...[...Array(this.frozen.frozenColsEnd ?? 0)].map((_, c0) => `${this.colSize(c0, 'frozenColsEnd')}px`),
848
875
  ].join(' '),
849
876
  gridTemplateRows: [
850
- ...[...Array((_c = this.frozen.frozenRowsStart) !== null && _c !== void 0 ? _c : 0)].map((_, r0) => `${this.rowSize(r0, 'frozenRowsStart')}px`),
877
+ ...[...Array(this.frozen.frozenRowsStart ?? 0)].map((_, r0) => `${this.rowSize(r0, 'frozenRowsStart')}px`),
851
878
  ...[...Array(visibleRows)].map((_, r0) => r0 === visibleRows - 1
852
879
  ? '1fr'
853
880
  : `${this.rowSize(this.visRowMin + r0, 'grid') + (r0 === 0 ? offsetBlock : 0)}px`),
854
- ...[...Array((_d = this.frozen.frozenRowsEnd) !== null && _d !== void 0 ? _d : 0)].map((_, r0) => `${this.rowSize(r0, 'frozenRowsEnd')}px`),
881
+ ...[...Array(this.frozen.frozenRowsEnd ?? 0)].map((_, r0) => `${this.rowSize(r0, 'frozenRowsEnd')}px`),
855
882
  ].join(' '),
856
883
  })}
857
884
  >
858
885
  ${
859
886
  /* TODO(thure): These are debug cells, remove when rendering actual overlay content. */ [
860
- ...Array(((_e = this.frozen.frozenRowsStart) !== null && _e !== void 0 ? _e : 0) + visibleRows + ((_f = this.frozen.frozenRowsEnd) !== null && _f !== void 0 ? _f : 0)),
861
- ].map((_, r0) => {
862
- var _a, _b;
863
- return [...Array(((_a = this.frozen.frozenColsStart) !== null && _a !== void 0 ? _a : 0) + visibleCols + ((_b = this.frozen.frozenColsEnd) !== null && _b !== void 0 ? _b : 0))].map((_, c0) => html `<div
887
+ ...Array((this.frozen.frozenRowsStart ?? 0) + visibleRows + (this.frozen.frozenRowsEnd ?? 0)),
888
+ ].map((_, r0) => [...Array((this.frozen.frozenColsStart ?? 0) + visibleCols + (this.frozen.frozenColsEnd ?? 0))].map((_, c0) => html `<div
864
889
  role="none"
865
890
  class="dx-grid-layer--presentation__cell"
866
891
  style="grid-column:${c0 + 1};grid-row:${r0 + 1}"
867
- ></div>`);
868
- })}
892
+ ></div>`))}
869
893
  </div>`;
870
894
  }
871
895
  renderFixed(plane, selection) {
@@ -873,7 +897,7 @@ let DxGrid = class DxGrid extends LitElement {
873
897
  const rowPlane = resolveRowPlane(plane);
874
898
  const cols = this.frozen[colPlane];
875
899
  const rows = this.frozen[rowPlane];
876
- return (cols !== null && cols !== void 0 ? cols : 0) > 0 && (rows !== null && rows !== void 0 ? rows : 0) > 0
900
+ return (cols ?? 0) > 0 && (rows ?? 0) > 0
877
901
  ? html `<div
878
902
  role="none"
879
903
  tabindex="0"
@@ -897,7 +921,7 @@ let DxGrid = class DxGrid extends LitElement {
897
921
  renderFrozenRows(plane, visibleCols, offsetInline, selection) {
898
922
  const rowPlane = resolveRowPlane(plane);
899
923
  const rows = this.frozen[rowPlane];
900
- return (rows !== null && rows !== void 0 ? rows : 0) > 0
924
+ return (rows ?? 0) > 0 && this.limitColumns > 0
901
925
  ? html `<div
902
926
  role="none"
903
927
  class="dx-grid__plane--frozen-row"
@@ -925,7 +949,7 @@ let DxGrid = class DxGrid extends LitElement {
925
949
  renderFrozenColumns(plane, visibleRows, offsetBlock, selection) {
926
950
  const colPlane = resolveColPlane(plane);
927
951
  const cols = this.frozen[colPlane];
928
- return (cols !== null && cols !== void 0 ? cols : 0) > 0
952
+ return (cols ?? 0) > 0 && this.limitRows > 0
929
953
  ? html `<div
930
954
  role="none"
931
955
  class="dx-grid__plane--frozen-col"
@@ -950,54 +974,119 @@ let DxGrid = class DxGrid extends LitElement {
950
974
  </div>`
951
975
  : null;
952
976
  }
977
+ renderMainGrid(visibleCols, visibleRows, offsetInline, offsetBlock, selection) {
978
+ return this.limitRows > 0 && this.limitColumns > 0
979
+ ? html `<div
980
+ role="grid"
981
+ class="dx-grid__plane--grid"
982
+ tabindex="0"
983
+ data-dx-grid-plane="grid"
984
+ data-dx-grid-plane-row="1"
985
+ data-dx-grid-plane-col="1"
986
+ >
987
+ <div
988
+ role="none"
989
+ class="dx-grid__plane--grid__content"
990
+ style="transform:translate3d(${offsetInline}px,${offsetBlock}px,0);grid-template-columns:${this
991
+ .templateGridColumns};grid-template-rows:${this.templateGridRows};"
992
+ >
993
+ ${[...Array(visibleRows)].map((_, r0) => {
994
+ return [...Array(visibleCols)].map((_, c0) => {
995
+ const c = c0 + this.visColMin;
996
+ const r = r0 + this.visRowMin;
997
+ return this.renderCell(c, r, 'grid', cellSelected(c, r, 'grid', selection), c0, r0);
998
+ });
999
+ })}
1000
+ </div>
1001
+ </div>`
1002
+ : null;
1003
+ }
953
1004
  cellReadonly(col, row, plane) {
954
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
955
1005
  const colPlane = resolveColPlane(plane);
956
1006
  const rowPlane = resolveRowPlane(plane);
957
1007
  // Check cell-specific setting first.
958
- const cellReadonly = (_a = this.cell(col, row, plane)) === null || _a === void 0 ? void 0 : _a.readonly;
1008
+ const cellReadonly = this.cell(col, row, plane)?.readonly;
959
1009
  if (cellReadonly !== undefined) {
960
1010
  return isReadonly(cellReadonly);
961
1011
  }
962
1012
  // Check column/row defaults.
963
- const colReadOnly = (_e = (_d = (_c = (_b = this.columns) === null || _b === void 0 ? void 0 : _b[colPlane]) === null || _c === void 0 ? void 0 : _c[col]) === null || _d === void 0 ? void 0 : _d.readonly) !== null && _e !== void 0 ? _e : (_g = (_f = this.columnDefault) === null || _f === void 0 ? void 0 : _f[colPlane]) === null || _g === void 0 ? void 0 : _g.readonly;
964
- const rowReadOnly = (_l = (_k = (_j = (_h = this.rows) === null || _h === void 0 ? void 0 : _h[rowPlane]) === null || _j === void 0 ? void 0 : _j[row]) === null || _k === void 0 ? void 0 : _k.readonly) !== null && _l !== void 0 ? _l : (_o = (_m = this.rowDefault) === null || _m === void 0 ? void 0 : _m[rowPlane]) === null || _o === void 0 ? void 0 : _o.readonly;
1013
+ const colReadOnly = this.columns?.[colPlane]?.[col]?.readonly ?? this.columnDefault?.[colPlane]?.readonly;
1014
+ const rowReadOnly = this.rows?.[rowPlane]?.[row]?.readonly ?? this.rowDefault?.[rowPlane]?.readonly;
965
1015
  return isReadonly(colReadOnly) || isReadonly(rowReadOnly);
966
1016
  }
1017
+ cellFocusUnfurl(col, row, plane) {
1018
+ const colPlane = resolveColPlane(plane);
1019
+ const rowPlane = resolveRowPlane(plane);
1020
+ // Check cell-specific setting first.
1021
+ const cellUnfurl = this.cell(col, row, plane)?.focusUnfurl;
1022
+ if (cellUnfurl !== undefined) {
1023
+ return cellUnfurl;
1024
+ }
1025
+ // Check column/row defaults.
1026
+ const colUnfurl = this.columns?.[colPlane]?.[col]?.focusUnfurl ?? this.columnDefault?.[colPlane]?.focusUnfurl;
1027
+ const rowUnfurl = this.rows?.[rowPlane]?.[row]?.focusUnfurl ?? this.rowDefault?.[rowPlane]?.focusUnfurl;
1028
+ return colUnfurl ?? rowUnfurl ?? focusUnfurlDefault;
1029
+ }
967
1030
  /**
968
1031
  * Determines if the cell's text content should be selectable based on its readonly value.
969
1032
  * @returns true if the cells text content is selectable, false otherwise.
970
1033
  */
971
1034
  cellTextSelectable(col, row, plane) {
972
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
973
1035
  const colPlane = resolveColPlane(plane);
974
1036
  const rowPlane = resolveRowPlane(plane);
975
1037
  // Check cell-specific setting first.
976
- const cellReadonly = (_a = this.cell(col, row, plane)) === null || _a === void 0 ? void 0 : _a.readonly;
1038
+ const cellReadonly = this.cell(col, row, plane)?.readonly;
977
1039
  if (cellReadonly !== undefined) {
978
1040
  return cellReadonly === 'text-select';
979
1041
  }
980
1042
  // Check column/row defaults.
981
- const colReadonly = (_e = (_d = (_c = (_b = this.columns) === null || _b === void 0 ? void 0 : _b[colPlane]) === null || _c === void 0 ? void 0 : _c[col]) === null || _d === void 0 ? void 0 : _d.readonly) !== null && _e !== void 0 ? _e : (_g = (_f = this.columnDefault) === null || _f === void 0 ? void 0 : _f[colPlane]) === null || _g === void 0 ? void 0 : _g.readonly;
982
- const rowReadonly = (_l = (_k = (_j = (_h = this.rows) === null || _h === void 0 ? void 0 : _h[rowPlane]) === null || _j === void 0 ? void 0 : _j[row]) === null || _k === void 0 ? void 0 : _k.readonly) !== null && _l !== void 0 ? _l : (_o = (_m = this.rowDefault) === null || _m === void 0 ? void 0 : _m[rowPlane]) === null || _o === void 0 ? void 0 : _o.readonly;
1043
+ const colReadonly = this.columns?.[colPlane]?.[col]?.readonly ?? this.columnDefault?.[colPlane]?.readonly;
1044
+ const rowReadonly = this.rows?.[rowPlane]?.[row]?.readonly ?? this.rowDefault?.[rowPlane]?.readonly;
983
1045
  return colReadonly === 'text-select' || rowReadonly === 'text-select';
984
1046
  }
1047
+ getOverflowingCellModifiedDeltas(event) {
1048
+ if (!event.target) {
1049
+ return event;
1050
+ }
1051
+ const element = event.target;
1052
+ const activeCell = element.closest('[data-dx-active]');
1053
+ const contentEl = element.closest('.dx-grid__cell__content');
1054
+ if (!activeCell || !contentEl || !document.activeElement?.contains(element)) {
1055
+ return event;
1056
+ }
1057
+ // Commented-out code will let the event delta through unmodified if the cell can scroll but is scrolled to the end
1058
+ // in the same direction as the wheel event, a.k.a. “overscroll”; this is probably undesirable, though.
1059
+ const { scrollWidth, clientWidth, scrollHeight, clientHeight /*, scrollLeft, scrollTop */ } = contentEl;
1060
+ if (scrollWidth <= clientWidth && scrollHeight <= clientHeight) {
1061
+ return event;
1062
+ }
1063
+ const deltaX = scrollWidth > clientWidth /* &&
1064
+ ((event.deltaX < 0 && scrollLeft > 0) || (event.deltaX > 0 && scrollLeft < scrollWidth - clientWidth)) */
1065
+ ? 0
1066
+ : event.deltaX;
1067
+ const deltaY = scrollHeight > clientHeight /* &&
1068
+ ((event.deltaY < 0 && scrollTop > 0) || (event.deltaY > 0 && scrollTop < scrollHeight - clientHeight)) */
1069
+ ? 0
1070
+ : event.deltaY;
1071
+ return { deltaX, deltaY };
1072
+ }
985
1073
  renderCell(col, row, plane, selected, visCol = col, visRow = row) {
986
- var _a, _b;
987
1074
  const cell = this.cell(col, row, plane);
988
1075
  const active = this.cellActive(col, row, plane);
989
1076
  const readonly = this.cellReadonly(col, row, plane);
1077
+ const focusUnfurl = this.cellFocusUnfurl(col, row, plane);
990
1078
  const textSelectable = this.cellTextSelectable(col, row, plane);
991
- const resizeIndex = (cell === null || cell === void 0 ? void 0 : cell.resizeHandle) ? (cell.resizeHandle === 'col' ? col : row) : undefined;
992
- const resizePlane = (cell === null || cell === void 0 ? void 0 : cell.resizeHandle) ? resolveFrozenPlane(cell.resizeHandle, plane) : undefined;
993
- const accessory = (cell === null || cell === void 0 ? void 0 : cell.accessoryHtml) ? staticHtml `${unsafeStatic(cell.accessoryHtml)}` : null;
1079
+ const resizeIndex = cell?.resizeHandle ? (cell.resizeHandle === 'col' ? col : row) : undefined;
1080
+ const resizePlane = cell?.resizeHandle ? resolveFrozenPlane(cell.resizeHandle, plane) : undefined;
1081
+ const accessory = cell?.accessoryHtml ? staticHtml `${unsafeStatic(cell.accessoryHtml)}` : null;
994
1082
  return html `<div
995
1083
  role="gridcell"
996
1084
  tabindex="0"
997
1085
  aria-selected=${selected ? 'true' : nothing}
998
1086
  aria-readonly=${readonly ? 'true' : nothing}
999
- class=${(_a = cell === null || cell === void 0 ? void 0 : cell.className) !== null && _a !== void 0 ? _a : nothing}
1000
- data-refs=${(_b = cell === null || cell === void 0 ? void 0 : cell.dataRefs) !== null && _b !== void 0 ? _b : nothing}
1087
+ class=${cell?.className ?? nothing}
1088
+ data-refs=${cell?.dataRefs ?? nothing}
1089
+ data-focus-unfurl=${focusUnfurl ? nothing : 'false'}
1001
1090
  ?data-dx-active=${active}
1002
1091
  data-text-selectable=${textSelectable ? 'true' : 'false'}
1003
1092
  data-dx-grid-action="cell"
@@ -1005,9 +1094,8 @@ let DxGrid = class DxGrid extends LitElement {
1005
1094
  aria-rowindex=${row}
1006
1095
  style="grid-column:${visCol + 1};grid-row:${visRow + 1}"
1007
1096
  >
1008
- ${this.mode !== 'browse' && active ? null : cell === null || cell === void 0 ? void 0 : cell.value}${this.mode !== 'browse' && active
1009
- ? null
1010
- : accessory}${(cell === null || cell === void 0 ? void 0 : cell.resizeHandle) &&
1097
+ <div role="none" class="dx-grid__cell__content">${cell?.value}${accessory}</div>
1098
+ ${cell?.resizeHandle &&
1011
1099
  this.mode === 'browse' &&
1012
1100
  this.axisResizeable(resizePlane, cell.resizeHandle, resizeIndex)
1013
1101
  ? html `<dx-grid-axis-resize-handle
@@ -1037,9 +1125,24 @@ let DxGrid = class DxGrid extends LitElement {
1037
1125
  <div
1038
1126
  role="none"
1039
1127
  class="dx-grid"
1128
+ data-arrow-keys="all"
1040
1129
  style=${styleMap({
1041
- 'grid-template-columns': `${this.templatefrozenColsStart ? 'min-content ' : ''}minmax(0, ${Number.isFinite(this.limitColumns) ? `${Math.max(0, this.intrinsicInlineSize)}px` : '1fr'})${this.templatefrozenColsEnd ? ' min-content' : ''}`,
1042
- 'grid-template-rows': `${this.templatefrozenRowsStart ? 'min-content ' : ''}minmax(0, ${Number.isFinite(this.limitRows) ? `${Math.max(0, this.intrinsicBlockSize)}px` : '1fr'})${this.templatefrozenRowsEnd ? ' min-content' : ''}`,
1130
+ 'grid-template-columns': [
1131
+ this.templatefrozenColsStart ? 'min-content' : false,
1132
+ this.limitColumns > 0 &&
1133
+ `minmax(0, ${Number.isFinite(this.limitColumns) ? `${Math.max(0, this.intrinsicInlineSize)}px` : '1fr'})`,
1134
+ this.templatefrozenColsEnd ? 'min-content' : false,
1135
+ ]
1136
+ .filter(Boolean)
1137
+ .join(' '),
1138
+ 'grid-template-rows': [
1139
+ this.templatefrozenRowsStart ? 'min-content' : false,
1140
+ this.limitRows > 0 &&
1141
+ `minmax(0, ${Number.isFinite(this.limitRows) ? `${Math.max(0, this.intrinsicBlockSize)}px` : '1fr'})`,
1142
+ this.templatefrozenRowsEnd ? ' min-content' : false,
1143
+ ]
1144
+ .filter(Boolean)
1145
+ .join(' '),
1043
1146
  '--dx-grid-content-inline-size': Number.isFinite(this.limitColumns)
1044
1147
  ? `${Math.max(0, this.totalIntrinsicInlineSize)}px`
1045
1148
  : 'max-content',
@@ -1053,70 +1156,34 @@ let DxGrid = class DxGrid extends LitElement {
1053
1156
  ${ref(this.gridRef)}
1054
1157
  >
1055
1158
  ${this.renderFixed('fixedStartStart', selection)}${this.renderFrozenRows('frozenRowsStart', visibleCols, offsetInline, selection)}${this.renderFixed('fixedStartEnd', selection)}${this.renderFrozenColumns('frozenColsStart', visibleRows, offsetBlock, selection)}
1056
- <div
1057
- role="grid"
1058
- class="dx-grid__plane--grid"
1059
- tabindex="0"
1060
- data-dx-grid-plane="grid"
1061
- data-dx-grid-plane-row="1"
1062
- data-dx-grid-plane-col="1"
1063
- ${ref(this.viewportRef)}
1064
- >
1065
- <div
1066
- role="none"
1067
- class="dx-grid__plane--grid__content"
1068
- style="transform:translate3d(${offsetInline}px,${offsetBlock}px,0);grid-template-columns:${this
1069
- .templateGridColumns};grid-template-rows:${this.templateGridRows};"
1070
- >
1071
- ${[...Array(visibleRows)].map((_, r0) => {
1072
- return [...Array(visibleCols)].map((_, c0) => {
1073
- const c = c0 + this.visColMin;
1074
- const r = r0 + this.visRowMin;
1075
- return this.renderCell(c, r, 'grid', cellSelected(c, r, 'grid', selection), c0, r0);
1076
- });
1077
- })}
1078
- </div>
1079
- </div>
1159
+ ${this.renderMainGrid(visibleCols, visibleRows, offsetInline, offsetBlock, selection)}
1080
1160
  ${this.renderFrozenColumns('frozenColsEnd', visibleRows, offsetBlock, selection)}${this.renderFixed('fixedEndStart', selection)}${this.renderFrozenRows('frozenRowsEnd', visibleCols, offsetInline, selection)}${this.renderFixed('fixedEndEnd', selection)}
1081
1161
  </div>`;
1082
1162
  }
1083
1163
  updateIntrinsicInlineSize() {
1084
1164
  this.intrinsicInlineSize = Number.isFinite(this.limitColumns)
1085
1165
  ? [...Array(this.limitColumns)].reduce((acc, _, c0) => acc + this.colSize(c0, 'grid'), 0) +
1086
- gap * (this.limitColumns - 1)
1166
+ gap * Math.max(0, this.limitColumns - 1)
1087
1167
  : Infinity;
1088
1168
  this.totalIntrinsicInlineSize =
1089
- this.intrinsicInlineSize +
1090
- (Number.isFinite(this.frozen.frozenColsStart)
1091
- ? [...Array(this.frozen.frozenColsStart)].reduce((acc, _, c0) => acc + gap + this.colSize(c0, 'frozenColsStart'), 0)
1092
- : 0) +
1093
- (Number.isFinite(this.frozen.frozenColsEnd)
1094
- ? [...Array(this.frozen.frozenColsEnd)].reduce((acc, _, c0) => acc + gap + this.colSize(c0, 'frozenColsEnd'), 0)
1095
- : 0);
1169
+ this.limitColumns > 0 ? this.intrinsicInlineSize + this.frozenColsSize : this.frozenColsSize - gap;
1096
1170
  }
1097
1171
  updateIntrinsicBlockSize() {
1098
1172
  this.intrinsicBlockSize = Number.isFinite(this.limitRows)
1099
1173
  ? [...Array(this.limitRows)].reduce((acc, _, r0) => acc + this.rowSize(r0, 'grid'), 0) +
1100
- gap * (this.limitRows - 1)
1174
+ gap * Math.max(0, this.limitRows - 1)
1101
1175
  : Infinity;
1102
1176
  this.totalIntrinsicBlockSize =
1103
- this.intrinsicBlockSize +
1104
- (Number.isFinite(this.frozen.frozenRowsStart)
1105
- ? [...Array(this.frozen.frozenRowsStart)].reduce((acc, _, r0) => acc + gap + this.rowSize(r0, 'frozenRowsStart'), 0)
1106
- : 0) +
1107
- (Number.isFinite(this.frozen.frozenRowsEnd)
1108
- ? [...Array(this.frozen.frozenRowsEnd)].reduce((acc, _, r0) => acc + gap + this.rowSize(r0, 'frozenRowsEnd'), 0)
1109
- : 0);
1177
+ this.limitRows > 0 ? this.intrinsicBlockSize + this.frozenRowsSize : this.frozenRowsSize - gap;
1110
1178
  }
1111
1179
  updateIntrinsicSizes() {
1112
1180
  this.updateIntrinsicInlineSize();
1113
1181
  this.updateIntrinsicBlockSize();
1114
1182
  }
1115
1183
  computeColSizes() {
1116
- var _a;
1117
- this.colSizes = Object.entries((_a = this.columns) !== null && _a !== void 0 ? _a : {}).reduce((acc, [plane, planeColMeta]) => {
1184
+ this.colSizes = Object.entries(this.columns ?? {}).reduce((acc, [plane, planeColMeta]) => {
1118
1185
  acc[plane] = Object.entries(planeColMeta).reduce((planeAcc, [col, colMeta]) => {
1119
- if (colMeta === null || colMeta === void 0 ? void 0 : colMeta.size) {
1186
+ if (colMeta?.size) {
1120
1187
  planeAcc[col] = colMeta.size;
1121
1188
  }
1122
1189
  return planeAcc;
@@ -1125,10 +1192,9 @@ let DxGrid = class DxGrid extends LitElement {
1125
1192
  }, { grid: {} });
1126
1193
  }
1127
1194
  computeRowSizes() {
1128
- var _a;
1129
- this.rowSizes = Object.entries((_a = this.rows) !== null && _a !== void 0 ? _a : {}).reduce((acc, [plane, planeRowMeta]) => {
1195
+ this.rowSizes = Object.entries(this.rows ?? {}).reduce((acc, [plane, planeRowMeta]) => {
1130
1196
  acc[plane] = Object.entries(planeRowMeta).reduce((planeAcc, [row, rowMeta]) => {
1131
- if (rowMeta === null || rowMeta === void 0 ? void 0 : rowMeta.size) {
1197
+ if (rowMeta?.size) {
1132
1198
  planeAcc[row] = rowMeta.size;
1133
1199
  }
1134
1200
  return planeAcc;
@@ -1140,7 +1206,7 @@ let DxGrid = class DxGrid extends LitElement {
1140
1206
  if (this.getCells) {
1141
1207
  this.updateCells(true);
1142
1208
  }
1143
- this.observer.observe(this.viewportRef.value);
1209
+ this.observer.observe(this.gridRef.value);
1144
1210
  this.computeColSizes();
1145
1211
  this.computeRowSizes();
1146
1212
  this.updateIntrinsicSizes();
@@ -1160,6 +1226,12 @@ let DxGrid = class DxGrid extends LitElement {
1160
1226
  this.updatePosInline();
1161
1227
  this.updateVisInline();
1162
1228
  }
1229
+ if (changedProperties.has('frozen')) {
1230
+ this.updateIntrinsicBlockSize();
1231
+ this.updateIntrinsicInlineSize();
1232
+ this.updateVisBlock();
1233
+ this.updateVisInline();
1234
+ }
1163
1235
  if (this.getCells &&
1164
1236
  (changedProperties.has('initialCells') ||
1165
1237
  changedProperties.has('visColMin') ||
@@ -1169,7 +1241,8 @@ let DxGrid = class DxGrid extends LitElement {
1169
1241
  changedProperties.has('columns') ||
1170
1242
  changedProperties.has('rows') ||
1171
1243
  changedProperties.has('limitColumns') ||
1172
- changedProperties.has('limitRows'))) {
1244
+ changedProperties.has('limitRows') ||
1245
+ changedProperties.has('frozen'))) {
1173
1246
  this.updateCells(true);
1174
1247
  }
1175
1248
  }
@@ -1184,20 +1257,20 @@ let DxGrid = class DxGrid extends LitElement {
1184
1257
  this.refocus();
1185
1258
  }
1186
1259
  }
1187
- updateIfWithinBounds({ col, row }) {
1260
+ updateIfWithinBounds({ col, row }, includeFixed) {
1188
1261
  if (col >= this.visColMin && col <= this.visColMax && row >= this.visRowMin && row <= this.visRowMax) {
1262
+ this.updateCells(includeFixed);
1189
1263
  this.requestUpdate();
1190
1264
  return true;
1191
1265
  }
1192
1266
  return false;
1193
1267
  }
1194
1268
  disconnectedCallback() {
1195
- var _a;
1196
1269
  super.disconnectedCallback();
1197
- if (this.viewportRef.value) {
1198
- this.observer.unobserve(this.viewportRef.value);
1270
+ if (this.gridRef.value) {
1271
+ this.observer.unobserve(this.gridRef.value);
1199
1272
  }
1200
- (_a = document.defaultView) === null || _a === void 0 ? void 0 : _a.removeEventListener('wheel', this.handleTopLevelWheel);
1273
+ document.defaultView?.removeEventListener('wheel', this.handleTopLevelWheel);
1201
1274
  }
1202
1275
  createRenderRoot() {
1203
1276
  return this;
@@ -1302,6 +1375,12 @@ __decorate([
1302
1375
  __decorate([
1303
1376
  state()
1304
1377
  ], DxGrid.prototype, "templatefrozenRowsEnd", void 0);
1378
+ __decorate([
1379
+ state()
1380
+ ], DxGrid.prototype, "frozenColsSize", void 0);
1381
+ __decorate([
1382
+ state()
1383
+ ], DxGrid.prototype, "frozenRowsSize", void 0);
1305
1384
  __decorate([
1306
1385
  state()
1307
1386
  ], DxGrid.prototype, "pointer", void 0);
@@ -1342,6 +1421,6 @@ DxGrid = __decorate([
1342
1421
  customElement('dx-grid')
1343
1422
  ], DxGrid);
1344
1423
  export { DxGrid };
1345
- export { rowToA1Notation, colToA1Notation, closestAction, closestCell, parseCellIndex, toPlaneCellIndex, cellQuery, } from './util';
1424
+ export { rowToA1Notation, colToA1Notation, closestAction, closestCell, parseCellIndex, toPlaneCellIndex, cellQuery, accessoryHandlesPointerdownAttrs, } from './util';
1346
1425
  export const commentedClassName = 'dx-grid__cell--commented';
1347
1426
  //# sourceMappingURL=dx-grid.js.map