@toolbox-web/grid 0.4.2 → 0.6.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/README.md +2 -3
- package/all.js +1063 -1024
- package/all.js.map +1 -1
- package/index.js +1078 -912
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +28 -0
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/dom-builder.d.ts +2 -0
- package/lib/core/internal/dom-builder.d.ts.map +1 -1
- package/lib/core/internal/event-delegation.d.ts +21 -0
- package/lib/core/internal/event-delegation.d.ts.map +1 -1
- package/lib/core/internal/header.d.ts.map +1 -1
- package/lib/core/internal/resize.d.ts.map +1 -1
- package/lib/core/internal/rows.d.ts +1 -1
- package/lib/core/internal/rows.d.ts.map +1 -1
- package/lib/core/internal/shell.d.ts +19 -13
- package/lib/core/internal/shell.d.ts.map +1 -1
- package/lib/core/plugin/base-plugin.d.ts +13 -2
- package/lib/core/plugin/base-plugin.d.ts.map +1 -1
- package/lib/core/plugin/expander-column.d.ts.map +1 -1
- package/lib/core/plugin/plugin-manager.d.ts +6 -2
- package/lib/core/plugin/plugin-manager.d.ts.map +1 -1
- package/lib/core/types.d.ts +41 -3
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +22 -11
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +59 -48
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +71 -60
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts +1 -0
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +93 -80
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js +29 -18
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts +9 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +199 -165
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts +1 -0
- package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts.map +1 -1
- package/lib/plugins/grouping-columns/index.js +79 -49
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/grouping-rows/index.js +98 -87
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +70 -57
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +48 -37
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts.map +1 -1
- package/lib/plugins/pinned-columns/index.js +71 -66
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-columns/pinned-columns.d.ts +2 -2
- package/lib/plugins/pinned-columns/pinned-columns.d.ts.map +1 -1
- package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/pinned-rows/index.js +63 -52
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/PivotPlugin.d.ts.map +1 -1
- package/lib/plugins/pivot/index.js +310 -299
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/ReorderPlugin.d.ts.map +1 -1
- package/lib/plugins/reorder/index.d.ts +1 -1
- package/lib/plugins/reorder/index.d.ts.map +1 -1
- package/lib/plugins/reorder/index.js +79 -68
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
- package/lib/plugins/selection/index.js +115 -105
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +15 -4
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/TreePlugin.d.ts.map +1 -1
- package/lib/plugins/tree/index.js +41 -30
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +29 -18
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/VisibilityPlugin.d.ts.map +1 -1
- package/lib/plugins/visibility/index.js +59 -47
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +6 -6
- package/public.d.ts +42 -0
- package/public.d.ts.map +1 -1
- package/themes/dg-theme-bootstrap.css +55 -53
- package/themes/dg-theme-contrast.css +42 -40
- package/themes/dg-theme-large.css +38 -37
- package/themes/dg-theme-material.css +54 -52
- package/themes/dg-theme-standard.css +19 -17
- package/themes/dg-theme-vibrant.css +16 -14
- package/umd/grid.all.umd.js +23 -22
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +15 -14
- package/umd/grid.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 -1
- package/umd/plugins/context-menu.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/grouping-columns.umd.js +1 -1
- package/umd/plugins/grouping-columns.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js +1 -1
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js +1 -1
- package/umd/plugins/master-detail.umd.js.map +1 -1
- package/umd/plugins/multi-sort.umd.js +1 -1
- 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 -1
- package/umd/plugins/pinned-rows.umd.js.map +1 -1
- package/umd/plugins/pivot.umd.js +1 -1
- package/umd/plugins/pivot.umd.js.map +1 -1
- package/umd/plugins/reorder.umd.js +1 -1
- package/umd/plugins/reorder.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +1 -1
- package/umd/plugins/selection.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js +1 -1
- package/umd/plugins/tree.umd.js.map +1 -1
- package/umd/plugins/visibility.umd.js +1 -1
- package/umd/plugins/visibility.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,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAU/F,OAAO,KAAK,EACV,SAAS,EAGT,eAAe,EAEf,eAAe,EAChB,MAAM,SAAS,CAAC;AAyCjB;;;;;;;GAOG;AACH,qBAAa,eAAgB,SAAQ,cAAc,CAAC,eAAe,CAAC;;IAClE,QAAQ,CAAC,IAAI,eAAe;IAC5B,SAAkB,MAAM,SAAU;IAElC,cAAuB,aAAa,IAAI,OAAO,CAAC,eAAe,CAAC,CAI/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;IAMxD,MAAM,IAAI,IAAI;IAcd,WAAW,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO;IAqF3C,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO;IA4FxC,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,GAAG,IAAI;IAyCtD,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,GAAG,IAAI;IA+BtD,aAAa,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"SelectionPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/selection/SelectionPlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAU/F,OAAO,KAAK,EACV,SAAS,EAGT,eAAe,EAEf,eAAe,EAChB,MAAM,SAAS,CAAC;AAyCjB;;;;;;;GAOG;AACH,qBAAa,eAAgB,SAAQ,cAAc,CAAC,eAAe,CAAC;;IAClE,QAAQ,CAAC,IAAI,eAAe;IAC5B,SAAkB,MAAM,SAAU;IAElC,cAAuB,aAAa,IAAI,OAAO,CAAC,eAAe,CAAC,CAI/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;IAMxD,MAAM,IAAI,IAAI;IAcd,WAAW,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO;IAqF3C,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO;IA4FxC,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,GAAG,IAAI;IAyCtD,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,GAAG,IAAI;IA+BtD,aAAa,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,GAAG,IAAI;IAuFrD,WAAW,IAAI,IAAI;IA0C5B;;;OAGG;IACM,cAAc,IAAI,IAAI;IAQ/B;;;;;;;;;;;;;;OAcG;IACH,YAAY,IAAI,eAAe;IAQ/B;;;OAGG;IACH,eAAe,IAAI;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAQtD;;;OAGG;IACH,eAAe,IAAI,MAAM,EAAE;IAQ3B;;;OAGG;IACH,SAAS,IAAI,SAAS,EAAE;IAIxB;;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,47 +1,47 @@
|
|
|
1
|
-
function x(
|
|
2
|
-
const
|
|
3
|
-
let o =
|
|
1
|
+
function x(r, e, t, s) {
|
|
2
|
+
const n = new Set(r.selected);
|
|
3
|
+
let o = r.anchor;
|
|
4
4
|
if (t === "single")
|
|
5
|
-
|
|
5
|
+
n.clear(), n.add(e), o = e;
|
|
6
6
|
else if (t === "multiple") {
|
|
7
7
|
const i = s.ctrlKey || s.metaKey;
|
|
8
|
-
if (s.shiftKey &&
|
|
9
|
-
const c = Math.min(
|
|
10
|
-
for (let
|
|
11
|
-
|
|
12
|
-
} else i ? (
|
|
8
|
+
if (s.shiftKey && r.anchor !== null) {
|
|
9
|
+
const c = Math.min(r.anchor, e), a = Math.max(r.anchor, e);
|
|
10
|
+
for (let d = c; d <= a; d++)
|
|
11
|
+
n.add(d);
|
|
12
|
+
} else i ? (n.has(e) ? n.delete(e) : n.add(e), o = e) : (n.clear(), n.add(e), o = e);
|
|
13
13
|
}
|
|
14
|
-
return { selected:
|
|
14
|
+
return { selected: n, lastSelected: e, anchor: o };
|
|
15
15
|
}
|
|
16
|
-
function _(
|
|
16
|
+
function _(r) {
|
|
17
17
|
const e = /* @__PURE__ */ new Set();
|
|
18
|
-
for (let t = 0; t <
|
|
18
|
+
for (let t = 0; t < r; t++)
|
|
19
19
|
e.add(t);
|
|
20
20
|
return e;
|
|
21
21
|
}
|
|
22
|
-
function D(
|
|
22
|
+
function D(r, e) {
|
|
23
23
|
const t = [], s = [];
|
|
24
|
-
for (const
|
|
25
|
-
|
|
26
|
-
for (const
|
|
27
|
-
e.has(
|
|
24
|
+
for (const n of e)
|
|
25
|
+
r.has(n) || t.push(n);
|
|
26
|
+
for (const n of r)
|
|
27
|
+
e.has(n) || s.push(n);
|
|
28
28
|
return { added: t, removed: s };
|
|
29
29
|
}
|
|
30
|
-
function b(
|
|
31
|
-
if (!
|
|
32
|
-
const e =
|
|
30
|
+
function b(r) {
|
|
31
|
+
if (!r) return -1;
|
|
32
|
+
const e = r.getAttribute("data-row");
|
|
33
33
|
if (e) return parseInt(e, 10);
|
|
34
|
-
const t =
|
|
34
|
+
const t = r.closest(".data-grid-row");
|
|
35
35
|
if (!t) return -1;
|
|
36
36
|
const s = t.parentElement;
|
|
37
37
|
if (!s) return -1;
|
|
38
|
-
const
|
|
39
|
-
for (let o = 0; o <
|
|
40
|
-
if (
|
|
38
|
+
const n = s.querySelectorAll(":scope > .data-grid-row");
|
|
39
|
+
for (let o = 0; o < n.length; o++)
|
|
40
|
+
if (n[o] === t) return o;
|
|
41
41
|
return -1;
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
43
|
+
function w(r) {
|
|
44
|
+
r && r.querySelectorAll(".cell-focus").forEach((e) => e.classList.remove("cell-focus"));
|
|
45
45
|
}
|
|
46
46
|
const p = {
|
|
47
47
|
expand: "▶",
|
|
@@ -230,10 +230,21 @@ class y {
|
|
|
230
230
|
return this.grid;
|
|
231
231
|
}
|
|
232
232
|
/**
|
|
233
|
-
* Get the
|
|
233
|
+
* Get the render root of the grid for DOM queries.
|
|
234
|
+
* @deprecated Use `gridElement` instead. This getter exists only for backward compatibility.
|
|
235
|
+
*
|
|
236
|
+
* With Shadow DOM removed, the grid element itself is the render root.
|
|
237
|
+
* All new code should use `this.gridElement` for DOM queries.
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* // OLD (deprecated)
|
|
241
|
+
* const rows = this.shadowRoot?.querySelector('.rows');
|
|
242
|
+
*
|
|
243
|
+
* // NEW (preferred)
|
|
244
|
+
* const rows = this.gridElement.querySelector('.rows');
|
|
234
245
|
*/
|
|
235
246
|
get shadowRoot() {
|
|
236
|
-
return this.
|
|
247
|
+
return this.gridElement;
|
|
237
248
|
}
|
|
238
249
|
/**
|
|
239
250
|
* Get the disconnect signal for event listener cleanup.
|
|
@@ -284,7 +295,7 @@ class y {
|
|
|
284
295
|
const e = this.grid?.effectiveConfig?.animation?.mode ?? "reduced-motion";
|
|
285
296
|
if (e === !1 || e === "off") return !1;
|
|
286
297
|
if (e === !0 || e === "on") return !0;
|
|
287
|
-
const t = this.
|
|
298
|
+
const t = this.gridElement;
|
|
288
299
|
return t ? getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim() !== "0" : !0;
|
|
289
300
|
}
|
|
290
301
|
/**
|
|
@@ -300,7 +311,7 @@ class y {
|
|
|
300
311
|
* ```
|
|
301
312
|
*/
|
|
302
313
|
get animationDuration() {
|
|
303
|
-
const e = this.
|
|
314
|
+
const e = this.gridElement;
|
|
304
315
|
if (e) {
|
|
305
316
|
const t = getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(), s = parseInt(t, 10);
|
|
306
317
|
if (!isNaN(s)) return s;
|
|
@@ -337,61 +348,61 @@ class y {
|
|
|
337
348
|
}
|
|
338
349
|
// #endregion
|
|
339
350
|
}
|
|
340
|
-
function
|
|
341
|
-
return
|
|
351
|
+
function h(r) {
|
|
352
|
+
return r.meta?.utility === !0;
|
|
342
353
|
}
|
|
343
|
-
function
|
|
354
|
+
function g(r) {
|
|
344
355
|
return {
|
|
345
|
-
startRow: Math.min(
|
|
346
|
-
startCol: Math.min(
|
|
347
|
-
endRow: Math.max(
|
|
348
|
-
endCol: Math.max(
|
|
356
|
+
startRow: Math.min(r.startRow, r.endRow),
|
|
357
|
+
startCol: Math.min(r.startCol, r.endCol),
|
|
358
|
+
endRow: Math.max(r.startRow, r.endRow),
|
|
359
|
+
endCol: Math.max(r.startCol, r.endCol)
|
|
349
360
|
};
|
|
350
361
|
}
|
|
351
|
-
function A(
|
|
352
|
-
const e =
|
|
362
|
+
function A(r) {
|
|
363
|
+
const e = g(r);
|
|
353
364
|
return {
|
|
354
365
|
from: { row: e.startRow, col: e.startCol },
|
|
355
366
|
to: { row: e.endRow, col: e.endCol }
|
|
356
367
|
};
|
|
357
368
|
}
|
|
358
|
-
function
|
|
359
|
-
return
|
|
369
|
+
function R(r) {
|
|
370
|
+
return r.map(A);
|
|
360
371
|
}
|
|
361
|
-
function v(
|
|
362
|
-
const s =
|
|
363
|
-
return
|
|
372
|
+
function v(r, e, t) {
|
|
373
|
+
const s = g(t);
|
|
374
|
+
return r >= s.startRow && r <= s.endRow && e >= s.startCol && e <= s.endCol;
|
|
364
375
|
}
|
|
365
|
-
function
|
|
366
|
-
return t.some((s) => v(
|
|
376
|
+
function m(r, e, t) {
|
|
377
|
+
return t.some((s) => v(r, e, s));
|
|
367
378
|
}
|
|
368
|
-
function S(
|
|
369
|
-
const e = [], t =
|
|
379
|
+
function S(r) {
|
|
380
|
+
const e = [], t = g(r);
|
|
370
381
|
for (let s = t.startRow; s <= t.endRow; s++)
|
|
371
|
-
for (let
|
|
372
|
-
e.push({ row: s, col:
|
|
382
|
+
for (let n = t.startCol; n <= t.endCol; n++)
|
|
383
|
+
e.push({ row: s, col: n });
|
|
373
384
|
return e;
|
|
374
385
|
}
|
|
375
|
-
function
|
|
386
|
+
function E(r) {
|
|
376
387
|
const e = /* @__PURE__ */ new Map();
|
|
377
|
-
for (const t of
|
|
388
|
+
for (const t of r)
|
|
378
389
|
for (const s of S(t))
|
|
379
390
|
e.set(`${s.row},${s.col}`, s);
|
|
380
391
|
return [...e.values()];
|
|
381
392
|
}
|
|
382
|
-
function
|
|
393
|
+
function u(r, e) {
|
|
383
394
|
return {
|
|
384
|
-
startRow:
|
|
385
|
-
startCol:
|
|
395
|
+
startRow: r.row,
|
|
396
|
+
startCol: r.col,
|
|
386
397
|
endRow: e.row,
|
|
387
398
|
endCol: e.col
|
|
388
399
|
};
|
|
389
400
|
}
|
|
390
|
-
const
|
|
391
|
-
function
|
|
392
|
-
if (
|
|
401
|
+
const I = "@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 .tbw-selection-summary{font-size:var(--tbw-font-size-sm, .8125rem);color:var(--tbw-color-fg-muted);white-space:nowrap}}";
|
|
402
|
+
function K(r, e, t) {
|
|
403
|
+
if (r === "cell" && e.selectedCell)
|
|
393
404
|
return {
|
|
394
|
-
mode:
|
|
405
|
+
mode: r,
|
|
395
406
|
ranges: [
|
|
396
407
|
{
|
|
397
408
|
from: { row: e.selectedCell.row, col: e.selectedCell.col },
|
|
@@ -399,18 +410,18 @@ function q(n, e, t) {
|
|
|
399
410
|
}
|
|
400
411
|
]
|
|
401
412
|
};
|
|
402
|
-
if (
|
|
403
|
-
const s = [...e.selected].map((
|
|
404
|
-
from: { row:
|
|
405
|
-
to: { row:
|
|
413
|
+
if (r === "row" && e.selected.size > 0) {
|
|
414
|
+
const s = [...e.selected].map((n) => ({
|
|
415
|
+
from: { row: n, col: 0 },
|
|
416
|
+
to: { row: n, col: t - 1 }
|
|
406
417
|
}));
|
|
407
|
-
return { mode:
|
|
418
|
+
return { mode: r, ranges: s };
|
|
408
419
|
}
|
|
409
|
-
return
|
|
420
|
+
return r === "range" && e.ranges.length > 0 ? { mode: r, ranges: R(e.ranges) } : { mode: r, ranges: [] };
|
|
410
421
|
}
|
|
411
422
|
class M extends y {
|
|
412
423
|
name = "selection";
|
|
413
|
-
styles =
|
|
424
|
+
styles = I;
|
|
414
425
|
get defaultConfig() {
|
|
415
426
|
return {
|
|
416
427
|
mode: "cell"
|
|
@@ -438,7 +449,7 @@ class M extends y {
|
|
|
438
449
|
// #endregion
|
|
439
450
|
// #region Event Handlers
|
|
440
451
|
onCellClick(e) {
|
|
441
|
-
const { rowIndex: t, colIndex: s, originalEvent:
|
|
452
|
+
const { rowIndex: t, colIndex: s, originalEvent: n } = e, { mode: o } = this.config, i = this.columns[s], c = i && h(i);
|
|
442
453
|
if (o === "cell")
|
|
443
454
|
return c || (this.selectedCell = { row: t, col: s }, this.emit("selection-change", this.#e()), this.requestAfterRender()), !1;
|
|
444
455
|
if (o === "row")
|
|
@@ -446,11 +457,11 @@ class M extends y {
|
|
|
446
457
|
if (o === "range") {
|
|
447
458
|
if (c)
|
|
448
459
|
return !1;
|
|
449
|
-
const a =
|
|
460
|
+
const a = n.shiftKey, d = n.ctrlKey || n.metaKey;
|
|
450
461
|
if (a && this.cellAnchor) {
|
|
451
|
-
const l =
|
|
452
|
-
|
|
453
|
-
} else if (
|
|
462
|
+
const l = u(this.cellAnchor, { row: t, col: s });
|
|
463
|
+
d ? this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = l : this.ranges.push(l) : this.ranges = [l], this.activeRange = l;
|
|
464
|
+
} else if (d) {
|
|
454
465
|
const l = {
|
|
455
466
|
startRow: t,
|
|
456
467
|
startCol: s,
|
|
@@ -472,10 +483,10 @@ class M extends y {
|
|
|
472
483
|
return !1;
|
|
473
484
|
}
|
|
474
485
|
onKeyDown(e) {
|
|
475
|
-
const { mode: t } = this.config,
|
|
486
|
+
const { mode: t } = this.config, n = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Tab", "Home", "End", "PageUp", "PageDown"].includes(e.key);
|
|
476
487
|
if (e.key === "Escape")
|
|
477
488
|
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;
|
|
478
|
-
if (t === "cell" &&
|
|
489
|
+
if (t === "cell" && n)
|
|
479
490
|
return queueMicrotask(() => {
|
|
480
491
|
this.selectedCell = { row: this.grid._focusRow, col: this.grid._focusCol }, this.emit("selection-change", this.#e()), this.requestAfterRender();
|
|
481
492
|
}), !1;
|
|
@@ -483,7 +494,7 @@ class M extends y {
|
|
|
483
494
|
return queueMicrotask(() => {
|
|
484
495
|
this.selected.clear(), this.selected.add(this.grid._focusRow), this.lastSelected = this.grid._focusRow, this.emit("selection-change", this.#e()), this.requestAfterRender();
|
|
485
496
|
}), !1;
|
|
486
|
-
if (t === "range" &&
|
|
497
|
+
if (t === "range" && n) {
|
|
487
498
|
const o = e.key === "Tab", i = e.shiftKey && !o;
|
|
488
499
|
return i && !this.cellAnchor && (this.cellAnchor = { row: this.grid._focusRow, col: this.grid._focusCol }), this.pendingKeyboardUpdate = { shiftKey: i }, queueMicrotask(() => this.requestAfterRender()), !1;
|
|
489
500
|
}
|
|
@@ -504,16 +515,16 @@ class M extends y {
|
|
|
504
515
|
onCellMouseDown(e) {
|
|
505
516
|
if (this.config.mode !== "range" || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
|
|
506
517
|
const t = this.columns[e.colIndex];
|
|
507
|
-
if (t &&
|
|
518
|
+
if (t && h(t) || e.originalEvent.shiftKey && this.cellAnchor)
|
|
508
519
|
return;
|
|
509
520
|
this.isDragging = !0;
|
|
510
|
-
const s = e.rowIndex,
|
|
511
|
-
this.cellAnchor = { row: s, col:
|
|
521
|
+
const s = e.rowIndex, n = e.colIndex;
|
|
522
|
+
this.cellAnchor = { row: s, col: n }, e.originalEvent.ctrlKey || e.originalEvent.metaKey || (this.ranges = []);
|
|
512
523
|
const i = {
|
|
513
524
|
startRow: s,
|
|
514
|
-
startCol:
|
|
525
|
+
startCol: n,
|
|
515
526
|
endRow: s,
|
|
516
|
-
endCol:
|
|
527
|
+
endCol: n
|
|
517
528
|
};
|
|
518
529
|
return this.ranges.push(i), this.activeRange = i, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0;
|
|
519
530
|
}
|
|
@@ -521,12 +532,12 @@ class M extends y {
|
|
|
521
532
|
if (this.config.mode !== "range" || !this.isDragging || !this.cellAnchor || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
|
|
522
533
|
let t = e.colIndex;
|
|
523
534
|
const s = this.columns[t];
|
|
524
|
-
if (s &&
|
|
525
|
-
const o = this.columns.findIndex((i) => !
|
|
535
|
+
if (s && h(s)) {
|
|
536
|
+
const o = this.columns.findIndex((i) => !h(i));
|
|
526
537
|
o >= 0 && (t = o);
|
|
527
538
|
}
|
|
528
|
-
const
|
|
529
|
-
return this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] =
|
|
539
|
+
const n = u(this.cellAnchor, { row: e.rowIndex, col: t });
|
|
540
|
+
return this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = n : this.ranges.push(n), this.activeRange = n, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0;
|
|
530
541
|
}
|
|
531
542
|
onCellMouseUp(e) {
|
|
532
543
|
if (this.config.mode === "range" && this.isDragging)
|
|
@@ -537,49 +548,48 @@ class M extends y {
|
|
|
537
548
|
* Shared by afterRender and onScrollRender.
|
|
538
549
|
*/
|
|
539
550
|
#t() {
|
|
540
|
-
const e = this.
|
|
551
|
+
const e = this.gridElement;
|
|
541
552
|
if (!e) return;
|
|
542
553
|
const { mode: t } = this.config;
|
|
543
554
|
e.querySelectorAll(".cell").forEach((o) => {
|
|
544
555
|
o.classList.remove("selected", "top", "bottom", "first", "last");
|
|
545
556
|
});
|
|
546
|
-
const
|
|
547
|
-
if (
|
|
557
|
+
const n = e.querySelectorAll(".data-grid-row");
|
|
558
|
+
if (n.forEach((o) => {
|
|
548
559
|
o.classList.remove("selected", "row-focus");
|
|
549
|
-
}), t === "row" && (
|
|
560
|
+
}), t === "row" && (w(e), n.forEach((o) => {
|
|
550
561
|
const i = o.querySelector(".cell[data-row]"), c = b(i);
|
|
551
562
|
c >= 0 && this.selected.has(c) && o.classList.add("selected", "row-focus");
|
|
552
563
|
})), t === "range" && this.ranges.length > 0) {
|
|
553
|
-
|
|
554
|
-
const o = this.activeRange ?
|
|
564
|
+
w(e);
|
|
565
|
+
const o = this.activeRange ? g(this.activeRange) : null, i = this.columns.findIndex((a) => !h(a));
|
|
555
566
|
this.columns.length - 1, e.querySelectorAll(".cell[data-row][data-col]").forEach((a) => {
|
|
556
|
-
const
|
|
557
|
-
if (
|
|
558
|
-
const
|
|
559
|
-
if (
|
|
567
|
+
const d = parseInt(a.getAttribute("data-row") ?? "-1", 10), l = parseInt(a.getAttribute("data-col") ?? "-1", 10);
|
|
568
|
+
if (d >= 0 && l >= 0) {
|
|
569
|
+
const f = this.columns[l];
|
|
570
|
+
if (f && h(f))
|
|
560
571
|
return;
|
|
561
|
-
if (
|
|
562
|
-
|
|
572
|
+
if (m(d, l, this.ranges) && (a.classList.add("selected"), o)) {
|
|
573
|
+
d === o.startRow && a.classList.add("top"), d === o.endRow && a.classList.add("bottom");
|
|
563
574
|
const C = Math.max(o.startCol, i);
|
|
564
575
|
l === C && a.classList.add("first"), l === o.endCol && a.classList.add("last");
|
|
565
576
|
}
|
|
566
577
|
}
|
|
567
578
|
});
|
|
568
579
|
}
|
|
569
|
-
t === "cell" && this.selectedCell && g(e);
|
|
570
580
|
}
|
|
571
581
|
afterRender() {
|
|
572
|
-
const e = this.
|
|
582
|
+
const e = this.gridElement;
|
|
573
583
|
if (!e) return;
|
|
574
584
|
const t = e.children[0], { mode: s } = this.config;
|
|
575
585
|
if (this.pendingKeyboardUpdate && s === "range") {
|
|
576
|
-
const { shiftKey:
|
|
586
|
+
const { shiftKey: n } = this.pendingKeyboardUpdate;
|
|
577
587
|
this.pendingKeyboardUpdate = null;
|
|
578
588
|
const o = this.grid._focusRow, i = this.grid._focusCol;
|
|
579
|
-
if (
|
|
580
|
-
const c =
|
|
589
|
+
if (n && this.cellAnchor) {
|
|
590
|
+
const c = u(this.cellAnchor, { row: o, col: i });
|
|
581
591
|
this.ranges = [c], this.activeRange = c;
|
|
582
|
-
} else
|
|
592
|
+
} else n || (this.ranges = [], this.activeRange = null, this.cellAnchor = { row: o, col: i });
|
|
583
593
|
this.emit("selection-change", this.#e());
|
|
584
594
|
}
|
|
585
595
|
this.grid.setAttribute("data-selection-mode", s), t && t.classList.toggle("selecting", this.isDragging), this.#t();
|
|
@@ -642,13 +652,13 @@ class M extends y {
|
|
|
642
652
|
* Get all selected cells across all ranges.
|
|
643
653
|
*/
|
|
644
654
|
getSelectedCells() {
|
|
645
|
-
return
|
|
655
|
+
return E(this.ranges);
|
|
646
656
|
}
|
|
647
657
|
/**
|
|
648
658
|
* Check if a specific cell is in range selection.
|
|
649
659
|
*/
|
|
650
660
|
isCellSelected(e, t) {
|
|
651
|
-
return
|
|
661
|
+
return m(e, t, this.ranges);
|
|
652
662
|
}
|
|
653
663
|
/**
|
|
654
664
|
* Clear all selection.
|
|
@@ -667,13 +677,13 @@ class M extends y {
|
|
|
667
677
|
endCol: t.to.col
|
|
668
678
|
})), this.activeRange = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null, this.emit("selection-change", {
|
|
669
679
|
mode: this.config.mode,
|
|
670
|
-
ranges:
|
|
680
|
+
ranges: R(this.ranges)
|
|
671
681
|
}), this.requestAfterRender();
|
|
672
682
|
}
|
|
673
683
|
// #endregion
|
|
674
684
|
// #region Private Helpers
|
|
675
685
|
#e() {
|
|
676
|
-
return
|
|
686
|
+
return K(
|
|
677
687
|
this.config.mode,
|
|
678
688
|
{
|
|
679
689
|
selectedCell: this.selectedCell,
|