@dxos/lit-grid 0.8.3 → 0.8.4-main.16b68245aa
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 +15 -9
- package/dist/src/dx-grid.d.ts.map +1 -1
- package/dist/src/dx-grid.js +253 -172
- package/dist/src/dx-grid.js.map +1 -1
- package/dist/src/dx-grid.lit-stories.d.ts +13 -15
- package/dist/src/dx-grid.lit-stories.d.ts.map +1 -1
- package/dist/src/dx-grid.lit-stories.js +22 -23
- package/dist/src/dx-grid.lit-stories.js.map +1 -1
- package/dist/src/playwright/dx-grid.spec.d.ts.map +1 -0
- package/dist/src/{testing/playwright → playwright}/dx-grid.spec.js +3 -3
- package/dist/src/playwright/dx-grid.spec.js.map +1 -0
- package/dist/src/playwright/playwright.config.d.ts +3 -0
- package/dist/src/playwright/playwright.config.d.ts.map +1 -0
- package/dist/src/playwright/playwright.config.js +15 -0
- package/dist/src/playwright/playwright.config.js.map +1 -0
- package/dist/src/testing/{playwright/dx-grid-manager.d.ts → dx-grid-manager.d.ts} +1 -1
- package/dist/src/testing/dx-grid-manager.d.ts.map +1 -0
- package/dist/src/testing/dx-grid-manager.js.map +1 -0
- package/dist/src/testing/index.d.ts +1 -1
- package/dist/src/testing/index.d.ts.map +1 -1
- package/dist/src/testing/index.js +1 -1
- package/dist/src/testing/index.js.map +1 -1
- package/dist/src/types.d.ts +10 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/src/util.d.ts +8 -5
- 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 +15 -14
- package/src/defs.ts +1 -0
- package/src/dx-grid-axis-resize-handle.pcss +10 -3
- package/src/dx-grid-axis-resize-handle.ts +1 -1
- package/src/dx-grid-multiselect-cell.pcss +8 -6
- package/src/dx-grid-multiselect-cell.ts +2 -1
- package/src/dx-grid.lit-stories.ts +6 -4
- package/src/dx-grid.pcss +146 -20
- package/src/dx-grid.ts +268 -123
- package/src/{testing/playwright → playwright}/dx-grid.spec.ts +5 -5
- package/src/playwright/playwright.config.ts +17 -0
- package/src/testing/{playwright/dx-grid-manager.ts → dx-grid-manager.ts} +2 -2
- package/src/testing/index.ts +1 -1
- package/src/types.ts +11 -0
- package/src/util.ts +13 -9
- package/dist/src/testing/playwright/dx-grid-manager.d.ts.map +0 -1
- package/dist/src/testing/playwright/dx-grid-manager.js.map +0 -1
- package/dist/src/testing/playwright/dx-grid.spec.d.ts.map +0 -1
- package/dist/src/testing/playwright/dx-grid.spec.js.map +0 -1
- package/dist/types/src/defs.d.ts +0 -3
- package/dist/types/src/defs.d.ts.map +0 -1
- package/dist/types/src/defs.js +0 -6
- package/dist/types/src/defs.js.map +0 -1
- package/dist/types/src/dx-grid-axis-resize-handle.d.ts +0 -16
- package/dist/types/src/dx-grid-axis-resize-handle.d.ts.map +0 -1
- package/dist/types/src/dx-grid-axis-resize-handle.js +0 -100
- package/dist/types/src/dx-grid-axis-resize-handle.js.map +0 -1
- package/dist/types/src/dx-grid-multiselect-cell.d.ts +0 -13
- package/dist/types/src/dx-grid-multiselect-cell.d.ts.map +0 -1
- package/dist/types/src/dx-grid-multiselect-cell.js +0 -56
- package/dist/types/src/dx-grid-multiselect-cell.js.map +0 -1
- package/dist/types/src/dx-grid.d.ts +0 -170
- package/dist/types/src/dx-grid.d.ts.map +0 -1
- package/dist/types/src/dx-grid.js +0 -1347
- package/dist/types/src/dx-grid.js.map +0 -1
- package/dist/types/src/dx-grid.lit-stories.d.ts +0 -46
- package/dist/types/src/dx-grid.lit-stories.d.ts.map +0 -1
- package/dist/types/src/dx-grid.lit-stories.js +0 -179
- package/dist/types/src/dx-grid.lit-stories.js.map +0 -1
- package/dist/types/src/index.d.ts +0 -5
- package/dist/types/src/index.d.ts.map +0 -1
- package/dist/types/src/index.js +0 -8
- package/dist/types/src/index.js.map +0 -1
- package/dist/types/src/testing/index.d.ts +0 -2
- package/dist/types/src/testing/index.d.ts.map +0 -1
- package/dist/types/src/testing/index.js +0 -5
- package/dist/types/src/testing/index.js.map +0 -1
- package/dist/types/src/testing/playwright/dx-grid-manager.d.ts +0 -24
- package/dist/types/src/testing/playwright/dx-grid-manager.d.ts.map +0 -1
- package/dist/types/src/testing/playwright/dx-grid-manager.js +0 -79
- package/dist/types/src/testing/playwright/dx-grid-manager.js.map +0 -1
- package/dist/types/src/testing/playwright/dx-grid.spec.d.ts +0 -2
- package/dist/types/src/testing/playwright/dx-grid.spec.d.ts.map +0 -1
- package/dist/types/src/testing/playwright/dx-grid.spec.js +0 -92
- package/dist/types/src/testing/playwright/dx-grid.spec.js.map +0 -1
- package/dist/types/src/types.d.ts +0 -137
- package/dist/types/src/types.d.ts.map +0 -1
- package/dist/types/src/types.js +0 -46
- package/dist/types/src/types.js.map +0 -1
- package/dist/types/src/util.d.ts +0 -39
- package/dist/types/src/util.d.ts.map +0 -1
- package/dist/types/src/util.js +0 -165
- package/dist/types/src/util.js.map +0 -1
- package/dist/types/tsconfig.tsbuildinfo +0 -1
- package/src/testing/playwright/playwright.config.cts +0 -18
- /package/dist/src/{testing/playwright → playwright}/dx-grid.spec.d.ts +0 -0
- /package/dist/src/testing/{playwright/dx-grid-manager.js → dx-grid-manager.js} +0 -0
package/dist/src/dx-grid.js
CHANGED
|
@@ -7,19 +7,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
8
8
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
9
9
|
};
|
|
10
|
+
import './dx-grid-axis-resize-handle';
|
|
10
11
|
import { LitElement, html, nothing } from 'lit';
|
|
11
|
-
import { customElement,
|
|
12
|
-
import {
|
|
12
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
13
|
+
import { createRef, ref } from 'lit/directives/ref.js';
|
|
13
14
|
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
|
|
17
|
-
import './dx-grid-axis-resize-handle';
|
|
15
|
+
import { html as staticHtml, unsafeStatic } from 'lit/static-html.js';
|
|
16
|
+
import { defaultColSize, defaultRowSize, focusUnfurlDefault } from './defs';
|
|
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;
|
|
@@ -122,7 +126,7 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
122
126
|
this.dispatchSelectionChange();
|
|
123
127
|
}
|
|
124
128
|
if (this.mode === 'edit-select') {
|
|
125
|
-
// Prevent focus moving when editing while selection is possible
|
|
129
|
+
// Prevent focus moving when editing while selection is possible.
|
|
126
130
|
event.preventDefault();
|
|
127
131
|
}
|
|
128
132
|
else if (this.focusActive && isSameCell(this.focusedCell, cellCoords)) {
|
|
@@ -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 &&
|
|
@@ -166,25 +168,23 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
166
168
|
}
|
|
167
169
|
};
|
|
168
170
|
//
|
|
169
|
-
// Resize & reposition handlers, observer, ref
|
|
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,20 +196,28 @@ 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)) {
|
|
204
|
-
event.
|
|
205
|
-
|
|
203
|
+
const element = event.target;
|
|
204
|
+
const activeCell = element.closest('[data-dx-active]');
|
|
205
|
+
const contentEl = element.closest('.dx-grid__cell__content');
|
|
206
|
+
if (!(element &&
|
|
207
|
+
activeCell &&
|
|
208
|
+
contentEl &&
|
|
209
|
+
(contentEl.scrollWidth > contentEl.clientWidth || contentEl.scrollHeight > contentEl.clientHeight))) {
|
|
210
|
+
event.preventDefault();
|
|
211
|
+
event.stopPropagation();
|
|
212
|
+
}
|
|
206
213
|
}
|
|
207
214
|
}
|
|
208
215
|
};
|
|
209
216
|
this.handleWheel = (event) => {
|
|
210
217
|
if (this.mode === 'browse') {
|
|
211
|
-
const
|
|
212
|
-
const
|
|
218
|
+
const { deltaX, deltaY } = this.getOverflowingCellModifiedDeltas(event);
|
|
219
|
+
const nextPosInline = this.posInline + deltaX;
|
|
220
|
+
const nextPosBlock = this.posBlock + deltaY;
|
|
213
221
|
const maxPosInline = this.maxPosInline();
|
|
214
222
|
const maxPosBlock = this.maxPosBlock();
|
|
215
223
|
this.updatePos(nextPosInline, nextPosBlock, maxPosInline, maxPosBlock);
|
|
@@ -220,12 +228,12 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
220
228
|
event.gridId = this.gridId;
|
|
221
229
|
}
|
|
222
230
|
};
|
|
223
|
-
// Wheel, top-level and element-level
|
|
224
|
-
|
|
231
|
+
// Wheel, top-level and element-level.
|
|
232
|
+
document.defaultView?.addEventListener('wheel', this.handleTopLevelWheel, { passive: false });
|
|
225
233
|
this.addEventListener('wheel', this.handleWheel);
|
|
226
|
-
// Custom event(s)
|
|
234
|
+
// Custom event(s).
|
|
227
235
|
this.addEventListener('dx-axis-resize-internal', this.handleAxisResizeInternal);
|
|
228
|
-
// Standard events
|
|
236
|
+
// Standard events.
|
|
229
237
|
this.addEventListener('pointerdown', this.handlePointerDown);
|
|
230
238
|
this.addEventListener('pointermove', this.handlePointerMove);
|
|
231
239
|
this.addEventListener('pointerup', this.handlePointerUp);
|
|
@@ -305,32 +313,27 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
305
313
|
}
|
|
306
314
|
}
|
|
307
315
|
moveFocusBetweenPlanes(event, plane) {
|
|
308
|
-
|
|
309
|
-
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}"]`);
|
|
310
317
|
if (planeElement) {
|
|
311
318
|
const axis = event.key === 'ArrowUp' || event.key === 'ArrowDown' ? 'col' : 'row';
|
|
312
319
|
const delta = event.key === 'ArrowLeft' || event.key === 'ArrowUp' ? -1 : 1;
|
|
313
|
-
const planeAxis = planeElement
|
|
314
|
-
const adjacentPlanes = Array.from(
|
|
315
|
-
|
|
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 });
|
|
316
323
|
}
|
|
317
324
|
}
|
|
318
325
|
moveFocusIntoPlane(plane) {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
this.
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
(_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 });
|
|
330
334
|
}
|
|
331
335
|
moveFocusToPlane() {
|
|
332
|
-
|
|
333
|
-
(_a = this.focusedPlaneElement()) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true });
|
|
336
|
+
this.focusedPlaneElement()?.focus({ preventScroll: true });
|
|
334
337
|
}
|
|
335
338
|
handleKeydown(event) {
|
|
336
339
|
if (this.focusActive && this.mode === 'browse') {
|
|
@@ -381,6 +384,13 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
381
384
|
event.preventDefault();
|
|
382
385
|
this.dispatchEditRequest();
|
|
383
386
|
break;
|
|
387
|
+
case 'Backspace':
|
|
388
|
+
case 'Delete':
|
|
389
|
+
if (!event.defaultPrevented) {
|
|
390
|
+
event.preventDefault();
|
|
391
|
+
this.dispatchEditRequest('');
|
|
392
|
+
}
|
|
393
|
+
break;
|
|
384
394
|
default:
|
|
385
395
|
if (event.key.length === 1 && event.key.match(/\P{Cc}/u) && !(event.metaKey || event.ctrlKey)) {
|
|
386
396
|
this.dispatchEditRequest(event.key);
|
|
@@ -394,19 +404,16 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
394
404
|
// Accessors
|
|
395
405
|
//
|
|
396
406
|
colSize(c, plane) {
|
|
397
|
-
var _a, _b, _c, _d, _e;
|
|
398
407
|
const resolvedPlane = resolveColPlane(plane);
|
|
399
|
-
return
|
|
408
|
+
return this.colSizes?.[resolvedPlane]?.[c] ?? this.columnDefault[resolvedPlane]?.size ?? defaultColSize;
|
|
400
409
|
}
|
|
401
410
|
rowSize(r, plane) {
|
|
402
|
-
var _a, _b, _c, _d, _e;
|
|
403
411
|
const resolvedPlane = resolveRowPlane(plane);
|
|
404
|
-
return
|
|
412
|
+
return this.rowSizes?.[resolvedPlane]?.[r] ?? this.rowDefault[resolvedPlane]?.size ?? defaultRowSize;
|
|
405
413
|
}
|
|
406
414
|
cell(c, r, plane) {
|
|
407
|
-
var _a, _b, _c, _d, _e;
|
|
408
415
|
const index = `${c}${separator}${r}`;
|
|
409
|
-
return
|
|
416
|
+
return this.cells?.[plane]?.[index] ?? this.initialCells?.[plane]?.[index];
|
|
410
417
|
}
|
|
411
418
|
cellActive(c, r, plane) {
|
|
412
419
|
return this.focusedCell.plane === plane && this.focusedCell.col === c && this.focusedCell.row === r;
|
|
@@ -467,11 +474,11 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
467
474
|
return this.intrinsicBlockSize - this.sizeBlock;
|
|
468
475
|
}
|
|
469
476
|
updatePosInline(inline, maxInline = this.maxPosInline()) {
|
|
470
|
-
this.posInline = Math.max(0, Math.min(maxInline, inline
|
|
477
|
+
this.posInline = Math.max(0, Math.min(maxInline, inline ?? this.posInline));
|
|
471
478
|
this.maybeUpdateVisInline();
|
|
472
479
|
}
|
|
473
480
|
updatePosBlock(block, maxBlock = this.maxPosBlock()) {
|
|
474
|
-
this.posBlock = Math.max(0, Math.min(maxBlock, block
|
|
481
|
+
this.posBlock = Math.max(0, Math.min(maxBlock, block ?? this.posBlock));
|
|
475
482
|
this.maybeUpdateVisBlock();
|
|
476
483
|
}
|
|
477
484
|
updatePos(inline, block, maxInline, maxBlock) {
|
|
@@ -479,8 +486,7 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
479
486
|
this.updatePosBlock(block, maxBlock);
|
|
480
487
|
}
|
|
481
488
|
updateVisInline() {
|
|
482
|
-
|
|
483
|
-
// todo: avoid starting from zero
|
|
489
|
+
// todo: avoid starting from zero.
|
|
484
490
|
let axisCursor = 0;
|
|
485
491
|
let pxCursor = this.colSize(axisCursor, 'grid');
|
|
486
492
|
while (pxCursor < this.posInline) {
|
|
@@ -509,16 +515,20 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
509
515
|
this.templateGridColumns = [...Array(this.visColMax - this.visColMin)]
|
|
510
516
|
.map((_, c0) => `${this.colSize(this.visColMin + c0, 'grid')}px`)
|
|
511
517
|
.join(' ');
|
|
512
|
-
this.templatefrozenColsStart = [...Array(
|
|
518
|
+
this.templatefrozenColsStart = [...Array(this.frozen.frozenColsStart ?? 0)]
|
|
513
519
|
.map((_, c0) => `${this.colSize(c0, 'frozenColsStart')}px`)
|
|
514
520
|
.join(' ');
|
|
515
|
-
this.templatefrozenColsEnd = [...Array(
|
|
521
|
+
this.templatefrozenColsEnd = [...Array(this.frozen.frozenColsEnd ?? 0)]
|
|
516
522
|
.map((_, c0) => `${this.colSize(c0, 'frozenColsEnd')}px`)
|
|
517
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);
|
|
518
529
|
}
|
|
519
530
|
updateVisBlock() {
|
|
520
|
-
|
|
521
|
-
// todo: avoid starting from zero
|
|
531
|
+
// todo: avoid starting from zero.
|
|
522
532
|
let axisCursor = 0;
|
|
523
533
|
let pxCursor = this.rowSize(axisCursor, 'grid');
|
|
524
534
|
while (pxCursor < this.posBlock) {
|
|
@@ -547,19 +557,23 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
547
557
|
this.templateGridRows = [...Array(this.visRowMax - this.visRowMin)]
|
|
548
558
|
.map((_, r0) => `${this.rowSize(this.visRowMin + r0, 'grid')}px`)
|
|
549
559
|
.join(' ');
|
|
550
|
-
this.templatefrozenRowsStart = [...Array(
|
|
560
|
+
this.templatefrozenRowsStart = [...Array(this.frozen.frozenRowsStart ?? 0)]
|
|
551
561
|
.map((_, r0) => `${this.rowSize(r0, 'frozenRowsStart')}px`)
|
|
552
562
|
.join(' ');
|
|
553
|
-
this.templatefrozenRowsEnd = [...Array(
|
|
563
|
+
this.templatefrozenRowsEnd = [...Array(this.frozen.frozenRowsEnd ?? 0)]
|
|
554
564
|
.map((_, r0) => `${this.rowSize(r0, 'frozenRowsEnd')}px`)
|
|
555
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);
|
|
556
571
|
}
|
|
557
572
|
updateVis() {
|
|
558
573
|
this.updateVisInline();
|
|
559
574
|
this.updateVisBlock();
|
|
560
575
|
}
|
|
561
576
|
updateCells(includeFixed) {
|
|
562
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
563
577
|
this.cells.grid = this.getCells({
|
|
564
578
|
start: { col: this.visColMin, row: this.visRowMin },
|
|
565
579
|
end: { col: this.visColMax, row: this.visRowMax },
|
|
@@ -578,25 +592,25 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
578
592
|
}, plane);
|
|
579
593
|
});
|
|
580
594
|
if (includeFixed) {
|
|
581
|
-
if ((
|
|
595
|
+
if ((this.frozen.frozenColsStart ?? 0) > 0 && (this.frozen.frozenRowsStart ?? 0) > 0) {
|
|
582
596
|
this.cells.fixedStartStart = this.getCells({
|
|
583
597
|
start: { col: 0, row: 0 },
|
|
584
598
|
end: { col: this.frozen.frozenColsStart, row: this.frozen.frozenRowsStart },
|
|
585
599
|
}, 'fixedStartStart');
|
|
586
600
|
}
|
|
587
|
-
if ((
|
|
601
|
+
if ((this.frozen.frozenColsEnd ?? 0) > 0 && (this.frozen.frozenRowsStart ?? 0) > 0) {
|
|
588
602
|
this.cells.fixedStartEnd = this.getCells({
|
|
589
603
|
start: { col: 0, row: 0 },
|
|
590
604
|
end: { col: this.frozen.frozenColsEnd, row: this.frozen.frozenRowsStart },
|
|
591
605
|
}, 'fixedStartEnd');
|
|
592
606
|
}
|
|
593
|
-
if ((
|
|
607
|
+
if ((this.frozen.frozenColsStart ?? 0) > 0 && (this.frozen.frozenRowsEnd ?? 0) > 0) {
|
|
594
608
|
this.cells.fixedEndStart = this.getCells({
|
|
595
609
|
start: { col: 0, row: 0 },
|
|
596
610
|
end: { col: this.frozen.frozenColsStart, row: this.frozen.frozenRowsEnd },
|
|
597
611
|
}, 'fixedEndStart');
|
|
598
612
|
}
|
|
599
|
-
if ((
|
|
613
|
+
if ((this.frozen.frozenColsEnd ?? 0) > 0 && (this.frozen.frozenRowsEnd ?? 0) > 0) {
|
|
600
614
|
this.cells.fixedEndEnd = this.getCells({
|
|
601
615
|
start: { col: 0, row: 0 },
|
|
602
616
|
end: { col: this.frozen.frozenColsEnd, row: this.frozen.frozenRowsEnd },
|
|
@@ -634,12 +648,10 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
634
648
|
return `[data-dx-grid-plane=${this.focusedCell.plane}]`;
|
|
635
649
|
}
|
|
636
650
|
focusedCellElement() {
|
|
637
|
-
|
|
638
|
-
return (_a = this.gridRef.value) === null || _a === void 0 ? void 0 : _a.querySelector(this.focusedCellQuery());
|
|
651
|
+
return this.gridRef.value?.querySelector(this.focusedCellQuery());
|
|
639
652
|
}
|
|
640
653
|
focusedPlaneElement() {
|
|
641
|
-
|
|
642
|
-
return (_a = this.gridRef.value) === null || _a === void 0 ? void 0 : _a.querySelector(this.focusedPlaneQuery());
|
|
654
|
+
return this.gridRef.value?.querySelector(this.focusedPlaneQuery());
|
|
643
655
|
}
|
|
644
656
|
//
|
|
645
657
|
// `outOfVis` returns by how many rows/cols the focused cell is outside of the `vis` range for an axis, inset by a
|
|
@@ -737,7 +749,7 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
737
749
|
}, 0);
|
|
738
750
|
}
|
|
739
751
|
/**
|
|
740
|
-
* Updates `pos` so that a cell in focus is fully within the viewport
|
|
752
|
+
* Updates `pos` so that a cell in focus is fully within the viewport.
|
|
741
753
|
*/
|
|
742
754
|
snapPosToFocusedCell() {
|
|
743
755
|
const outOfVis = this.focusedCellOutOfVis();
|
|
@@ -798,22 +810,37 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
798
810
|
// Resize handlers
|
|
799
811
|
//
|
|
800
812
|
axisResizeable(plane, axis, index) {
|
|
801
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
802
813
|
return axis === 'col'
|
|
803
|
-
? !!(
|
|
804
|
-
: !!(
|
|
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));
|
|
805
833
|
}
|
|
806
834
|
handleAxisResizeInternal(event) {
|
|
807
835
|
event.stopPropagation();
|
|
808
836
|
const { plane, axis, delta, size, index, state } = event;
|
|
837
|
+
const nextSize = this.clampAxisSize(plane, axis, index, size + delta);
|
|
809
838
|
if (axis === 'col') {
|
|
810
|
-
const nextSize = Math.max(sizeColMin, Math.min(sizeColMax, size + delta));
|
|
811
839
|
this.colSizes = { ...this.colSizes, [plane]: { ...this.colSizes[plane], [index]: nextSize } };
|
|
812
840
|
this.updateVisInline();
|
|
813
841
|
this.updateIntrinsicInlineSize();
|
|
814
842
|
}
|
|
815
843
|
else {
|
|
816
|
-
const nextSize = Math.max(sizeRowMin, Math.min(sizeRowMax, size + delta));
|
|
817
844
|
this.rowSizes = { ...this.colSizes, [plane]: { ...this.rowSizes[plane], [index]: nextSize } };
|
|
818
845
|
this.updateVisBlock();
|
|
819
846
|
this.updateIntrinsicBlockSize();
|
|
@@ -828,11 +855,10 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
828
855
|
}
|
|
829
856
|
}
|
|
830
857
|
//
|
|
831
|
-
// Render and other lifecycle methods
|
|
858
|
+
// Render and other lifecycle methods.
|
|
832
859
|
//
|
|
833
860
|
// TODO(thure): This is for rendering presentational objects superimposed onto the canonical grid (e.g. DnD drop line for #8108).
|
|
834
861
|
renderPresentationLayer(offsetInline, offsetBlock) {
|
|
835
|
-
var _a, _b, _c, _d, _e, _f;
|
|
836
862
|
const visibleCols = this.visColMax - this.visColMin;
|
|
837
863
|
const visibleRows = this.visRowMax - this.visRowMin;
|
|
838
864
|
return html `<div
|
|
@@ -840,32 +866,29 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
840
866
|
class="dx-grid-layer--presentation"
|
|
841
867
|
style=${styleMap({
|
|
842
868
|
gridTemplateColumns: [
|
|
843
|
-
...[...Array(
|
|
869
|
+
...[...Array(this.frozen.frozenColsStart ?? 0)].map((_, c0) => `${this.colSize(c0, 'frozenColsStart')}px`),
|
|
844
870
|
...[...Array(visibleCols)].map((_, c0) => c0 === visibleCols - 1
|
|
845
871
|
? '1fr'
|
|
846
872
|
: `${this.colSize(this.visColMin + c0, 'grid') + (c0 === 0 ? offsetInline : 0)}px`),
|
|
847
|
-
...[...Array(
|
|
873
|
+
...[...Array(this.frozen.frozenColsEnd ?? 0)].map((_, c0) => `${this.colSize(c0, 'frozenColsEnd')}px`),
|
|
848
874
|
].join(' '),
|
|
849
875
|
gridTemplateRows: [
|
|
850
|
-
...[...Array(
|
|
876
|
+
...[...Array(this.frozen.frozenRowsStart ?? 0)].map((_, r0) => `${this.rowSize(r0, 'frozenRowsStart')}px`),
|
|
851
877
|
...[...Array(visibleRows)].map((_, r0) => r0 === visibleRows - 1
|
|
852
878
|
? '1fr'
|
|
853
879
|
: `${this.rowSize(this.visRowMin + r0, 'grid') + (r0 === 0 ? offsetBlock : 0)}px`),
|
|
854
|
-
...[...Array(
|
|
880
|
+
...[...Array(this.frozen.frozenRowsEnd ?? 0)].map((_, r0) => `${this.rowSize(r0, 'frozenRowsEnd')}px`),
|
|
855
881
|
].join(' '),
|
|
856
882
|
})}
|
|
857
883
|
>
|
|
858
884
|
${
|
|
859
885
|
/* TODO(thure): These are debug cells, remove when rendering actual overlay content. */ [
|
|
860
|
-
...Array((
|
|
861
|
-
].map((_, r0) =>
|
|
862
|
-
var _a, _b;
|
|
863
|
-
return [...Array(((_a = this.frozen.frozenColsStart) !== null && _a !== void 0 ? _a : 0) + visibleCols + ((_b = this.frozen.frozenColsEnd) !== null && _b !== void 0 ? _b : 0))].map((_, c0) => html `<div
|
|
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
|
|
864
888
|
role="none"
|
|
865
889
|
class="dx-grid-layer--presentation__cell"
|
|
866
890
|
style="grid-column:${c0 + 1};grid-row:${r0 + 1}"
|
|
867
|
-
></div>`)
|
|
868
|
-
})}
|
|
891
|
+
></div>`))}
|
|
869
892
|
</div>`;
|
|
870
893
|
}
|
|
871
894
|
renderFixed(plane, selection) {
|
|
@@ -873,7 +896,7 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
873
896
|
const rowPlane = resolveRowPlane(plane);
|
|
874
897
|
const cols = this.frozen[colPlane];
|
|
875
898
|
const rows = this.frozen[rowPlane];
|
|
876
|
-
return (cols
|
|
899
|
+
return (cols ?? 0) > 0 && (rows ?? 0) > 0
|
|
877
900
|
? html `<div
|
|
878
901
|
role="none"
|
|
879
902
|
tabindex="0"
|
|
@@ -897,7 +920,7 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
897
920
|
renderFrozenRows(plane, visibleCols, offsetInline, selection) {
|
|
898
921
|
const rowPlane = resolveRowPlane(plane);
|
|
899
922
|
const rows = this.frozen[rowPlane];
|
|
900
|
-
return (rows
|
|
923
|
+
return (rows ?? 0) > 0 && this.limitColumns > 0
|
|
901
924
|
? html `<div
|
|
902
925
|
role="none"
|
|
903
926
|
class="dx-grid__plane--frozen-row"
|
|
@@ -925,7 +948,7 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
925
948
|
renderFrozenColumns(plane, visibleRows, offsetBlock, selection) {
|
|
926
949
|
const colPlane = resolveColPlane(plane);
|
|
927
950
|
const cols = this.frozen[colPlane];
|
|
928
|
-
return (cols
|
|
951
|
+
return (cols ?? 0) > 0 && this.limitRows > 0
|
|
929
952
|
? html `<div
|
|
930
953
|
role="none"
|
|
931
954
|
class="dx-grid__plane--frozen-col"
|
|
@@ -950,64 +973,129 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
950
973
|
</div>`
|
|
951
974
|
: null;
|
|
952
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
|
+
}
|
|
953
1003
|
cellReadonly(col, row, plane) {
|
|
954
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
955
1004
|
const colPlane = resolveColPlane(plane);
|
|
956
1005
|
const rowPlane = resolveRowPlane(plane);
|
|
957
1006
|
// Check cell-specific setting first.
|
|
958
|
-
const cellReadonly =
|
|
1007
|
+
const cellReadonly = this.cell(col, row, plane)?.readonly;
|
|
959
1008
|
if (cellReadonly !== undefined) {
|
|
960
1009
|
return isReadonly(cellReadonly);
|
|
961
1010
|
}
|
|
962
1011
|
// Check column/row defaults.
|
|
963
|
-
const colReadOnly =
|
|
964
|
-
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;
|
|
965
1014
|
return isReadonly(colReadOnly) || isReadonly(rowReadOnly);
|
|
966
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
|
+
}
|
|
967
1029
|
/**
|
|
968
1030
|
* Determines if the cell's text content should be selectable based on its readonly value.
|
|
969
1031
|
* @returns true if the cells text content is selectable, false otherwise.
|
|
970
1032
|
*/
|
|
971
1033
|
cellTextSelectable(col, row, plane) {
|
|
972
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
973
1034
|
const colPlane = resolveColPlane(plane);
|
|
974
1035
|
const rowPlane = resolveRowPlane(plane);
|
|
975
1036
|
// Check cell-specific setting first.
|
|
976
|
-
const cellReadonly =
|
|
1037
|
+
const cellReadonly = this.cell(col, row, plane)?.readonly;
|
|
977
1038
|
if (cellReadonly !== undefined) {
|
|
978
1039
|
return cellReadonly === 'text-select';
|
|
979
1040
|
}
|
|
980
1041
|
// Check column/row defaults.
|
|
981
|
-
const colReadonly =
|
|
982
|
-
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;
|
|
983
1044
|
return colReadonly === 'text-select' || rowReadonly === 'text-select';
|
|
984
1045
|
}
|
|
1046
|
+
getOverflowingCellModifiedDeltas(event) {
|
|
1047
|
+
if (!event.target) {
|
|
1048
|
+
return event;
|
|
1049
|
+
}
|
|
1050
|
+
const element = event.target;
|
|
1051
|
+
const activeCell = element.closest('[data-dx-active]');
|
|
1052
|
+
const contentEl = element.closest('.dx-grid__cell__content');
|
|
1053
|
+
if (!activeCell || !contentEl || !document.activeElement?.contains(element)) {
|
|
1054
|
+
return event;
|
|
1055
|
+
}
|
|
1056
|
+
// Commented-out code will let the event delta through unmodified if the cell can scroll but is scrolled to the end
|
|
1057
|
+
// in the same direction as the wheel event, a.k.a. “overscroll”; this is probably undesirable, though.
|
|
1058
|
+
const { scrollWidth, clientWidth, scrollHeight, clientHeight /*, scrollLeft, scrollTop */ } = contentEl;
|
|
1059
|
+
if (scrollWidth <= clientWidth && scrollHeight <= clientHeight) {
|
|
1060
|
+
return event;
|
|
1061
|
+
}
|
|
1062
|
+
const deltaX = scrollWidth > clientWidth /* &&
|
|
1063
|
+
((event.deltaX < 0 && scrollLeft > 0) || (event.deltaX > 0 && scrollLeft < scrollWidth - clientWidth)) */
|
|
1064
|
+
? 0
|
|
1065
|
+
: event.deltaX;
|
|
1066
|
+
const deltaY = scrollHeight > clientHeight /* &&
|
|
1067
|
+
((event.deltaY < 0 && scrollTop > 0) || (event.deltaY > 0 && scrollTop < scrollHeight - clientHeight)) */
|
|
1068
|
+
? 0
|
|
1069
|
+
: event.deltaY;
|
|
1070
|
+
return { deltaX, deltaY };
|
|
1071
|
+
}
|
|
985
1072
|
renderCell(col, row, plane, selected, visCol = col, visRow = row) {
|
|
986
|
-
var _a, _b;
|
|
987
1073
|
const cell = this.cell(col, row, plane);
|
|
988
1074
|
const active = this.cellActive(col, row, plane);
|
|
989
1075
|
const readonly = this.cellReadonly(col, row, plane);
|
|
1076
|
+
const focusUnfurl = this.cellFocusUnfurl(col, row, plane);
|
|
990
1077
|
const textSelectable = this.cellTextSelectable(col, row, plane);
|
|
991
|
-
const resizeIndex =
|
|
992
|
-
const resizePlane =
|
|
993
|
-
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;
|
|
994
1081
|
return html `<div
|
|
995
1082
|
role="gridcell"
|
|
996
1083
|
tabindex="0"
|
|
997
1084
|
aria-selected=${selected ? 'true' : nothing}
|
|
998
1085
|
aria-readonly=${readonly ? 'true' : nothing}
|
|
999
|
-
class=${
|
|
1000
|
-
data-refs=${
|
|
1086
|
+
class=${cell?.className ?? nothing}
|
|
1087
|
+
data-refs=${cell?.dataRefs ?? nothing}
|
|
1088
|
+
data-focus-unfurl=${focusUnfurl ? nothing : 'false'}
|
|
1001
1089
|
?data-dx-active=${active}
|
|
1002
1090
|
data-text-selectable=${textSelectable ? 'true' : 'false'}
|
|
1003
1091
|
data-dx-grid-action="cell"
|
|
1004
1092
|
aria-colindex=${col}
|
|
1005
1093
|
aria-rowindex=${row}
|
|
1094
|
+
data-testid=${`${plane}.${col}.${row}`}
|
|
1006
1095
|
style="grid-column:${visCol + 1};grid-row:${visRow + 1}"
|
|
1007
1096
|
>
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
: accessory}${(cell === null || cell === void 0 ? void 0 : cell.resizeHandle) &&
|
|
1097
|
+
<div role="none" class="dx-grid__cell__content">${cell?.value}${accessory}</div>
|
|
1098
|
+
${cell?.resizeHandle &&
|
|
1011
1099
|
this.mode === 'browse' &&
|
|
1012
1100
|
this.axisResizeable(resizePlane, cell.resizeHandle, resizeIndex)
|
|
1013
1101
|
? html `<dx-grid-axis-resize-handle
|
|
@@ -1029,17 +1117,30 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
1029
1117
|
${this.activeRefs
|
|
1030
1118
|
.split(' ')
|
|
1031
1119
|
.filter((value) => value)
|
|
1032
|
-
.map(
|
|
1033
|
-
// TODO(burdon): Consistent camelCase?
|
|
1034
|
-
(activeRef) => `[data-refs~="${activeRef}"] { background: var(--dx-grid-commented-active, var(--dx-gridCommentedActive)) !important; }`)
|
|
1120
|
+
.map((activeRef) => `[data-refs~="${activeRef}"] { background: var(--color-grid-comment-active) !important; }`)
|
|
1035
1121
|
.join('\n')}
|
|
1036
1122
|
</style>
|
|
1037
1123
|
<div
|
|
1038
1124
|
role="none"
|
|
1039
1125
|
class="dx-grid"
|
|
1126
|
+
data-arrow-keys="all"
|
|
1040
1127
|
style=${styleMap({
|
|
1041
|
-
'grid-template-columns':
|
|
1042
|
-
|
|
1128
|
+
'grid-template-columns': [
|
|
1129
|
+
this.templatefrozenColsStart ? 'min-content' : false,
|
|
1130
|
+
this.limitColumns > 0 &&
|
|
1131
|
+
`minmax(0, ${Number.isFinite(this.limitColumns) ? `${Math.max(0, this.intrinsicInlineSize)}px` : '1fr'})`,
|
|
1132
|
+
this.templatefrozenColsEnd ? 'min-content' : false,
|
|
1133
|
+
]
|
|
1134
|
+
.filter(Boolean)
|
|
1135
|
+
.join(' '),
|
|
1136
|
+
'grid-template-rows': [
|
|
1137
|
+
this.templatefrozenRowsStart ? 'min-content' : false,
|
|
1138
|
+
this.limitRows > 0 &&
|
|
1139
|
+
`minmax(0, ${Number.isFinite(this.limitRows) ? `${Math.max(0, this.intrinsicBlockSize)}px` : '1fr'})`,
|
|
1140
|
+
this.templatefrozenRowsEnd ? ' min-content' : false,
|
|
1141
|
+
]
|
|
1142
|
+
.filter(Boolean)
|
|
1143
|
+
.join(' '),
|
|
1043
1144
|
'--dx-grid-content-inline-size': Number.isFinite(this.limitColumns)
|
|
1044
1145
|
? `${Math.max(0, this.totalIntrinsicInlineSize)}px`
|
|
1045
1146
|
: 'max-content',
|
|
@@ -1049,74 +1150,39 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
1049
1150
|
})}
|
|
1050
1151
|
data-grid=${this.gridId}
|
|
1051
1152
|
data-grid-mode=${this.mode}
|
|
1153
|
+
data-grid-focus-indicator-variant=${this.focusIndicatorVariant}
|
|
1052
1154
|
?data-grid-select=${selection.visible}
|
|
1053
1155
|
${ref(this.gridRef)}
|
|
1054
1156
|
>
|
|
1055
1157
|
${this.renderFixed('fixedStartStart', selection)}${this.renderFrozenRows('frozenRowsStart', visibleCols, offsetInline, selection)}${this.renderFixed('fixedStartEnd', selection)}${this.renderFrozenColumns('frozenColsStart', visibleRows, offsetBlock, selection)}
|
|
1056
|
-
|
|
1057
|
-
role="grid"
|
|
1058
|
-
class="dx-grid__plane--grid"
|
|
1059
|
-
tabindex="0"
|
|
1060
|
-
data-dx-grid-plane="grid"
|
|
1061
|
-
data-dx-grid-plane-row="1"
|
|
1062
|
-
data-dx-grid-plane-col="1"
|
|
1063
|
-
${ref(this.viewportRef)}
|
|
1064
|
-
>
|
|
1065
|
-
<div
|
|
1066
|
-
role="none"
|
|
1067
|
-
class="dx-grid__plane--grid__content"
|
|
1068
|
-
style="transform:translate3d(${offsetInline}px,${offsetBlock}px,0);grid-template-columns:${this
|
|
1069
|
-
.templateGridColumns};grid-template-rows:${this.templateGridRows};"
|
|
1070
|
-
>
|
|
1071
|
-
${[...Array(visibleRows)].map((_, r0) => {
|
|
1072
|
-
return [...Array(visibleCols)].map((_, c0) => {
|
|
1073
|
-
const c = c0 + this.visColMin;
|
|
1074
|
-
const r = r0 + this.visRowMin;
|
|
1075
|
-
return this.renderCell(c, r, 'grid', cellSelected(c, r, 'grid', selection), c0, r0);
|
|
1076
|
-
});
|
|
1077
|
-
})}
|
|
1078
|
-
</div>
|
|
1079
|
-
</div>
|
|
1158
|
+
${this.renderMainGrid(visibleCols, visibleRows, offsetInline, offsetBlock, selection)}
|
|
1080
1159
|
${this.renderFrozenColumns('frozenColsEnd', visibleRows, offsetBlock, selection)}${this.renderFixed('fixedEndStart', selection)}${this.renderFrozenRows('frozenRowsEnd', visibleCols, offsetInline, selection)}${this.renderFixed('fixedEndEnd', selection)}
|
|
1081
1160
|
</div>`;
|
|
1082
1161
|
}
|
|
1083
1162
|
updateIntrinsicInlineSize() {
|
|
1084
1163
|
this.intrinsicInlineSize = Number.isFinite(this.limitColumns)
|
|
1085
1164
|
? [...Array(this.limitColumns)].reduce((acc, _, c0) => acc + this.colSize(c0, 'grid'), 0) +
|
|
1086
|
-
gap * (this.limitColumns - 1)
|
|
1165
|
+
gap * Math.max(0, this.limitColumns - 1)
|
|
1087
1166
|
: Infinity;
|
|
1088
1167
|
this.totalIntrinsicInlineSize =
|
|
1089
|
-
this.intrinsicInlineSize +
|
|
1090
|
-
(Number.isFinite(this.frozen.frozenColsStart)
|
|
1091
|
-
? [...Array(this.frozen.frozenColsStart)].reduce((acc, _, c0) => acc + gap + this.colSize(c0, 'frozenColsStart'), 0)
|
|
1092
|
-
: 0) +
|
|
1093
|
-
(Number.isFinite(this.frozen.frozenColsEnd)
|
|
1094
|
-
? [...Array(this.frozen.frozenColsEnd)].reduce((acc, _, c0) => acc + gap + this.colSize(c0, 'frozenColsEnd'), 0)
|
|
1095
|
-
: 0);
|
|
1168
|
+
this.limitColumns > 0 ? this.intrinsicInlineSize + this.frozenColsSize : this.frozenColsSize - gap;
|
|
1096
1169
|
}
|
|
1097
1170
|
updateIntrinsicBlockSize() {
|
|
1098
1171
|
this.intrinsicBlockSize = Number.isFinite(this.limitRows)
|
|
1099
1172
|
? [...Array(this.limitRows)].reduce((acc, _, r0) => acc + this.rowSize(r0, 'grid'), 0) +
|
|
1100
|
-
gap * (this.limitRows - 1)
|
|
1173
|
+
gap * Math.max(0, this.limitRows - 1)
|
|
1101
1174
|
: Infinity;
|
|
1102
1175
|
this.totalIntrinsicBlockSize =
|
|
1103
|
-
this.intrinsicBlockSize +
|
|
1104
|
-
(Number.isFinite(this.frozen.frozenRowsStart)
|
|
1105
|
-
? [...Array(this.frozen.frozenRowsStart)].reduce((acc, _, r0) => acc + gap + this.rowSize(r0, 'frozenRowsStart'), 0)
|
|
1106
|
-
: 0) +
|
|
1107
|
-
(Number.isFinite(this.frozen.frozenRowsEnd)
|
|
1108
|
-
? [...Array(this.frozen.frozenRowsEnd)].reduce((acc, _, r0) => acc + gap + this.rowSize(r0, 'frozenRowsEnd'), 0)
|
|
1109
|
-
: 0);
|
|
1176
|
+
this.limitRows > 0 ? this.intrinsicBlockSize + this.frozenRowsSize : this.frozenRowsSize - gap;
|
|
1110
1177
|
}
|
|
1111
1178
|
updateIntrinsicSizes() {
|
|
1112
1179
|
this.updateIntrinsicInlineSize();
|
|
1113
1180
|
this.updateIntrinsicBlockSize();
|
|
1114
1181
|
}
|
|
1115
1182
|
computeColSizes() {
|
|
1116
|
-
|
|
1117
|
-
this.colSizes = Object.entries((_a = this.columns) !== null && _a !== void 0 ? _a : {}).reduce((acc, [plane, planeColMeta]) => {
|
|
1183
|
+
this.colSizes = Object.entries(this.columns ?? {}).reduce((acc, [plane, planeColMeta]) => {
|
|
1118
1184
|
acc[plane] = Object.entries(planeColMeta).reduce((planeAcc, [col, colMeta]) => {
|
|
1119
|
-
if (colMeta
|
|
1185
|
+
if (colMeta?.size) {
|
|
1120
1186
|
planeAcc[col] = colMeta.size;
|
|
1121
1187
|
}
|
|
1122
1188
|
return planeAcc;
|
|
@@ -1125,10 +1191,9 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
1125
1191
|
}, { grid: {} });
|
|
1126
1192
|
}
|
|
1127
1193
|
computeRowSizes() {
|
|
1128
|
-
|
|
1129
|
-
this.rowSizes = Object.entries((_a = this.rows) !== null && _a !== void 0 ? _a : {}).reduce((acc, [plane, planeRowMeta]) => {
|
|
1194
|
+
this.rowSizes = Object.entries(this.rows ?? {}).reduce((acc, [plane, planeRowMeta]) => {
|
|
1130
1195
|
acc[plane] = Object.entries(planeRowMeta).reduce((planeAcc, [row, rowMeta]) => {
|
|
1131
|
-
if (rowMeta
|
|
1196
|
+
if (rowMeta?.size) {
|
|
1132
1197
|
planeAcc[row] = rowMeta.size;
|
|
1133
1198
|
}
|
|
1134
1199
|
return planeAcc;
|
|
@@ -1140,7 +1205,7 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
1140
1205
|
if (this.getCells) {
|
|
1141
1206
|
this.updateCells(true);
|
|
1142
1207
|
}
|
|
1143
|
-
this.observer.observe(this.
|
|
1208
|
+
this.observer.observe(this.gridRef.value);
|
|
1144
1209
|
this.computeColSizes();
|
|
1145
1210
|
this.computeRowSizes();
|
|
1146
1211
|
this.updateIntrinsicSizes();
|
|
@@ -1160,6 +1225,12 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
1160
1225
|
this.updatePosInline();
|
|
1161
1226
|
this.updateVisInline();
|
|
1162
1227
|
}
|
|
1228
|
+
if (changedProperties.has('frozen')) {
|
|
1229
|
+
this.updateIntrinsicBlockSize();
|
|
1230
|
+
this.updateIntrinsicInlineSize();
|
|
1231
|
+
this.updateVisBlock();
|
|
1232
|
+
this.updateVisInline();
|
|
1233
|
+
}
|
|
1163
1234
|
if (this.getCells &&
|
|
1164
1235
|
(changedProperties.has('initialCells') ||
|
|
1165
1236
|
changedProperties.has('visColMin') ||
|
|
@@ -1169,7 +1240,8 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
1169
1240
|
changedProperties.has('columns') ||
|
|
1170
1241
|
changedProperties.has('rows') ||
|
|
1171
1242
|
changedProperties.has('limitColumns') ||
|
|
1172
|
-
changedProperties.has('limitRows')
|
|
1243
|
+
changedProperties.has('limitRows') ||
|
|
1244
|
+
changedProperties.has('frozen'))) {
|
|
1173
1245
|
this.updateCells(true);
|
|
1174
1246
|
}
|
|
1175
1247
|
}
|
|
@@ -1184,20 +1256,20 @@ let DxGrid = class DxGrid extends LitElement {
|
|
|
1184
1256
|
this.refocus();
|
|
1185
1257
|
}
|
|
1186
1258
|
}
|
|
1187
|
-
updateIfWithinBounds({ col, row }) {
|
|
1259
|
+
updateIfWithinBounds({ col, row }, includeFixed) {
|
|
1188
1260
|
if (col >= this.visColMin && col <= this.visColMax && row >= this.visRowMin && row <= this.visRowMax) {
|
|
1261
|
+
this.updateCells(includeFixed);
|
|
1189
1262
|
this.requestUpdate();
|
|
1190
1263
|
return true;
|
|
1191
1264
|
}
|
|
1192
1265
|
return false;
|
|
1193
1266
|
}
|
|
1194
1267
|
disconnectedCallback() {
|
|
1195
|
-
var _a;
|
|
1196
1268
|
super.disconnectedCallback();
|
|
1197
|
-
if (this.
|
|
1198
|
-
this.observer.unobserve(this.
|
|
1269
|
+
if (this.gridRef.value) {
|
|
1270
|
+
this.observer.unobserve(this.gridRef.value);
|
|
1199
1271
|
}
|
|
1200
|
-
|
|
1272
|
+
document.defaultView?.removeEventListener('wheel', this.handleTopLevelWheel);
|
|
1201
1273
|
}
|
|
1202
1274
|
createRenderRoot() {
|
|
1203
1275
|
return this;
|
|
@@ -1239,6 +1311,9 @@ __decorate([
|
|
|
1239
1311
|
__decorate([
|
|
1240
1312
|
property({ type: String })
|
|
1241
1313
|
], DxGrid.prototype, "activeRefs", void 0);
|
|
1314
|
+
__decorate([
|
|
1315
|
+
property({ type: String })
|
|
1316
|
+
], DxGrid.prototype, "focusIndicatorVariant", void 0);
|
|
1242
1317
|
__decorate([
|
|
1243
1318
|
state()
|
|
1244
1319
|
], DxGrid.prototype, "cells", void 0);
|
|
@@ -1302,6 +1377,12 @@ __decorate([
|
|
|
1302
1377
|
__decorate([
|
|
1303
1378
|
state()
|
|
1304
1379
|
], DxGrid.prototype, "templatefrozenRowsEnd", void 0);
|
|
1380
|
+
__decorate([
|
|
1381
|
+
state()
|
|
1382
|
+
], DxGrid.prototype, "frozenColsSize", void 0);
|
|
1383
|
+
__decorate([
|
|
1384
|
+
state()
|
|
1385
|
+
], DxGrid.prototype, "frozenRowsSize", void 0);
|
|
1305
1386
|
__decorate([
|
|
1306
1387
|
state()
|
|
1307
1388
|
], DxGrid.prototype, "pointer", void 0);
|
|
@@ -1342,6 +1423,6 @@ DxGrid = __decorate([
|
|
|
1342
1423
|
customElement('dx-grid')
|
|
1343
1424
|
], DxGrid);
|
|
1344
1425
|
export { DxGrid };
|
|
1345
|
-
export { rowToA1Notation, colToA1Notation, closestAction, closestCell, parseCellIndex, toPlaneCellIndex, cellQuery, } from './util';
|
|
1426
|
+
export { rowToA1Notation, colToA1Notation, closestAction, closestCell, parseCellIndex, toPlaneCellIndex, cellQuery, accessoryHandlesPointerdownAttrs, } from './util';
|
|
1346
1427
|
export const commentedClassName = 'dx-grid__cell--commented';
|
|
1347
1428
|
//# sourceMappingURL=dx-grid.js.map
|