@toolbox-web/grid 1.16.1 → 1.17.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/all.js +1 -1
- package/all.js.map +1 -1
- package/index.js +376 -357
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +1 -1
- package/lib/core/grid.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 +8 -1
- 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/index.js.map +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js.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.map +1 -1
- package/lib/plugins/multi-sort/index.js +31 -31
- 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.map +1 -1
- package/lib/plugins/responsive/index.js.map +1 -1
- 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 +19 -19
- 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/multi-sort.umd.js +1 -1
- package/umd/plugins/multi-sort.umd.js.map +1 -1
|
@@ -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;IAKpC,gBAAgB;IACP,MAAM,IAAI,IAAI;IAOvB,gBAAgB;IACP,WAAW,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,GAAG,OAAO,EAAE;IAOzD,gBAAgB;IACP,aAAa,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO;IAexD,gBAAgB;IACP,WAAW,IAAI,IAAI;
|
|
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,E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|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const h = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>',
|
|
1
|
+
const h = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>', v = {
|
|
2
2
|
expand: "▶",
|
|
3
3
|
collapse: "▼",
|
|
4
4
|
sortAsc: "▲",
|
|
@@ -11,7 +11,7 @@ const h = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentCo
|
|
|
11
11
|
filterActive: h,
|
|
12
12
|
print: "🖨️"
|
|
13
13
|
};
|
|
14
|
-
class
|
|
14
|
+
class x {
|
|
15
15
|
/**
|
|
16
16
|
* Plugin dependencies - declare other plugins this one requires.
|
|
17
17
|
*
|
|
@@ -301,7 +301,7 @@ class C {
|
|
|
301
301
|
*/
|
|
302
302
|
get gridIcons() {
|
|
303
303
|
const t = this.grid?.gridConfig?.icons ?? {};
|
|
304
|
-
return { ...
|
|
304
|
+
return { ...v, ...t };
|
|
305
305
|
}
|
|
306
306
|
// #region Animation Helpers
|
|
307
307
|
/**
|
|
@@ -377,32 +377,32 @@ class C {
|
|
|
377
377
|
}
|
|
378
378
|
// #endregion
|
|
379
379
|
}
|
|
380
|
-
function
|
|
381
|
-
return t.length ? [...
|
|
380
|
+
function C(i, t, e) {
|
|
381
|
+
return t.length ? [...i].sort((o, r) => {
|
|
382
382
|
for (const n of t) {
|
|
383
|
-
const d = e.find((
|
|
383
|
+
const d = e.find((u) => u.field === n.field)?.sortComparator ?? S, g = o[n.field], c = r[n.field], s = d(g, c, o, r);
|
|
384
384
|
if (s !== 0)
|
|
385
385
|
return n.direction === "asc" ? s : -s;
|
|
386
386
|
}
|
|
387
387
|
return 0;
|
|
388
|
-
}) : [...
|
|
388
|
+
}) : [...i];
|
|
389
389
|
}
|
|
390
|
-
function
|
|
391
|
-
return
|
|
390
|
+
function S(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, o) {
|
|
394
|
+
const r = i.find((n) => n.field === t);
|
|
395
|
+
return e ? r ? r.direction === "asc" ? i.map((n) => n.field === t ? { ...n, direction: "desc" } : n) : i.filter((n) => n.field !== t) : i.length < o ? [...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((o) => o.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
|
-
class y extends
|
|
405
|
+
class y extends x {
|
|
406
406
|
/** @internal */
|
|
407
407
|
name = "multiSort";
|
|
408
408
|
/** @internal */
|
|
@@ -426,34 +426,34 @@ class y extends C {
|
|
|
426
426
|
// #region Hooks
|
|
427
427
|
/** @internal */
|
|
428
428
|
processRows(t) {
|
|
429
|
-
return this.sortModel.length === 0 ? [...t] :
|
|
429
|
+
return this.sortModel.length === 0 ? [...t] : C([...t], this.sortModel, [...this.columns]);
|
|
430
430
|
}
|
|
431
431
|
/** @internal */
|
|
432
432
|
onHeaderClick(t) {
|
|
433
433
|
if (!this.columns.find((n) => n.field === t.field)?.sortable) return !1;
|
|
434
|
-
const o = t.originalEvent.shiftKey,
|
|
435
|
-
return this.sortModel =
|
|
434
|
+
const o = t.originalEvent.shiftKey, r = this.config.maxSortColumns ?? 3;
|
|
435
|
+
return this.sortModel = M(this.sortModel, t.field, o, r), this.emit("sort-change", { sortModel: [...this.sortModel] }), this.requestRender(), !0;
|
|
436
436
|
}
|
|
437
437
|
/** @internal */
|
|
438
438
|
afterRender() {
|
|
439
439
|
const t = this.gridElement;
|
|
440
440
|
if (!t) return;
|
|
441
441
|
const e = this.config.showSortIndex !== !1;
|
|
442
|
-
t.querySelectorAll(".header-row .cell[data-field]").forEach((
|
|
443
|
-
const n =
|
|
442
|
+
t.querySelectorAll(".header-row .cell[data-field]").forEach((r) => {
|
|
443
|
+
const n = r.getAttribute("data-field");
|
|
444
444
|
if (!n) return;
|
|
445
445
|
const a = m(this.sortModel, n), d = p(this.sortModel, n);
|
|
446
|
-
if (
|
|
447
|
-
|
|
446
|
+
if (r.querySelector(".sort-index")?.remove(), d) {
|
|
447
|
+
r.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove(), r.setAttribute("data-sort", d);
|
|
448
448
|
const s = document.createElement("span");
|
|
449
449
|
s.className = "sort-indicator", this.setIcon(s, this.resolveIcon(d === "asc" ? "sortAsc" : "sortDesc"));
|
|
450
|
-
const
|
|
451
|
-
if (f ?
|
|
450
|
+
const u = r.querySelector(".tbw-filter-btn"), b = r.querySelector(".resize-handle"), f = u ?? b;
|
|
451
|
+
if (f ? r.insertBefore(s, f) : r.appendChild(s), e && this.sortModel.length > 1 && a !== void 0) {
|
|
452
452
|
const l = document.createElement("span");
|
|
453
|
-
l.className = "sort-index", l.textContent = String(a), s.nextSibling ?
|
|
453
|
+
l.className = "sort-index", l.textContent = String(a), s.nextSibling ? r.insertBefore(l, s.nextSibling) : r.appendChild(l);
|
|
454
454
|
}
|
|
455
455
|
} else
|
|
456
|
-
|
|
456
|
+
r.removeAttribute("data-sort"), r.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();
|
|
457
457
|
});
|
|
458
458
|
}
|
|
459
459
|
// #endregion
|
|
@@ -501,7 +501,7 @@ class y extends C {
|
|
|
501
501
|
* @internal
|
|
502
502
|
*/
|
|
503
503
|
getColumnState(t) {
|
|
504
|
-
const e = this.sortModel.findIndex((
|
|
504
|
+
const e = this.sortModel.findIndex((r) => r.field === t);
|
|
505
505
|
return e === -1 ? void 0 : {
|
|
506
506
|
sort: {
|
|
507
507
|
direction: this.sortModel[e].direction,
|
|
@@ -519,11 +519,11 @@ class y extends C {
|
|
|
519
519
|
this.sortModel = this.sortModel.filter((n) => n.field !== t);
|
|
520
520
|
return;
|
|
521
521
|
}
|
|
522
|
-
const o = this.sortModel.findIndex((n) => n.field === t),
|
|
522
|
+
const o = this.sortModel.findIndex((n) => n.field === t), r = {
|
|
523
523
|
field: t,
|
|
524
524
|
direction: e.sort.direction
|
|
525
525
|
};
|
|
526
|
-
o !== -1 ? this.sortModel[o] =
|
|
526
|
+
o !== -1 ? this.sortModel[o] = r : this.sortModel.splice(e.sort.priority, 0, r);
|
|
527
527
|
}
|
|
528
528
|
// #endregion
|
|
529
529
|
}
|