@toolbox-web/grid 0.2.5 → 0.2.7

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 (71) hide show
  1. package/all.d.ts +486 -80
  2. package/all.js +1364 -1029
  3. package/all.js.map +1 -1
  4. package/index-DG2CZ_Zo.js +3229 -0
  5. package/index-DG2CZ_Zo.js.map +1 -0
  6. package/index.d.ts +222 -11
  7. package/index.js +25 -3143
  8. package/index.js.map +1 -1
  9. package/lib/plugins/clipboard/index.js +1 -1
  10. package/lib/plugins/clipboard/index.js.map +1 -1
  11. package/lib/plugins/column-virtualization/index.js +1 -1
  12. package/lib/plugins/column-virtualization/index.js.map +1 -1
  13. package/lib/plugins/context-menu/index.js +1 -1
  14. package/lib/plugins/context-menu/index.js.map +1 -1
  15. package/lib/plugins/export/index.js +1 -1
  16. package/lib/plugins/export/index.js.map +1 -1
  17. package/lib/plugins/filtering/index.js +184 -149
  18. package/lib/plugins/filtering/index.js.map +1 -1
  19. package/lib/plugins/grouping-columns/index.js +46 -45
  20. package/lib/plugins/grouping-columns/index.js.map +1 -1
  21. package/lib/plugins/grouping-rows/index.js +117 -83
  22. package/lib/plugins/grouping-rows/index.js.map +1 -1
  23. package/lib/plugins/master-detail/index.js +140 -82
  24. package/lib/plugins/master-detail/index.js.map +1 -1
  25. package/lib/plugins/multi-sort/index.js +18 -18
  26. package/lib/plugins/multi-sort/index.js.map +1 -1
  27. package/lib/plugins/pinned-columns/index.js +1 -1
  28. package/lib/plugins/pinned-columns/index.js.map +1 -1
  29. package/lib/plugins/pinned-rows/index.js +55 -47
  30. package/lib/plugins/pinned-rows/index.js.map +1 -1
  31. package/lib/plugins/pivot/index.js +385 -351
  32. package/lib/plugins/pivot/index.js.map +1 -1
  33. package/lib/plugins/reorder/index.js +278 -85
  34. package/lib/plugins/reorder/index.js.map +1 -1
  35. package/lib/plugins/selection/index.js +28 -27
  36. package/lib/plugins/selection/index.js.map +1 -1
  37. package/lib/plugins/server-side/index.js +2 -2
  38. package/lib/plugins/server-side/index.js.map +1 -1
  39. package/lib/plugins/tree/index.js +181 -170
  40. package/lib/plugins/tree/index.js.map +1 -1
  41. package/lib/plugins/undo-redo/index.js +1 -1
  42. package/lib/plugins/undo-redo/index.js.map +1 -1
  43. package/lib/plugins/visibility/index.js +1 -1
  44. package/lib/plugins/visibility/index.js.map +1 -1
  45. package/package.json +1 -1
  46. package/umd/grid.all.umd.js +22 -22
  47. package/umd/grid.all.umd.js.map +1 -1
  48. package/umd/grid.umd.js +12 -12
  49. package/umd/grid.umd.js.map +1 -1
  50. package/umd/plugins/filtering.umd.js +1 -1
  51. package/umd/plugins/filtering.umd.js.map +1 -1
  52. package/umd/plugins/grouping-columns.umd.js +1 -1
  53. package/umd/plugins/grouping-columns.umd.js.map +1 -1
  54. package/umd/plugins/grouping-rows.umd.js +1 -1
  55. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  56. package/umd/plugins/master-detail.umd.js +1 -1
  57. package/umd/plugins/master-detail.umd.js.map +1 -1
  58. package/umd/plugins/multi-sort.umd.js +1 -1
  59. package/umd/plugins/multi-sort.umd.js.map +1 -1
  60. package/umd/plugins/pinned-rows.umd.js +1 -1
  61. package/umd/plugins/pinned-rows.umd.js.map +1 -1
  62. package/umd/plugins/pivot.umd.js +1 -1
  63. package/umd/plugins/pivot.umd.js.map +1 -1
  64. package/umd/plugins/reorder.umd.js +1 -1
  65. package/umd/plugins/reorder.umd.js.map +1 -1
  66. package/umd/plugins/selection.umd.js +1 -1
  67. package/umd/plugins/selection.umd.js.map +1 -1
  68. package/umd/plugins/server-side.umd.js +1 -1
  69. package/umd/plugins/server-side.umd.js.map +1 -1
  70. package/umd/plugins/tree.umd.js +1 -1
  71. package/umd/plugins/tree.umd.js.map +1 -1
