@toolbox-web/grid 0.4.2 → 0.5.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.
- package/README.md +1 -2
- package/all.js +1060 -1023
- package/all.js.map +1 -1
- package/index.js +588 -502
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +11 -0
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/dom-builder.d.ts +2 -0
- package/lib/core/internal/dom-builder.d.ts.map +1 -1
- package/lib/core/internal/header.d.ts.map +1 -1
- package/lib/core/internal/resize.d.ts.map +1 -1
- package/lib/core/internal/rows.d.ts.map +1 -1
- package/lib/core/internal/shell.d.ts +19 -13
- package/lib/core/internal/shell.d.ts.map +1 -1
- package/lib/core/plugin/base-plugin.d.ts +13 -2
- package/lib/core/plugin/base-plugin.d.ts.map +1 -1
- package/lib/core/plugin/expander-column.d.ts.map +1 -1
- package/lib/core/plugin/plugin-manager.d.ts +6 -2
- package/lib/core/plugin/plugin-manager.d.ts.map +1 -1
- package/lib/core/types.d.ts +6 -3
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +22 -11
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +59 -48
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +71 -60
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts +1 -0
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +93 -80
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js +29 -18
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts +9 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +199 -165
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts +1 -0
- package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts.map +1 -1
- package/lib/plugins/grouping-columns/index.js +79 -49
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/grouping-rows/index.js +98 -87
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +70 -57
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +48 -37
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts.map +1 -1
- package/lib/plugins/pinned-columns/index.js +71 -66
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-columns/pinned-columns.d.ts +2 -2
- package/lib/plugins/pinned-columns/pinned-columns.d.ts.map +1 -1
- package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/pinned-rows/index.js +63 -52
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/PivotPlugin.d.ts.map +1 -1
- package/lib/plugins/pivot/index.js +310 -299
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/ReorderPlugin.d.ts.map +1 -1
- package/lib/plugins/reorder/index.d.ts +1 -1
- package/lib/plugins/reorder/index.d.ts.map +1 -1
- package/lib/plugins/reorder/index.js +79 -68
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
- package/lib/plugins/selection/index.js +115 -105
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +15 -4
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/TreePlugin.d.ts.map +1 -1
- package/lib/plugins/tree/index.js +41 -30
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +29 -18
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/VisibilityPlugin.d.ts.map +1 -1
- package/lib/plugins/visibility/index.js +59 -47
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/themes/dg-theme-bootstrap.css +55 -53
- package/themes/dg-theme-contrast.css +42 -40
- package/themes/dg-theme-large.css +38 -37
- package/themes/dg-theme-material.css +54 -52
- package/themes/dg-theme-standard.css +19 -17
- package/themes/dg-theme-vibrant.css +16 -14
- package/umd/grid.all.umd.js +23 -22
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +12 -11
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/column-virtualization.umd.js +1 -1
- package/umd/plugins/column-virtualization.umd.js.map +1 -1
- package/umd/plugins/context-menu.umd.js +1 -1
- package/umd/plugins/context-menu.umd.js.map +1 -1
- package/umd/plugins/editing.umd.js +1 -1
- package/umd/plugins/editing.umd.js.map +1 -1
- package/umd/plugins/filtering.umd.js +1 -1
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/grouping-columns.umd.js +1 -1
- package/umd/plugins/grouping-columns.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js +1 -1
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js +1 -1
- package/umd/plugins/master-detail.umd.js.map +1 -1
- package/umd/plugins/multi-sort.umd.js +1 -1
- package/umd/plugins/multi-sort.umd.js.map +1 -1
- package/umd/plugins/pinned-columns.umd.js +1 -1
- package/umd/plugins/pinned-columns.umd.js.map +1 -1
- package/umd/plugins/pinned-rows.umd.js +1 -1
- package/umd/plugins/pinned-rows.umd.js.map +1 -1
- package/umd/plugins/pivot.umd.js +1 -1
- package/umd/plugins/pivot.umd.js.map +1 -1
- package/umd/plugins/reorder.umd.js +1 -1
- package/umd/plugins/reorder.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +1 -1
- package/umd/plugins/selection.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js +1 -1
- package/umd/plugins/tree.umd.js.map +1 -1
- package/umd/plugins/visibility.umd.js +1 -1
- package/umd/plugins/visibility.umd.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReorderPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/reorder/ReorderPlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,cAAc,EAAkB,MAAM,+BAA+B,CAAC;AAI/E,OAAO,KAAK,EAAoB,aAAa,EAAE,MAAM,SAAS,CAAC;AAE/D;;;;;;;GAOG;AACH,qBAAa,aAAc,SAAQ,cAAc,CAAC,aAAa,CAAC;IAC9D,QAAQ,CAAC,IAAI,aAAa;IAC1B,SAAkB,MAAM,SAAU;IAElC,cAAuB,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC,CAI7D;IAED;;;OAGG;IACH,OAAO,KAAK,aAAa,GAYxB;IAED;;;OAGG;IACH,cAAuB,iBAAiB,IAAI,MAAM,CAMjD;IAGD,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,SAAS,CAAuB;IAExC;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAShC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IASf,MAAM,CAAC,IAAI,EAAE,OAAO,+BAA+B,EAAE,WAAW,GAAG,IAAI;IAiBvE,MAAM,IAAI,IAAI;IAUd,WAAW,IAAI,IAAI;
|
|
1
|
+
{"version":3,"file":"ReorderPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/reorder/ReorderPlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,cAAc,EAAkB,MAAM,+BAA+B,CAAC;AAI/E,OAAO,KAAK,EAAoB,aAAa,EAAE,MAAM,SAAS,CAAC;AAE/D;;;;;;;GAOG;AACH,qBAAa,aAAc,SAAQ,cAAc,CAAC,aAAa,CAAC;IAC9D,QAAQ,CAAC,IAAI,aAAa;IAC1B,SAAkB,MAAM,SAAU;IAElC,cAAuB,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC,CAI7D;IAED;;;OAGG;IACH,OAAO,KAAK,aAAa,GAYxB;IAED;;;OAGG;IACH,cAAuB,iBAAiB,IAAI,MAAM,CAMjD;IAGD,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,SAAS,CAAuB;IAExC;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAShC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IASf,MAAM,CAAC,IAAI,EAAE,OAAO,+BAA+B,EAAE,WAAW,GAAG,IAAI;IAiBvE,MAAM,IAAI,IAAI;IAUd,WAAW,IAAI,IAAI;IAiG5B;;OAEG;IACM,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,GAAG,IAAI;IAyCxD;;;OAGG;IACH,cAAc,IAAI,MAAM,EAAE;IAI1B;;;;OAIG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAoBhD;;;OAGG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI;IAIrC;;OAEG;IACH,gBAAgB,IAAI,IAAI;IAQxB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAS9B;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAmDnB;;;OAGG;IACH,OAAO,CAAC,WAAW;IAgDnB;;OAEG;IACH,OAAO,CAAC,iBAAiB;CAqB1B"}
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* Re-exports plugin class and types for tree-shakeable imports.
|
|
4
4
|
*/
|
|
5
5
|
export { ReorderPlugin } from './ReorderPlugin';
|
|
6
|
-
export type { ReorderAnimation, ReorderConfig } from './types';
|
|
6
|
+
export type { ColumnMoveDetail, ReorderAnimation, ReorderConfig } from './types';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/reorder/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/reorder/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
function b(
|
|
2
|
-
|
|
1
|
+
function b(l) {
|
|
2
|
+
l && l.querySelectorAll(".cell-focus").forEach((e) => e.classList.remove("cell-focus"));
|
|
3
3
|
}
|
|
4
|
-
const v = 'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])',
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
function
|
|
9
|
-
if (
|
|
10
|
-
const { rowHeight:
|
|
4
|
+
const v = 'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])', C = document.createElement("template");
|
|
5
|
+
C.innerHTML = '<div class="cell" role="gridcell" part="cell"></div>';
|
|
6
|
+
const E = document.createElement("template");
|
|
7
|
+
E.innerHTML = '<div class="data-grid-row" role="row" part="row"></div>';
|
|
8
|
+
function w(l, e) {
|
|
9
|
+
if (l._virtualization?.enabled) {
|
|
10
|
+
const { rowHeight: a, container: r, viewportEl: s } = l._virtualization, o = r, c = s?.clientHeight ?? o?.clientHeight ?? 0;
|
|
11
11
|
if (o && c > 0) {
|
|
12
|
-
const u =
|
|
13
|
-
u < o.scrollTop ? o.scrollTop = u : u +
|
|
12
|
+
const u = l._focusRow * a;
|
|
13
|
+
u < o.scrollTop ? o.scrollTop = u : u + a > o.scrollTop + c && (o.scrollTop = u - c + a);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
const t =
|
|
17
|
-
t ||
|
|
18
|
-
|
|
16
|
+
const t = l._activeEditRows !== void 0 && l._activeEditRows !== -1;
|
|
17
|
+
t || l.refreshVirtualWindow(!1), b(l._bodyEl), Array.from(l._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach((a) => {
|
|
18
|
+
a.setAttribute("aria-selected", "false");
|
|
19
19
|
});
|
|
20
|
-
const i =
|
|
20
|
+
const i = l._focusRow, n = l._virtualization.start ?? 0, d = l._virtualization.end ?? l._rows.length;
|
|
21
21
|
if (i >= n && i < d) {
|
|
22
|
-
const
|
|
23
|
-
let r =
|
|
24
|
-
if ((!r || !r.classList?.contains("cell")) && (r =
|
|
22
|
+
const a = l._bodyEl.querySelectorAll(".data-grid-row")[i - n];
|
|
23
|
+
let r = a?.children[l._focusCol];
|
|
24
|
+
if ((!r || !r.classList?.contains("cell")) && (r = a?.querySelector(`.cell[data-col="${l._focusCol}"]`) ?? a?.querySelector(".cell[data-col]")), r) {
|
|
25
25
|
r.classList.add("cell-focus"), r.setAttribute("aria-selected", "true");
|
|
26
|
-
const s =
|
|
26
|
+
const s = l.querySelector(".tbw-scroll-area");
|
|
27
27
|
if (s && r && !t) {
|
|
28
|
-
const o =
|
|
28
|
+
const o = l._getHorizontalScrollOffsets?.(a ?? void 0, r) ?? { left: 0, right: 0 };
|
|
29
29
|
if (!o.skipScroll) {
|
|
30
30
|
const c = r.getBoundingClientRect(), u = s.getBoundingClientRect(), f = c.left - u.left + s.scrollLeft, g = f + c.width, h = s.scrollLeft + o.left, m = s.scrollLeft + s.clientWidth - o.right;
|
|
31
31
|
f < h ? s.scrollLeft = f - o.left : g > m && (s.scrollLeft = g - s.clientWidth + o.right);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
if (
|
|
34
|
+
if (l._activeEditRows !== void 0 && l._activeEditRows !== -1 && r.classList.contains("editing")) {
|
|
35
35
|
const o = r.querySelector(v);
|
|
36
36
|
if (o && document.activeElement !== o)
|
|
37
37
|
try {
|
|
@@ -48,7 +48,7 @@ function E(a, e) {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
const
|
|
51
|
+
const y = {
|
|
52
52
|
expand: "▶",
|
|
53
53
|
collapse: "▼",
|
|
54
54
|
sortAsc: "▲",
|
|
@@ -57,11 +57,11 @@ const R = {
|
|
|
57
57
|
submenuArrow: "▶",
|
|
58
58
|
dragHandle: "⋮⋮",
|
|
59
59
|
toolPanel: "☰"
|
|
60
|
-
},
|
|
60
|
+
}, L = {
|
|
61
61
|
/** Ask if a column can be moved. Context: ColumnConfig. Response: boolean | undefined */
|
|
62
62
|
CAN_MOVE_COLUMN: "canMoveColumn"
|
|
63
63
|
};
|
|
64
|
-
class
|
|
64
|
+
class A {
|
|
65
65
|
/**
|
|
66
66
|
* Plugin dependencies - declare other plugins this one requires.
|
|
67
67
|
*
|
|
@@ -238,10 +238,21 @@ class L {
|
|
|
238
238
|
return this.grid;
|
|
239
239
|
}
|
|
240
240
|
/**
|
|
241
|
-
* Get the
|
|
241
|
+
* Get the render root of the grid for DOM queries.
|
|
242
|
+
* @deprecated Use `gridElement` instead. This getter exists only for backward compatibility.
|
|
243
|
+
*
|
|
244
|
+
* With Shadow DOM removed, the grid element itself is the render root.
|
|
245
|
+
* All new code should use `this.gridElement` for DOM queries.
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* // OLD (deprecated)
|
|
249
|
+
* const rows = this.shadowRoot?.querySelector('.rows');
|
|
250
|
+
*
|
|
251
|
+
* // NEW (preferred)
|
|
252
|
+
* const rows = this.gridElement.querySelector('.rows');
|
|
242
253
|
*/
|
|
243
254
|
get shadowRoot() {
|
|
244
|
-
return this.
|
|
255
|
+
return this.gridElement;
|
|
245
256
|
}
|
|
246
257
|
/**
|
|
247
258
|
* Get the disconnect signal for event listener cleanup.
|
|
@@ -269,7 +280,7 @@ class L {
|
|
|
269
280
|
*/
|
|
270
281
|
get gridIcons() {
|
|
271
282
|
const e = this.grid?.gridConfig?.icons ?? {};
|
|
272
|
-
return { ...
|
|
283
|
+
return { ...y, ...e };
|
|
273
284
|
}
|
|
274
285
|
// #region Animation Helpers
|
|
275
286
|
/**
|
|
@@ -292,7 +303,7 @@ class L {
|
|
|
292
303
|
const e = this.grid?.effectiveConfig?.animation?.mode ?? "reduced-motion";
|
|
293
304
|
if (e === !1 || e === "off") return !1;
|
|
294
305
|
if (e === !0 || e === "on") return !0;
|
|
295
|
-
const t = this.
|
|
306
|
+
const t = this.gridElement;
|
|
296
307
|
return t ? getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim() !== "0" : !0;
|
|
297
308
|
}
|
|
298
309
|
/**
|
|
@@ -308,7 +319,7 @@ class L {
|
|
|
308
319
|
* ```
|
|
309
320
|
*/
|
|
310
321
|
get animationDuration() {
|
|
311
|
-
const e = this.
|
|
322
|
+
const e = this.gridElement;
|
|
312
323
|
if (e) {
|
|
313
324
|
const t = getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(), i = parseInt(t, 10);
|
|
314
325
|
if (!isNaN(i)) return i;
|
|
@@ -345,19 +356,19 @@ class L {
|
|
|
345
356
|
}
|
|
346
357
|
// #endregion
|
|
347
358
|
}
|
|
348
|
-
function O(
|
|
349
|
-
const e =
|
|
359
|
+
function O(l) {
|
|
360
|
+
const e = l.meta ?? {};
|
|
350
361
|
return e.lockPosition !== !0 && e.suppressMovable !== !0;
|
|
351
362
|
}
|
|
352
|
-
function p(
|
|
353
|
-
if (e === t || e < 0 || e >=
|
|
354
|
-
const i = [...
|
|
363
|
+
function p(l, e, t) {
|
|
364
|
+
if (e === t || e < 0 || e >= l.length || t < 0 || t > l.length) return l;
|
|
365
|
+
const i = [...l], [n] = i.splice(e, 1);
|
|
355
366
|
return i.splice(t, 0, n), i;
|
|
356
367
|
}
|
|
357
|
-
const
|
|
358
|
-
class
|
|
368
|
+
const _ = '@layer tbw-plugins{.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}}';
|
|
369
|
+
class R extends A {
|
|
359
370
|
name = "reorder";
|
|
360
|
-
styles =
|
|
371
|
+
styles = _;
|
|
361
372
|
get defaultConfig() {
|
|
362
373
|
return {
|
|
363
374
|
animation: "flip"
|
|
@@ -388,7 +399,7 @@ class _ extends L {
|
|
|
388
399
|
*/
|
|
389
400
|
canMoveColumnWithPlugins(e) {
|
|
390
401
|
return !e || !O(e) ? !1 : !this.grid.queryPlugins({
|
|
391
|
-
type:
|
|
402
|
+
type: L.CAN_MOVE_COLUMN,
|
|
392
403
|
context: e
|
|
393
404
|
}).includes(!1);
|
|
394
405
|
}
|
|
@@ -396,7 +407,7 @@ class _ extends L {
|
|
|
396
407
|
* Clear all drag-related classes from header cells.
|
|
397
408
|
*/
|
|
398
409
|
clearDragClasses() {
|
|
399
|
-
this.
|
|
410
|
+
this.gridElement?.querySelectorAll(".header-row > .cell").forEach((e) => {
|
|
400
411
|
e.classList.remove("dragging", "drop-target", "drop-before", "drop-after");
|
|
401
412
|
});
|
|
402
413
|
}
|
|
@@ -418,13 +429,13 @@ class _ extends L {
|
|
|
418
429
|
// #endregion
|
|
419
430
|
// #region Hooks
|
|
420
431
|
afterRender() {
|
|
421
|
-
const e = this.
|
|
432
|
+
const e = this.gridElement;
|
|
422
433
|
if (!e) return;
|
|
423
434
|
e.querySelectorAll(".header-row > .cell").forEach((i) => {
|
|
424
435
|
const n = i, d = n.getAttribute("data-field");
|
|
425
436
|
if (!d) return;
|
|
426
|
-
const
|
|
427
|
-
if (!this.canMoveColumnWithPlugins(
|
|
437
|
+
const a = this.columns.find((r) => r.field === d);
|
|
438
|
+
if (!this.canMoveColumnWithPlugins(a)) {
|
|
428
439
|
n.draggable = !1;
|
|
429
440
|
return;
|
|
430
441
|
}
|
|
@@ -450,7 +461,7 @@ class _ extends L {
|
|
|
450
461
|
toIndex: u,
|
|
451
462
|
columnOrder: g
|
|
452
463
|
};
|
|
453
|
-
this.
|
|
464
|
+
this.emitCancelable("column-move", h) || this.updateColumnOrder(g);
|
|
454
465
|
}));
|
|
455
466
|
});
|
|
456
467
|
}
|
|
@@ -464,13 +475,13 @@ class _ extends L {
|
|
|
464
475
|
if (i < 0 || i >= n.length) return;
|
|
465
476
|
const d = n[i];
|
|
466
477
|
if (!this.canMoveColumnWithPlugins(d)) return;
|
|
467
|
-
const
|
|
478
|
+
const a = this.getColumnOrder(), r = a.indexOf(d.field);
|
|
468
479
|
if (r === -1) return;
|
|
469
480
|
const s = e.key === "ArrowLeft" ? r - 1 : r + 1;
|
|
470
|
-
if (s < 0 || s >=
|
|
471
|
-
const o = n.find((c) => c.field ===
|
|
481
|
+
if (s < 0 || s >= a.length) return;
|
|
482
|
+
const o = n.find((c) => c.field === a[s]);
|
|
472
483
|
if (this.canMoveColumnWithPlugins(o))
|
|
473
|
-
return this.moveColumn(d.field, s), t._focusCol = s,
|
|
484
|
+
return this.moveColumn(d.field, s), t._focusCol = s, w(this.grid), e.preventDefault(), e.stopPropagation(), !0;
|
|
474
485
|
}
|
|
475
486
|
// #endregion
|
|
476
487
|
// #region Public API
|
|
@@ -490,12 +501,12 @@ class _ extends L {
|
|
|
490
501
|
const i = this.getColumnOrder(), n = i.indexOf(e);
|
|
491
502
|
if (n === -1) return;
|
|
492
503
|
const d = p(i, n, t);
|
|
493
|
-
this.
|
|
504
|
+
this.emitCancelable("column-move", {
|
|
494
505
|
field: e,
|
|
495
506
|
fromIndex: n,
|
|
496
507
|
toIndex: t,
|
|
497
508
|
columnOrder: d
|
|
498
|
-
})
|
|
509
|
+
}) || this.updateColumnOrder(d);
|
|
499
510
|
}
|
|
500
511
|
/**
|
|
501
512
|
* Set a specific column order.
|
|
@@ -518,7 +529,7 @@ class _ extends L {
|
|
|
518
529
|
*/
|
|
519
530
|
captureHeaderPositions() {
|
|
520
531
|
const e = /* @__PURE__ */ new Map();
|
|
521
|
-
return this.
|
|
532
|
+
return this.gridElement?.querySelectorAll(".header-row > .cell[data-field]").forEach((t) => {
|
|
522
533
|
const i = t.getAttribute("data-field");
|
|
523
534
|
i && e.set(i, t.getBoundingClientRect().left);
|
|
524
535
|
}), e;
|
|
@@ -529,33 +540,33 @@ class _ extends L {
|
|
|
529
540
|
* @param oldPositions - Header positions captured before DOM change
|
|
530
541
|
*/
|
|
531
542
|
animateFLIP(e) {
|
|
532
|
-
const t = this.
|
|
543
|
+
const t = this.gridElement;
|
|
533
544
|
if (!t || e.size === 0) return;
|
|
534
545
|
const i = /* @__PURE__ */ new Map();
|
|
535
|
-
if (t.querySelectorAll(".header-row > .cell[data-field]").forEach((
|
|
536
|
-
const r =
|
|
546
|
+
if (t.querySelectorAll(".header-row > .cell[data-field]").forEach((a) => {
|
|
547
|
+
const r = a.getAttribute("data-field");
|
|
537
548
|
if (!r) return;
|
|
538
549
|
const s = e.get(r);
|
|
539
550
|
if (s === void 0) return;
|
|
540
|
-
const o = s -
|
|
551
|
+
const o = s - a.getBoundingClientRect().left;
|
|
541
552
|
Math.abs(o) > 1 && i.set(r, o);
|
|
542
553
|
}), i.size === 0) return;
|
|
543
554
|
const n = [];
|
|
544
|
-
if (t.querySelectorAll(".cell[data-field]").forEach((
|
|
545
|
-
const r = i.get(
|
|
555
|
+
if (t.querySelectorAll(".cell[data-field]").forEach((a) => {
|
|
556
|
+
const r = i.get(a.getAttribute("data-field") ?? "");
|
|
546
557
|
if (r !== void 0) {
|
|
547
|
-
const s =
|
|
558
|
+
const s = a;
|
|
548
559
|
s.style.transform = `translateX(${r}px)`, n.push(s);
|
|
549
560
|
}
|
|
550
561
|
}), n.length === 0) return;
|
|
551
|
-
|
|
562
|
+
this.gridElement.offsetHeight;
|
|
552
563
|
const d = this.animationDuration;
|
|
553
564
|
requestAnimationFrame(() => {
|
|
554
|
-
n.forEach((
|
|
555
|
-
|
|
565
|
+
n.forEach((a) => {
|
|
566
|
+
a.classList.add("flip-animating"), a.style.transform = "";
|
|
556
567
|
}), setTimeout(() => {
|
|
557
|
-
n.forEach((
|
|
558
|
-
|
|
568
|
+
n.forEach((a) => {
|
|
569
|
+
a.style.transform = "", a.classList.remove("flip-animating");
|
|
559
570
|
});
|
|
560
571
|
}, d + 50);
|
|
561
572
|
});
|
|
@@ -565,7 +576,7 @@ class _ extends L {
|
|
|
565
576
|
* Uses CSS keyframes - JS just toggles classes.
|
|
566
577
|
*/
|
|
567
578
|
animateFade(e) {
|
|
568
|
-
const t = this.
|
|
579
|
+
const t = this.gridElement;
|
|
569
580
|
if (!t) {
|
|
570
581
|
e();
|
|
571
582
|
return;
|
|
@@ -589,20 +600,20 @@ class _ extends L {
|
|
|
589
600
|
o.classList.add("fade-animating"), d.push(o);
|
|
590
601
|
}
|
|
591
602
|
}), d.length === 0) return;
|
|
592
|
-
const
|
|
603
|
+
const a = this.animationDuration;
|
|
593
604
|
setTimeout(() => {
|
|
594
605
|
d.forEach((r) => r.classList.remove("fade-animating"));
|
|
595
|
-
},
|
|
606
|
+
}, a + 50);
|
|
596
607
|
}
|
|
597
608
|
/**
|
|
598
609
|
* Update column order with configured animation.
|
|
599
610
|
*/
|
|
600
611
|
updateColumnOrder(e) {
|
|
601
612
|
const t = this.animationType;
|
|
602
|
-
if (t === "flip" && this.
|
|
613
|
+
if (t === "flip" && this.gridElement) {
|
|
603
614
|
const i = this.captureHeaderPositions();
|
|
604
615
|
this.grid.setColumnOrder(e), requestAnimationFrame(() => {
|
|
605
|
-
this.
|
|
616
|
+
this.gridElement.offsetHeight, this.animateFLIP(i);
|
|
606
617
|
});
|
|
607
618
|
} else t === "fade" ? this.animateFade(() => this.grid.setColumnOrder(e)) : this.grid.setColumnOrder(e);
|
|
608
619
|
this.grid.requestStateChange?.();
|
|
@@ -610,6 +621,6 @@ class _ extends L {
|
|
|
610
621
|
// #endregion
|
|
611
622
|
}
|
|
612
623
|
export {
|
|
613
|
-
|
|
624
|
+
R as ReorderPlugin
|
|
614
625
|
};
|
|
615
626
|
//# sourceMappingURL=index.js.map
|