@dxos/lit-grid 0.6.12-main.ed7cda7 → 0.6.12-staging.0b4bb48
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 +104 -320
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/dx-grid.d.ts +60 -50
- package/dist/types/src/dx-grid.d.ts.map +1 -1
- package/dist/types/src/dx-grid.lit-stories.d.ts +1 -4
- package/dist/types/src/dx-grid.lit-stories.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +0 -53
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/dx-grid.lit-stories.ts +8 -11
- package/src/dx-grid.pcss +3 -27
- package/src/dx-grid.ts +157 -317
- package/src/types.ts +0 -73
- package/dist/types/src/util.d.ts +0 -7
- package/dist/types/src/util.d.ts.map +0 -1
- package/src/util.ts +0 -12
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
// packages/ui/lit-grid/src/dx-grid.ts
|
|
2
|
-
import { LitElement, html
|
|
2
|
+
import { LitElement, html } from "lit";
|
|
3
3
|
import { customElement, state, property, eventOptions } from "lit/decorators.js";
|
|
4
4
|
import { ref, createRef } from "lit/directives/ref.js";
|
|
5
5
|
|
|
6
|
-
// packages/ui/lit-grid/src/util.ts
|
|
7
|
-
var separator = ",";
|
|
8
|
-
var toCellIndex = (cellCoords) => `${cellCoords.col}${separator}${cellCoords.row}`;
|
|
9
|
-
|
|
10
6
|
// packages/ui/lit-grid/src/types.ts
|
|
11
7
|
var DxAxisResize = class extends Event {
|
|
12
8
|
constructor(props) {
|
|
@@ -16,25 +12,6 @@ var DxAxisResize = class extends Event {
|
|
|
16
12
|
this.size = props.size;
|
|
17
13
|
}
|
|
18
14
|
};
|
|
19
|
-
var DxEditRequest = class extends Event {
|
|
20
|
-
constructor(props) {
|
|
21
|
-
super("dx-edit-request");
|
|
22
|
-
this.cellIndex = props.cellIndex;
|
|
23
|
-
this.cellBox = props.cellBox;
|
|
24
|
-
this.initialContent = props.initialContent;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
var DxGridCellsSelect = class extends Event {
|
|
28
|
-
constructor({ start, end }) {
|
|
29
|
-
super("dx-grid-cells-select");
|
|
30
|
-
this.start = toCellIndex(start);
|
|
31
|
-
this.end = toCellIndex(end);
|
|
32
|
-
this.minCol = Math.min(start.col, end.col);
|
|
33
|
-
this.maxCol = Math.max(start.col, end.col);
|
|
34
|
-
this.minRow = Math.min(start.row, end.row);
|
|
35
|
-
this.maxRow = Math.max(start.row, end.row);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
15
|
|
|
39
16
|
// packages/ui/lit-grid/src/dx-grid.ts
|
|
40
17
|
function _ts_decorate(decorators, target, key, desc) {
|
|
@@ -51,46 +28,19 @@ var sizeColMin = 32;
|
|
|
51
28
|
var sizeColMax = 1024;
|
|
52
29
|
var sizeRowMin = 16;
|
|
53
30
|
var sizeRowMax = 1024;
|
|
31
|
+
var separator = ",";
|
|
54
32
|
var colToA1Notation = (col) => {
|
|
55
33
|
return (col >= 26 ? String.fromCharCode("A".charCodeAt(0) + Math.floor(col / 26) - 1) : "") + String.fromCharCode("A".charCodeAt(0) + col % 26);
|
|
56
34
|
};
|
|
57
35
|
var rowToA1Notation = (row) => {
|
|
58
36
|
return `${row + 1}`;
|
|
59
37
|
};
|
|
60
|
-
var closestAction = (target) => {
|
|
61
|
-
const actionEl = target?.closest("[data-dx-grid-action]") ?? null;
|
|
62
|
-
return {
|
|
63
|
-
actionEl,
|
|
64
|
-
action: actionEl?.getAttribute("data-dx-grid-action") ?? null
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
var closestCell = (target, actionEl) => {
|
|
68
|
-
let cellElement = actionEl;
|
|
69
|
-
if (!cellElement) {
|
|
70
|
-
const { action, actionEl: actionEl2 } = closestAction(target);
|
|
71
|
-
if (action === "cell") {
|
|
72
|
-
cellElement = actionEl2;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (cellElement) {
|
|
76
|
-
const col = parseInt(cellElement.getAttribute("aria-colindex") ?? "never");
|
|
77
|
-
const row = parseInt(cellElement.getAttribute("aria-rowindex") ?? "never");
|
|
78
|
-
return {
|
|
79
|
-
col,
|
|
80
|
-
row
|
|
81
|
-
};
|
|
82
|
-
} else {
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
var isSameCell = (a, b) => a && b && Number.isFinite(a.col) && Number.isFinite(a.row) && a.col === b.col && a.row === b.row;
|
|
87
38
|
var localChId = (c0) => `ch--${c0}`;
|
|
88
39
|
var localRhId = (r0) => `rh--${r0}`;
|
|
89
40
|
var getPage = (axis, event) => axis === "col" ? event.pageX : event.pageY;
|
|
90
41
|
var DxGrid = class extends LitElement {
|
|
91
42
|
constructor() {
|
|
92
43
|
super(...arguments);
|
|
93
|
-
this.gridId = "default-grid-id";
|
|
94
44
|
this.rowDefault = {
|
|
95
45
|
size: 32
|
|
96
46
|
};
|
|
@@ -99,13 +49,6 @@ var DxGrid = class extends LitElement {
|
|
|
99
49
|
};
|
|
100
50
|
this.rows = {};
|
|
101
51
|
this.columns = {};
|
|
102
|
-
this.initialCells = {};
|
|
103
|
-
this.mode = "browse";
|
|
104
|
-
/**
|
|
105
|
-
* When this function is defined, it is used first to try to get a value for a cell, and otherwise will fall back
|
|
106
|
-
* to `cells`.
|
|
107
|
-
*/
|
|
108
|
-
this.getCells = null;
|
|
109
52
|
this.cells = {};
|
|
110
53
|
//
|
|
111
54
|
// `pos`, short for ‘position’, is the position in pixels of the viewport from the origin.
|
|
@@ -143,100 +86,56 @@ var DxGrid = class extends LitElement {
|
|
|
143
86
|
this.templateColumns = `${this.colSize(0)}px`;
|
|
144
87
|
this.templateRows = `${this.rowSize(0)}px`;
|
|
145
88
|
//
|
|
146
|
-
//
|
|
89
|
+
// Resize state and handlers
|
|
147
90
|
//
|
|
148
|
-
this.pointer = null;
|
|
149
91
|
this.colSizes = {};
|
|
150
92
|
this.rowSizes = {};
|
|
151
|
-
this.
|
|
152
|
-
this.focusedCell = {
|
|
153
|
-
col: 0,
|
|
154
|
-
row: 0
|
|
155
|
-
};
|
|
156
|
-
this.selectionStart = {
|
|
157
|
-
col: 0,
|
|
158
|
-
row: 0
|
|
159
|
-
};
|
|
160
|
-
this.selectionEnd = {
|
|
161
|
-
col: 0,
|
|
162
|
-
row: 0
|
|
163
|
-
};
|
|
93
|
+
this.resizing = null;
|
|
164
94
|
this.handlePointerDown = (event) => {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
};
|
|
178
|
-
} else if (action === "cell") {
|
|
179
|
-
const cellCoords = closestCell(event.target, actionEl);
|
|
180
|
-
if (cellCoords) {
|
|
181
|
-
this.pointer = {
|
|
182
|
-
state: "selecting"
|
|
183
|
-
};
|
|
184
|
-
this.selectionStart = cellCoords;
|
|
185
|
-
}
|
|
186
|
-
if (this.mode === "edit") {
|
|
187
|
-
event.preventDefault();
|
|
188
|
-
} else {
|
|
189
|
-
if (this.focusActive && isSameCell(this.focusedCell, cellCoords)) {
|
|
190
|
-
this.dispatchEditRequest();
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
95
|
+
const actionEl = event.target?.closest("[data-dx-grid-action]");
|
|
96
|
+
const action = actionEl?.getAttribute("data-dx-grid-action");
|
|
97
|
+
if (action) {
|
|
98
|
+
if (action.startsWith("resize")) {
|
|
99
|
+
const [resize, index] = action.split(",");
|
|
100
|
+
const [_, axis] = resize.split("-");
|
|
101
|
+
this.resizing = {
|
|
102
|
+
axis,
|
|
103
|
+
size: axis === "col" ? this.colSize(index) : this.rowSize(index),
|
|
104
|
+
page: getPage(axis, event),
|
|
105
|
+
index
|
|
106
|
+
};
|
|
194
107
|
}
|
|
195
108
|
}
|
|
196
109
|
};
|
|
197
|
-
this.handlePointerUp = (
|
|
198
|
-
if (this.
|
|
110
|
+
this.handlePointerUp = (_event) => {
|
|
111
|
+
if (this.resizing) {
|
|
199
112
|
const resizeEvent = new DxAxisResize({
|
|
200
|
-
axis: this.
|
|
201
|
-
index: this.
|
|
202
|
-
size: this[this.
|
|
113
|
+
axis: this.resizing.axis,
|
|
114
|
+
index: this.resizing.index,
|
|
115
|
+
size: this[this.resizing.axis === "col" ? "colSize" : "rowSize"](this.resizing.index)
|
|
203
116
|
});
|
|
204
117
|
this.dispatchEvent(resizeEvent);
|
|
205
|
-
|
|
206
|
-
const cell = closestCell(event.target);
|
|
207
|
-
if (cell) {
|
|
208
|
-
this.selectionEnd = cell;
|
|
209
|
-
this.dispatchEvent(new DxGridCellsSelect({
|
|
210
|
-
start: this.selectionStart,
|
|
211
|
-
end: this.selectionEnd
|
|
212
|
-
}));
|
|
213
|
-
}
|
|
118
|
+
this.resizing = null;
|
|
214
119
|
}
|
|
215
|
-
this.pointer = null;
|
|
216
120
|
};
|
|
217
121
|
this.handlePointerMove = (event) => {
|
|
218
|
-
if (this.
|
|
219
|
-
const delta = getPage(this.
|
|
220
|
-
if (this.
|
|
221
|
-
const nextSize = Math.max(sizeColMin, Math.min(sizeColMax, this.
|
|
122
|
+
if (this.resizing) {
|
|
123
|
+
const delta = getPage(this.resizing.axis, event) - this.resizing.page;
|
|
124
|
+
if (this.resizing.axis === "col") {
|
|
125
|
+
const nextSize = Math.max(sizeColMin, Math.min(sizeColMax, this.resizing.size + delta));
|
|
222
126
|
this.colSizes = {
|
|
223
127
|
...this.colSizes,
|
|
224
|
-
[this.
|
|
128
|
+
[this.resizing.index]: nextSize
|
|
225
129
|
};
|
|
226
130
|
this.updateVisInline();
|
|
227
131
|
} else {
|
|
228
|
-
const nextSize = Math.max(sizeRowMin, Math.min(sizeRowMax, this.
|
|
132
|
+
const nextSize = Math.max(sizeRowMin, Math.min(sizeRowMax, this.resizing.size + delta));
|
|
229
133
|
this.rowSizes = {
|
|
230
134
|
...this.rowSizes,
|
|
231
|
-
[this.
|
|
135
|
+
[this.resizing.index]: nextSize
|
|
232
136
|
};
|
|
233
137
|
this.updateVisBlock();
|
|
234
138
|
}
|
|
235
|
-
} else if (this.pointer?.state === "selecting") {
|
|
236
|
-
const cell = closestCell(event.target);
|
|
237
|
-
if (cell && (cell.col !== this.selectionEnd.col || cell.row !== this.selectionEnd.row)) {
|
|
238
|
-
this.selectionEnd = cell;
|
|
239
|
-
}
|
|
240
139
|
}
|
|
241
140
|
};
|
|
242
141
|
//
|
|
@@ -255,75 +154,19 @@ var DxGrid = class extends LitElement {
|
|
|
255
154
|
});
|
|
256
155
|
this.viewportRef = createRef();
|
|
257
156
|
this.handleWheel = ({ deltaX, deltaY }) => {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
this.updateVis();
|
|
264
|
-
}
|
|
157
|
+
this.posInline = Math.max(0, this.posInline + deltaX);
|
|
158
|
+
this.posBlock = Math.max(0, this.posBlock + deltaY);
|
|
159
|
+
if (this.posInline >= this.binInlineMin && this.posInline < this.binInlineMax && this.posBlock >= this.binBlockMin && this.posBlock < this.binBlockMax) {
|
|
160
|
+
} else {
|
|
161
|
+
this.updateVis();
|
|
265
162
|
}
|
|
266
163
|
};
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
this.
|
|
273
|
-
queueMicrotask(() => this.dispatchEvent(new DxEditRequest({
|
|
274
|
-
cellIndex: toCellIndex(this.focusedCell),
|
|
275
|
-
cellBox: this.focusedCellBox(),
|
|
276
|
-
initialContent
|
|
277
|
-
})));
|
|
278
|
-
}
|
|
279
|
-
handleKeydown(event) {
|
|
280
|
-
if (this.focusActive && this.mode === "browse") {
|
|
281
|
-
switch (event.key) {
|
|
282
|
-
case "ArrowDown":
|
|
283
|
-
this.focusedCell = {
|
|
284
|
-
...this.focusedCell,
|
|
285
|
-
row: this.focusedCell.row + 1
|
|
286
|
-
};
|
|
287
|
-
break;
|
|
288
|
-
case "ArrowUp":
|
|
289
|
-
this.focusedCell = {
|
|
290
|
-
...this.focusedCell,
|
|
291
|
-
row: Math.max(0, this.focusedCell.row - 1)
|
|
292
|
-
};
|
|
293
|
-
break;
|
|
294
|
-
case "ArrowRight":
|
|
295
|
-
this.focusedCell = {
|
|
296
|
-
...this.focusedCell,
|
|
297
|
-
col: this.focusedCell.col + 1
|
|
298
|
-
};
|
|
299
|
-
break;
|
|
300
|
-
case "ArrowLeft":
|
|
301
|
-
this.focusedCell = {
|
|
302
|
-
...this.focusedCell,
|
|
303
|
-
col: Math.max(0, this.focusedCell.col - 1)
|
|
304
|
-
};
|
|
305
|
-
break;
|
|
306
|
-
}
|
|
307
|
-
switch (event.key) {
|
|
308
|
-
case "Enter":
|
|
309
|
-
this.dispatchEditRequest();
|
|
310
|
-
break;
|
|
311
|
-
default:
|
|
312
|
-
if (event.key.length === 1 && event.key.match(/\P{Cc}/u)) {
|
|
313
|
-
this.dispatchEditRequest(event.key);
|
|
314
|
-
}
|
|
315
|
-
break;
|
|
316
|
-
}
|
|
317
|
-
switch (event.key) {
|
|
318
|
-
case "ArrowDown":
|
|
319
|
-
case "ArrowUp":
|
|
320
|
-
case "ArrowRight":
|
|
321
|
-
case "ArrowLeft":
|
|
322
|
-
event.preventDefault();
|
|
323
|
-
this.snapPosToFocusedCell();
|
|
324
|
-
break;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
164
|
+
// Focus handlers
|
|
165
|
+
this.focusedCell = {
|
|
166
|
+
col: 0,
|
|
167
|
+
row: 0
|
|
168
|
+
};
|
|
169
|
+
this.focusActive = false;
|
|
327
170
|
}
|
|
328
171
|
//
|
|
329
172
|
// Accessors
|
|
@@ -334,33 +177,8 @@ var DxGrid = class extends LitElement {
|
|
|
334
177
|
rowSize(r) {
|
|
335
178
|
return this.rowSizes?.[r] ?? this.rowDefault.size;
|
|
336
179
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
return this.cells[index] ?? this.initialCells[index];
|
|
340
|
-
}
|
|
341
|
-
focusedCellBox() {
|
|
342
|
-
const cellElement = this.focusedCellElement();
|
|
343
|
-
const cellSize = {
|
|
344
|
-
inlineSize: this.colSize(this.focusedCell.col),
|
|
345
|
-
blockSize: this.rowSize(this.focusedCell.row)
|
|
346
|
-
};
|
|
347
|
-
if (!cellElement) {
|
|
348
|
-
return {
|
|
349
|
-
insetInlineStart: NaN,
|
|
350
|
-
insetBlockStart: NaN,
|
|
351
|
-
...cellSize
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
const contentElement = cellElement.offsetParent;
|
|
355
|
-
const [_translate3d, inlineStr, blockStr] = contentElement.style.transform.split(/[()]|px,?\s?/);
|
|
356
|
-
const contentOffsetInline = parseFloat(inlineStr);
|
|
357
|
-
const contentOffsetBlock = parseFloat(blockStr);
|
|
358
|
-
const offsetParent = contentElement.offsetParent;
|
|
359
|
-
return {
|
|
360
|
-
insetInlineStart: cellElement.offsetLeft + contentOffsetInline + offsetParent.offsetLeft,
|
|
361
|
-
insetBlockStart: cellElement.offsetTop + contentOffsetBlock + offsetParent.offsetTop,
|
|
362
|
-
...cellSize
|
|
363
|
-
};
|
|
180
|
+
getCell(c, r) {
|
|
181
|
+
return this.cells[`${c}${separator}${r}`];
|
|
364
182
|
}
|
|
365
183
|
updateVisInline() {
|
|
366
184
|
let colIndex = 0;
|
|
@@ -416,45 +234,31 @@ var DxGrid = class extends LitElement {
|
|
|
416
234
|
this.updateVisInline();
|
|
417
235
|
this.updateVisBlock();
|
|
418
236
|
}
|
|
419
|
-
// Focus handlers
|
|
420
237
|
handleFocus(event) {
|
|
421
|
-
const
|
|
422
|
-
|
|
423
|
-
|
|
238
|
+
const target = event.target;
|
|
239
|
+
const action = target.getAttribute("data-dx-grid-action");
|
|
240
|
+
if (action === "cell") {
|
|
241
|
+
const c = parseInt(target.getAttribute("aria-colindex") ?? "never");
|
|
242
|
+
const r = parseInt(target.getAttribute("aria-rowindex") ?? "never");
|
|
243
|
+
this.focusedCell = {
|
|
244
|
+
col: c,
|
|
245
|
+
row: r
|
|
246
|
+
};
|
|
424
247
|
this.focusActive = true;
|
|
425
248
|
}
|
|
426
249
|
}
|
|
427
250
|
handleBlur(event) {
|
|
428
|
-
if (!event.relatedTarget ||
|
|
251
|
+
if (!event.relatedTarget || event.relatedTarget.closest(".dx-grid__viewport") !== this.viewportRef.value) {
|
|
429
252
|
this.focusActive = false;
|
|
430
253
|
}
|
|
431
254
|
}
|
|
432
|
-
focusedCellElement() {
|
|
433
|
-
return this.viewportRef.value?.querySelector(`[aria-colindex="${this.focusedCell.col}"][aria-rowindex="${this.focusedCell.row}"]`);
|
|
434
|
-
}
|
|
435
255
|
/**
|
|
436
256
|
* Moves focus to the cell with actual focus, otherwise moves focus to the viewport.
|
|
437
257
|
*/
|
|
438
|
-
refocus(
|
|
439
|
-
|
|
440
|
-
case "row":
|
|
441
|
-
this.focusedCell = {
|
|
442
|
-
...this.focusedCell,
|
|
443
|
-
row: this.focusedCell.row + delta
|
|
444
|
-
};
|
|
445
|
-
break;
|
|
446
|
-
case "col":
|
|
447
|
-
this.focusedCell = {
|
|
448
|
-
...this.focusedCell,
|
|
449
|
-
col: this.focusedCell.col + delta
|
|
450
|
-
};
|
|
451
|
-
}
|
|
452
|
-
(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({
|
|
258
|
+
refocus() {
|
|
259
|
+
(this.focusedCell.row < this.visRowMin || this.focusedCell.row > this.visRowMax || this.focusedCell.col < this.visColMin || this.focusedCell.col > this.visColMax ? this.viewportRef.value : this.viewportRef.value?.querySelector(`[aria-colindex="${this.focusedCell.col}"][aria-rowindex="${this.focusedCell.row}"]`))?.focus({
|
|
453
260
|
preventScroll: true
|
|
454
261
|
});
|
|
455
|
-
if (increment) {
|
|
456
|
-
this.snapPosToFocusedCell();
|
|
457
|
-
}
|
|
458
262
|
}
|
|
459
263
|
/**
|
|
460
264
|
* Updates `pos` so that a cell in focus is fully within the viewport
|
|
@@ -473,7 +277,7 @@ var DxGrid = class extends LitElement {
|
|
|
473
277
|
acc += this.colSize(this.visColMin + overscanCol + c0) + gap;
|
|
474
278
|
return acc;
|
|
475
279
|
}, 0);
|
|
476
|
-
this.posInline =
|
|
280
|
+
this.posInline = this.binInlineMin + sizeSumCol + gap * 2 - this.sizeInline;
|
|
477
281
|
this.updateVisInline();
|
|
478
282
|
}
|
|
479
283
|
if (this.focusedCell.row <= this.visRowMin + overscanRow) {
|
|
@@ -486,34 +290,65 @@ var DxGrid = class extends LitElement {
|
|
|
486
290
|
acc += this.rowSize(this.visRowMin + overscanRow + r0) + gap;
|
|
487
291
|
return acc;
|
|
488
292
|
}, 0);
|
|
489
|
-
this.posBlock =
|
|
293
|
+
this.posBlock = this.binBlockMin + sizeSumRow + gap * 2 - this.sizeBlock;
|
|
490
294
|
this.updateVisBlock();
|
|
491
295
|
}
|
|
492
296
|
}
|
|
493
297
|
}
|
|
298
|
+
// Keyboard interactions
|
|
299
|
+
handleKeydown(event) {
|
|
300
|
+
if (this.focusActive) {
|
|
301
|
+
switch (event.key) {
|
|
302
|
+
case "ArrowDown":
|
|
303
|
+
this.focusedCell = {
|
|
304
|
+
...this.focusedCell,
|
|
305
|
+
row: this.focusedCell.row + 1
|
|
306
|
+
};
|
|
307
|
+
break;
|
|
308
|
+
case "ArrowUp":
|
|
309
|
+
this.focusedCell = {
|
|
310
|
+
...this.focusedCell,
|
|
311
|
+
row: Math.max(0, this.focusedCell.row - 1)
|
|
312
|
+
};
|
|
313
|
+
break;
|
|
314
|
+
case "ArrowRight":
|
|
315
|
+
this.focusedCell = {
|
|
316
|
+
...this.focusedCell,
|
|
317
|
+
col: this.focusedCell.col + 1
|
|
318
|
+
};
|
|
319
|
+
break;
|
|
320
|
+
case "ArrowLeft":
|
|
321
|
+
this.focusedCell = {
|
|
322
|
+
...this.focusedCell,
|
|
323
|
+
col: Math.max(0, this.focusedCell.col - 1)
|
|
324
|
+
};
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
switch (event.key) {
|
|
328
|
+
case "ArrowDown":
|
|
329
|
+
case "ArrowUp":
|
|
330
|
+
case "ArrowRight":
|
|
331
|
+
case "ArrowLeft":
|
|
332
|
+
event.preventDefault();
|
|
333
|
+
this.snapPosToFocusedCell();
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
494
338
|
//
|
|
495
339
|
// Render and other lifecycle methods
|
|
496
340
|
//
|
|
497
341
|
render() {
|
|
498
342
|
const visibleCols = this.visColMax - this.visColMin;
|
|
499
343
|
const visibleRows = this.visRowMax - this.visRowMin;
|
|
500
|
-
const offsetInline = this.binInlineMin - this.posInline - this.overscanInline;
|
|
501
|
-
const offsetBlock = this.binBlockMin - this.posBlock - this.overscanBlock;
|
|
502
|
-
const selectColMin = Math.min(this.selectionStart.col, this.selectionEnd.col);
|
|
503
|
-
const selectColMax = Math.max(this.selectionStart.col, this.selectionEnd.col);
|
|
504
|
-
const selectRowMin = Math.min(this.selectionStart.row, this.selectionEnd.row);
|
|
505
|
-
const selectRowMax = Math.max(this.selectionStart.row, this.selectionEnd.row);
|
|
506
|
-
const selectVisible = selectColMin !== selectColMax || selectRowMin !== selectRowMax;
|
|
344
|
+
const offsetInline = gap + this.binInlineMin - this.posInline - this.overscanInline;
|
|
345
|
+
const offsetBlock = gap + this.binBlockMin - this.posBlock - this.overscanBlock;
|
|
507
346
|
return html`<div
|
|
508
347
|
role="none"
|
|
509
348
|
class="dx-grid"
|
|
510
|
-
data-grid=${this.gridId}
|
|
511
|
-
data-grid-mode=${this.mode}
|
|
512
|
-
?data-grid-select=${selectVisible}
|
|
513
349
|
@pointerdown=${this.handlePointerDown}
|
|
514
350
|
@pointerup=${this.handlePointerUp}
|
|
515
351
|
@pointermove=${this.handlePointerMove}
|
|
516
|
-
@pointerleave=${this.handlePointerUp}
|
|
517
352
|
@focus=${this.handleFocus}
|
|
518
353
|
@blur=${this.handleBlur}
|
|
519
354
|
@keydown=${this.handleKeydown}
|
|
@@ -576,15 +411,11 @@ var DxGrid = class extends LitElement {
|
|
|
576
411
|
].map((_2, r0) => {
|
|
577
412
|
const c = c0 + this.visColMin;
|
|
578
413
|
const r = r0 + this.visRowMin;
|
|
579
|
-
const cell = this.
|
|
580
|
-
const active = this.focusActive && this.focusedCell.col === c && this.focusedCell.row === r;
|
|
581
|
-
const selected = c >= selectColMin && c <= selectColMax && r >= selectRowMin && r <= selectRowMax;
|
|
414
|
+
const cell = this.getCell(c, r);
|
|
582
415
|
return html`<div
|
|
583
416
|
role="gridcell"
|
|
584
417
|
tabindex="0"
|
|
585
418
|
?inert=${c < 0 || r < 0}
|
|
586
|
-
?aria-selected=${selected}
|
|
587
|
-
class=${cell || active ? (cell?.className ? cell.className + " " : "") + (active ? "dx-grid__cell--active" : "") : nothing}
|
|
588
419
|
aria-rowindex=${r}
|
|
589
420
|
aria-colindex=${c}
|
|
590
421
|
data-dx-grid-action="cell"
|
|
@@ -607,18 +438,6 @@ var DxGrid = class extends LitElement {
|
|
|
607
438
|
</div>`;
|
|
608
439
|
}
|
|
609
440
|
firstUpdated() {
|
|
610
|
-
if (this.getCells) {
|
|
611
|
-
this.cells = this.getCells({
|
|
612
|
-
start: {
|
|
613
|
-
col: this.visColMin,
|
|
614
|
-
row: this.visRowMin
|
|
615
|
-
},
|
|
616
|
-
end: {
|
|
617
|
-
col: this.visColMax,
|
|
618
|
-
row: this.visRowMax
|
|
619
|
-
}
|
|
620
|
-
});
|
|
621
|
-
}
|
|
622
441
|
this.observer.observe(this.viewportRef.value);
|
|
623
442
|
this.colSizes = Object.entries(this.columns).reduce((acc, [colId, colMeta]) => {
|
|
624
443
|
if (colMeta?.size) {
|
|
@@ -633,20 +452,6 @@ var DxGrid = class extends LitElement {
|
|
|
633
452
|
return acc;
|
|
634
453
|
}, {});
|
|
635
454
|
}
|
|
636
|
-
willUpdate(changedProperties) {
|
|
637
|
-
if (this.getCells && (changedProperties.has("initialCells") || changedProperties.has("visColMin") || changedProperties.has("visColMax") || changedProperties.has("visRowMin") || changedProperties.has("visRowMax"))) {
|
|
638
|
-
this.cells = this.getCells({
|
|
639
|
-
start: {
|
|
640
|
-
col: this.visColMin,
|
|
641
|
-
row: this.visRowMin
|
|
642
|
-
},
|
|
643
|
-
end: {
|
|
644
|
-
col: this.visColMax,
|
|
645
|
-
row: this.visRowMax
|
|
646
|
-
}
|
|
647
|
-
});
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
455
|
updated(changedProperties) {
|
|
651
456
|
if (this.focusActive && (changedProperties.has("visRowMin") || changedProperties.has("visColMin") || changedProperties.has("focusedCell"))) {
|
|
652
457
|
this.refocus();
|
|
@@ -662,11 +467,6 @@ var DxGrid = class extends LitElement {
|
|
|
662
467
|
return this;
|
|
663
468
|
}
|
|
664
469
|
};
|
|
665
|
-
_ts_decorate([
|
|
666
|
-
property({
|
|
667
|
-
type: String
|
|
668
|
-
})
|
|
669
|
-
], DxGrid.prototype, "gridId", void 0);
|
|
670
470
|
_ts_decorate([
|
|
671
471
|
property({
|
|
672
472
|
type: Object
|
|
@@ -691,14 +491,6 @@ _ts_decorate([
|
|
|
691
491
|
property({
|
|
692
492
|
type: Object
|
|
693
493
|
})
|
|
694
|
-
], DxGrid.prototype, "initialCells", void 0);
|
|
695
|
-
_ts_decorate([
|
|
696
|
-
property({
|
|
697
|
-
type: String
|
|
698
|
-
})
|
|
699
|
-
], DxGrid.prototype, "mode", void 0);
|
|
700
|
-
_ts_decorate([
|
|
701
|
-
state()
|
|
702
494
|
], DxGrid.prototype, "cells", void 0);
|
|
703
495
|
_ts_decorate([
|
|
704
496
|
state()
|
|
@@ -748,9 +540,6 @@ _ts_decorate([
|
|
|
748
540
|
_ts_decorate([
|
|
749
541
|
state()
|
|
750
542
|
], DxGrid.prototype, "templateRows", void 0);
|
|
751
|
-
_ts_decorate([
|
|
752
|
-
state()
|
|
753
|
-
], DxGrid.prototype, "pointer", void 0);
|
|
754
543
|
_ts_decorate([
|
|
755
544
|
state()
|
|
756
545
|
], DxGrid.prototype, "colSizes", void 0);
|
|
@@ -759,19 +548,16 @@ _ts_decorate([
|
|
|
759
548
|
], DxGrid.prototype, "rowSizes", void 0);
|
|
760
549
|
_ts_decorate([
|
|
761
550
|
state()
|
|
762
|
-
], DxGrid.prototype, "
|
|
763
|
-
_ts_decorate([
|
|
764
|
-
state()
|
|
765
|
-
], DxGrid.prototype, "focusedCell", void 0);
|
|
551
|
+
], DxGrid.prototype, "resizing", void 0);
|
|
766
552
|
_ts_decorate([
|
|
767
553
|
state()
|
|
768
|
-
], DxGrid.prototype, "
|
|
554
|
+
], DxGrid.prototype, "observer", void 0);
|
|
769
555
|
_ts_decorate([
|
|
770
556
|
state()
|
|
771
|
-
], DxGrid.prototype, "
|
|
557
|
+
], DxGrid.prototype, "focusedCell", void 0);
|
|
772
558
|
_ts_decorate([
|
|
773
559
|
state()
|
|
774
|
-
], DxGrid.prototype, "
|
|
560
|
+
], DxGrid.prototype, "focusActive", void 0);
|
|
775
561
|
_ts_decorate([
|
|
776
562
|
eventOptions({
|
|
777
563
|
capture: true
|
|
@@ -787,8 +573,6 @@ DxGrid = _ts_decorate([
|
|
|
787
573
|
], DxGrid);
|
|
788
574
|
export {
|
|
789
575
|
DxAxisResize,
|
|
790
|
-
|
|
791
|
-
DxGrid,
|
|
792
|
-
DxGridCellsSelect
|
|
576
|
+
DxGrid
|
|
793
577
|
};
|
|
794
578
|
//# sourceMappingURL=index.mjs.map
|