@toolbox-web/grid 0.0.7 → 0.1.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.
Files changed (86) hide show
  1. package/all.d.ts +151 -95
  2. package/all.js +1554 -1452
  3. package/all.js.map +1 -1
  4. package/custom-elements.json +89 -7
  5. package/index.d.ts +68 -23
  6. package/index.js +1066 -948
  7. package/index.js.map +1 -1
  8. package/lib/plugins/clipboard/index.js +48 -49
  9. package/lib/plugins/clipboard/index.js.map +1 -1
  10. package/lib/plugins/column-virtualization/index.js +6 -6
  11. package/lib/plugins/column-virtualization/index.js.map +1 -1
  12. package/lib/plugins/context-menu/index.js +32 -34
  13. package/lib/plugins/context-menu/index.js.map +1 -1
  14. package/lib/plugins/export/index.js +7 -7
  15. package/lib/plugins/export/index.js.map +1 -1
  16. package/lib/plugins/filtering/index.js +5 -38
  17. package/lib/plugins/filtering/index.js.map +1 -1
  18. package/lib/plugins/grouping-columns/index.js +4 -32
  19. package/lib/plugins/grouping-columns/index.js.map +1 -1
  20. package/lib/plugins/grouping-rows/index.js +8 -45
  21. package/lib/plugins/grouping-rows/index.js.map +1 -1
  22. package/lib/plugins/master-detail/index.js +6 -30
  23. package/lib/plugins/master-detail/index.js.map +1 -1
  24. package/lib/plugins/multi-sort/index.js +19 -42
  25. package/lib/plugins/multi-sort/index.js.map +1 -1
  26. package/lib/plugins/pinned-columns/index.js +5 -6
  27. package/lib/plugins/pinned-columns/index.js.map +1 -1
  28. package/lib/plugins/pinned-rows/index.js +6 -80
  29. package/lib/plugins/pinned-rows/index.js.map +1 -1
  30. package/lib/plugins/pivot/index.js +673 -145
  31. package/lib/plugins/pivot/index.js.map +1 -1
  32. package/lib/plugins/reorder/index.js +22 -51
  33. package/lib/plugins/reorder/index.js.map +1 -1
  34. package/lib/plugins/selection/index.js +53 -83
  35. package/lib/plugins/selection/index.js.map +1 -1
  36. package/lib/plugins/server-side/index.js +2 -2
  37. package/lib/plugins/server-side/index.js.map +1 -1
  38. package/lib/plugins/tree/index.js +6 -14
  39. package/lib/plugins/tree/index.js.map +1 -1
  40. package/lib/plugins/undo-redo/index.js +2 -3
  41. package/lib/plugins/undo-redo/index.js.map +1 -1
  42. package/lib/plugins/visibility/index.js +13 -105
  43. package/lib/plugins/visibility/index.js.map +1 -1
  44. package/package.json +1 -1
  45. package/themes/dg-theme-bootstrap.css +73 -0
  46. package/themes/dg-theme-material.css +71 -0
  47. package/umd/grid.all.umd.js +40 -415
  48. package/umd/grid.all.umd.js.map +1 -1
  49. package/umd/grid.umd.js +29 -60
  50. package/umd/grid.umd.js.map +1 -1
  51. package/umd/plugins/clipboard.umd.js +4 -4
  52. package/umd/plugins/clipboard.umd.js.map +1 -1
  53. package/umd/plugins/column-virtualization.umd.js +1 -1
  54. package/umd/plugins/column-virtualization.umd.js.map +1 -1
  55. package/umd/plugins/context-menu.umd.js +2 -2
  56. package/umd/plugins/context-menu.umd.js.map +1 -1
  57. package/umd/plugins/export.umd.js +1 -1
  58. package/umd/plugins/export.umd.js.map +1 -1
  59. package/umd/plugins/filtering.umd.js +2 -34
  60. package/umd/plugins/filtering.umd.js.map +1 -1
  61. package/umd/plugins/grouping-columns.umd.js +1 -28
  62. package/umd/plugins/grouping-columns.umd.js.map +1 -1
  63. package/umd/plugins/grouping-rows.umd.js +1 -39
  64. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  65. package/umd/plugins/master-detail.umd.js +1 -26
  66. package/umd/plugins/master-detail.umd.js.map +1 -1
  67. package/umd/plugins/multi-sort.umd.js +1 -25
  68. package/umd/plugins/multi-sort.umd.js.map +1 -1
  69. package/umd/plugins/pinned-columns.umd.js +1 -1
  70. package/umd/plugins/pinned-columns.umd.js.map +1 -1
  71. package/umd/plugins/pinned-rows.umd.js +1 -72
  72. package/umd/plugins/pinned-rows.umd.js.map +1 -1
  73. package/umd/plugins/pivot.umd.js +1 -7
  74. package/umd/plugins/pivot.umd.js.map +1 -1
  75. package/umd/plugins/reorder.umd.js +1 -30
  76. package/umd/plugins/reorder.umd.js.map +1 -1
  77. package/umd/plugins/selection.umd.js +1 -33
  78. package/umd/plugins/selection.umd.js.map +1 -1
  79. package/umd/plugins/server-side.umd.js +1 -1
  80. package/umd/plugins/server-side.umd.js.map +1 -1
  81. package/umd/plugins/tree.umd.js +1 -10
  82. package/umd/plugins/tree.umd.js.map +1 -1
  83. package/umd/plugins/undo-redo.umd.js +1 -1
  84. package/umd/plugins/undo-redo.umd.js.map +1 -1
  85. package/umd/plugins/visibility.umd.js +1 -93
  86. 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 d(s) {
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,24 +172,24 @@ function d(s) {
171
172
  };
172
173
  }
