@toolbox-web/grid 0.0.7 → 0.1.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/all.d.ts +151 -95
- package/all.js +1554 -1452
- package/all.js.map +1 -1
- package/custom-elements.json +89 -7
- package/index.d.ts +68 -23
- package/index.js +1066 -948
- package/index.js.map +1 -1
- package/lib/plugins/clipboard/index.js +48 -49
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +6 -6
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +32 -34
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/export/index.js +7 -7
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js +5 -38
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +4 -32
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js +8 -45
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +6 -30
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +19 -42
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +5 -6
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +6 -80
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +673 -145
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +22 -51
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js +53 -83
- 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 +6 -14
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +2 -3
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +13 -105
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/themes/dg-theme-bootstrap.css +73 -0
- package/themes/dg-theme-material.css +71 -0
- package/umd/grid.all.umd.js +40 -415
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +29 -60
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js +4 -4
- package/umd/plugins/clipboard.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 +2 -2
- package/umd/plugins/context-menu.umd.js.map +1 -1
- package/umd/plugins/export.umd.js +1 -1
- package/umd/plugins/export.umd.js.map +1 -1
- package/umd/plugins/filtering.umd.js +2 -34
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/grouping-columns.umd.js +1 -28
- package/umd/plugins/grouping-columns.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js +1 -39
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js +1 -26
- package/umd/plugins/master-detail.umd.js.map +1 -1
- package/umd/plugins/multi-sort.umd.js +1 -25
- 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 -72
- package/umd/plugins/pinned-rows.umd.js.map +1 -1
- package/umd/plugins/pivot.umd.js +1 -7
- package/umd/plugins/pivot.umd.js.map +1 -1
- package/umd/plugins/reorder.umd.js +1 -30
- package/umd/plugins/reorder.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +1 -33
- 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 -10
- package/umd/plugins/tree.umd.js.map +1 -1
- package/umd/plugins/undo-redo.umd.js +1 -1
- package/umd/plugins/undo-redo.umd.js.map +1 -1
- package/umd/plugins/visibility.umd.js +1 -93
- package/umd/plugins/visibility.umd.js.map +1 -1
|
@@ -5,7 +5,8 @@ const b = {
|
|
|
5
5
|
sortDesc: "▼",
|
|
6
6
|
sortNone: "⇅",
|
|
7
7
|
submenuArrow: "▶",
|
|
8
|
-
dragHandle: "⋮⋮"
|
|
8
|
+
dragHandle: "⋮⋮",
|
|
9
|
+
toolPanel: "☰"
|
|
9
10
|
};
|
|
10
11
|
class I {
|
|
11
12
|
/** Plugin version - override in subclass if needed */
|
|
@@ -162,23 +163,23 @@ class I {
|
|
|
162
163
|
console.warn(`[tbw-grid:${this.name}] ${e}`);
|
|
163
164
|
}
|
|
164
165
|
}
|
|
165
|
-
function T(
|
|
166
|
+
function T(h, e, t, n) {
|
|
166
167
|
if (n.processCell)
|
|
167
|
-
return n.processCell(
|
|
168
|
-
if (
|
|
169
|
-
if (
|
|
170
|
-
if (typeof
|
|
171
|
-
const i = String(
|
|
168
|
+
return n.processCell(h, e, t);
|
|
169
|
+
if (h == null) return "";
|
|
170
|
+
if (h instanceof Date) return h.toISOString();
|
|
171
|
+
if (typeof h == "object") return JSON.stringify(h);
|
|
172
|
+
const i = String(h), l = n.delimiter ?? " ", o = n.newline ?? `
|
|
172
173
|
`;
|
|
173
|
-
return n.quoteStrings || i.includes(l) || i.includes(
|
|
174
|
+
return n.quoteStrings || i.includes(l) || i.includes(o) || i.includes('"') ? `"${i.replace(/"/g, '""')}"` : i;
|
|
174
175
|
}
|
|
175
|
-
function p(
|
|
176
|
-
const { rows: e, columns: t, selectedIndices: n, config: i } =
|
|
177
|
-
`,
|
|
176
|
+
function p(h) {
|
|
177
|
+
const { rows: e, columns: t, selectedIndices: n, config: i } = h, l = i.delimiter ?? " ", o = i.newline ?? `
|
|
178
|
+
`, r = t.filter((s) => !s.hidden && !s.field.startsWith("__")), c = [];
|
|
178
179
|
if (i.includeHeaders) {
|
|
179
|
-
const s =
|
|
180
|
-
const
|
|
181
|
-
return
|
|
180
|
+
const s = r.map((d) => {
|
|
181
|
+
const f = d.header || d.field;
|
|
182
|
+
return f.includes(l) || f.includes(o) || f.includes('"') ? `"${f.replace(/"/g, '""')}"` : f;
|
|
182
183
|
});
|
|
183
184
|
c.push(s.join(l));
|
|
184
185
|
}
|
|
@@ -186,34 +187,34 @@ function p(f) {
|
|
|
186
187
|
for (const s of u) {
|
|
187
188
|
const d = e[s];
|
|
188
189
|
if (!d) continue;
|
|
189
|
-
const
|
|
190
|
+
const f = r.map(
|
|
190
191
|
(g) => T(d[g.field], g.field, d, i)
|
|
191
192
|
);
|
|
192
|
-
c.push(
|
|
193
|
+
c.push(f.join(l));
|
|
193
194
|
}
|
|
194
|
-
return c.join(
|
|
195
|
+
return c.join(o);
|
|
195
196
|
}
|
|
196
|
-
async function C(
|
|
197
|
+
async function C(h) {
|
|
197
198
|
try {
|
|
198
|
-
return await navigator.clipboard.writeText(
|
|
199
|
+
return await navigator.clipboard.writeText(h), !0;
|
|
199
200
|
} catch {
|
|
200
201
|
const e = document.createElement("textarea");
|
|
201
|
-
e.value =
|
|
202
|
+
e.value = h, e.style.position = "fixed", e.style.opacity = "0", e.style.pointerEvents = "none", document.body.appendChild(e), e.select();
|
|
202
203
|
const t = document.execCommand("copy");
|
|
203
204
|
return document.body.removeChild(e), t;
|
|
204
205
|
}
|
|
205
206
|
}
|
|
206
|
-
function y(
|
|
207
|
+
function y(h, e) {
|
|
207
208
|
const t = e.delimiter ?? " ", n = e.newline ?? `
|
|
208
|
-
`, i =
|
|
209
|
+
`, i = h.replace(/\r\n/g, `
|
|
209
210
|
`).replace(/\r/g, `
|
|
210
211
|
`), l = [];
|
|
211
|
-
let
|
|
212
|
+
let o = [], r = "", c = !1;
|
|
212
213
|
for (let a = 0; a < i.length; a++) {
|
|
213
214
|
const u = i[a];
|
|
214
|
-
u === '"' && !c ? c = !0 : u === '"' && c ? i[a + 1] === '"' ? (
|
|
215
|
+
u === '"' && !c ? c = !0 : u === '"' && c ? i[a + 1] === '"' ? (r += '"', a++) : c = !1 : u === t && !c ? (o.push(r), r = "") : u === n && !c ? (o.push(r), r = "", (o.length > 1 || o.some((s) => s.trim() !== "")) && l.push(o), o = []) : r += u;
|
|
215
216
|
}
|
|
216
|
-
return
|
|
217
|
+
return o.push(r), (o.length > 1 || o.some((a) => a.trim() !== "")) && l.push(o), l;
|
|
217
218
|
}
|
|
218
219
|
async function x() {
|
|
219
220
|
try {
|
|
@@ -227,7 +228,6 @@ class D extends I {
|
|
|
227
228
|
version = "1.0.0";
|
|
228
229
|
get defaultConfig() {
|
|
229
230
|
return {
|
|
230
|
-
enabled: !0,
|
|
231
231
|
includeHeaders: !1,
|
|
232
232
|
delimiter: " ",
|
|
233
233
|
newline: `
|
|
@@ -244,7 +244,6 @@ class D extends I {
|
|
|
244
244
|
}
|
|
245
245
|
// ===== Event Handlers =====
|
|
246
246
|
onKeyDown(e) {
|
|
247
|
-
if (this.config.enabled === !1) return !1;
|
|
248
247
|
const t = (e.ctrlKey || e.metaKey) && e.key === "c", n = (e.ctrlKey || e.metaKey) && e.key === "v";
|
|
249
248
|
return t ? (this.#t(e.target), !0) : n ? (this.#n(), !0) : !1;
|
|
250
249
|
}
|
|
@@ -253,7 +252,7 @@ class D extends I {
|
|
|
253
252
|
* Handle copy operation
|
|
254
253
|
*/
|
|
255
254
|
#t(e) {
|
|
256
|
-
const t = this.#e(), n = t?.getSelectedRows() ?? [], i = n.length > 0, l = t?.getRanges() ?? [],
|
|
255
|
+
const t = this.#e(), n = t?.getSelectedRows() ?? [], i = n.length > 0, l = t?.getRanges() ?? [], o = l.length > 0, r = t?.getSelectedCell() != null;
|
|
257
256
|
let c, a, u;
|
|
258
257
|
if (i && t)
|
|
259
258
|
c = p({
|
|
@@ -262,7 +261,7 @@ class D extends I {
|
|
|
262
261
|
selectedIndices: n,
|
|
263
262
|
config: this.config
|
|
264
263
|
}), a = n.length, u = this.columns.filter((s) => !s.hidden && !s.field.startsWith("__")).length;
|
|
265
|
-
else if (
|
|
264
|
+
else if (o && t) {
|
|
266
265
|
const s = l[l.length - 1], d = this.#i({
|
|
267
266
|
startRow: s.from.row,
|
|
268
267
|
startCol: s.from.col,
|
|
@@ -270,12 +269,12 @@ class D extends I {
|
|
|
270
269
|
endCol: s.to.col
|
|
271
270
|
});
|
|
272
271
|
c = d.text, a = d.rowCount, u = d.columnCount;
|
|
273
|
-
} else if (
|
|
272
|
+
} else if (r && t) {
|
|
274
273
|
const s = t.getSelectedCell(), d = this.#s(s.row, s.col);
|
|
275
274
|
if (!d) return;
|
|
276
275
|
c = d.text, a = 1, u = 1;
|
|
277
276
|
} else {
|
|
278
|
-
const s = this.#
|
|
277
|
+
const s = this.#o(e);
|
|
279
278
|
if (!s) return;
|
|
280
279
|
c = s.text, a = 1, u = 1;
|
|
281
280
|
}
|
|
@@ -315,29 +314,29 @@ class D extends I {
|
|
|
315
314
|
if (!n) return null;
|
|
316
315
|
const i = this.columns[t];
|
|
317
316
|
if (!i) return null;
|
|
318
|
-
const l = n[i.field],
|
|
319
|
-
let
|
|
317
|
+
const l = n[i.field], o = i.header || i.field;
|
|
318
|
+
let r;
|
|
320
319
|
if (this.config.includeHeaders) {
|
|
321
320
|
const c = l == null ? "" : String(l);
|
|
322
|
-
|
|
321
|
+
r = `${o}: ${c}`;
|
|
323
322
|
} else
|
|
324
|
-
|
|
325
|
-
return { text:
|
|
323
|
+
r = l == null ? "" : String(l);
|
|
324
|
+
return { text: r };
|
|
326
325
|
}
|
|
327
326
|
/**
|
|
328
327
|
* Build text for a rectangular range of cells.
|
|
329
328
|
*/
|
|
330
329
|
#i(e) {
|
|
331
|
-
const { startRow: t, startCol: n, endRow: i, endCol: l } = e,
|
|
332
|
-
`, d = [],
|
|
330
|
+
const { startRow: t, startCol: n, endRow: i, endCol: l } = e, o = Math.min(t, i), r = Math.max(t, i), c = Math.min(n, l), a = Math.max(n, l), u = this.config.delimiter ?? " ", s = this.config.newline ?? `
|
|
331
|
+
`, d = [], f = this.columns.slice(c, a + 1);
|
|
333
332
|
if (this.config.includeHeaders) {
|
|
334
|
-
const g =
|
|
333
|
+
const g = f.map((m) => m.header || m.field);
|
|
335
334
|
d.push(g.join(u));
|
|
336
335
|
}
|
|
337
|
-
for (let g =
|
|
336
|
+
for (let g = o; g <= r; g++) {
|
|
338
337
|
const m = this.rows[g];
|
|
339
338
|
if (!m) continue;
|
|
340
|
-
const S =
|
|
339
|
+
const S = f.map((R) => {
|
|
341
340
|
const w = m[R.field];
|
|
342
341
|
return w == null ? "" : w instanceof Date ? w.toISOString() : String(w);
|
|
343
342
|
});
|
|
@@ -345,7 +344,7 @@ class D extends I {
|
|
|
345
344
|
}
|
|
346
345
|
return {
|
|
347
346
|
text: d.join(s),
|
|
348
|
-
rowCount:
|
|
347
|
+
rowCount: r - o + 1,
|
|
349
348
|
columnCount: a - c + 1
|
|
350
349
|
};
|
|
351
350
|
}
|
|
@@ -353,7 +352,7 @@ class D extends I {
|
|
|
353
352
|
* Build text for a single focused cell from DOM.
|
|
354
353
|
* Used when selection plugin is not available or no rows are selected.
|
|
355
354
|
*/
|
|
356
|
-
#
|
|
355
|
+
#o(e) {
|
|
357
356
|
const t = e.closest("[data-field-cache]");
|
|
358
357
|
if (!t) return null;
|
|
359
358
|
const n = t.dataset.fieldCache;
|
|
@@ -362,16 +361,16 @@ class D extends I {
|
|
|
362
361
|
if (!i) return null;
|
|
363
362
|
const l = parseInt(i, 10);
|
|
364
363
|
if (isNaN(l)) return null;
|
|
365
|
-
const
|
|
366
|
-
if (!
|
|
367
|
-
const
|
|
364
|
+
const o = this.rows[l];
|
|
365
|
+
if (!o) return null;
|
|
366
|
+
const r = o[n], a = this.columns.find((s) => s.field === n)?.header || n;
|
|
368
367
|
let u;
|
|
369
368
|
if (this.config.includeHeaders) {
|
|
370
|
-
const s =
|
|
369
|
+
const s = r == null ? "" : String(r);
|
|
371
370
|
u = `${a}: ${s}`;
|
|
372
371
|
} else
|
|
373
|
-
u =
|
|
374
|
-
return { text: u, field: n, value:
|
|
372
|
+
u = r == null ? "" : String(r);
|
|
373
|
+
return { text: u, field: n, value: r };
|
|
375
374
|
}
|
|
376
375
|
// ===== Public API =====
|
|
377
376
|
/**
|