@toolbox-web/grid 1.3.0 → 1.4.0
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.d.ts +1 -0
- package/all.d.ts.map +1 -1
- package/all.js +997 -710
- package/all.js.map +1 -1
- package/index.js +642 -599
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/header.d.ts +7 -0
- package/lib/core/internal/header.d.ts.map +1 -1
- package/lib/core/types.d.ts +151 -0
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +19 -16
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +42 -39
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +25 -22
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +53 -48
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js +23 -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 +186 -150
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +21 -18
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js +67 -64
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +52 -49
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +18 -15
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +25 -22
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +26 -23
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +50 -47
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/print/PrintPlugin.d.ts +98 -0
- package/lib/plugins/print/PrintPlugin.d.ts.map +1 -0
- package/lib/plugins/print/index.d.ts +10 -0
- package/lib/plugins/print/index.d.ts.map +1 -0
- package/lib/plugins/print/index.js +626 -0
- package/lib/plugins/print/index.js.map +1 -0
- package/lib/plugins/print/print-isolated.d.ts +26 -0
- package/lib/plugins/print/print-isolated.d.ts.map +1 -0
- package/lib/plugins/print/types.d.ts +147 -0
- package/lib/plugins/print/types.d.ts.map +1 -0
- package/lib/plugins/reorder/index.js +25 -22
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/responsive/index.js +20 -17
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-reorder/index.js +39 -36
- package/lib/plugins/row-reorder/index.js.map +1 -1
- package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
- package/lib/plugins/selection/index.js +115 -101
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +35 -32
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js +26 -23
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +23 -20
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +22 -19
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/public.d.ts +1 -1
- package/public.d.ts.map +1 -1
- package/umd/grid.all.umd.js +98 -24
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +11 -11
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/editing.umd.js +1 -1
- package/umd/plugins/editing.umd.js.map +1 -1
- package/umd/plugins/filtering.umd.js +1 -1
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/print.umd.js +76 -0
- package/umd/plugins/print.umd.js.map +1 -0
- package/umd/plugins/selection.umd.js +2 -2
- package/umd/plugins/selection.umd.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/selection/SelectionPlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"SelectionPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/selection/SelectionPlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAW/F,OAAO,KAAK,EACV,SAAS,EAGT,eAAe,EAEf,eAAe,EAChB,MAAM,SAAS,CAAC;AAyCjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8EG;AACH,qBAAa,eAAgB,SAAQ,cAAc,CAAC,eAAe,CAAC;;IAClE;;;OAGG;IACH,gBAAyB,QAAQ,EAAE,cAAc,CAAC,eAAe,CAAC,CAYhE;IAEF,gBAAgB;IAChB,QAAQ,CAAC,IAAI,eAAe;IAC5B,gBAAgB;IAChB,SAAkB,MAAM,SAAU;IAElC,gBAAgB;IAChB,cAAuB,aAAa,IAAI,OAAO,CAAC,eAAe,CAAC,CAK/D;IAGD,qCAAqC;IACrC,OAAO,CAAC,QAAQ,CAAqB;IACrC,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,MAAM,CAAuB;IAErC,yCAAyC;IACzC,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,WAAW,CAAkC;IACrD,OAAO,CAAC,UAAU,CAA6C;IAC/D,OAAO,CAAC,UAAU,CAAS;IAE3B,oEAAoE;IACpE,OAAO,CAAC,qBAAqB,CAAsC;IAEnE,uCAAuC;IACvC,OAAO,CAAC,YAAY,CAA6C;IAMjE;;;OAGG;IACH,OAAO,CAAC,eAAe;IAWvB;;OAEG;IACH,OAAO,CAAC,eAAe;IAIvB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAQxB,gBAAgB;IACP,MAAM,IAAI,IAAI;IAcvB,gBAAgB;IACP,WAAW,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO;IA4HpD,gBAAgB;IACP,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO;IA+GjD,gBAAgB;IACP,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,GAAG,IAAI;IAwD/D,gBAAgB;IACP,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,GAAG,IAAI;IAqC/D,gBAAgB;IACP,aAAa,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,GAAG,IAAI;IAoH9D,gBAAgB;IACP,WAAW,IAAI,IAAI;IA0C5B;;;;OAIG;IACM,cAAc,IAAI,IAAI;IAQ/B;;;;;;;;;;;;;;OAcG;IACH,YAAY,IAAI,eAAe;IAQ/B;;OAEG;IACH,gBAAgB,IAAI,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAIvD;;OAEG;IACH,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO;IAIjD;;OAEG;IACH,cAAc,IAAI,IAAI;IAWtB;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI;CAgCrC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function y(r) {
|
|
2
2
|
if (!r) return -1;
|
|
3
3
|
const e = r.getAttribute("data-row");
|
|
4
4
|
if (e) return parseInt(e, 10);
|
|
@@ -6,15 +6,15 @@ function p(r) {
|
|
|
6
6
|
if (!t) return -1;
|
|
7
7
|
const s = t.parentElement;
|
|
8
8
|
if (!s) return -1;
|
|
9
|
-
const
|
|
10
|
-
for (let
|
|
11
|
-
if (i
|
|
9
|
+
const l = s.querySelectorAll(":scope > .data-grid-row");
|
|
10
|
+
for (let i = 0; i < l.length; i++)
|
|
11
|
+
if (l[i] === t) return i;
|
|
12
12
|
return -1;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function m(r) {
|
|
15
15
|
r && r.querySelectorAll(".cell-focus").forEach((e) => e.classList.remove("cell-focus"));
|
|
16
16
|
}
|
|
17
|
-
const
|
|
17
|
+
const R = '<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>', v = {
|
|
18
18
|
expand: "▶",
|
|
19
19
|
collapse: "▼",
|
|
20
20
|
sortAsc: "▲",
|
|
@@ -22,9 +22,12 @@ const A = {
|
|
|
22
22
|
sortNone: "⇅",
|
|
23
23
|
submenuArrow: "▶",
|
|
24
24
|
dragHandle: "⋮⋮",
|
|
25
|
-
toolPanel: "☰"
|
|
25
|
+
toolPanel: "☰",
|
|
26
|
+
filter: R,
|
|
27
|
+
filterActive: R,
|
|
28
|
+
print: "🖨️"
|
|
26
29
|
};
|
|
27
|
-
class
|
|
30
|
+
class I {
|
|
28
31
|
/**
|
|
29
32
|
* Plugin dependencies - declare other plugins this one requires.
|
|
30
33
|
*
|
|
@@ -248,7 +251,7 @@ class y {
|
|
|
248
251
|
*/
|
|
249
252
|
get gridIcons() {
|
|
250
253
|
const e = this.grid?.gridConfig?.icons ?? {};
|
|
251
|
-
return { ...
|
|
254
|
+
return { ...v, ...e };
|
|
252
255
|
}
|
|
253
256
|
// #region Animation Helpers
|
|
254
257
|
/**
|
|
@@ -324,7 +327,7 @@ class y {
|
|
|
324
327
|
}
|
|
325
328
|
// #endregion
|
|
326
329
|
}
|
|
327
|
-
function
|
|
330
|
+
function g(r) {
|
|
328
331
|
return r.meta?.utility === !0;
|
|
329
332
|
}
|
|
330
333
|
function u(r) {
|
|
@@ -335,38 +338,38 @@ function u(r) {
|
|
|
335
338
|
endCol: Math.max(r.startCol, r.endCol)
|
|
336
339
|
};
|
|
337
340
|
}
|
|
338
|
-
function
|
|
341
|
+
function S(r) {
|
|
339
342
|
const e = u(r);
|
|
340
343
|
return {
|
|
341
344
|
from: { row: e.startRow, col: e.startCol },
|
|
342
345
|
to: { row: e.endRow, col: e.endCol }
|
|
343
346
|
};
|
|
344
347
|
}
|
|
345
|
-
function
|
|
346
|
-
return r.map(
|
|
348
|
+
function p(r) {
|
|
349
|
+
return r.map(S);
|
|
347
350
|
}
|
|
348
|
-
function
|
|
351
|
+
function E(r, e, t) {
|
|
349
352
|
const s = u(t);
|
|
350
353
|
return r >= s.startRow && r <= s.endRow && e >= s.startCol && e <= s.endCol;
|
|
351
354
|
}
|
|
352
|
-
function
|
|
353
|
-
return t.some((s) =>
|
|
355
|
+
function C(r, e, t) {
|
|
356
|
+
return t.some((s) => E(r, e, s));
|
|
354
357
|
}
|
|
355
|
-
function
|
|
358
|
+
function x(r) {
|
|
356
359
|
const e = [], t = u(r);
|
|
357
360
|
for (let s = t.startRow; s <= t.endRow; s++)
|
|
358
|
-
for (let
|
|
359
|
-
e.push({ row: s, col:
|
|
361
|
+
for (let l = t.startCol; l <= t.endCol; l++)
|
|
362
|
+
e.push({ row: s, col: l });
|
|
360
363
|
return e;
|
|
361
364
|
}
|
|
362
|
-
function
|
|
365
|
+
function q(r) {
|
|
363
366
|
const e = /* @__PURE__ */ new Map();
|
|
364
367
|
for (const t of r)
|
|
365
|
-
for (const s of
|
|
368
|
+
for (const s of x(t))
|
|
366
369
|
e.set(`${s.row},${s.col}`, s);
|
|
367
370
|
return [...e.values()];
|
|
368
371
|
}
|
|
369
|
-
function
|
|
372
|
+
function b(r, e) {
|
|
370
373
|
return {
|
|
371
374
|
startRow: r.row,
|
|
372
375
|
startCol: r.col,
|
|
@@ -374,8 +377,12 @@ function f(r, e) {
|
|
|
374
377
|
endCol: e.col
|
|
375
378
|
};
|
|
376
379
|
}
|
|
377
|
-
|
|
378
|
-
|
|
380
|
+
function w(r, e) {
|
|
381
|
+
const t = u(r), s = u(e);
|
|
382
|
+
return t.startRow === s.startRow && t.startCol === s.startCol && t.endRow === s.endRow && t.endCol === s.endCol;
|
|
383
|
+
}
|
|
384
|
+
const k = "@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}}";
|
|
385
|
+
function K(r, e, t) {
|
|
379
386
|
if (r === "cell" && e.selectedCell)
|
|
380
387
|
return {
|
|
381
388
|
mode: r,
|
|
@@ -387,15 +394,15 @@ function q(r, e, t) {
|
|
|
387
394
|
]
|
|
388
395
|
};
|
|
389
396
|
if (r === "row" && e.selected.size > 0) {
|
|
390
|
-
const s = [...e.selected].map((
|
|
391
|
-
from: { row:
|
|
392
|
-
to: { row:
|
|
397
|
+
const s = [...e.selected].map((l) => ({
|
|
398
|
+
from: { row: l, col: 0 },
|
|
399
|
+
to: { row: l, col: t - 1 }
|
|
393
400
|
}));
|
|
394
401
|
return { mode: r, ranges: s };
|
|
395
402
|
}
|
|
396
|
-
return r === "range" && e.ranges.length > 0 ? { mode: r, ranges:
|
|
403
|
+
return r === "range" && e.ranges.length > 0 ? { mode: r, ranges: p(e.ranges) } : { mode: r, ranges: [] };
|
|
397
404
|
}
|
|
398
|
-
class
|
|
405
|
+
class D extends I {
|
|
399
406
|
/**
|
|
400
407
|
* Plugin manifest - declares configuration validation rules.
|
|
401
408
|
* @internal
|
|
@@ -415,7 +422,7 @@ class K extends y {
|
|
|
415
422
|
/** @internal */
|
|
416
423
|
name = "selection";
|
|
417
424
|
/** @internal */
|
|
418
|
-
styles =
|
|
425
|
+
styles = k;
|
|
419
426
|
/** @internal */
|
|
420
427
|
get defaultConfig() {
|
|
421
428
|
return {
|
|
@@ -446,10 +453,10 @@ class K extends y {
|
|
|
446
453
|
checkSelectable(e, t) {
|
|
447
454
|
const { isSelectable: s } = this.config;
|
|
448
455
|
if (!s) return !0;
|
|
449
|
-
const
|
|
450
|
-
if (!
|
|
451
|
-
const
|
|
452
|
-
return s(
|
|
456
|
+
const l = this.rows[e];
|
|
457
|
+
if (!l) return !1;
|
|
458
|
+
const i = t !== void 0 ? this.columns[t] : void 0;
|
|
459
|
+
return s(l, e, i, t);
|
|
453
460
|
}
|
|
454
461
|
/**
|
|
455
462
|
* Check if an entire row is selectable (for row mode).
|
|
@@ -473,37 +480,45 @@ class K extends y {
|
|
|
473
480
|
// #region Event Handlers
|
|
474
481
|
/** @internal */
|
|
475
482
|
onCellClick(e) {
|
|
476
|
-
const { rowIndex: t, colIndex: s, originalEvent:
|
|
477
|
-
if (
|
|
483
|
+
const { rowIndex: t, colIndex: s, originalEvent: l } = e, { mode: i, triggerOn: n = "click" } = this.config;
|
|
484
|
+
if (l.type !== n)
|
|
478
485
|
return !1;
|
|
479
|
-
const o = this.columns[s], d = o &&
|
|
480
|
-
if (
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
486
|
+
const o = this.columns[s], d = o && g(o);
|
|
487
|
+
if (i === "cell") {
|
|
488
|
+
if (d || !this.isCellSelectable(t, s))
|
|
489
|
+
return !1;
|
|
490
|
+
const c = this.selectedCell;
|
|
491
|
+
return c && c.row === t && c.col === s || (this.selectedCell = { row: t, col: s }, this.emit("selection-change", this.#e()), this.requestAfterRender()), !1;
|
|
492
|
+
}
|
|
493
|
+
if (i === "row")
|
|
494
|
+
return !this.isRowSelectable(t) || this.selected.size === 1 && this.selected.has(t) || (this.selected.clear(), this.selected.add(t), this.lastSelected = t, this.emit("selection-change", this.#e()), this.requestAfterRender()), !1;
|
|
495
|
+
if (i === "range") {
|
|
485
496
|
if (d || !this.isCellSelectable(t, s))
|
|
486
497
|
return !1;
|
|
487
|
-
const
|
|
488
|
-
if (
|
|
489
|
-
const
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
498
|
+
const c = l.shiftKey, h = l.ctrlKey || l.metaKey;
|
|
499
|
+
if (c && this.cellAnchor) {
|
|
500
|
+
const a = b(this.cellAnchor, { row: t, col: s }), f = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null;
|
|
501
|
+
if (f && w(f, a))
|
|
502
|
+
return !1;
|
|
503
|
+
h ? this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = a : this.ranges.push(a) : this.ranges = [a], this.activeRange = a;
|
|
504
|
+
} else if (h) {
|
|
505
|
+
const a = {
|
|
493
506
|
startRow: t,
|
|
494
507
|
startCol: s,
|
|
495
508
|
endRow: t,
|
|
496
509
|
endCol: s
|
|
497
510
|
};
|
|
498
|
-
this.ranges.push(
|
|
511
|
+
this.ranges.push(a), this.activeRange = a, this.cellAnchor = { row: t, col: s };
|
|
499
512
|
} else {
|
|
500
|
-
const
|
|
513
|
+
const a = {
|
|
501
514
|
startRow: t,
|
|
502
515
|
startCol: s,
|
|
503
516
|
endRow: t,
|
|
504
517
|
endCol: s
|
|
505
518
|
};
|
|
506
|
-
this.ranges
|
|
519
|
+
if (this.ranges.length === 1 && w(this.ranges[0], a))
|
|
520
|
+
return !1;
|
|
521
|
+
this.ranges = [a], this.activeRange = a, this.cellAnchor = { row: t, col: s };
|
|
507
522
|
}
|
|
508
523
|
return this.emit("selection-change", this.#e()), this.requestAfterRender(), !1;
|
|
509
524
|
}
|
|
@@ -511,30 +526,31 @@ class K extends y {
|
|
|
511
526
|
}
|
|
512
527
|
/** @internal */
|
|
513
528
|
onKeyDown(e) {
|
|
514
|
-
const { mode: t } = this.config,
|
|
529
|
+
const { mode: t } = this.config, l = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Tab", "Home", "End", "PageUp", "PageDown"].includes(e.key);
|
|
515
530
|
if (e.key === "Escape")
|
|
516
531
|
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;
|
|
517
|
-
if (t === "cell" &&
|
|
532
|
+
if (t === "cell" && l)
|
|
518
533
|
return queueMicrotask(() => {
|
|
519
|
-
const
|
|
520
|
-
this.isCellSelectable(
|
|
534
|
+
const i = this.grid._focusRow, n = this.grid._focusCol;
|
|
535
|
+
this.isCellSelectable(i, n) ? this.selectedCell = { row: i, col: n } : this.selectedCell = null, this.emit("selection-change", this.#e()), this.requestAfterRender();
|
|
521
536
|
}), !1;
|
|
522
537
|
if (t === "row" && (e.key === "ArrowUp" || e.key === "ArrowDown"))
|
|
523
538
|
return queueMicrotask(() => {
|
|
524
|
-
const
|
|
525
|
-
this.isRowSelectable(
|
|
539
|
+
const i = this.grid._focusRow;
|
|
540
|
+
this.isRowSelectable(i) ? (this.selected.clear(), this.selected.add(i), this.lastSelected = i) : this.selected.clear(), this.emit("selection-change", this.#e()), this.requestAfterRender();
|
|
526
541
|
}), !1;
|
|
527
|
-
if (t === "range" &&
|
|
528
|
-
const
|
|
542
|
+
if (t === "range" && l) {
|
|
543
|
+
const i = e.key === "Tab", n = e.shiftKey && !i;
|
|
529
544
|
return n && !this.cellAnchor && (this.cellAnchor = { row: this.grid._focusRow, col: this.grid._focusCol }), this.pendingKeyboardUpdate = { shiftKey: n }, queueMicrotask(() => this.requestAfterRender()), !1;
|
|
530
545
|
}
|
|
531
546
|
if (t === "range" && e.key === "a" && (e.ctrlKey || e.metaKey)) {
|
|
532
|
-
const
|
|
533
|
-
if (
|
|
547
|
+
const i = this.rows.length, n = this.columns.length;
|
|
548
|
+
if (i > 0 && n > 0) {
|
|
549
|
+
e.preventDefault(), e.stopPropagation();
|
|
534
550
|
const o = {
|
|
535
551
|
startRow: 0,
|
|
536
552
|
startCol: 0,
|
|
537
|
-
endRow:
|
|
553
|
+
endRow: i - 1,
|
|
538
554
|
endCol: n - 1
|
|
539
555
|
};
|
|
540
556
|
return this.ranges = [o], this.activeRange = o, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0;
|
|
@@ -546,30 +562,28 @@ class K extends y {
|
|
|
546
562
|
onCellMouseDown(e) {
|
|
547
563
|
if (this.config.mode !== "range" || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
|
|
548
564
|
const t = this.columns[e.colIndex];
|
|
549
|
-
if (t &&
|
|
565
|
+
if (t && g(t) || !this.isCellSelectable(e.rowIndex, e.colIndex) || e.originalEvent.shiftKey && this.cellAnchor)
|
|
550
566
|
return;
|
|
551
567
|
this.isDragging = !0;
|
|
552
|
-
const s = e.rowIndex, i = e.
|
|
553
|
-
this.cellAnchor = { row: s, col: i }, e.originalEvent.ctrlKey || e.originalEvent.metaKey || (this.ranges = []);
|
|
554
|
-
const n = {
|
|
568
|
+
const s = e.rowIndex, l = e.colIndex, i = e.originalEvent.ctrlKey || e.originalEvent.metaKey, n = {
|
|
555
569
|
startRow: s,
|
|
556
|
-
startCol:
|
|
570
|
+
startCol: l,
|
|
557
571
|
endRow: s,
|
|
558
|
-
endCol:
|
|
572
|
+
endCol: l
|
|
559
573
|
};
|
|
560
|
-
return this.ranges.push(n), this.activeRange = n, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0;
|
|
574
|
+
return !i && this.ranges.length === 1 && w(this.ranges[0], n) ? (this.cellAnchor = { row: s, col: l }, !0) : (this.cellAnchor = { row: s, col: l }, i || (this.ranges = []), this.ranges.push(n), this.activeRange = n, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0);
|
|
561
575
|
}
|
|
562
576
|
/** @internal */
|
|
563
577
|
onCellMouseMove(e) {
|
|
564
578
|
if (this.config.mode !== "range" || !this.isDragging || !this.cellAnchor || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
|
|
565
579
|
let t = e.colIndex;
|
|
566
580
|
const s = this.columns[t];
|
|
567
|
-
if (s &&
|
|
568
|
-
const
|
|
569
|
-
|
|
581
|
+
if (s && g(s)) {
|
|
582
|
+
const n = this.columns.findIndex((o) => !g(o));
|
|
583
|
+
n >= 0 && (t = n);
|
|
570
584
|
}
|
|
571
|
-
const
|
|
572
|
-
return this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] =
|
|
585
|
+
const l = b(this.cellAnchor, { row: e.rowIndex, col: t }), i = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null;
|
|
586
|
+
return i && w(i, l) || (this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = l : this.ranges.push(l), this.activeRange = l, this.emit("selection-change", this.#e()), this.requestAfterRender()), !0;
|
|
573
587
|
}
|
|
574
588
|
/** @internal */
|
|
575
589
|
onCellMouseUp(e) {
|
|
@@ -587,28 +601,28 @@ class K extends y {
|
|
|
587
601
|
e.querySelectorAll(".cell").forEach((n) => {
|
|
588
602
|
n.classList.remove("selected", "top", "bottom", "first", "last"), s && n.removeAttribute("data-selectable");
|
|
589
603
|
});
|
|
590
|
-
const
|
|
591
|
-
if (
|
|
604
|
+
const i = e.querySelectorAll(".data-grid-row");
|
|
605
|
+
if (i.forEach((n) => {
|
|
592
606
|
n.classList.remove("selected", "row-focus"), s && n.removeAttribute("data-selectable");
|
|
593
|
-
}), t === "row" && (
|
|
594
|
-
const o = n.querySelector(".cell[data-row]"), d =
|
|
607
|
+
}), t === "row" && (m(e), i.forEach((n) => {
|
|
608
|
+
const o = n.querySelector(".cell[data-row]"), d = y(o);
|
|
595
609
|
d >= 0 && (s && !this.isRowSelectable(d) && n.setAttribute("data-selectable", "false"), this.selected.has(d) && n.classList.add("selected", "row-focus"));
|
|
596
610
|
})), (t === "cell" || t === "range") && s && e.querySelectorAll(".cell[data-row][data-col]").forEach((o) => {
|
|
597
|
-
const d = parseInt(o.getAttribute("data-row") ?? "-1", 10),
|
|
598
|
-
d >= 0 &&
|
|
611
|
+
const d = parseInt(o.getAttribute("data-row") ?? "-1", 10), c = parseInt(o.getAttribute("data-col") ?? "-1", 10);
|
|
612
|
+
d >= 0 && c >= 0 && (this.isCellSelectable(d, c) || o.setAttribute("data-selectable", "false"));
|
|
599
613
|
}), t === "range" && this.ranges.length > 0) {
|
|
600
|
-
|
|
601
|
-
const n = this.activeRange ? u(this.activeRange) : null, o = this.columns.findIndex((
|
|
602
|
-
this.columns.length - 1, e.querySelectorAll(".cell[data-row][data-col]").forEach((
|
|
603
|
-
const
|
|
604
|
-
if (
|
|
605
|
-
const
|
|
606
|
-
if (
|
|
614
|
+
m(e);
|
|
615
|
+
const n = this.activeRange ? u(this.activeRange) : null, o = this.columns.findIndex((c) => !g(c));
|
|
616
|
+
this.columns.length - 1, e.querySelectorAll(".cell[data-row][data-col]").forEach((c) => {
|
|
617
|
+
const h = parseInt(c.getAttribute("data-row") ?? "-1", 10), a = parseInt(c.getAttribute("data-col") ?? "-1", 10);
|
|
618
|
+
if (h >= 0 && a >= 0) {
|
|
619
|
+
const f = this.columns[a];
|
|
620
|
+
if (f && g(f))
|
|
607
621
|
return;
|
|
608
|
-
if (
|
|
609
|
-
|
|
610
|
-
const
|
|
611
|
-
|
|
622
|
+
if (C(h, a, this.ranges) && (c.classList.add("selected"), n)) {
|
|
623
|
+
h === n.startRow && c.classList.add("top"), h === n.endRow && c.classList.add("bottom");
|
|
624
|
+
const A = Math.max(n.startCol, o);
|
|
625
|
+
a === A && c.classList.add("first"), a === n.endCol && c.classList.add("last");
|
|
612
626
|
}
|
|
613
627
|
}
|
|
614
628
|
});
|
|
@@ -620,13 +634,13 @@ class K extends y {
|
|
|
620
634
|
if (!e) return;
|
|
621
635
|
const t = e.children[0], { mode: s } = this.config;
|
|
622
636
|
if (this.pendingKeyboardUpdate && s === "range") {
|
|
623
|
-
const { shiftKey:
|
|
637
|
+
const { shiftKey: l } = this.pendingKeyboardUpdate;
|
|
624
638
|
this.pendingKeyboardUpdate = null;
|
|
625
|
-
const
|
|
626
|
-
if (
|
|
627
|
-
const o =
|
|
639
|
+
const i = this.grid._focusRow, n = this.grid._focusCol;
|
|
640
|
+
if (l && this.cellAnchor) {
|
|
641
|
+
const o = b(this.cellAnchor, { row: i, col: n });
|
|
628
642
|
this.ranges = [o], this.activeRange = o;
|
|
629
|
-
} else
|
|
643
|
+
} else l || (this.ranges = [], this.activeRange = null, this.cellAnchor = { row: i, col: n });
|
|
630
644
|
this.emit("selection-change", this.#e());
|
|
631
645
|
}
|
|
632
646
|
this.grid.setAttribute("data-selection-mode", s), t && t.classList.toggle("selecting", this.isDragging), this.#t();
|
|
@@ -667,13 +681,13 @@ class K extends y {
|
|
|
667
681
|
* Get all selected cells across all ranges.
|
|
668
682
|
*/
|
|
669
683
|
getSelectedCells() {
|
|
670
|
-
return
|
|
684
|
+
return q(this.ranges);
|
|
671
685
|
}
|
|
672
686
|
/**
|
|
673
687
|
* Check if a specific cell is in range selection.
|
|
674
688
|
*/
|
|
675
689
|
isCellSelected(e, t) {
|
|
676
|
-
return
|
|
690
|
+
return C(e, t, this.ranges);
|
|
677
691
|
}
|
|
678
692
|
/**
|
|
679
693
|
* Clear all selection.
|
|
@@ -692,13 +706,13 @@ class K extends y {
|
|
|
692
706
|
endCol: t.to.col
|
|
693
707
|
})), this.activeRange = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null, this.emit("selection-change", {
|
|
694
708
|
mode: this.config.mode,
|
|
695
|
-
ranges:
|
|
709
|
+
ranges: p(this.ranges)
|
|
696
710
|
}), this.requestAfterRender();
|
|
697
711
|
}
|
|
698
712
|
// #endregion
|
|
699
713
|
// #region Private Helpers
|
|
700
714
|
#e() {
|
|
701
|
-
return
|
|
715
|
+
return K(
|
|
702
716
|
this.config.mode,
|
|
703
717
|
{
|
|
704
718
|
selectedCell: this.selectedCell,
|
|
@@ -711,6 +725,6 @@ class K extends y {
|
|
|
711
725
|
// #endregion
|
|
712
726
|
}
|
|
713
727
|
export {
|
|
714
|
-
|
|
728
|
+
D as SelectionPlugin
|
|
715
729
|
};
|
|
716
730
|
//# sourceMappingURL=index.js.map
|