@toolbox-web/grid 1.6.2 → 1.8.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 +51 -15
- package/all.js +267 -158
- package/all.js.map +1 -1
- package/index.js +866 -722
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +68 -1
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/header.d.ts.map +1 -1
- package/lib/core/plugin/base-plugin.d.ts +182 -1
- package/lib/core/plugin/base-plugin.d.ts.map +1 -1
- package/lib/core/plugin/index.d.ts +1 -1
- package/lib/core/plugin/index.d.ts.map +1 -1
- package/lib/core/plugin/plugin-manager.d.ts +56 -1
- package/lib/core/plugin/plugin-manager.d.ts.map +1 -1
- package/lib/core/plugin/types.d.ts +36 -0
- package/lib/core/plugin/types.d.ts.map +1 -1
- package/lib/core/types.d.ts +1349 -31
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +140 -87
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +64 -7
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/ContextMenuPlugin.d.ts.map +1 -1
- package/lib/plugins/context-menu/index.js +123 -65
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts +6 -1
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +95 -13
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js +91 -34
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts +6 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +192 -123
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +57 -0
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts +7 -2
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/grouping-rows/index.js +142 -60
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +69 -12
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +70 -13
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts +3 -3
- package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts.map +1 -1
- package/lib/plugins/pinned-columns/index.js +106 -36
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +57 -0
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +57 -0
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/print/PrintPlugin.d.ts.map +1 -1
- package/lib/plugins/print/index.js +58 -1
- package/lib/plugins/print/index.js.map +1 -1
- package/lib/plugins/reorder/ReorderPlugin.d.ts.map +1 -1
- package/lib/plugins/reorder/column-drag.d.ts +2 -2
- package/lib/plugins/reorder/index.js +68 -17
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/responsive/ResponsivePlugin.d.ts +6 -1
- package/lib/plugins/responsive/ResponsivePlugin.d.ts.map +1 -1
- package/lib/plugins/responsive/index.js +125 -54
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-reorder/index.js +169 -112
- package/lib/plugins/row-reorder/index.js.map +1 -1
- package/lib/plugins/selection/SelectionPlugin.d.ts +14 -2
- package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
- package/lib/plugins/selection/index.js +84 -7
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +79 -22
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/TreePlugin.d.ts +7 -1
- package/lib/plugins/tree/TreePlugin.d.ts.map +1 -1
- package/lib/plugins/tree/index.js +140 -58
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts +6 -1
- package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts.map +1 -1
- package/lib/plugins/undo-redo/index.js +79 -10
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +57 -0
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/public.d.ts +80 -2
- package/public.d.ts.map +1 -1
- package/umd/grid.all.umd.js +25 -25
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +15 -15
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js +5 -5
- package/umd/plugins/clipboard.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-rows.umd.js +2 -2
- package/umd/plugins/grouping-rows.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/print.umd.js +1 -1
- package/umd/plugins/print.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/responsive.umd.js +1 -1
- package/umd/plugins/responsive.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +2 -2
- 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/undo-redo.umd.js +1 -1
- package/umd/plugins/undo-redo.umd.js.map +1 -1
|
@@ -149,6 +149,63 @@ class C {
|
|
|
149
149
|
const n = new CustomEvent(e, { detail: t, bubbles: !0, cancelable: !0 });
|
|
150
150
|
return this.grid?.dispatchEvent?.(n), n.defaultPrevented;
|
|
151
151
|
}
|
|
152
|
+
// =========================================================================
|
|
153
|
+
// Event Bus - Plugin-to-Plugin Communication
|
|
154
|
+
// =========================================================================
|
|
155
|
+
/**
|
|
156
|
+
* Subscribe to an event from another plugin.
|
|
157
|
+
* The subscription is automatically cleaned up when this plugin is detached.
|
|
158
|
+
*
|
|
159
|
+
* @category Plugin Development
|
|
160
|
+
* @param eventType - The event type to listen for (e.g., 'filter-change')
|
|
161
|
+
* @param callback - The callback to invoke when the event is emitted
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* // In attach() or other initialization
|
|
166
|
+
* this.on('filter-change', (detail) => {
|
|
167
|
+
* console.log('Filter changed:', detail);
|
|
168
|
+
* });
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
on(e, t) {
|
|
172
|
+
this.grid?._pluginManager?.subscribe(this, e, t);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Unsubscribe from a plugin event.
|
|
176
|
+
*
|
|
177
|
+
* @category Plugin Development
|
|
178
|
+
* @param eventType - The event type to stop listening for
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```typescript
|
|
182
|
+
* this.off('filter-change');
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
off(e) {
|
|
186
|
+
this.grid?._pluginManager?.unsubscribe(this, e);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Emit an event to other plugins via the Event Bus.
|
|
190
|
+
* This is for inter-plugin communication only; it does NOT dispatch DOM events.
|
|
191
|
+
* Use `emit()` to dispatch DOM events that external consumers can listen to.
|
|
192
|
+
*
|
|
193
|
+
* @category Plugin Development
|
|
194
|
+
* @param eventType - The event type to emit (should be declared in manifest.events)
|
|
195
|
+
* @param detail - The event payload
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```typescript
|
|
199
|
+
* // Emit to other plugins (not DOM)
|
|
200
|
+
* this.emitPluginEvent('filter-change', { field: 'name', value: 'Alice' });
|
|
201
|
+
*
|
|
202
|
+
* // For DOM events that consumers can addEventListener to:
|
|
203
|
+
* this.emit('filter-change', { field: 'name', value: 'Alice' });
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
emitPluginEvent(e, t) {
|
|
207
|
+
this.grid?._pluginManager?.emitPluginEvent(e, t);
|
|
208
|
+
}
|
|
152
209
|
/**
|
|
153
210
|
* Request a re-render of the grid.
|
|
154
211
|
*/
|
|
@@ -311,45 +368,45 @@ class C {
|
|
|
311
368
|
}
|
|
312
369
|
// #endregion
|
|
313
370
|
}
|
|
314
|
-
function b(
|
|
315
|
-
if (
|
|
316
|
-
if (
|
|
317
|
-
if (typeof
|
|
318
|
-
const t = String(
|
|
371
|
+
function b(o, e = !0) {
|
|
372
|
+
if (o == null) return "";
|
|
373
|
+
if (o instanceof Date) return o.toISOString();
|
|
374
|
+
if (typeof o == "object") return JSON.stringify(o);
|
|
375
|
+
const t = String(o);
|
|
319
376
|
return e && (t.includes(",") || t.includes('"') || t.includes(`
|
|
320
377
|
`) || t.includes("\r")) ? `"${t.replace(/"/g, '""')}"` : t;
|
|
321
378
|
}
|
|
322
|
-
function E(
|
|
379
|
+
function E(o, e, t, n = {}) {
|
|
323
380
|
const c = n.delimiter ?? ",", l = n.newline ?? `
|
|
324
|
-
`,
|
|
381
|
+
`, i = [], r = n.bom ? "\uFEFF" : "";
|
|
325
382
|
if (t.includeHeaders !== !1) {
|
|
326
383
|
const s = e.map((a) => {
|
|
327
384
|
const d = a.header || a.field, u = t.processHeader ? t.processHeader(d, a.field) : d;
|
|
328
385
|
return b(u);
|
|
329
386
|
});
|
|
330
|
-
|
|
387
|
+
i.push(s.join(c));
|
|
331
388
|
}
|
|
332
|
-
for (const s of
|
|
389
|
+
for (const s of o) {
|
|
333
390
|
const a = e.map((d) => {
|
|
334
391
|
let u = s[d.field];
|
|
335
392
|
return t.processCell && (u = t.processCell(u, d.field, s)), b(u);
|
|
336
393
|
});
|
|
337
|
-
|
|
394
|
+
i.push(a.join(c));
|
|
338
395
|
}
|
|
339
|
-
return r +
|
|
396
|
+
return r + i.join(l);
|
|
340
397
|
}
|
|
341
|
-
function h(
|
|
342
|
-
const t = URL.createObjectURL(
|
|
398
|
+
function h(o, e) {
|
|
399
|
+
const t = URL.createObjectURL(o), n = document.createElement("a");
|
|
343
400
|
n.href = t, n.download = e, n.style.display = "none", document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(t);
|
|
344
401
|
}
|
|
345
|
-
function S(
|
|
346
|
-
const t = new Blob([
|
|
402
|
+
function S(o, e) {
|
|
403
|
+
const t = new Blob([o], { type: "text/csv;charset=utf-8;" });
|
|
347
404
|
h(t, e);
|
|
348
405
|
}
|
|
349
|
-
function w(
|
|
350
|
-
return
|
|
406
|
+
function w(o) {
|
|
407
|
+
return o.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
351
408
|
}
|
|
352
|
-
function
|
|
409
|
+
function v(o, e, t) {
|
|
353
410
|
let n = `<?xml version="1.0" encoding="UTF-8"?>
|
|
354
411
|
<?mso-application progid="Excel.Sheet"?>
|
|
355
412
|
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
|
|
@@ -360,19 +417,19 @@ function y(i, e, t) {
|
|
|
360
417
|
n += `
|
|
361
418
|
<Row>`;
|
|
362
419
|
for (const c of e) {
|
|
363
|
-
const l = c.header || c.field,
|
|
364
|
-
n += `<Cell><Data ss:Type="String">${w(
|
|
420
|
+
const l = c.header || c.field, i = t.processHeader ? t.processHeader(l, c.field) : l;
|
|
421
|
+
n += `<Cell><Data ss:Type="String">${w(i)}</Data></Cell>`;
|
|
365
422
|
}
|
|
366
423
|
n += "</Row>";
|
|
367
424
|
}
|
|
368
|
-
for (const c of
|
|
425
|
+
for (const c of o) {
|
|
369
426
|
n += `
|
|
370
427
|
<Row>`;
|
|
371
428
|
for (const l of e) {
|
|
372
|
-
let
|
|
373
|
-
t.processCell && (
|
|
429
|
+
let i = c[l.field];
|
|
430
|
+
t.processCell && (i = t.processCell(i, l.field, c));
|
|
374
431
|
let r = "String", s = "";
|
|
375
|
-
|
|
432
|
+
i == null ? s = "" : typeof i == "number" && !isNaN(i) ? (r = "Number", s = String(i)) : i instanceof Date ? (r = "DateTime", s = i.toISOString()) : s = w(String(i)), n += `<Cell><Data ss:Type="${r}">${s}</Data></Cell>`;
|
|
376
433
|
}
|
|
377
434
|
n += "</Row>";
|
|
378
435
|
}
|
|
@@ -381,8 +438,8 @@ function y(i, e, t) {
|
|
|
381
438
|
</Worksheet>
|
|
382
439
|
</Workbook>`, n;
|
|
383
440
|
}
|
|
384
|
-
function
|
|
385
|
-
const t = e.endsWith(".xls") ? e : `${e}.xls`, n = new Blob([
|
|
441
|
+
function y(o, e) {
|
|
442
|
+
const t = e.endsWith(".xls") ? e : `${e}.xls`, n = new Blob([o], {
|
|
386
443
|
type: "application/vnd.ms-excel;charset=utf-8;"
|
|
387
444
|
});
|
|
388
445
|
h(n, t);
|
|
@@ -419,27 +476,27 @@ class I extends C {
|
|
|
419
476
|
const s = new Set(t.columns);
|
|
420
477
|
l = l.filter((a) => s.has(a.field));
|
|
421
478
|
}
|
|
422
|
-
let
|
|
479
|
+
let i = [...this.rows];
|
|
423
480
|
if (n.onlySelected) {
|
|
424
481
|
const s = this.getSelectionState();
|
|
425
|
-
s?.selected?.size && (
|
|
482
|
+
s?.selected?.size && (i = [...s.selected].sort((d, u) => d - u).map((d) => this.rows[d]).filter(Boolean));
|
|
426
483
|
}
|
|
427
|
-
t?.rowIndices && (
|
|
484
|
+
t?.rowIndices && (i = t.rowIndices.map((s) => this.rows[s]).filter(Boolean)), this.isExportingFlag = !0;
|
|
428
485
|
let r = c.fileName;
|
|
429
486
|
try {
|
|
430
487
|
switch (e) {
|
|
431
488
|
case "csv": {
|
|
432
|
-
const s = E(
|
|
489
|
+
const s = E(i, l, c, { bom: !0 });
|
|
433
490
|
r = r.endsWith(".csv") ? r : `${r}.csv`, S(s, r);
|
|
434
491
|
break;
|
|
435
492
|
}
|
|
436
493
|
case "excel": {
|
|
437
|
-
const s =
|
|
438
|
-
r = r.endsWith(".xls") ? r : `${r}.xls`,
|
|
494
|
+
const s = v(i, l, c);
|
|
495
|
+
r = r.endsWith(".xls") ? r : `${r}.xls`, y(s, r);
|
|
439
496
|
break;
|
|
440
497
|
}
|
|
441
498
|
case "json": {
|
|
442
|
-
const s =
|
|
499
|
+
const s = i.map((u) => {
|
|
443
500
|
const p = {};
|
|
444
501
|
for (const f of l) {
|
|
445
502
|
let g = u[f.field];
|
|
@@ -456,7 +513,7 @@ class I extends C {
|
|
|
456
513
|
this.lastExportInfo = { format: e, timestamp: /* @__PURE__ */ new Date() }, this.emit("export-complete", {
|
|
457
514
|
format: e,
|
|
458
515
|
fileName: r,
|
|
459
|
-
rowCount:
|
|
516
|
+
rowCount: i.length,
|
|
460
517
|
columnCount: l.length
|
|
461
518
|
});
|
|
462
519
|
} finally {
|