@@ -1,4 +1,47 @@
1
- const C = {
1
+ function E(a, t) {
2
+ if (a._virtualization?.enabled) {
3
+ const { rowHeight: n, container: o, viewportEl: l } = a._virtualization, s = o, d = l?.clientHeight ?? s?.clientHeight ?? 0;
4
+ if (s && d > 0) {
5
+ const f = a._focusRow * n;
6
+ f < s.scrollTop ? s.scrollTop = f : f + n > s.scrollTop + d && (s.scrollTop = f - d + n);
7
+ }
8
+ }
9
+ a._activeEditRows !== void 0 && a._activeEditRows !== -1 || a.refreshVirtualWindow(!1), Array.from(a._bodyEl.querySelectorAll(".cell-focus")).forEach((n) => n.classList.remove("cell-focus")), Array.from(a._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach((n) => {
10
+ n.setAttribute("aria-selected", "false");
11
+ });
12
+ const i = a._focusRow, r = a._virtualization.start ?? 0, c = a._virtualization.end ?? a._rows.length;
13
+ if (i >= r && i < c) {
14
+ const n = a._bodyEl.querySelectorAll(".data-grid-row")[i - r], o = n?.children[a._focusCol];
15
+ if (o) {
16
+ o.classList.add("cell-focus"), o.setAttribute("aria-selected", "true");
17
+ const l = a.shadowRoot?.querySelector(".tbw-scroll-area");
18
+ if (l && o) {
19
+ const s = a._getHorizontalScrollOffsets?.(n ?? void 0, o) ?? { left: 0, right: 0 };
20
+ if (!s.skipScroll) {
21
+ const d = o.getBoundingClientRect(), f = l.getBoundingClientRect(), u = d.left - f.left + l.scrollLeft, g = u + d.width, h = l.scrollLeft + s.left, m = l.scrollLeft + l.clientWidth - s.right;
22
+ u < h ? l.scrollLeft = u - s.left : g > m && (l.scrollLeft = g - l.clientWidth + s.right);
23
+ }
24
+ }
25
+ if (a._activeEditRows !== void 0 && a._activeEditRows !== -1 && o.classList.contains("editing")) {
26
+ const s = o.querySelector(
27
+ 'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])'
28
+ );
29
+ if (s && document.activeElement !== s)
30
+ try {
31
+ s.focus();
32
+ } catch {
33
+ }
34
+ } else if (!o.contains(document.activeElement)) {
35
+ o.hasAttribute("tabindex") || o.setAttribute("tabindex", "-1");
36
+ try {
37
+ o.focus({ preventScroll: !0 });
38
+ } catch {
39
+ }
40
+ }
41
+ }
42
+ }
43
+ }
44
+ const R = {
2
45
  expand: "▶",
3
46
  collapse: "▼",
4
47
  sortAsc: "▲",
@@ -7,11 +50,11 @@ const C = {
7
50
  submenuArrow: "▶",
8
51
  dragHandle: "⋮⋮",
9
52
  toolPanel: "☰"
10
- }, b = {
53
+ }, p = {
11
54
  /** Ask if a column can be moved. Context: ColumnConfig. Response: boolean | undefined */
12
55
  CAN_MOVE_COLUMN: "canMoveColumn"
13
56
  };
14
- class v {
57
+ class y {
15
58
  /** Plugin version - override in subclass if needed */
16
59
  version = "1.0.0";
17
60
  /** CSS styles to inject into the grid's shadow DOM */
@@ -36,15 +79,15 @@ class v {
36
79
  get defaultConfig() {
37
80
  return {};
38
81
  }
39
- constructor(e = {}) {
40
- this.userConfig = e;
82
+ constructor(t = {}) {
83
+ this.userConfig = t;
41
84
  }
42
85
  /**
43
86
  * Called when the plugin is attached to a grid.
44
87
  * Override to set up event listeners, initialize state, etc.
45
88
  */
46
- attach(e) {
47
- this.grid = e, this.config = { ...this.defaultConfig, ...this.userConfig };
89
+ attach(t) {
90
+ this.grid = t, this.config = { ...this.defaultConfig, ...this.userConfig };
48
91
  }
49
92
  /**
50
93
  * Called when the plugin is detached from a grid.
@@ -56,14 +99,14 @@ class v {
56
99
  * Get another plugin instance from the same grid.
57
100
  * Use for inter-plugin communication.
58
101
  */
59
- getPlugin(e) {
60
- return this.grid?.getPlugin(e);
102
+ getPlugin(t) {
103
+ return this.grid?.getPlugin(t);
61
104
  }
62
105
  /**
63
106
  * Emit a custom event from the grid.
64
107
  */
65
- emit(e, r) {
66
- this.grid?.dispatchEvent?.(new CustomEvent(e, { detail: r, bubbles: !0 }));
108
+ emit(t, e) {
109
+ this.grid?.dispatchEvent?.(new CustomEvent(t, { detail: e, bubbles: !0 }));
67
110
  }
68
111
  /**
69
112
  * Request a re-render of the grid.
@@ -102,7 +145,7 @@ class v {
102
145
  * Use this for rendering that needs to match the grid template.
103
146
  */
104
147
  get visibleColumns() {
105
- return this.grid?.visibleColumns ?? [];
148
+ return this.grid?._visibleColumns ?? [];
106
149
  }
107
150
  /**
108
151
  * Get the shadow root of the grid.
@@ -135,8 +178,8 @@ class v {
135
178
  * Returns merged icons (user config + defaults).
136
179
  */
137
180
  get gridIcons() {
138
- const e = this.grid?.gridConfig?.icons ?? {};
139
- return { ...C, ...e };
181
+ const t = this.grid?.gridConfig?.icons ?? {};
182
+ return { ...R, ...t };
140
183
  }
141
184
  /**
142
185
  * Resolve an icon value to string or HTMLElement.
@@ -146,8 +189,8 @@ class v {
146
189
  * @param pluginOverride - Optional plugin-level override
147
190
  * @returns The resolved icon value
148
191
  */
149
- resolveIcon(e, r) {
150
- return r !== void 0 ? r : this.gridIcons[e];
192
+ resolveIcon(t, e) {
193
+ return e !== void 0 ? e : this.gridIcons[t];
151
194
  }
152
195
  /**
153
196
  * Set an icon value on an element.
@@ -156,36 +199,67 @@ class v {
156
199
  * @param element - The element to set the icon on
157
200
  * @param icon - The icon value (string or HTMLElement)
158
201
  */
159
- setIcon(e, r) {
160
- typeof r == "string" ? e.innerHTML = r : r instanceof HTMLElement && (e.innerHTML = "", e.appendChild(r.cloneNode(!0)));
202
+ setIcon(t, e) {
203
+ typeof e == "string" ? t.innerHTML = e : e instanceof HTMLElement && (t.innerHTML = "", t.appendChild(e.cloneNode(!0)));
161
204
  }
162
205
  /**
163
206
  * Log a warning message.
164
207
  */
165
- warn(e) {
166
- console.warn(`[tbw-grid:${this.name}] ${e}`);
208
+ warn(t) {
209
+ console.warn(`[tbw-grid:${this.name}] ${t}`);
167
210
  }
168
211
  // #endregion
169
212
  }
170
- function w(i) {
171
- const e = i.meta ?? {};
172
- return e.lockPosition !== !0 && e.suppressMovable !== !0;
213
+ function w(a) {
214
+ const t = a.meta ?? {};
215
+ return t.lockPosition !== !0 && t.suppressMovable !== !0;
173
216
  }
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;
217
+ function v(a, t, e) {
218
+ if (t === e || t < 0 || t >= a.length || e < 0 || e > a.length) return a;
219
+ const i = [...a], [r] = i.splice(t, 1);
220
+ return i.splice(e, 0, r), i;
178
221
  }
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 {
222
+ const A = '.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}.cell.flip-animating{transition:transform var(--tbw-animation-duration, .2s) ease-out;will-change:transform;z-index:1}@keyframes reorder-fade-in{0%{opacity:0}to{opacity:1}}.cell.fade-animating{animation:reorder-fade-in var(--tbw-animation-duration, .2s) ease-out backwards}';
223
+ class L extends y {
181
224
  name = "reorder";
182
225
  version = "1.0.0";
183
226
  get defaultConfig() {
184
227
  return {
185
- animation: !0,
186
- animationDuration: 200
228
+ animation: "flip"
229
+ // Plugin's own default
187
230
  };
188
231
  }
232
+ /**
233
+ * Resolve animation type from plugin config.
234
+ * Respects grid-level animation.mode (disabled = no animation).
235
+ */
236
+ get animationType() {
237
+ return this.isAnimationEnabled ? this.config.animation !== void 0 ? this.config.animation : this.config.viewTransition === !1 ? !1 : (this.config.viewTransition === !0, "flip") : !1;
238
+ }
239
+ /**
240
+ * Check if animations are enabled at the grid level.
241
+ * Respects gridConfig.animation.mode and CSS variable.
242
+ */
243
+ get isAnimationEnabled() {
244
+ const e = this.grid.effectiveConfig?.animation?.mode ?? "reduced-motion";
245
+ if (e === !1 || e === "off") return !1;
246
+ if (e === !0 || e === "on") return !0;
247
+ const i = this.shadowRoot?.host;
248
+ return i ? getComputedStyle(i).getPropertyValue("--tbw-animation-enabled").trim() !== "0" : !0;
249
+ }
250
+ /**
251
+ * Get animation duration from CSS variable (set by grid config).
252
+ */
253
+ get animationDuration() {
254
+ if (this.config.animationDuration !== void 0)
255
+ return this.config.animationDuration;
256
+ const t = this.shadowRoot?.host;
257
+ if (t) {
258
+ const e = getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(), i = parseInt(e, 10);
259
+ if (!isNaN(i)) return i;
260
+ }
261
+ return 200;
262
+ }
189
263
  // #region Internal State
190
264
  isDragging = !1;
191
265
  draggedField = null;
@@ -193,12 +267,12 @@ class E extends v {
193
267
  dropIndex = null;
194
268
  // #endregion
195
269
  // #region Lifecycle
196
- attach(e) {
197
- super.attach(e), e.addEventListener(
270
+ attach(t) {
271
+ super.attach(t), t.addEventListener(
198
272
  "column-reorder-request",
199
- (r) => {
200
- const s = r.detail;
201
- s?.field && typeof s.toIndex == "number" && this.moveColumn(s.field, s.toIndex);
273
+ (e) => {
274
+ const i = e.detail;
275
+ i?.field && typeof i.toIndex == "number" && this.moveColumn(i.field, i.toIndex);
202
276
  },
203
277
  { signal: this.disconnectSignal }
204
278
  );
@@ -208,49 +282,74 @@ class E extends v {
208
282
  }
209
283
  // #endregion
210
284
  // #region Hooks
211
- // Note: No processColumns hook needed - we directly update the grid's column order
212
285
  afterRender() {
213
- const e = this.shadowRoot;
214
- 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
286
+ const t = this.shadowRoot;
287
+ if (!t) return;
288
+ t.querySelectorAll(".header-row > .cell").forEach((i) => {
289
+ const r = i, c = r.getAttribute("data-field");
290
+ if (!c) return;
291
+ const n = this.columns.find((d) => d.field === c), s = !this.grid.queryPlugins({
292
+ type: p.CAN_MOVE_COLUMN,
293
+ context: n
221
294
  }).includes(!1);
222
- if (!u || !w(u) || !f) {
223
- t.draggable = !1;
295
+ if (!n || !w(n) || !s) {
296
+ r.draggable = !1;
224
297
  return;
225
298
  }
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");
299
+ r.draggable = !0, !r.getAttribute("data-dragstart-bound") && (r.setAttribute("data-dragstart-bound", "true"), r.addEventListener("dragstart", (d) => {
300
+ const u = this.getColumnOrder().indexOf(c);
301
+ this.isDragging = !0, this.draggedField = c, this.draggedIndex = u, d.dataTransfer && (d.dataTransfer.effectAllowed = "move", d.dataTransfer.setData("text/plain", c)), r.classList.add("dragging");
302
+ }), r.addEventListener("dragend", () => {
303
+ this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null, t.querySelectorAll(".header-row > .cell").forEach((d) => {
304
+ d.classList.remove("dragging", "drop-target", "drop-before", "drop-after");
232
305
  });
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)
306
+ }), r.addEventListener("dragover", (d) => {
307
+ if (d.preventDefault(), !this.isDragging || this.draggedField === c) return;
308
+ const f = r.getBoundingClientRect(), u = f.left + f.width / 2, h = this.getColumnOrder().indexOf(c);
309
+ this.dropIndex = d.clientX < u ? h : h + 1, r.classList.add("drop-target"), r.classList.toggle("drop-before", d.clientX < u), r.classList.toggle("drop-after", d.clientX >= u);
310
+ }), r.addEventListener("dragleave", () => {
311
+ r.classList.remove("drop-target", "drop-before", "drop-after");
312
+ }), r.addEventListener("drop", (d) => {
313
+ d.preventDefault();
314
+ const f = this.draggedField, u = this.draggedIndex, g = this.dropIndex;
315
+ if (!this.isDragging || f === null || u === null || g === null)
243
316
  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
317
+ const h = g > u ? g - 1 : g, m = this.getColumnOrder(), b = v(m, u, h), C = {
318
+ field: f,
319
+ fromIndex: u,
320
+ toIndex: h,
321
+ columnOrder: b
249
322
  };
250
- this.grid.setColumnOrder(c), this.emit("column-move", m), this.grid.requestStateChange?.();
323
+ this.updateColumnOrder(b), this.emit("column-move", C);
251
324
  }));
252
325
  });
253
326
  }
327
+ /**
328
+ * Handle Alt+Arrow keyboard shortcuts for column reordering.
329
+ */
330
+ onKeyDown(t) {
331
+ if (!t.altKey || t.key !== "ArrowLeft" && t.key !== "ArrowRight")
332
+ return;
333
+ const e = this.grid, i = e._focusCol, r = e._visibleColumns;
334
+ if (i < 0 || i >= r.length) return;
335
+ const c = r[i];
336
+ if (!c || !w(c)) return;
337
+ const n = this.grid;
338
+ if (n.queryPlugins({
339
+ type: p.CAN_MOVE_COLUMN,
340
+ context: c
341
+ }).includes(!1)) return;
342
+ const l = this.getColumnOrder(), s = l.indexOf(c.field);
343
+ if (s === -1) return;
344
+ const d = t.key === "ArrowLeft" ? s - 1 : s + 1;
345
+ if (d < 0 || d >= l.length) return;
346
+ const f = r.find((u) => u.field === l[d]);
347
+ if (!(f && n.queryPlugins({
348
+ type: p.CAN_MOVE_COLUMN,
349
+ context: f
350
+ }).includes(!1)))
351
+ return this.moveColumn(c.field, d), e._focusCol = d, E(this.grid), t.preventDefault(), t.stopPropagation(), !0;
352
+ }
254
353
  // #endregion
255
354
  // #region Public API
256
355
  /**
@@ -265,37 +364,131 @@ class E extends v {
265
364
  * @param field - The field name of the column to move
266
365
  * @param toIndex - The target index
267
366
  */
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", {
273
- field: e,
274
- fromIndex: t,
275
- toIndex: r,
276
- columnOrder: d
277
- }), this.grid.requestStateChange?.();
367
+ moveColumn(t, e) {
368
+ const i = this.getColumnOrder(), r = i.indexOf(t);
369
+ if (r === -1) return;
370
+ const c = v(i, r, e);
371
+ this.updateColumnOrder(c), this.emit("column-move", {
372
+ field: t,
373
+ fromIndex: r,
374
+ toIndex: e,
375
+ columnOrder: c
376
+ });
278
377
  }
279
378
  /**
280
379
  * Set a specific column order.
281
380
  * @param order - Array of field names in desired order
282
381
  */
283
- setColumnOrder(e) {
284
- this.grid.setColumnOrder(e), this.grid.requestStateChange?.();
382
+ setColumnOrder(t) {
383
+ this.updateColumnOrder(t);
285
384
  }
286
385
  /**
287
386
  * Reset column order to the original configuration order.
288
387
  */
289
388
  resetColumnOrder() {
290
- const e = this.columns.map((r) => r.field);
291
- this.grid.setColumnOrder(e), this.grid.requestStateChange?.();
389
+ const t = this.columns.map((e) => e.field);
390
+ this.updateColumnOrder(t);
391
+ }
392
+ // #endregion
393
+ // #region View Transition
394
+ /**
395
+ * Capture header cell positions before reorder.
396
+ */
397
+ captureHeaderPositions() {
398
+ const t = /* @__PURE__ */ new Map();
399
+ return this.shadowRoot?.querySelectorAll(".header-row > .cell[data-field]").forEach((e) => {
400
+ const i = e.getAttribute("data-field");
401
+ i && t.set(i, e.getBoundingClientRect().left);
402
+ }), t;
403
+ }
404
+ /**
405
+ * Apply FLIP animation for column reorder.
406
+ * Uses CSS transitions - JS sets initial transform and toggles class.
407
+ * @param oldPositions - Header positions captured before DOM change
408
+ */
409
+ animateFLIP(t) {
410
+ const e = this.shadowRoot;
411
+ if (!e || t.size === 0) return;
412
+ const i = /* @__PURE__ */ new Map();
413
+ if (e.querySelectorAll(".header-row > .cell[data-field]").forEach((n) => {
414
+ const o = n.getAttribute("data-field");
415
+ if (!o) return;
416
+ const l = t.get(o);
417
+ if (l === void 0) return;
418
+ const s = l - n.getBoundingClientRect().left;
419
+ Math.abs(s) > 1 && i.set(o, s);
420
+ }), i.size === 0) return;
421
+ const r = [];
422
+ if (e.querySelectorAll(".cell[data-field]").forEach((n) => {
423
+ const o = i.get(n.getAttribute("data-field") ?? "");
424
+ if (o !== void 0) {
425
+ const l = n;
426
+ l.style.transform = `translateX(${o}px)`, r.push(l);
427
+ }
428
+ }), r.length === 0) return;
429
+ e.host.offsetHeight;
430
+ const c = this.animationDuration;
431
+ requestAnimationFrame(() => {
432
+ r.forEach((n) => {
433
+ n.classList.add("flip-animating"), n.style.transform = "";
434
+ }), setTimeout(() => {
435
+ r.forEach((n) => {
436
+ n.style.transform = "", n.classList.remove("flip-animating");
437
+ });
438
+ }, c + 50);
439
+ });
440
+ }
441
+ /**
442
+ * Apply crossfade animation for moved columns.
443
+ * Uses CSS keyframes - JS just toggles classes.
444
+ */
445
+ animateFade(t) {
446
+ const e = this.shadowRoot;
447
+ if (!e) {
448
+ t();
449
+ return;
450
+ }
451
+ const i = this.captureHeaderPositions();
452
+ t();
453
+ const r = /* @__PURE__ */ new Set();
454
+ if (e.querySelectorAll(".header-row > .cell[data-field]").forEach((o) => {
455
+ const l = o.getAttribute("data-field");
456
+ if (!l) return;
457
+ const s = i.get(l);
458
+ if (s === void 0) return;
459
+ const d = o.getBoundingClientRect().left;
460
+ Math.abs(s - d) > 1 && r.add(l);
461
+ }), r.size === 0) return;
462
+ const c = [];
463
+ if (e.querySelectorAll(".cell[data-field]").forEach((o) => {
464
+ const l = o.getAttribute("data-field");
465
+ if (l && r.has(l)) {
466
+ const s = o;
467
+ s.classList.add("fade-animating"), c.push(s);
468
+ }
469
+ }), c.length === 0) return;
470
+ const n = this.animationDuration;
471
+ setTimeout(() => {
472
+ c.forEach((o) => o.classList.remove("fade-animating"));
473
+ }, n + 50);
474
+ }
475
+ /**
476
+ * Update column order with configured animation.
477
+ */
478
+ updateColumnOrder(t) {
479
+ const e = this.grid, i = this.animationType;
480
+ if (i === "flip" && this.shadowRoot) {
481
+ const r = this.captureHeaderPositions();
482
+ e.setColumnOrder(t), this.shadowRoot.host.offsetHeight, this.animateFLIP(r);
483
+ } else i === "fade" ? this.animateFade(() => e.setColumnOrder(t)) : e.setColumnOrder(t);
484
+ e.requestStateChange?.();
292
485
  }
293
486
  // #endregion
294
487
  // #region Styles
295
- styles = O;
488
+ styles = A;
296
489
  // #endregion
297
490
  }
298
491
  export {
299
- E as ReorderPlugin
492
+ L as ReorderPlugin
300
493
  };
301
494
  //# sourceMappingURL=index.js.map