@dxos/lit-grid 0.8.4-main.b97322e → 0.8.4-main.dedc0f3

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 (38) 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 +9 -5
  12. package/dist/src/dx-grid.d.ts.map +1 -1
  13. package/dist/src/dx-grid.js +181 -145
  14. package/dist/src/dx-grid.js.map +1 -1
  15. package/dist/src/dx-grid.lit-stories.js +15 -18
  16. package/dist/src/dx-grid.lit-stories.js.map +1 -1
  17. package/dist/src/playwright/dx-grid.spec.js.map +1 -1
  18. package/dist/src/testing/dx-grid-manager.d.ts.map +1 -1
  19. package/dist/src/testing/dx-grid-manager.js.map +1 -1
  20. package/dist/src/types.d.ts +7 -0
  21. package/dist/src/types.d.ts.map +1 -1
  22. package/dist/src/types.js.map +1 -1
  23. package/dist/src/util.d.ts +4 -1
  24. package/dist/src/util.d.ts.map +1 -1
  25. package/dist/src/util.js +11 -11
  26. package/dist/src/util.js.map +1 -1
  27. package/dist/tsconfig.tsbuildinfo +1 -1
  28. package/package.json +3 -3
  29. package/src/defs.ts +1 -0
  30. package/src/dx-grid-axis-resize-handle.pcss +6 -0
  31. package/src/dx-grid-axis-resize-handle.ts +1 -1
  32. package/src/dx-grid-multiselect-cell.ts +2 -1
  33. package/src/dx-grid.pcss +14 -1
  34. package/src/dx-grid.ts +172 -91
  35. package/src/playwright/dx-grid.spec.ts +1 -1
  36. package/src/testing/dx-grid-manager.ts +1 -1
  37. package/src/types.ts +7 -0
  38. package/src/util.ts +13 -9
@@ -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,8 +195,7 @@ 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)) {
@@ -230,7 +228,7 @@ let DxGrid = class DxGrid extends LitElement {
230
228
  }
231
229
  };
232
230
  // Wheel, top-level and element-level
233
- (_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 });
234
232
  this.addEventListener('wheel', this.handleWheel);
235
233
  // Custom event(s)
236
234
  this.addEventListener('dx-axis-resize-internal', this.handleAxisResizeInternal);
@@ -314,18 +312,16 @@ let DxGrid = class DxGrid extends LitElement {
314
312
  }
315
313
  }
316
314
  moveFocusBetweenPlanes(event, plane) {
317
- var _a, _b, _c, _d;
318
- 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}"]`);
319
316
  if (planeElement) {
320
317
  const axis = event.key === 'ArrowUp' || event.key === 'ArrowDown' ? 'col' : 'row';
321
318
  const delta = event.key === 'ArrowLeft' || event.key === 'ArrowUp' ? -1 : 1;
322
- const planeAxis = planeElement === null || planeElement === void 0 ? void 0 : planeElement.getAttribute(`data-dx-grid-plane-${axis}`);
323
- 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);
324
- (_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 });
325
322
  }
326
323
  }
327
324
  moveFocusIntoPlane(plane) {
328
- var _a;
329
325
  if (this.focusedCell.plane !== plane) {
330
326
  const colPlane = resolveColPlane(plane);
331
327
  const rowPlane = resolveRowPlane(plane);
@@ -335,11 +331,10 @@ let DxGrid = class DxGrid extends LitElement {
335
331
  row: rowPlane === 'grid' ? this.visRowMin : 0,
336
332
  };
337
333
  }
338
- (_a = this.focusedCellElement()) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true });
334
+ this.focusedCellElement()?.focus({ preventScroll: true });
339
335
  }
340
336
  moveFocusToPlane() {
341
- var _a;
342
- (_a = this.focusedPlaneElement()) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true });
337
+ this.focusedPlaneElement()?.focus({ preventScroll: true });
343
338
  }
