@toolbox-web/grid 0.2.5 → 0.2.6

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 (61) hide show
  1. package/all.d.ts +56 -23
  2. package/all.js +841 -809
  3. package/all.js.map +1 -1
  4. package/index.d.ts +12 -5
  5. package/index.js +276 -225
  6. package/index.js.map +1 -1
  7. package/lib/plugins/clipboard/index.js +1 -1
  8. package/lib/plugins/clipboard/index.js.map +1 -1
  9. package/lib/plugins/column-virtualization/index.js +1 -1
  10. package/lib/plugins/column-virtualization/index.js.map +1 -1
  11. package/lib/plugins/context-menu/index.js +1 -1
  12. package/lib/plugins/context-menu/index.js.map +1 -1
  13. package/lib/plugins/export/index.js +1 -1
  14. package/lib/plugins/export/index.js.map +1 -1
  15. package/lib/plugins/filtering/index.js +1 -1
  16. package/lib/plugins/filtering/index.js.map +1 -1
  17. package/lib/plugins/grouping-columns/index.js +46 -45
  18. package/lib/plugins/grouping-columns/index.js.map +1 -1
  19. package/lib/plugins/grouping-rows/index.js +1 -1
  20. package/lib/plugins/grouping-rows/index.js.map +1 -1
  21. package/lib/plugins/master-detail/index.js +1 -1
  22. package/lib/plugins/master-detail/index.js.map +1 -1
  23. package/lib/plugins/multi-sort/index.js +1 -1
  24. package/lib/plugins/multi-sort/index.js.map +1 -1
  25. package/lib/plugins/pinned-columns/index.js +1 -1
  26. package/lib/plugins/pinned-columns/index.js.map +1 -1
  27. package/lib/plugins/pinned-rows/index.js +55 -47
  28. package/lib/plugins/pinned-rows/index.js.map +1 -1
  29. package/lib/plugins/pivot/index.js +243 -241
  30. package/lib/plugins/pivot/index.js.map +1 -1
  31. package/lib/plugins/reorder/index.js +87 -67
  32. package/lib/plugins/reorder/index.js.map +1 -1
  33. package/lib/plugins/selection/index.js +28 -27
  34. package/lib/plugins/selection/index.js.map +1 -1
  35. package/lib/plugins/server-side/index.js +2 -2
  36. package/lib/plugins/server-side/index.js.map +1 -1
  37. package/lib/plugins/tree/index.js +70 -70
  38. package/lib/plugins/tree/index.js.map +1 -1
  39. package/lib/plugins/undo-redo/index.js +1 -1
  40. package/lib/plugins/undo-redo/index.js.map +1 -1
  41. package/lib/plugins/visibility/index.js +1 -1
  42. package/lib/plugins/visibility/index.js.map +1 -1
  43. package/package.json +1 -1
  44. package/umd/grid.all.umd.js +13 -13
  45. package/umd/grid.all.umd.js.map +1 -1
  46. package/umd/grid.umd.js +7 -7
  47. package/umd/grid.umd.js.map +1 -1
  48. package/umd/plugins/grouping-columns.umd.js +1 -1
  49. package/umd/plugins/grouping-columns.umd.js.map +1 -1
  50. package/umd/plugins/pinned-rows.umd.js +1 -1
  51. package/umd/plugins/pinned-rows.umd.js.map +1 -1
  52. package/umd/plugins/pivot.umd.js +1 -1
  53. package/umd/plugins/pivot.umd.js.map +1 -1
  54. package/umd/plugins/reorder.umd.js +1 -1
  55. package/umd/plugins/reorder.umd.js.map +1 -1
  56. package/umd/plugins/selection.umd.js +1 -1
  57. package/umd/plugins/selection.umd.js.map +1 -1
  58. package/umd/plugins/server-side.umd.js +1 -1
  59. package/umd/plugins/server-side.umd.js.map +1 -1
  60. package/umd/plugins/tree.umd.js +1 -1
  61. package/umd/plugins/tree.umd.js.map +1 -1
