@toolbox-web/grid 0.2.6 → 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 (52) hide show
  1. package/all.d.ts +434 -61
  2. package/all.js +844 -541
  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 +210 -6
  7. package/index.js +25 -3194
  8. package/index.js.map +1 -1
  9. package/lib/plugins/clipboard/index.js.map +1 -1
  10. package/lib/plugins/column-virtualization/index.js.map +1 -1
  11. package/lib/plugins/context-menu/index.js.map +1 -1
  12. package/lib/plugins/export/index.js.map +1 -1
  13. package/lib/plugins/filtering/index.js +183 -148
  14. package/lib/plugins/filtering/index.js.map +1 -1
  15. package/lib/plugins/grouping-columns/index.js.map +1 -1
  16. package/lib/plugins/grouping-rows/index.js +116 -82
  17. package/lib/plugins/grouping-rows/index.js.map +1 -1
  18. package/lib/plugins/master-detail/index.js +139 -81
  19. package/lib/plugins/master-detail/index.js.map +1 -1
  20. package/lib/plugins/multi-sort/index.js +17 -17
  21. package/lib/plugins/multi-sort/index.js.map +1 -1
  22. package/lib/plugins/pinned-columns/index.js.map +1 -1
  23. package/lib/plugins/pinned-rows/index.js.map +1 -1
  24. package/lib/plugins/pivot/index.js +369 -337
  25. package/lib/plugins/pivot/index.js.map +1 -1
  26. package/lib/plugins/reorder/index.js +264 -91
  27. package/lib/plugins/reorder/index.js.map +1 -1
  28. package/lib/plugins/selection/index.js.map +1 -1
  29. package/lib/plugins/server-side/index.js.map +1 -1
  30. package/lib/plugins/tree/index.js +180 -169
  31. package/lib/plugins/tree/index.js.map +1 -1
  32. package/lib/plugins/undo-redo/index.js.map +1 -1
  33. package/lib/plugins/visibility/index.js.map +1 -1
  34. package/package.json +1 -1
  35. package/umd/grid.all.umd.js +21 -21
  36. package/umd/grid.all.umd.js.map +1 -1
  37. package/umd/grid.umd.js +12 -12
  38. package/umd/grid.umd.js.map +1 -1
  39. package/umd/plugins/filtering.umd.js +1 -1
  40. package/umd/plugins/filtering.umd.js.map +1 -1
  41. package/umd/plugins/grouping-rows.umd.js +1 -1
  42. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  43. package/umd/plugins/master-detail.umd.js +1 -1
  44. package/umd/plugins/master-detail.umd.js.map +1 -1
  45. package/umd/plugins/multi-sort.umd.js +1 -1
  46. package/umd/plugins/multi-sort.umd.js.map +1 -1
  47. package/umd/plugins/pivot.umd.js +1 -1
  48. package/umd/plugins/pivot.umd.js.map +1 -1
  49. package/umd/plugins/reorder.umd.js +1 -1
  50. package/umd/plugins/reorder.umd.js.map +1 -1
  51. package/umd/plugins/tree.umd.js +1 -1
  52. 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
