@toolbox-web/grid 0.2.5 → 0.2.7
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 +486 -80
- package/all.js +1364 -1029
- package/all.js.map +1 -1
- package/index-DG2CZ_Zo.js +3229 -0
- package/index-DG2CZ_Zo.js.map +1 -0
- package/index.d.ts +222 -11
- package/index.js +25 -3143
- 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 +184 -149
- 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 +117 -83
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +140 -82
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +18 -18
- 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 +385 -351
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +278 -85
- 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 +181 -170
- 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 +22 -22
- 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-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-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 R = {
|
|
2
2
|
expand: "▶",
|
|
3
3
|
collapse: "▼",
|
|
4
4
|
sortAsc: "▲",
|
|
@@ -8,7 +8,7 @@ const v = {
|
|
|
8
8
|
dragHandle: "⋮⋮",
|
|
9
9
|
toolPanel: "☰"
|
|
10
10
|
};
|
|
11
|
-
class
|
|
11
|
+
class A {
|
|
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 R {
|
|
|
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 R {
|
|
|
133
133
|
*/
|
|
134
134
|
get gridIcons() {
|
|
135
135
|
const t = this.grid?.gridConfig?.icons ?? {};
|
|
136
|
-
return { ...
|
|
136
|
+
return { ...R, ...t };
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
139
139
|
* Resolve an icon value to string or HTMLElement.
|
|
@@ -164,7 +164,7 @@ class R {
|
|
|
164
164
|
}
|
|
165
165
|
// #endregion
|
|
166
166
|
}
|
|
167
|
-
const
|
|
167
|
+
const p = {
|
|
168
168
|
sum: (e, t) => e.reduce((n, i) => n + (Number(i[t]) || 0), 0),
|
|
169
169
|
avg: (e, t) => {
|
|
170
170
|
const n = e.reduce((i, r) => i + (Number(r[t]) || 0), 0);
|
|
@@ -175,7 +175,7 @@ const f = {
|
|
|
175
175
|
max: (e, t) => Math.max(...e.map((n) => Number(n[t]) || -1 / 0)),
|
|
176
176
|
first: (e, t) => e[0]?.[t],
|
|
177
177
|
last: (e, t) => e[e.length - 1]?.[t]
|
|
178
|
-
}, u = /* @__PURE__ */ new Map(),
|
|
178
|
+
}, u = /* @__PURE__ */ new Map(), d = {
|
|
179
179
|
/**
|
|
180
180
|
* Register a custom aggregator function.
|
|
181
181
|
*/
|
|
@@ -193,7 +193,7 @@ const f = {
|
|
|
193
193
|
*/
|
|
194
194
|
get(e) {
|
|
195
195
|
if (e !== void 0)
|
|
196
|
-
return typeof e == "function" ? e : u.get(e) ??
|
|
196
|
+
return typeof e == "function" ? e : u.get(e) ?? p[e];
|
|
197
197
|
},
|
|
198
198
|
/**
|
|
199
199
|
* Run an aggregator on a set of rows.
|
|
@@ -206,21 +206,24 @@ const f = {
|
|
|
206
206
|
* Check if an aggregator exists.
|
|
207
207
|
*/
|
|
208
208
|
has(e) {
|
|
209
|
-
return u.has(e) || e in
|
|
209
|
+
return u.has(e) || e in p;
|
|
210
210
|
},
|
|
211
211
|
/**
|
|
212
212
|
* List all available aggregator names.
|
|
213
213
|
*/
|
|
214
214
|
list() {
|
|
215
|
-
return [...Object.keys(
|
|
215
|
+
return [...Object.keys(p), ...u.keys()];
|
|
216
216
|
}
|
|
217
217
|
};
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
function
|
|
218
|
+
d.register.bind(d);
|
|
219
|
+
d.unregister.bind(d);
|
|
220
|
+
const w = d.get.bind(d);
|
|
221
|
+
d.run.bind(d);
|
|
222
|
+
d.list.bind(d);
|
|
223
|
+
function E(e) {
|
|
224
|
+
return typeof e == "object" && e !== null && "aggFunc" in e;
|
|
225
|
+
}
|
|
226
|
+
function m(e, t) {
|
|
224
227
|
const n = document.createElement("div");
|
|
225
228
|
n.className = "tbw-pinned-rows", n.setAttribute("role", "presentation"), n.setAttribute("aria-live", "polite");
|
|
226
229
|
const i = document.createElement("div");
|
|
@@ -242,7 +245,7 @@ function p(e, t) {
|
|
|
242
245
|
}
|
|
243
246
|
if (e.customPanels)
|
|
244
247
|
for (const o of e.customPanels) {
|
|
245
|
-
const a =
|
|
248
|
+
const a = x(o, t);
|
|
246
249
|
switch (o.position) {
|
|
247
250
|
case "left":
|
|
248
251
|
i.appendChild(a);
|
|
@@ -257,11 +260,11 @@ function p(e, t) {
|
|
|
257
260
|
}
|
|
258
261
|
return n.appendChild(i), n.appendChild(r), n.appendChild(s), n;
|
|
259
262
|
}
|
|
260
|
-
function
|
|
263
|
+
function b(e) {
|
|
261
264
|
const t = document.createElement("div");
|
|
262
265
|
return t.className = `tbw-aggregation-rows tbw-aggregation-rows-${e}`, t.setAttribute("role", "presentation"), t;
|
|
263
266
|
}
|
|
264
|
-
function
|
|
267
|
+
function C(e, t, n, i) {
|
|
265
268
|
e.innerHTML = "";
|
|
266
269
|
for (const r of t) {
|
|
267
270
|
const s = document.createElement("div");
|
|
@@ -272,27 +275,32 @@ function w(e, t, n, i) {
|
|
|
272
275
|
for (const o of n) {
|
|
273
276
|
const a = document.createElement("div");
|
|
274
277
|
a.className = "tbw-aggregation-cell", a.setAttribute("data-field", o.field);
|
|
275
|
-
let
|
|
278
|
+
let l, f;
|
|
276
279
|
const h = r.aggregators?.[o.field];
|
|
277
|
-
if (h)
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
280
|
+
if (h)
|
|
281
|
+
if (E(h)) {
|
|
282
|
+
const g = w(h.aggFunc);
|
|
283
|
+
g && (l = g(i, o.field, o)), f = h.formatter;
|
|
284
|
+
} else {
|
|
285
|
+
const g = w(h);
|
|
286
|
+
g && (l = g(i, o.field, o));
|
|
287
|
+
}
|
|
288
|
+
else if (r.cells && Object.prototype.hasOwnProperty.call(r.cells, o.field)) {
|
|
289
|
+
const g = r.cells[o.field];
|
|
290
|
+
typeof g == "function" ? l = g(i, o.field, o) : l = g;
|
|
283
291
|
}
|
|
284
|
-
a.textContent =
|
|
292
|
+
l != null ? a.textContent = f ? f(l, o.field, o) : String(l) : a.textContent = "", s.appendChild(a);
|
|
285
293
|
}
|
|
286
294
|
e.appendChild(s);
|
|
287
295
|
}
|
|
288
296
|
}
|
|
289
|
-
function
|
|
297
|
+
function x(e, t) {
|
|
290
298
|
const n = document.createElement("div");
|
|
291
299
|
n.className = "tbw-status-panel tbw-status-panel-custom", n.id = `status-panel-${e.id}`;
|
|
292
300
|
const i = e.render(t);
|
|
293
301
|
return typeof i == "string" ? n.innerHTML = i : n.appendChild(i), n;
|
|
294
302
|
}
|
|
295
|
-
function
|
|
303
|
+
function v(e, t, n, i, r) {
|
|
296
304
|
return {
|
|
297
305
|
totalRows: e.length,
|
|
298
306
|
filteredRows: r?.cachedResult?.length ?? e.length,
|
|
@@ -302,8 +310,8 @@ function b(e, t, n, i, r) {
|
|
|
302
310
|
grid: n
|
|
303
311
|
};
|
|
304
312
|
}
|
|
305
|
-
const
|
|
306
|
-
class
|
|
313
|
+
const y = ".tbw-footer{position:sticky;bottom: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:8px 12px;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:12px;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:16px}.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, 2px 8px);min-height:var(--tbw-row-height, 28px);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}";
|
|
314
|
+
class S extends A {
|
|
307
315
|
name = "pinnedRows";
|
|
308
316
|
version = "1.0.0";
|
|
309
317
|
get defaultConfig() {
|
|
@@ -331,41 +339,41 @@ class y extends R {
|
|
|
331
339
|
if (!t) return;
|
|
332
340
|
const n = t.querySelector(".tbw-scroll-area") ?? t.querySelector(".tbw-grid-content") ?? t.children[0];
|
|
333
341
|
if (!n) return;
|
|
334
|
-
const i = this.getSelectionState(), r = this.getFilterState(), s =
|
|
342
|
+
const i = this.getSelectionState(), r = this.getFilterState(), s = v(
|
|
335
343
|
this.rows,
|
|
336
344
|
this.columns,
|
|
337
345
|
this.grid,
|
|
338
346
|
i,
|
|
339
347
|
r
|
|
340
|
-
), o = this.config.aggregationRows || [], a = o.filter((
|
|
348
|
+
), o = this.config.aggregationRows || [], a = o.filter((c) => c.position === "top"), l = o.filter((c) => c.position !== "top");
|
|
341
349
|
if (a.length > 0) {
|
|
342
350
|
if (!this.topAggregationContainer) {
|
|
343
|
-
this.topAggregationContainer =
|
|
344
|
-
const
|
|
345
|
-
|
|
351
|
+
this.topAggregationContainer = b("top");
|
|
352
|
+
const c = t.querySelector(".header");
|
|
353
|
+
c && c.nextSibling ? n.insertBefore(this.topAggregationContainer, c.nextSibling) : n.appendChild(this.topAggregationContainer);
|
|
346
354
|
}
|
|
347
|
-
|
|
355
|
+
C(
|
|
348
356
|
this.topAggregationContainer,
|
|
349
357
|
a,
|
|
350
358
|
this.visibleColumns,
|
|
351
359
|
this.rows
|
|
352
360
|
);
|
|
353
361
|
} else this.topAggregationContainer && (this.topAggregationContainer.remove(), this.topAggregationContainer = null);
|
|
354
|
-
const
|
|
355
|
-
if (
|
|
362
|
+
const f = this.config.showRowCount !== !1 || this.config.showSelectedCount && s.selectedRows > 0 || this.config.showFilteredCount && s.filteredRows !== s.totalRows || this.config.customPanels && this.config.customPanels.length > 0, h = f && this.config.position !== "top", g = l.length > 0 || h;
|
|
363
|
+
if (f && this.config.position === "top")
|
|
356
364
|
if (!this.infoBarElement)
|
|
357
|
-
this.infoBarElement =
|
|
365
|
+
this.infoBarElement = m(this.config, s), n.insertBefore(this.infoBarElement, n.firstChild);
|
|
358
366
|
else {
|
|
359
|
-
const
|
|
360
|
-
this.infoBarElement.replaceWith(
|
|
367
|
+
const c = m(this.config, s);
|
|
368
|
+
this.infoBarElement.replaceWith(c), this.infoBarElement = c;
|
|
361
369
|
}
|
|
362
370
|
else this.config.position === "top" && this.infoBarElement && (this.infoBarElement.remove(), this.infoBarElement = null);
|
|
363
|
-
|
|
371
|
+
g ? (this.footerWrapper || (this.footerWrapper = document.createElement("div"), this.footerWrapper.className = "tbw-footer", n.appendChild(this.footerWrapper)), this.footerWrapper.innerHTML = "", l.length > 0 && (this.bottomAggregationContainer || (this.bottomAggregationContainer = b("bottom")), this.footerWrapper.appendChild(this.bottomAggregationContainer), C(
|
|
364
372
|
this.bottomAggregationContainer,
|
|
365
|
-
|
|
373
|
+
l,
|
|
366
374
|
this.visibleColumns,
|
|
367
375
|
this.rows
|
|
368
|
-
)),
|
|
376
|
+
)), h && (this.infoBarElement = m(this.config, s), this.footerWrapper.appendChild(this.infoBarElement))) : this.cleanupFooter();
|
|
369
377
|
}
|
|
370
378
|
// #endregion
|
|
371
379
|
// #region Private Methods
|
|
@@ -403,7 +411,7 @@ class y extends R {
|
|
|
403
411
|
*/
|
|
404
412
|
getContext() {
|
|
405
413
|
const t = this.getSelectionState(), n = this.getFilterState();
|
|
406
|
-
return
|
|
414
|
+
return v(
|
|
407
415
|
this.rows,
|
|
408
416
|
this.columns,
|
|
409
417
|
this.grid,
|
|
@@ -441,10 +449,10 @@ class y extends R {
|
|
|
441
449
|
}
|
|
442
450
|
// #endregion
|
|
443
451
|
// #region Styles
|
|
444
|
-
styles =
|
|
452
|
+
styles = y;
|
|
445
453
|
// #endregion
|
|
446
454
|
}
|
|
447
455
|
export {
|
|
448
|
-
|
|
456
|
+
S as PinnedRowsPlugin
|
|
449
457
|
};
|
|
450
458
|
//# sourceMappingURL=index.js.map
|