@@ -1,4 +1,4 @@
1
- const m = {
1
+ const v = {
2
2
  expand: "▶",
3
3
  collapse: "▼",
4
4
  sortAsc: "▲",
@@ -8,7 +8,7 @@ const m = {
8
8
  dragHandle: "⋮⋮",
9
9
  toolPanel: "☰"
10
10
  };
11
- class _ {
11
+ class b {
12
12
  /** Plugin version - override in subclass if needed */
13
13
  version = "1.0.0";
14
14
  /** CSS styles to inject into the grid's shadow DOM */
@@ -99,7 +99,7 @@ class _ {
99
99
  * Use this for rendering that needs to match the grid template.
100
100
  */
101
101
  get visibleColumns() {
102
- return this.grid?.visibleColumns ?? [];
102
+ return this.grid?._visibleColumns ?? [];
103
103
  }
104
104
  /**
105
105
  * Get the shadow root of the grid.
@@ -133,7 +133,7 @@ class _ {
133
133
  */
134
134
  get gridIcons() {
135
135
  const e = this.grid?.gridConfig?.icons ?? {};
136
- return { ...m, ...e };
136
+ return { ...v, ...e };
137
137
  }
138
138
  /**
139
139
  * Resolve an icon value to string or HTMLElement.
@@ -167,74 +167,74 @@ class _ {
167
167
  function w(r, e, t) {
168
168
  return r.id !== void 0 ? String(r.id) : t ? `${t}-${e}` : String(e);
169
169
  }
170
- function K(r, e, t, n = null, s = 0) {
170
+ function E(r, e, t, n = null, s = 0) {
171
171
  const o = e.childrenField ?? "children", i = [];
172
172
  for (let c = 0; c < r.length; c++) {
173
- const l = r[c], a = w(l, c, n), h = l[o], f = Array.isArray(h) && h.length > 0, p = t.has(a);
173
+ const a = r[c], d = w(a, c, n), h = a[o], f = Array.isArray(h) && h.length > 0, g = t.has(d);
174
174
  if (i.push({
175
- key: a,
176
- data: l,
175
+ key: d,
176
+ data: a,
177
177
  depth: s,
178
178
  hasChildren: f,
179
- isExpanded: p,
179
+ isExpanded: g,
180
180
  parentKey: n
181
- }), f && p) {
182
- const y = K(h, e, t, a, s + 1);
181
+ }), f && g) {
182
+ const y = E(h, e, t, d, s + 1);
183
183
  i.push(...y);
184
184
  }
185
185
  }
186
186
  return i;
187
187
  }
188
- function R(r, e) {
188
+ function C(r, e) {
189
189
  const t = new Set(r);
190
190
  return t.has(e) ? t.delete(e) : t.add(e), t;
191
191
  }
192
192
  function x(r, e, t = null, n = 0) {
193
193
  const s = e.childrenField ?? "children", o = /* @__PURE__ */ new Set();
194
194
  for (let i = 0; i < r.length; i++) {
195
- const c = r[i], l = w(c, i, t), a = c[s];
196
- if (Array.isArray(a) && a.length > 0) {
197
- o.add(l);
198
- const h = x(a, e, l, n + 1);
195
+ const c = r[i], a = w(c, i, t), d = c[s];
196
+ if (Array.isArray(d) && d.length > 0) {
197
+ o.add(a);
198
+ const h = x(d, e, a, n + 1);
199
199
  for (const f of h) o.add(f);
200
200
  }
201
201
  }
202
202
  return o;
203
203
  }
204
- function v() {
204
+ function S() {
205
205
  return /* @__PURE__ */ new Set();
206
206
  }
207
- function C(r, e, t, n = null, s = 0) {
207
+ function m(r, e, t, n = null, s = 0) {
208
208
  const o = t.childrenField ?? "children";
209
209
  for (let i = 0; i < r.length; i++) {
210
- const c = r[i], l = w(c, i, n);
211
- if (l === e)
212
- return [l];
213
- const a = c[o];
214
- if (Array.isArray(a) && a.length > 0) {
215
- const h = C(a, e, t, l, s + 1);
210
+ const c = r[i], a = w(c, i, n);
211
+ if (a === e)
212
+ return [a];
213
+ const d = c[o];
214
+ if (Array.isArray(d) && d.length > 0) {
215
+ const h = m(d, e, t, a, s + 1);
216
216
  if (h)
217
- return [l, ...h];
217
+ return [a, ...h];
218
218
  }
219
219
  }
220
220
  return null;
221
221
  }
222
- function b(r, e, t, n) {
223
- const s = C(r, e, t);
222
+ function I(r, e, t, n) {
223
+ const s = m(r, e, t);
224
224
  if (!s) return n;
225
225
  const o = new Set(n);
226
226
  for (let i = 0; i < s.length - 1; i++)
227
227
  o.add(s[i]);
228
228
  return o;
229
229
  }
230
- function A(r, e = "children") {
230
+ function K(r, e = "children") {
231
231
  if (!Array.isArray(r) || r.length === 0) return !1;
232
232
  for (const t of r)
233
233
  if (t && Array.isArray(t[e]) && t[e].length > 0)
234
234
  return !0;
235
235
  return !1;
236
236
  }
237
- function S(r) {
237
+ function D(r) {
238
238
  if (!Array.isArray(r) || r.length === 0) return null;
239
239
  const e = ["children", "items", "nodes", "subRows", "nested"];
240
240
  for (const t of r)
@@ -245,32 +245,32 @@ function S(r) {
245
245
  }
246
246
  return null;
247
247
  }
248
- function I(r, e = "children", t = 0) {
248
+ function F(r, e = "children", t = 0) {
249
249
  if (!Array.isArray(r) || r.length === 0) return t;
250
250
  let n = t;
251
251
  for (const s of r) {
252
252
  if (!s) continue;
253
253
  const o = s[e];
254
254
  if (Array.isArray(o) && o.length > 0) {
255
- const i = I(o, e, t + 1);
255
+ const i = F(o, e, t + 1);
256
256
  i > n && (n = i);
257
257
  }
258
258
  }
259
259
  return n;
260
260
  }
261
- function D(r, e = "children") {
261
+ function M(r, e = "children") {
262
262
  if (!Array.isArray(r)) return 0;
263
263
  let t = 0;
264
264
  for (const n of r) {
265
265
  if (!n) continue;
266
266
  t++;
267
267
  const s = n[e];
268
- Array.isArray(s) && (t += D(s, e));
268
+ Array.isArray(s) && (t += M(s, e));
269
269
  }
270
270
  return t;
271
271
  }
272
- const F = ".tree-toggle{cursor:pointer;-webkit-user-select:none;user-select:none;transition:transform .2s}.tree-toggle:hover{color:var(--tbw-tree-accent, var(--tbw-color-accent))}";
273
- class M extends _ {
272
+ const k = ".tree-toggle{cursor:pointer;-webkit-user-select:none;user-select:none;transition:transform .2s}.tree-toggle:hover{color:var(--tbw-tree-accent, var(--tbw-color-accent))}";
273
+ class q extends b {
274
274
  name = "tree";
275
275
  version = "1.0.0";
276
276
  get defaultConfig() {
@@ -304,16 +304,16 @@ class M extends _ {
304
304
  */
305
305
  detect(e) {
306
306
  if (!this.config.autoDetect) return !1;
307
- const t = this.config.childrenField ?? S(e) ?? "children";
308
- return A(e, t);
307
+ const t = this.config.childrenField ?? D(e) ?? "children";
308
+ return K(e, t);
309
309
  }
310
310
  // #endregion
311
311
  // #region Data Processing
312
312
  processRows(e) {
313
313
  const t = this.config.childrenField ?? "children";
314
- if (!A(e, t))
314
+ if (!K(e, t))
315
315
  return this.flattenedRows = [], this.rowKeyMap.clear(), [...e];
316
- this.config.defaultExpanded && !this.initialExpansionDone && (this.expandedKeys = x(e, this.config), this.initialExpansionDone = !0), this.flattenedRows = K(e, this.config, this.expandedKeys), this.rowKeyMap.clear();
316
+ this.config.defaultExpanded && !this.initialExpansionDone && (this.expandedKeys = x(e, this.config), this.initialExpansionDone = !0), this.flattenedRows = E(e, this.config, this.expandedKeys), this.rowKeyMap.clear();
317
317
  for (const n of this.flattenedRows)
318
318
  this.rowKeyMap.set(n.key, n);
319
319
  return this.flattenedRows.map((n) => ({
@@ -326,31 +326,31 @@ class M extends _ {
326
326
  }
327
327
  processColumns(e) {
328
328
  if (this.flattenedRows.length === 0) return [...e];
329
- const t = this.config.indentWidth ?? 20, n = this.config.showExpandIcons ?? !0, s = [...e];
330
- if (s.length > 0) {
331
- const o = { ...s[0] }, i = o.viewRenderer;
332
- if (i?.__treeWrapped)
333
- return s;
334
- const c = (l) => {
335
- const { value: a, row: h, column: f } = l, p = h.__treeDepth ?? 0, y = h.__treeHasChildren ?? !1, E = h.__treeExpanded ?? !1, u = document.createElement("span");
336
- if (u.style.display = "flex", u.style.alignItems = "center", u.style.paddingLeft = `${p * t}px`, y && n) {
337
- const d = document.createElement("span");
338
- d.className = "tree-toggle", this.setIcon(d, this.resolveIcon(E ? "collapse" : "expand")), d.style.cursor = "pointer", d.style.marginRight = "4px", d.style.fontSize = "10px", d.setAttribute("data-tree-key", h.__treeKey), u.appendChild(d);
339
- } else if (n) {
340
- const d = document.createElement("span");
341
- d.style.width = "14px", d.style.display = "inline-block", u.appendChild(d);
329
+ const t = [...e];
330
+ if (t.length > 0) {
331
+ const n = { ...t[0] }, s = n.viewRenderer;
332
+ if (s?.__treeWrapped)
333
+ return t;
334
+ const o = () => this.config, i = (c) => {
335
+ const { value: a, row: d, column: h } = c, f = d.__treeDepth ?? 0, g = d.__treeHasChildren ?? !1, y = d.__treeExpanded ?? !1, R = o(), _ = R.indentWidth ?? 20, A = R.showExpandIcons ?? !0, u = document.createElement("span");
336
+ if (u.style.display = "flex", u.style.alignItems = "center", u.style.paddingLeft = `${f * _}px`, g && A) {
337
+ const l = document.createElement("span");
338
+ l.className = "tree-toggle", this.setIcon(l, this.resolveIcon(y ? "collapse" : "expand")), l.style.cursor = "pointer", l.style.marginRight = "4px", l.style.fontSize = "10px", l.setAttribute("data-tree-key", d.__treeKey), u.appendChild(l);
339
+ } else if (A) {
340
+ const l = document.createElement("span");
341
+ l.style.width = "14px", l.style.display = "inline-block", u.appendChild(l);
342
342
  }
343
- const g = document.createElement("span");
344
- if (i) {
345
- const d = i(l);
346
- d instanceof Node ? g.appendChild(d) : g.textContent = String(d ?? a ?? "");
343
+ const p = document.createElement("span");
344
+ if (s) {
345
+ const l = s(c);
346
+ l instanceof Node ? p.appendChild(l) : p.textContent = String(l ?? a ?? "");
347
347
  } else
348
- g.textContent = String(a ?? "");
349
- return u.appendChild(g), u;
348
+ p.textContent = String(a ?? "");
349
+ return u.appendChild(p), u;
350
350
  };
351
- c.__treeWrapped = !0, o.viewRenderer = c, s[0] = o;
351
+ i.__treeWrapped = !0, n.viewRenderer = i, t[0] = n;
352
352
  }
353
- return s;
353
+ return t;
354
354
  }
355
355
  // #endregion
356
356
  // #region Event Handlers
@@ -360,7 +360,7 @@ class M extends _ {
360
360
  const n = t.getAttribute("data-tree-key");
361
361
  if (!n) return !1;
362
362
  const s = this.rowKeyMap.get(n);
363
- return s ? (this.expandedKeys = R(this.expandedKeys, n), this.emit("tree-expand", {
363
+ return s ? (this.expandedKeys = C(this.expandedKeys, n), this.emit("tree-expand", {
364
364
  key: n,
365
365
  row: s.data,
366
366
  expanded: this.expandedKeys.has(n),
@@ -385,7 +385,7 @@ class M extends _ {
385
385
  * Toggle the expansion state of a node.
386
386
  */
387
387
  toggle(e) {
388
- this.expandedKeys = R(this.expandedKeys, e), this.requestRender();
388
+ this.expandedKeys = C(this.expandedKeys, e), this.requestRender();
389
389
  }
390
390
  /**
391
391
  * Expand all nodes in the tree.
@@ -397,7 +397,7 @@ class M extends _ {
397
397
  * Collapse all nodes in the tree.
398
398
  */
399
399
  collapseAll() {
400
- this.expandedKeys = v(), this.requestRender();
400
+ this.expandedKeys = S(), this.requestRender();
401
401
  }
402
402
  /**
403
403
  * Check if a node is currently expanded.
@@ -427,18 +427,18 @@ class M extends _ {
427
427
  * Expand all ancestors of a node to make it visible.
428
428
  */
429
429
  expandToKey(e) {
430
- this.expandedKeys = b(this.rows, e, this.config, this.expandedKeys), this.requestRender();
430
+ this.expandedKeys = I(this.rows, e, this.config, this.expandedKeys), this.requestRender();
431
431
  }
432
432
  // #endregion
433
433
  // #region Styles
434
- styles = F;
434
+ styles = k;
435
435
  // #endregion
436
436
  }
437
437
  export {
438
- M as TreePlugin,
439
- D as countNodes,
440
- A as detectTreeStructure,
441
- I as getMaxDepth,
442
- S as inferChildrenField
438
+ q as TreePlugin,
439
+ M as countNodes,
440
+ K as detectTreeStructure,
441
+ F as getMaxDepth,
442
+ D as inferChildrenField
443
443
  };
444
444
  //# sourceMappingURL=index.js.map