- }, w = {
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 b {
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 b {
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 b {
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, t) {
66
- this.grid?.dispatchEvent?.(new CustomEvent(e, { detail: t, 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.
@@ -135,8 +178,8 @@ class b {
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 b {
146
189
  * @param pluginOverride - Optional plugin-level override
147
190
  * @returns The resolved icon value
148
191
  */
149
- resolveIcon(e, t) {
150
- return t !== void 0 ? t : 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,35 +199,67 @@ class b {
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, t) {
160
- typeof t == "string" ? e.innerHTML = t : t instanceof HTMLElement && (e.innerHTML = "", e.appendChild(t.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 O(o) {
171
- const e = o.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 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;
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 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 {
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
- viewTransition: !0
228
+ animation: "flip"
229
+ // Plugin's own default
186
230
  };
187
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
+ }
188
263
  // #region Internal State
189
264
  isDragging = !1;
190
265
  draggedField = null;
@@ -192,12 +267,12 @@ class I extends b {
192
267
  dropIndex = null;
193
268
  // #endregion
194
269
  // #region Lifecycle
195
- attach(e) {
196
- super.attach(e), e.addEventListener(
270
+ attach(t) {
271
+ super.attach(t), t.addEventListener(
197
272
  "column-reorder-request",
198
- (t) => {
199
- const n = t.detail;
200
- n?.field && typeof n.toIndex == "number" && this.moveColumn(n.field, n.toIndex);
273
+ (e) => {
274
+ const i = e.detail;
275
+ i?.field && typeof i.toIndex == "number" && this.moveColumn(i.field, i.toIndex);
201
276
  },
202
277
  { signal: this.disconnectSignal }
203
278
  );
@@ -208,47 +283,73 @@ class I extends b {
208
283
  // #endregion
209
284
  // #region Hooks
210
285
  afterRender() {
211
- const e = this.shadowRoot;
212
- if (!e) return;
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
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
219
294
  }).includes(!1);
220
- if (!a || !O(a) || !p) {
295
+ if (!n || !w(n) || !s) {
221
296
  r.draggable = !1;
222
297
  return;
223
298
  }
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");
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");
227
302
  }), 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");
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");
230
305
  });
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);
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);
235
310
  }), r.addEventListener("dragleave", () => {
236
311
  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)
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)
241
316
  return;
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
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
247
322
  };
248
- this.updateColumnOrder(h), this.emit("column-move", v);
323
+ this.updateColumnOrder(b), this.emit("column-move", C);
249
324
  }));
250
325
  });
251
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
+ }
252
353
  // #endregion
253
354
  // #region Public API
254
355
  /**
@@ -263,59 +364,131 @@ class I extends b {
263
364
  * @param field - The field name of the column to move
264
365
  * @param toIndex - The target index
265
366
  */
266
- moveColumn(e, t) {
267
- const n = this.getColumnOrder(), r = n.indexOf(e);
367
+ moveColumn(t, e) {
368
+ const i = this.getColumnOrder(), r = i.indexOf(t);
268
369
  if (r === -1) return;
269
- const s = f(n, r, t);
270
- this.updateColumnOrder(s), this.emit("column-move", {
271
- field: e,
370
+ const c = v(i, r, e);
371
+ this.updateColumnOrder(c), this.emit("column-move", {
372
+ field: t,
272
373
  fromIndex: r,
273
- toIndex: t,
274
- columnOrder: s
374
+ toIndex: e,
375
+ columnOrder: c
275
376
  });
276
377
  }
277
378
  /**
278
379
  * Set a specific column order.
279
380
  * @param order - Array of field names in desired order
280
381
  */
281
- setColumnOrder(e) {
282
- this.updateColumnOrder(e);
382
+ setColumnOrder(t) {
383
+ this.updateColumnOrder(t);
283
384
  }
284
385
  /**
285
386
  * Reset column order to the original configuration order.
286
387
  */
287
388
  resetColumnOrder() {
288
- const e = this.columns.map((t) => t.field);
289
- this.updateColumnOrder(e);
389
+ const t = this.columns.map((e) => e.field);
390
+ this.updateColumnOrder(t);
290
391
  }
291
392
  // #endregion
292
393
  // #region View Transition
293
394
  /**
294
- * Update column order with optional view transition animation.
295
- * Falls back to instant update if View Transitions API is not supported.
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
296
408
  */
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 = "";
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");
307
437
  });
308
- });
309
- } else
310
- t.setColumnOrder(e);
311
- t.requestStateChange?.();
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?.();
312
485
  }
313
486
  // #endregion
314
487
  // #region Styles
315
- styles = x;
488
+ styles = A;
316
489
  // #endregion
317
490
  }
318
491
  export {
319
- I as ReorderPlugin
492
+ L as ReorderPlugin
320
493
  };
321
494
  //# sourceMappingURL=index.js.map