@toolbox-web/grid 0.2.4 → 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 (67) hide show
  1. package/all.d.ts +61 -23
  2. package/all.js +841 -809
  3. package/all.js.map +1 -1
  4. package/index.d.ts +17 -5
  5. package/index.js +316 -247
  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/themes/dg-theme-bootstrap.css +0 -2
  45. package/themes/dg-theme-contrast.css +0 -1
  46. package/themes/dg-theme-large.css +0 -1
  47. package/themes/dg-theme-material.css +0 -2
  48. package/themes/dg-theme-standard.css +0 -1
  49. package/themes/dg-theme-vibrant.css +0 -1
  50. package/umd/grid.all.umd.js +13 -13
  51. package/umd/grid.all.umd.js.map +1 -1
  52. package/umd/grid.umd.js +7 -7
  53. package/umd/grid.umd.js.map +1 -1
  54. package/umd/plugins/grouping-columns.umd.js +1 -1
  55. package/umd/plugins/grouping-columns.umd.js.map +1 -1
  56. package/umd/plugins/pinned-rows.umd.js +1 -1
  57. package/umd/plugins/pinned-rows.umd.js.map +1 -1
  58. package/umd/plugins/pivot.umd.js +1 -1
  59. package/umd/plugins/pivot.umd.js.map +1 -1
  60. package/umd/plugins/reorder.umd.js +1 -1
  61. package/umd/plugins/reorder.umd.js.map +1 -1
  62. package/umd/plugins/selection.umd.js +1 -1
  63. package/umd/plugins/selection.umd.js.map +1 -1
  64. package/umd/plugins/server-side.umd.js +1 -1
  65. package/umd/plugins/server-side.umd.js.map +1 -1
  66. package/umd/plugins/tree.umd.js +1 -1
  67. package/umd/plugins/tree.umd.js.map +1 -1
@@ -7,11 +7,11 @@ const C = {
7
7
  submenuArrow: "▶",
8
8
  dragHandle: "⋮⋮",
9
9
  toolPanel: "☰"
10
- }, b = {
10
+ }, w = {
11
11
  /** Ask if a column can be moved. Context: ColumnConfig. Response: boolean | undefined */
12
12
  CAN_MOVE_COLUMN: "canMoveColumn"
13
13
  };
