@dxos/lit-grid 0.8.4-main.84f28bd → 0.8.4-main.a4bbb77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/defs.d.ts +1 -0
- package/dist/src/defs.d.ts.map +1 -1
- package/dist/src/defs.js +1 -0
- package/dist/src/defs.js.map +1 -1
- package/dist/src/dx-grid-axis-resize-handle.d.ts.map +1 -1
- package/dist/src/dx-grid-axis-resize-handle.js +3 -5
- package/dist/src/dx-grid-axis-resize-handle.js.map +1 -1
- package/dist/src/dx-grid-multiselect-cell.d.ts.map +1 -1
- package/dist/src/dx-grid-multiselect-cell.js +2 -1
- package/dist/src/dx-grid-multiselect-cell.js.map +1 -1
- package/dist/src/dx-grid.d.ts +12 -7
- package/dist/src/dx-grid.d.ts.map +1 -1
- package/dist/src/dx-grid.js +195 -157
- package/dist/src/dx-grid.js.map +1 -1
- package/dist/src/dx-grid.lit-stories.js +15 -18
- package/dist/src/dx-grid.lit-stories.js.map +1 -1
- package/dist/src/playwright/dx-grid.spec.js.map +1 -1
- package/dist/src/testing/dx-grid-manager.d.ts.map +1 -1
- package/dist/src/testing/dx-grid-manager.js.map +1 -1
- package/dist/src/types.d.ts +9 -0
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/src/util.d.ts +4 -1
- package/dist/src/util.d.ts.map +1 -1
- package/dist/src/util.js +11 -11
- package/dist/src/util.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/defs.ts +1 -0
- package/src/dx-grid-axis-resize-handle.pcss +6 -0
- package/src/dx-grid-axis-resize-handle.ts +1 -1
- package/src/dx-grid-multiselect-cell.ts +2 -1
- package/src/dx-grid.pcss +47 -31
- package/src/dx-grid.ts +189 -105
- package/src/playwright/dx-grid.spec.ts +1 -1
- package/src/testing/dx-grid-manager.ts +1 -1
- package/src/types.ts +11 -0
- package/src/util.ts +13 -9
package/dist/src/dx-grid.js
CHANGED
|
@@ -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,
|
|
12
|
-
import {
|
|
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 {
|
|
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 {
|
|
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 = {
|
|
@@ -37,6 +35,7 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
37
35
|
this.frozen = {};
|
|
38
36
|
this.overscroll = undefined;
|
|
39
37
|
this.activeRefs = '';
|
|
38
|
+
this.focusIndicatorVariant = 'sheet';
|
|
40
39
|
/**
|
|
41
40
|
* When this function is defined, it is used first to try to get a value for a cell,
|
|
42
41
|
* and otherwise will fall back to `cells`.
|
|
@@ -83,6 +82,11 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
83
82
|
this.templatefrozenRowsStart = '';
|
|
84
83
|
this.templatefrozenRowsEnd = '';
|
|
85
84
|
//
|
|
85
|
+
// `frozen…Size` is used to measure space available for the non-fixed planes
|
|
86
|
+
//
|
|
87
|
+
this.frozenColsSize = 0;
|
|
88
|
+
this.frozenRowsSize = 0;
|
|
89
|
+
//
|
|
86
90
|
// Focus, selection, and resize states
|
|
87
91
|
//
|
|
88
92
|
this.pointer = null;
|
|
@@ -133,8 +137,7 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
133
137
|
}
|
|
134
138
|
};
|
|
135
139
|
this.handlePointerUp = (event) => {
|
|
136
|
-
|
|
137
|
-
if (((_a = this.pointer) === null || _a === void 0 ? void 0 : _a.state) === 'selecting') {
|
|
140
|
+
if (this.pointer?.state === 'selecting') {
|
|
138
141
|
const cell = closestCell(event.target);
|
|
139
142
|
if (cell) {
|
|
140
143
|
this.setSelectionEnd(cell);
|
|
@@ -144,8 +147,7 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
144
147
|
this.pointer = null;
|
|
145
148
|
};
|
|
146
149
|
this.handlePointerMove = (event) => {
|
|
147
|
-
|
|
148
|
-
if (((_a = this.pointer) === null || _a === void 0 ? void 0 : _a.state) === 'panning') {
|
|
150
|
+
if (this.pointer?.state === 'panning') {
|
|
149
151
|
const panEvent = event;
|
|
150
152
|
panEvent.deltaX = this.pointer.pageX - event.pageX;
|
|
151
153
|
panEvent.deltaY = this.pointer.pageY - event.pageY;
|
|
@@ -156,7 +158,7 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
156
158
|
else if (shouldSelect(this.pointer, event)) {
|
|
157
159
|
this.pointer = { state: 'selecting' };
|
|
158
160
|
}
|
|
159
|
-
else if (
|
|
161
|
+
else if (this.pointer?.state === 'selecting') {
|
|
160
162
|
const cell = closestCell(event.target);
|
|
161
163
|
if (cell &&
|
|
162
164
|
cell.plane === this.selectionStart.plane &&
|
|
@@ -169,22 +171,20 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
169
171
|
// Resize & reposition handlers, observer, ref
|
|
170
172
|
//
|
|
171
173
|
this.observer = new ResizeObserver((entries) => {
|
|
172
|
-
|
|
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 : {
|
|
174
|
+
const { inlineSize, blockSize } = entries?.[0]?.contentBoxSize?.[0] ?? {
|
|
174
175
|
inlineSize: 0,
|
|
175
176
|
blockSize: 0,
|
|
176
177
|
};
|
|
177
|
-
if (Math.abs(inlineSize - this.sizeInline) > resizeTolerance ||
|
|
178
|
-
Math.abs(blockSize - this.sizeBlock) > resizeTolerance) {
|
|
178
|
+
if (Math.abs(inlineSize - this.frozenColsSize - this.sizeInline) > resizeTolerance ||
|
|
179
|
+
Math.abs(blockSize - this.frozenRowsSize - this.sizeBlock) > resizeTolerance) {
|
|
179
180
|
// console.info('[updating bounds]', 'resize', [inlineSize - this.sizeInline, blockSize - this.sizeBlock]);
|
|
180
|
-
this.sizeInline = inlineSize;
|
|
181
|
-
this.sizeBlock = blockSize;
|
|
181
|
+
this.sizeInline = inlineSize - this.frozenColsSize;
|
|
182
|
+
this.sizeBlock = blockSize - this.frozenRowsSize;
|
|
182
183
|
this.updateVis();
|
|
183
184
|
queueMicrotask(() => this.updatePos());
|
|
184
185
|
}
|
|
185
186
|
});
|
|
186
187
|
this.gridRef = createRef();
|
|
187
|
-
this.viewportRef = createRef();
|
|
188
188
|
this.maybeUpdateVisInline = () => {
|
|
189
189
|
if (this.posInline < this.binInlineMin || this.posInline >= this.binInlineMax) {
|
|
190
190
|
this.updateVisInline();
|
|
@@ -196,8 +196,7 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
196
196
|
}
|
|
197
197
|
};
|
|
198
198
|
this.handleTopLevelWheel = (event) => {
|
|
199
|
-
|
|
200
|
-
if (event.gridId === ((_a = this.gridId) !== null && _a !== void 0 ? _a : 'never')) {
|
|
199
|
+
if (event.gridId === (this.gridId ?? 'never')) {
|
|
201
200
|
if (this.overscroll === 'trap' ||
|
|
202
201
|
(this.overscroll === 'inline' && event.overscrollInline === 0) ||
|
|
203
202
|
(this.overscroll === 'block' && event.overscrollBlock === 0)) {
|
|
@@ -230,7 +229,7 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
230
229
|
}
|
|
231
230
|
};
|
|
232
231
|
// Wheel, top-level and element-level
|
|
233
|
-
|
|
232
|
+
document.defaultView?.addEventListener('wheel', this.handleTopLevelWheel, { passive: false });
|
|
234
233
|
this.addEventListener('wheel', this.handleWheel);
|
|
235
234
|
// Custom event(s)
|
|
236
235
|
this.addEventListener('dx-axis-resize-internal', this.handleAxisResizeInternal);
|
|
@@ -314,32 +313,27 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
314
313
|
}
|
|
315
314
|
}
|
|
316
315
|
moveFocusBetweenPlanes(event, plane) {
|
|
317
|
-
|
|
318
|
-
const planeElement = (_a = this.gridRef.value) === null || _a === void 0 ? void 0 : _a.querySelector(`[data-dx-grid-plane="${plane}"]`);
|
|
316
|
+
const planeElement = this.gridRef.value?.querySelector(`[data-dx-grid-plane="${plane}"]`);
|
|
319
317
|
if (planeElement) {
|
|
320
318
|
const axis = event.key === 'ArrowUp' || event.key === 'ArrowDown' ? 'col' : 'row';
|
|
321
319
|
const delta = event.key === 'ArrowLeft' || event.key === 'ArrowUp' ? -1 : 1;
|
|
322
|
-
const planeAxis = planeElement
|
|
323
|
-
const adjacentPlanes = Array.from(
|
|
324
|
-
|
|
320
|
+
const planeAxis = planeElement?.getAttribute(`data-dx-grid-plane-${axis}`);
|
|
321
|
+
const adjacentPlanes = Array.from(this.gridRef.value?.querySelectorAll(`[data-dx-grid-plane-${axis}="${planeAxis}"]`) ?? [planeElement]).filter((el) => !!el);
|
|
322
|
+
adjacentPlanes[(adjacentPlanes.length + adjacentPlanes.indexOf(planeElement) + delta) % adjacentPlanes.length]?.focus({ preventScroll: true });
|
|
325
323
|
}
|
|
326
324
|
}
|
|
327
325
|
moveFocusIntoPlane(plane) {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
this.
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
};
|
|
337
|
-
}
|
|
338
|
-
(_a = this.focusedCellElement()) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true });
|
|
326
|
+
const colPlane = resolveColPlane(plane);
|
|
327
|
+
const rowPlane = resolveRowPlane(plane);
|
|
328
|
+
this.focusedCell = {
|
|
329
|
+
plane,
|
|
330
|
+
col: colPlane === 'grid' ? this.visColMin : 0,
|
|
331
|
+
row: rowPlane === 'grid' ? this.visRowMin : 0,
|
|
332
|
+
};
|
|
333
|
+
this.focusedCellElement()?.focus({ preventScroll: true });
|
|
339
334
|
}
|
|
340
335
|
moveFocusToPlane() {
|
|
341
|
-
|
|
342
|
-
(_a = this.focusedPlaneElement()) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true });
|
|
336
|
+
this.focusedPlaneElement()?.focus({ preventScroll: true });
|
|
343
337
|
}
|
|
344
338
|
handleKeydown(event) {
|
|
345
339
|
if (this.focusActive && this.mode === 'browse') {
|
|
@@ -390,6 +384,13 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
390
384
|
event.preventDefault();
|
|
391
385
|
this.dispatchEditRequest();
|
|
392
386
|
break;
|
|
387
|
+
case 'Backspace':
|
|
388
|
+
case 'Delete':
|
|
389
|
+
if (!event.defaultPrevented) {
|
|
390
|
+
event.preventDefault();
|
|
391
|
+
this.dispatchEditRequest('');
|
|
392
|
+
}
|
|
393
|
+
break;
|
|
393
394
|
default:
|
|
394
395
|
if (event.key.length === 1 && event.key.match(/\P{Cc}/u) && !(event.metaKey || event.ctrlKey)) {
|
|
395
396
|
this.dispatchEditRequest(event.key);
|
|
@@ -403,19 +404,16 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
403
404
|
// Accessors
|
|
404
405
|
//
|
|
405
406
|
colSize(c, plane) {
|
|
406
|
-
var _a, _b, _c, _d, _e;
|
|
407
407
|
const resolvedPlane = resolveColPlane(plane);
|
|
408
|
-
return
|
|
408
|
+
return this.colSizes?.[resolvedPlane]?.[c] ?? this.columnDefault[resolvedPlane]?.size ?? defaultColSize;
|
|
409
409
|
}
|
|
410
410
|
rowSize(r, plane) {
|
|
411
|
-
var _a, _b, _c, _d, _e;
|
|
412
411
|
const resolvedPlane = resolveRowPlane(plane);
|
|
413
|
-
return
|
|
412
|
+
return this.rowSizes?.[resolvedPlane]?.[r] ?? this.rowDefault[resolvedPlane]?.size ?? defaultRowSize;
|
|
414
413
|
}
|
|
415
414
|
cell(c, r, plane) {
|
|
416
|
-
var _a, _b, _c, _d, _e;
|
|
417
415
|
const index = `${c}${separator}${r}`;
|
|
418
|
-
return
|
|
416
|
+
return this.cells?.[plane]?.[index] ?? this.initialCells?.[plane]?.[index];
|
|
419
417
|
}
|
|
420
418
|
cellActive(c, r, plane) {
|
|
421
419
|
return this.focusedCell.plane === plane && this.focusedCell.col === c && this.focusedCell.row === r;
|
|
@@ -476,11 +474,11 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
476
474
|
return this.intrinsicBlockSize - this.sizeBlock;
|
|
477
475
|
}
|
|
478
476
|
updatePosInline(inline, maxInline = this.maxPosInline()) {
|
|
479
|
-
this.posInline = Math.max(0, Math.min(maxInline, inline
|
|
477
|
+
this.posInline = Math.max(0, Math.min(maxInline, inline ?? this.posInline));
|
|
480
478
|
this.maybeUpdateVisInline();
|
|
481
479
|
}
|
|
482
480
|
updatePosBlock(block, maxBlock = this.maxPosBlock()) {
|
|
483
|
-
this.posBlock = Math.max(0, Math.min(maxBlock, block
|
|
481
|
+
this.posBlock = Math.max(0, Math.min(maxBlock, block ?? this.posBlock));
|
|
484
482
|
this.maybeUpdateVisBlock();
|
|
485
483
|
}
|
|
486
484
|
updatePos(inline, block, maxInline, maxBlock) {
|
|
@@ -488,7 +486,6 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
488
486
|
this.updatePosBlock(block, maxBlock);
|
|
489
487
|
}
|
|
490
488
|
updateVisInline() {
|
|
491
|
-
var _a, _b;
|
|
492
489
|
// todo: avoid starting from zero
|
|
493
490
|
let axisCursor = 0;
|
|
494
491
|
let pxCursor = this.colSize(axisCursor, 'grid');
|
|
@@ -518,15 +515,19 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
518
515
|
this.templateGridColumns = [...Array(this.visColMax - this.visColMin)]
|
|
519
516
|
.map((_, c0) => `${this.colSize(this.visColMin + c0, 'grid')}px`)
|
|
520
517
|
.join(' ');
|
|
521
|
-
this.templatefrozenColsStart = [...Array(
|
|
518
|
+
this.templatefrozenColsStart = [...Array(this.frozen.frozenColsStart ?? 0)]
|
|
522
519
|
.map((_, c0) => `${this.colSize(c0, 'frozenColsStart')}px`)
|
|
523
520
|
.join(' ');
|
|
524
|
-
this.templatefrozenColsEnd = [...Array(
|
|
521
|
+
this.templatefrozenColsEnd = [...Array(this.frozen.frozenColsEnd ?? 0)]
|
|
525
522
|
.map((_, c0) => `${this.colSize(c0, 'frozenColsEnd')}px`)
|
|
526
523
|
.join(' ');
|
|
524
|
+
this.frozenColsSize =
|
|
525
|
+
[...Array(this.frozen.frozenColsStart ?? 0)].reduce((sum, _, c0) => sum + this.colSize(c0, 'frozenColsStart'), 0) +
|
|
526
|
+
gap * Math.max(0, this.frozen.frozenColsStart ?? 0 - 1) +
|
|
527
|
+
[...Array(this.frozen.frozenColsEnd ?? 0)].reduce((sum, _, c0) => sum + this.colSize(c0, 'frozenColsEnd'), 0) +
|
|
528
|
+
gap * Math.max(0, this.frozen.frozenColsEnd ?? 0 - 1);
|
|
527
529
|
}
|
|
528
530
|
updateVisBlock() {
|
|
529
|
-
var _a, _b;
|
|
530
531
|
// todo: avoid starting from zero
|
|
531
532
|
let axisCursor = 0;
|
|
532
533
|
let pxCursor = this.rowSize(axisCursor, 'grid');
|
|
@@ -556,19 +557,23 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
556
557
|
this.templateGridRows = [...Array(this.visRowMax - this.visRowMin)]
|
|
557
558
|
.map((_, r0) => `${this.rowSize(this.visRowMin + r0, 'grid')}px`)
|
|
558
559
|
.join(' ');
|
|
559
|
-
this.templatefrozenRowsStart = [...Array(
|
|
560
|
+
this.templatefrozenRowsStart = [...Array(this.frozen.frozenRowsStart ?? 0)]
|
|
560
561
|
.map((_, r0) => `${this.rowSize(r0, 'frozenRowsStart')}px`)
|
|
561
562
|
.join(' ');
|
|
562
|
-
this.templatefrozenRowsEnd = [...Array(
|
|
563
|
+
this.templatefrozenRowsEnd = [...Array(this.frozen.frozenRowsEnd ?? 0)]
|
|
563
564
|
.map((_, r0) => `${this.rowSize(r0, 'frozenRowsEnd')}px`)
|
|
564
565
|
.join(' ');
|
|
566
|
+
this.frozenRowsSize =
|
|
567
|
+
[...Array(this.frozen.frozenRowsStart ?? 0)].reduce((sum, _, r0) => sum + this.rowSize(r0, 'frozenRowsStart'), 0) +
|
|
568
|
+
gap * Math.max(0, this.frozen.frozenRowsStart ?? 0 - 1) +
|
|
569
|
+
[...Array(this.frozen.frozenRowsEnd ?? 0)].reduce((sum, _, r0) => sum + this.rowSize(r0, 'frozenRowsEnd'), 0) +
|
|
570
|
+
gap * Math.max(0, this.frozen.frozenRowsEnd ?? 0 - 1);
|
|
565
571
|
}
|
|
566
572
|
updateVis() {
|
|
567
573
|
this.updateVisInline();
|
|
568
574
|
this.updateVisBlock();
|
|
569
575
|
}
|
|
570
576
|
updateCells(includeFixed) {
|
|
571
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
572
577
|
this.cells.grid = this.getCells({
|
|
573
578
|
start: { col: this.visColMin, row: this.visRowMin },
|
|
574
579
|
end: { col: this.visColMax, row: this.visRowMax },
|
|
@@ -587,25 +592,25 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
587
592
|
}, plane);
|
|
588
593
|
});
|
|
589
594
|
if (includeFixed) {
|
|
590
|
-
if ((
|
|
595
|
+
if ((this.frozen.frozenColsStart ?? 0) > 0 && (this.frozen.frozenRowsStart ?? 0) > 0) {
|
|
591
596
|
this.cells.fixedStartStart = this.getCells({
|
|
592
597
|
start: { col: 0, row: 0 },
|
|
593
598
|
end: { col: this.frozen.frozenColsStart, row: this.frozen.frozenRowsStart },
|
|
594
599
|
}, 'fixedStartStart');
|
|
595
600
|
}
|
|
596
|
-
if ((
|
|
601
|
+
if ((this.frozen.frozenColsEnd ?? 0) > 0 && (this.frozen.frozenRowsStart ?? 0) > 0) {
|
|
597
602
|
this.cells.fixedStartEnd = this.getCells({
|
|
598
603
|
start: { col: 0, row: 0 },
|
|
599
604
|
end: { col: this.frozen.frozenColsEnd, row: this.frozen.frozenRowsStart },
|
|
600
605
|
}, 'fixedStartEnd');
|
|
601
606
|
}
|
|
602
|
-
if ((
|
|
607
|
+
if ((this.frozen.frozenColsStart ?? 0) > 0 && (this.frozen.frozenRowsEnd ?? 0) > 0) {
|
|
603
608
|
this.cells.fixedEndStart = this.getCells({
|
|
604
609
|
start: { col: 0, row: 0 },
|
|
605
610
|
end: { col: this.frozen.frozenColsStart, row: this.frozen.frozenRowsEnd },
|
|
606
611
|
}, 'fixedEndStart');
|
|
607
612
|
}
|
|
608
|
-
if ((
|
|
613
|
+
if ((this.frozen.frozenColsEnd ?? 0) > 0 && (this.frozen.frozenRowsEnd ?? 0) > 0) {
|
|
609
614
|
this.cells.fixedEndEnd = this.getCells({
|
|
610
615
|
start: { col: 0, row: 0 },
|
|
611
616
|
end: { col: this.frozen.frozenColsEnd, row: this.frozen.frozenRowsEnd },
|
|
@@ -643,12 +648,10 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
643
648
|
return `[data-dx-grid-plane=${this.focusedCell.plane}]`;
|
|
644
649
|
}
|
|
645
650
|
focusedCellElement() {
|
|
646
|
-
|
|
647
|
-
return (_a = this.gridRef.value) === null || _a === void 0 ? void 0 : _a.querySelector(this.focusedCellQuery());
|
|
651
|
+
return this.gridRef.value?.querySelector(this.focusedCellQuery());
|
|
648
652
|
}
|
|
649
653
|
focusedPlaneElement() {
|
|
650
|
-
|
|
651
|
-
return (_a = this.gridRef.value) === null || _a === void 0 ? void 0 : _a.querySelector(this.focusedPlaneQuery());
|
|
654
|
+
return this.gridRef.value?.querySelector(this.focusedPlaneQuery());
|
|
652
655
|
}
|
|
653
656
|
//
|
|
654
657
|
// `outOfVis` returns by how many rows/cols the focused cell is outside of the `vis` range for an axis, inset by a
|
|
@@ -807,22 +810,37 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
807
810
|
// Resize handlers
|
|
808
811
|
//
|
|
809
812
|
axisResizeable(plane, axis, index) {
|
|
810
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
811
813
|
return axis === 'col'
|
|
812
|
-
? !!(
|
|
813
|
-
: !!(
|
|
814
|
+
? !!(this.columns[plane]?.[index]?.resizeable ?? this.columnDefault[plane]?.resizeable)
|
|
815
|
+
: !!(this.rows[plane]?.[index]?.resizeable ?? this.rowDefault[plane]?.resizeable);
|
|
816
|
+
}
|
|
817
|
+
clampAxisSize(plane, axis, index, requestedSize) {
|
|
818
|
+
const minSize = axis === 'col'
|
|
819
|
+
? (this.columns[plane]?.[index]?.minSize ??
|
|
820
|
+
this.columnDefault[plane]?.minSize ??
|
|
821
|
+
sizeColMin)
|
|
822
|
+
: (this.rows[plane]?.[index]?.minSize ??
|
|
823
|
+
this.rowDefault[plane]?.minSize ??
|
|
824
|
+
sizeRowMin);
|
|
825
|
+
const maxSize = axis === 'col'
|
|
826
|
+
? (this.columns[plane]?.[index]?.maxSize ??
|
|
827
|
+
this.columnDefault[plane]?.maxSize ??
|
|
828
|
+
sizeColMax)
|
|
829
|
+
: (this.rows[plane]?.[index]?.maxSize ??
|
|
830
|
+
this.rowDefault[plane]?.maxSize ??
|
|
831
|
+
sizeRowMax);
|
|
832
|
+
return Math.max(minSize, Math.min(maxSize, requestedSize));
|
|
814
833
|
}
|
|
815
834
|
handleAxisResizeInternal(event) {
|
|
816
835
|
event.stopPropagation();
|
|
817
836
|
const { plane, axis, delta, size, index, state } = event;
|
|
837
|
+
const nextSize = this.clampAxisSize(plane, axis, index, size + delta);
|
|
818
838
|
if (axis === 'col') {
|
|
819
|
-
const nextSize = Math.max(sizeColMin, Math.min(sizeColMax, size + delta));
|
|
820
839
|
this.colSizes = { ...this.colSizes, [plane]: { ...this.colSizes[plane], [index]: nextSize } };
|
|
821
840
|
this.updateVisInline();
|
|
822
841
|
this.updateIntrinsicInlineSize();
|
|
823
842
|
}
|
|
824
843
|
else {
|
|
825
|
-
const nextSize = Math.max(sizeRowMin, Math.min(sizeRowMax, size + delta));
|
|
826
844
|
this.rowSizes = { ...this.colSizes, [plane]: { ...this.rowSizes[plane], [index]: nextSize } };
|
|
827
845
|
this.updateVisBlock();
|
|
828
846
|
this.updateIntrinsicBlockSize();
|
|
@@ -841,7 +859,6 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
841
859
|
//
|
|
842
860
|
// TODO(thure): This is for rendering presentational objects superimposed onto the canonical grid (e.g. DnD drop line for #8108).
|
|
843
861
|
renderPresentationLayer(offsetInline, offsetBlock) {
|
|
844
|
-
var _a, _b, _c, _d, _e, _f;
|
|
845
862
|
const visibleCols = this.visColMax - this.visColMin;
|
|
846
863
|
const visibleRows = this.visRowMax - this.visRowMin;
|
|
847
864
|
return html `<div
|
|
@@ -849,32 +866,29 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
849
866
|
class="dx-grid-layer--presentation"
|
|
850
867
|
style=${styleMap({
|
|
851
868
|
gridTemplateColumns: [
|
|
852
|
-
...[...Array(
|
|
869
|
+
...[...Array(this.frozen.frozenColsStart ?? 0)].map((_, c0) => `${this.colSize(c0, 'frozenColsStart')}px`),
|
|
853
870
|
...[...Array(visibleCols)].map((_, c0) => c0 === visibleCols - 1
|
|
854
871
|
? '1fr'
|
|
855
872
|
: `${this.colSize(this.visColMin + c0, 'grid') + (c0 === 0 ? offsetInline : 0)}px`),
|
|
856
|
-
...[...Array(
|
|
873
|
+
...[...Array(this.frozen.frozenColsEnd ?? 0)].map((_, c0) => `${this.colSize(c0, 'frozenColsEnd')}px`),
|
|
857
874
|
].join(' '),
|
|
858
875
|
gridTemplateRows: [
|
|
859
|
-
...[...Array(
|
|
876
|
+
...[...Array(this.frozen.frozenRowsStart ?? 0)].map((_, r0) => `${this.rowSize(r0, 'frozenRowsStart')}px`),
|
|
860
877
|
...[...Array(visibleRows)].map((_, r0) => r0 === visibleRows - 1
|
|
861
878
|
? '1fr'
|
|
862
879
|
: `${this.rowSize(this.visRowMin + r0, 'grid') + (r0 === 0 ? offsetBlock : 0)}px`),
|
|
863
|
-
...[...Array(
|
|
880
|
+
...[...Array(this.frozen.frozenRowsEnd ?? 0)].map((_, r0) => `${this.rowSize(r0, 'frozenRowsEnd')}px`),
|
|
864
881
|
].join(' '),
|
|
865
882
|
})}
|
|
866
883
|
>
|
|
867
884
|
${
|
|
868
885
|
/* TODO(thure): These are debug cells, remove when rendering actual overlay content. */ [
|
|
869
|
-
...Array((
|
|
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
|
|
886
|
+
...Array((this.frozen.frozenRowsStart ?? 0) + visibleRows + (this.frozen.frozenRowsEnd ?? 0)),
|
|
887
|
+
].map((_, r0) => [...Array((this.frozen.frozenColsStart ?? 0) + visibleCols + (this.frozen.frozenColsEnd ?? 0))].map((_, c0) => html `<div
|
|
873
888
|
role="none"
|
|
874
889
|
class="dx-grid-layer--presentation__cell"
|
|
875
890
|
style="grid-column:${c0 + 1};grid-row:${r0 + 1}"
|
|
876
|
-
></div>`)
|
|
877
|
-
})}
|
|
891
|
+
></div>`))}
|
|
878
892
|
</div>`;
|
|
879
893
|
}
|
|
880
894
|
renderFixed(plane, selection) {
|
|
@@ -882,7 +896,7 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
882
896
|
const rowPlane = resolveRowPlane(plane);
|
|
883
897
|
const cols = this.frozen[colPlane];
|
|
884
898
|
const rows = this.frozen[rowPlane];
|
|
885
|
-
return (cols
|
|
899
|
+
return (cols ?? 0) > 0 && (rows ?? 0) > 0
|
|
886
900
|
? html `<div
|
|
887
901
|
role="none"
|
|
888
902
|
tabindex="0"
|
|
@@ -906,7 +920,7 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
906
920
|
renderFrozenRows(plane, visibleCols, offsetInline, selection) {
|
|
907
921
|
const rowPlane = resolveRowPlane(plane);
|
|
908
922
|
const rows = this.frozen[rowPlane];
|
|
909
|
-
return (rows
|
|
923
|
+
return (rows ?? 0) > 0 && this.limitColumns > 0
|
|
910
924
|
? html `<div
|
|
911
925
|
role="none"
|
|
912
926
|
class="dx-grid__plane--frozen-row"
|
|
@@ -934,7 +948,7 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
934
948
|
renderFrozenColumns(plane, visibleRows, offsetBlock, selection) {
|
|
935
949
|
const colPlane = resolveColPlane(plane);
|
|
936
950
|
const cols = this.frozen[colPlane];
|
|
937
|
-
return (cols
|
|
951
|
+
return (cols ?? 0) > 0 && this.limitRows > 0
|
|
938
952
|
? html `<div
|
|
939
953
|
role="none"
|
|
940
954
|
class="dx-grid__plane--frozen-col"
|
|
@@ -959,47 +973,84 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
959
973
|
</div>`
|
|
960
974
|
: null;
|
|
961
975
|
}
|
|
976
|
+
renderMainGrid(visibleCols, visibleRows, offsetInline, offsetBlock, selection) {
|
|
977
|
+
return this.limitRows > 0 && this.limitColumns > 0
|
|
978
|
+
? html `<div
|
|
979
|
+
role="grid"
|
|
980
|
+
class="dx-grid__plane--grid"
|
|
981
|
+
tabindex="0"
|
|
982
|
+
data-dx-grid-plane="grid"
|
|
983
|
+
data-dx-grid-plane-row="1"
|
|
984
|
+
data-dx-grid-plane-col="1"
|
|
985
|
+
>
|
|
986
|
+
<div
|
|
987
|
+
role="none"
|
|
988
|
+
class="dx-grid__plane--grid__content"
|
|
989
|
+
style="transform:translate3d(${offsetInline}px,${offsetBlock}px,0);grid-template-columns:${this
|
|
990
|
+
.templateGridColumns};grid-template-rows:${this.templateGridRows};"
|
|
991
|
+
>
|
|
992
|
+
${[...Array(visibleRows)].map((_, r0) => {
|
|
993
|
+
return [...Array(visibleCols)].map((_, c0) => {
|
|
994
|
+
const c = c0 + this.visColMin;
|
|
995
|
+
const r = r0 + this.visRowMin;
|
|
996
|
+
return this.renderCell(c, r, 'grid', cellSelected(c, r, 'grid', selection), c0, r0);
|
|
997
|
+
});
|
|
998
|
+
})}
|
|
999
|
+
</div>
|
|
1000
|
+
</div>`
|
|
1001
|
+
: null;
|
|
1002
|
+
}
|
|
962
1003
|
cellReadonly(col, row, plane) {
|
|
963
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
964
1004
|
const colPlane = resolveColPlane(plane);
|
|
965
1005
|
const rowPlane = resolveRowPlane(plane);
|
|
966
1006
|
// Check cell-specific setting first.
|
|
967
|
-
const cellReadonly =
|
|
1007
|
+
const cellReadonly = this.cell(col, row, plane)?.readonly;
|
|
968
1008
|
if (cellReadonly !== undefined) {
|
|
969
1009
|
return isReadonly(cellReadonly);
|
|
970
1010
|
}
|
|
971
1011
|
// Check column/row defaults.
|
|
972
|
-
const colReadOnly =
|
|
973
|
-
const rowReadOnly =
|
|
1012
|
+
const colReadOnly = this.columns?.[colPlane]?.[col]?.readonly ?? this.columnDefault?.[colPlane]?.readonly;
|
|
1013
|
+
const rowReadOnly = this.rows?.[rowPlane]?.[row]?.readonly ?? this.rowDefault?.[rowPlane]?.readonly;
|
|
974
1014
|
return isReadonly(colReadOnly) || isReadonly(rowReadOnly);
|
|
975
1015
|
}
|
|
1016
|
+
cellFocusUnfurl(col, row, plane) {
|
|
1017
|
+
const colPlane = resolveColPlane(plane);
|
|
1018
|
+
const rowPlane = resolveRowPlane(plane);
|
|
1019
|
+
// Check cell-specific setting first.
|
|
1020
|
+
const cellUnfurl = this.cell(col, row, plane)?.focusUnfurl;
|
|
1021
|
+
if (cellUnfurl !== undefined) {
|
|
1022
|
+
return cellUnfurl;
|
|
1023
|
+
}
|
|
1024
|
+
// Check column/row defaults.
|
|
1025
|
+
const colUnfurl = this.columns?.[colPlane]?.[col]?.focusUnfurl ?? this.columnDefault?.[colPlane]?.focusUnfurl;
|
|
1026
|
+
const rowUnfurl = this.rows?.[rowPlane]?.[row]?.focusUnfurl ?? this.rowDefault?.[rowPlane]?.focusUnfurl;
|
|
1027
|
+
return colUnfurl ?? rowUnfurl ?? focusUnfurlDefault;
|
|
1028
|
+
}
|
|
976
1029
|
/**
|
|
977
1030
|
* Determines if the cell's text content should be selectable based on its readonly value.
|
|
978
1031
|
* @returns true if the cells text content is selectable, false otherwise.
|
|
979
1032
|
*/
|
|
980
1033
|
cellTextSelectable(col, row, plane) {
|
|
981
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
982
1034
|
const colPlane = resolveColPlane(plane);
|
|
983
1035
|
const rowPlane = resolveRowPlane(plane);
|
|
984
1036
|
// Check cell-specific setting first.
|
|
985
|
-
const cellReadonly =
|
|
1037
|
+
const cellReadonly = this.cell(col, row, plane)?.readonly;
|
|
986
1038
|
if (cellReadonly !== undefined) {
|
|
987
1039
|
return cellReadonly === 'text-select';
|
|
988
1040
|
}
|
|
989
1041
|
// Check column/row defaults.
|
|
990
|
-
const colReadonly =
|
|
991
|
-
const rowReadonly =
|
|
1042
|
+
const colReadonly = this.columns?.[colPlane]?.[col]?.readonly ?? this.columnDefault?.[colPlane]?.readonly;
|
|
1043
|
+
const rowReadonly = this.rows?.[rowPlane]?.[row]?.readonly ?? this.rowDefault?.[rowPlane]?.readonly;
|
|
992
1044
|
return colReadonly === 'text-select' || rowReadonly === 'text-select';
|
|
993
1045
|
}
|
|
994
1046
|
getOverflowingCellModifiedDeltas(event) {
|
|
995
|
-
var _a;
|
|
996
1047
|
if (!event.target) {
|
|
997
1048
|
return event;
|
|
998
1049
|
}
|
|
999
1050
|
const element = event.target;
|
|
1000
1051
|
const activeCell = element.closest('[data-dx-active]');
|
|
1001
1052
|
const contentEl = element.closest('.dx-grid__cell__content');
|
|
1002
|
-
if (!activeCell || !contentEl || !
|
|
1053
|
+
if (!activeCell || !contentEl || !document.activeElement?.contains(element)) {
|
|
1003
1054
|
return event;
|
|
1004
1055
|
}
|
|
1005
1056
|
// Commented-out code will let the event delta through unmodified if the cell can scroll but is scrolled to the end
|
|
@@ -1019,21 +1070,22 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
1019
1070
|
return { deltaX, deltaY };
|
|
1020
1071
|
}
|
|
1021
1072
|
renderCell(col, row, plane, selected, visCol = col, visRow = row) {
|
|
1022
|
-
var _a, _b;
|
|
1023
1073
|
const cell = this.cell(col, row, plane);
|
|
1024
1074
|
const active = this.cellActive(col, row, plane);
|
|
1025
1075
|
const readonly = this.cellReadonly(col, row, plane);
|
|
1076
|
+
const focusUnfurl = this.cellFocusUnfurl(col, row, plane);
|
|
1026
1077
|
const textSelectable = this.cellTextSelectable(col, row, plane);
|
|
1027
|
-
const resizeIndex =
|
|
1028
|
-
const resizePlane =
|
|
1029
|
-
const accessory =
|
|
1078
|
+
const resizeIndex = cell?.resizeHandle ? (cell.resizeHandle === 'col' ? col : row) : undefined;
|
|
1079
|
+
const resizePlane = cell?.resizeHandle ? resolveFrozenPlane(cell.resizeHandle, plane) : undefined;
|
|
1080
|
+
const accessory = cell?.accessoryHtml ? staticHtml `${unsafeStatic(cell.accessoryHtml)}` : null;
|
|
1030
1081
|
return html `<div
|
|
1031
1082
|
role="gridcell"
|
|
1032
1083
|
tabindex="0"
|
|
1033
1084
|
aria-selected=${selected ? 'true' : nothing}
|
|
1034
1085
|
aria-readonly=${readonly ? 'true' : nothing}
|
|
1035
|
-
class=${
|
|
1036
|
-
data-refs=${
|
|
1086
|
+
class=${cell?.className ?? nothing}
|
|
1087
|
+
data-refs=${cell?.dataRefs ?? nothing}
|
|
1088
|
+
data-focus-unfurl=${focusUnfurl ? nothing : 'false'}
|
|
1037
1089
|
?data-dx-active=${active}
|
|
1038
1090
|
data-text-selectable=${textSelectable ? 'true' : 'false'}
|
|
1039
1091
|
data-dx-grid-action="cell"
|
|
@@ -1041,10 +1093,8 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
1041
1093
|
aria-rowindex=${row}
|
|
1042
1094
|
style="grid-column:${visCol + 1};grid-row:${visRow + 1}"
|
|
1043
1095
|
>
|
|
1044
|
-
<div role="none" class="dx-grid__cell__content">
|
|
1045
|
-
|
|
1046
|
-
</div>
|
|
1047
|
-
${(cell === null || cell === void 0 ? void 0 : cell.resizeHandle) &&
|
|
1096
|
+
<div role="none" class="dx-grid__cell__content">${cell?.value}${accessory}</div>
|
|
1097
|
+
${cell?.resizeHandle &&
|
|
1048
1098
|
this.mode === 'browse' &&
|
|
1049
1099
|
this.axisResizeable(resizePlane, cell.resizeHandle, resizeIndex)
|
|
1050
1100
|
? html `<dx-grid-axis-resize-handle
|
|
@@ -1074,9 +1124,24 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
1074
1124
|
<div
|
|
1075
1125
|
role="none"
|
|
1076
1126
|
class="dx-grid"
|
|
1127
|
+
data-arrow-keys="all"
|
|
1077
1128
|
style=${styleMap({
|
|
1078
|
-
'grid-template-columns':
|
|
1079
|
-
|
|
1129
|
+
'grid-template-columns': [
|
|
1130
|
+
this.templatefrozenColsStart ? 'min-content' : false,
|
|
1131
|
+
this.limitColumns > 0 &&
|
|
1132
|
+
`minmax(0, ${Number.isFinite(this.limitColumns) ? `${Math.max(0, this.intrinsicInlineSize)}px` : '1fr'})`,
|
|
1133
|
+
this.templatefrozenColsEnd ? 'min-content' : false,
|
|
1134
|
+
]
|
|
1135
|
+
.filter(Boolean)
|
|
1136
|
+
.join(' '),
|
|
1137
|
+
'grid-template-rows': [
|
|
1138
|
+
this.templatefrozenRowsStart ? 'min-content' : false,
|
|
1139
|
+
this.limitRows > 0 &&
|
|
1140
|
+
`minmax(0, ${Number.isFinite(this.limitRows) ? `${Math.max(0, this.intrinsicBlockSize)}px` : '1fr'})`,
|
|
1141
|
+
this.templatefrozenRowsEnd ? ' min-content' : false,
|
|
1142
|
+
]
|
|
1143
|
+
.filter(Boolean)
|
|
1144
|
+
.join(' '),
|
|
1080
1145
|
'--dx-grid-content-inline-size': Number.isFinite(this.limitColumns)
|
|
1081
1146
|
? `${Math.max(0, this.totalIntrinsicInlineSize)}px`
|
|
1082
1147
|
: 'max-content',
|
|
@@ -1086,74 +1151,39 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
1086
1151
|
})}
|
|
1087
1152
|
data-grid=${this.gridId}
|
|
1088
1153
|
data-grid-mode=${this.mode}
|
|
1154
|
+
data-grid-focus-indicator-variant=${this.focusIndicatorVariant}
|
|
1089
1155
|
?data-grid-select=${selection.visible}
|
|
1090
1156
|
${ref(this.gridRef)}
|
|
1091
1157
|
>
|
|
1092
1158
|
${this.renderFixed('fixedStartStart', selection)}${this.renderFrozenRows('frozenRowsStart', visibleCols, offsetInline, selection)}${this.renderFixed('fixedStartEnd', selection)}${this.renderFrozenColumns('frozenColsStart', visibleRows, offsetBlock, selection)}
|
|
1093
|
-
|
|
1094
|
-
role="grid"
|
|
1095
|
-
class="dx-grid__plane--grid"
|
|
1096
|
-
tabindex="0"
|
|
1097
|
-
data-dx-grid-plane="grid"
|
|
1098
|
-
data-dx-grid-plane-row="1"
|
|
1099
|
-
data-dx-grid-plane-col="1"
|
|
1100
|
-
${ref(this.viewportRef)}
|
|
1101
|
-
>
|
|
1102
|
-
<div
|
|
1103
|
-
role="none"
|
|
1104
|
-
class="dx-grid__plane--grid__content"
|
|
1105
|
-
style="transform:translate3d(${offsetInline}px,${offsetBlock}px,0);grid-template-columns:${this
|
|
1106
|
-
.templateGridColumns};grid-template-rows:${this.templateGridRows};"
|
|
1107
|
-
>
|
|
1108
|
-
${[...Array(visibleRows)].map((_, r0) => {
|
|
1109
|
-
return [...Array(visibleCols)].map((_, c0) => {
|
|
1110
|
-
const c = c0 + this.visColMin;
|
|
1111
|
-
const r = r0 + this.visRowMin;
|
|
1112
|
-
return this.renderCell(c, r, 'grid', cellSelected(c, r, 'grid', selection), c0, r0);
|
|
1113
|
-
});
|
|
1114
|
-
})}
|
|
1115
|
-
</div>
|
|
1116
|
-
</div>
|
|
1159
|
+
${this.renderMainGrid(visibleCols, visibleRows, offsetInline, offsetBlock, selection)}
|
|
1117
1160
|
${this.renderFrozenColumns('frozenColsEnd', visibleRows, offsetBlock, selection)}${this.renderFixed('fixedEndStart', selection)}${this.renderFrozenRows('frozenRowsEnd', visibleCols, offsetInline, selection)}${this.renderFixed('fixedEndEnd', selection)}
|
|
1118
1161
|
</div>`;
|
|
1119
1162
|
}
|
|
1120
1163
|
updateIntrinsicInlineSize() {
|
|
1121
1164
|
this.intrinsicInlineSize = Number.isFinite(this.limitColumns)
|
|
1122
1165
|
? [...Array(this.limitColumns)].reduce((acc, _, c0) => acc + this.colSize(c0, 'grid'), 0) +
|
|
1123
|
-
gap * (this.limitColumns - 1)
|
|
1166
|
+
gap * Math.max(0, this.limitColumns - 1)
|
|
1124
1167
|
: Infinity;
|
|
1125
1168
|
this.totalIntrinsicInlineSize =
|
|
1126
|
-
this.intrinsicInlineSize +
|
|
1127
|
-
(Number.isFinite(this.frozen.frozenColsStart)
|
|
1128
|
-
? [...Array(this.frozen.frozenColsStart)].reduce((acc, _, c0) => acc + gap + this.colSize(c0, 'frozenColsStart'), 0)
|
|
1129
|
-
: 0) +
|
|
1130
|
-
(Number.isFinite(this.frozen.frozenColsEnd)
|
|
1131
|
-
? [...Array(this.frozen.frozenColsEnd)].reduce((acc, _, c0) => acc + gap + this.colSize(c0, 'frozenColsEnd'), 0)
|
|
1132
|
-
: 0);
|
|
1169
|
+
this.limitColumns > 0 ? this.intrinsicInlineSize + this.frozenColsSize : this.frozenColsSize - gap;
|
|
1133
1170
|
}
|
|
1134
1171
|
updateIntrinsicBlockSize() {
|
|
1135
1172
|
this.intrinsicBlockSize = Number.isFinite(this.limitRows)
|
|
1136
1173
|
? [...Array(this.limitRows)].reduce((acc, _, r0) => acc + this.rowSize(r0, 'grid'), 0) +
|
|
1137
|
-
gap * (this.limitRows - 1)
|
|
1174
|
+
gap * Math.max(0, this.limitRows - 1)
|
|
1138
1175
|
: Infinity;
|
|
1139
1176
|
this.totalIntrinsicBlockSize =
|
|
1140
|
-
this.intrinsicBlockSize +
|
|
1141
|
-
(Number.isFinite(this.frozen.frozenRowsStart)
|
|
1142
|
-
? [...Array(this.frozen.frozenRowsStart)].reduce((acc, _, r0) => acc + gap + this.rowSize(r0, 'frozenRowsStart'), 0)
|
|
1143
|
-
: 0) +
|
|
1144
|
-
(Number.isFinite(this.frozen.frozenRowsEnd)
|
|
1145
|
-
? [...Array(this.frozen.frozenRowsEnd)].reduce((acc, _, r0) => acc + gap + this.rowSize(r0, 'frozenRowsEnd'), 0)
|
|
1146
|
-
: 0);
|
|
1177
|
+
this.limitRows > 0 ? this.intrinsicBlockSize + this.frozenRowsSize : this.frozenRowsSize - gap;
|
|
1147
1178
|
}
|
|
1148
1179
|
updateIntrinsicSizes() {
|
|
1149
1180
|
this.updateIntrinsicInlineSize();
|
|
1150
1181
|
this.updateIntrinsicBlockSize();
|
|
1151
1182
|
}
|
|
1152
1183
|
computeColSizes() {
|
|
1153
|
-
|
|
1154
|
-
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]) => {
|
|
1155
1185
|
acc[plane] = Object.entries(planeColMeta).reduce((planeAcc, [col, colMeta]) => {
|
|
1156
|
-
if (colMeta
|
|
1186
|
+
if (colMeta?.size) {
|
|
1157
1187
|
planeAcc[col] = colMeta.size;
|
|
1158
1188
|
}
|
|
1159
1189
|
return planeAcc;
|
|
@@ -1162,10 +1192,9 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
1162
1192
|
}, { grid: {} });
|
|
1163
1193
|
}
|
|
1164
1194
|
computeRowSizes() {
|
|
1165
|
-
|
|
1166
|
-
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]) => {
|
|
1167
1196
|
acc[plane] = Object.entries(planeRowMeta).reduce((planeAcc, [row, rowMeta]) => {
|
|
1168
|
-
if (rowMeta
|
|
1197
|
+
if (rowMeta?.size) {
|
|
1169
1198
|
planeAcc[row] = rowMeta.size;
|
|
1170
1199
|
}
|
|
1171
1200
|
return planeAcc;
|
|
@@ -1177,7 +1206,7 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
1177
1206
|
if (this.getCells) {
|
|
1178
1207
|
this.updateCells(true);
|
|
1179
1208
|
}
|
|
1180
|
-
this.observer.observe(this.
|
|
1209
|
+
this.observer.observe(this.gridRef.value);
|
|
1181
1210
|
this.computeColSizes();
|
|
1182
1211
|
this.computeRowSizes();
|
|
1183
1212
|
this.updateIntrinsicSizes();
|
|
@@ -1228,20 +1257,20 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
1228
1257
|
this.refocus();
|
|
1229
1258
|
}
|
|
1230
1259
|
}
|
|
1231
|
-
updateIfWithinBounds({ col, row }) {
|
|
1260
|
+
updateIfWithinBounds({ col, row }, includeFixed) {
|
|
1232
1261
|
if (col >= this.visColMin && col <= this.visColMax && row >= this.visRowMin && row <= this.visRowMax) {
|
|
1262
|
+
this.updateCells(includeFixed);
|
|
1233
1263
|
this.requestUpdate();
|
|
1234
1264
|
return true;
|
|
1235
1265
|
}
|
|
1236
1266
|
return false;
|
|
1237
1267
|
}
|
|
1238
1268
|
disconnectedCallback() {
|
|
1239
|
-
var _a;
|
|
1240
1269
|
super.disconnectedCallback();
|
|
1241
|
-
if (this.
|
|
1242
|
-
this.observer.unobserve(this.
|
|
1270
|
+
if (this.gridRef.value) {
|
|
1271
|
+
this.observer.unobserve(this.gridRef.value);
|
|
1243
1272
|
}
|
|
1244
|
-
|
|
1273
|
+
document.defaultView?.removeEventListener('wheel', this.handleTopLevelWheel);
|
|
1245
1274
|
}
|
|
1246
1275
|
createRenderRoot() {
|
|
1247
1276
|
return this;
|
|
@@ -1283,6 +1312,9 @@ __decorate([
|
|
|
1283
1312
|
__decorate([
|
|
1284
1313
|
property({ type: String })
|
|
1285
1314
|
], DxGrid.prototype, "activeRefs", void 0);
|
|
1315
|
+
__decorate([
|
|
1316
|
+
property({ type: String })
|
|
1317
|
+
], DxGrid.prototype, "focusIndicatorVariant", void 0);
|
|
1286
1318
|
__decorate([
|
|
1287
1319
|
state()
|
|
1288
1320
|
], DxGrid.prototype, "cells", void 0);
|
|
@@ -1346,6 +1378,12 @@ __decorate([
|
|
|
1346
1378
|
__decorate([
|
|
1347
1379
|
state()
|
|
1348
1380
|
], DxGrid.prototype, "templatefrozenRowsEnd", void 0);
|
|
1381
|
+
__decorate([
|
|
1382
|
+
state()
|
|
1383
|
+
], DxGrid.prototype, "frozenColsSize", void 0);
|
|
1384
|
+
__decorate([
|
|
1385
|
+
state()
|
|
1386
|
+
], DxGrid.prototype, "frozenRowsSize", void 0);
|
|
1349
1387
|
__decorate([
|
|
1350
1388
|
state()
|
|
1351
1389
|
], DxGrid.prototype, "pointer", void 0);
|
|
@@ -1386,6 +1424,6 @@ DxGrid = __decorate([
|
|
|
1386
1424
|
customElement('dx-grid')
|
|
1387
1425
|
], DxGrid);
|
|
1388
1426
|
export { DxGrid };
|
|
1389
|
-
export { rowToA1Notation, colToA1Notation, closestAction, closestCell, parseCellIndex, toPlaneCellIndex, cellQuery, } from './util';
|
|
1427
|
+
export { rowToA1Notation, colToA1Notation, closestAction, closestCell, parseCellIndex, toPlaneCellIndex, cellQuery, accessoryHandlesPointerdownAttrs, } from './util';
|
|
1390
1428
|
export const commentedClassName = 'dx-grid__cell--commented';
|
|
1391
1429
|
//# sourceMappingURL=dx-grid.js.map
|