@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 b = {
5
5
  sortDesc: "▼",
6
6
  sortNone: "⇅",
7
7
  submenuArrow: "▶",
8
- dragHandle: "⋮⋮"
8
+ dragHandle: "⋮⋮",
9
+ toolPanel: "☰"
9
10
  };
10
11
  class I {
11
12
  /** Plugin version - override in subclass if needed */
@@ -162,23 +163,23 @@ class I {
162
163
  console.warn(`[tbw-grid:${this.name}] ${e}`);
163
164
  }
164
165
  }
165
- function T(f, e, t, n) {
166
+ function T(h, e, t, n) {
166
167
  if (n.processCell)
167
- return n.processCell(f, e, t);
168
- if (f == null) return "";
169
- if (f instanceof Date) return f.toISOString();
170
- if (typeof f == "object") return JSON.stringify(f);
171
- const i = String(f), l = n.delimiter ?? " ", r = n.newline ?? `
168
+ return n.processCell(h, e, t);
169
+ if (h == null) return "";
170
+ if (h instanceof Date) return h.toISOString();
171
+ if (typeof h == "object") return JSON.stringify(h);
172
+ const i = String(h), l = n.delimiter ?? " ", o = n.newline ?? `
172
173
  `;
173
- return n.quoteStrings || i.includes(l) || i.includes(r) || i.includes('"') ? `"${i.replace(/"/g, '""')}"` : i;
174
+ return n.quoteStrings || i.includes(l) || i.includes(o) || i.includes('"') ? `"${i.replace(/"/g, '""')}"` : i;
174
175
  }