344
339
  handleKeydown(event) {
345
340
  if (this.focusActive && this.mode === 'browse') {
@@ -390,6 +385,13 @@ let DxGrid = class DxGrid extends LitElement {
390
385
  event.preventDefault();
391
386
  this.dispatchEditRequest();
392
387
  break;
388
+ case 'Backspace':
389
+ case 'Delete':
390
+ if (!event.defaultPrevented) {
391
+ event.preventDefault();
392
+ this.dispatchEditRequest('');
393
+ }
394
+ break;
393
395
  default:
394
396
  if (event.key.length === 1 && event.key.match(/\P{Cc}/u) && !(event.metaKey || event.ctrlKey)) {
395
397
  this.dispatchEditRequest(event.key);
@@ -403,19 +405,16 @@ let DxGrid = class DxGrid extends LitElement {
403
405
  // Accessors
404
406
  //
405
407
  colSize(c, plane) {
406
- var _a, _b, _c, _d, _e;
407
408
  const resolvedPlane = resolveColPlane(plane);
408
- 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;
409
410
  }
410
411
  rowSize(r, plane) {
411
- var _a, _b, _c, _d, _e;
412
412
  const resolvedPlane = resolveRowPlane(plane);
413
- 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;
414
414
  }
415
415
  cell(c, r, plane) {
416
- var _a, _b, _c, _d, _e;
417
416
  const index = `${c}${separator}${r}`;
418
- 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];
419
418
  }
420
419
  cellActive(c, r, plane) {
421
420
  return this.focusedCell.plane === plane && this.focusedCell.col === c && this.focusedCell.row === r;
@@ -476,11 +475,11 @@ let DxGrid = class DxGrid extends LitElement {
476
475
  return this.intrinsicBlockSize - this.sizeBlock;
477
476
  }
478
477
  updatePosInline(inline, maxInline = this.maxPosInline()) {
479
- 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));
480
479
  this.maybeUpdateVisInline();
481
480
  }
482
481
  updatePosBlock(block, maxBlock = this.maxPosBlock()) {
483
- 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));
484
483
  this.maybeUpdateVisBlock();
485
484
  }
486
485
  updatePos(inline, block, maxInline, maxBlock) {
@@ -488,7 +487,6 @@ let DxGrid = class DxGrid extends LitElement {
488
487
  this.updatePosBlock(block, maxBlock);
489
488
  }
490
489
  updateVisInline() {
491
- var _a, _b;
492
490
  // todo: avoid starting from zero
493
491
  let axisCursor = 0;
494
492
  let pxCursor = this.colSize(axisCursor, 'grid');
@@ -518,15 +516,19 @@ let DxGrid = class DxGrid extends LitElement {
518
516
  this.templateGridColumns = [...Array(this.visColMax - this.visColMin)]
519
517
  .map((_, c0) => `${this.colSize(this.visColMin + c0, 'grid')}px`)
520
518
  .join(' ');
521
- this.templatefrozenColsStart = [...Array((_a = this.frozen.frozenColsStart) !== null && _a !== void 0 ? _a : 0)]
519
+ this.templatefrozenColsStart = [...Array(this.frozen.frozenColsStart ?? 0)]
522
520
  .map((_, c0) => `${this.colSize(c0, 'frozenColsStart')}px`)
523
521
  .join(' ');
524
- this.templatefrozenColsEnd = [...Array((_b = this.frozen.frozenColsEnd) !== null && _b !== void 0 ? _b : 0)]
522
+ this.templatefrozenColsEnd = [...Array(this.frozen.frozenColsEnd ?? 0)]
525
523
  .map((_, c0) => `${this.colSize(c0, 'frozenColsEnd')}px`)
526
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);
527
530
  }
528
531
  updateVisBlock() {
529
- var _a, _b;
530
532
  // todo: avoid starting from zero
531
533
  let axisCursor = 0;
532
534
  let pxCursor = this.rowSize(axisCursor, 'grid');
@@ -556,19 +558,23 @@ let DxGrid = class DxGrid extends LitElement {
556
558
  this.templateGridRows = [...Array(this.visRowMax - this.visRowMin)]
557
559
  .map((_, r0) => `${this.rowSize(this.visRowMin + r0, 'grid')}px`)
558
560
  .join(' ');
559
- this.templatefrozenRowsStart = [...Array((_a = this.frozen.frozenRowsStart) !== null && _a !== void 0 ? _a : 0)]
561
+ this.templatefrozenRowsStart = [...Array(this.frozen.frozenRowsStart ?? 0)]
560
562
  .map((_, r0) => `${this.rowSize(r0, 'frozenRowsStart')}px`)
561
563
  .join(' ');
562
- this.templatefrozenRowsEnd = [...Array((_b = this.frozen.frozenRowsEnd) !== null && _b !== void 0 ? _b : 0)]
564
+ this.templatefrozenRowsEnd = [...Array(this.frozen.frozenRowsEnd ?? 0)]
563
565
  .map((_, r0) => `${this.rowSize(r0, 'frozenRowsEnd')}px`)
564
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);
565
572
  }
566
573
  updateVis() {
567
574
  this.updateVisInline();
568
575
  this.updateVisBlock();
569
576
  }
570
577
  updateCells(includeFixed) {
571
- var _a, _b, _c, _d, _e, _f, _g, _h;
572
578
  this.cells.grid = this.getCells({
573
579
  start: { col: this.visColMin, row: this.visRowMin },
574
580
  end: { col: this.visColMax, row: this.visRowMax },
@@ -587,25 +593,25 @@ let DxGrid = class DxGrid extends LitElement {
587
593
  }, plane);
588
594
  });
589
595
  if (includeFixed) {
590
- 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) {
591
597
  this.cells.fixedStartStart = this.getCells({
592
598
  start: { col: 0, row: 0 },
593
599
  end: { col: this.frozen.frozenColsStart, row: this.frozen.frozenRowsStart },
594
600
  }, 'fixedStartStart');
595
601
  }
596
- 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) {
597
603
  this.cells.fixedStartEnd = this.getCells({
598
604
  start: { col: 0, row: 0 },
599
605
  end: { col: this.frozen.frozenColsEnd, row: this.frozen.frozenRowsStart },
600
606
  }, 'fixedStartEnd');
601
607
  }
602
- 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) {
603
609
  this.cells.fixedEndStart = this.getCells({
604
610
  start: { col: 0, row: 0 },
605
611
  end: { col: this.frozen.frozenColsStart, row: this.frozen.frozenRowsEnd },
606
612
  }, 'fixedEndStart');
607
613
  }
