@dxos/lit-grid 0.6.12-main.78ddbdf → 0.6.12-main.89e9959
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/lib/browser/index.mjs +522 -217
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/dx-grid-axis-resize-handle.d.ts +2 -1
- package/dist/types/src/dx-grid-axis-resize-handle.d.ts.map +1 -1
- package/dist/types/src/dx-grid.d.ts +30 -6
- package/dist/types/src/dx-grid.d.ts.map +1 -1
- package/dist/types/src/dx-grid.lit-stories.d.ts +23 -1
- package/dist/types/src/dx-grid.lit-stories.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +42 -10
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/src/util.d.ts +2 -0
- package/dist/types/src/util.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/dx-grid-axis-resize-handle.ts +6 -2
- package/src/dx-grid.lit-stories.ts +140 -16
- package/src/dx-grid.pcss +37 -62
- package/src/dx-grid.ts +553 -237
- package/src/types.ts +52 -8
- package/src/util.ts +15 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// packages/ui/lit-grid/src/dx-grid.ts
|
|
2
2
|
import { LitElement as LitElement2, html as html2, nothing } from "lit";
|
|
3
|
-
import { customElement as customElement2, state, property as property2
|
|
3
|
+
import { customElement as customElement2, state, property as property2 } from "lit/decorators.js";
|
|
4
4
|
import { ref as ref2, createRef } from "lit/directives/ref.js";
|
|
5
|
+
import { styleMap } from "lit/directives/style-map.js";
|
|
5
6
|
|
|
6
7
|
// packages/ui/lit-grid/src/dx-grid-axis-resize-handle.ts
|
|
7
8
|
import { draggable } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
@@ -14,12 +15,19 @@ import { ref } from "lit/directives/ref.js";
|
|
|
14
15
|
// packages/ui/lit-grid/src/util.ts
|
|
15
16
|
var separator = ",";
|
|
16
17
|
var toCellIndex = (cellCoords) => `${cellCoords.col}${separator}${cellCoords.row}`;
|
|
18
|
+
var colToA1Notation = (col) => {
|
|
19
|
+
return (col >= 26 ? String.fromCharCode("A".charCodeAt(0) + Math.floor(col / 26) - 1) : "") + String.fromCharCode("A".charCodeAt(0) + col % 26);
|
|
20
|
+
};
|
|
21
|
+
var rowToA1Notation = (row) => {
|
|
22
|
+
return `${row + 1}`;
|
|
23
|
+
};
|
|
17
24
|
|
|
18
25
|
// packages/ui/lit-grid/src/types.ts
|
|
19
26
|
var DxAxisResize = class extends Event {
|
|
20
27
|
constructor(props) {
|
|
21
28
|
super("dx-axis-resize");
|
|
22
29
|
this.axis = props.axis;
|
|
30
|
+
this.plane = props.plane;
|
|
23
31
|
this.index = props.index;
|
|
24
32
|
this.size = props.size;
|
|
25
33
|
}
|
|
@@ -31,6 +39,7 @@ var DxAxisResizeInternal = class extends Event {
|
|
|
31
39
|
bubbles: true
|
|
32
40
|
});
|
|
33
41
|
this.axis = props.axis;
|
|
42
|
+
this.plane = props.plane;
|
|
34
43
|
this.index = props.index;
|
|
35
44
|
this.size = props.size;
|
|
36
45
|
this.delta = props.delta;
|
|
@@ -68,13 +77,14 @@ var DxGridAxisResizeHandle = class extends LitElement {
|
|
|
68
77
|
constructor() {
|
|
69
78
|
super(...arguments);
|
|
70
79
|
this.axis = "row";
|
|
80
|
+
this.plane = "grid";
|
|
71
81
|
this.index = "-1";
|
|
72
82
|
this.size = 128;
|
|
73
83
|
this.dragStartSize = 128;
|
|
74
84
|
this.cleanup = null;
|
|
75
85
|
}
|
|
76
86
|
render() {
|
|
77
|
-
return html`<button class="dx-grid__resize-handle" ${ref(this.mount)}>
|
|
87
|
+
return html`<button class="dx-grid__resize-handle" data-dx-grid-axis=${this.axis} ${ref(this.mount)}>
|
|
78
88
|
<span class="sr-only">Resize</span>
|
|
79
89
|
</button>`;
|
|
80
90
|
}
|
|
@@ -82,6 +92,7 @@ var DxGridAxisResizeHandle = class extends LitElement {
|
|
|
82
92
|
const client = this.axis === "row" ? "clientY" : "clientX";
|
|
83
93
|
const event = new DxAxisResizeInternal({
|
|
84
94
|
axis: this.axis,
|
|
95
|
+
plane: this.plane,
|
|
85
96
|
size: this.dragStartSize,
|
|
86
97
|
index: this.index,
|
|
87
98
|
delta: location.current.input[client] - location.initial.input[client],
|
|
@@ -126,6 +137,11 @@ _ts_decorate([
|
|
|
126
137
|
type: String
|
|
127
138
|
})
|
|
128
139
|
], DxGridAxisResizeHandle.prototype, "axis", void 0);
|
|
140
|
+
_ts_decorate([
|
|
141
|
+
property({
|
|
142
|
+
type: String
|
|
143
|
+
})
|
|
144
|
+
], DxGridAxisResizeHandle.prototype, "plane", void 0);
|
|
129
145
|
_ts_decorate([
|
|
130
146
|
property({
|
|
131
147
|
type: String
|
|
@@ -148,18 +164,39 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
148
164
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
149
165
|
}
|
|
150
166
|
var gap = 1;
|
|
151
|
-
var resizeTolerance =
|
|
167
|
+
var resizeTolerance = 1;
|
|
168
|
+
var selectTolerance = 4;
|
|
152
169
|
var overscanCol = 1;
|
|
153
170
|
var overscanRow = 1;
|
|
154
171
|
var sizeColMin = 32;
|
|
155
172
|
var sizeColMax = 1024;
|
|
156
173
|
var sizeRowMin = 16;
|
|
157
174
|
var sizeRowMax = 1024;
|
|
158
|
-
var
|
|
159
|
-
|
|
175
|
+
var shouldSelect = (pointer, { pageX, pageY }) => {
|
|
176
|
+
if (pointer?.state === "maybeSelecting") {
|
|
177
|
+
return Math.hypot(Math.abs(pointer.pageX - pageX), Math.abs(pointer.pageY - pageY)) >= selectTolerance;
|
|
178
|
+
} else {
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
160
181
|
};
|
|
161
|
-
var
|
|
162
|
-
|
|
182
|
+
var selectionProps = (selectionStart, selectionEnd) => {
|
|
183
|
+
const colMin = Math.min(selectionStart.col, selectionEnd.col);
|
|
184
|
+
const colMax = Math.max(selectionStart.col, selectionEnd.col);
|
|
185
|
+
const rowMin = Math.min(selectionStart.row, selectionEnd.row);
|
|
186
|
+
const rowMax = Math.max(selectionStart.row, selectionEnd.row);
|
|
187
|
+
const plane = selectionStart.plane;
|
|
188
|
+
const visible = colMin !== colMax || rowMin !== rowMax;
|
|
189
|
+
return {
|
|
190
|
+
colMin,
|
|
191
|
+
colMax,
|
|
192
|
+
rowMin,
|
|
193
|
+
rowMax,
|
|
194
|
+
plane,
|
|
195
|
+
visible
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
var cellSelected = (col, row, plane, selection) => {
|
|
199
|
+
return plane === selection.plane && col >= selection.colMin && col <= selection.colMax && row >= selection.rowMin && row <= selection.rowMax;
|
|
163
200
|
};
|
|
164
201
|
var closestAction = (target) => {
|
|
165
202
|
const actionEl = target?.closest("[data-dx-grid-action]") ?? null;
|
|
@@ -179,7 +216,9 @@ var closestCell = (target, actionEl) => {
|
|
|
179
216
|
if (cellElement) {
|
|
180
217
|
const col = parseInt(cellElement.getAttribute("aria-colindex") ?? "never");
|
|
181
218
|
const row = parseInt(cellElement.getAttribute("aria-rowindex") ?? "never");
|
|
219
|
+
const plane = cellElement.closest("[data-dx-grid-plane]")?.getAttribute("data-dx-grid-plane") ?? "grid";
|
|
182
220
|
return {
|
|
221
|
+
plane,
|
|
183
222
|
col,
|
|
184
223
|
row
|
|
185
224
|
};
|
|
@@ -187,30 +226,92 @@ var closestCell = (target, actionEl) => {
|
|
|
187
226
|
return null;
|
|
188
227
|
}
|
|
189
228
|
};
|
|
190
|
-
var
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
229
|
+
var resolveRowPlane = (plane) => {
|
|
230
|
+
switch (plane) {
|
|
231
|
+
case "fixedStartStart":
|
|
232
|
+
case "fixedStartEnd":
|
|
233
|
+
case "frozenRowsStart":
|
|
234
|
+
return "frozenRowsStart";
|
|
235
|
+
case "fixedEndStart":
|
|
236
|
+
case "fixedEndEnd":
|
|
237
|
+
case "frozenRowsEnd":
|
|
238
|
+
return "frozenRowsEnd";
|
|
239
|
+
default:
|
|
240
|
+
return "grid";
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
var resolveColPlane = (plane) => {
|
|
244
|
+
switch (plane) {
|
|
245
|
+
case "fixedStartStart":
|
|
246
|
+
case "fixedEndStart":
|
|
247
|
+
case "frozenColsStart":
|
|
248
|
+
return "frozenColsStart";
|
|
249
|
+
case "fixedStartEnd":
|
|
250
|
+
case "fixedEndEnd":
|
|
251
|
+
case "frozenColsEnd":
|
|
252
|
+
return "frozenColsEnd";
|
|
253
|
+
default:
|
|
254
|
+
return "grid";
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
var resolveResizePlane = (resizeAxis, cellPlane) => {
|
|
258
|
+
switch (cellPlane) {
|
|
259
|
+
case "fixedStartStart":
|
|
260
|
+
return resizeAxis === "col" ? "frozenColsStart" : "frozenRowsStart";
|
|
261
|
+
case "fixedStartEnd":
|
|
262
|
+
return resizeAxis === "col" ? "frozenColsEnd" : "frozenRowsStart";
|
|
263
|
+
case "fixedEndStart":
|
|
264
|
+
return resizeAxis === "col" ? "frozenColsStart" : "frozenRowsEnd";
|
|
265
|
+
case "fixedEndEnd":
|
|
266
|
+
return resizeAxis === "col" ? "frozenColsEnd" : "frozenRowsEnd";
|
|
267
|
+
case "frozenColsStart":
|
|
268
|
+
case "frozenColsEnd":
|
|
269
|
+
return resizeAxis === "col" ? cellPlane : "grid";
|
|
270
|
+
case "frozenRowsStart":
|
|
271
|
+
case "frozenRowsEnd":
|
|
272
|
+
return resizeAxis === "row" ? cellPlane : "grid";
|
|
273
|
+
default:
|
|
274
|
+
return cellPlane;
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
var isSameCell = (a, b) => a && b && a.plane === b.plane && Number.isFinite(a.col) && Number.isFinite(a.row) && a.col === b.col && a.row === b.row;
|
|
278
|
+
var defaultRowSize = 32;
|
|
279
|
+
var defaultColSize = 180;
|
|
194
280
|
var DxGrid = class extends LitElement2 {
|
|
195
281
|
constructor() {
|
|
196
282
|
super();
|
|
197
283
|
this.gridId = "default-grid-id";
|
|
198
284
|
this.rowDefault = {
|
|
199
|
-
|
|
285
|
+
grid: {
|
|
286
|
+
size: defaultRowSize
|
|
287
|
+
}
|
|
200
288
|
};
|
|
201
289
|
this.columnDefault = {
|
|
202
|
-
|
|
290
|
+
grid: {
|
|
291
|
+
size: defaultColSize
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
this.rows = {
|
|
295
|
+
grid: {}
|
|
296
|
+
};
|
|
297
|
+
this.columns = {
|
|
298
|
+
grid: {}
|
|
299
|
+
};
|
|
300
|
+
this.initialCells = {
|
|
301
|
+
grid: {}
|
|
203
302
|
};
|
|
204
|
-
this.rows = {};
|
|
205
|
-
this.columns = {};
|
|
206
|
-
this.initialCells = {};
|
|
207
303
|
this.mode = "browse";
|
|
304
|
+
this.limitColumns = Infinity;
|
|
305
|
+
this.limitRows = Infinity;
|
|
306
|
+
this.frozen = {};
|
|
208
307
|
/**
|
|
209
308
|
* When this function is defined, it is used first to try to get a value for a cell, and otherwise will fall back
|
|
210
309
|
* to `cells`.
|
|
211
310
|
*/
|
|
212
311
|
this.getCells = null;
|
|
213
|
-
this.cells = {
|
|
312
|
+
this.cells = {
|
|
313
|
+
grid: {}
|
|
314
|
+
};
|
|
214
315
|
//
|
|
215
316
|
// `pos`, short for ‘position’, is the position in pixels of the viewport from the origin.
|
|
216
317
|
//
|
|
@@ -230,9 +331,9 @@ var DxGrid = class extends LitElement2 {
|
|
|
230
331
|
// `bin`, not short for anything, is the range in pixels within which virtualization does not need to reassess.
|
|
231
332
|
//
|
|
232
333
|
this.binInlineMin = 0;
|
|
233
|
-
this.binInlineMax =
|
|
334
|
+
this.binInlineMax = defaultColSize;
|
|
234
335
|
this.binBlockMin = 0;
|
|
235
|
-
this.binBlockMax =
|
|
336
|
+
this.binBlockMax = defaultRowSize;
|
|
236
337
|
//
|
|
237
338
|
// `vis`, short for ‘visible’, is the range in numeric index of the columns or rows which should be rendered within
|
|
238
339
|
// the viewport. These start with naïve values that are updated before first contentful render.
|
|
@@ -244,48 +345,57 @@ var DxGrid = class extends LitElement2 {
|
|
|
244
345
|
//
|
|
245
346
|
// `template` is the rendered value of `grid-{axis}-template`.
|
|
246
347
|
//
|
|
247
|
-
this.
|
|
248
|
-
this.
|
|
348
|
+
this.templateGridColumns = "0";
|
|
349
|
+
this.templatefrozenColsStart = "";
|
|
350
|
+
this.templatefrozenColsEnd = "";
|
|
351
|
+
this.templateGridRows = "0";
|
|
352
|
+
this.templatefrozenRowsStart = "";
|
|
353
|
+
this.templatefrozenRowsEnd = "";
|
|
249
354
|
//
|
|
250
355
|
// Focus, selection, and resize states
|
|
251
356
|
//
|
|
252
357
|
this.pointer = null;
|
|
253
|
-
this.colSizes = {
|
|
254
|
-
|
|
358
|
+
this.colSizes = {
|
|
359
|
+
grid: {}
|
|
360
|
+
};
|
|
361
|
+
this.rowSizes = {
|
|
362
|
+
grid: {}
|
|
363
|
+
};
|
|
255
364
|
this.focusActive = false;
|
|
256
365
|
this.focusedCell = {
|
|
366
|
+
plane: "grid",
|
|
257
367
|
col: 0,
|
|
258
368
|
row: 0
|
|
259
369
|
};
|
|
260
370
|
this.selectionStart = {
|
|
371
|
+
plane: "grid",
|
|
261
372
|
col: 0,
|
|
262
373
|
row: 0
|
|
263
374
|
};
|
|
264
375
|
this.selectionEnd = {
|
|
376
|
+
plane: "grid",
|
|
265
377
|
col: 0,
|
|
266
378
|
row: 0
|
|
267
379
|
};
|
|
380
|
+
//
|
|
381
|
+
// Limits
|
|
382
|
+
//
|
|
383
|
+
this.intrinsicInlineSize = Infinity;
|
|
384
|
+
this.intrinsicBlockSize = Infinity;
|
|
268
385
|
this.handlePointerDown = (event) => {
|
|
269
386
|
if (event.isPrimary) {
|
|
270
387
|
const { action, actionEl } = closestAction(event.target);
|
|
271
388
|
if (action) {
|
|
272
|
-
if (action
|
|
273
|
-
const [resize, index] = action.split(",");
|
|
274
|
-
const [_, axis] = resize.split("-");
|
|
275
|
-
this.pointer = {
|
|
276
|
-
state: "resizing",
|
|
277
|
-
axis,
|
|
278
|
-
size: axis === "col" ? this.colSize(index) : this.rowSize(index),
|
|
279
|
-
page: getPage(axis, event),
|
|
280
|
-
index
|
|
281
|
-
};
|
|
282
|
-
} else if (action === "cell") {
|
|
389
|
+
if (action === "cell") {
|
|
283
390
|
const cellCoords = closestCell(event.target, actionEl);
|
|
284
391
|
if (cellCoords) {
|
|
285
392
|
this.pointer = {
|
|
286
|
-
state: "
|
|
393
|
+
state: "maybeSelecting",
|
|
394
|
+
pageX: event.pageX,
|
|
395
|
+
pageY: event.pageY
|
|
287
396
|
};
|
|
288
397
|
this.selectionStart = cellCoords;
|
|
398
|
+
this.selectionEnd = cellCoords;
|
|
289
399
|
}
|
|
290
400
|
if (this.mode === "edit") {
|
|
291
401
|
event.preventDefault();
|
|
@@ -299,23 +409,24 @@ var DxGrid = class extends LitElement2 {
|
|
|
299
409
|
}
|
|
300
410
|
};
|
|
301
411
|
this.handlePointerUp = (event) => {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
this.
|
|
307
|
-
this.
|
|
308
|
-
|
|
309
|
-
end: this.selectionEnd
|
|
310
|
-
}));
|
|
311
|
-
}
|
|
412
|
+
const cell = closestCell(event.target);
|
|
413
|
+
if (cell) {
|
|
414
|
+
this.selectionEnd = cell;
|
|
415
|
+
this.dispatchEvent(new DxGridCellsSelect({
|
|
416
|
+
start: this.selectionStart,
|
|
417
|
+
end: this.selectionEnd
|
|
418
|
+
}));
|
|
312
419
|
}
|
|
313
420
|
this.pointer = null;
|
|
314
421
|
};
|
|
315
422
|
this.handlePointerMove = (event) => {
|
|
316
|
-
if (this.pointer
|
|
423
|
+
if (shouldSelect(this.pointer, event)) {
|
|
424
|
+
this.pointer = {
|
|
425
|
+
state: "selecting"
|
|
426
|
+
};
|
|
427
|
+
} else if (this.pointer?.state === "selecting") {
|
|
317
428
|
const cell = closestCell(event.target);
|
|
318
|
-
if (cell && (cell.col !== this.selectionEnd.col || cell.row !== this.selectionEnd.row)) {
|
|
429
|
+
if (cell && cell.plane === this.selectionStart.plane && (cell.col !== this.selectionEnd.col || cell.row !== this.selectionEnd.row)) {
|
|
319
430
|
this.selectionEnd = cell;
|
|
320
431
|
}
|
|
321
432
|
}
|
|
@@ -332,6 +443,7 @@ var DxGrid = class extends LitElement2 {
|
|
|
332
443
|
this.sizeInline = inlineSize;
|
|
333
444
|
this.sizeBlock = blockSize;
|
|
334
445
|
this.updateVis();
|
|
446
|
+
queueMicrotask(() => this.updatePos());
|
|
335
447
|
}
|
|
336
448
|
});
|
|
337
449
|
this.viewportRef = createRef();
|
|
@@ -343,13 +455,13 @@ var DxGrid = class extends LitElement2 {
|
|
|
343
455
|
};
|
|
344
456
|
this.handleWheel = ({ deltaX, deltaY }) => {
|
|
345
457
|
if (this.mode === "browse") {
|
|
346
|
-
this.posInline
|
|
347
|
-
this.posBlock = Math.max(0, this.posBlock + deltaY);
|
|
348
|
-
this.maybeUpdateVis();
|
|
458
|
+
this.updatePos(this.posInline + deltaX, this.posBlock + deltaY);
|
|
349
459
|
}
|
|
350
460
|
};
|
|
351
461
|
this.addEventListener("dx-axis-resize-internal", this.handleAxisResizeInternal);
|
|
352
|
-
this.addEventListener("wheel", this.handleWheel
|
|
462
|
+
this.addEventListener("wheel", this.handleWheel, {
|
|
463
|
+
passive: true
|
|
464
|
+
});
|
|
353
465
|
this.addEventListener("pointerdown", this.handlePointerDown);
|
|
354
466
|
this.addEventListener("pointermove", this.handlePointerMove);
|
|
355
467
|
this.addEventListener("pointerup", this.handlePointerUp);
|
|
@@ -379,7 +491,7 @@ var DxGrid = class extends LitElement2 {
|
|
|
379
491
|
case "ArrowDown":
|
|
380
492
|
this.focusedCell = {
|
|
381
493
|
...this.focusedCell,
|
|
382
|
-
row: this.focusedCell.row + 1
|
|
494
|
+
row: Math.min(this.limitRows - 1, this.focusedCell.row + 1)
|
|
383
495
|
};
|
|
384
496
|
break;
|
|
385
497
|
case "ArrowUp":
|
|
@@ -391,7 +503,7 @@ var DxGrid = class extends LitElement2 {
|
|
|
391
503
|
case "ArrowRight":
|
|
392
504
|
this.focusedCell = {
|
|
393
505
|
...this.focusedCell,
|
|
394
|
-
col: this.focusedCell.col + 1
|
|
506
|
+
col: Math.min(this.limitColumns - 1, this.focusedCell.col + 1)
|
|
395
507
|
};
|
|
396
508
|
break;
|
|
397
509
|
case "ArrowLeft":
|
|
@@ -425,21 +537,26 @@ var DxGrid = class extends LitElement2 {
|
|
|
425
537
|
//
|
|
426
538
|
// Accessors
|
|
427
539
|
//
|
|
428
|
-
colSize(c) {
|
|
429
|
-
|
|
540
|
+
colSize(c, plane) {
|
|
541
|
+
const resolvedPlane = resolveColPlane(plane);
|
|
542
|
+
return this.colSizes?.[resolvedPlane]?.[c] ?? this.columnDefault[resolvedPlane]?.size ?? defaultColSize;
|
|
430
543
|
}
|
|
431
|
-
rowSize(r) {
|
|
432
|
-
|
|
544
|
+
rowSize(r, plane) {
|
|
545
|
+
const resolvedPlane = resolveRowPlane(plane);
|
|
546
|
+
return this.rowSizes?.[resolvedPlane]?.[r] ?? this.rowDefault[resolvedPlane]?.size ?? defaultRowSize;
|
|
433
547
|
}
|
|
434
|
-
cell(c, r) {
|
|
548
|
+
cell(c, r, plane) {
|
|
435
549
|
const index = `${c}${separator}${r}`;
|
|
436
|
-
return this.cells[index] ?? this.initialCells[index];
|
|
550
|
+
return this.cells?.[plane]?.[index] ?? this.initialCells?.[plane]?.[index];
|
|
551
|
+
}
|
|
552
|
+
cellActive(c, r, plane) {
|
|
553
|
+
return this.focusActive && this.focusedCell.plane === plane && this.focusedCell.col === c && this.focusedCell.row === r;
|
|
437
554
|
}
|
|
438
555
|
focusedCellBox() {
|
|
439
556
|
const cellElement = this.focusedCellElement();
|
|
440
557
|
const cellSize = {
|
|
441
|
-
inlineSize: this.colSize(this.focusedCell.col),
|
|
442
|
-
blockSize: this.rowSize(this.focusedCell.row)
|
|
558
|
+
inlineSize: this.colSize(this.focusedCell.col, this.focusedCell.plane),
|
|
559
|
+
blockSize: this.rowSize(this.focusedCell.row, this.focusedCell.plane)
|
|
443
560
|
};
|
|
444
561
|
if (!cellElement) {
|
|
445
562
|
return {
|
|
@@ -459,60 +576,160 @@ var DxGrid = class extends LitElement2 {
|
|
|
459
576
|
...cellSize
|
|
460
577
|
};
|
|
461
578
|
}
|
|
579
|
+
updatePos(inline, block) {
|
|
580
|
+
this.posInline = Math.max(0, Math.min(this.intrinsicInlineSize - this.sizeInline, inline ?? this.posInline));
|
|
581
|
+
this.posBlock = Math.max(0, Math.min(this.intrinsicBlockSize - this.sizeBlock, block ?? this.posBlock));
|
|
582
|
+
this.maybeUpdateVis();
|
|
583
|
+
}
|
|
462
584
|
updateVisInline() {
|
|
463
585
|
let colIndex = 0;
|
|
464
|
-
let pxInline = this.colSize(colIndex);
|
|
586
|
+
let pxInline = this.colSize(colIndex, "grid");
|
|
465
587
|
while (pxInline < this.posInline) {
|
|
466
588
|
colIndex += 1;
|
|
467
|
-
pxInline += this.colSize(colIndex) + gap;
|
|
589
|
+
pxInline += this.colSize(colIndex, "grid") + gap;
|
|
468
590
|
}
|
|
469
591
|
this.visColMin = colIndex - overscanCol;
|
|
470
|
-
this.binInlineMin = pxInline - this.colSize(colIndex) - gap;
|
|
592
|
+
this.binInlineMin = pxInline - this.colSize(colIndex, "grid") - gap;
|
|
471
593
|
this.binInlineMax = pxInline + gap;
|
|
472
594
|
this.overscanInline = [
|
|
473
595
|
...Array(overscanCol)
|
|
474
596
|
].reduce((acc, _, c0) => {
|
|
475
|
-
acc += this.colSize(this.visColMin + c0);
|
|
597
|
+
acc += this.colSize(this.visColMin + c0, "grid");
|
|
476
598
|
return acc;
|
|
477
599
|
}, 0) + gap * (overscanCol - 1);
|
|
478
600
|
while (pxInline < this.binInlineMax + this.sizeInline + gap) {
|
|
479
601
|
colIndex += 1;
|
|
480
|
-
pxInline += this.colSize(colIndex) + gap;
|
|
602
|
+
pxInline += this.colSize(colIndex, "grid") + gap;
|
|
481
603
|
}
|
|
482
|
-
this.visColMax = colIndex + overscanCol;
|
|
483
|
-
this.
|
|
604
|
+
this.visColMax = Math.min(this.limitColumns, colIndex + overscanCol);
|
|
605
|
+
this.templateGridColumns = [
|
|
484
606
|
...Array(this.visColMax - this.visColMin)
|
|
485
|
-
].map((_, c0) => `${this.colSize(this.visColMin + c0)}px`).join(" ");
|
|
607
|
+
].map((_, c0) => `${this.colSize(this.visColMin + c0, "grid")}px`).join(" ");
|
|
608
|
+
this.templatefrozenColsStart = [
|
|
609
|
+
...Array(this.frozen.frozenColsStart ?? 0)
|
|
610
|
+
].map((_, c0) => `${this.colSize(c0, "frozenColsStart")}px`).join(" ");
|
|
611
|
+
this.templatefrozenColsEnd = [
|
|
612
|
+
...Array(this.frozen.frozenColsEnd ?? 0)
|
|
613
|
+
].map((_, c0) => `${this.colSize(c0, "frozenColsEnd")}px`).join(" ");
|
|
486
614
|
}
|
|
487
615
|
updateVisBlock() {
|
|
488
616
|
let rowIndex = 0;
|
|
489
|
-
let pxBlock = this.rowSize(rowIndex);
|
|
617
|
+
let pxBlock = this.rowSize(rowIndex, "grid");
|
|
490
618
|
while (pxBlock < this.posBlock) {
|
|
491
619
|
rowIndex += 1;
|
|
492
|
-
pxBlock += this.rowSize(rowIndex) + gap;
|
|
620
|
+
pxBlock += this.rowSize(rowIndex, "grid") + gap;
|
|
493
621
|
}
|
|
494
622
|
this.visRowMin = rowIndex - overscanRow;
|
|
495
|
-
this.binBlockMin = pxBlock - this.rowSize(rowIndex) - gap;
|
|
623
|
+
this.binBlockMin = pxBlock - this.rowSize(rowIndex, "grid") - gap;
|
|
496
624
|
this.binBlockMax = pxBlock + gap;
|
|
497
625
|
this.overscanBlock = [
|
|
498
626
|
...Array(overscanRow)
|
|
499
627
|
].reduce((acc, _, r0) => {
|
|
500
|
-
acc += this.rowSize(this.visRowMin + r0);
|
|
628
|
+
acc += this.rowSize(this.visRowMin + r0, "grid");
|
|
501
629
|
return acc;
|
|
502
630
|
}, 0) + gap * (overscanRow - 1);
|
|
503
631
|
while (pxBlock < this.binBlockMax + this.sizeBlock) {
|
|
504
632
|
rowIndex += 1;
|
|
505
|
-
pxBlock += this.rowSize(rowIndex) + gap;
|
|
633
|
+
pxBlock += this.rowSize(rowIndex, "grid") + gap;
|
|
506
634
|
}
|
|
507
|
-
this.visRowMax = rowIndex + overscanRow;
|
|
508
|
-
this.
|
|
635
|
+
this.visRowMax = Math.min(this.limitRows, rowIndex + overscanRow);
|
|
636
|
+
this.templateGridRows = [
|
|
509
637
|
...Array(this.visRowMax - this.visRowMin)
|
|
510
|
-
].map((_, r0) => `${this.rowSize(this.visRowMin + r0)}px`).join(" ");
|
|
638
|
+
].map((_, r0) => `${this.rowSize(this.visRowMin + r0, "grid")}px`).join(" ");
|
|
639
|
+
this.templatefrozenRowsStart = [
|
|
640
|
+
...Array(this.frozen.frozenRowsStart ?? 0)
|
|
641
|
+
].map((_, r0) => `${this.rowSize(r0, "frozenRowsStart")}px`).join(" ");
|
|
642
|
+
this.templatefrozenRowsEnd = [
|
|
643
|
+
...Array(this.frozen.frozenRowsEnd ?? 0)
|
|
644
|
+
].map((_, r0) => `${this.rowSize(r0, "frozenRowsEnd")}px`).join(" ");
|
|
511
645
|
}
|
|
512
646
|
updateVis() {
|
|
513
647
|
this.updateVisInline();
|
|
514
648
|
this.updateVisBlock();
|
|
515
649
|
}
|
|
650
|
+
updateCells(includeFixed) {
|
|
651
|
+
this.cells.grid = this.getCells({
|
|
652
|
+
start: {
|
|
653
|
+
col: this.visColMin,
|
|
654
|
+
row: this.visRowMin
|
|
655
|
+
},
|
|
656
|
+
end: {
|
|
657
|
+
col: this.visColMax,
|
|
658
|
+
row: this.visRowMax
|
|
659
|
+
}
|
|
660
|
+
}, "grid");
|
|
661
|
+
Object.entries(this.frozen).filter(([_, limit]) => limit && limit > 0).forEach(([plane, limit]) => {
|
|
662
|
+
this.cells[plane] = this.getCells(plane.startsWith("frozenRows") ? {
|
|
663
|
+
start: {
|
|
664
|
+
col: this.visColMin,
|
|
665
|
+
row: 0
|
|
666
|
+
},
|
|
667
|
+
end: {
|
|
668
|
+
col: this.visColMax,
|
|
669
|
+
row: limit
|
|
670
|
+
}
|
|
671
|
+
} : {
|
|
672
|
+
start: {
|
|
673
|
+
col: 0,
|
|
674
|
+
row: this.visRowMin
|
|
675
|
+
},
|
|
676
|
+
end: {
|
|
677
|
+
col: limit,
|
|
678
|
+
row: this.visRowMax
|
|
679
|
+
}
|
|
680
|
+
}, plane);
|
|
681
|
+
});
|
|
682
|
+
if (includeFixed) {
|
|
683
|
+
if ((this.frozen.frozenColsStart ?? 0) > 0 && (this.frozen.frozenRowsStart ?? 0) > 0) {
|
|
684
|
+
this.cells.fixedStartStart = this.getCells({
|
|
685
|
+
start: {
|
|
686
|
+
col: 0,
|
|
687
|
+
row: 0
|
|
688
|
+
},
|
|
689
|
+
end: {
|
|
690
|
+
col: this.frozen.frozenColsStart,
|
|
691
|
+
row: this.frozen.frozenRowsStart
|
|
692
|
+
}
|
|
693
|
+
}, "fixedStartStart");
|
|
694
|
+
}
|
|
695
|
+
if ((this.frozen.frozenColsEnd ?? 0) > 0 && (this.frozen.frozenRowsStart ?? 0) > 0) {
|
|
696
|
+
this.cells.fixedStartEnd = this.getCells({
|
|
697
|
+
start: {
|
|
698
|
+
col: 0,
|
|
699
|
+
row: 0
|
|
700
|
+
},
|
|
701
|
+
end: {
|
|
702
|
+
col: this.frozen.frozenColsEnd,
|
|
703
|
+
row: this.frozen.frozenRowsStart
|
|
704
|
+
}
|
|
705
|
+
}, "fixedStartEnd");
|
|
706
|
+
}
|
|
707
|
+
if ((this.frozen.frozenColsStart ?? 0) > 0 && (this.frozen.frozenRowsEnd ?? 0) > 0) {
|
|
708
|
+
this.cells.fixedEndStart = this.getCells({
|
|
709
|
+
start: {
|
|
710
|
+
col: 0,
|
|
711
|
+
row: 0
|
|
712
|
+
},
|
|
713
|
+
end: {
|
|
714
|
+
col: this.frozen.frozenColsStart,
|
|
715
|
+
row: this.frozen.frozenRowsEnd
|
|
716
|
+
}
|
|
717
|
+
}, "fixedEndStart");
|
|
718
|
+
}
|
|
719
|
+
if ((this.frozen.frozenColsEnd ?? 0) > 0 && (this.frozen.frozenRowsEnd ?? 0) > 0) {
|
|
720
|
+
this.cells.fixedEndEnd = this.getCells({
|
|
721
|
+
start: {
|
|
722
|
+
col: 0,
|
|
723
|
+
row: 0
|
|
724
|
+
},
|
|
725
|
+
end: {
|
|
726
|
+
col: this.frozen.frozenColsEnd,
|
|
727
|
+
row: this.frozen.frozenRowsEnd
|
|
728
|
+
}
|
|
729
|
+
}, "fixedEndEnd");
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
}
|
|
516
733
|
// Focus handlers
|
|
517
734
|
handleFocus(event) {
|
|
518
735
|
const cellCoords = closestCell(event.target);
|
|
@@ -527,7 +744,27 @@ var DxGrid = class extends LitElement2 {
|
|
|
527
744
|
}
|
|
528
745
|
}
|
|
529
746
|
focusedCellElement() {
|
|
530
|
-
return this.viewportRef.value?.querySelector(`[aria-colindex="${this.focusedCell.col}"][aria-rowindex="${this.focusedCell.row}"]`);
|
|
747
|
+
return this.viewportRef.value?.querySelector(`[data-dx-grid-plane=${this.focusedCell.plane}] > [aria-colindex="${this.focusedCell.col}"][aria-rowindex="${this.focusedCell.row}"]`);
|
|
748
|
+
}
|
|
749
|
+
focusedCellRowOutOfVis(minDelta = 0, maxDelta = minDelta) {
|
|
750
|
+
return this.focusedCell.row < this.visRowMin + minDelta || this.focusedCell.row > this.visRowMax - maxDelta;
|
|
751
|
+
}
|
|
752
|
+
focusedCellColOutOfVis(minDelta = 0, maxDelta = minDelta) {
|
|
753
|
+
return this.focusedCell.col < this.visColMin + minDelta || this.focusedCell.col > this.visColMax - maxDelta;
|
|
754
|
+
}
|
|
755
|
+
focusedCellOutOfVis(colDelta = 0, rowDelta = colDelta) {
|
|
756
|
+
switch (this.focusedCell.plane) {
|
|
757
|
+
case "grid":
|
|
758
|
+
return this.focusedCellRowOutOfVis(rowDelta) || this.focusedCellColOutOfVis(colDelta);
|
|
759
|
+
case "frozenRowsStart":
|
|
760
|
+
case "frozenRowsEnd":
|
|
761
|
+
return this.focusedCellColOutOfVis(colDelta);
|
|
762
|
+
case "frozenColsStart":
|
|
763
|
+
case "frozenColsEnd":
|
|
764
|
+
return this.focusedCellRowOutOfVis(rowDelta);
|
|
765
|
+
default:
|
|
766
|
+
return false;
|
|
767
|
+
}
|
|
531
768
|
}
|
|
532
769
|
/**
|
|
533
770
|
* Moves focus to the cell with actual focus, otherwise moves focus to the viewport.
|
|
@@ -546,20 +783,18 @@ var DxGrid = class extends LitElement2 {
|
|
|
546
783
|
col: this.focusedCell.col + delta
|
|
547
784
|
};
|
|
548
785
|
}
|
|
549
|
-
(this.focusedCell.row < this.visRowMin || this.focusedCell.row > this.visRowMax || this.focusedCell.col < this.visColMin || this.focusedCell.col > this.visColMax ? this.viewportRef.value : this.focusedCellElement())?.focus({
|
|
550
|
-
preventScroll: true
|
|
551
|
-
});
|
|
552
786
|
if (increment) {
|
|
553
787
|
this.snapPosToFocusedCell();
|
|
554
788
|
}
|
|
789
|
+
queueMicrotask(() => (this.focusedCellOutOfVis() ? this.viewportRef.value : this.focusedCellElement())?.focus({
|
|
790
|
+
preventScroll: true
|
|
791
|
+
}));
|
|
555
792
|
}
|
|
556
793
|
/**
|
|
557
794
|
* Updates `pos` so that a cell in focus is fully within the viewport
|
|
558
795
|
*/
|
|
559
796
|
snapPosToFocusedCell() {
|
|
560
|
-
if (this.
|
|
561
|
-
} else if (this.focusedCell.col > this.visColMin + overscanCol && this.focusedCell.col < this.visColMax - overscanCol - 1 && this.focusedCell.row > this.visRowMin + overscanRow && this.focusedCell.row < this.visRowMax - overscanRow - 1) {
|
|
562
|
-
} else {
|
|
797
|
+
if (this.focusedCellOutOfVis(overscanCol + 1, overscanRow + 1)) {
|
|
563
798
|
if (this.focusedCell.col <= this.visColMin + overscanCol) {
|
|
564
799
|
this.posInline = this.binInlineMin;
|
|
565
800
|
this.updateVisInline();
|
|
@@ -567,10 +802,10 @@ var DxGrid = class extends LitElement2 {
|
|
|
567
802
|
const sizeSumCol = [
|
|
568
803
|
...Array(this.focusedCell.col - this.visColMin)
|
|
569
804
|
].reduce((acc, _, c0) => {
|
|
570
|
-
acc += this.colSize(this.visColMin + overscanCol + c0) + gap;
|
|
805
|
+
acc += this.colSize(this.visColMin + overscanCol + c0, "grid") + gap;
|
|
571
806
|
return acc;
|
|
572
807
|
}, 0);
|
|
573
|
-
this.posInline = Math.max(0, this.binInlineMin + sizeSumCol
|
|
808
|
+
this.posInline = Math.max(0, Math.min(this.intrinsicInlineSize - this.sizeInline, this.binInlineMin + sizeSumCol - this.sizeInline));
|
|
574
809
|
this.updateVisInline();
|
|
575
810
|
}
|
|
576
811
|
if (this.focusedCell.row <= this.visRowMin + overscanRow) {
|
|
@@ -580,10 +815,10 @@ var DxGrid = class extends LitElement2 {
|
|
|
580
815
|
const sizeSumRow = [
|
|
581
816
|
...Array(this.focusedCell.row - this.visRowMin)
|
|
582
817
|
].reduce((acc, _, r0) => {
|
|
583
|
-
acc += this.rowSize(this.visRowMin + overscanRow + r0) + gap;
|
|
818
|
+
acc += this.rowSize(this.visRowMin + overscanRow + r0, "grid") + gap;
|
|
584
819
|
return acc;
|
|
585
820
|
}, 0);
|
|
586
|
-
this.posBlock = Math.max(0, this.binBlockMin + sizeSumRow
|
|
821
|
+
this.posBlock = Math.max(0, Math.min(this.intrinsicBlockSize - this.sizeBlock, this.binBlockMin + sizeSumRow - this.sizeBlock));
|
|
587
822
|
this.updateVisBlock();
|
|
588
823
|
}
|
|
589
824
|
}
|
|
@@ -608,106 +843,166 @@ var DxGrid = class extends LitElement2 {
|
|
|
608
843
|
//
|
|
609
844
|
// Resize handlers
|
|
610
845
|
//
|
|
846
|
+
axisResizeable(plane, axis, index) {
|
|
847
|
+
return axis === "col" ? !!(this.columns[plane]?.[index]?.resizeable ?? this.columnDefault[plane]?.resizeable) : !!(this.rows[plane]?.[index]?.resizeable ?? this.rowDefault[plane]?.resizeable);
|
|
848
|
+
}
|
|
611
849
|
handleAxisResizeInternal(event) {
|
|
612
850
|
event.stopPropagation();
|
|
613
|
-
const { axis, delta, size, index, type } = event;
|
|
851
|
+
const { plane, axis, delta, size, index, type } = event;
|
|
614
852
|
if (axis === "col") {
|
|
615
853
|
const nextSize = Math.max(sizeColMin, Math.min(sizeColMax, size + delta));
|
|
616
854
|
this.colSizes = {
|
|
617
855
|
...this.colSizes,
|
|
618
|
-
[
|
|
856
|
+
[plane]: {
|
|
857
|
+
...this.colSizes[plane],
|
|
858
|
+
[index]: nextSize
|
|
859
|
+
}
|
|
619
860
|
};
|
|
620
861
|
this.updateVisInline();
|
|
862
|
+
this.updateIntrinsicInlineSize();
|
|
621
863
|
} else {
|
|
622
864
|
const nextSize = Math.max(sizeRowMin, Math.min(sizeRowMax, size + delta));
|
|
623
865
|
this.rowSizes = {
|
|
624
|
-
...this.
|
|
625
|
-
[
|
|
866
|
+
...this.colSizes,
|
|
867
|
+
[plane]: {
|
|
868
|
+
...this.rowSizes[plane],
|
|
869
|
+
[index]: nextSize
|
|
870
|
+
}
|
|
626
871
|
};
|
|
627
872
|
this.updateVisBlock();
|
|
873
|
+
this.updateIntrinsicBlockSize();
|
|
628
874
|
}
|
|
629
875
|
if (type === "dropped") {
|
|
630
876
|
this.dispatchEvent(new DxAxisResize({
|
|
877
|
+
plane,
|
|
631
878
|
axis,
|
|
632
879
|
index,
|
|
633
|
-
size: this[axis
|
|
880
|
+
size: this[`${axis}Size`](index, plane)
|
|
634
881
|
}));
|
|
635
882
|
}
|
|
636
883
|
}
|
|
637
884
|
//
|
|
638
885
|
// Render and other lifecycle methods
|
|
639
886
|
//
|
|
887
|
+
renderFixed(plane, selection) {
|
|
888
|
+
const colPlane = resolveColPlane(plane);
|
|
889
|
+
const rowPlane = resolveRowPlane(plane);
|
|
890
|
+
const cols = this.frozen[colPlane];
|
|
891
|
+
const rows = this.frozen[rowPlane];
|
|
892
|
+
return (cols ?? 0) > 0 && (rows ?? 0) > 0 ? html2`<div
|
|
893
|
+
role="none"
|
|
894
|
+
data-dx-grid-plane=${plane}
|
|
895
|
+
class="dx-grid__plane--fixed"
|
|
896
|
+
style=${styleMap({
|
|
897
|
+
"grid-template-columns": this[`template${colPlane}`],
|
|
898
|
+
"grid-template-rows": this[`template${rowPlane}`]
|
|
899
|
+
})}
|
|
900
|
+
>
|
|
901
|
+
${[
|
|
902
|
+
...Array(cols)
|
|
903
|
+
].map((_, c) => {
|
|
904
|
+
return [
|
|
905
|
+
...Array(rows)
|
|
906
|
+
].map((_2, r) => {
|
|
907
|
+
return this.renderCell(c, r, plane, cellSelected(c, r, plane, selection));
|
|
908
|
+
});
|
|
909
|
+
})}
|
|
910
|
+
</div>` : null;
|
|
911
|
+
}
|
|
912
|
+
renderFrozenRows(plane, visibleCols, offsetInline, selection) {
|
|
913
|
+
const rowPlane = resolveRowPlane(plane);
|
|
914
|
+
const rows = this.frozen[rowPlane];
|
|
915
|
+
return (rows ?? 0) > 0 ? html2`<div role="none" class="dx-grid__plane--frozen-row">
|
|
916
|
+
<div
|
|
917
|
+
role="none"
|
|
918
|
+
data-dx-grid-plane=${plane}
|
|
919
|
+
class="dx-grid__plane--frozen-row__content"
|
|
920
|
+
style="transform:translate3d(${offsetInline}px,0,0);grid-template-columns:${this.templateGridColumns};grid-template-rows:${this[`template${rowPlane}`]}"
|
|
921
|
+
>
|
|
922
|
+
${[
|
|
923
|
+
...Array(visibleCols)
|
|
924
|
+
].map((_, c0) => {
|
|
925
|
+
return [
|
|
926
|
+
...Array(rows)
|
|
927
|
+
].map((_2, r) => {
|
|
928
|
+
const c = this.visColMin + c0;
|
|
929
|
+
return this.renderCell(c, r, plane, cellSelected(c, r, plane, selection), c0, r);
|
|
930
|
+
});
|
|
931
|
+
})}
|
|
932
|
+
</div>
|
|
933
|
+
</div>` : null;
|
|
934
|
+
}
|
|
935
|
+
renderFrozenColumns(plane, visibleRows, offsetBlock, selection) {
|
|
936
|
+
const colPlane = resolveColPlane(plane);
|
|
937
|
+
const cols = this.frozen[colPlane];
|
|
938
|
+
return (cols ?? 0) > 0 ? html2`<div role="none" class="dx-grid__plane--frozen-col">
|
|
939
|
+
<div
|
|
940
|
+
role="none"
|
|
941
|
+
data-dx-grid-plane=${plane}
|
|
942
|
+
class="dx-grid__plane--frozen-col__content"
|
|
943
|
+
style="transform:translate3d(0,${offsetBlock}px,0);grid-template-rows:${this.templateGridRows};grid-template-columns:${this[`template${colPlane}`]}"
|
|
944
|
+
>
|
|
945
|
+
${[
|
|
946
|
+
...Array(cols)
|
|
947
|
+
].map((_, c) => {
|
|
948
|
+
return [
|
|
949
|
+
...Array(visibleRows)
|
|
950
|
+
].map((_2, r0) => {
|
|
951
|
+
const r = this.visRowMin + r0;
|
|
952
|
+
return this.renderCell(c, r, plane, cellSelected(c, r, plane, selection), c, r0);
|
|
953
|
+
});
|
|
954
|
+
})}
|
|
955
|
+
</div>
|
|
956
|
+
</div>` : null;
|
|
957
|
+
}
|
|
958
|
+
renderCell(col, row, plane, selected, visCol = col, visRow = row) {
|
|
959
|
+
const cell = this.cell(col, row, plane);
|
|
960
|
+
const active = this.cellActive(col, row, plane);
|
|
961
|
+
const resizeIndex = cell?.resizeHandle ? cell.resizeHandle === "col" ? col : row : void 0;
|
|
962
|
+
const resizePlane = cell?.resizeHandle ? resolveResizePlane(cell.resizeHandle, plane) : void 0;
|
|
963
|
+
return html2`<div
|
|
964
|
+
role="gridcell"
|
|
965
|
+
tabindex="0"
|
|
966
|
+
?inert=${col < 0 || row < 0}
|
|
967
|
+
?aria-selected=${selected}
|
|
968
|
+
class=${cell || active ? (cell?.className ? cell.className + " " : "") + (active ? "dx-grid__cell--active" : "") : nothing}
|
|
969
|
+
aria-colindex=${col}
|
|
970
|
+
aria-rowindex=${row}
|
|
971
|
+
data-dx-grid-action="cell"
|
|
972
|
+
style="grid-column:${visCol + 1};grid-row:${visRow + 1}"
|
|
973
|
+
>
|
|
974
|
+
${cell?.value}${cell?.resizeHandle && this.axisResizeable(resizePlane, cell.resizeHandle, resizeIndex) ? html2`<dx-grid-axis-resize-handle
|
|
975
|
+
axis=${cell.resizeHandle}
|
|
976
|
+
plane=${resizePlane}
|
|
977
|
+
index=${resizeIndex}
|
|
978
|
+
size=${this[`${cell.resizeHandle}Size`](resizeIndex, plane)}
|
|
979
|
+
></dx-grid-axis-resize-handle>` : null}
|
|
980
|
+
</div>`;
|
|
981
|
+
}
|
|
640
982
|
render() {
|
|
641
983
|
const visibleCols = this.visColMax - this.visColMin;
|
|
642
984
|
const visibleRows = this.visRowMax - this.visRowMin;
|
|
643
985
|
const offsetInline = this.binInlineMin - this.posInline - this.overscanInline;
|
|
644
986
|
const offsetBlock = this.binBlockMin - this.posBlock - this.overscanBlock;
|
|
645
|
-
const
|
|
646
|
-
const selectColMax = Math.max(this.selectionStart.col, this.selectionEnd.col);
|
|
647
|
-
const selectRowMin = Math.min(this.selectionStart.row, this.selectionEnd.row);
|
|
648
|
-
const selectRowMax = Math.max(this.selectionStart.row, this.selectionEnd.row);
|
|
649
|
-
const selectVisible = selectColMin !== selectColMax || selectRowMin !== selectRowMax;
|
|
987
|
+
const selection = selectionProps(this.selectionStart, this.selectionEnd);
|
|
650
988
|
return html2`<div
|
|
651
989
|
role="none"
|
|
652
990
|
class="dx-grid"
|
|
991
|
+
style=${styleMap({
|
|
992
|
+
"grid-template-columns": `${this.templatefrozenColsStart ? "min-content " : ""}minmax(0, ${Number.isFinite(this.limitColumns) ? `${this.intrinsicInlineSize}px` : "1fr"})${this.templatefrozenColsEnd ? " min-content" : ""}`,
|
|
993
|
+
"grid-template-rows": `${this.templatefrozenRowsStart ? "min-content " : ""}minmax(0, ${Number.isFinite(this.limitRows) ? `${this.intrinsicBlockSize}px` : "1fr"})${this.templatefrozenRowsEnd ? " min-content" : ""}`
|
|
994
|
+
})}
|
|
653
995
|
data-grid=${this.gridId}
|
|
654
996
|
data-grid-mode=${this.mode}
|
|
655
|
-
?data-grid-select=${
|
|
997
|
+
?data-grid-select=${selection.visible}
|
|
656
998
|
>
|
|
657
|
-
|
|
658
|
-
<div role="
|
|
659
|
-
<div
|
|
660
|
-
role="none"
|
|
661
|
-
class="dx-grid__columnheader__content"
|
|
662
|
-
style="transform:translate3d(${offsetInline}px,0,0);grid-template-columns:${this.templateColumns};"
|
|
663
|
-
>
|
|
664
|
-
${[
|
|
665
|
-
...Array(visibleCols)
|
|
666
|
-
].map((_, c0) => {
|
|
667
|
-
const c = this.visColMin + c0;
|
|
668
|
-
return html2`<div
|
|
669
|
-
role="columnheader"
|
|
670
|
-
?inert=${c < 0}
|
|
671
|
-
style="block-size:${this.rowDefault.size}px;grid-column:${c0 + 1}/${c0 + 2};"
|
|
672
|
-
>
|
|
673
|
-
<span id=${localChId(c0)}>${colToA1Notation(c)}</span>
|
|
674
|
-
${(this.columns[c]?.resizeable ?? this.columnDefault.resizeable) && html2`<dx-grid-axis-resize-handle
|
|
675
|
-
axis="col"
|
|
676
|
-
index=${c}
|
|
677
|
-
size=${this.colSize(c)}
|
|
678
|
-
@dxaxisresizeinternal=${this.handleAxisResizeInternal}
|
|
679
|
-
></dx-grid-axis-resize-handle>`}
|
|
680
|
-
</div>`;
|
|
681
|
-
})}
|
|
682
|
-
</div>
|
|
683
|
-
</div>
|
|
684
|
-
<div role="none" class="dx-grid__corner"></div>
|
|
685
|
-
<div role="none" class="dx-grid__rowheader">
|
|
686
|
-
<div
|
|
687
|
-
role="none"
|
|
688
|
-
class="dx-grid__rowheader__content"
|
|
689
|
-
style="transform:translate3d(0,${offsetBlock}px,0);grid-template-rows:${this.templateRows};"
|
|
690
|
-
>
|
|
691
|
-
${[
|
|
692
|
-
...Array(visibleRows)
|
|
693
|
-
].map((_, r0) => {
|
|
694
|
-
const r = this.visRowMin + r0;
|
|
695
|
-
return html2`<div role="rowheader" ?inert=${r < 0} style="grid-row:${r0 + 1}/${r0 + 2}">
|
|
696
|
-
<span id=${localRhId(r0)}>${rowToA1Notation(r)}</span>
|
|
697
|
-
${(this.rows[r]?.resizeable ?? this.rowDefault.resizeable) && html2`<dx-grid-axis-resize-handle
|
|
698
|
-
axis="row"
|
|
699
|
-
index=${r}
|
|
700
|
-
size=${this.rowSize(r)}
|
|
701
|
-
></dx-grid-axis-resize-handle>`}
|
|
702
|
-
</div>`;
|
|
703
|
-
})}
|
|
704
|
-
</div>
|
|
705
|
-
</div>
|
|
706
|
-
<div role="grid" class="dx-grid__viewport" tabindex="0" @wheel=${this.handleWheel} ${ref2(this.viewportRef)}>
|
|
999
|
+
${this.renderFixed("fixedStartStart", selection)}${this.renderFrozenRows("frozenRowsStart", visibleCols, offsetInline, selection)}${this.renderFixed("fixedStartEnd", selection)}${this.renderFrozenColumns("frozenColsStart", visibleRows, offsetBlock, selection)}
|
|
1000
|
+
<div role="grid" class="dx-grid__plane--grid" tabindex="0" ${ref2(this.viewportRef)}>
|
|
707
1001
|
<div
|
|
708
1002
|
role="none"
|
|
709
|
-
class="dx-grid__content"
|
|
710
|
-
|
|
1003
|
+
class="dx-grid__plane--grid__content"
|
|
1004
|
+
data-dx-grid-plane="grid"
|
|
1005
|
+
style="transform:translate3d(${offsetInline}px,${offsetBlock}px,0);grid-template-columns:${this.templateGridColumns};grid-template-rows:${this.templateGridRows};"
|
|
711
1006
|
>
|
|
712
1007
|
${[
|
|
713
1008
|
...Array(visibleCols)
|
|
@@ -717,75 +1012,60 @@ var DxGrid = class extends LitElement2 {
|
|
|
717
1012
|
].map((_2, r0) => {
|
|
718
1013
|
const c = c0 + this.visColMin;
|
|
719
1014
|
const r = r0 + this.visRowMin;
|
|
720
|
-
|
|
721
|
-
const active = this.focusActive && this.focusedCell.col === c && this.focusedCell.row === r;
|
|
722
|
-
const selected = c >= selectColMin && c <= selectColMax && r >= selectRowMin && r <= selectRowMax;
|
|
723
|
-
return html2`<div
|
|
724
|
-
role="gridcell"
|
|
725
|
-
tabindex="0"
|
|
726
|
-
?inert=${c < 0 || r < 0}
|
|
727
|
-
?aria-selected=${selected}
|
|
728
|
-
class=${cell || active ? (cell?.className ? cell.className + " " : "") + (active ? "dx-grid__cell--active" : "") : nothing}
|
|
729
|
-
aria-rowindex=${r}
|
|
730
|
-
aria-colindex=${c}
|
|
731
|
-
data-dx-grid-action="cell"
|
|
732
|
-
style="grid-column:${c0 + 1};grid-row:${r0 + 1}"
|
|
733
|
-
>
|
|
734
|
-
${cell?.value}
|
|
735
|
-
</div>`;
|
|
1015
|
+
return this.renderCell(c, r, "grid", cellSelected(c, r, "grid", selection), c0, r0);
|
|
736
1016
|
});
|
|
737
1017
|
})}
|
|
738
1018
|
</div>
|
|
739
1019
|
</div>
|
|
740
|
-
|
|
741
|
-
<div role="none" class="dx-grid__scrollbar__thumb"></div>
|
|
742
|
-
</div>
|
|
743
|
-
<div role="none" class="dx-grid__corner"></div>
|
|
744
|
-
<div role="none" class="dx-grid__scrollbar" aria-orientation="horizontal">
|
|
745
|
-
<div role="none" class="dx-grid__scrollbar__thumb"></div>
|
|
746
|
-
</div>
|
|
747
|
-
<div role="none" class="dx-grid__corner"></div>
|
|
1020
|
+
${this.renderFrozenColumns("frozenColsEnd", visibleRows, offsetBlock, selection)}${this.renderFixed("fixedEndStart", selection)}${this.renderFrozenRows("frozenRowsEnd", visibleCols, offsetInline, selection)}${this.renderFixed("fixedEndEnd", selection)}
|
|
748
1021
|
</div>`;
|
|
749
1022
|
}
|
|
1023
|
+
updateIntrinsicInlineSize() {
|
|
1024
|
+
this.intrinsicInlineSize = Number.isFinite(this.limitColumns) ? [
|
|
1025
|
+
...Array(this.limitColumns)
|
|
1026
|
+
].reduce((acc, _, c0) => acc + this.colSize(c0, "grid"), 0) + gap * (this.limitColumns - 1) : Infinity;
|
|
1027
|
+
}
|
|
1028
|
+
updateIntrinsicBlockSize() {
|
|
1029
|
+
this.intrinsicBlockSize = Number.isFinite(this.limitRows) ? [
|
|
1030
|
+
...Array(this.limitRows)
|
|
1031
|
+
].reduce((acc, _, r0) => acc + this.rowSize(r0, "grid"), 0) + gap * (this.limitRows - 1) : Infinity;
|
|
1032
|
+
}
|
|
1033
|
+
updateIntrinsicSizes() {
|
|
1034
|
+
this.updateIntrinsicInlineSize();
|
|
1035
|
+
this.updateIntrinsicBlockSize();
|
|
1036
|
+
}
|
|
750
1037
|
firstUpdated() {
|
|
751
1038
|
if (this.getCells) {
|
|
752
|
-
this.
|
|
753
|
-
start: {
|
|
754
|
-
col: this.visColMin,
|
|
755
|
-
row: this.visRowMin
|
|
756
|
-
},
|
|
757
|
-
end: {
|
|
758
|
-
col: this.visColMax,
|
|
759
|
-
row: this.visRowMax
|
|
760
|
-
}
|
|
761
|
-
});
|
|
1039
|
+
this.updateCells(true);
|
|
762
1040
|
}
|
|
763
1041
|
this.observer.observe(this.viewportRef.value);
|
|
764
|
-
this.colSizes = Object.entries(this.columns).reduce((acc, [
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
1042
|
+
this.colSizes = Object.entries(this.columns).reduce((acc, [plane, planeColMeta]) => {
|
|
1043
|
+
acc[plane] = Object.entries(planeColMeta).reduce((planeAcc, [col, colMeta]) => {
|
|
1044
|
+
if (colMeta?.size) {
|
|
1045
|
+
planeAcc[col] = colMeta.size;
|
|
1046
|
+
}
|
|
1047
|
+
return planeAcc;
|
|
1048
|
+
}, {});
|
|
768
1049
|
return acc;
|
|
769
|
-
}, {
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
1050
|
+
}, {
|
|
1051
|
+
grid: {}
|
|
1052
|
+
});
|
|
1053
|
+
this.rowSizes = Object.entries(this.rows).reduce((acc, [plane, planeRowMeta]) => {
|
|
1054
|
+
acc[plane] = Object.entries(planeRowMeta).reduce((planeAcc, [row, rowMeta]) => {
|
|
1055
|
+
if (rowMeta?.size) {
|
|
1056
|
+
planeAcc[row] = rowMeta.size;
|
|
1057
|
+
}
|
|
1058
|
+
return planeAcc;
|
|
1059
|
+
}, {});
|
|
774
1060
|
return acc;
|
|
775
|
-
}, {
|
|
1061
|
+
}, {
|
|
1062
|
+
grid: {}
|
|
1063
|
+
});
|
|
1064
|
+
this.updateIntrinsicSizes();
|
|
776
1065
|
}
|
|
777
1066
|
willUpdate(changedProperties) {
|
|
778
1067
|
if (this.getCells && (changedProperties.has("initialCells") || changedProperties.has("visColMin") || changedProperties.has("visColMax") || changedProperties.has("visRowMin") || changedProperties.has("visRowMax"))) {
|
|
779
|
-
this.
|
|
780
|
-
start: {
|
|
781
|
-
col: this.visColMin,
|
|
782
|
-
row: this.visRowMin
|
|
783
|
-
},
|
|
784
|
-
end: {
|
|
785
|
-
col: this.visColMax,
|
|
786
|
-
row: this.visRowMax
|
|
787
|
-
}
|
|
788
|
-
});
|
|
1068
|
+
this.updateCells();
|
|
789
1069
|
}
|
|
790
1070
|
}
|
|
791
1071
|
updated(changedProperties) {
|
|
@@ -838,6 +1118,21 @@ _ts_decorate2([
|
|
|
838
1118
|
type: String
|
|
839
1119
|
})
|
|
840
1120
|
], DxGrid.prototype, "mode", void 0);
|
|
1121
|
+
_ts_decorate2([
|
|
1122
|
+
property2({
|
|
1123
|
+
type: Number
|
|
1124
|
+
})
|
|
1125
|
+
], DxGrid.prototype, "limitColumns", void 0);
|
|
1126
|
+
_ts_decorate2([
|
|
1127
|
+
property2({
|
|
1128
|
+
type: Number
|
|
1129
|
+
})
|
|
1130
|
+
], DxGrid.prototype, "limitRows", void 0);
|
|
1131
|
+
_ts_decorate2([
|
|
1132
|
+
property2({
|
|
1133
|
+
type: Object
|
|
1134
|
+
})
|
|
1135
|
+
], DxGrid.prototype, "frozen", void 0);
|
|
841
1136
|
_ts_decorate2([
|
|
842
1137
|
state()
|
|
843
1138
|
], DxGrid.prototype, "cells", void 0);
|
|
@@ -885,10 +1180,22 @@ _ts_decorate2([
|
|
|
885
1180
|
], DxGrid.prototype, "visRowMax", void 0);
|
|
886
1181
|
_ts_decorate2([
|
|
887
1182
|
state()
|
|
888
|
-
], DxGrid.prototype, "
|
|
1183
|
+
], DxGrid.prototype, "templateGridColumns", void 0);
|
|
1184
|
+
_ts_decorate2([
|
|
1185
|
+
state()
|
|
1186
|
+
], DxGrid.prototype, "templatefrozenColsStart", void 0);
|
|
1187
|
+
_ts_decorate2([
|
|
1188
|
+
state()
|
|
1189
|
+
], DxGrid.prototype, "templatefrozenColsEnd", void 0);
|
|
1190
|
+
_ts_decorate2([
|
|
1191
|
+
state()
|
|
1192
|
+
], DxGrid.prototype, "templateGridRows", void 0);
|
|
889
1193
|
_ts_decorate2([
|
|
890
1194
|
state()
|
|
891
|
-
], DxGrid.prototype, "
|
|
1195
|
+
], DxGrid.prototype, "templatefrozenRowsStart", void 0);
|
|
1196
|
+
_ts_decorate2([
|
|
1197
|
+
state()
|
|
1198
|
+
], DxGrid.prototype, "templatefrozenRowsEnd", void 0);
|
|
892
1199
|
_ts_decorate2([
|
|
893
1200
|
state()
|
|
894
1201
|
], DxGrid.prototype, "pointer", void 0);
|
|
@@ -912,17 +1219,13 @@ _ts_decorate2([
|
|
|
912
1219
|
], DxGrid.prototype, "selectionEnd", void 0);
|
|
913
1220
|
_ts_decorate2([
|
|
914
1221
|
state()
|
|
915
|
-
], DxGrid.prototype, "
|
|
1222
|
+
], DxGrid.prototype, "intrinsicInlineSize", void 0);
|
|
916
1223
|
_ts_decorate2([
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
})
|
|
920
|
-
], DxGrid.prototype, "handleFocus", null);
|
|
1224
|
+
state()
|
|
1225
|
+
], DxGrid.prototype, "intrinsicBlockSize", void 0);
|
|
921
1226
|
_ts_decorate2([
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
})
|
|
925
|
-
], DxGrid.prototype, "handleBlur", null);
|
|
1227
|
+
state()
|
|
1228
|
+
], DxGrid.prototype, "observer", void 0);
|
|
926
1229
|
DxGrid = _ts_decorate2([
|
|
927
1230
|
customElement2("dx-grid")
|
|
928
1231
|
], DxGrid);
|
|
@@ -931,6 +1234,8 @@ export {
|
|
|
931
1234
|
DxAxisResizeInternal,
|
|
932
1235
|
DxEditRequest,
|
|
933
1236
|
DxGrid,
|
|
934
|
-
DxGridCellsSelect
|
|
1237
|
+
DxGridCellsSelect,
|
|
1238
|
+
colToA1Notation,
|
|
1239
|
+
rowToA1Notation
|
|
935
1240
|
};
|
|
936
1241
|
//# sourceMappingURL=index.mjs.map
|