@toolbox-web/grid 1.16.1 → 1.18.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 +126 -41
- package/all.js +1046 -936
- package/all.js.map +1 -1
- package/index.js +394 -369
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +13 -3
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/header.d.ts.map +1 -1
- package/lib/core/internal/keyboard.d.ts.map +1 -1
- package/lib/core/internal/shell.d.ts +11 -0
- package/lib/core/internal/shell.d.ts.map +1 -1
- package/lib/core/plugin/types.d.ts +1 -0
- package/lib/core/plugin/types.d.ts.map +1 -1
- package/lib/core/types.d.ts +42 -2
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +155 -145
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts +31 -0
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
- package/lib/plugins/filtering/filter-model.d.ts +30 -3
- package/lib/plugins/filtering/filter-model.d.ts.map +1 -1
- package/lib/plugins/filtering/index.d.ts +1 -0
- package/lib/plugins/filtering/index.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +471 -361
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/filtering/types.d.ts +32 -0
- package/lib/plugins/filtering/types.d.ts.map +1 -1
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/MultiSortPlugin.d.ts +4 -0
- package/lib/plugins/multi-sort/MultiSortPlugin.d.ts.map +1 -1
- package/lib/plugins/multi-sort/index.js +57 -47
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/print/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +81 -78
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/responsive/index.js +58 -55
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-reorder/index.js +5 -2
- package/lib/plugins/row-reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +29 -29
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +10 -10
- package/umd/grid.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/multi-sort.umd.js +1 -1
- package/umd/plugins/multi-sort.umd.js.map +1 -1
|
@@ -89,6 +89,10 @@ export declare class MultiSortPlugin extends BaseGridPlugin<MultiSortConfig> {
|
|
|
89
89
|
/** @internal */
|
|
90
90
|
protected get defaultConfig(): Partial<MultiSortConfig>;
|
|
91
91
|
private sortModel;
|
|
92
|
+
/** Cached sort result — returned as-is while a row edit is active to prevent
|
|
93
|
+
* the edited row from jumping to a new sorted position mid-edit. Row data
|
|
94
|
+
* mutations are still visible because the array holds shared object refs. */
|
|
95
|
+
private cachedSortResult;
|
|
92
96
|
/** @internal */
|
|
93
97
|
detach(): void;
|
|
94
98
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSortPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/multi-sort/MultiSortPlugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGpD,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EG;AACH,qBAAa,eAAgB,SAAQ,cAAc,CAAC,eAAe,CAAC;IAClE,gBAAgB;IAChB,QAAQ,CAAC,IAAI,eAAe;IAC5B,gBAAgB;IAChB,SAAkB,MAAM,SAAU;IAElC,gBAAgB;IAChB,cAAuB,aAAa,IAAI,OAAO,CAAC,eAAe,CAAC,CAK/D;IAGD,OAAO,CAAC,SAAS,CAAmB;
|
|
1
|
+
{"version":3,"file":"MultiSortPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/multi-sort/MultiSortPlugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGpD,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EG;AACH,qBAAa,eAAgB,SAAQ,cAAc,CAAC,eAAe,CAAC;IAClE,gBAAgB;IAChB,QAAQ,CAAC,IAAI,eAAe;IAC5B,gBAAgB;IAChB,SAAkB,MAAM,SAAU;IAElC,gBAAgB;IAChB,cAAu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se: "▼",
|
|
4
4
|
sortAsc: "▲",
|
|
@@ -7,8 +7,8 @@ const h = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentCo
|
|
|
7
7
|
submenuArrow: "▶",
|
|
8
8
|
dragHandle: "⋮⋮",
|
|
9
9
|
toolPanel: "☰",
|
|
10
|
-
filter:
|
|
11
|
-
filterActive:
|
|
10
|
+
filter: f,
|
|
11
|
+
filterActive: f,
|
|
12
12
|
print: "🖨️"
|
|
13
13
|
};
|
|
14
14
|
class C {
|
|
@@ -146,8 +146,8 @@ class C {
|
|
|
146
146
|
* @returns `true` if the event was cancelled (preventDefault called), `false` otherwise
|
|
147
147
|
*/
|
|
148
148
|
emitCancelable(t, e) {
|
|
149
|
-
const
|
|
150
|
-
return this.grid?.dispatchEvent?.(
|
|
149
|
+
const n = new CustomEvent(t, { detail: e, bubbles: !0, cancelable: !0 });
|
|
150
|
+
return this.grid?.dispatchEvent?.(n), n.defaultPrevented;
|
|
151
151
|
}
|
|
152
152
|
// =========================================================================
|
|
153
153
|
// Event Bus - Plugin-to-Plugin Communication
|
|
@@ -301,7 +301,7 @@ class C {
|
|
|
301
301
|
*/
|
|
302
302
|
get gridIcons() {
|
|
303
303
|
const t = this.grid?.gridConfig?.icons ?? {};
|
|
304
|
-
return { ...
|
|
304
|
+
return { ...S, ...t };
|
|
305
305
|
}
|
|
306
306
|
// #region Animation Helpers
|
|
307
307
|
/**
|
|
@@ -342,8 +342,8 @@ class C {
|
|
|
342
342
|
get animationDuration() {
|
|
343
343
|
const t = this.gridElement;
|
|
344
344
|
if (t) {
|
|
345
|
-
const e = getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(),
|
|
346
|
-
if (!isNaN(
|
|
345
|
+
const e = getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(), n = parseInt(e, 10);
|
|
346
|
+
if (!isNaN(n)) return n;
|
|
347
347
|
}
|
|
348
348
|
return 200;
|
|
349
349
|
}
|
|
@@ -377,29 +377,29 @@ class C {
|
|
|
377
377
|
}
|
|
378
378
|
// #endregion
|
|
379
379
|
}
|
|
380
|
-
function v(
|
|
381
|
-
return t.length ? [...
|
|
382
|
-
for (const
|
|
383
|
-
const d = e.find((
|
|
384
|
-
if (
|
|
385
|
-
return
|
|
380
|
+
function v(i, t, e) {
|
|
381
|
+
return t.length ? [...i].sort((n, r) => {
|
|
382
|
+
for (const s of t) {
|
|
383
|
+
const d = e.find((u) => u.field === s.field)?.sortComparator ?? x, g = n[s.field], c = r[s.field], o = d(g, c, n, r);
|
|
384
|
+
if (o !== 0)
|
|
385
|
+
return s.direction === "asc" ? o : -o;
|
|
386
386
|
}
|
|
387
387
|
return 0;
|
|
388
|
-
}) : [...
|
|
388
|
+
}) : [...i];
|
|
389
389
|
}
|
|
390
|
-
function
|
|
391
|
-
return
|
|
390
|
+
function x(i, t) {
|
|
391
|
+
return i == null && t == null ? 0 : i == null ? 1 : t == null ? -1 : typeof i == "number" && typeof t == "number" ? i - t : i instanceof Date && t instanceof Date ? i.getTime() - t.getTime() : typeof i == "boolean" && typeof t == "boolean" ? i === t ? 0 : i ? -1 : 1 : String(i).localeCompare(String(t));
|
|
392
392
|
}
|
|
393
|
-
function
|
|
394
|
-
const
|
|
395
|
-
return e ?
|
|
393
|
+
function M(i, t, e, n) {
|
|
394
|
+
const r = i.find((s) => s.field === t);
|
|
395
|
+
return e ? r ? r.direction === "asc" ? i.map((s) => s.field === t ? { ...s, direction: "desc" } : s) : i.filter((s) => s.field !== t) : i.length < n ? [...i, { field: t, direction: "asc" }] : i : r?.direction === "asc" ? [{ field: t, direction: "desc" }] : r?.direction === "desc" ? [] : [{ field: t, direction: "asc" }];
|
|
396
396
|
}
|
|
397
|
-
function m(
|
|
398
|
-
const e =
|
|
397
|
+
function m(i, t) {
|
|
398
|
+
const e = i.findIndex((n) => n.field === t);
|
|
399
399
|
return e >= 0 ? e + 1 : void 0;
|
|
400
400
|
}
|
|
401
|
-
function p(
|
|
402
|
-
return
|
|
401
|
+
function p(i, t) {
|
|
402
|
+
return i.find((e) => e.field === t)?.direction;
|
|
403
403
|
}
|
|
404
404
|
const w = '@layer tbw-plugins{.header-cell[data-sort=asc]:after{content:"↑";margin-left:var(--tbw-spacing-xs, .25em);opacity:.8}.header-cell[data-sort=desc]:after{content:"↓";margin-left:var(--tbw-spacing-xs, .25em);opacity:.8}.sort-indicator{margin-left:var(--tbw-spacing-xs, .25em);opacity:.8}.sort-index{font-size:var(--tbw-font-size-2xs, .7em);background:var(--tbw-multi-sort-badge-bg, var(--tbw-color-panel-bg));color:var(--tbw-multi-sort-badge-color, var(--tbw-color-fg));border-radius:50%;width:var(--tbw-multi-sort-badge-size, 1em);height:var(--tbw-multi-sort-badge-size, 1em);display:inline-flex;align-items:center;justify-content:center;margin-left:var(--tbw-spacing-xs, .125em);font-weight:600}}';
|
|
405
405
|
class y extends C {
|
|
@@ -416,44 +416,54 @@ class y extends C {
|
|
|
416
416
|
}
|
|
417
417
|
// #region Internal State
|
|
418
418
|
sortModel = [];
|
|
419
|
+
/** Cached sort result — returned as-is while a row edit is active to prevent
|
|
420
|
+
* the edited row from jumping to a new sorted position mid-edit. Row data
|
|
421
|
+
* mutations are still visible because the array holds shared object refs. */
|
|
422
|
+
cachedSortResult = null;
|
|
419
423
|
// #endregion
|
|
420
424
|
// #region Lifecycle
|
|
421
425
|
/** @internal */
|
|
422
426
|
detach() {
|
|
423
|
-
this.sortModel = [];
|
|
427
|
+
this.sortModel = [], this.cachedSortResult = null;
|
|
424
428
|
}
|
|
425
429
|
// #endregion
|
|
426
430
|
// #region Hooks
|
|
427
431
|
/** @internal */
|
|
428
432
|
processRows(t) {
|
|
429
|
-
|
|
433
|
+
if (this.sortModel.length === 0)
|
|
434
|
+
return this.cachedSortResult = null, [...t];
|
|
435
|
+
const e = this.gridElement;
|
|
436
|
+
if (e && !e._isGridEditMode && typeof e._activeEditRows == "number" && e._activeEditRows !== -1 && this.cachedSortResult && this.cachedSortResult.length === t.length)
|
|
437
|
+
return [...this.cachedSortResult];
|
|
438
|
+
const n = v([...t], this.sortModel, [...this.columns]);
|
|
439
|
+
return this.cachedSortResult = n, n;
|
|
430
440
|
}
|
|
431
441
|
/** @internal */
|
|
432
442
|
onHeaderClick(t) {
|
|
433
|
-
if (!this.columns.find((
|
|
434
|
-
const
|
|
435
|
-
return this.sortModel =
|
|
443
|
+
if (!this.columns.find((s) => s.field === t.field)?.sortable) return !1;
|
|
444
|
+
const n = t.originalEvent.shiftKey, r = this.config.maxSortColumns ?? 3;
|
|
445
|
+
return this.sortModel = M(this.sortModel, t.field, n, r), this.emit("sort-change", { sortModel: [...this.sortModel] }), this.requestRender(), this.grid?.requestStateChange?.(), !0;
|
|
436
446
|
}
|
|
437
447
|
/** @internal */
|
|
438
448
|
afterRender() {
|
|
439
449
|
const t = this.gridElement;
|
|
440
450
|
if (!t) return;
|
|
441
451
|
const e = this.config.showSortIndex !== !1;
|
|
442
|
-
t.querySelectorAll(".header-row .cell[data-field]").forEach((
|
|
443
|
-
const
|
|
444
|
-
if (!
|
|
445
|
-
const a = m(this.sortModel,
|
|
446
|
-
if (
|
|
447
|
-
|
|
448
|
-
const
|
|
449
|
-
|
|
450
|
-
const
|
|
451
|
-
if (
|
|
452
|
+
t.querySelectorAll(".header-row .cell[data-field]").forEach((r) => {
|
|
453
|
+
const s = r.getAttribute("data-field");
|
|
454
|
+
if (!s) return;
|
|
455
|
+
const a = m(this.sortModel, s), d = p(this.sortModel, s);
|
|
456
|
+
if (r.querySelector(".sort-index")?.remove(), d) {
|
|
457
|
+
r.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove(), r.setAttribute("data-sort", d);
|
|
458
|
+
const o = document.createElement("span");
|
|
459
|
+
o.className = "sort-indicator", this.setIcon(o, this.resolveIcon(d === "asc" ? "sortAsc" : "sortDesc"));
|
|
460
|
+
const u = r.querySelector(".tbw-filter-btn"), b = r.querySelector(".resize-handle"), h = u ?? b;
|
|
461
|
+
if (h ? r.insertBefore(o, h) : r.appendChild(o), e && this.sortModel.length > 1 && a !== void 0) {
|
|
452
462
|
const l = document.createElement("span");
|
|
453
|
-
l.className = "sort-index", l.textContent = String(a),
|
|
463
|
+
l.className = "sort-index", l.textContent = String(a), o.nextSibling ? r.insertBefore(l, o.nextSibling) : r.appendChild(l);
|
|
454
464
|
}
|
|
455
465
|
} else
|
|
456
|
-
|
|
466
|
+
r.removeAttribute("data-sort"), r.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();
|
|
457
467
|
});
|
|
458
468
|
}
|
|
459
469
|
// #endregion
|
|
@@ -470,13 +480,13 @@ class y extends C {
|
|
|
470
480
|
* @param model - New sort model to apply
|
|
471
481
|
*/
|
|
472
482
|
setSortModel(t) {
|
|
473
|
-
this.sortModel = [...t], this.emit("sort-change", { sortModel: [...t] }), this.requestRender();
|
|
483
|
+
this.sortModel = [...t], this.emit("sort-change", { sortModel: [...t] }), this.requestRender(), this.grid?.requestStateChange?.();
|
|
474
484
|
}
|
|
475
485
|
/**
|
|
476
486
|
* Clear all sorting.
|
|
477
487
|
*/
|
|
478
488
|
clearSort() {
|
|
479
|
-
this.sortModel = [], this.emit("sort-change", { sortModel: [] }), this.requestRender();
|
|
489
|
+
this.sortModel = [], this.emit("sort-change", { sortModel: [] }), this.requestRender(), this.grid?.requestStateChange?.();
|
|
480
490
|
}
|
|
481
491
|
/**
|
|
482
492
|
* Get the sort index (1-based) for a specific field.
|
|
@@ -501,7 +511,7 @@ class y extends C {
|
|
|
501
511
|
* @internal
|
|
502
512
|
*/
|
|
503
513
|
getColumnState(t) {
|
|
504
|
-
const e = this.sortModel.findIndex((
|
|
514
|
+
const e = this.sortModel.findIndex((r) => r.field === t);
|
|
505
515
|
return e === -1 ? void 0 : {
|
|
506
516
|
sort: {
|
|
507
517
|
direction: this.sortModel[e].direction,
|
|
@@ -516,14 +526,14 @@ class y extends C {
|
|
|
516
526
|
*/
|
|
517
527
|
applyColumnState(t, e) {
|
|
518
528
|
if (!e.sort) {
|
|
519
|
-
this.sortModel = this.sortModel.filter((
|
|
529
|
+
this.sortModel = this.sortModel.filter((s) => s.field !== t);
|
|
520
530
|
return;
|
|
521
531
|
}
|
|
522
|
-
const
|
|
532
|
+
const n = this.sortModel.findIndex((s) => s.field === t), r = {
|
|
523
533
|
field: t,
|
|
524
534
|
direction: e.sort.direction
|
|
525
535
|
};
|
|
526
|
-
|
|
536
|
+
n !== -1 ? this.sortModel[n] = r : this.sortModel.splice(e.sort.priority, 0, r);
|
|
527
537
|
}
|
|
528
538
|
// #endregion
|
|
529
539
|
}
|