@toolbox-web/grid 1.3.0 → 1.3.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/all.js +469 -444
- package/all.js.map +1 -1
- package/index.js +242 -240
- package/index.js.map +1 -1
- package/lib/core/types.d.ts +4 -0
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +18 -16
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +43 -41
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +24 -22
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/index.js +48 -46
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js +22 -20
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts +11 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +160 -125
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +20 -18
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js +66 -64
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +51 -49
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +17 -15
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +24 -22
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +25 -23
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +49 -47
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +24 -22
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/responsive/index.js +19 -17
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-reorder/index.js +38 -36
- package/lib/plugins/row-reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js +41 -39
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +34 -32
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js +25 -23
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +22 -20
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +21 -19
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +19 -19
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +9 -9
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/filtering.umd.js +1 -1
- package/umd/plugins/filtering.umd.js.map +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function A(r) {
|
|
2
2
|
if (!r) return -1;
|
|
3
3
|
const e = r.getAttribute("data-row");
|
|
4
4
|
if (e) return parseInt(e, 10);
|
|
@@ -14,7 +14,7 @@ function p(r) {
|
|
|
14
14
|
function b(r) {
|
|
15
15
|
r && r.querySelectorAll(".cell-focus").forEach((e) => e.classList.remove("cell-focus"));
|
|
16
16
|
}
|
|
17
|
-
const
|
|
17
|
+
const m = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>', y = {
|
|
18
18
|
expand: "▶",
|
|
19
19
|
collapse: "▼",
|
|
20
20
|
sortAsc: "▲",
|
|
@@ -22,9 +22,11 @@ const A = {
|
|
|
22
22
|
sortNone: "⇅",
|
|
23
23
|
submenuArrow: "▶",
|
|
24
24
|
dragHandle: "⋮⋮",
|
|
25
|
-
toolPanel: "☰"
|
|
25
|
+
toolPanel: "☰",
|
|
26
|
+
filter: m,
|
|
27
|
+
filterActive: m
|
|
26
28
|
};
|
|
27
|
-
class
|
|
29
|
+
class v {
|
|
28
30
|
/**
|
|
29
31
|
* Plugin dependencies - declare other plugins this one requires.
|
|
30
32
|
*
|
|
@@ -248,7 +250,7 @@ class y {
|
|
|
248
250
|
*/
|
|
249
251
|
get gridIcons() {
|
|
250
252
|
const e = this.grid?.gridConfig?.icons ?? {};
|
|
251
|
-
return { ...
|
|
253
|
+
return { ...y, ...e };
|
|
252
254
|
}
|
|
253
255
|
// #region Animation Helpers
|
|
254
256
|
/**
|
|
@@ -324,7 +326,7 @@ class y {
|
|
|
324
326
|
}
|
|
325
327
|
// #endregion
|
|
326
328
|
}
|
|
327
|
-
function
|
|
329
|
+
function g(r) {
|
|
328
330
|
return r.meta?.utility === !0;
|
|
329
331
|
}
|
|
330
332
|
function u(r) {
|
|
@@ -335,34 +337,34 @@ function u(r) {
|
|
|
335
337
|
endCol: Math.max(r.startCol, r.endCol)
|
|
336
338
|
};
|
|
337
339
|
}
|
|
338
|
-
function
|
|
340
|
+
function I(r) {
|
|
339
341
|
const e = u(r);
|
|
340
342
|
return {
|
|
341
343
|
from: { row: e.startRow, col: e.startCol },
|
|
342
344
|
to: { row: e.endRow, col: e.endCol }
|
|
343
345
|
};
|
|
344
346
|
}
|
|
345
|
-
function
|
|
346
|
-
return r.map(
|
|
347
|
+
function C(r) {
|
|
348
|
+
return r.map(I);
|
|
347
349
|
}
|
|
348
350
|
function S(r, e, t) {
|
|
349
351
|
const s = u(t);
|
|
350
352
|
return r >= s.startRow && r <= s.endRow && e >= s.startCol && e <= s.endCol;
|
|
351
353
|
}
|
|
352
|
-
function
|
|
354
|
+
function R(r, e, t) {
|
|
353
355
|
return t.some((s) => S(r, e, s));
|
|
354
356
|
}
|
|
355
|
-
function
|
|
357
|
+
function E(r) {
|
|
356
358
|
const e = [], t = u(r);
|
|
357
359
|
for (let s = t.startRow; s <= t.endRow; s++)
|
|
358
360
|
for (let i = t.startCol; i <= t.endCol; i++)
|
|
359
361
|
e.push({ row: s, col: i });
|
|
360
362
|
return e;
|
|
361
363
|
}
|
|
362
|
-
function
|
|
364
|
+
function x(r) {
|
|
363
365
|
const e = /* @__PURE__ */ new Map();
|
|
364
366
|
for (const t of r)
|
|
365
|
-
for (const s of
|
|
367
|
+
for (const s of E(t))
|
|
366
368
|
e.set(`${s.row},${s.col}`, s);
|
|
367
369
|
return [...e.values()];
|
|
368
370
|
}
|
|
@@ -374,8 +376,8 @@ function f(r, e) {
|
|
|
374
376
|
endCol: e.col
|
|
375
377
|
};
|
|
376
378
|
}
|
|
377
|
-
const
|
|
378
|
-
function
|
|
379
|
+
const q = "@layer tbw-plugins{tbw-grid.selecting .data-grid-row>.cell{-webkit-user-select:none;user-select:none}tbw-grid[data-has-focus] .data-grid-row.row-focus{background-color:var(--tbw-focus-background, rgba(from var(--tbw-color-accent) r g b / 12%))}tbw-grid[data-selection-mode=row] .cell-focus{outline:none}tbw-grid .data-grid-row>.cell.selected{background-color:var(--tbw-range-selection-bg)}tbw-grid .data-grid-row>.cell.selected.top{border-top:2px solid var(--tbw-range-border-color)}tbw-grid .data-grid-row>.cell.selected.bottom{border-bottom:2px solid var(--tbw-range-border-color)}tbw-grid .data-grid-row>.cell.selected.first{border-left:2px solid var(--tbw-range-border-color)}tbw-grid .data-grid-row>.cell.selected.last{border-right:2px solid var(--tbw-range-border-color)}tbw-grid .data-grid-row[data-selectable=false]{cursor:not-allowed;opacity:.6}tbw-grid .data-grid-row[data-selectable=false].row-focus{background-color:var(--tbw-color-row-alt)}tbw-grid .data-grid-row>.cell[data-selectable=false]{cursor:not-allowed;opacity:.6}tbw-grid .data-grid-row>.cell[data-selectable=false].selected{background-color:var(--tbw-color-warning-bg, rgba(255, 243, 205, .5))}tbw-grid .tbw-selection-summary{font-size:var(--tbw-font-size-sm, .8125rem);color:var(--tbw-color-fg-muted);white-space:nowrap}}";
|
|
380
|
+
function k(r, e, t) {
|
|
379
381
|
if (r === "cell" && e.selectedCell)
|
|
380
382
|
return {
|
|
381
383
|
mode: r,
|
|
@@ -393,9 +395,9 @@ function q(r, e, t) {
|
|
|
393
395
|
}));
|
|
394
396
|
return { mode: r, ranges: s };
|
|
395
397
|
}
|
|
396
|
-
return r === "range" && e.ranges.length > 0 ? { mode: r, ranges:
|
|
398
|
+
return r === "range" && e.ranges.length > 0 ? { mode: r, ranges: C(e.ranges) } : { mode: r, ranges: [] };
|
|
397
399
|
}
|
|
398
|
-
class
|
|
400
|
+
class _ extends v {
|
|
399
401
|
/**
|
|
400
402
|
* Plugin manifest - declares configuration validation rules.
|
|
401
403
|
* @internal
|
|
@@ -415,7 +417,7 @@ class K extends y {
|
|
|
415
417
|
/** @internal */
|
|
416
418
|
name = "selection";
|
|
417
419
|
/** @internal */
|
|
418
|
-
styles =
|
|
420
|
+
styles = q;
|
|
419
421
|
/** @internal */
|
|
420
422
|
get defaultConfig() {
|
|
421
423
|
return {
|
|
@@ -476,7 +478,7 @@ class K extends y {
|
|
|
476
478
|
const { rowIndex: t, colIndex: s, originalEvent: i } = e, { mode: l, triggerOn: n = "click" } = this.config;
|
|
477
479
|
if (i.type !== n)
|
|
478
480
|
return !1;
|
|
479
|
-
const o = this.columns[s], d = o &&
|
|
481
|
+
const o = this.columns[s], d = o && g(o);
|
|
480
482
|
if (l === "cell")
|
|
481
483
|
return d || !this.isCellSelectable(t, s) || (this.selectedCell = { row: t, col: s }, this.emit("selection-change", this.#e()), this.requestAfterRender()), !1;
|
|
482
484
|
if (l === "row")
|
|
@@ -484,11 +486,11 @@ class K extends y {
|
|
|
484
486
|
if (l === "range") {
|
|
485
487
|
if (d || !this.isCellSelectable(t, s))
|
|
486
488
|
return !1;
|
|
487
|
-
const a = i.shiftKey,
|
|
489
|
+
const a = i.shiftKey, h = i.ctrlKey || i.metaKey;
|
|
488
490
|
if (a && this.cellAnchor) {
|
|
489
491
|
const c = f(this.cellAnchor, { row: t, col: s });
|
|
490
|
-
|
|
491
|
-
} else if (
|
|
492
|
+
h ? this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = c : this.ranges.push(c) : this.ranges = [c], this.activeRange = c;
|
|
493
|
+
} else if (h) {
|
|
492
494
|
const c = {
|
|
493
495
|
startRow: t,
|
|
494
496
|
startCol: s,
|
|
@@ -546,7 +548,7 @@ class K extends y {
|
|
|
546
548
|
onCellMouseDown(e) {
|
|
547
549
|
if (this.config.mode !== "range" || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
|
|
548
550
|
const t = this.columns[e.colIndex];
|
|
549
|
-
if (t &&
|
|
551
|
+
if (t && g(t) || !this.isCellSelectable(e.rowIndex, e.colIndex) || e.originalEvent.shiftKey && this.cellAnchor)
|
|
550
552
|
return;
|
|
551
553
|
this.isDragging = !0;
|
|
552
554
|
const s = e.rowIndex, i = e.colIndex;
|
|
@@ -564,8 +566,8 @@ class K extends y {
|
|
|
564
566
|
if (this.config.mode !== "range" || !this.isDragging || !this.cellAnchor || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
|
|
565
567
|
let t = e.colIndex;
|
|
566
568
|
const s = this.columns[t];
|
|
567
|
-
if (s &&
|
|
568
|
-
const l = this.columns.findIndex((n) => !
|
|
569
|
+
if (s && g(s)) {
|
|
570
|
+
const l = this.columns.findIndex((n) => !g(n));
|
|
569
571
|
l >= 0 && (t = l);
|
|
570
572
|
}
|
|
571
573
|
const i = f(this.cellAnchor, { row: e.rowIndex, col: t });
|
|
@@ -591,24 +593,24 @@ class K extends y {
|
|
|
591
593
|
if (l.forEach((n) => {
|
|
592
594
|
n.classList.remove("selected", "row-focus"), s && n.removeAttribute("data-selectable");
|
|
593
595
|
}), t === "row" && (b(e), l.forEach((n) => {
|
|
594
|
-
const o = n.querySelector(".cell[data-row]"), d =
|
|
596
|
+
const o = n.querySelector(".cell[data-row]"), d = A(o);
|
|
595
597
|
d >= 0 && (s && !this.isRowSelectable(d) && n.setAttribute("data-selectable", "false"), this.selected.has(d) && n.classList.add("selected", "row-focus"));
|
|
596
598
|
})), (t === "cell" || t === "range") && s && e.querySelectorAll(".cell[data-row][data-col]").forEach((o) => {
|
|
597
599
|
const d = parseInt(o.getAttribute("data-row") ?? "-1", 10), a = parseInt(o.getAttribute("data-col") ?? "-1", 10);
|
|
598
600
|
d >= 0 && a >= 0 && (this.isCellSelectable(d, a) || o.setAttribute("data-selectable", "false"));
|
|
599
601
|
}), t === "range" && this.ranges.length > 0) {
|
|
600
602
|
b(e);
|
|
601
|
-
const n = this.activeRange ? u(this.activeRange) : null, o = this.columns.findIndex((a) => !
|
|
603
|
+
const n = this.activeRange ? u(this.activeRange) : null, o = this.columns.findIndex((a) => !g(a));
|
|
602
604
|
this.columns.length - 1, e.querySelectorAll(".cell[data-row][data-col]").forEach((a) => {
|
|
603
|
-
const
|
|
604
|
-
if (
|
|
605
|
+
const h = parseInt(a.getAttribute("data-row") ?? "-1", 10), c = parseInt(a.getAttribute("data-col") ?? "-1", 10);
|
|
606
|
+
if (h >= 0 && c >= 0) {
|
|
605
607
|
const w = this.columns[c];
|
|
606
|
-
if (w &&
|
|
608
|
+
if (w && g(w))
|
|
607
609
|
return;
|
|
608
|
-
if (
|
|
609
|
-
|
|
610
|
-
const
|
|
611
|
-
c ===
|
|
610
|
+
if (R(h, c, this.ranges) && (a.classList.add("selected"), n)) {
|
|
611
|
+
h === n.startRow && a.classList.add("top"), h === n.endRow && a.classList.add("bottom");
|
|
612
|
+
const p = Math.max(n.startCol, o);
|
|
613
|
+
c === p && a.classList.add("first"), c === n.endCol && a.classList.add("last");
|
|
612
614
|
}
|
|
613
615
|
}
|
|
614
616
|
});
|
|
@@ -667,13 +669,13 @@ class K extends y {
|
|
|
667
669
|
* Get all selected cells across all ranges.
|
|
668
670
|
*/
|
|
669
671
|
getSelectedCells() {
|
|
670
|
-
return
|
|
672
|
+
return x(this.ranges);
|
|
671
673
|
}
|
|
672
674
|
/**
|
|
673
675
|
* Check if a specific cell is in range selection.
|
|
674
676
|
*/
|
|
675
677
|
isCellSelected(e, t) {
|
|
676
|
-
return
|
|
678
|
+
return R(e, t, this.ranges);
|
|
677
679
|
}
|
|
678
680
|
/**
|
|
679
681
|
* Clear all selection.
|
|
@@ -692,13 +694,13 @@ class K extends y {
|
|
|
692
694
|
endCol: t.to.col
|
|
693
695
|
})), this.activeRange = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null, this.emit("selection-change", {
|
|
694
696
|
mode: this.config.mode,
|
|
695
|
-
ranges:
|
|
697
|
+
ranges: C(this.ranges)
|
|
696
698
|
}), this.requestAfterRender();
|
|
697
699
|
}
|
|
698
700
|
// #endregion
|
|
699
701
|
// #region Private Helpers
|
|
700
702
|
#e() {
|
|
701
|
-
return
|
|
703
|
+
return k(
|
|
702
704
|
this.config.mode,
|
|
703
705
|
{
|
|
704
706
|
selectedCell: this.selectedCell,
|
|
@@ -711,6 +713,6 @@ class K extends y {
|
|
|
711
713
|
// #endregion
|
|
712
714
|
}
|
|
713
715
|
export {
|
|
714
|
-
|
|
716
|
+
_ as SelectionPlugin
|
|
715
717
|
};
|
|
716
718
|
//# sourceMappingURL=index.js.map
|