173
174
  function R(s) {
174
- const e = d(s);
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 h(s) {
181
+ function d(s) {
181
182
  return s.map(R);
182
183
  }
183
184
  function C(s, e, t) {
184
- const r = d(t);
185
+ const r = h(t);
185
186
  return s >= r.startRow && s <= r.endRow && e >= r.startCol && e <= r.endCol;
186
187
  }
187
188
  function g(s, e, t) {
188
189
  return t.some((r) => C(s, e, r));
189
190
  }
190
191
  function m(s) {
191
- const e = [], t = d(s);
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 });
@@ -209,7 +210,8 @@ function u(s, e) {
209
210
  endCol: e.col
210
211
  };
211
212
  }
212
- function A(s, e, t) {
213
+ const A = ':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,9 +229,9 @@ 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: h(e.ranges) } : { mode: s, ranges: [] };
232
+ return s === "range" && e.ranges.length > 0 ? { mode: s, ranges: d(e.ranges) } : { mode: s, ranges: [] };
231
233
  }
232
- class v extends w {
234
+ class y extends w {
233
235
  name = "selection";
234
236
  version = "1.0.0";
235
237
  get defaultConfig() {
@@ -255,32 +257,32 @@ class v extends w {
255
257
  }
256
258
  // ===== Event Handlers =====
257
259
  onCellClick(e) {
258
- const { rowIndex: t, colIndex: r, originalEvent: n } = e, { mode: o } = this.config;
259
- if (o === "cell")
260
+ const { rowIndex: t, colIndex: r, originalEvent: n } = e, { mode: l } = this.config;
261
+ if (l === "cell")
260
262
  return this.selectedCell = { row: t, col: r }, this.emit("selection-change", this.#e()), this.requestAfterRender(), !1;
261
- if (o === "row")
263
+ if (l === "row")
262
264
  return this.selected.clear(), this.selected.add(t), this.lastSelected = t, this.emit("selection-change", this.#e()), this.requestAfterRender(), !1;
263
- if (o === "range") {
265
+ if (l === "range") {
264
266
  const a = n.shiftKey, i = n.ctrlKey || n.metaKey;
265
267
  if (a && this.cellAnchor) {
266
- const l = u(this.cellAnchor, { row: t, col: r });
267
- i ? this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = l : this.ranges.push(l) : this.ranges = [l], this.activeRange = l;
268
+ const o = u(this.cellAnchor, { row: t, col: r });
269
+ i ? this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = o : this.ranges.push(o) : this.ranges = [o], this.activeRange = o;
268
270
  } else if (i) {
269
- const l = {
271
+ const o = {
270
272
  startRow: t,
271
273
  startCol: r,
272
274
  endRow: t,
273
275
  endCol: r
274
276
  };
275
- this.ranges.push(l), this.activeRange = l, this.cellAnchor = { row: t, col: r };
277
+ this.ranges.push(o), this.activeRange = o, this.cellAnchor = { row: t, col: r };
276
278
  } else {
277
- const l = {
279
+ const o = {
278
280
  startRow: t,
279
281
  startCol: r,
280
282
  endRow: t,
281
283
  endCol: r
282
284
  };
283
- this.ranges = [l], this.activeRange = l, this.cellAnchor = { row: t, col: r };
285
+ this.ranges = [o], this.activeRange = o, this.cellAnchor = { row: t, col: r };
284
286
  }
285
287
  return this.emit("selection-change", this.#e()), this.requestAfterRender(), !1;
286
288
  }
@@ -293,13 +295,13 @@ class v extends w {
293
295
  if (t === "range" && e.key === "a" && (e.ctrlKey || e.metaKey)) {
294
296
  const r = this.rows.length, n = this.columns.length;
295
297
  if (r > 0 && n > 0) {
296
- const o = {
298
+ const l = {
297
299
  startRow: 0,
298
300
  startCol: 0,
299
301
  endRow: r - 1,
300
302
  endCol: n - 1
301
303
  };
302
- return this.ranges = [o], this.activeRange = o, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0;
304
+ return this.ranges = [l], this.activeRange = l, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0;
303
305
  }
304
306
  }
305
307
  return !1;
@@ -310,13 +312,13 @@ class v extends w {
310
312
  this.isDragging = !0;
311
313
  const t = e.rowIndex, r = e.colIndex;
312
314
  this.cellAnchor = { row: t, col: r }, e.originalEvent.ctrlKey || e.originalEvent.metaKey || (this.ranges = []);
313
- const o = {
315
+ const l = {
314
316
  startRow: t,
315
317
  startCol: r,
316
318
  endRow: t,
317
319
  endCol: r
318
320
  };
319
- return this.ranges.push(o), this.activeRange = o, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0;
321
+ return this.ranges.push(l), this.activeRange = l, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0;
320
322
  }
321
323
  onCellMouseMove(e) {
322
324
  if (this.config.mode !== "range" || !this.isDragging || !this.cellAnchor || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
@@ -335,23 +337,23 @@ class v extends w {
335
337
  const e = this.shadowRoot;
336
338
  if (!e) return;
337
339
  const { mode: t } = this.config;
338
- e.querySelectorAll(".cell").forEach((o) => {
339
- o.classList.remove("selected", "top", "bottom", "first", "last");
340
+ e.querySelectorAll(".cell").forEach((l) => {
341
+ l.classList.remove("selected", "top", "bottom", "first", "last");
340
342
  });
341
343
  const n = e.querySelectorAll(".data-grid-row");
342
- if (n.forEach((o) => {
343
- o.classList.remove("selected", "row-focus");
344
- }), t === "row" && n.forEach((o) => {
345
- const a = o.querySelector(".cell[data-row]"), i = parseInt(a?.getAttribute("data-row") ?? "-1", 10);
346
- i >= 0 && this.selected.has(i) && (o.classList.add("selected", "row-focus"), o.querySelectorAll(".cell-focus").forEach((l) => l.classList.remove("cell-focus")));
344
+ if (n.forEach((l) => {
345
+ l.classList.remove("selected", "row-focus");
346
+ }), t === "row" && n.forEach((l) => {
347
+ const a = l.querySelector(".cell[data-row]"), i = parseInt(a?.getAttribute("data-row") ?? "-1", 10);
348
+ i >= 0 && this.selected.has(i) && (l.classList.add("selected", "row-focus"), l.querySelectorAll(".cell-focus").forEach((o) => o.classList.remove("cell-focus")));
347
349
  }), t === "range" && this.ranges.length > 0) {
348
- const o = this.activeRange ? d(this.activeRange) : null;
350
+ const l = this.activeRange ? h(this.activeRange) : null;
349
351
  e.querySelectorAll(".cell[data-row][data-col]").forEach((i) => {
350
- const l = parseInt(i.getAttribute("data-row") ?? "-1", 10), c = parseInt(i.getAttribute("data-col") ?? "-1", 10);
351
- l >= 0 && c >= 0 && g(l, c, this.ranges) && (i.classList.add("selected"), i.classList.remove("cell-focus"), o && (l === o.startRow && i.classList.add("top"), l === o.endRow && i.classList.add("bottom"), c === o.startCol && i.classList.add("first"), c === o.endCol && i.classList.add("last")));
352
+ const o = parseInt(i.getAttribute("data-row") ?? "-1", 10), c = parseInt(i.getAttribute("data-col") ?? "-1", 10);
353
+ o >= 0 && c >= 0 && g(o, c, this.ranges) && (i.classList.add("selected"), i.classList.remove("cell-focus"), l && (o === l.startRow && i.classList.add("top"), o === l.endRow && i.classList.add("bottom"), c === l.startCol && i.classList.add("first"), c === l.endCol && i.classList.add("last")));
352
354
  });
353
355
  }
354
- t === "cell" && this.selectedCell && e.querySelectorAll(".cell-focus").forEach((o) => o.classList.remove("cell-focus"));
356
+ t === "cell" && this.selectedCell && e.querySelectorAll(".cell-focus").forEach((l) => l.classList.remove("cell-focus"));
355
357
  }
356
358
  afterRender() {
357
359
  const e = this.shadowRoot;
@@ -383,7 +385,7 @@ class v extends w {
383
385
  * Get all selected cell ranges in public format.
384
386
  */
385
387
  getRanges() {
386
- return h(this.ranges);
388
+ return d(this.ranges);
387
389
  }
388
390
  /**
389
391
  * Get all selected cells across all ranges.
@@ -414,12 +416,12 @@ class v extends w {
414
416
  endCol: t.to.col
415
417
  })), this.activeRange = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null, this.emit("selection-change", {
416
418
  mode: this.config.mode,
417
- ranges: h(this.ranges)
419
+ ranges: d(this.ranges)
418
420
  }), this.requestAfterRender();
419
421
  }
420
422
  // ===== Private Helpers =====
421
423
  #e() {
422
- return A(
424
+ return p(
423
425
  this.config.mode,
424
426
  {
425
427
  selectedCell: this.selectedCell,
@@ -430,62 +432,30 @@ class v extends w {
430
432
  );
431
433
  }
432
434
  // ===== 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
- `;
435
+ styles = A;
466
436
  }
467
- function y(s, e, t, r) {
437
+ function S(s, e, t, r) {
468
438
  const n = new Set(s.selected);
469
- let o = s.anchor;
439
+ let l = s.anchor;
470
440
  if (t === "single")
471
- n.clear(), n.add(e), o = e;
441
+ n.clear(), n.add(e), l = e;
472
442
  else if (t === "multiple") {
473
443
  const a = r.ctrlKey || r.metaKey;
474
444
  if (r.shiftKey && s.anchor !== null) {
475
- const i = Math.min(s.anchor, e), l = Math.max(s.anchor, e);
476
- for (let c = i; c <= l; c++)
445
+ const i = Math.min(s.anchor, e), o = Math.max(s.anchor, e);
446
+ for (let c = i; c <= o; c++)
477
447
  n.add(c);
478
- } else a ? (n.has(e) ? n.delete(e) : n.add(e), o = e) : (n.clear(), n.add(e), o = e);
448
+ } else a ? (n.has(e) ? n.delete(e) : n.add(e), l = e) : (n.clear(), n.add(e), l = e);
479
449
  }
480
- return { selected: n, lastSelected: e, anchor: o };
450
+ return { selected: n, lastSelected: e, anchor: l };
481
451
  }
482
- function S(s) {
452
+ function I(s) {
483
453
  const e = /* @__PURE__ */ new Set();
484
454
  for (let t = 0; t < s; t++)
485
455
  e.add(t);
486
456
  return e;
487
457
  }
488
- function I(s, e) {
458
+ function q(s, e) {
489
459
  const t = [], r = [];
490
460
  for (const n of e)
491
461
  s.has(n) || t.push(n);
@@ -494,9 +464,9 @@ function I(s, e) {
494
464
  return { added: t, removed: r };
495
465
  }
496
466
  export {
497
- v as SelectionPlugin,
498
- I as computeSelectionDiff,
499
- y as handleRowClick,
500
- S as selectAll
467
+ y as SelectionPlugin,
468
+ q as computeSelectionDiff,
469
+ S as handleRowClick,
470
+ I as selectAll
501
471
  };
502
472
  //# sourceMappingURL=index.js.map