175
- function p(f) {
176
- const { rows: e, columns: t, selectedIndices: n, config: i } = f, l = i.delimiter ?? " ", r = i.newline ?? `
177
- `, o = t.filter((s) => !s.hidden && !s.field.startsWith("__")), c = [];
176
+ function p(h) {
177
+ const { rows: e, columns: t, selectedIndices: n, config: i } = h, l = i.delimiter ?? " ", o = i.newline ?? `
178
+ `, r = t.filter((s) => !s.hidden && !s.field.startsWith("__")), c = [];
178
179
  if (i.includeHeaders) {
179
- const s = o.map((d) => {
180
- const h = d.header || d.field;
181
- return h.includes(l) || h.includes(r) || h.includes('"') ? `"${h.replace(/"/g, '""')}"` : h;
180
+ const s = r.map((d) => {
181
+ const f = d.header || d.field;
182
+ return f.includes(l) || f.includes(o) || f.includes('"') ? `"${f.replace(/"/g, '""')}"` : f;
182
183
  });
183
184
  c.push(s.join(l));
184
185
  }
@@ -186,34 +187,34 @@ function p(f) {
186
187
  for (const s of u) {
187
188
  const d = e[s];
188
189
  if (!d) continue;
189
- const h = o.map(
190
+ const f = r.map(
190
191
  (g) => T(d[g.field], g.field, d, i)
191
192
  );
192
- c.push(h.join(l));
193
+ c.push(f.join(l));
193
194
  }
194
- return c.join(r);
195
+ return c.join(o);
195
196
  }
196
- async function C(f) {
197
+ async function C(h) {
197
198
  try {
198
- return await navigator.clipboard.writeText(f), !0;
199
+ return await navigator.clipboard.writeText(h), !0;
199
200
  } catch {
200
201
  const e = document.createElement("textarea");
201
- e.value = f, e.style.position = "fixed", e.style.opacity = "0", e.style.pointerEvents = "none", document.body.appendChild(e), e.select();
202
+ e.value = h, e.style.position = "fixed", e.style.opacity = "0", e.style.pointerEvents = "none", document.body.appendChild(e), e.select();
202
203
  const t = document.execCommand("copy");
203
204
  return document.body.removeChild(e), t;
204
205
  }
205
206
  }
206
- function y(f, e) {
207
+ function y(h, e) {
207
208
  const t = e.delimiter ?? " ", n = e.newline ?? `
208
- `, i = f.replace(/\r\n/g, `
209
+ `, i = h.replace(/\r\n/g, `
209
210
  `).replace(/\r/g, `
210
211
  `), l = [];
211
- let r = [], o = "", c = !1;
212
+ let o = [], r = "", c = !1;
212
213
  for (let a = 0; a < i.length; a++) {
213
214
  const u = i[a];
214
- u === '"' && !c ? c = !0 : u === '"' && c ? i[a + 1] === '"' ? (o += '"', a++) : c = !1 : u === t && !c ? (r.push(o), o = "") : u === n && !c ? (r.push(o), o = "", (r.length > 1 || r.some((s) => s.trim() !== "")) && l.push(r), r = []) : o += u;
215
+ u === '"' && !c ? c = !0 : u === '"' && c ? i[a + 1] === '"' ? (r += '"', a++) : c = !1 : u === t && !c ? (o.push(r), r = "") : u === n && !c ? (o.push(r), r = "", (o.length > 1 || o.some((s) => s.trim() !== "")) && l.push(o), o = []) : r += u;
215
216
  }
216
- return r.push(o), (r.length > 1 || r.some((a) => a.trim() !== "")) && l.push(r), l;
217
+ return o.push(r), (o.length > 1 || o.some((a) => a.trim() !== "")) && l.push(o), l;
217
218
  }
218
219
  async function x() {
219
220
  try {
@@ -227,7 +228,6 @@ class D extends I {
227
228
  version = "1.0.0";
228
229
  get defaultConfig() {
229
230
  return {
230
- enabled: !0,
231
231
  includeHeaders: !1,
232
232
  delimiter: " ",
233
233
  newline: `
@@ -244,7 +244,6 @@ class D extends I {
244
244
  }
245
245
  // ===== Event Handlers =====
246
246
  onKeyDown(e) {
247
- if (this.config.enabled === !1) return !1;
248
247
  const t = (e.ctrlKey || e.metaKey) && e.key === "c", n = (e.ctrlKey || e.metaKey) && e.key === "v";
249
248
  return t ? (this.#t(e.target), !0) : n ? (this.#n(), !0) : !1;
250
249
  }
@@ -253,7 +252,7 @@ class D extends I {
253
252
  * Handle copy operation
254
253
  */
255
254
  #t(e) {
256
- const t = this.#e(), n = t?.getSelectedRows() ?? [], i = n.length > 0, l = t?.getRanges() ?? [], r = l.length > 0, o = t?.getSelectedCell() != null;
255
+ const t = this.#e(), n = t?.getSelectedRows() ?? [], i = n.length > 0, l = t?.getRanges() ?? [], o = l.length > 0, r = t?.getSelectedCell() != null;
257
256
  let c, a, u;
258
257
  if (i && t)
259
258
  c = p({
@@ -262,7 +261,7 @@ class D extends I {
262
261
  selectedIndices: n,
263
262
  config: this.config
264
263
  }), a = n.length, u = this.columns.filter((s) => !s.hidden && !s.field.startsWith("__")).length;
265
- else if (r && t) {
264
+ else if (o && t) {
266
265
  const s = l[l.length - 1], d = this.#i({
267
266
  startRow: s.from.row,
268
267
  startCol: s.from.col,
@@ -270,12 +269,12 @@ class D extends I {
270
269
  endCol: s.to.col
271
270
  });
272
271
  c = d.text, a = d.rowCount, u = d.columnCount;
273
- } else if (o && t) {
272
+ } else if (r && t) {
274
273
  const s = t.getSelectedCell(), d = this.#s(s.row, s.col);
275
274
  if (!d) return;
276
275
  c = d.text, a = 1, u = 1;
277
276
  } else {
278
- const s = this.#r(e);
277
+ const s = this.#o(e);
279
278
  if (!s) return;
280
279
  c = s.text, a = 1, u = 1;
281
280
  }
@@ -315,29 +314,29 @@ class D extends I {
315
314
  if (!n) return null;
316
315
  const i = this.columns[t];
317
316
  if (!i) return null;
318
- const l = n[i.field], r = i.header || i.field;
319
- let o;
317
+ const l = n[i.field], o = i.header || i.field;
318
+ let r;
320
319
  if (this.config.includeHeaders) {
321
320
  const c = l == null ? "" : String(l);
322
- o = `${r}: ${c}`;
321
+ r = `${o}: ${c}`;
323
322
  } else
324
- o = l == null ? "" : String(l);
325
- return { text: o };
323
+ r = l == null ? "" : String(l);
324
+ return { text: r };
326
325
  }
327
326
  /**
328
327
  * Build text for a rectangular range of cells.
329
328
  */
330
329
  #i(e) {
331
- const { startRow: t, startCol: n, endRow: i, endCol: l } = e, r = Math.min(t, i), o = Math.max(t, i), c = Math.min(n, l), a = Math.max(n, l), u = this.config.delimiter ?? " ", s = this.config.newline ?? `
332
- `, d = [], h = this.columns.slice(c, a + 1);
330
+ const { startRow: t, startCol: n, endRow: i, endCol: l } = e, o = Math.min(t, i), r = Math.max(t, i), c = Math.min(n, l), a = Math.max(n, l), u = this.config.delimiter ?? " ", s = this.config.newline ?? `
331
+ `, d = [], f = this.columns.slice(c, a + 1);
333
332
  if (this.config.includeHeaders) {
334
- const g = h.map((m) => m.header || m.field);
333
+ const g = f.map((m) => m.header || m.field);
335
334
  d.push(g.join(u));
336
335
  }
337
- for (let g = r; g <= o; g++) {
336
+ for (let g = o; g <= r; g++) {
338
337
  const m = this.rows[g];
339
338
  if (!m) continue;
340
- const S = h.map((R) => {
339
+ const S = f.map((R) => {
341
340
  const w = m[R.field];
342
341
  return w == null ? "" : w instanceof Date ? w.toISOString() : String(w);
343
342
  });
@@ -345,7 +344,7 @@ class D extends I {
345
344
  }
346
345
  return {
347
346
  text: d.join(s),
348
- rowCount: o - r + 1,
347
+ rowCount: r - o + 1,
349
348
  columnCount: a - c + 1
350
349
  };
351
350
  }
@@ -353,7 +352,7 @@ class D extends I {
353
352
  * Build text for a single focused cell from DOM.
354
353
  * Used when selection plugin is not available or no rows are selected.
355
354
  */
356
- #r(e) {
355
+ #o(e) {
357
356
  const t = e.closest("[data-field-cache]");
358
357
  if (!t) return null;
359
358
  const n = t.dataset.fieldCache;
@@ -362,16 +361,16 @@ class D extends I {
362
361
  if (!i) return null;
363
362
  const l = parseInt(i, 10);
364
363
  if (isNaN(l)) return null;
365
- const r = this.rows[l];
366
- if (!r) return null;
367
- const o = r[n], a = this.columns.find((s) => s.field === n)?.header || n;
364
+ const o = this.rows[l];
365
+ if (!o) return null;
366
+ const r = o[n], a = this.columns.find((s) => s.field === n)?.header || n;
368
367
  let u;
369
368
  if (this.config.includeHeaders) {
370
- const s = o == null ? "" : String(o);
369
+ const s = r == null ? "" : String(r);
371
370
  u = `${a}: ${s}`;
372
371
  } else
373
- u = o == null ? "" : String(o);
374
- return { text: u, field: n, value: o };
372
+ u = r == null ? "" : String(r);
373
+ return { text: u, field: n, value: r };
375
374
  }
376
375
  // ===== Public API =====
377
376
  /**