@toolbox-web/grid 0.0.7 → 0.1.1
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/README.md +1 -1
- package/all.d.ts +156 -95
- package/all.js +1561 -1502
- package/all.js.map +1 -1
- package/custom-elements.json +89 -7
- package/index.d.ts +68 -23
- package/index.js +1617 -1388
- package/index.js.map +1 -1
- package/lib/plugins/clipboard/index.js +48 -49
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +6 -6
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +64 -109
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/export/index.js +7 -7
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js +5 -38
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +4 -32
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js +8 -45
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +7 -31
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +19 -42
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +5 -6
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +14 -88
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +673 -145
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +22 -51
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js +76 -83
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +2 -2
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js +6 -14
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +2 -3
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +13 -105
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/themes/dg-theme-bootstrap.css +73 -0
- package/themes/dg-theme-material.css +71 -0
- package/umd/grid.all.umd.js +43 -469
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +35 -66
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js +4 -4
- package/umd/plugins/clipboard.umd.js.map +1 -1
- package/umd/plugins/column-virtualization.umd.js +1 -1
- package/umd/plugins/column-virtualization.umd.js.map +1 -1
- package/umd/plugins/context-menu.umd.js +1 -52
- package/umd/plugins/context-menu.umd.js.map +1 -1
- package/umd/plugins/export.umd.js +1 -1
- package/umd/plugins/export.umd.js.map +1 -1
- package/umd/plugins/filtering.umd.js +2 -34
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/grouping-columns.umd.js +1 -28
- package/umd/plugins/grouping-columns.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js +1 -39
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js +1 -26
- package/umd/plugins/master-detail.umd.js.map +1 -1
- package/umd/plugins/multi-sort.umd.js +1 -25
- package/umd/plugins/multi-sort.umd.js.map +1 -1
- package/umd/plugins/pinned-columns.umd.js +1 -1
- package/umd/plugins/pinned-columns.umd.js.map +1 -1
- package/umd/plugins/pinned-rows.umd.js +1 -72
- package/umd/plugins/pinned-rows.umd.js.map +1 -1
- package/umd/plugins/pivot.umd.js +1 -7
- package/umd/plugins/pivot.umd.js.map +1 -1
- package/umd/plugins/reorder.umd.js +1 -30
- package/umd/plugins/reorder.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +1 -33
- package/umd/plugins/selection.umd.js.map +1 -1
- package/umd/plugins/server-side.umd.js +1 -1
- package/umd/plugins/server-side.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js +1 -10
- package/umd/plugins/tree.umd.js.map +1 -1
- package/umd/plugins/undo-redo.umd.js +1 -1
- package/umd/plugins/undo-redo.umd.js.map +1 -1
- package/umd/plugins/visibility.umd.js +1 -93
- package/umd/plugins/visibility.umd.js.map +1 -1
|
@@ -5,7 +5,8 @@ const f = {
|
|
|
5
5
|
sortDesc: "▼",
|
|
6
6
|
sortNone: "⇅",
|
|
7
7
|
submenuArrow: "▶",
|
|
8
|
-
dragHandle: "⋮⋮"
|
|
8
|
+
dragHandle: "⋮⋮",
|
|
9
|
+
toolPanel: "☰"
|
|
9
10
|
};
|
|
10
11
|
class w {
|
|
11
12
|
/** Plugin version - override in subclass if needed */
|
|
@@ -162,7 +163,7 @@ class w {
|
|
|
162
163
|
console.warn(`[tbw-grid:${this.name}] ${e}`);
|
|
163
164
|
}
|
|
164
165
|
}
|
|
165
|
-
function
|
|
166
|
+
function h(s) {
|
|
166
167
|
return {
|
|
167
168
|
startRow: Math.min(s.startRow, s.endRow),
|
|
168
169
|
startCol: Math.min(s.startCol, s.endCol),
|
|
@@ -171,37 +172,37 @@ function d(s) {
|
|
|
171
172
|
};
|
|
172
173
|
}
|
|
173
174
|
function R(s) {
|
|
174
|
-
const e =
|
|
175
|
+
const e = h(s);
|
|
175
176
|
return {
|
|
176
177
|
from: { row: e.startRow, col: e.startCol },
|
|
177
178
|
to: { row: e.endRow, col: e.endCol }
|
|
178
179
|
};
|
|
179
180
|
}
|
|
180
|
-
function
|
|
181
|
+
function g(s) {
|
|
181
182
|
return s.map(R);
|
|
182
183
|
}
|
|
183
184
|
function C(s, e, t) {
|
|
184
|
-
const r =
|
|
185
|
+
const r = h(t);
|
|
185
186
|
return s >= r.startRow && s <= r.endRow && e >= r.startCol && e <= r.endCol;
|
|
186
187
|
}
|
|
187
|
-
function
|
|
188
|
+
function u(s, e, t) {
|
|
188
189
|
return t.some((r) => C(s, e, r));
|
|
189
190
|
}
|
|
190
191
|
function m(s) {
|
|
191
|
-
const e = [], t =
|
|
192
|
+
const e = [], t = h(s);
|
|
192
193
|
for (let r = t.startRow; r <= t.endRow; r++)
|
|
193
194
|
for (let n = t.startCol; n <= t.endCol; n++)
|
|
194
195
|
e.push({ row: r, col: n });
|
|
195
196
|
return e;
|
|
196
197
|
}
|
|
197
|
-
function
|
|
198
|
+
function A(s) {
|
|
198
199
|
const e = /* @__PURE__ */ new Map();
|
|
199
200
|
for (const t of s)
|
|
200
201
|
for (const r of m(t))
|
|
201
202
|
e.set(`${r.row},${r.col}`, r);
|
|
202
203
|
return [...e.values()];
|
|
203
204
|
}
|
|
204
|
-
function
|
|
205
|
+
function d(s, e) {
|
|
205
206
|
return {
|
|
206
207
|
startRow: s.row,
|
|
207
208
|
startCol: s.col,
|
|
@@ -209,7 +210,8 @@ function u(s, e) {
|
|
|
209
210
|
endCol: e.col
|
|
210
211
|
};
|
|
211
212
|
}
|
|
212
|
-
|
|
213
|
+
const b = ':host .selecting .data-grid-row>.cell{-webkit-user-select:none;user-select:none}:host .data-grid-row.row-focus{background-color:var(--tbw-focus-background, rgba(from var(--tbw-color-accent) r g b / 12%))}:host([data-selection-mode="row"]) .cell-focus{outline:none}:host .data-grid-row>.cell.selected{background-color:var(--tbw-range-selection-bg)}:host .data-grid-row>.cell.selected.top{border-top:2px solid var(--tbw-range-border-color)}:host .data-grid-row>.cell.selected.bottom{border-bottom:2px solid var(--tbw-range-border-color)}:host .data-grid-row>.cell.selected.first{border-left:2px solid var(--tbw-range-border-color)}:host .data-grid-row>.cell.selected.last{border-right:2px solid var(--tbw-range-border-color)}';
|
|
214
|
+
function p(s, e, t) {
|
|
213
215
|
if (s === "cell" && e.selectedCell)
|
|
214
216
|
return {
|
|
215
217
|
mode: s,
|
|
@@ -227,7 +229,7 @@ function A(s, e, t) {
|
|
|
227
229
|
}));
|
|
228
230
|
return { mode: s, ranges: r };
|
|
229
231
|
}
|
|
230
|
-
return s === "range" && e.ranges.length > 0 ? { mode: s, ranges:
|
|
232
|
+
return s === "range" && e.ranges.length > 0 ? { mode: s, ranges: g(e.ranges) } : { mode: s, ranges: [] };
|
|
231
233
|
}
|
|
232
234
|
class v extends w {
|
|
233
235
|
name = "selection";
|
|
@@ -261,45 +263,68 @@ class v extends w {
|
|
|
261
263
|
if (o === "row")
|
|
262
264
|
return this.selected.clear(), this.selected.add(t), this.lastSelected = t, this.emit("selection-change", this.#e()), this.requestAfterRender(), !1;
|
|
263
265
|
if (o === "range") {
|
|
264
|
-
const
|
|
265
|
-
if (
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
} else if (
|
|
269
|
-
const
|
|
266
|
+
const c = n.shiftKey, l = n.ctrlKey || n.metaKey;
|
|
267
|
+
if (c && this.cellAnchor) {
|
|
268
|
+
const i = d(this.cellAnchor, { row: t, col: r });
|
|
269
|
+
l ? this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = i : this.ranges.push(i) : this.ranges = [i], this.activeRange = i;
|
|
270
|
+
} else if (l) {
|
|
271
|
+
const i = {
|
|
270
272
|
startRow: t,
|
|
271
273
|
startCol: r,
|
|
272
274
|
endRow: t,
|
|
273
275
|
endCol: r
|
|
274
276
|
};
|
|
275
|
-
this.ranges.push(
|
|
277
|
+
this.ranges.push(i), this.activeRange = i, this.cellAnchor = { row: t, col: r };
|
|
276
278
|
} else {
|
|
277
|
-
const
|
|
279
|
+
const i = {
|
|
278
280
|
startRow: t,
|
|
279
281
|
startCol: r,
|
|
280
282
|
endRow: t,
|
|
281
283
|
endCol: r
|
|
282
284
|
};
|
|
283
|
-
this.ranges = [
|
|
285
|
+
this.ranges = [i], this.activeRange = i, this.cellAnchor = { row: t, col: r };
|
|
284
286
|
}
|
|
285
287
|
return this.emit("selection-change", this.#e()), this.requestAfterRender(), !1;
|
|
286
288
|
}
|
|
287
289
|
return !1;
|
|
288
290
|
}
|
|
289
291
|
onKeyDown(e) {
|
|
290
|
-
const { mode: t } = this.config;
|
|
292
|
+
const { mode: t } = this.config, n = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Tab", "Home", "End", "PageUp", "PageDown"].includes(e.key);
|
|
291
293
|
if (e.key === "Escape")
|
|
292
294
|
return t === "cell" ? this.selectedCell = null : t === "row" ? (this.selected.clear(), this.anchor = null) : t === "range" && (this.ranges = [], this.activeRange = null, this.cellAnchor = null), this.emit("selection-change", this.#e()), this.requestAfterRender(), !0;
|
|
295
|
+
if (t === "cell" && n)
|
|
296
|
+
return queueMicrotask(() => {
|
|
297
|
+
const o = this.grid;
|
|
298
|
+
this.selectedCell = { row: o.focusRow, col: o.focusCol }, this.emit("selection-change", this.#e()), this.requestAfterRender();
|
|
299
|
+
}), !1;
|
|
300
|
+
if (t === "row" && (e.key === "ArrowUp" || e.key === "ArrowDown"))
|
|
301
|
+
return queueMicrotask(() => {
|
|
302
|
+
const o = this.grid;
|
|
303
|
+
this.selected.clear(), this.selected.add(o.focusRow), this.lastSelected = o.focusRow, this.emit("selection-change", this.#e()), this.requestAfterRender();
|
|
304
|
+
}), !1;
|
|
305
|
+
if (t === "range" && n) {
|
|
306
|
+
const o = e.shiftKey;
|
|
307
|
+
return queueMicrotask(() => {
|
|
308
|
+
const c = this.grid, l = c.focusRow, i = c.focusCol;
|
|
309
|
+
if (o) {
|
|
310
|
+
this.cellAnchor || (this.cellAnchor = { row: l, col: i });
|
|
311
|
+
const a = d(this.cellAnchor, { row: l, col: i });
|
|
312
|
+
this.ranges = [a], this.activeRange = a;
|
|
313
|
+
} else
|
|
314
|
+
this.ranges = [], this.activeRange = null, this.cellAnchor = { row: l, col: i };
|
|
315
|
+
this.emit("selection-change", this.#e()), this.requestAfterRender();
|
|
316
|
+
}), !1;
|
|
317
|
+
}
|
|
293
318
|
if (t === "range" && e.key === "a" && (e.ctrlKey || e.metaKey)) {
|
|
294
|
-
const
|
|
295
|
-
if (
|
|
296
|
-
const
|
|
319
|
+
const o = this.rows.length, c = this.columns.length;
|
|
320
|
+
if (o > 0 && c > 0) {
|
|
321
|
+
const l = {
|
|
297
322
|
startRow: 0,
|
|
298
323
|
startCol: 0,
|
|
299
|
-
endRow:
|
|
300
|
-
endCol:
|
|
324
|
+
endRow: o - 1,
|
|
325
|
+
endCol: c - 1
|
|
301
326
|
};
|
|
302
|
-
return this.ranges = [
|
|
327
|
+
return this.ranges = [l], this.activeRange = l, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0;
|
|
303
328
|
}
|
|
304
329
|
}
|
|
305
330
|
return !1;
|
|
@@ -320,7 +345,7 @@ class v extends w {
|
|
|
320
345
|
}
|
|
321
346
|
onCellMouseMove(e) {
|
|
322
347
|
if (this.config.mode !== "range" || !this.isDragging || !this.cellAnchor || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
|
|
323
|
-
const t =
|
|
348
|
+
const t = d(this.cellAnchor, { row: e.rowIndex, col: e.colIndex });
|
|
324
349
|
return this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = t : this.ranges.push(t), this.activeRange = t, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0;
|
|
325
350
|
}
|
|
326
351
|
onCellMouseUp(e) {
|
|
@@ -341,14 +366,14 @@ class v extends w {
|
|
|
341
366
|
const n = e.querySelectorAll(".data-grid-row");
|
|
342
367
|
if (n.forEach((o) => {
|
|
343
368
|
o.classList.remove("selected", "row-focus");
|
|
344
|
-
}), t === "row" && n.forEach((o) => {
|
|
345
|
-
const
|
|
346
|
-
|
|
347
|
-
}), t === "range" && this.ranges.length > 0) {
|
|
348
|
-
const o = this.activeRange ?
|
|
349
|
-
e.querySelectorAll(".cell[data-row][data-col]").forEach((
|
|
350
|
-
const
|
|
351
|
-
|
|
369
|
+
}), t === "row" && (e.querySelectorAll(".cell-focus").forEach((o) => o.classList.remove("cell-focus")), n.forEach((o) => {
|
|
370
|
+
const c = o.querySelector(".cell[data-row]"), l = parseInt(c?.getAttribute("data-row") ?? "-1", 10);
|
|
371
|
+
l >= 0 && this.selected.has(l) && o.classList.add("selected", "row-focus");
|
|
372
|
+
})), t === "range" && this.ranges.length > 0) {
|
|
373
|
+
const o = this.activeRange ? h(this.activeRange) : null;
|
|
374
|
+
e.querySelectorAll(".cell[data-row][data-col]").forEach((l) => {
|
|
375
|
+
const i = parseInt(l.getAttribute("data-row") ?? "-1", 10), a = parseInt(l.getAttribute("data-col") ?? "-1", 10);
|
|
376
|
+
i >= 0 && a >= 0 && u(i, a, this.ranges) && (l.classList.add("selected"), l.classList.remove("cell-focus"), o && (i === o.startRow && l.classList.add("top"), i === o.endRow && l.classList.add("bottom"), a === o.startCol && l.classList.add("first"), a === o.endCol && l.classList.add("last")));
|
|
352
377
|
});
|
|
353
378
|
}
|
|
354
379
|
t === "cell" && this.selectedCell && e.querySelectorAll(".cell-focus").forEach((o) => o.classList.remove("cell-focus"));
|
|
@@ -383,19 +408,19 @@ class v extends w {
|
|
|
383
408
|
* Get all selected cell ranges in public format.
|
|
384
409
|
*/
|
|
385
410
|
getRanges() {
|
|
386
|
-
return
|
|
411
|
+
return g(this.ranges);
|
|
387
412
|
}
|
|
388
413
|
/**
|
|
389
414
|
* Get all selected cells across all ranges.
|
|
390
415
|
*/
|
|
391
416
|
getSelectedCells() {
|
|
392
|
-
return
|
|
417
|
+
return A(this.ranges);
|
|
393
418
|
}
|
|
394
419
|
/**
|
|
395
420
|
* Check if a specific cell is in range selection.
|
|
396
421
|
*/
|
|
397
422
|
isCellSelected(e, t) {
|
|
398
|
-
return
|
|
423
|
+
return u(e, t, this.ranges);
|
|
399
424
|
}
|
|
400
425
|
/**
|
|
401
426
|
* Clear all selection.
|
|
@@ -414,12 +439,12 @@ class v extends w {
|
|
|
414
439
|
endCol: t.to.col
|
|
415
440
|
})), this.activeRange = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null, this.emit("selection-change", {
|
|
416
441
|
mode: this.config.mode,
|
|
417
|
-
ranges:
|
|
442
|
+
ranges: g(this.ranges)
|
|
418
443
|
}), this.requestAfterRender();
|
|
419
444
|
}
|
|
420
445
|
// ===== Private Helpers =====
|
|
421
446
|
#e() {
|
|
422
|
-
return
|
|
447
|
+
return p(
|
|
423
448
|
this.config.mode,
|
|
424
449
|
{
|
|
425
450
|
selectedCell: this.selectedCell,
|
|
@@ -430,52 +455,20 @@ class v extends w {
|
|
|
430
455
|
);
|
|
431
456
|
}
|
|
432
457
|
// ===== Styles =====
|
|
433
|
-
styles =
|
|
434
|
-
/* Prevent text selection during range drag */
|
|
435
|
-
:host .selecting .data-grid-row > .cell {
|
|
436
|
-
user-select: none;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
/* Row selection - use accent color for row focus */
|
|
440
|
-
:host .data-grid-row.row-focus {
|
|
441
|
-
background-color: var(--tbw-focus-background, rgba(from var(--tbw-color-accent) r g b / 12%));
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
/* Disable cell-focus outline in row mode - row is the focus unit */
|
|
445
|
-
:host([data-selection-mode="row"]) .cell-focus {
|
|
446
|
-
outline: none;
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
/* Selection cell styles - for range mode */
|
|
450
|
-
:host .data-grid-row > .cell.selected {
|
|
451
|
-
background-color: var(--tbw-range-selection-bg);
|
|
452
|
-
}
|
|
453
|
-
:host .data-grid-row > .cell.selected.top {
|
|
454
|
-
border-top: 2px solid var(--tbw-range-border-color);
|
|
455
|
-
}
|
|
456
|
-
:host .data-grid-row > .cell.selected.bottom {
|
|
457
|
-
border-bottom: 2px solid var(--tbw-range-border-color);
|
|
458
|
-
}
|
|
459
|
-
:host .data-grid-row > .cell.selected.first {
|
|
460
|
-
border-left: 2px solid var(--tbw-range-border-color);
|
|
461
|
-
}
|
|
462
|
-
:host .data-grid-row > .cell.selected.last {
|
|
463
|
-
border-right: 2px solid var(--tbw-range-border-color);
|
|
464
|
-
}
|
|
465
|
-
`;
|
|
458
|
+
styles = b;
|
|
466
459
|
}
|
|
467
|
-
function
|
|
460
|
+
function q(s, e, t, r) {
|
|
468
461
|
const n = new Set(s.selected);
|
|
469
462
|
let o = s.anchor;
|
|
470
463
|
if (t === "single")
|
|
471
464
|
n.clear(), n.add(e), o = e;
|
|
472
465
|
else if (t === "multiple") {
|
|
473
|
-
const
|
|
466
|
+
const c = r.ctrlKey || r.metaKey;
|
|
474
467
|
if (r.shiftKey && s.anchor !== null) {
|
|
475
|
-
const
|
|
476
|
-
for (let
|
|
477
|
-
n.add(
|
|
478
|
-
} else
|
|
468
|
+
const l = Math.min(s.anchor, e), i = Math.max(s.anchor, e);
|
|
469
|
+
for (let a = l; a <= i; a++)
|
|
470
|
+
n.add(a);
|
|
471
|
+
} else c ? (n.has(e) ? n.delete(e) : n.add(e), o = e) : (n.clear(), n.add(e), o = e);
|
|
479
472
|
}
|
|
480
473
|
return { selected: n, lastSelected: e, anchor: o };
|
|
481
474
|
}
|
|
@@ -485,7 +478,7 @@ function S(s) {
|
|
|
485
478
|
e.add(t);
|
|
486
479
|
return e;
|
|
487
480
|
}
|
|
488
|
-
function
|
|
481
|
+
function K(s, e) {
|
|
489
482
|
const t = [], r = [];
|
|
490
483
|
for (const n of e)
|
|
491
484
|
s.has(n) || t.push(n);
|
|
@@ -495,8 +488,8 @@ function I(s, e) {
|
|
|
495
488
|
}
|
|
496
489
|
export {
|
|
497
490
|
v as SelectionPlugin,
|
|
498
|
-
|
|
499
|
-
|
|
491
|
+
K as computeSelectionDiff,
|
|
492
|
+
q as handleRowClick,
|
|
500
493
|
S as selectAll
|
|
501
494
|
};
|
|
502
495
|
//# sourceMappingURL=index.js.map
|