@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 E = {
|
|
2
2
|
expand: "▶",
|
|
3
3
|
collapse: "▼",
|
|
4
4
|
sortAsc: "▲",
|
|
@@ -121,8 +121,8 @@ class A {
|
|
|
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 A {
|
|
|
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 A {
|
|
|
216
227
|
*/
|
|
217
228
|
get gridIcons() {
|
|
218
229
|
const t = this.grid?.gridConfig?.icons ?? {};
|
|
219
|
-
return { ...
|
|
230
|
+
return { ...E, ...t };
|
|
220
231
|
}
|
|
221
232
|
// #region Animation Helpers
|
|
222
233
|
/**
|
|
@@ -239,7 +250,7 @@ class A {
|
|
|
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 A {
|
|
|
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,9 +304,9 @@ class A {
|
|
|
293
304
|
// #endregion
|
|
294
305
|
}
|
|
295
306
|
const p = {
|
|
296
|
-
sum: (n, t) => n.reduce((e,
|
|
307
|
+
sum: (n, t) => n.reduce((e, o) => e + (Number(o[t]) || 0), 0),
|
|
297
308
|
avg: (n, t) => {
|
|
298
|
-
const e = n.reduce((
|
|
309
|
+
const e = n.reduce((o, r) => o + (Number(r[t]) || 0), 0);
|
|
299
310
|
return n.length ? e / n.length : 0;
|
|
300
311
|
},
|
|
301
312
|
count: (n) => n.length,
|
|
@@ -326,9 +337,9 @@ const p = {
|
|
|
326
337
|
/**
|
|
327
338
|
* Run an aggregator on a set of rows.
|
|
328
339
|
*/
|
|
329
|
-
run(n, t, e,
|
|
340
|
+
run(n, t, e, o) {
|
|
330
341
|
const r = this.get(n);
|
|
331
|
-
return r ? r(t, e,
|
|
342
|
+
return r ? r(t, e, o) : void 0;
|
|
332
343
|
},
|
|
333
344
|
/**
|
|
334
345
|
* Check if an aggregator exists.
|
|
@@ -348,35 +359,35 @@ d.unregister.bind(d);
|
|
|
348
359
|
const b = d.get.bind(d);
|
|
349
360
|
d.run.bind(d);
|
|
350
361
|
d.list.bind(d);
|
|
351
|
-
function
|
|
362
|
+
function R(n) {
|
|
352
363
|
return typeof n == "object" && n !== null && "aggFunc" in n;
|
|
353
364
|
}
|
|
354
365
|
function m(n, t) {
|
|
355
366
|
const e = document.createElement("div");
|
|
356
367
|
e.className = "tbw-pinned-rows", e.setAttribute("role", "presentation"), e.setAttribute("aria-live", "polite");
|
|
357
|
-
const
|
|
358
|
-
|
|
368
|
+
const o = document.createElement("div");
|
|
369
|
+
o.className = "tbw-pinned-rows-left";
|
|
359
370
|
const r = document.createElement("div");
|
|
360
371
|
r.className = "tbw-pinned-rows-center";
|
|
361
372
|
const s = document.createElement("div");
|
|
362
373
|
if (s.className = "tbw-pinned-rows-right", n.showRowCount !== !1) {
|
|
363
|
-
const
|
|
364
|
-
|
|
374
|
+
const i = document.createElement("span");
|
|
375
|
+
i.className = "tbw-status-panel tbw-status-panel-row-count", i.textContent = `Total: ${t.totalRows} rows`, o.appendChild(i);
|
|
365
376
|
}
|
|
366
377
|
if (n.showFilteredCount && t.filteredRows !== t.totalRows) {
|
|
367
|
-
const
|
|
368
|
-
|
|
378
|
+
const i = document.createElement("span");
|
|
379
|
+
i.className = "tbw-status-panel tbw-status-panel-filtered-count", i.textContent = `Filtered: ${t.filteredRows}`, o.appendChild(i);
|
|
369
380
|
}
|
|
370
381
|
if (n.showSelectedCount && t.selectedRows > 0) {
|
|
371
|
-
const
|
|
372
|
-
|
|
382
|
+
const i = document.createElement("span");
|
|
383
|
+
i.className = "tbw-status-panel tbw-status-panel-selected-count", i.textContent = `Selected: ${t.selectedRows}`, s.appendChild(i);
|
|
373
384
|
}
|
|
374
385
|
if (n.customPanels)
|
|
375
|
-
for (const
|
|
376
|
-
const a = y(
|
|
377
|
-
switch (
|
|
386
|
+
for (const i of n.customPanels) {
|
|
387
|
+
const a = y(i, t);
|
|
388
|
+
switch (i.position) {
|
|
378
389
|
case "left":
|
|
379
|
-
|
|
390
|
+
o.appendChild(a);
|
|
380
391
|
break;
|
|
381
392
|
case "center":
|
|
382
393
|
r.appendChild(a);
|
|
@@ -386,38 +397,38 @@ function m(n, t) {
|
|
|
386
397
|
break;
|
|
387
398
|
}
|
|
388
399
|
}
|
|
389
|
-
return e.appendChild(
|
|
400
|
+
return e.appendChild(o), e.appendChild(r), e.appendChild(s), e;
|
|
390
401
|
}
|
|
391
402
|
function w(n) {
|
|
392
403
|
const t = document.createElement("div");
|
|
393
404
|
return t.className = `tbw-aggregation-rows tbw-aggregation-rows-${n}`, t.setAttribute("role", "presentation"), t;
|
|
394
405
|
}
|
|
395
|
-
function C(n, t, e,
|
|
406
|
+
function C(n, t, e, o) {
|
|
396
407
|
n.innerHTML = "";
|
|
397
408
|
for (const r of t) {
|
|
398
409
|
const s = document.createElement("div");
|
|
399
410
|
if (s.className = "tbw-aggregation-row", s.setAttribute("role", "presentation"), r.id && s.setAttribute("data-aggregation-id", r.id), r.fullWidth) {
|
|
400
|
-
const
|
|
401
|
-
|
|
411
|
+
const i = document.createElement("div");
|
|
412
|
+
i.className = "tbw-aggregation-cell tbw-aggregation-cell-full", i.style.gridColumn = "1 / -1", i.textContent = r.label || "", s.appendChild(i);
|
|
402
413
|
} else
|
|
403
|
-
for (const
|
|
414
|
+
for (const i of e) {
|
|
404
415
|
const a = document.createElement("div");
|
|
405
|
-
a.className = "tbw-aggregation-cell", a.setAttribute("data-field",
|
|
416
|
+
a.className = "tbw-aggregation-cell", a.setAttribute("data-field", i.field);
|
|
406
417
|
let l, u;
|
|
407
|
-
const h = r.aggregators?.[
|
|
418
|
+
const h = r.aggregators?.[i.field];
|
|
408
419
|
if (h)
|
|
409
|
-
if (
|
|
420
|
+
if (R(h)) {
|
|
410
421
|
const g = b(h.aggFunc);
|
|
411
|
-
g && (l = g(
|
|
422
|
+
g && (l = g(o, i.field, i)), u = h.formatter;
|
|
412
423
|
} else {
|
|
413
424
|
const g = b(h);
|
|
414
|
-
g && (l = g(
|
|
425
|
+
g && (l = g(o, i.field, i));
|
|
415
426
|
}
|
|
416
|
-
else if (r.cells && Object.prototype.hasOwnProperty.call(r.cells,
|
|
417
|
-
const g = r.cells[
|
|
418
|
-
typeof g == "function" ? l = g(
|
|
427
|
+
else if (r.cells && Object.prototype.hasOwnProperty.call(r.cells, i.field)) {
|
|
428
|
+
const g = r.cells[i.field];
|
|
429
|
+
typeof g == "function" ? l = g(o, i.field, i) : l = g;
|
|
419
430
|
}
|
|
420
|
-
l != null ? a.textContent = u ? u(l,
|
|
431
|
+
l != null ? a.textContent = u ? u(l, i.field, i) : String(l) : a.textContent = "", s.appendChild(a);
|
|
421
432
|
}
|
|
422
433
|
n.appendChild(s);
|
|
423
434
|
}
|
|
@@ -425,21 +436,21 @@ function C(n, t, e, i) {
|
|
|
425
436
|
function y(n, t) {
|
|
426
437
|
const e = document.createElement("div");
|
|
427
438
|
e.className = "tbw-status-panel tbw-status-panel-custom", e.id = `status-panel-${n.id}`;
|
|
428
|
-
const
|
|
429
|
-
return typeof
|
|
439
|
+
const o = n.render(t);
|
|
440
|
+
return typeof o == "string" ? e.innerHTML = o : e.appendChild(o), e;
|
|
430
441
|
}
|
|
431
|
-
function v(n, t, e,
|
|
442
|
+
function v(n, t, e, o, r) {
|
|
432
443
|
return {
|
|
433
444
|
totalRows: n.length,
|
|
434
445
|
filteredRows: r?.cachedResult?.length ?? n.length,
|
|
435
|
-
selectedRows:
|
|
446
|
+
selectedRows: o?.selected?.size ?? 0,
|
|
436
447
|
columns: t,
|
|
437
448
|
rows: n,
|
|
438
449
|
grid: e
|
|
439
450
|
};
|
|
440
451
|
}
|
|
441
|
-
const S = ".tbw-footer{flex-shrink:0;z-index:var(--tbw-z-layer-pinned-rows, 20);background:var(--tbw-color-panel-bg)}.tbw-pinned-rows{display:flex;align-items:center;justify-content:space-between;padding:
|
|
442
|
-
class
|
|
452
|
+
const S = "@layer tbw-plugins{.tbw-footer{flex-shrink:0;z-index:var(--tbw-z-layer-pinned-rows, 20);background:var(--tbw-color-panel-bg)}.tbw-pinned-rows{display:flex;align-items:center;justify-content:space-between;padding:var(--tbw-button-padding, var(--tbw-spacing-md, .5rem) var(--tbw-spacing-lg, .75rem));background:var(--tbw-pinned-rows-bg, var(--tbw-color-panel-bg));border-top:1px solid var(--tbw-pinned-rows-border, var(--tbw-color-border));font-size:var(--tbw-font-size-xs, .75rem);color:var(--tbw-pinned-rows-color, var(--tbw-color-fg-muted));min-height:32px;box-sizing:border-box;min-width:fit-content}.tbw-pinned-rows-left,.tbw-pinned-rows-center,.tbw-pinned-rows-right{display:flex;align-items:center;gap:var(--tbw-spacing-xl, 1rem)}.tbw-pinned-rows-left{justify-content:flex-start}.tbw-pinned-rows-center{justify-content:center;flex:1}.tbw-pinned-rows-right{justify-content:flex-end}.tbw-status-panel{white-space:nowrap}.tbw-aggregation-rows{min-width:fit-content;background:var(--tbw-aggregation-bg, var(--tbw-color-header-bg))}.tbw-aggregation-rows-top{border-bottom:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-rows-bottom{border-top:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-row{display:grid;grid-template-columns:var(--tbw-column-template);font-size:var(--tbw-aggregation-font-size, .8em);font-weight:var(--tbw-aggregation-font-weight, 600)}.tbw-aggregation-cell{padding:var(--tbw-cell-padding, .125rem .5rem);min-height:var(--tbw-row-height, 1.75rem);display:flex;align-items:center;border-right:1px solid var(--tbw-color-border-cell)}.tbw-aggregation-cell:last-child{border-right:0}.tbw-aggregation-cell-full{grid-column:1 / -1;border-right:0}}";
|
|
453
|
+
class B extends A {
|
|
443
454
|
name = "pinnedRows";
|
|
444
455
|
styles = S;
|
|
445
456
|
get defaultConfig() {
|
|
@@ -463,18 +474,18 @@ class x extends A {
|
|
|
463
474
|
// #endregion
|
|
464
475
|
// #region Hooks
|
|
465
476
|
afterRender() {
|
|
466
|
-
const t = this.
|
|
477
|
+
const t = this.gridElement;
|
|
467
478
|
if (!t) return;
|
|
468
479
|
const e = t.querySelector(".tbw-scroll-area") ?? t.querySelector(".tbw-grid-content") ?? t.children[0];
|
|
469
480
|
if (!e) return;
|
|
470
481
|
this.footerWrapper && !e.contains(this.footerWrapper) && (this.footerWrapper = null, this.bottomAggregationContainer = null, this.infoBarElement = null), this.topAggregationContainer && !e.contains(this.topAggregationContainer) && (this.topAggregationContainer = null), this.infoBarElement && !e.contains(this.infoBarElement) && (this.infoBarElement = null);
|
|
471
|
-
const
|
|
482
|
+
const o = this.getSelectionState(), r = this.getFilterState(), s = v(
|
|
472
483
|
this.rows,
|
|
473
484
|
this.columns,
|
|
474
485
|
this.grid,
|
|
475
|
-
|
|
486
|
+
o,
|
|
476
487
|
r
|
|
477
|
-
),
|
|
488
|
+
), i = this.config.aggregationRows || [], a = i.filter((c) => c.position === "top"), l = i.filter((c) => c.position !== "top");
|
|
478
489
|
if (a.length > 0) {
|
|
479
490
|
if (!this.topAggregationContainer) {
|
|
480
491
|
this.topAggregationContainer = w("top");
|
|
@@ -579,6 +590,6 @@ class x extends A {
|
|
|
579
590
|
// #endregion
|
|
580
591
|
}
|
|
581
592
|
export {
|
|
582
|
-
|
|
593
|
+
B as PinnedRowsPlugin
|
|
583
594
|
};
|
|
584
595
|
//# sourceMappingURL=index.js.map
|