608
- 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) {
609
615
  this.cells.fixedEndEnd = this.getCells({
610
616
  start: { col: 0, row: 0 },
611
617
  end: { col: this.frozen.frozenColsEnd, row: this.frozen.frozenRowsEnd },
@@ -643,12 +649,10 @@ let DxGrid = class DxGrid extends LitElement {
643
649
  return `[data-dx-grid-plane=${this.focusedCell.plane}]`;
644
650
  }
645
651
  focusedCellElement() {
646
- var _a;
647
- return (_a = this.gridRef.value) === null || _a === void 0 ? void 0 : _a.querySelector(this.focusedCellQuery());
652
+ return this.gridRef.value?.querySelector(this.focusedCellQuery());
648
653
  }
649
654
  focusedPlaneElement() {
650
- var _a;
651
- return (_a = this.gridRef.value) === null || _a === void 0 ? void 0 : _a.querySelector(this.focusedPlaneQuery());
655
+ return this.gridRef.value?.querySelector(this.focusedPlaneQuery());
652
656
  }
653
657
  //
654
658
  // `outOfVis` returns by how many rows/cols the focused cell is outside of the `vis` range for an axis, inset by a
@@ -807,22 +811,37 @@ let DxGrid = class DxGrid extends LitElement {
807
811
  // Resize handlers
808
812
  //
809
813
  axisResizeable(plane, axis, index) {
810
- var _a, _b, _c, _d, _e, _f, _g, _h;
811
814
  return axis === 'col'
812
- ? !!((_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)
813
- : !!((_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));
814
834
  }
815
835
  handleAxisResizeInternal(event) {
816
836
  event.stopPropagation();
817
837
  const { plane, axis, delta, size, index, state } = event;
838
+ const nextSize = this.clampAxisSize(plane, axis, index, size + delta);
818
839
  if (axis === 'col') {
819
- const nextSize = Math.max(sizeColMin, Math.min(sizeColMax, size + delta));
820
840
  this.colSizes = { ...this.colSizes, [plane]: { ...this.colSizes[plane], [index]: nextSize } };
821
841
  this.updateVisInline();
822
842
  this.updateIntrinsicInlineSize();
823
843
  }
824
844
  else {
825
- const nextSize = Math.max(sizeRowMin, Math.min(sizeRowMax, size + delta));
826
845
  this.rowSizes = { ...this.colSizes, [plane]: { ...this.rowSizes[plane], [index]: nextSize } };
827
846
  this.updateVisBlock();
828
847
  this.updateIntrinsicBlockSize();
@@ -841,7 +860,6 @@ let DxGrid = class DxGrid extends LitElement {
841
860
  //
842
861
  // TODO(thure): This is for rendering presentational objects superimposed onto the canonical grid (e.g. DnD drop line for #8108).
843
862
  renderPresentationLayer(offsetInline, offsetBlock) {
844
- var _a, _b, _c, _d, _e, _f;
845
863
  const visibleCols = this.visColMax - this.visColMin;
846
864
  const visibleRows = this.visRowMax - this.visRowMin;
847
865
  return html `<div
@@ -849,32 +867,29 @@ let DxGrid = class DxGrid extends LitElement {
849
867
  class="dx-grid-layer--presentation"
850
868
  style=${styleMap({
851
869
  gridTemplateColumns: [
852
- ...[...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`),
853
871
  ...[...Array(visibleCols)].map((_, c0) => c0 === visibleCols - 1
854
872
  ? '1fr'
855
873
  : `${this.colSize(this.visColMin + c0, 'grid') + (c0 === 0 ? offsetInline : 0)}px`),
856
- ...[...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`),
857
875
  ].join(' '),
858
876
  gridTemplateRows: [
859
- ...[...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`),
860
878
  ...[...Array(visibleRows)].map((_, r0) => r0 === visibleRows - 1
861
879
  ? '1fr'
862
880
  : `${this.rowSize(this.visRowMin + r0, 'grid') + (r0 === 0 ? offsetBlock : 0)}px`),
863
- ...[...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`),
864
882
  ].join(' '),
865
883
  })}
866
884
  >
867
885
  ${
868
886
  /* TODO(thure): These are debug cells, remove when rendering actual overlay content. */ [
869
- ...Array(((_e = this.frozen.frozenRowsStart) !== null && _e !== void 0 ? _e : 0) + visibleRows + ((_f = this.frozen.frozenRowsEnd) !== null && _f !== void 0 ? _f : 0)),
870
- ].map((_, r0) => {
871
- var _a, _b;
872
- 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
873
889
  role="none"
874
890
  class="dx-grid-layer--presentation__cell"
875
891
  style="grid-column:${c0 + 1};grid-row:${r0 + 1}"
876
- ></div>`);
877
- })}
892
+ ></div>`))}
878
893
  </div>`;
879
894
  }
880
895
  renderFixed(plane, selection) {
@@ -882,7 +897,7 @@ let DxGrid = class DxGrid extends LitElement {
882
897
  const rowPlane = resolveRowPlane(plane);
883
898
  const cols = this.frozen[colPlane];
884
899
  const rows = this.frozen[rowPlane];
885
- 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
886
901
  ? html `<div
887
902
  role="none"
888
903
  tabindex="0"
@@ -906,7 +921,7 @@ let DxGrid = class DxGrid extends LitElement {
906
921
  renderFrozenRows(plane, visibleCols, offsetInline, selection) {
907
922
  const rowPlane = resolveRowPlane(plane);
908
923
  const rows = this.frozen[rowPlane];
909
- return (rows !== null && rows !== void 0 ? rows : 0) > 0
924
+ return (rows ?? 0) > 0 && this.limitColumns > 0
910
925
  ? html `<div
911
926
  role="none"
912
927
  class="dx-grid__plane--frozen-row"
@@ -934,7 +949,7 @@ let DxGrid = class DxGrid extends LitElement {
934
949
  renderFrozenColumns(plane, visibleRows, offsetBlock, selection) {
935
950
  const colPlane = resolveColPlane(plane);
936
951
  const cols = this.frozen[colPlane];
937
- return (cols !== null && cols !== void 0 ? cols : 0) > 0
952
+ return (cols ?? 0) > 0 && this.limitRows > 0
938
953
  ? html `<div
939
954
  role="none"
940
955
  class="dx-grid__plane--frozen-col"
@@ -959,47 +974,84 @@ let DxGrid = class DxGrid extends LitElement {
959
974
  </div>`
960
975
  : null;
961
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
+ }
962
1004
  cellReadonly(col, row, plane) {
963
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
964
1005
  const colPlane = resolveColPlane(plane);
965
1006
  const rowPlane = resolveRowPlane(plane);
966
1007
  // Check cell-specific setting first.
967
- 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;
968
1009
  if (cellReadonly !== undefined) {
969
1010
  return isReadonly(cellReadonly);
970
1011
  }
971
1012
  // Check column/row defaults.
972
- 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;
973
- 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;
974
1015
  return isReadonly(colReadOnly) || isReadonly(rowReadOnly);
975
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
+ }
976
1030
  /**
977
1031
  * Determines if the cell's text content should be selectable based on its readonly value.
978
1032
  * @returns true if the cells text content is selectable, false otherwise.
979
1033
  */
980
1034
  cellTextSelectable(col, row, plane) {
981
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
982
1035
  const colPlane = resolveColPlane(plane);
983
1036
  const rowPlane = resolveRowPlane(plane);
984
1037
  // Check cell-specific setting first.
985
- 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;
986
1039
  if (cellReadonly !== undefined) {
987
1040
  return cellReadonly === 'text-select';
988
1041
  }
989
1042
  // Check column/row defaults.
990
- 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;
991
- 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;
992
1045
  return colReadonly === 'text-select' || rowReadonly === 'text-select';
993
1046
  }
994
1047
  getOverflowingCellModifiedDeltas(event) {
995
- var _a;
996
1048
  if (!event.target) {
997
1049
  return event;
998
1050
  }
999
1051
  const element = event.target;
1000
1052
  const activeCell = element.closest('[data-dx-active]');
1001
1053
  const contentEl = element.closest('.dx-grid__cell__content');
1002
- if (!activeCell || !contentEl || !((_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.contains(element))) {
1054
+ if (!activeCell || !contentEl || !document.activeElement?.contains(element)) {
1003
1055
  return event;
1004
1056
  }
1005
1057
  // Commented-out code will let the event delta through unmodified if the cell can scroll but is scrolled to the end
@@ -1019,21 +1071,22 @@ let DxGrid = class DxGrid extends LitElement {
1019
1071
  return { deltaX, deltaY };
1020
1072
  }
1021
1073
  renderCell(col, row, plane, selected, visCol = col, visRow = row) {
1022
- var _a, _b;
1023
1074
  const cell = this.cell(col, row, plane);
1024
1075
  const active = this.cellActive(col, row, plane);
1025
1076
  const readonly = this.cellReadonly(col, row, plane);
1077
+ const focusUnfurl = this.cellFocusUnfurl(col, row, plane);
1026
1078
  const textSelectable = this.cellTextSelectable(col, row, plane);
1027
- const resizeIndex = (cell === null || cell === void 0 ? void 0 : cell.resizeHandle) ? (cell.resizeHandle === 'col' ? col : row) : undefined;
1028
- const resizePlane = (cell === null || cell === void 0 ? void 0 : cell.resizeHandle) ? resolveFrozenPlane(cell.resizeHandle, plane) : undefined;
1029
- 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;
1030
1082
  return html `<div
1031
1083
  role="gridcell"
1032
1084
  tabindex="0"
1033
1085
  aria-selected=${selected ? 'true' : nothing}
1034
1086
  aria-readonly=${readonly ? 'true' : nothing}
1035
- class=${(_a = cell === null || cell === void 0 ? void 0 : cell.className) !== null && _a !== void 0 ? _a : nothing}
1036
- 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'}
1037
1090
  ?data-dx-active=${active}
1038
1091
  data-text-selectable=${textSelectable ? 'true' : 'false'}
1039
1092
  data-dx-grid-action="cell"
@@ -1041,8 +1094,8 @@ let DxGrid = class DxGrid extends LitElement {
1041
1094
  aria-rowindex=${row}
1042
1095
  style="grid-column:${visCol + 1};grid-row:${visRow + 1}"
1043
1096
  >
1044
- <div role="none" class="dx-grid__cell__content">${cell === null || cell === void 0 ? void 0 : cell.value}${accessory}</div>
1045
- ${(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 &&
1046
1099
  this.mode === 'browse' &&
1047
1100
  this.axisResizeable(resizePlane, cell.resizeHandle, resizeIndex)
1048
1101
  ? html `<dx-grid-axis-resize-handle
@@ -1072,9 +1125,24 @@ let DxGrid = class DxGrid extends LitElement {
1072
1125
  <div
1073
1126
  role="none"
1074
1127
  class="dx-grid"
1128
+ data-arrow-keys="all"
1075
1129
  style=${styleMap({
1076
- 'grid-template-columns': `${this.templatefrozenColsStart ? 'min-content ' : ''}minmax(0, ${Number.isFinite(this.limitColumns) ? `${Math.max(0, this.intrinsicInlineSize)}px` : '1fr'})${this.templatefrozenColsEnd ? ' min-content' : ''}`,
1077
- '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(' '),
1078
1146
  '--dx-grid-content-inline-size': Number.isFinite(this.limitColumns)
1079
1147
  ? `${Math.max(0, this.totalIntrinsicInlineSize)}px`
1080
1148
  : 'max-content',
@@ -1088,70 +1156,34 @@ let DxGrid = class DxGrid extends LitElement {
1088
1156
  ${ref(this.gridRef)}
1089
1157
  >
1090
1158
  ${this.renderFixed('fixedStartStart', selection)}${this.renderFrozenRows('frozenRowsStart', visibleCols, offsetInline, selection)}${this.renderFixed('fixedStartEnd', selection)}${this.renderFrozenColumns('frozenColsStart', visibleRows, offsetBlock, selection)}
1091
- <div
1092
- role="grid"
1093
- class="dx-grid__plane--grid"
1094
- tabindex="0"
1095
- data-dx-grid-plane="grid"
1096
- data-dx-grid-plane-row="1"
1097
- data-dx-grid-plane-col="1"
1098
- ${ref(this.viewportRef)}
1099
- >
1100
- <div
1101
- role="none"
1102
- class="dx-grid__plane--grid__content"
1103
- style="transform:translate3d(${offsetInline}px,${offsetBlock}px,0);grid-template-columns:${this
1104
- .templateGridColumns};grid-template-rows:${this.templateGridRows};"
1105
- >
1106
- ${[...Array(visibleRows)].map((_, r0) => {
1107
- return [...Array(visibleCols)].map((_, c0) => {
1108
- const c = c0 + this.visColMin;
1109
- const r = r0 + this.visRowMin;
1110
- return this.renderCell(c, r, 'grid', cellSelected(c, r, 'grid', selection), c0, r0);
1111
- });
1112
- })}
1113
- </div>
1114
- </div>
1159
+ ${this.renderMainGrid(visibleCols, visibleRows, offsetInline, offsetBlock, selection)}
1115
1160
  ${this.renderFrozenColumns('frozenColsEnd', visibleRows, offsetBlock, selection)}${this.renderFixed('fixedEndStart', selection)}${this.renderFrozenRows('frozenRowsEnd', visibleCols, offsetInline, selection)}${this.renderFixed('fixedEndEnd', selection)}
1116
1161
  </div>`;
1117
1162
  }
1118
1163
  updateIntrinsicInlineSize() {
1119
1164
  this.intrinsicInlineSize = Number.isFinite(this.limitColumns)
1120
1165
  ? [...Array(this.limitColumns)].reduce((acc, _, c0) => acc + this.colSize(c0, 'grid'), 0) +
1121
- gap * (this.limitColumns - 1)
1166
+ gap * Math.max(0, this.limitColumns - 1)
1122
1167
  : Infinity;
1123
1168
  this.totalIntrinsicInlineSize =
1124
- this.intrinsicInlineSize +
1125
- (Number.isFinite(this.frozen.frozenColsStart)
1126
- ? [...Array(this.frozen.frozenColsStart)].reduce((acc, _, c0) => acc + gap + this.colSize(c0, 'frozenColsStart'), 0)
1127
- : 0) +
1128
- (Number.isFinite(this.frozen.frozenColsEnd)
1129
- ? [...Array(this.frozen.frozenColsEnd)].reduce((acc, _, c0) => acc + gap + this.colSize(c0, 'frozenColsEnd'), 0)
1130
- : 0);
1169
+ this.limitColumns > 0 ? this.intrinsicInlineSize + this.frozenColsSize : this.frozenColsSize - gap;
1131
1170
  }
1132
1171
  updateIntrinsicBlockSize() {
1133
1172
  this.intrinsicBlockSize = Number.isFinite(this.limitRows)
1134
1173
  ? [...Array(this.limitRows)].reduce((acc, _, r0) => acc + this.rowSize(r0, 'grid'), 0) +
1135
- gap * (this.limitRows - 1)
1174
+ gap * Math.max(0, this.limitRows - 1)
1136
1175
  : Infinity;
1137
1176
  this.totalIntrinsicBlockSize =
1138
- this.intrinsicBlockSize +
1139
- (Number.isFinite(this.frozen.frozenRowsStart)
1140
- ? [...Array(this.frozen.frozenRowsStart)].reduce((acc, _, r0) => acc + gap + this.rowSize(r0, 'frozenRowsStart'), 0)
1141
- : 0) +
1142
- (Number.isFinite(this.frozen.frozenRowsEnd)
1143
- ? [...Array(this.frozen.frozenRowsEnd)].reduce((acc, _, r0) => acc + gap + this.rowSize(r0, 'frozenRowsEnd'), 0)
1144
- : 0);
1177
+ this.limitRows > 0 ? this.intrinsicBlockSize + this.frozenRowsSize : this.frozenRowsSize - gap;
1145
1178
  }
1146
1179
  updateIntrinsicSizes() {
1147
1180
  this.updateIntrinsicInlineSize();
1148
1181
  this.updateIntrinsicBlockSize();
1149
1182
  }
1150
1183
  computeColSizes() {
1151
- var _a;
1152
- 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]) => {
1153
1185
  acc[plane] = Object.entries(planeColMeta).reduce((planeAcc, [col, colMeta]) => {
1154
- if (colMeta === null || colMeta === void 0 ? void 0 : colMeta.size) {
1186
+ if (colMeta?.size) {
1155
1187
  planeAcc[col] = colMeta.size;
1156
1188
  }
1157
1189
  return planeAcc;
@@ -1160,10 +1192,9 @@ let DxGrid = class DxGrid extends LitElement {
1160
1192
  }, { grid: {} });
1161
1193
  }
1162
1194
  computeRowSizes() {
1163
- var _a;
1164
- 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]) => {
1165
1196
  acc[plane] = Object.entries(planeRowMeta).reduce((planeAcc, [row, rowMeta]) => {
1166
- if (rowMeta === null || rowMeta === void 0 ? void 0 : rowMeta.size) {
1197
+ if (rowMeta?.size) {
1167
1198
  planeAcc[row] = rowMeta.size;
1168
1199
  }
1169
1200
  return planeAcc;
@@ -1175,7 +1206,7 @@ let DxGrid = class DxGrid extends LitElement {
1175
1206
  if (this.getCells) {
1176
1207
  this.updateCells(true);
1177
1208
  }
1178
- this.observer.observe(this.viewportRef.value);
1209
+ this.observer.observe(this.gridRef.value);
1179
1210
  this.computeColSizes();
1180
1211
  this.computeRowSizes();
1181
1212
  this.updateIntrinsicSizes();
@@ -1235,12 +1266,11 @@ let DxGrid = class DxGrid extends LitElement {
1235
1266
  return false;
1236
1267
  }
1237
1268
  disconnectedCallback() {
1238
- var _a;
1239
1269
  super.disconnectedCallback();
1240
- if (this.viewportRef.value) {
1241
- this.observer.unobserve(this.viewportRef.value);
1270
+ if (this.gridRef.value) {
1271
+ this.observer.unobserve(this.gridRef.value);
1242
1272
  }
1243
- (_a = document.defaultView) === null || _a === void 0 ? void 0 : _a.removeEventListener('wheel', this.handleTopLevelWheel);
1273
+ document.defaultView?.removeEventListener('wheel', this.handleTopLevelWheel);
1244
1274
  }
1245
1275
  createRenderRoot() {
1246
1276
  return this;
@@ -1345,6 +1375,12 @@ __decorate([
1345
1375
  __decorate([
1346
1376
  state()
1347
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);
1348
1384
  __decorate([
1349
1385
  state()
1350
1386
  ], DxGrid.prototype, "pointer", void 0);
@@ -1385,6 +1421,6 @@ DxGrid = __decorate([
1385
1421
  customElement('dx-grid')
1386
1422
  ], DxGrid);
1387
1423
  export { DxGrid };
1388
- export { rowToA1Notation, colToA1Notation, closestAction, closestCell, parseCellIndex, toPlaneCellIndex, cellQuery, } from './util';
1424
+ export { rowToA1Notation, colToA1Notation, closestAction, closestCell, parseCellIndex, toPlaneCellIndex, cellQuery, accessoryHandlesPointerdownAttrs, } from './util';
1389
1425
  export const commentedClassName = 'dx-grid__cell--commented';
1390
1426
  //# sourceMappingURL=dx-grid.js.map