@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 S = {
|
|
2
2
|
expand: "▶",
|
|
3
3
|
collapse: "▼",
|
|
4
4
|
sortAsc: "▲",
|
|
@@ -8,7 +8,7 @@ const _ = {
|
|
|
8
8
|
dragHandle: "⋮⋮",
|
|
9
9
|
toolPanel: "☰"
|
|
10
10
|
};
|
|
11
|
-
class
|
|
11
|
+
class _ {
|
|
12
12
|
/**
|
|
13
13
|
* Plugin dependencies - declare other plugins this one requires.
|
|
14
14
|
*
|
|
@@ -185,10 +185,21 @@ class S {
|
|
|
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 S {
|
|
|
216
227
|
*/
|
|
217
228
|
get gridIcons() {
|
|
218
229
|
const e = this.grid?.gridConfig?.icons ?? {};
|
|
219
|
-
return { ...
|
|
230
|
+
return { ...S, ...e };
|
|
220
231
|
}
|
|
221
232
|
// #region Animation Helpers
|
|
222
233
|
/**
|
|
@@ -239,7 +250,7 @@ class S {
|
|
|
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 S {
|
|
|
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(), n = parseInt(t, 10);
|
|
261
272
|
if (!isNaN(n)) return n;
|
|
@@ -292,7 +303,7 @@ class S {
|
|
|
292
303
|
}
|
|
293
304
|
// #endregion
|
|
294
305
|
}
|
|
295
|
-
function
|
|
306
|
+
function x(s, e, t) {
|
|
296
307
|
return s.id !== void 0 ? String(s.id) : t ? `${t}-${e}` : String(e);
|
|
297
308
|
}
|
|
298
309
|
function y(s, e) {
|
|
@@ -302,7 +313,7 @@ function y(s, e) {
|
|
|
302
313
|
function w(s, e, t = null, n = 0) {
|
|
303
314
|
const i = e.childrenField ?? "children", o = /* @__PURE__ */ new Set();
|
|
304
315
|
for (let r = 0; r < s.length; r++) {
|
|
305
|
-
const l = s[r], a =
|
|
316
|
+
const l = s[r], a = x(l, r, t), d = l[i];
|
|
306
317
|
if (Array.isArray(d) && d.length > 0) {
|
|
307
318
|
o.add(a);
|
|
308
319
|
const h = w(d, e, a, n + 1);
|
|
@@ -314,23 +325,23 @@ function w(s, e, t = null, n = 0) {
|
|
|
314
325
|
function v() {
|
|
315
326
|
return /* @__PURE__ */ new Set();
|
|
316
327
|
}
|
|
317
|
-
function
|
|
328
|
+
function R(s, e, t, n = null, i = 0) {
|
|
318
329
|
const o = t.childrenField ?? "children";
|
|
319
330
|
for (let r = 0; r < s.length; r++) {
|
|
320
|
-
const l = s[r], a =
|
|
331
|
+
const l = s[r], a = x(l, r, n);
|
|
321
332
|
if (a === e)
|
|
322
333
|
return [a];
|
|
323
334
|
const d = l[o];
|
|
324
335
|
if (Array.isArray(d) && d.length > 0) {
|
|
325
|
-
const h =
|
|
336
|
+
const h = R(d, e, t, a, i + 1);
|
|
326
337
|
if (h)
|
|
327
338
|
return [a, ...h];
|
|
328
339
|
}
|
|
329
340
|
}
|
|
330
341
|
return null;
|
|
331
342
|
}
|
|
332
|
-
function
|
|
333
|
-
const i =
|
|
343
|
+
function E(s, e, t, n) {
|
|
344
|
+
const i = R(s, e, t);
|
|
334
345
|
if (!i) return n;
|
|
335
346
|
const o = new Set(n);
|
|
336
347
|
for (let r = 0; r < i.length - 1; r++)
|
|
@@ -347,7 +358,7 @@ function m(s, e = "children") {
|
|
|
347
358
|
}
|
|
348
359
|
return !1;
|
|
349
360
|
}
|
|
350
|
-
function
|
|
361
|
+
function C(s) {
|
|
351
362
|
if (!Array.isArray(s) || s.length === 0) return null;
|
|
352
363
|
const e = ["children", "items", "nodes", "subRows", "nested"];
|
|
353
364
|
for (const t of s)
|
|
@@ -383,8 +394,8 @@ function T(s, e = "children") {
|
|
|
383
394
|
}
|
|
384
395
|
return t;
|
|
385
396
|
}
|
|
386
|
-
const I = ".cell[data-field=__tbw_expander]{border-right:none!important;padding:0;display:flex;align-items:center;justify-content:flex-start}.header-row .cell[data-field=__tbw_expander]{
|
|
387
|
-
class F extends
|
|
397
|
+
const I = "@layer tbw-plugins{tbw-grid .cell[data-field=__tbw_expander]{border-right:none!important;padding:0;display:flex;align-items:center;justify-content:flex-start}tbw-grid .header-row .cell[data-field=__tbw_expander]{display:none}tbw-grid .header-row .cell[data-field=__tbw_expander]+.cell{grid-column:1 / 3}tbw-grid .tree-cell-wrapper{display:inline-flex;align-items:center;padding-left:calc(var(--tbw-tree-depth, 0) * var(--tbw-tree-indent-width, var(--tbw-tree-toggle-size, 1.25em)))}tbw-grid .tree-expander{display:flex;align-items:center;justify-content:flex-start;width:100%;height:100%;box-sizing:border-box}tbw-grid .tree-toggle{cursor:pointer;-webkit-user-select:none;user-select:none;display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-tree-toggle-size, 1.25em);height:var(--tbw-tree-toggle-size, 1.25em);flex-shrink:0}tbw-grid .tree-toggle:hover{color:var(--tbw-tree-accent, var(--tbw-color-accent))}tbw-grid .tree-spacer{width:var(--tbw-tree-toggle-size, 1.25em);display:inline-block;flex-shrink:0}tbw-grid .data-grid-row.tbw-tree-slide-in{animation:tbw-tree-slide-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}tbw-grid .data-grid-row.tbw-tree-fade-in{animation:tbw-tree-fade-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-tree-slide-in{0%{opacity:0;transform:translate(-8px)}to{opacity:1;transform:translate(0)}}@keyframes tbw-tree-fade-in{0%{opacity:0}to{opacity:1}}}";
|
|
398
|
+
class F extends _ {
|
|
388
399
|
name = "tree";
|
|
389
400
|
styles = I;
|
|
390
401
|
get defaultConfig() {
|
|
@@ -421,7 +432,7 @@ class F extends S {
|
|
|
421
432
|
// #region Auto-Detection
|
|
422
433
|
detect(e) {
|
|
423
434
|
if (!this.config.autoDetect) return !1;
|
|
424
|
-
const t = e, n = this.config.childrenField ??
|
|
435
|
+
const t = e, n = this.config.childrenField ?? C(t) ?? "children";
|
|
425
436
|
return m(t, n);
|
|
426
437
|
}
|
|
427
438
|
// #endregion
|
|
@@ -487,22 +498,22 @@ class F extends S {
|
|
|
487
498
|
const t = [...e];
|
|
488
499
|
if (t.length === 0) return t;
|
|
489
500
|
const n = t[0], i = n.viewRenderer, o = () => this.config, r = this.setIcon.bind(this), l = this.resolveIcon.bind(this), a = (d) => {
|
|
490
|
-
const { row: h, value: u } = d, {
|
|
491
|
-
if (f.className = "tree-cell-wrapper", f.style.
|
|
492
|
-
if (
|
|
501
|
+
const { row: h, value: u } = d, { showExpandIcons: A = !0, indentWidth: b } = o(), g = h, K = g.__treeDepth ?? 0, f = document.createElement("span");
|
|
502
|
+
if (f.className = "tree-cell-wrapper", f.style.setProperty("--tbw-tree-depth", String(K)), b !== void 0 && f.style.setProperty("--tbw-tree-indent-width", `${b}px`), A)
|
|
503
|
+
if (g.__treeHasChildren) {
|
|
493
504
|
const c = document.createElement("span");
|
|
494
|
-
c.className = `tree-toggle${
|
|
505
|
+
c.className = `tree-toggle${g.__treeExpanded ? " expanded" : ""}`, r(c, l(g.__treeExpanded ? "collapse" : "expand")), c.setAttribute("data-tree-key", String(g.__treeKey ?? "")), f.appendChild(c);
|
|
495
506
|
} else {
|
|
496
507
|
const c = document.createElement("span");
|
|
497
508
|
c.className = "tree-spacer", f.appendChild(c);
|
|
498
509
|
}
|
|
499
|
-
const
|
|
500
|
-
if (
|
|
510
|
+
const p = document.createElement("span");
|
|
511
|
+
if (p.className = "tree-content", i) {
|
|
501
512
|
const c = i(d);
|
|
502
|
-
c instanceof Node ?
|
|
513
|
+
c instanceof Node ? p.appendChild(c) : typeof c == "string" && (p.innerHTML = c);
|
|
503
514
|
} else
|
|
504
|
-
|
|
505
|
-
return f.appendChild(
|
|
515
|
+
p.textContent = u != null ? String(u) : "";
|
|
516
|
+
return f.appendChild(p), f;
|
|
506
517
|
};
|
|
507
518
|
return t[0] = { ...n, viewRenderer: a }, t;
|
|
508
519
|
}
|
|
@@ -542,7 +553,7 @@ class F extends S {
|
|
|
542
553
|
afterRender() {
|
|
543
554
|
const e = this.animationStyle;
|
|
544
555
|
if (e === !1 || this.keysToAnimate.size === 0) return;
|
|
545
|
-
const t = this.
|
|
556
|
+
const t = this.gridElement?.querySelector(".rows");
|
|
546
557
|
if (!t) return;
|
|
547
558
|
const n = e === "fade" ? "tbw-tree-fade-in" : "tbw-tree-slide-in";
|
|
548
559
|
for (const i of t.querySelectorAll(".data-grid-row")) {
|
|
@@ -581,7 +592,7 @@ class F extends S {
|
|
|
581
592
|
return this.rowKeyMap.get(e)?.data;
|
|
582
593
|
}
|
|
583
594
|
expandToKey(e) {
|
|
584
|
-
this.expandedKeys =
|
|
595
|
+
this.expandedKeys = E(this.rows, e, this.config, this.expandedKeys), this.requestRender();
|
|
585
596
|
}
|
|
586
597
|
// #endregion
|
|
587
598
|
}
|
|
@@ -590,6 +601,6 @@ export {
|
|
|
590
601
|
T as countNodes,
|
|
591
602
|
m as detectTreeStructure,
|
|
592
603
|
k as getMaxDepth,
|
|
593
|
-
|
|
604
|
+
C as inferChildrenField
|
|
594
605
|
};
|
|
595
606
|
//# sourceMappingURL=index.js.map
|