@toolbox-web/grid 0.4.2 → 0.6.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 +2 -3
- package/all.js +1063 -1024
- package/all.js.map +1 -1
- package/index.js +1078 -912
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +28 -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/event-delegation.d.ts +21 -0
- package/lib/core/internal/event-delegation.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 +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 +41 -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 +6 -6
- package/public.d.ts +42 -0
- package/public.d.ts.map +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 +15 -14
- 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,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const b = {
|
|
2
2
|
expand: "▶",
|
|
3
3
|
collapse: "▼",
|
|
4
4
|
sortAsc: "▲",
|
|
@@ -8,7 +8,7 @@ const x = {
|
|
|
8
8
|
dragHandle: "⋮⋮",
|
|
9
9
|
toolPanel: "☰"
|
|
10
10
|
};
|
|
11
|
-
class
|
|
11
|
+
class x {
|
|
12
12
|
/**
|
|
13
13
|
* Plugin dependencies - declare other plugins this one requires.
|
|
14
14
|
*
|
|
@@ -121,8 +121,8 @@ class b {
|
|
|
121
121
|
* @returns `true` if the event was cancelled (preventDefault called), `false` otherwise
|
|
122
122
|
*/
|
|
123
123
|
emitCancelable(t, e) {
|
|
124
|
-
const
|
|
125
|
-
return this.grid?.dispatchEvent?.(
|
|
124
|
+
const o = new CustomEvent(t, { detail: e, bubbles: !0, cancelable: !0 });
|
|
125
|
+
return this.grid?.dispatchEvent?.(o), o.defaultPrevented;
|
|
126
126
|
}
|
|
127
127
|
/**
|
|
128
128
|
* Request a re-render of the grid.
|
|
@@ -185,10 +185,21 @@ class b {
|
|
|
185
185
|
return this.grid;
|
|
186
186
|
}
|
|
187
187
|
/**
|
|
188
|
-
* Get the
|
|
188
|
+
* Get the render root of the grid for DOM queries.
|
|
189
|
+
* @deprecated Use `gridElement` instead. This getter exists only for backward compatibility.
|
|
190
|
+
*
|
|
191
|
+
* With Shadow DOM removed, the grid element itself is the render root.
|
|
192
|
+
* All new code should use `this.gridElement` for DOM queries.
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* // OLD (deprecated)
|
|
196
|
+
* const rows = this.shadowRoot?.querySelector('.rows');
|
|
197
|
+
*
|
|
198
|
+
* // NEW (preferred)
|
|
199
|
+
* const rows = this.gridElement.querySelector('.rows');
|
|
189
200
|
*/
|
|
190
201
|
get shadowRoot() {
|
|
191
|
-
return this.
|
|
202
|
+
return this.gridElement;
|
|
192
203
|
}
|
|
193
204
|
/**
|
|
194
205
|
* Get the disconnect signal for event listener cleanup.
|
|
@@ -216,7 +227,7 @@ class b {
|
|
|
216
227
|
*/
|
|
217
228
|
get gridIcons() {
|
|
218
229
|
const t = this.grid?.gridConfig?.icons ?? {};
|
|
219
|
-
return { ...
|
|
230
|
+
return { ...b, ...t };
|
|
220
231
|
}
|
|
221
232
|
// #region Animation Helpers
|
|
222
233
|
/**
|
|
@@ -239,7 +250,7 @@ class b {
|
|
|
239
250
|
const t = this.grid?.effectiveConfig?.animation?.mode ?? "reduced-motion";
|
|
240
251
|
if (t === !1 || t === "off") return !1;
|
|
241
252
|
if (t === !0 || t === "on") return !0;
|
|
242
|
-
const e = this.
|
|
253
|
+
const e = this.gridElement;
|
|
243
254
|
return e ? getComputedStyle(e).getPropertyValue("--tbw-animation-enabled").trim() !== "0" : !0;
|
|
244
255
|
}
|
|
245
256
|
/**
|
|
@@ -255,10 +266,10 @@ class b {
|
|
|
255
266
|
* ```
|
|
256
267
|
*/
|
|
257
268
|
get animationDuration() {
|
|
258
|
-
const t = this.
|
|
269
|
+
const t = this.gridElement;
|
|
259
270
|
if (t) {
|
|
260
|
-
const e = getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(),
|
|
261
|
-
if (!isNaN(
|
|
271
|
+
const e = getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(), o = parseInt(e, 10);
|
|
272
|
+
if (!isNaN(o)) return o;
|
|
262
273
|
}
|
|
263
274
|
return 200;
|
|
264
275
|
}
|
|
@@ -293,31 +304,31 @@ class b {
|
|
|
293
304
|
// #endregion
|
|
294
305
|
}
|
|
295
306
|
function S(r, t, e) {
|
|
296
|
-
return t.length ? [...r].sort((
|
|
307
|
+
return t.length ? [...r].sort((o, i) => {
|
|
297
308
|
for (const n of t) {
|
|
298
|
-
const d = e.find((c) => c.field === n.field)?.sortComparator ??
|
|
309
|
+
const d = e.find((c) => c.field === n.field)?.sortComparator ?? y, u = o[n.field], f = i[n.field], s = d(u, f, o, i);
|
|
299
310
|
if (s !== 0)
|
|
300
311
|
return n.direction === "asc" ? s : -s;
|
|
301
312
|
}
|
|
302
313
|
return 0;
|
|
303
314
|
}) : [...r];
|
|
304
315
|
}
|
|
305
|
-
function
|
|
316
|
+
function y(r, t) {
|
|
306
317
|
return r == null && t == null ? 0 : r == null ? 1 : t == null ? -1 : typeof r == "number" && typeof t == "number" ? r - t : r instanceof Date && t instanceof Date ? r.getTime() - t.getTime() : typeof r == "boolean" && typeof t == "boolean" ? r === t ? 0 : r ? -1 : 1 : String(r).localeCompare(String(t));
|
|
307
318
|
}
|
|
308
|
-
function
|
|
309
|
-
const
|
|
310
|
-
return e ?
|
|
319
|
+
function C(r, t, e, o) {
|
|
320
|
+
const i = r.find((n) => n.field === t);
|
|
321
|
+
return e ? i ? i.direction === "asc" ? r.map((n) => n.field === t ? { ...n, direction: "desc" } : n) : r.filter((n) => n.field !== t) : r.length < o ? [...r, { field: t, direction: "asc" }] : r : i?.direction === "asc" ? [{ field: t, direction: "desc" }] : i?.direction === "desc" ? [] : [{ field: t, direction: "asc" }];
|
|
311
322
|
}
|
|
312
|
-
function
|
|
313
|
-
const e = r.findIndex((
|
|
323
|
+
function h(r, t) {
|
|
324
|
+
const e = r.findIndex((o) => o.field === t);
|
|
314
325
|
return e >= 0 ? e + 1 : void 0;
|
|
315
326
|
}
|
|
316
327
|
function m(r, t) {
|
|
317
328
|
return r.find((e) => e.field === t)?.direction;
|
|
318
329
|
}
|
|
319
|
-
const M = '.header-cell[data-sort=asc]:after{content:"↑";margin-left:4px;opacity:.8}.header-cell[data-sort=desc]:after{content:"↓";margin-left:4px;opacity:.8}.sort-indicator{margin-left:4px;opacity:.8}.sort-index{font-size:10px;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:14px;height:14px;display:inline-flex;align-items:center;justify-content:center;margin-left:2px;font-weight:600}';
|
|
320
|
-
class w extends
|
|
330
|
+
const M = '@layer tbw-plugins{.header-cell[data-sort=asc]:after{content:"↑";margin-left:4px;opacity:.8}.header-cell[data-sort=desc]:after{content:"↓";margin-left:4px;opacity:.8}.sort-indicator{margin-left:4px;opacity:.8}.sort-index{font-size:10px;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:14px;height:14px;display:inline-flex;align-items:center;justify-content:center;margin-left:2px;font-weight:600}}';
|
|
331
|
+
class w extends x {
|
|
321
332
|
name = "multiSort";
|
|
322
333
|
styles = M;
|
|
323
334
|
get defaultConfig() {
|
|
@@ -340,28 +351,28 @@ class w extends b {
|
|
|
340
351
|
}
|
|
341
352
|
onHeaderClick(t) {
|
|
342
353
|
if (!this.columns.find((n) => n.field === t.field)?.sortable) return !1;
|
|
343
|
-
const
|
|
344
|
-
return this.sortModel =
|
|
354
|
+
const o = t.originalEvent.shiftKey, i = this.config.maxSortColumns ?? 3;
|
|
355
|
+
return this.sortModel = C(this.sortModel, t.field, o, i), this.emit("sort-change", { sortModel: [...this.sortModel] }), this.requestRender(), !0;
|
|
345
356
|
}
|
|
346
357
|
afterRender() {
|
|
347
|
-
const t = this.
|
|
358
|
+
const t = this.gridElement;
|
|
348
359
|
if (!t) return;
|
|
349
360
|
const e = this.config.showSortIndex !== !1;
|
|
350
|
-
t.querySelectorAll(".header-row .cell[data-field]").forEach((
|
|
351
|
-
const n =
|
|
361
|
+
t.querySelectorAll(".header-row .cell[data-field]").forEach((i) => {
|
|
362
|
+
const n = i.getAttribute("data-field");
|
|
352
363
|
if (!n) return;
|
|
353
|
-
const a =
|
|
354
|
-
if (
|
|
355
|
-
|
|
364
|
+
const a = h(this.sortModel, n), d = m(this.sortModel, n);
|
|
365
|
+
if (i.querySelector(".sort-index")?.remove(), d) {
|
|
366
|
+
i.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove(), i.setAttribute("data-sort", d);
|
|
356
367
|
const s = document.createElement("span");
|
|
357
368
|
s.className = "sort-indicator", this.setIcon(s, this.resolveIcon(d === "asc" ? "sortAsc" : "sortDesc"));
|
|
358
|
-
const c =
|
|
359
|
-
if (
|
|
369
|
+
const c = i.querySelector(".tbw-filter-btn"), p = i.querySelector(".resize-handle"), g = c ?? p;
|
|
370
|
+
if (g ? i.insertBefore(s, g) : i.appendChild(s), e && this.sortModel.length > 1 && a !== void 0) {
|
|
360
371
|
const l = document.createElement("span");
|
|
361
|
-
l.className = "sort-index", l.textContent = String(a), s.nextSibling ?
|
|
372
|
+
l.className = "sort-index", l.textContent = String(a), s.nextSibling ? i.insertBefore(l, s.nextSibling) : i.appendChild(l);
|
|
362
373
|
}
|
|
363
374
|
} else
|
|
364
|
-
|
|
375
|
+
i.removeAttribute("data-sort");
|
|
365
376
|
});
|
|
366
377
|
}
|
|
367
378
|
// #endregion
|
|
@@ -392,7 +403,7 @@ class w extends b {
|
|
|
392
403
|
* @returns 1-based index or undefined if not sorted
|
|
393
404
|
*/
|
|
394
405
|
getSortIndex(t) {
|
|
395
|
-
return
|
|
406
|
+
return h(this.sortModel, t);
|
|
396
407
|
}
|
|
397
408
|
/**
|
|
398
409
|
* Get the sort direction for a specific field.
|
|
@@ -408,7 +419,7 @@ class w extends b {
|
|
|
408
419
|
* Return sort state for a column if it's in the sort model.
|
|
409
420
|
*/
|
|
410
421
|
getColumnState(t) {
|
|
411
|
-
const e = this.sortModel.findIndex((
|
|
422
|
+
const e = this.sortModel.findIndex((i) => i.field === t);
|
|
412
423
|
return e === -1 ? void 0 : {
|
|
413
424
|
sort: {
|
|
414
425
|
direction: this.sortModel[e].direction,
|
|
@@ -425,11 +436,11 @@ class w extends b {
|
|
|
425
436
|
this.sortModel = this.sortModel.filter((n) => n.field !== t);
|
|
426
437
|
return;
|
|
427
438
|
}
|
|
428
|
-
const
|
|
439
|
+
const o = this.sortModel.findIndex((n) => n.field === t), i = {
|
|
429
440
|
field: t,
|
|
430
441
|
direction: e.sort.direction
|
|
431
442
|
};
|
|
432
|
-
|
|
443
|
+
o !== -1 ? this.sortModel[o] = i : this.sortModel.splice(e.sort.priority, 0, i);
|
|
433
444
|
}
|
|
434
445
|
// #endregion
|
|
435
446
|
}
|