@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 v = {
|
|
2
2
|
expand: "▶",
|
|
3
3
|
collapse: "▼",
|
|
4
4
|
sortAsc: "▲",
|
|
@@ -8,7 +8,7 @@ const h = {
|
|
|
8
8
|
dragHandle: "⋮⋮",
|
|
9
9
|
toolPanel: "☰"
|
|
10
10
|
};
|
|
11
|
-
class
|
|
11
|
+
class w {
|
|
12
12
|
/**
|
|
13
13
|
* Plugin dependencies - declare other plugins this one requires.
|
|
14
14
|
*
|
|
@@ -185,10 +185,21 @@ class p {
|
|
|
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 p {
|
|
|
216
227
|
*/
|
|
217
228
|
get gridIcons() {
|
|
218
229
|
const e = this.grid?.gridConfig?.icons ?? {};
|
|
219
|
-
return { ...
|
|
230
|
+
return { ...v, ...e };
|
|
220
231
|
}
|
|
221
232
|
// #region Animation Helpers
|
|
222
233
|
/**
|
|
@@ -239,7 +250,7 @@ class p {
|
|
|
239
250
|
const e = this.grid?.effectiveConfig?.animation?.mode ?? "reduced-motion";
|
|
240
251
|
if (e === !1 || e === "off") return !1;
|
|
241
252
|
if (e === !0 || e === "on") return !0;
|
|
242
|
-
const t = this.
|
|
253
|
+
const t = this.gridElement;
|
|
243
254
|
return t ? getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim() !== "0" : !0;
|
|
244
255
|
}
|
|
245
256
|
/**
|
|
@@ -255,7 +266,7 @@ class p {
|
|
|
255
266
|
* ```
|
|
256
267
|
*/
|
|
257
268
|
get animationDuration() {
|
|
258
|
-
const e = this.
|
|
269
|
+
const e = this.gridElement;
|
|
259
270
|
if (e) {
|
|
260
271
|
const t = getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(), r = parseInt(t, 10);
|
|
261
272
|
if (!isNaN(r)) return r;
|
|
@@ -292,12 +303,12 @@ class p {
|
|
|
292
303
|
}
|
|
293
304
|
// #endregion
|
|
294
305
|
}
|
|
295
|
-
const
|
|
296
|
-
function b
|
|
297
|
-
const e =
|
|
306
|
+
const C = '@layer tbw-plugins{.tbw-visibility-content{display:flex;flex-direction:column;height:100%}.tbw-visibility-list{flex:1;overflow-y:auto;padding:var(--tbw-panel-padding, var(--tbw-spacing-md, .5rem))}.tbw-visibility-row{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));padding:var(--tbw-menu-item-padding, .375rem .25rem);cursor:pointer;font-size:var(--tbw-font-size-sm, .8125rem);border-radius:var(--tbw-border-radius, .25rem);position:relative}.tbw-visibility-row:hover{background:var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6))}.tbw-visibility-row input[type=checkbox]{cursor:pointer}.tbw-visibility-row.locked span{color:var(--tbw-color-fg-muted, #888)}.tbw-visibility-handle{cursor:grab;color:var(--tbw-color-fg-muted, #888);font-size:var(--tbw-font-size-2xs, .625rem);letter-spacing:-2px;-webkit-user-select:none;user-select:none;flex-shrink:0}.tbw-visibility-row.reorderable:hover .tbw-visibility-handle{color:var(--tbw-color-fg, #1f2937)}.tbw-visibility-label{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));flex:1;cursor:pointer}.tbw-visibility-row.dragging{opacity:.5;cursor:grabbing}.tbw-visibility-row.drop-before:before{content:"";position:absolute;left:0;right:0;top:0;height:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6))}.tbw-visibility-row.drop-after:after{content:"";position:absolute;left:0;right:0;bottom:0;height:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6))}.tbw-visibility-show-all{margin:var(--tbw-panel-padding, var(--tbw-spacing-md, .5rem));padding:var(--tbw-button-padding, .5rem .75rem);border:1px solid var(--tbw-visibility-border, var(--tbw-color-border, #e5e7eb));border-radius:var(--tbw-border-radius, .25rem);background:var(--tbw-visibility-btn-bg, var(--tbw-color-header-bg, #f9fafb));color:var(--tbw-color-fg, #1f2937);cursor:pointer;font-size:var(--tbw-font-size-sm, .8125rem)}.tbw-visibility-show-all:hover{background:var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6))}}';
|
|
307
|
+
function m(b) {
|
|
308
|
+
const e = b.meta ?? {};
|
|
298
309
|
return e.lockPosition !== !0 && e.suppressMovable !== !0;
|
|
299
310
|
}
|
|
300
|
-
class
|
|
311
|
+
class g extends w {
|
|
301
312
|
/**
|
|
302
313
|
* Plugin dependencies - VisibilityPlugin optionally uses ReorderPlugin for drag-drop reordering.
|
|
303
314
|
*
|
|
@@ -309,7 +320,7 @@ class a extends p {
|
|
|
309
320
|
name = "visibility";
|
|
310
321
|
/** Tool panel ID for shell integration */
|
|
311
322
|
static PANEL_ID = "columns";
|
|
312
|
-
styles =
|
|
323
|
+
styles = C;
|
|
313
324
|
get defaultConfig() {
|
|
314
325
|
return {
|
|
315
326
|
allowHideAll: !1
|
|
@@ -340,7 +351,7 @@ class a extends p {
|
|
|
340
351
|
*/
|
|
341
352
|
getToolPanel() {
|
|
342
353
|
return {
|
|
343
|
-
id:
|
|
354
|
+
id: g.PANEL_ID,
|
|
344
355
|
title: "Columns",
|
|
345
356
|
icon: "☰",
|
|
346
357
|
tooltip: "Column visibility",
|
|
@@ -356,7 +367,7 @@ class a extends p {
|
|
|
356
367
|
* Opens the tool panel and ensures this section is expanded.
|
|
357
368
|
*/
|
|
358
369
|
show() {
|
|
359
|
-
this.grid.openToolPanel(), this.grid.expandedToolPanelSections.includes(
|
|
370
|
+
this.grid.openToolPanel(), this.grid.expandedToolPanelSections.includes(g.PANEL_ID) || this.grid.toggleToolPanelSection(g.PANEL_ID);
|
|
360
371
|
}
|
|
361
372
|
/**
|
|
362
373
|
* Hide the visibility sidebar panel.
|
|
@@ -368,7 +379,7 @@ class a extends p {
|
|
|
368
379
|
* Toggle the visibility sidebar panel section.
|
|
369
380
|
*/
|
|
370
381
|
toggle() {
|
|
371
|
-
this.grid.isToolPanelOpen || this.grid.openToolPanel(), this.grid.toggleToolPanelSection(
|
|
382
|
+
this.grid.isToolPanelOpen || this.grid.openToolPanel(), this.grid.toggleToolPanelSection(g.PANEL_ID);
|
|
372
383
|
}
|
|
373
384
|
/**
|
|
374
385
|
* Check if a specific column is visible.
|
|
@@ -446,7 +457,7 @@ class a extends p {
|
|
|
446
457
|
* @returns True if the panel section is expanded
|
|
447
458
|
*/
|
|
448
459
|
isPanelVisible() {
|
|
449
|
-
return this.grid.isToolPanelOpen && this.grid.expandedToolPanelSections.includes(
|
|
460
|
+
return this.grid.isToolPanelOpen && this.grid.expandedToolPanelSections.includes(g.PANEL_ID);
|
|
450
461
|
}
|
|
451
462
|
// #endregion
|
|
452
463
|
// #region Private Methods
|
|
@@ -459,10 +470,10 @@ class a extends p {
|
|
|
459
470
|
t.className = "tbw-visibility-content";
|
|
460
471
|
const r = document.createElement("div");
|
|
461
472
|
r.className = "tbw-visibility-list", t.appendChild(r);
|
|
462
|
-
const
|
|
463
|
-
return
|
|
473
|
+
const s = document.createElement("button");
|
|
474
|
+
return s.className = "tbw-visibility-show-all", s.textContent = "Show All", s.addEventListener("click", () => {
|
|
464
475
|
this.grid.showAllColumns(), this.rebuildToggles(r);
|
|
465
|
-
}), t.appendChild(
|
|
476
|
+
}), t.appendChild(s), this.columnListElement = r, this.rebuildToggles(r), e.appendChild(t), () => {
|
|
466
477
|
this.columnListElement = null, t.remove();
|
|
467
478
|
};
|
|
468
479
|
}
|
|
@@ -480,55 +491,56 @@ class a extends p {
|
|
|
480
491
|
rebuildToggles(e) {
|
|
481
492
|
const t = this.hasReorderPlugin();
|
|
482
493
|
e.innerHTML = "";
|
|
483
|
-
const r = this.grid.getAllColumns().filter((
|
|
484
|
-
for (let
|
|
485
|
-
const i = r[
|
|
486
|
-
|
|
487
|
-
const
|
|
488
|
-
|
|
489
|
-
const
|
|
490
|
-
|
|
494
|
+
const r = this.grid.getAllColumns().filter((s) => !s.utility);
|
|
495
|
+
for (let s = 0; s < r.length; s++) {
|
|
496
|
+
const i = r[s], d = i.header || i.field, n = document.createElement("div");
|
|
497
|
+
n.className = i.lockVisible ? "tbw-visibility-row locked" : "tbw-visibility-row", n.setAttribute("data-field", i.field), n.setAttribute("data-index", String(s)), t && m(i) && (n.draggable = !0, n.classList.add("reorderable"), this.setupDragListeners(n, i.field, s, e));
|
|
498
|
+
const l = document.createElement("label");
|
|
499
|
+
l.className = "tbw-visibility-label";
|
|
500
|
+
const o = document.createElement("input");
|
|
501
|
+
o.type = "checkbox", o.checked = i.visible, o.disabled = i.lockVisible ?? !1, o.addEventListener("change", () => {
|
|
491
502
|
this.grid.toggleColumnVisibility(i.field), setTimeout(() => this.rebuildToggles(e), 0);
|
|
492
503
|
});
|
|
493
|
-
const
|
|
494
|
-
if (
|
|
504
|
+
const a = document.createElement("span");
|
|
505
|
+
if (a.textContent = d, l.appendChild(o), l.appendChild(a), t && m(i)) {
|
|
495
506
|
const c = document.createElement("span");
|
|
496
|
-
c.className = "tbw-visibility-handle", this.setIcon(c, this.resolveIcon("dragHandle")), c.title = "Drag to reorder",
|
|
507
|
+
c.className = "tbw-visibility-handle", this.setIcon(c, this.resolveIcon("dragHandle")), c.title = "Drag to reorder", n.appendChild(c);
|
|
497
508
|
}
|
|
498
|
-
|
|
509
|
+
n.appendChild(l), e.appendChild(n);
|
|
499
510
|
}
|
|
500
511
|
}
|
|
501
512
|
/**
|
|
502
513
|
* Set up drag-and-drop event listeners for a row.
|
|
503
514
|
* On drop, emits a 'column-reorder-request' event for other plugins to handle.
|
|
504
515
|
*/
|
|
505
|
-
setupDragListeners(e, t, r,
|
|
516
|
+
setupDragListeners(e, t, r, s) {
|
|
506
517
|
e.addEventListener("dragstart", (i) => {
|
|
507
518
|
this.isDragging = !0, this.draggedField = t, this.draggedIndex = r, i.dataTransfer && (i.dataTransfer.effectAllowed = "move", i.dataTransfer.setData("text/plain", t)), e.classList.add("dragging");
|
|
508
519
|
}), e.addEventListener("dragend", () => {
|
|
509
|
-
this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null, this.clearDragClasses(
|
|
520
|
+
this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null, this.clearDragClasses(s);
|
|
510
521
|
}), e.addEventListener("dragover", (i) => {
|
|
511
522
|
if (i.preventDefault(), !this.isDragging || this.draggedField === t) return;
|
|
512
|
-
const d = e.getBoundingClientRect(),
|
|
513
|
-
this.dropIndex = i.clientY <
|
|
514
|
-
|
|
515
|
-
}), e.classList.add("drop-target"), e.classList.toggle("drop-before", i.clientY <
|
|
523
|
+
const d = e.getBoundingClientRect(), n = d.top + d.height / 2;
|
|
524
|
+
this.dropIndex = i.clientY < n ? r : r + 1, s.querySelectorAll(".tbw-visibility-row").forEach((l) => {
|
|
525
|
+
l !== e && l.classList.remove("drop-target", "drop-before", "drop-after");
|
|
526
|
+
}), e.classList.add("drop-target"), e.classList.toggle("drop-before", i.clientY < n), e.classList.toggle("drop-after", i.clientY >= n);
|
|
516
527
|
}), e.addEventListener("dragleave", () => {
|
|
517
528
|
e.classList.remove("drop-target", "drop-before", "drop-after");
|
|
518
529
|
}), e.addEventListener("drop", (i) => {
|
|
519
530
|
i.preventDefault();
|
|
520
|
-
const d = this.draggedField,
|
|
521
|
-
if (!this.isDragging || d === null ||
|
|
531
|
+
const d = this.draggedField, n = this.draggedIndex, l = this.dropIndex;
|
|
532
|
+
if (!this.isDragging || d === null || n === null || l === null)
|
|
522
533
|
return;
|
|
523
|
-
const
|
|
524
|
-
if (
|
|
525
|
-
const
|
|
534
|
+
const o = l > n ? l - 1 : l;
|
|
535
|
+
if (o !== n) {
|
|
536
|
+
const a = this.grid.getAllColumns(), h = a.filter((u) => !u.utility)[o]?.field, f = h ? a.findIndex((u) => u.field === h) : a.length, p = {
|
|
526
537
|
field: d,
|
|
527
|
-
fromIndex:
|
|
528
|
-
|
|
538
|
+
fromIndex: n,
|
|
539
|
+
// Not used by ReorderPlugin, just for info
|
|
540
|
+
toIndex: f
|
|
529
541
|
};
|
|
530
|
-
this.emit("column-reorder-request",
|
|
531
|
-
this.rebuildToggles(
|
|
542
|
+
this.emit("column-reorder-request", p), setTimeout(() => {
|
|
543
|
+
this.rebuildToggles(s);
|
|
532
544
|
}, 0);
|
|
533
545
|
}
|
|
534
546
|
});
|
|
@@ -536,6 +548,6 @@ class a extends p {
|
|
|
536
548
|
// #endregion
|
|
537
549
|
}
|
|
538
550
|
export {
|
|
539
|
-
|
|
551
|
+
g as VisibilityPlugin
|
|
540
552
|
};
|
|
541
553
|
//# sourceMappingURL=index.js.map
|