@toolbox-web/grid 0.2.6 → 0.2.8
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 +434 -61
- package/all.js +844 -541
- package/all.js.map +1 -1
- package/index-YjW60MHD.js +3235 -0
- package/index-YjW60MHD.js.map +1 -0
- package/index.d.ts +210 -6
- package/index.js +25 -3194
- package/index.js.map +1 -1
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js +183 -148
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js +116 -82
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +139 -81
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +17 -17
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +369 -337
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +264 -91
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js +180 -169
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +21 -21
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +12 -12
- package/umd/grid.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-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/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/tree.umd.js +1 -1
- package/umd/plugins/tree.umd.js.map +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const w = {
|
|
2
2
|
expand: "▶",
|
|
3
3
|
collapse: "▼",
|
|
4
4
|
sortAsc: "▲",
|
|
@@ -8,7 +8,7 @@ const p = {
|
|
|
8
8
|
dragHandle: "⋮⋮",
|
|
9
9
|
toolPanel: "☰"
|
|
10
10
|
};
|
|
11
|
-
class
|
|
11
|
+
class m {
|
|
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 */
|
|
@@ -133,7 +133,7 @@ class x {
|
|
|
133
133
|
*/
|
|
134
134
|
get gridIcons() {
|
|
135
135
|
const e = this.grid?.gridConfig?.icons ?? {};
|
|
136
|
-
return { ...
|
|
136
|
+
return { ...w, ...e };
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
139
139
|
* Resolve an icon value to string or HTMLElement.
|
|
@@ -164,31 +164,31 @@ class x {
|
|
|
164
164
|
}
|
|
165
165
|
// #endregion
|
|
166
166
|
}
|
|
167
|
-
function
|
|
168
|
-
const t = new Set(
|
|
167
|
+
function p(c, e) {
|
|
168
|
+
const t = new Set(c);
|
|
169
169
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
170
170
|
}
|
|
171
|
-
function
|
|
172
|
-
const t = new Set(
|
|
171
|
+
function x(c, e) {
|
|
172
|
+
const t = new Set(c);
|
|
173
173
|
return t.add(e), t;
|
|
174
174
|
}
|
|
175
|
-
function
|
|
176
|
-
const t = new Set(
|
|
175
|
+
function R(c, e) {
|
|
176
|
+
const t = new Set(c);
|
|
177
177
|
return t.delete(e), t;
|
|
178
178
|
}
|
|
179
|
-
function
|
|
180
|
-
return
|
|
179
|
+
function b(c, e) {
|
|
180
|
+
return c.has(e);
|
|
181
181
|
}
|
|
182
|
-
function
|
|
182
|
+
function E(c, e, t, i) {
|
|
183
183
|
const o = document.createElement("div");
|
|
184
184
|
o.className = "master-detail-row", o.setAttribute("data-detail-for", String(e)), o.setAttribute("role", "row");
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
const
|
|
188
|
-
return typeof
|
|
185
|
+
const a = document.createElement("div");
|
|
186
|
+
a.className = "master-detail-cell", a.setAttribute("role", "cell"), a.style.gridColumn = `1 / ${i + 1}`;
|
|
187
|
+
const r = t(c, e);
|
|
188
|
+
return typeof r == "string" ? a.innerHTML = r : r instanceof HTMLElement && a.appendChild(r), o.appendChild(a), o;
|
|
189
189
|
}
|
|
190
|
-
const
|
|
191
|
-
class
|
|
190
|
+
const y = ".master-detail-cell-wrapper{display:flex;align-items:center;gap:4px}.master-detail-toggle{cursor:pointer;opacity:.7;-webkit-user-select:none;user-select:none;display:inline-flex;align-items:center;justify-content:center}.master-detail-toggle:hover{opacity:1}.master-detail-row{grid-column:1 / -1;display:grid;background:var(--tbw-master-detail-bg, var(--tbw-color-row-alt));border-bottom:1px solid var(--tbw-master-detail-border, var(--tbw-color-border));overflow:hidden}.master-detail-cell{padding:16px;overflow:auto}.master-detail-row.tbw-expanding{animation:tbw-detail-expand var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}.master-detail-row.tbw-collapsing{animation:tbw-detail-collapse var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-detail-expand{0%{opacity:0;max-height:0;padding-top:0;padding-bottom:0}to{opacity:1;max-height:500px;padding-top:16px;padding-bottom:16px}}@keyframes tbw-detail-collapse{0%{opacity:1;max-height:500px}to{opacity:0;max-height:0}}";
|
|
191
|
+
class C extends m {
|
|
192
192
|
name = "masterDetail";
|
|
193
193
|
version = "1.0.0";
|
|
194
194
|
get defaultConfig() {
|
|
@@ -196,9 +196,67 @@ class v extends x {
|
|
|
196
196
|
detailHeight: "auto",
|
|
197
197
|
expandOnRowClick: !1,
|
|
198
198
|
collapseOnClickOutside: !1,
|
|
199
|
-
showExpandColumn: !0
|
|
199
|
+
showExpandColumn: !0,
|
|
200
|
+
animation: "slide"
|
|
201
|
+
// Plugin's own default
|
|
200
202
|
};
|
|
201
203
|
}
|
|
204
|
+
// #region Animation Helpers
|
|
205
|
+
/**
|
|
206
|
+
* Check if animations are enabled at the grid level.
|
|
207
|
+
* Respects gridConfig.animation.mode and CSS variable.
|
|
208
|
+
*/
|
|
209
|
+
get isAnimationEnabled() {
|
|
210
|
+
const t = this.grid.effectiveConfig?.animation?.mode ?? "reduced-motion";
|
|
211
|
+
if (t === !1 || t === "off") return !1;
|
|
212
|
+
if (t === !0 || t === "on") return !0;
|
|
213
|
+
const i = this.shadowRoot?.host;
|
|
214
|
+
return i ? getComputedStyle(i).getPropertyValue("--tbw-animation-enabled").trim() !== "0" : !0;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Get expand/collapse animation style from plugin config.
|
|
218
|
+
*/
|
|
219
|
+
get animationStyle() {
|
|
220
|
+
return this.isAnimationEnabled ? this.config.animation ?? "slide" : !1;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Get animation duration from CSS variable (set by grid).
|
|
224
|
+
*/
|
|
225
|
+
get animationDuration() {
|
|
226
|
+
const e = this.shadowRoot?.host;
|
|
227
|
+
if (e) {
|
|
228
|
+
const t = getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(), i = parseInt(t, 10);
|
|
229
|
+
if (!isNaN(i)) return i;
|
|
230
|
+
}
|
|
231
|
+
return 200;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Apply expand animation to a detail element.
|
|
235
|
+
*/
|
|
236
|
+
animateExpand(e) {
|
|
237
|
+
!this.isAnimationEnabled || this.animationStyle === !1 || (e.classList.add("tbw-expanding"), e.addEventListener(
|
|
238
|
+
"animationend",
|
|
239
|
+
() => {
|
|
240
|
+
e.classList.remove("tbw-expanding");
|
|
241
|
+
},
|
|
242
|
+
{ once: !0 }
|
|
243
|
+
));
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Apply collapse animation to a detail element and remove after animation.
|
|
247
|
+
*/
|
|
248
|
+
animateCollapse(e, t) {
|
|
249
|
+
if (!this.isAnimationEnabled || this.animationStyle === !1) {
|
|
250
|
+
t();
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
e.classList.add("tbw-collapsing");
|
|
254
|
+
const i = () => {
|
|
255
|
+
e.classList.remove("tbw-collapsing"), t();
|
|
256
|
+
};
|
|
257
|
+
e.addEventListener("animationend", i, { once: !0 }), setTimeout(i, this.animationDuration + 50);
|
|
258
|
+
}
|
|
259
|
+
// #endregion
|
|
202
260
|
// #region Internal State
|
|
203
261
|
expandedRows = /* @__PURE__ */ new Set();
|
|
204
262
|
detailElements = /* @__PURE__ */ new Map();
|
|
@@ -214,37 +272,37 @@ class v extends x {
|
|
|
214
272
|
return [...e];
|
|
215
273
|
const t = [...e];
|
|
216
274
|
if (t.length > 0) {
|
|
217
|
-
const
|
|
275
|
+
const i = { ...t[0] }, o = i.viewRenderer;
|
|
218
276
|
if (o?.__masterDetailWrapped)
|
|
219
277
|
return t;
|
|
220
|
-
const
|
|
221
|
-
const { value:
|
|
222
|
-
|
|
278
|
+
const a = (r) => {
|
|
279
|
+
const { value: s, row: n } = r, d = this.expandedRows.has(n), l = document.createElement("span");
|
|
280
|
+
l.className = "master-detail-cell-wrapper";
|
|
223
281
|
const h = document.createElement("span");
|
|
224
|
-
h.className =
|
|
225
|
-
|
|
226
|
-
const
|
|
227
|
-
this.expandedRows =
|
|
228
|
-
rowIndex:
|
|
229
|
-
row:
|
|
230
|
-
expanded: this.expandedRows.has(
|
|
282
|
+
h.className = `master-detail-toggle${d ? " expanded" : ""}`, this.setIcon(h, this.resolveIcon(d ? "collapse" : "expand")), h.setAttribute("role", "button"), h.setAttribute("tabindex", "0"), h.setAttribute("aria-expanded", String(d)), h.setAttribute("aria-label", d ? "Collapse details" : "Expand details"), h.addEventListener("click", (g) => {
|
|
283
|
+
g.stopPropagation();
|
|
284
|
+
const f = this.rows.indexOf(n);
|
|
285
|
+
this.expandedRows = p(this.expandedRows, n), this.emit("detail-expand", {
|
|
286
|
+
rowIndex: f,
|
|
287
|
+
row: n,
|
|
288
|
+
expanded: this.expandedRows.has(n)
|
|
231
289
|
}), this.requestRender();
|
|
232
|
-
}),
|
|
290
|
+
}), l.appendChild(h);
|
|
233
291
|
const u = document.createElement("span");
|
|
234
292
|
if (o) {
|
|
235
|
-
const
|
|
236
|
-
|
|
293
|
+
const g = o(r);
|
|
294
|
+
g instanceof Node ? u.appendChild(g) : u.textContent = String(g ?? s ?? "");
|
|
237
295
|
} else
|
|
238
|
-
u.textContent = String(
|
|
239
|
-
return
|
|
296
|
+
u.textContent = String(s ?? "");
|
|
297
|
+
return l.appendChild(u), l;
|
|
240
298
|
};
|
|
241
|
-
|
|
299
|
+
a.__masterDetailWrapped = !0, i.viewRenderer = a, t[0] = i;
|
|
242
300
|
}
|
|
243
301
|
return t;
|
|
244
302
|
}
|
|
245
303
|
onRowClick(e) {
|
|
246
304
|
if (!(!this.config.expandOnRowClick || !this.config.detailRenderer))
|
|
247
|
-
return this.expandedRows =
|
|
305
|
+
return this.expandedRows = p(this.expandedRows, e.row), this.emit("detail-expand", {
|
|
248
306
|
rowIndex: e.rowIndex,
|
|
249
307
|
row: e.row,
|
|
250
308
|
expanded: this.expandedRows.has(e.row)
|
|
@@ -271,26 +329,26 @@ class v extends x {
|
|
|
271
329
|
if (!this.config.detailRenderer) return;
|
|
272
330
|
const e = this.shadowRoot?.querySelector(".rows");
|
|
273
331
|
if (!e) return;
|
|
274
|
-
const t = /* @__PURE__ */ new Map(),
|
|
275
|
-
for (const
|
|
276
|
-
const
|
|
277
|
-
|
|
332
|
+
const t = /* @__PURE__ */ new Map(), i = e.querySelectorAll(".data-grid-row"), o = this.columns.length;
|
|
333
|
+
for (const r of i) {
|
|
334
|
+
const s = r.querySelector(".cell[data-row]"), n = s ? parseInt(s.getAttribute("data-row") ?? "-1", 10) : -1;
|
|
335
|
+
n >= 0 && t.set(n, r);
|
|
278
336
|
}
|
|
279
|
-
const
|
|
280
|
-
for (const
|
|
281
|
-
const
|
|
282
|
-
(!
|
|
337
|
+
const a = e.querySelectorAll(".master-detail-row");
|
|
338
|
+
for (const r of a) {
|
|
339
|
+
const s = parseInt(r.getAttribute("data-detail-for") ?? "-1", 10), n = s >= 0 ? this.rows[s] : void 0, d = n && this.expandedRows.has(n), l = t.has(s);
|
|
340
|
+
(!d || !l) && (r.remove(), n && this.detailElements.delete(n));
|
|
283
341
|
}
|
|
284
|
-
for (const [
|
|
285
|
-
const
|
|
286
|
-
if (!
|
|
287
|
-
const
|
|
288
|
-
if (
|
|
289
|
-
|
|
342
|
+
for (const [r, s] of t) {
|
|
343
|
+
const n = this.rows[r];
|
|
344
|
+
if (!n || !this.expandedRows.has(n)) continue;
|
|
345
|
+
const d = this.detailElements.get(n);
|
|
346
|
+
if (d) {
|
|
347
|
+
d.previousElementSibling !== s && s.after(d);
|
|
290
348
|
continue;
|
|
291
349
|
}
|
|
292
|
-
const
|
|
293
|
-
typeof this.config.detailHeight == "number" && (
|
|
350
|
+
const l = E(n, r, this.config.detailRenderer, o);
|
|
351
|
+
typeof this.config.detailHeight == "number" && (l.style.height = `${this.config.detailHeight}px`), s.after(l), this.detailElements.set(n, l), this.animateExpand(l);
|
|
294
352
|
}
|
|
295
353
|
}
|
|
296
354
|
/**
|
|
@@ -300,9 +358,9 @@ class v extends x {
|
|
|
300
358
|
getExtraHeight() {
|
|
301
359
|
let e = 0;
|
|
302
360
|
for (const t of this.expandedRows) {
|
|
303
|
-
const
|
|
304
|
-
if (
|
|
305
|
-
e +=
|
|
361
|
+
const i = this.detailElements.get(t);
|
|
362
|
+
if (i)
|
|
363
|
+
e += i.offsetHeight;
|
|
306
364
|
else {
|
|
307
365
|
const o = this.config?.detailHeight;
|
|
308
366
|
e += typeof o == "number" ? o : 150;
|
|
@@ -316,15 +374,15 @@ class v extends x {
|
|
|
316
374
|
*/
|
|
317
375
|
getExtraHeightBefore(e) {
|
|
318
376
|
let t = 0;
|
|
319
|
-
for (const
|
|
320
|
-
const o = this.rows.indexOf(
|
|
377
|
+
for (const i of this.expandedRows) {
|
|
378
|
+
const o = this.rows.indexOf(i);
|
|
321
379
|
if (o >= 0 && o < e) {
|
|
322
|
-
const
|
|
323
|
-
if (
|
|
324
|
-
t +=
|
|
380
|
+
const a = this.detailElements.get(i);
|
|
381
|
+
if (a)
|
|
382
|
+
t += a.offsetHeight;
|
|
325
383
|
else {
|
|
326
|
-
const
|
|
327
|
-
t += typeof
|
|
384
|
+
const r = this.config?.detailHeight;
|
|
385
|
+
t += typeof r == "number" ? r : 150;
|
|
328
386
|
}
|
|
329
387
|
}
|
|
330
388
|
}
|
|
@@ -334,20 +392,20 @@ class v extends x {
|
|
|
334
392
|
* Adjust the virtualization start index to keep expanded row visible while its detail is visible.
|
|
335
393
|
* This ensures the detail scrolls smoothly out of view instead of disappearing abruptly.
|
|
336
394
|
*/
|
|
337
|
-
adjustVirtualStart(e, t,
|
|
395
|
+
adjustVirtualStart(e, t, i) {
|
|
338
396
|
if (this.expandedRows.size === 0) return e;
|
|
339
397
|
const o = [];
|
|
340
|
-
for (const
|
|
341
|
-
const
|
|
342
|
-
|
|
398
|
+
for (const s of this.expandedRows) {
|
|
399
|
+
const n = this.rows.indexOf(s);
|
|
400
|
+
n >= 0 && o.push({ index: n, row: s });
|
|
343
401
|
}
|
|
344
|
-
o.sort((
|
|
345
|
-
let
|
|
346
|
-
for (const { index:
|
|
347
|
-
const
|
|
348
|
-
|
|
402
|
+
o.sort((s, n) => s.index - n.index);
|
|
403
|
+
let a = e, r = 0;
|
|
404
|
+
for (const { index: s, row: n } of o) {
|
|
405
|
+
const d = s * i + r, h = this.detailElements.get(n)?.offsetHeight ?? (typeof this.config?.detailHeight == "number" ? this.config.detailHeight : 150), u = d + i + h;
|
|
406
|
+
r += h, !(s >= e) && u > t && s < a && (a = s);
|
|
349
407
|
}
|
|
350
|
-
return
|
|
408
|
+
return a;
|
|
351
409
|
}
|
|
352
410
|
// #endregion
|
|
353
411
|
// #region Public API
|
|
@@ -357,7 +415,7 @@ class v extends x {
|
|
|
357
415
|
*/
|
|
358
416
|
expand(e) {
|
|
359
417
|
const t = this.rows[e];
|
|
360
|
-
t && (this.expandedRows =
|
|
418
|
+
t && (this.expandedRows = x(this.expandedRows, t), this.requestRender());
|
|
361
419
|
}
|
|
362
420
|
/**
|
|
363
421
|
* Collapse the detail row at the given index.
|
|
@@ -365,7 +423,7 @@ class v extends x {
|
|
|
365
423
|
*/
|
|
366
424
|
collapse(e) {
|
|
367
425
|
const t = this.rows[e];
|
|
368
|
-
t && (this.expandedRows =
|
|
426
|
+
t && (this.expandedRows = R(this.expandedRows, t), this.requestRender());
|
|
369
427
|
}
|
|
370
428
|
/**
|
|
371
429
|
* Toggle the detail row at the given index.
|
|
@@ -373,7 +431,7 @@ class v extends x {
|
|
|
373
431
|
*/
|
|
374
432
|
toggle(e) {
|
|
375
433
|
const t = this.rows[e];
|
|
376
|
-
t && (this.expandedRows =
|
|
434
|
+
t && (this.expandedRows = p(this.expandedRows, t), this.requestRender());
|
|
377
435
|
}
|
|
378
436
|
/**
|
|
379
437
|
* Check if the detail row at the given index is expanded.
|
|
@@ -382,7 +440,7 @@ class v extends x {
|
|
|
382
440
|
*/
|
|
383
441
|
isExpanded(e) {
|
|
384
442
|
const t = this.rows[e];
|
|
385
|
-
return t ?
|
|
443
|
+
return t ? b(this.expandedRows, t) : !1;
|
|
386
444
|
}
|
|
387
445
|
/**
|
|
388
446
|
* Expand all detail rows.
|
|
@@ -405,8 +463,8 @@ class v extends x {
|
|
|
405
463
|
getExpandedRows() {
|
|
406
464
|
const e = [];
|
|
407
465
|
for (const t of this.expandedRows) {
|
|
408
|
-
const
|
|
409
|
-
|
|
466
|
+
const i = this.rows.indexOf(t);
|
|
467
|
+
i >= 0 && e.push(i);
|
|
410
468
|
}
|
|
411
469
|
return e;
|
|
412
470
|
}
|
|
@@ -421,10 +479,10 @@ class v extends x {
|
|
|
421
479
|
}
|
|
422
480
|
// #endregion
|
|
423
481
|
// #region Styles
|
|
424
|
-
styles =
|
|
482
|
+
styles = y;
|
|
425
483
|
// #endregion
|
|
426
484
|
}
|
|
427
485
|
export {
|
|
428
|
-
|
|
486
|
+
C as MasterDetailPlugin
|
|
429
487
|
};
|
|
430
488
|
//# sourceMappingURL=index.js.map
|