@dxos/lit-grid 0.8.4-main.5acf9ea → 0.8.4-main.5ad4a44
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 +11 -6
- package/dist/src/dx-grid.d.ts.map +1 -1
- package/dist/src/dx-grid.js +186 -153
- 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 +22 -9
- package/src/dx-grid.ts +179 -100
- 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,17 +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';
|
|
14
|
+
import { html as staticHtml, unsafeStatic } from 'lit/static-html.js';
|
|
15
|
+
import { defaultColSize, defaultRowSize, focusUnfurlDefault } from './defs';
|
|
16
16
|
import './dx-grid-axis-resize-handle';
|
|
17
17
|
import { DxAxisResize, DxEditRequest, DxGridCellsSelect, separator, } from './types';
|
|
18
|
-
import {
|
|
18
|
+
import { cellSelected, closestAction, closestCell, gap, isReadonly, isSameCell, resizeTolerance, resolveColPlane, resolveFrozenPlane, resolveRowPlane, selectionProps, shouldSelect, sizeColMax, sizeColMin, sizeRowMax, sizeRowMin, targetIsPlane, toCellIndex, } from './util';
|
|
19
19
|
let DxGrid = class DxGrid extends LitElement {
|
|
20
20
|
constructor() {
|
|
21
|
-
var _a;
|
|
22
21
|
super();
|
|
23
22
|
this.gridId = 'default-grid-id';
|
|
24
23
|
this.rowDefault = {
|
|
@@ -36,6 +35,7 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
36
35
|
this.frozen = {};
|
|
37
36
|
this.overscroll = undefined;
|
|
38
37
|
this.activeRefs = '';
|
|
38
|
+
this.focusIndicatorVariant = 'sheet';
|
|
39
39
|
/**
|
|
40
40
|
* When this function is defined, it is used first to try to get a value for a cell,
|
|
41
41
|
* and otherwise will fall back to `cells`.
|
|
@@ -82,6 +82,11 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
82
82
|
this.templatefrozenRowsStart = '';
|
|
83
83
|
this.templatefrozenRowsEnd = '';
|
|
84
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
|
+
//
|
|
85
90
|
// Focus, selection, and resize states
|
|
86
91
|
//
|
|
87
92
|
this.pointer = null;
|
|
@@ -132,8 +137,7 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
132
137
|
}
|
|
133
138
|
};
|
|
134
139
|
this.handlePointerUp = (event) => {
|
|
135
|
-
|
|
136
|
-
if (((_a = this.pointer) === null || _a === void 0 ? void 0 : _a.state) === 'selecting') {
|
|
140
|
+
if (this.pointer?.state === 'selecting') {
|
|
137
141
|
const cell = closestCell(event.target);
|
|
138
142
|
if (cell) {
|
|
139
143
|
this.setSelectionEnd(cell);
|
|
@@ -143,8 +147,7 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
143
147
|
this.pointer = null;
|
|
144
148
|
};
|
|
145
149
|
this.handlePointerMove = (event) => {
|
|
146
|
-
|
|
147
|
-
if (((_a = this.pointer) === null || _a === void 0 ? void 0 : _a.state) === 'panning') {
|
|
150
|
+
if (this.pointer?.state === 'panning') {
|
|
148
151
|
const panEvent = event;
|
|
149
152
|
panEvent.deltaX = this.pointer.pageX - event.pageX;
|
|
150
153
|
panEvent.deltaY = this.pointer.pageY - event.pageY;
|
|
@@ -155,7 +158,7 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
155
158
|
else if (shouldSelect(this.pointer, event)) {
|
|
156
159
|
this.pointer = { state: 'selecting' };
|
|
157
160
|
}
|
|
158
|
-
else if (
|
|
161
|
+
else if (this.pointer?.state === 'selecting') {
|
|
159
162
|
const cell = closestCell(event.target);
|
|
160
163
|
if (cell &&
|
|
161
164
|
cell.plane === this.selectionStart.plane &&
|
|
@@ -168,22 +171,20 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
168
171
|
// Resize & reposition handlers, observer, ref
|
|
169
172
|
//
|
|
170
173
|
this.observer = new ResizeObserver((entries) => {
|
|
171
|
-
|
|
172
|
-
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] ?? {
|
|
173
175
|
inlineSize: 0,
|
|
174
176
|
blockSize: 0,
|
|
175
177
|
};
|
|
176
|
-
if (Math.abs(inlineSize - this.sizeInline) > resizeTolerance ||
|
|
177
|
-
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) {
|
|
178
180
|
// console.info('[updating bounds]', 'resize', [inlineSize - this.sizeInline, blockSize - this.sizeBlock]);
|
|
179
|
-
this.sizeInline = inlineSize;
|
|
180
|
-
this.sizeBlock = blockSize;
|
|
181
|
+
this.sizeInline = inlineSize - this.frozenColsSize;
|
|
182
|
+
this.sizeBlock = blockSize - this.frozenRowsSize;
|
|
181
183
|
this.updateVis();
|
|
182
184
|
queueMicrotask(() => this.updatePos());
|
|
183
185
|
}
|
|
184
186
|
});
|
|
185
187
|
this.gridRef = createRef();
|
|
186
|
-
this.viewportRef = createRef();
|
|
187
188
|
this.maybeUpdateVisInline = () => {
|
|
188
189
|
if (this.posInline < this.binInlineMin || this.posInline >= this.binInlineMax) {
|
|
189
190
|
this.updateVisInline();
|
|
@@ -195,8 +196,7 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
195
196
|
}
|
|
196
197
|
};
|
|
197
198
|
this.handleTopLevelWheel = (event) => {
|
|
198
|
-
|
|
199
|
-
if (event.gridId === ((_a = this.gridId) !== null && _a !== void 0 ? _a : 'never')) {
|
|
199
|
+
if (event.gridId === (this.gridId ?? 'never')) {
|
|
200
200
|
if (this.overscroll === 'trap' ||
|
|
201
201
|
(this.overscroll === 'inline' && event.overscrollInline === 0) ||
|
|
202
202
|
(this.overscroll === 'block' && event.overscrollBlock === 0)) {
|
|
@@ -229,7 +229,7 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
229
229
|
}
|
|
230
230
|
};
|
|
231
231
|
// Wheel, top-level and element-level
|
|
232
|
-
|
|
232
|
+
document.defaultView?.addEventListener('wheel', this.handleTopLevelWheel, { passive: false });
|
|
233
233
|
this.addEventListener('wheel', this.handleWheel);
|
|
234
234
|
// Custom event(s)
|
|
235
235
|
this.addEventListener('dx-axis-resize-internal', this.handleAxisResizeInternal);
|
|
@@ -313,32 +313,27 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
315
|
moveFocusBetweenPlanes(event, plane) {
|
|
316
|
-
|
|
317
|
-
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}"]`);
|
|
318
317
|
if (planeElement) {
|
|
319
318
|
const axis = event.key === 'ArrowUp' || event.key === 'ArrowDown' ? 'col' : 'row';
|
|
320
319
|
const delta = event.key === 'ArrowLeft' || event.key === 'ArrowUp' ? -1 : 1;
|
|
321
|
-
const planeAxis = planeElement
|
|
322
|
-
const adjacentPlanes = Array.from(
|
|
323
|
-
|
|
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 });
|
|
324
323
|
}
|
|
325
324
|
}
|
|
326
325
|
moveFocusIntoPlane(plane) {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
this.
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
(_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 });
|
|
338
334
|
}
|
|
339
335
|
moveFocusToPlane() {
|
|
340
|
-
|
|
341
|
-
(_a = this.focusedPlaneElement()) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true });
|
|
336
|
+
this.focusedPlaneElement()?.focus({ preventScroll: true });
|
|
342
337
|
}
|
|
343
338
|
handleKeydown(event) {
|
|
344
339
|
if (this.focusActive && this.mode === 'browse') {
|
|
@@ -409,19 +404,16 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
409
404
|
// Accessors
|
|
410
405
|
//
|
|
411
406
|
colSize(c, plane) {
|
|
412
|
-
var _a, _b, _c, _d, _e;
|
|
413
407
|
const resolvedPlane = resolveColPlane(plane);
|
|
414
|
-
return
|
|
408
|
+
return this.colSizes?.[resolvedPlane]?.[c] ?? this.columnDefault[resolvedPlane]?.size ?? defaultColSize;
|
|
415
409
|
}
|
|
416
410
|
rowSize(r, plane) {
|
|
417
|
-
var _a, _b, _c, _d, _e;
|
|
418
411
|
const resolvedPlane = resolveRowPlane(plane);
|
|
419
|
-
return
|
|
412
|
+
return this.rowSizes?.[resolvedPlane]?.[r] ?? this.rowDefault[resolvedPlane]?.size ?? defaultRowSize;
|
|
420
413
|
}
|
|
421
414
|
cell(c, r, plane) {
|
|
422
|
-
var _a, _b, _c, _d, _e;
|
|
423
415
|
const index = `${c}${separator}${r}`;
|
|
424
|
-
return
|
|
416
|
+
return this.cells?.[plane]?.[index] ?? this.initialCells?.[plane]?.[index];
|
|
425
417
|
}
|
|
426
418
|
cellActive(c, r, plane) {
|
|
427
419
|
return this.focusedCell.plane === plane && this.focusedCell.col === c && this.focusedCell.row === r;
|
|
@@ -482,11 +474,11 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
482
474
|
return this.intrinsicBlockSize - this.sizeBlock;
|
|
483
475
|
}
|
|
484
476
|
updatePosInline(inline, maxInline = this.maxPosInline()) {
|
|
485
|
-
this.posInline = Math.max(0, Math.min(maxInline, inline
|
|
477
|
+
this.posInline = Math.max(0, Math.min(maxInline, inline ?? this.posInline));
|
|
486
478
|
this.maybeUpdateVisInline();
|
|
487
479
|
}
|
|
488
480
|
updatePosBlock(block, maxBlock = this.maxPosBlock()) {
|
|
489
|
-
this.posBlock = Math.max(0, Math.min(maxBlock, block
|
|
481
|
+
this.posBlock = Math.max(0, Math.min(maxBlock, block ?? this.posBlock));
|
|
490
482
|
this.maybeUpdateVisBlock();
|
|
491
483
|
}
|
|
492
484
|
updatePos(inline, block, maxInline, maxBlock) {
|
|
@@ -494,7 +486,6 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
494
486
|
this.updatePosBlock(block, maxBlock);
|
|
495
487
|
}
|
|
496
488
|
updateVisInline() {
|
|
497
|
-
var _a, _b;
|
|
498
489
|
// todo: avoid starting from zero
|
|
499
490
|
let axisCursor = 0;
|
|
500
491
|
let pxCursor = this.colSize(axisCursor, 'grid');
|
|
@@ -524,15 +515,19 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
524
515
|
this.templateGridColumns = [...Array(this.visColMax - this.visColMin)]
|
|
525
516
|
.map((_, c0) => `${this.colSize(this.visColMin + c0, 'grid')}px`)
|
|
526
517
|
.join(' ');
|
|
527
|
-
this.templatefrozenColsStart = [...Array(
|
|
518
|
+
this.templatefrozenColsStart = [...Array(this.frozen.frozenColsStart ?? 0)]
|
|
528
519
|
.map((_, c0) => `${this.colSize(c0, 'frozenColsStart')}px`)
|
|
529
520
|
.join(' ');
|
|
530
|
-
this.templatefrozenColsEnd = [...Array(
|
|
521
|
+
this.templatefrozenColsEnd = [...Array(this.frozen.frozenColsEnd ?? 0)]
|
|
531
522
|
.map((_, c0) => `${this.colSize(c0, 'frozenColsEnd')}px`)
|
|
532
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);
|
|
533
529
|
}
|
|
534
530
|
updateVisBlock() {
|
|
535
|
-
var _a, _b;
|
|
536
531
|
// todo: avoid starting from zero
|
|
537
532
|
let axisCursor = 0;
|
|
538
533
|
let pxCursor = this.rowSize(axisCursor, 'grid');
|
|
@@ -562,19 +557,23 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
562
557
|
this.templateGridRows = [...Array(this.visRowMax - this.visRowMin)]
|
|
563
558
|
.map((_, r0) => `${this.rowSize(this.visRowMin + r0, 'grid')}px`)
|
|
564
559
|
.join(' ');
|
|
565
|
-
this.templatefrozenRowsStart = [...Array(
|
|
560
|
+
this.templatefrozenRowsStart = [...Array(this.frozen.frozenRowsStart ?? 0)]
|
|
566
561
|
.map((_, r0) => `${this.rowSize(r0, 'frozenRowsStart')}px`)
|
|
567
562
|
.join(' ');
|
|
568
|
-
this.templatefrozenRowsEnd = [...Array(
|
|
563
|
+
this.templatefrozenRowsEnd = [...Array(this.frozen.frozenRowsEnd ?? 0)]
|
|
569
564
|
.map((_, r0) => `${this.rowSize(r0, 'frozenRowsEnd')}px`)
|
|
570
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);
|
|
571
571
|
}
|
|
572
572
|
updateVis() {
|
|
573
573
|
this.updateVisInline();
|
|
574
574
|
this.updateVisBlock();
|
|
575
575
|
}
|
|
576
576
|
updateCells(includeFixed) {
|
|
577
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
578
577
|
this.cells.grid = this.getCells({
|
|
579
578
|
start: { col: this.visColMin, row: this.visRowMin },
|
|
580
579
|
end: { col: this.visColMax, row: this.visRowMax },
|
|
@@ -593,25 +592,25 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
593
592
|
}, plane);
|
|
594
593
|
});
|
|
595
594
|
if (includeFixed) {
|
|
596
|
-
if ((
|
|
595
|
+
if ((this.frozen.frozenColsStart ?? 0) > 0 && (this.frozen.frozenRowsStart ?? 0) > 0) {
|
|
597
596
|
this.cells.fixedStartStart = this.getCells({
|
|
598
597
|
start: { col: 0, row: 0 },
|
|
599
598
|
end: { col: this.frozen.frozenColsStart, row: this.frozen.frozenRowsStart },
|
|
600
599
|
}, 'fixedStartStart');
|
|
601
600
|
}
|
|
602
|
-
if ((
|
|
601
|
+
if ((this.frozen.frozenColsEnd ?? 0) > 0 && (this.frozen.frozenRowsStart ?? 0) > 0) {
|
|
603
602
|
this.cells.fixedStartEnd = this.getCells({
|
|
604
603
|
start: { col: 0, row: 0 },
|
|
605
604
|
end: { col: this.frozen.frozenColsEnd, row: this.frozen.frozenRowsStart },
|
|
606
605
|
}, 'fixedStartEnd');
|
|
607
606
|
}
|
|
608
|
-
if ((
|
|
607
|
+
if ((this.frozen.frozenColsStart ?? 0) > 0 && (this.frozen.frozenRowsEnd ?? 0) > 0) {
|
|
609
608
|
this.cells.fixedEndStart = this.getCells({
|
|
610
609
|
start: { col: 0, row: 0 },
|
|
611
610
|
end: { col: this.frozen.frozenColsStart, row: this.frozen.frozenRowsEnd },
|
|
612
611
|
}, 'fixedEndStart');
|
|
613
612
|
}
|
|
614
|
-
if ((
|
|
613
|
+
if ((this.frozen.frozenColsEnd ?? 0) > 0 && (this.frozen.frozenRowsEnd ?? 0) > 0) {
|
|
615
614
|
this.cells.fixedEndEnd = this.getCells({
|
|
616
615
|
start: { col: 0, row: 0 },
|
|
617
616
|
end: { col: this.frozen.frozenColsEnd, row: this.frozen.frozenRowsEnd },
|
|
@@ -649,12 +648,10 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
649
648
|
return `[data-dx-grid-plane=${this.focusedCell.plane}]`;
|
|
650
649
|
}
|
|
651
650
|
focusedCellElement() {
|
|
652
|
-
|
|
653
|
-
return (_a = this.gridRef.value) === null || _a === void 0 ? void 0 : _a.querySelector(this.focusedCellQuery());
|
|
651
|
+
return this.gridRef.value?.querySelector(this.focusedCellQuery());
|
|
654
652
|
}
|
|
655
653
|
focusedPlaneElement() {
|
|
656
|
-
|
|
657
|
-
return (_a = this.gridRef.value) === null || _a === void 0 ? void 0 : _a.querySelector(this.focusedPlaneQuery());
|
|
654
|
+
return this.gridRef.value?.querySelector(this.focusedPlaneQuery());
|
|
658
655
|
}
|
|
659
656
|
//
|
|
660
657
|
// `outOfVis` returns by how many rows/cols the focused cell is outside of the `vis` range for an axis, inset by a
|
|
@@ -813,22 +810,37 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
813
810
|
// Resize handlers
|
|
814
811
|
//
|
|
815
812
|
axisResizeable(plane, axis, index) {
|
|
816
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
817
813
|
return axis === 'col'
|
|
818
|
-
? !!(
|
|
819
|
-
: !!(
|
|
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));
|
|
820
833
|
}
|
|
821
834
|
handleAxisResizeInternal(event) {
|
|
822
835
|
event.stopPropagation();
|
|
823
836
|
const { plane, axis, delta, size, index, state } = event;
|
|
837
|
+
const nextSize = this.clampAxisSize(plane, axis, index, size + delta);
|
|
824
838
|
if (axis === 'col') {
|
|
825
|
-
const nextSize = Math.max(sizeColMin, Math.min(sizeColMax, size + delta));
|
|
826
839
|
this.colSizes = { ...this.colSizes, [plane]: { ...this.colSizes[plane], [index]: nextSize } };
|
|
827
840
|
this.updateVisInline();
|
|
828
841
|
this.updateIntrinsicInlineSize();
|
|
829
842
|
}
|
|
830
843
|
else {
|
|
831
|
-
const nextSize = Math.max(sizeRowMin, Math.min(sizeRowMax, size + delta));
|
|
832
844
|
this.rowSizes = { ...this.colSizes, [plane]: { ...this.rowSizes[plane], [index]: nextSize } };
|
|
833
845
|
this.updateVisBlock();
|
|
834
846
|
this.updateIntrinsicBlockSize();
|
|
@@ -847,7 +859,6 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
847
859
|
//
|
|
848
860
|
// TODO(thure): This is for rendering presentational objects superimposed onto the canonical grid (e.g. DnD drop line for #8108).
|
|
849
861
|
renderPresentationLayer(offsetInline, offsetBlock) {
|
|
850
|
-
var _a, _b, _c, _d, _e, _f;
|
|
851
862
|
const visibleCols = this.visColMax - this.visColMin;
|
|
852
863
|
const visibleRows = this.visRowMax - this.visRowMin;
|
|
853
864
|
return html `<div
|
|
@@ -855,32 +866,29 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
855
866
|
class="dx-grid-layer--presentation"
|
|
856
867
|
style=${styleMap({
|
|
857
868
|
gridTemplateColumns: [
|
|
858
|
-
...[...Array(
|
|
869
|
+
...[...Array(this.frozen.frozenColsStart ?? 0)].map((_, c0) => `${this.colSize(c0, 'frozenColsStart')}px`),
|
|
859
870
|
...[...Array(visibleCols)].map((_, c0) => c0 === visibleCols - 1
|
|
860
871
|
? '1fr'
|
|
861
872
|
: `${this.colSize(this.visColMin + c0, 'grid') + (c0 === 0 ? offsetInline : 0)}px`),
|
|
862
|
-
...[...Array(
|
|
873
|
+
...[...Array(this.frozen.frozenColsEnd ?? 0)].map((_, c0) => `${this.colSize(c0, 'frozenColsEnd')}px`),
|
|
863
874
|
].join(' '),
|
|
864
875
|
gridTemplateRows: [
|
|
865
|
-
...[...Array(
|
|
876
|
+
...[...Array(this.frozen.frozenRowsStart ?? 0)].map((_, r0) => `${this.rowSize(r0, 'frozenRowsStart')}px`),
|
|
866
877
|
...[...Array(visibleRows)].map((_, r0) => r0 === visibleRows - 1
|
|
867
878
|
? '1fr'
|
|
868
879
|
: `${this.rowSize(this.visRowMin + r0, 'grid') + (r0 === 0 ? offsetBlock : 0)}px`),
|
|
869
|
-
...[...Array(
|
|
880
|
+
...[...Array(this.frozen.frozenRowsEnd ?? 0)].map((_, r0) => `${this.rowSize(r0, 'frozenRowsEnd')}px`),
|
|
870
881
|
].join(' '),
|
|
871
882
|
})}
|
|
872
883
|
>
|
|
873
884
|
${
|
|
874
885
|
/* TODO(thure): These are debug cells, remove when rendering actual overlay content. */ [
|
|
875
|
-
...Array((
|
|
876
|
-
].map((_, r0) =>
|
|
877
|
-
var _a, _b;
|
|
878
|
-
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
|
|
879
888
|
role="none"
|
|
880
889
|
class="dx-grid-layer--presentation__cell"
|
|
881
890
|
style="grid-column:${c0 + 1};grid-row:${r0 + 1}"
|
|
882
|
-
></div>`)
|
|
883
|
-
})}
|
|
891
|
+
></div>`))}
|
|
884
892
|
</div>`;
|
|
885
893
|
}
|
|
886
894
|
renderFixed(plane, selection) {
|
|
@@ -888,7 +896,7 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
888
896
|
const rowPlane = resolveRowPlane(plane);
|
|
889
897
|
const cols = this.frozen[colPlane];
|
|
890
898
|
const rows = this.frozen[rowPlane];
|
|
891
|
-
return (cols
|
|
899
|
+
return (cols ?? 0) > 0 && (rows ?? 0) > 0
|
|
892
900
|
? html `<div
|
|
893
901
|
role="none"
|
|
894
902
|
tabindex="0"
|
|
@@ -912,7 +920,7 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
912
920
|
renderFrozenRows(plane, visibleCols, offsetInline, selection) {
|
|
913
921
|
const rowPlane = resolveRowPlane(plane);
|
|
914
922
|
const rows = this.frozen[rowPlane];
|
|
915
|
-
return (rows
|
|
923
|
+
return (rows ?? 0) > 0 && this.limitColumns > 0
|
|
916
924
|
? html `<div
|
|
917
925
|
role="none"
|
|
918
926
|
class="dx-grid__plane--frozen-row"
|
|
@@ -940,7 +948,7 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
940
948
|
renderFrozenColumns(plane, visibleRows, offsetBlock, selection) {
|
|
941
949
|
const colPlane = resolveColPlane(plane);
|
|
942
950
|
const cols = this.frozen[colPlane];
|
|
943
|
-
return (cols
|
|
951
|
+
return (cols ?? 0) > 0 && this.limitRows > 0
|
|
944
952
|
? html `<div
|
|
945
953
|
role="none"
|
|
946
954
|
class="dx-grid__plane--frozen-col"
|
|
@@ -965,47 +973,84 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
965
973
|
</div>`
|
|
966
974
|
: null;
|
|
967
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
|
+
}
|
|
968
1003
|
cellReadonly(col, row, plane) {
|
|
969
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
970
1004
|
const colPlane = resolveColPlane(plane);
|
|
971
1005
|
const rowPlane = resolveRowPlane(plane);
|
|
972
1006
|
// Check cell-specific setting first.
|
|
973
|
-
const cellReadonly =
|
|
1007
|
+
const cellReadonly = this.cell(col, row, plane)?.readonly;
|
|
974
1008
|
if (cellReadonly !== undefined) {
|
|
975
1009
|
return isReadonly(cellReadonly);
|
|
976
1010
|
}
|
|
977
1011
|
// Check column/row defaults.
|
|
978
|
-
const colReadOnly =
|
|
979
|
-
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;
|
|
980
1014
|
return isReadonly(colReadOnly) || isReadonly(rowReadOnly);
|
|
981
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
|
+
}
|
|
982
1029
|
/**
|
|
983
1030
|
* Determines if the cell's text content should be selectable based on its readonly value.
|
|
984
1031
|
* @returns true if the cells text content is selectable, false otherwise.
|
|
985
1032
|
*/
|
|
986
1033
|
cellTextSelectable(col, row, plane) {
|
|
987
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
988
1034
|
const colPlane = resolveColPlane(plane);
|
|
989
1035
|
const rowPlane = resolveRowPlane(plane);
|
|
990
1036
|
// Check cell-specific setting first.
|
|
991
|
-
const cellReadonly =
|
|
1037
|
+
const cellReadonly = this.cell(col, row, plane)?.readonly;
|
|
992
1038
|
if (cellReadonly !== undefined) {
|
|
993
1039
|
return cellReadonly === 'text-select';
|
|
994
1040
|
}
|
|
995
1041
|
// Check column/row defaults.
|
|
996
|
-
const colReadonly =
|
|
997
|
-
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;
|
|
998
1044
|
return colReadonly === 'text-select' || rowReadonly === 'text-select';
|
|
999
1045
|
}
|
|
1000
1046
|
getOverflowingCellModifiedDeltas(event) {
|
|
1001
|
-
var _a;
|
|
1002
1047
|
if (!event.target) {
|
|
1003
1048
|
return event;
|
|
1004
1049
|
}
|
|
1005
1050
|
const element = event.target;
|
|
1006
1051
|
const activeCell = element.closest('[data-dx-active]');
|
|
1007
1052
|
const contentEl = element.closest('.dx-grid__cell__content');
|
|
1008
|
-
if (!activeCell || !contentEl || !
|
|
1053
|
+
if (!activeCell || !contentEl || !document.activeElement?.contains(element)) {
|
|
1009
1054
|
return event;
|
|
1010
1055
|
}
|
|
1011
1056
|
// Commented-out code will let the event delta through unmodified if the cell can scroll but is scrolled to the end
|
|
@@ -1025,21 +1070,22 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
1025
1070
|
return { deltaX, deltaY };
|
|
1026
1071
|
}
|
|
1027
1072
|
renderCell(col, row, plane, selected, visCol = col, visRow = row) {
|
|
1028
|
-
var _a, _b;
|
|
1029
1073
|
const cell = this.cell(col, row, plane);
|
|
1030
1074
|
const active = this.cellActive(col, row, plane);
|
|
1031
1075
|
const readonly = this.cellReadonly(col, row, plane);
|
|
1076
|
+
const focusUnfurl = this.cellFocusUnfurl(col, row, plane);
|
|
1032
1077
|
const textSelectable = this.cellTextSelectable(col, row, plane);
|
|
1033
|
-
const resizeIndex =
|
|
1034
|
-
const resizePlane =
|
|
1035
|
-
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;
|
|
1036
1081
|
return html `<div
|
|
1037
1082
|
role="gridcell"
|
|
1038
1083
|
tabindex="0"
|
|
1039
1084
|
aria-selected=${selected ? 'true' : nothing}
|
|
1040
1085
|
aria-readonly=${readonly ? 'true' : nothing}
|
|
1041
|
-
class=${
|
|
1042
|
-
data-refs=${
|
|
1086
|
+
class=${cell?.className ?? nothing}
|
|
1087
|
+
data-refs=${cell?.dataRefs ?? nothing}
|
|
1088
|
+
data-focus-unfurl=${focusUnfurl ? nothing : 'false'}
|
|
1043
1089
|
?data-dx-active=${active}
|
|
1044
1090
|
data-text-selectable=${textSelectable ? 'true' : 'false'}
|
|
1045
1091
|
data-dx-grid-action="cell"
|
|
@@ -1047,8 +1093,8 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
1047
1093
|
aria-rowindex=${row}
|
|
1048
1094
|
style="grid-column:${visCol + 1};grid-row:${visRow + 1}"
|
|
1049
1095
|
>
|
|
1050
|
-
<div role="none" class="dx-grid__cell__content">${cell
|
|
1051
|
-
${
|
|
1096
|
+
<div role="none" class="dx-grid__cell__content">${cell?.value}${accessory}</div>
|
|
1097
|
+
${cell?.resizeHandle &&
|
|
1052
1098
|
this.mode === 'browse' &&
|
|
1053
1099
|
this.axisResizeable(resizePlane, cell.resizeHandle, resizeIndex)
|
|
1054
1100
|
? html `<dx-grid-axis-resize-handle
|
|
@@ -1078,9 +1124,24 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
1078
1124
|
<div
|
|
1079
1125
|
role="none"
|
|
1080
1126
|
class="dx-grid"
|
|
1127
|
+
data-arrow-keys="all"
|
|
1081
1128
|
style=${styleMap({
|
|
1082
|
-
'grid-template-columns':
|
|
1083
|
-
|
|
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(' '),
|
|
1084
1145
|
'--dx-grid-content-inline-size': Number.isFinite(this.limitColumns)
|
|
1085
1146
|
? `${Math.max(0, this.totalIntrinsicInlineSize)}px`
|
|
1086
1147
|
: 'max-content',
|
|
@@ -1090,74 +1151,39 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
1090
1151
|
})}
|
|
1091
1152
|
data-grid=${this.gridId}
|
|
1092
1153
|
data-grid-mode=${this.mode}
|
|
1154
|
+
data-grid-focus-indicator-variant=${this.focusIndicatorVariant}
|
|
1093
1155
|
?data-grid-select=${selection.visible}
|
|
1094
1156
|
${ref(this.gridRef)}
|
|
1095
1157
|
>
|
|
1096
1158
|
${this.renderFixed('fixedStartStart', selection)}${this.renderFrozenRows('frozenRowsStart', visibleCols, offsetInline, selection)}${this.renderFixed('fixedStartEnd', selection)}${this.renderFrozenColumns('frozenColsStart', visibleRows, offsetBlock, selection)}
|
|
1097
|
-
|
|
1098
|
-
role="grid"
|
|
1099
|
-
class="dx-grid__plane--grid"
|
|
1100
|
-
tabindex="0"
|
|
1101
|
-
data-dx-grid-plane="grid"
|
|
1102
|
-
data-dx-grid-plane-row="1"
|
|
1103
|
-
data-dx-grid-plane-col="1"
|
|
1104
|
-
${ref(this.viewportRef)}
|
|
1105
|
-
>
|
|
1106
|
-
<div
|
|
1107
|
-
role="none"
|
|
1108
|
-
class="dx-grid__plane--grid__content"
|
|
1109
|
-
style="transform:translate3d(${offsetInline}px,${offsetBlock}px,0);grid-template-columns:${this
|
|
1110
|
-
.templateGridColumns};grid-template-rows:${this.templateGridRows};"
|
|
1111
|
-
>
|
|
1112
|
-
${[...Array(visibleRows)].map((_, r0) => {
|
|
1113
|
-
return [...Array(visibleCols)].map((_, c0) => {
|
|
1114
|
-
const c = c0 + this.visColMin;
|
|
1115
|
-
const r = r0 + this.visRowMin;
|
|
1116
|
-
return this.renderCell(c, r, 'grid', cellSelected(c, r, 'grid', selection), c0, r0);
|
|
1117
|
-
});
|
|
1118
|
-
})}
|
|
1119
|
-
</div>
|
|
1120
|
-
</div>
|
|
1159
|
+
${this.renderMainGrid(visibleCols, visibleRows, offsetInline, offsetBlock, selection)}
|
|
1121
1160
|
${this.renderFrozenColumns('frozenColsEnd', visibleRows, offsetBlock, selection)}${this.renderFixed('fixedEndStart', selection)}${this.renderFrozenRows('frozenRowsEnd', visibleCols, offsetInline, selection)}${this.renderFixed('fixedEndEnd', selection)}
|
|
1122
1161
|
</div>`;
|
|
1123
1162
|
}
|
|
1124
1163
|
updateIntrinsicInlineSize() {
|
|
1125
1164
|
this.intrinsicInlineSize = Number.isFinite(this.limitColumns)
|
|
1126
1165
|
? [...Array(this.limitColumns)].reduce((acc, _, c0) => acc + this.colSize(c0, 'grid'), 0) +
|
|
1127
|
-
gap * (this.limitColumns - 1)
|
|
1166
|
+
gap * Math.max(0, this.limitColumns - 1)
|
|
1128
1167
|
: Infinity;
|
|
1129
1168
|
this.totalIntrinsicInlineSize =
|
|
1130
|
-
this.intrinsicInlineSize +
|
|
1131
|
-
(Number.isFinite(this.frozen.frozenColsStart)
|
|
1132
|
-
? [...Array(this.frozen.frozenColsStart)].reduce((acc, _, c0) => acc + gap + this.colSize(c0, 'frozenColsStart'), 0)
|
|
1133
|
-
: 0) +
|
|
1134
|
-
(Number.isFinite(this.frozen.frozenColsEnd)
|
|
1135
|
-
? [...Array(this.frozen.frozenColsEnd)].reduce((acc, _, c0) => acc + gap + this.colSize(c0, 'frozenColsEnd'), 0)
|
|
1136
|
-
: 0);
|
|
1169
|
+
this.limitColumns > 0 ? this.intrinsicInlineSize + this.frozenColsSize : this.frozenColsSize - gap;
|
|
1137
1170
|
}
|
|
1138
1171
|
updateIntrinsicBlockSize() {
|
|
1139
1172
|
this.intrinsicBlockSize = Number.isFinite(this.limitRows)
|
|
1140
1173
|
? [...Array(this.limitRows)].reduce((acc, _, r0) => acc + this.rowSize(r0, 'grid'), 0) +
|
|
1141
|
-
gap * (this.limitRows - 1)
|
|
1174
|
+
gap * Math.max(0, this.limitRows - 1)
|
|
1142
1175
|
: Infinity;
|
|
1143
1176
|
this.totalIntrinsicBlockSize =
|
|
1144
|
-
this.intrinsicBlockSize +
|
|
1145
|
-
(Number.isFinite(this.frozen.frozenRowsStart)
|
|
1146
|
-
? [...Array(this.frozen.frozenRowsStart)].reduce((acc, _, r0) => acc + gap + this.rowSize(r0, 'frozenRowsStart'), 0)
|
|
1147
|
-
: 0) +
|
|
1148
|
-
(Number.isFinite(this.frozen.frozenRowsEnd)
|
|
1149
|
-
? [...Array(this.frozen.frozenRowsEnd)].reduce((acc, _, r0) => acc + gap + this.rowSize(r0, 'frozenRowsEnd'), 0)
|
|
1150
|
-
: 0);
|
|
1177
|
+
this.limitRows > 0 ? this.intrinsicBlockSize + this.frozenRowsSize : this.frozenRowsSize - gap;
|
|
1151
1178
|
}
|
|
1152
1179
|
updateIntrinsicSizes() {
|
|
1153
1180
|
this.updateIntrinsicInlineSize();
|
|
1154
1181
|
this.updateIntrinsicBlockSize();
|
|
1155
1182
|
}
|
|
1156
1183
|
computeColSizes() {
|
|
1157
|
-
|
|
1158
|
-
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]) => {
|
|
1159
1185
|
acc[plane] = Object.entries(planeColMeta).reduce((planeAcc, [col, colMeta]) => {
|
|
1160
|
-
if (colMeta
|
|
1186
|
+
if (colMeta?.size) {
|
|
1161
1187
|
planeAcc[col] = colMeta.size;
|
|
1162
1188
|
}
|
|
1163
1189
|
return planeAcc;
|
|
@@ -1166,10 +1192,9 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
1166
1192
|
}, { grid: {} });
|
|
1167
1193
|
}
|
|
1168
1194
|
computeRowSizes() {
|
|
1169
|
-
|
|
1170
|
-
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]) => {
|
|
1171
1196
|
acc[plane] = Object.entries(planeRowMeta).reduce((planeAcc, [row, rowMeta]) => {
|
|
1172
|
-
if (rowMeta
|
|
1197
|
+
if (rowMeta?.size) {
|
|
1173
1198
|
planeAcc[row] = rowMeta.size;
|
|
1174
1199
|
}
|
|
1175
1200
|
return planeAcc;
|
|
@@ -1181,7 +1206,7 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
1181
1206
|
if (this.getCells) {
|
|
1182
1207
|
this.updateCells(true);
|
|
1183
1208
|
}
|
|
1184
|
-
this.observer.observe(this.
|
|
1209
|
+
this.observer.observe(this.gridRef.value);
|
|
1185
1210
|
this.computeColSizes();
|
|
1186
1211
|
this.computeRowSizes();
|
|
1187
1212
|
this.updateIntrinsicSizes();
|
|
@@ -1241,12 +1266,11 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
1241
1266
|
return false;
|
|
1242
1267
|
}
|
|
1243
1268
|
disconnectedCallback() {
|
|
1244
|
-
var _a;
|
|
1245
1269
|
super.disconnectedCallback();
|
|
1246
|
-
if (this.
|
|
1247
|
-
this.observer.unobserve(this.
|
|
1270
|
+
if (this.gridRef.value) {
|
|
1271
|
+
this.observer.unobserve(this.gridRef.value);
|
|
1248
1272
|
}
|
|
1249
|
-
|
|
1273
|
+
document.defaultView?.removeEventListener('wheel', this.handleTopLevelWheel);
|
|
1250
1274
|
}
|
|
1251
1275
|
createRenderRoot() {
|
|
1252
1276
|
return this;
|
|
@@ -1288,6 +1312,9 @@ __decorate([
|
|
|
1288
1312
|
__decorate([
|
|
1289
1313
|
property({ type: String })
|
|
1290
1314
|
], DxGrid.prototype, "activeRefs", void 0);
|
|
1315
|
+
__decorate([
|
|
1316
|
+
property({ type: String })
|
|
1317
|
+
], DxGrid.prototype, "focusIndicatorVariant", void 0);
|
|
1291
1318
|
__decorate([
|
|
1292
1319
|
state()
|
|
1293
1320
|
], DxGrid.prototype, "cells", void 0);
|
|
@@ -1351,6 +1378,12 @@ __decorate([
|
|
|
1351
1378
|
__decorate([
|
|
1352
1379
|
state()
|
|
1353
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);
|
|
1354
1387
|
__decorate([
|
|
1355
1388
|
state()
|
|
1356
1389
|
], DxGrid.prototype, "pointer", void 0);
|
|
@@ -1391,6 +1424,6 @@ DxGrid = __decorate([
|
|
|
1391
1424
|
customElement('dx-grid')
|
|
1392
1425
|
], DxGrid);
|
|
1393
1426
|
export { DxGrid };
|
|
1394
|
-
export { rowToA1Notation, colToA1Notation, closestAction, closestCell, parseCellIndex, toPlaneCellIndex, cellQuery, } from './util';
|
|
1427
|
+
export { rowToA1Notation, colToA1Notation, closestAction, closestCell, parseCellIndex, toPlaneCellIndex, cellQuery, accessoryHandlesPointerdownAttrs, } from './util';
|
|
1395
1428
|
export const commentedClassName = 'dx-grid__cell--commented';
|
|
1396
1429
|
//# sourceMappingURL=dx-grid.js.map
|