@toolbox-web/grid 0.2.5 → 0.2.6
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.d.ts +56 -23
- package/all.js +841 -809
- package/all.js.map +1 -1
- package/index.d.ts +12 -5
- package/index.js +276 -225
- package/index.js.map +1 -1
- package/lib/plugins/clipboard/index.js +1 -1
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +1 -1
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +1 -1
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/export/index.js +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js +1 -1
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +46 -45
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js +1 -1
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +1 -1
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +1 -1
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +1 -1
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +55 -47
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +243 -241
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +87 -67
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js +28 -27
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +2 -2
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js +70 -70
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +1 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +1 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +13 -13
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +7 -7
- package/umd/grid.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/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/server-side.umd.js +1 -1
- package/umd/plugins/server-side.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js +1 -1
- package/umd/plugins/tree.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 m = {
|
|
|
8
8
|
dragHandle: "⋮⋮",
|
|
9
9
|
toolPanel: "☰"
|
|
10
10
|
};
|
|
11
|
-
class
|
|
11
|
+
class b {
|
|
12
12
|
/** Plugin version - override in subclass if needed */
|
|
13
13
|
version = "1.0.0";
|
|
14
14
|
/** CSS styles to inject into the grid's shadow DOM */
|
|
@@ -99,7 +99,7 @@ class _ {
|
|
|
99
99
|
* Use this for rendering that needs to match the grid template.
|
|
100
100
|
*/
|
|
101
101
|
get visibleColumns() {
|
|
102
|
-
return this.grid?.
|
|
102
|
+
return this.grid?._visibleColumns ?? [];
|
|
103
103
|
}
|
|
104
104
|
/**
|
|
105
105
|
* Get the shadow root of the grid.
|
|
@@ -133,7 +133,7 @@ class _ {
|
|
|
133
133
|
*/
|
|
134
134
|
get gridIcons() {
|
|
135
135
|
const e = this.grid?.gridConfig?.icons ?? {};
|
|
136
|
-
return { ...
|
|
136
|
+
return { ...v, ...e };
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
139
139
|
* Resolve an icon value to string or HTMLElement.
|
|
@@ -167,74 +167,74 @@ class _ {
|
|
|
167
167
|
function w(r, e, t) {
|
|
168
168
|
return r.id !== void 0 ? String(r.id) : t ? `${t}-${e}` : String(e);
|
|
169
169
|
}
|
|
170
|
-
function
|
|
170
|
+
function E(r, e, t, n = null, s = 0) {
|
|
171
171
|
const o = e.childrenField ?? "children", i = [];
|
|
172
172
|
for (let c = 0; c < r.length; c++) {
|
|
173
|
-
const
|
|
173
|
+
const a = r[c], d = w(a, c, n), h = a[o], f = Array.isArray(h) && h.length > 0, g = t.has(d);
|
|
174
174
|
if (i.push({
|
|
175
|
-
key:
|
|
176
|
-
data:
|
|
175
|
+
key: d,
|
|
176
|
+
data: a,
|
|
177
177
|
depth: s,
|
|
178
178
|
hasChildren: f,
|
|
179
|
-
isExpanded:
|
|
179
|
+
isExpanded: g,
|
|
180
180
|
parentKey: n
|
|
181
|
-
}), f &&
|
|
182
|
-
const y =
|
|
181
|
+
}), f && g) {
|
|
182
|
+
const y = E(h, e, t, d, s + 1);
|
|
183
183
|
i.push(...y);
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
return i;
|
|
187
187
|
}
|
|
188
|
-
function
|
|
188
|
+
function C(r, e) {
|
|
189
189
|
const t = new Set(r);
|
|
190
190
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
191
191
|
}
|
|
192
192
|
function x(r, e, t = null, n = 0) {
|
|
193
193
|
const s = e.childrenField ?? "children", o = /* @__PURE__ */ new Set();
|
|
194
194
|
for (let i = 0; i < r.length; i++) {
|
|
195
|
-
const c = r[i],
|
|
196
|
-
if (Array.isArray(
|
|
197
|
-
o.add(
|
|
198
|
-
const h = x(
|
|
195
|
+
const c = r[i], a = w(c, i, t), d = c[s];
|
|
196
|
+
if (Array.isArray(d) && d.length > 0) {
|
|
197
|
+
o.add(a);
|
|
198
|
+
const h = x(d, e, a, n + 1);
|
|
199
199
|
for (const f of h) o.add(f);
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
return o;
|
|
203
203
|
}
|
|
204
|
-
function
|
|
204
|
+
function S() {
|
|
205
205
|
return /* @__PURE__ */ new Set();
|
|
206
206
|
}
|
|
207
|
-
function
|
|
207
|
+
function m(r, e, t, n = null, s = 0) {
|
|
208
208
|
const o = t.childrenField ?? "children";
|
|
209
209
|
for (let i = 0; i < r.length; i++) {
|
|
210
|
-
const c = r[i],
|
|
211
|
-
if (
|
|
212
|
-
return [
|
|
213
|
-
const
|
|
214
|
-
if (Array.isArray(
|
|
215
|
-
const h =
|
|
210
|
+
const c = r[i], a = w(c, i, n);
|
|
211
|
+
if (a === e)
|
|
212
|
+
return [a];
|
|
213
|
+
const d = c[o];
|
|
214
|
+
if (Array.isArray(d) && d.length > 0) {
|
|
215
|
+
const h = m(d, e, t, a, s + 1);
|
|
216
216
|
if (h)
|
|
217
|
-
return [
|
|
217
|
+
return [a, ...h];
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
return null;
|
|
221
221
|
}
|
|
222
|
-
function
|
|
223
|
-
const s =
|
|
222
|
+
function I(r, e, t, n) {
|
|
223
|
+
const s = m(r, e, t);
|
|
224
224
|
if (!s) return n;
|
|
225
225
|
const o = new Set(n);
|
|
226
226
|
for (let i = 0; i < s.length - 1; i++)
|
|
227
227
|
o.add(s[i]);
|
|
228
228
|
return o;
|
|
229
229
|
}
|
|
230
|
-
function
|
|
230
|
+
function K(r, e = "children") {
|
|
231
231
|
if (!Array.isArray(r) || r.length === 0) return !1;
|
|
232
232
|
for (const t of r)
|
|
233
233
|
if (t && Array.isArray(t[e]) && t[e].length > 0)
|
|
234
234
|
return !0;
|
|
235
235
|
return !1;
|
|
236
236
|
}
|
|
237
|
-
function
|
|
237
|
+
function D(r) {
|
|
238
238
|
if (!Array.isArray(r) || r.length === 0) return null;
|
|
239
239
|
const e = ["children", "items", "nodes", "subRows", "nested"];
|
|
240
240
|
for (const t of r)
|
|
@@ -245,32 +245,32 @@ function S(r) {
|
|
|
245
245
|
}
|
|
246
246
|
return null;
|
|
247
247
|
}
|
|
248
|
-
function
|
|
248
|
+
function F(r, e = "children", t = 0) {
|
|
249
249
|
if (!Array.isArray(r) || r.length === 0) return t;
|
|
250
250
|
let n = t;
|
|
251
251
|
for (const s of r) {
|
|
252
252
|
if (!s) continue;
|
|
253
253
|
const o = s[e];
|
|
254
254
|
if (Array.isArray(o) && o.length > 0) {
|
|
255
|
-
const i =
|
|
255
|
+
const i = F(o, e, t + 1);
|
|
256
256
|
i > n && (n = i);
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
259
|
return n;
|
|
260
260
|
}
|
|
261
|
-
function
|
|
261
|
+
function M(r, e = "children") {
|
|
262
262
|
if (!Array.isArray(r)) return 0;
|
|
263
263
|
let t = 0;
|
|
264
264
|
for (const n of r) {
|
|
265
265
|
if (!n) continue;
|
|
266
266
|
t++;
|
|
267
267
|
const s = n[e];
|
|
268
|
-
Array.isArray(s) && (t +=
|
|
268
|
+
Array.isArray(s) && (t += M(s, e));
|
|
269
269
|
}
|
|
270
270
|
return t;
|
|
271
271
|
}
|
|
272
|
-
const
|
|
273
|
-
class
|
|
272
|
+
const k = ".tree-toggle{cursor:pointer;-webkit-user-select:none;user-select:none;transition:transform .2s}.tree-toggle:hover{color:var(--tbw-tree-accent, var(--tbw-color-accent))}";
|
|
273
|
+
class q extends b {
|
|
274
274
|
name = "tree";
|
|
275
275
|
version = "1.0.0";
|
|
276
276
|
get defaultConfig() {
|
|
@@ -304,16 +304,16 @@ class M extends _ {
|
|
|
304
304
|
*/
|
|
305
305
|
detect(e) {
|
|
306
306
|
if (!this.config.autoDetect) return !1;
|
|
307
|
-
const t = this.config.childrenField ??
|
|
308
|
-
return
|
|
307
|
+
const t = this.config.childrenField ?? D(e) ?? "children";
|
|
308
|
+
return K(e, t);
|
|
309
309
|
}
|
|
310
310
|
// #endregion
|
|
311
311
|
// #region Data Processing
|
|
312
312
|
processRows(e) {
|
|
313
313
|
const t = this.config.childrenField ?? "children";
|
|
314
|
-
if (!
|
|
314
|
+
if (!K(e, t))
|
|
315
315
|
return this.flattenedRows = [], this.rowKeyMap.clear(), [...e];
|
|
316
|
-
this.config.defaultExpanded && !this.initialExpansionDone && (this.expandedKeys = x(e, this.config), this.initialExpansionDone = !0), this.flattenedRows =
|
|
316
|
+
this.config.defaultExpanded && !this.initialExpansionDone && (this.expandedKeys = x(e, this.config), this.initialExpansionDone = !0), this.flattenedRows = E(e, this.config, this.expandedKeys), this.rowKeyMap.clear();
|
|
317
317
|
for (const n of this.flattenedRows)
|
|
318
318
|
this.rowKeyMap.set(n.key, n);
|
|
319
319
|
return this.flattenedRows.map((n) => ({
|
|
@@ -326,31 +326,31 @@ class M extends _ {
|
|
|
326
326
|
}
|
|
327
327
|
processColumns(e) {
|
|
328
328
|
if (this.flattenedRows.length === 0) return [...e];
|
|
329
|
-
const t =
|
|
330
|
-
if (
|
|
331
|
-
const
|
|
332
|
-
if (
|
|
333
|
-
return
|
|
334
|
-
const
|
|
335
|
-
const { value: a, row:
|
|
336
|
-
if (u.style.display = "flex", u.style.alignItems = "center", u.style.paddingLeft = `${
|
|
337
|
-
const
|
|
338
|
-
|
|
339
|
-
} else if (
|
|
340
|
-
const
|
|
341
|
-
|
|
329
|
+
const t = [...e];
|
|
330
|
+
if (t.length > 0) {
|
|
331
|
+
const n = { ...t[0] }, s = n.viewRenderer;
|
|
332
|
+
if (s?.__treeWrapped)
|
|
333
|
+
return t;
|
|
334
|
+
const o = () => this.config, i = (c) => {
|
|
335
|
+
const { value: a, row: d, column: h } = c, f = d.__treeDepth ?? 0, g = d.__treeHasChildren ?? !1, y = d.__treeExpanded ?? !1, R = o(), _ = R.indentWidth ?? 20, A = R.showExpandIcons ?? !0, u = document.createElement("span");
|
|
336
|
+
if (u.style.display = "flex", u.style.alignItems = "center", u.style.paddingLeft = `${f * _}px`, g && A) {
|
|
337
|
+
const l = document.createElement("span");
|
|
338
|
+
l.className = "tree-toggle", this.setIcon(l, this.resolveIcon(y ? "collapse" : "expand")), l.style.cursor = "pointer", l.style.marginRight = "4px", l.style.fontSize = "10px", l.setAttribute("data-tree-key", d.__treeKey), u.appendChild(l);
|
|
339
|
+
} else if (A) {
|
|
340
|
+
const l = document.createElement("span");
|
|
341
|
+
l.style.width = "14px", l.style.display = "inline-block", u.appendChild(l);
|
|
342
342
|
}
|
|
343
|
-
const
|
|
344
|
-
if (
|
|
345
|
-
const
|
|
346
|
-
|
|
343
|
+
const p = document.createElement("span");
|
|
344
|
+
if (s) {
|
|
345
|
+
const l = s(c);
|
|
346
|
+
l instanceof Node ? p.appendChild(l) : p.textContent = String(l ?? a ?? "");
|
|
347
347
|
} else
|
|
348
|
-
|
|
349
|
-
return u.appendChild(
|
|
348
|
+
p.textContent = String(a ?? "");
|
|
349
|
+
return u.appendChild(p), u;
|
|
350
350
|
};
|
|
351
|
-
|
|
351
|
+
i.__treeWrapped = !0, n.viewRenderer = i, t[0] = n;
|
|
352
352
|
}
|
|
353
|
-
return
|
|
353
|
+
return t;
|
|
354
354
|
}
|
|
355
355
|
// #endregion
|
|
356
356
|
// #region Event Handlers
|
|
@@ -360,7 +360,7 @@ class M extends _ {
|
|
|
360
360
|
const n = t.getAttribute("data-tree-key");
|
|
361
361
|
if (!n) return !1;
|
|
362
362
|
const s = this.rowKeyMap.get(n);
|
|
363
|
-
return s ? (this.expandedKeys =
|
|
363
|
+
return s ? (this.expandedKeys = C(this.expandedKeys, n), this.emit("tree-expand", {
|
|
364
364
|
key: n,
|
|
365
365
|
row: s.data,
|
|
366
366
|
expanded: this.expandedKeys.has(n),
|
|
@@ -385,7 +385,7 @@ class M extends _ {
|
|
|
385
385
|
* Toggle the expansion state of a node.
|
|
386
386
|
*/
|
|
387
387
|
toggle(e) {
|
|
388
|
-
this.expandedKeys =
|
|
388
|
+
this.expandedKeys = C(this.expandedKeys, e), this.requestRender();
|
|
389
389
|
}
|
|
390
390
|
/**
|
|
391
391
|
* Expand all nodes in the tree.
|
|
@@ -397,7 +397,7 @@ class M extends _ {
|
|
|
397
397
|
* Collapse all nodes in the tree.
|
|
398
398
|
*/
|
|
399
399
|
collapseAll() {
|
|
400
|
-
this.expandedKeys =
|
|
400
|
+
this.expandedKeys = S(), this.requestRender();
|
|
401
401
|
}
|
|
402
402
|
/**
|
|
403
403
|
* Check if a node is currently expanded.
|
|
@@ -427,18 +427,18 @@ class M extends _ {
|
|
|
427
427
|
* Expand all ancestors of a node to make it visible.
|
|
428
428
|
*/
|
|
429
429
|
expandToKey(e) {
|
|
430
|
-
this.expandedKeys =
|
|
430
|
+
this.expandedKeys = I(this.rows, e, this.config, this.expandedKeys), this.requestRender();
|
|
431
431
|
}
|
|
432
432
|
// #endregion
|
|
433
433
|
// #region Styles
|
|
434
|
-
styles =
|
|
434
|
+
styles = k;
|
|
435
435
|
// #endregion
|
|
436
436
|
}
|
|
437
437
|
export {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
438
|
+
q as TreePlugin,
|
|
439
|
+
M as countNodes,
|
|
440
|
+
K as detectTreeStructure,
|
|
441
|
+
F as getMaxDepth,
|
|
442
|
+
D as inferChildrenField
|
|
443
443
|
};
|
|
444
444
|
//# sourceMappingURL=index.js.map
|