14
- class v {
14
+ class b {
15
15
  /** Plugin version - override in subclass if needed */
16
16
  version = "1.0.0";
17
17
  /** CSS styles to inject into the grid's shadow DOM */
@@ -62,8 +62,8 @@ class v {
62
62
  /**
63
63
  * Emit a custom event from the grid.
64
64
  */
65
- emit(e, r) {
66
- this.grid?.dispatchEvent?.(new CustomEvent(e, { detail: r, bubbles: !0 }));
65
+ emit(e, t) {
66
+ this.grid?.dispatchEvent?.(new CustomEvent(e, { detail: t, bubbles: !0 }));
67
67
  }
68
68
  /**
69
69
  * Request a re-render of the grid.
@@ -102,7 +102,7 @@ class v {
102
102
  * Use this for rendering that needs to match the grid template.
103
103
  */
104
104
  get visibleColumns() {
105
- return this.grid?.visibleColumns ?? [];
105
+ return this.grid?._visibleColumns ?? [];
106
106
  }
107
107
  /**
108
108
  * Get the shadow root of the grid.
@@ -146,8 +146,8 @@ class v {
146
146
  * @param pluginOverride - Optional plugin-level override
147
147
  * @returns The resolved icon value
148
148
  */
149
- resolveIcon(e, r) {
150
- return r !== void 0 ? r : this.gridIcons[e];
149
+ resolveIcon(e, t) {
150
+ return t !== void 0 ? t : this.gridIcons[e];
151
151
  }
152
152
  /**
153
153
  * Set an icon value on an element.
@@ -156,8 +156,8 @@ class v {
156
156
  * @param element - The element to set the icon on
157
157
  * @param icon - The icon value (string or HTMLElement)
158
158
  */
159
- setIcon(e, r) {
160
- typeof r == "string" ? e.innerHTML = r : r instanceof HTMLElement && (e.innerHTML = "", e.appendChild(r.cloneNode(!0)));
159
+ setIcon(e, t) {
160
+ typeof t == "string" ? e.innerHTML = t : t instanceof HTMLElement && (e.innerHTML = "", e.appendChild(t.cloneNode(!0)));
161
161
  }
162
162
  /**
163
163
  * Log a warning message.
@@ -167,23 +167,22 @@ class v {
167
167
  }
168
168
  // #endregion
169
169
  }
170
- function w(i) {
171
- const e = i.meta ?? {};
170
+ function O(o) {
171
+ const e = o.meta ?? {};
172
172
  return e.lockPosition !== !0 && e.suppressMovable !== !0;
173
173
  }
174
- function h(i, e, r) {
175
- if (e === r || e < 0 || e >= i.length || r < 0 || r > i.length) return i;
176
- const s = [...i], [t] = s.splice(e, 1);
177
- return s.splice(r, 0, t), s;
174
+ function f(o, e, t) {
175
+ if (e === t || e < 0 || e >= o.length || t < 0 || t > o.length) return o;
176
+ const n = [...o], [r] = n.splice(e, 1);
177
+ return n.splice(t, 0, r), n;
178
178
  }
179
- const O = '.header-row>.cell[draggable=true]{cursor:grab;position:relative}.header-row>.cell.dragging{opacity:.5;cursor:grabbing}.header-row>.cell.drop-before:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}.header-row>.cell.drop-after:after{content:"";position:absolute;right:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}';
180
- class E extends v {
179
+ const x = '.header-row>.cell[draggable=true]{cursor:grab;position:relative}.header-row>.cell.dragging{opacity:.5;cursor:grabbing}.header-row>.cell.drop-before:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}.header-row>.cell.drop-after:after{content:"";position:absolute;right:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}';
180
+ class I extends b {
181
181
  name = "reorder";
182
182
  version = "1.0.0";
183
183
  get defaultConfig() {
184
184
  return {
185
- animation: !0,
186
- animationDuration: 200
185
+ viewTransition: !0
187
186
  };
188
187
  }
189
188
  // #region Internal State
@@ -196,9 +195,9 @@ class E extends v {
196
195
  attach(e) {
197
196
  super.attach(e), e.addEventListener(
198
197
  "column-reorder-request",
199
- (r) => {
200
- const s = r.detail;
201
- s?.field && typeof s.toIndex == "number" && this.moveColumn(s.field, s.toIndex);
198
+ (t) => {
199
+ const n = t.detail;
200
+ n?.field && typeof n.toIndex == "number" && this.moveColumn(n.field, n.toIndex);
202
201
  },
203
202
  { signal: this.disconnectSignal }
204
203
  );
@@ -208,46 +207,45 @@ class E extends v {
208
207
  }
209
208
  // #endregion
210
209
  // #region Hooks
211
- // Note: No processColumns hook needed - we directly update the grid's column order
212
210
  afterRender() {
213
211
  const e = this.shadowRoot;
214
212
  if (!e) return;
215
- e.querySelectorAll(".header-row > .cell").forEach((s) => {
216
- const t = s, d = t.getAttribute("data-field");
217
- if (!d) return;
218
- const u = this.columns.find((n) => n.field === d), f = !this.grid.queryPlugins({
219
- type: b.CAN_MOVE_COLUMN,
220
- context: u
213
+ e.querySelectorAll(".header-row > .cell").forEach((n) => {
214
+ const r = n, s = r.getAttribute("data-field");
215
+ if (!s) return;
216
+ const a = this.columns.find((i) => i.field === s), p = !this.grid.queryPlugins({
217
+ type: w.CAN_MOVE_COLUMN,
218
+ context: a
221
219
  }).includes(!1);
222
- if (!u || !w(u) || !f) {
223
- t.draggable = !1;
220
+ if (!a || !O(a) || !p) {
221
+ r.draggable = !1;
224
222
  return;
225
223
  }
226
- t.draggable = !0, !t.getAttribute("data-dragstart-bound") && (t.setAttribute("data-dragstart-bound", "true"), t.addEventListener("dragstart", (n) => {
227
- const o = this.getColumnOrder().indexOf(d);
228
- this.isDragging = !0, this.draggedField = d, this.draggedIndex = o, n.dataTransfer && (n.dataTransfer.effectAllowed = "move", n.dataTransfer.setData("text/plain", d)), t.classList.add("dragging");
229
- }), t.addEventListener("dragend", () => {
230
- this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null, e.querySelectorAll(".header-row > .cell").forEach((n) => {
231
- n.classList.remove("dragging", "drop-target", "drop-before", "drop-after");
224
+ r.draggable = !0, !r.getAttribute("data-dragstart-bound") && (r.setAttribute("data-dragstart-bound", "true"), r.addEventListener("dragstart", (i) => {
225
+ const d = this.getColumnOrder().indexOf(s);
226
+ this.isDragging = !0, this.draggedField = s, this.draggedIndex = d, i.dataTransfer && (i.dataTransfer.effectAllowed = "move", i.dataTransfer.setData("text/plain", s)), r.classList.add("dragging");
227
+ }), r.addEventListener("dragend", () => {
228
+ this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null, e.querySelectorAll(".header-row > .cell").forEach((i) => {
229
+ i.classList.remove("dragging", "drop-target", "drop-before", "drop-after");
232
230
  });
233
- }), t.addEventListener("dragover", (n) => {
234
- if (n.preventDefault(), !this.isDragging || this.draggedField === d) return;
235
- const a = t.getBoundingClientRect(), o = a.left + a.width / 2, g = this.getColumnOrder().indexOf(d);
236
- this.dropIndex = n.clientX < o ? g : g + 1, t.classList.add("drop-target"), t.classList.toggle("drop-before", n.clientX < o), t.classList.toggle("drop-after", n.clientX >= o);
237
- }), t.addEventListener("dragleave", () => {
238
- t.classList.remove("drop-target", "drop-before", "drop-after");
239
- }), t.addEventListener("drop", (n) => {
240
- n.preventDefault();
241
- const a = this.draggedField, o = this.draggedIndex, l = this.dropIndex;
242
- if (!this.isDragging || a === null || o === null || l === null)
231
+ }), r.addEventListener("dragover", (i) => {
232
+ if (i.preventDefault(), !this.isDragging || this.draggedField === s) return;
233
+ const l = r.getBoundingClientRect(), d = l.left + l.width / 2, u = this.getColumnOrder().indexOf(s);
234
+ this.dropIndex = i.clientX < d ? u : u + 1, r.classList.add("drop-target"), r.classList.toggle("drop-before", i.clientX < d), r.classList.toggle("drop-after", i.clientX >= d);
235
+ }), r.addEventListener("dragleave", () => {
236
+ r.classList.remove("drop-target", "drop-before", "drop-after");
237
+ }), r.addEventListener("drop", (i) => {
238
+ i.preventDefault();
239
+ const l = this.draggedField, d = this.draggedIndex, g = this.dropIndex;
240
+ if (!this.isDragging || l === null || d === null || g === null)
243
241
  return;
244
- const g = l > o ? l - 1 : l, p = this.getColumnOrder(), c = h(p, o, g), m = {
245
- field: a,
246
- fromIndex: o,
247
- toIndex: g,
248
- columnOrder: c
242
+ const u = g > d ? g - 1 : g, m = this.getColumnOrder(), h = f(m, d, u), v = {
243
+ field: l,
244
+ fromIndex: d,
245
+ toIndex: u,
246
+ columnOrder: h
249
247
  };
250
- this.grid.setColumnOrder(c), this.emit("column-move", m), this.grid.requestStateChange?.();
248
+ this.updateColumnOrder(h), this.emit("column-move", v);
251
249
  }));
252
250
  });
253
251
  }
@@ -265,37 +263,59 @@ class E extends v {
265
263
  * @param field - The field name of the column to move
266
264
  * @param toIndex - The target index
267
265
  */
268
- moveColumn(e, r) {
269
- const s = this.getColumnOrder(), t = s.indexOf(e);
270
- if (t === -1) return;
271
- const d = h(s, t, r);
272
- this.grid.setColumnOrder(d), this.emit("column-move", {
266
+ moveColumn(e, t) {
267
+ const n = this.getColumnOrder(), r = n.indexOf(e);
268
+ if (r === -1) return;
269
+ const s = f(n, r, t);
270
+ this.updateColumnOrder(s), this.emit("column-move", {
273
271
  field: e,
274
- fromIndex: t,
275
- toIndex: r,
276
- columnOrder: d
277
- }), this.grid.requestStateChange?.();
272
+ fromIndex: r,
273
+ toIndex: t,
274
+ columnOrder: s
275
+ });
278
276
  }
279
277
  /**
280
278
  * Set a specific column order.
281
279
  * @param order - Array of field names in desired order
282
280
  */
283
281
  setColumnOrder(e) {
284
- this.grid.setColumnOrder(e), this.grid.requestStateChange?.();
282
+ this.updateColumnOrder(e);
285
283
  }
286
284
  /**
287
285
  * Reset column order to the original configuration order.
288
286
  */
289
287
  resetColumnOrder() {
290
- const e = this.columns.map((r) => r.field);
291
- this.grid.setColumnOrder(e), this.grid.requestStateChange?.();
288
+ const e = this.columns.map((t) => t.field);
289
+ this.updateColumnOrder(e);
290
+ }
291
+ // #endregion
292
+ // #region View Transition
293
+ /**
294
+ * Update column order with optional view transition animation.
295
+ * Falls back to instant update if View Transitions API is not supported.
296
+ */
297
+ updateColumnOrder(e) {
298
+ const t = this.grid, n = this.shadowRoot;
299
+ if (this.config.viewTransition && "startViewTransition" in document && n) {
300
+ const r = n.querySelectorAll(".cell[data-field]");
301
+ r.forEach((a) => {
302
+ const c = a.getAttribute("data-field");
303
+ c && (a.style.viewTransitionName = `col-${c}`);
304
+ }), document.startViewTransition(() => t.setColumnOrder(e)).finished.finally(() => {
305
+ r.forEach((a) => {
306
+ a.style.viewTransitionName = "";
307
+ });
308
+ });
309
+ } else
310
+ t.setColumnOrder(e);
311
+ t.requestStateChange?.();
292
312
  }
293
313
  // #endregion
294
314
  // #region Styles
295
- styles = O;
315
+ styles = x;
296
316
  // #endregion
297
317
  }
298
318
  export {
299
- E as ReorderPlugin
319
+ I as ReorderPlugin
300
320
  };
301
321
  //# sourceMappingURL=index.js.map