@toolbox-web/grid 1.21.1 → 1.22.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 +6 -8
- package/all.js +2 -6850
- package/all.js.map +1 -1
- package/index.js +1 -4352
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +75 -8
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/rows.d.ts.map +1 -1
- package/lib/core/plugin/base-plugin.d.ts +8 -2
- package/lib/core/plugin/base-plugin.d.ts.map +1 -1
- package/lib/core/styles/index.d.ts.map +1 -1
- package/lib/core/types.d.ts +84 -2
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +1 -733
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/clipboard/types.d.ts +5 -0
- package/lib/plugins/clipboard/types.d.ts.map +1 -1
- package/lib/plugins/column-virtualization/index.js +1 -560
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/column-virtualization/types.d.ts +5 -0
- package/lib/plugins/column-virtualization/types.d.ts.map +1 -1
- package/lib/plugins/context-menu/index.js +1 -754
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/context-menu/types.d.ts +5 -0
- package/lib/plugins/context-menu/types.d.ts.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/index.d.ts +1 -1
- package/lib/plugins/editing/index.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +1 -1539
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/editing/types.d.ts +49 -0
- package/lib/plugins/editing/types.d.ts.map +1 -1
- package/lib/plugins/export/index.js +1 -589
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/export/types.d.ts +5 -0
- package/lib/plugins/export/types.d.ts.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
- package/lib/plugins/filtering/filter-model.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +1 -1283
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/filtering/types.d.ts +7 -2
- package/lib/plugins/filtering/types.d.ts.map +1 -1
- package/lib/plugins/grouping-columns/index.js +1 -726
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-columns/types.d.ts +3 -0
- package/lib/plugins/grouping-columns/types.d.ts.map +1 -1
- package/lib/plugins/grouping-rows/index.js +2 -905
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/grouping-rows/types.d.ts +5 -0
- package/lib/plugins/grouping-rows/types.d.ts.map +1 -1
- package/lib/plugins/master-detail/index.js +1 -950
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/master-detail/types.d.ts +5 -0
- package/lib/plugins/master-detail/types.d.ts.map +1 -1
- package/lib/plugins/multi-sort/index.js +1 -553
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/multi-sort/types.d.ts +5 -0
- package/lib/plugins/multi-sort/types.d.ts.map +1 -1
- package/lib/plugins/pinned-columns/index.js +1 -688
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-columns/types.d.ts +3 -0
- package/lib/plugins/pinned-columns/types.d.ts.map +1 -1
- package/lib/plugins/pinned-rows/index.js +1 -704
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pinned-rows/types.d.ts +5 -0
- package/lib/plugins/pinned-rows/types.d.ts.map +1 -1
- package/lib/plugins/pivot/index.js +1 -1191
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/pivot/types.d.ts +5 -0
- package/lib/plugins/pivot/types.d.ts.map +1 -1
- package/lib/plugins/print/index.js +1 -691
- package/lib/plugins/print/index.js.map +1 -1
- package/lib/plugins/print/types.d.ts +3 -0
- package/lib/plugins/print/types.d.ts.map +1 -1
- package/lib/plugins/reorder/index.js +1 -703
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/reorder/types.d.ts +5 -0
- package/lib/plugins/reorder/types.d.ts.map +1 -1
- package/lib/plugins/responsive/index.js +1 -971
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/responsive/types.d.ts +5 -0
- package/lib/plugins/responsive/types.d.ts.map +1 -1
- package/lib/plugins/row-reorder/index.js +1 -728
- package/lib/plugins/row-reorder/index.js.map +1 -1
- package/lib/plugins/row-reorder/types.d.ts +5 -0
- package/lib/plugins/row-reorder/types.d.ts.map +1 -1
- package/lib/plugins/selection/index.js +1 -1071
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/selection/types.d.ts +3 -0
- package/lib/plugins/selection/types.d.ts.map +1 -1
- package/lib/plugins/server-side/index.js +1 -521
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/server-side/types.d.ts +5 -0
- package/lib/plugins/server-side/types.d.ts.map +1 -1
- package/lib/plugins/tree/index.js +1 -686
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/tree/types.d.ts +5 -0
- package/lib/plugins/tree/types.d.ts.map +1 -1
- package/lib/plugins/undo-redo/index.js +1 -584
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/undo-redo/types.d.ts +5 -0
- package/lib/plugins/undo-redo/types.d.ts.map +1 -1
- package/lib/plugins/visibility/index.js +1 -792
- package/lib/plugins/visibility/index.js.map +1 -1
- package/lib/plugins/visibility/types.d.ts +5 -0
- package/lib/plugins/visibility/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +1 -186
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +1 -90
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js +1 -6
- 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 +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/export.umd.js +1 -13
- package/umd/plugins/export.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 -4
- 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-columns.umd.js +1 -1
- package/umd/plugins/pinned-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/print.umd.js +1 -75
- 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/row-reorder.umd.js +1 -1
- package/umd/plugins/row-reorder.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +1 -3
- 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
- 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 -1
- package/umd/plugins/visibility.umd.js.map +1 -1
|
@@ -125,6 +125,27 @@ export interface EditOpenDetail<TRow = unknown> {
|
|
|
125
125
|
/** Row object reference. */
|
|
126
126
|
row: TRow;
|
|
127
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Detail payload for the `before-edit-close` event.
|
|
130
|
+
*
|
|
131
|
+
* Fired **synchronously** just before the grid clears editing state and
|
|
132
|
+
* destroys editor DOM. At this point the commit callback is still active,
|
|
133
|
+
* so framework adapter editors (Angular/React/Vue) can flush pending values
|
|
134
|
+
* via their `commit()` callback.
|
|
135
|
+
*
|
|
136
|
+
* Only fires on the **commit** path (not on revert/cancel) and only in
|
|
137
|
+
* `mode: 'row'` — never in `mode: 'grid'`.
|
|
138
|
+
*
|
|
139
|
+
* @category Events
|
|
140
|
+
*/
|
|
141
|
+
export interface BeforeEditCloseDetail<TRow = unknown> {
|
|
142
|
+
/** Index of the row about to leave edit mode. */
|
|
143
|
+
rowIndex: number;
|
|
144
|
+
/** Stable row identifier (from getRowId). */
|
|
145
|
+
rowId: string;
|
|
146
|
+
/** Row object reference (current state — mutations are still accepted). */
|
|
147
|
+
row: TRow;
|
|
148
|
+
}
|
|
128
149
|
/**
|
|
129
150
|
* Detail payload for the `edit-close` event.
|
|
130
151
|
*
|
|
@@ -247,9 +268,14 @@ declare module '../../core/types' {
|
|
|
247
268
|
'changed-rows-reset': ChangedRowsResetDetail<TRow>;
|
|
248
269
|
/** Fired when a row enters edit mode (row mode only, not grid mode). */
|
|
249
270
|
'edit-open': EditOpenDetail<TRow>;
|
|
271
|
+
/** Fired synchronously before editing state is cleared. Commit callbacks are still active. */
|
|
272
|
+
'before-edit-close': BeforeEditCloseDetail<TRow>;
|
|
250
273
|
/** Fired when a row leaves edit mode, whether committed or reverted (row mode only). */
|
|
251
274
|
'edit-close': EditCloseDetail<TRow>;
|
|
252
275
|
}
|
|
276
|
+
interface PluginNameMap {
|
|
277
|
+
editing: import('./EditingPlugin').EditingPlugin;
|
|
278
|
+
}
|
|
253
279
|
}
|
|
254
280
|
/**
|
|
255
281
|
* Configuration options for EditingPlugin.
|
|
@@ -314,6 +340,29 @@ export interface EditingConfig {
|
|
|
314
340
|
* ```
|
|
315
341
|
*/
|
|
316
342
|
onBeforeEditClose?: (event: MouseEvent | KeyboardEvent) => boolean;
|
|
343
|
+
/**
|
|
344
|
+
* When `true`, prevents focus from leaving the grid (or its registered
|
|
345
|
+
* external focus containers) while a row is in edit mode.
|
|
346
|
+
*
|
|
347
|
+
* If the user tabs or clicks outside the grid during an active edit,
|
|
348
|
+
* focus is returned to the editing cell. This prevents accidental
|
|
349
|
+
* data loss from focus leaving the grid unexpectedly.
|
|
350
|
+
*
|
|
351
|
+
* Elements registered via `grid.registerExternalFocusContainer()` are
|
|
352
|
+
* considered "inside" the grid for focus trap purposes, so overlays
|
|
353
|
+
* (datepickers, dropdowns) continue to work normally.
|
|
354
|
+
*
|
|
355
|
+
* @default false
|
|
356
|
+
*
|
|
357
|
+
* @example
|
|
358
|
+
* ```typescript
|
|
359
|
+
* new EditingPlugin({
|
|
360
|
+
* focusTrap: true,
|
|
361
|
+
* editOn: 'dblclick',
|
|
362
|
+
* })
|
|
363
|
+
* ```
|
|
364
|
+
*/
|
|
365
|
+
focusTrap?: boolean;
|
|
317
366
|
}
|
|
318
367
|
/**
|
|
319
368
|
* Context passed to editor factory functions.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/editing/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAM5D;;;;;;;;;;GAUG;AACH,MAAM,WAAW,gBAAgB,CAAC,IAAI,GAAG,OAAO;IAC9C,+DAA+D;IAC/D,GAAG,EAAE,IAAI,CAAC;IACV,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,QAAQ,EAAE,OAAO,CAAC;IAClB,8BAA8B;IAC9B,K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AAC;IACb,kCAAkC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC,2CAA2C;IAC3C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,+CAA+C;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GACpB,kBAAkB,GAClB,gBAAgB,GAChB,gBAAgB,GAChB,kBAAkB,GAClB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC"}
|
|
@@ -1,590 +1,2 @@
|
|
|
1
|
-
const
|
|
2
|
-
expand: "▶",
|
|
3
|
-
collapse: "▼",
|
|
4
|
-
sortAsc: "▲",
|
|
5
|
-
sortDesc: "▼",
|
|
6
|
-
sortNone: "⇅",
|
|
7
|
-
submenuArrow: "▶",
|
|
8
|
-
dragHandle: "⋮⋮",
|
|
9
|
-
toolPanel: "☰",
|
|
10
|
-
filter: m,
|
|
11
|
-
filterActive: m,
|
|
12
|
-
print: "🖨️"
|
|
13
|
-
};
|
|
14
|
-
class E {
|
|
15
|
-
/**
|
|
16
|
-
* Plugin dependencies - declare other plugins this one requires.
|
|
17
|
-
*
|
|
18
|
-
* Dependencies are validated when the plugin is attached.
|
|
19
|
-
* Required dependencies throw an error if missing.
|
|
20
|
-
* Optional dependencies log an info message if missing.
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```typescript
|
|
24
|
-
* static readonly dependencies: PluginDependency[] = [
|
|
25
|
-
* { name: 'editing', required: true, reason: 'Tracks cell edits for undo/redo' },
|
|
26
|
-
* { name: 'selection', required: false, reason: 'Enables selection-based undo' },
|
|
27
|
-
* ];
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
static dependencies;
|
|
31
|
-
/**
|
|
32
|
-
* Plugin manifest - declares owned properties, config rules, and hook priorities.
|
|
33
|
-
*
|
|
34
|
-
* This is read by the configuration validator to:
|
|
35
|
-
* - Validate that required plugins are loaded when their properties are used
|
|
36
|
-
* - Execute configRules to detect invalid/conflicting settings
|
|
37
|
-
* - Order hook execution based on priority
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```typescript
|
|
41
|
-
* static override readonly manifest: PluginManifest<MyConfig> = {
|
|
42
|
-
* ownedProperties: [
|
|
43
|
-
* { property: 'myProp', level: 'column', description: 'the "myProp" column property' },
|
|
44
|
-
* ],
|
|
45
|
-
* configRules: [
|
|
46
|
-
* { id: 'myPlugin/conflict', severity: 'warn', message: '...', check: (c) => c.a && c.b },
|
|
47
|
-
* ],
|
|
48
|
-
* };
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
|
-
static manifest;
|
|
53
|
-
/**
|
|
54
|
-
* Plugin version - defaults to grid version for built-in plugins.
|
|
55
|
-
* Third-party plugins can override with their own semver.
|
|
56
|
-
*/
|
|
57
|
-
version = typeof __GRID_VERSION__ < "u" ? __GRID_VERSION__ : "dev";
|
|
58
|
-
/** CSS styles to inject into the grid's shadow DOM */
|
|
59
|
-
styles;
|
|
60
|
-
/** Custom cell renderers keyed by type name */
|
|
61
|
-
cellRenderers;
|
|
62
|
-
/** Custom header renderers keyed by type name */
|
|
63
|
-
headerRenderers;
|
|
64
|
-
/** Custom cell editors keyed by type name */
|
|
65
|
-
cellEditors;
|
|
66
|
-
/** The grid instance this plugin is attached to */
|
|
67
|
-
grid;
|
|
68
|
-
/** Plugin configuration - merged with defaults in attach() */
|
|
69
|
-
config;
|
|
70
|
-
/** User-provided configuration from constructor */
|
|
71
|
-
userConfig;
|
|
72
|
-
/**
|
|
73
|
-
* Plugin-level AbortController for event listener cleanup.
|
|
74
|
-
* Created fresh in attach(), aborted in detach().
|
|
75
|
-
* This ensures event listeners are properly cleaned up when plugins are re-attached.
|
|
76
|
-
*/
|
|
77
|
-
#e;
|
|
78
|
-
/**
|
|
79
|
-
* Default configuration - subclasses should override this getter.
|
|
80
|
-
* Note: This must be a getter (not property initializer) for proper inheritance
|
|
81
|
-
* since property initializers run after parent constructor.
|
|
82
|
-
*/
|
|
83
|
-
get defaultConfig() {
|
|
84
|
-
return {};
|
|
85
|
-
}
|
|
86
|
-
constructor(e = {}) {
|
|
87
|
-
this.userConfig = e;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Called when the plugin is attached to a grid.
|
|
91
|
-
* Override to set up event listeners, initialize state, etc.
|
|
92
|
-
*
|
|
93
|
-
* @example
|
|
94
|
-
* ```ts
|
|
95
|
-
* attach(grid: GridElement): void {
|
|
96
|
-
* super.attach(grid);
|
|
97
|
-
* // Set up document-level listeners with auto-cleanup
|
|
98
|
-
* document.addEventListener('keydown', this.handleEscape, {
|
|
99
|
-
* signal: this.disconnectSignal
|
|
100
|
-
* });
|
|
101
|
-
* }
|
|
102
|
-
* ```
|
|
103
|
-
*/
|
|
104
|
-
attach(e) {
|
|
105
|
-
this.#e?.abort(), this.#e = new AbortController(), this.grid = e, this.config = { ...this.defaultConfig, ...this.userConfig };
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Called when the plugin is detached from a grid.
|
|
109
|
-
* Override to clean up event listeners, timers, etc.
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* ```ts
|
|
113
|
-
* detach(): void {
|
|
114
|
-
* // Clean up any state not handled by disconnectSignal
|
|
115
|
-
* this.selectedRows.clear();
|
|
116
|
-
* this.cache = null;
|
|
117
|
-
* }
|
|
118
|
-
* ```
|
|
119
|
-
*/
|
|
120
|
-
detach() {
|
|
121
|
-
this.#e?.abort(), this.#e = void 0;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Get another plugin instance from the same grid.
|
|
125
|
-
* Use for inter-plugin communication.
|
|
126
|
-
*
|
|
127
|
-
* @example
|
|
128
|
-
* ```ts
|
|
129
|
-
* const selection = this.getPlugin(SelectionPlugin);
|
|
130
|
-
* if (selection) {
|
|
131
|
-
* const selectedRows = selection.getSelectedRows();
|
|
132
|
-
* }
|
|
133
|
-
* ```
|
|
134
|
-
*/
|
|
135
|
-
getPlugin(e) {
|
|
136
|
-
return this.grid?.getPlugin(e);
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Emit a custom event from the grid.
|
|
140
|
-
*/
|
|
141
|
-
emit(e, t) {
|
|
142
|
-
this.grid?.dispatchEvent?.(new CustomEvent(e, { detail: t, bubbles: !0 }));
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Emit a cancelable custom event from the grid.
|
|
146
|
-
* @returns `true` if the event was cancelled (preventDefault called), `false` otherwise
|
|
147
|
-
*/
|
|
148
|
-
emitCancelable(e, t) {
|
|
149
|
-
const n = new CustomEvent(e, { detail: t, bubbles: !0, cancelable: !0 });
|
|
150
|
-
return this.grid?.dispatchEvent?.(n), n.defaultPrevented;
|
|
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
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Request a re-render of the grid.
|
|
211
|
-
* Uses ROWS phase - does NOT trigger processColumns hooks.
|
|
212
|
-
*/
|
|
213
|
-
requestRender() {
|
|
214
|
-
this.grid?.requestRender?.();
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Request a columns re-render of the grid.
|
|
218
|
-
* Uses COLUMNS phase - triggers processColumns hooks.
|
|
219
|
-
* Use this when your plugin needs to reprocess column configuration.
|
|
220
|
-
*/
|
|
221
|
-
requestColumnsRender() {
|
|
222
|
-
this.grid?.requestColumnsRender?.();
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Request a re-render and restore focus styling afterward.
|
|
226
|
-
* Use this when a plugin action (like expand/collapse) triggers a render
|
|
227
|
-
* but needs to maintain keyboard navigation focus.
|
|
228
|
-
*/
|
|
229
|
-
requestRenderWithFocus() {
|
|
230
|
-
this.grid?.requestRenderWithFocus?.();
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Request a lightweight style update without rebuilding DOM.
|
|
234
|
-
* Use this instead of requestRender() when only CSS classes need updating.
|
|
235
|
-
*/
|
|
236
|
-
requestAfterRender() {
|
|
237
|
-
this.grid?.requestAfterRender?.();
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Get the current rows from the grid.
|
|
241
|
-
*/
|
|
242
|
-
get rows() {
|
|
243
|
-
return this.grid?.rows ?? [];
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Get the original unfiltered/unprocessed rows from the grid.
|
|
247
|
-
* Use this when you need all source data regardless of active filters.
|
|
248
|
-
*/
|
|
249
|
-
get sourceRows() {
|
|
250
|
-
return this.grid?.sourceRows ?? [];
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Get the current columns from the grid.
|
|
254
|
-
*/
|
|
255
|
-
get columns() {
|
|
256
|
-
return this.grid?.columns ?? [];
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* Get only visible columns from the grid (excludes hidden).
|
|
260
|
-
* Use this for rendering that needs to match the grid template.
|
|
261
|
-
*/
|
|
262
|
-
get visibleColumns() {
|
|
263
|
-
return this.grid?._visibleColumns ?? [];
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Get the grid as an HTMLElement for direct DOM operations.
|
|
267
|
-
* Use sparingly - prefer the typed GridElementRef API when possible.
|
|
268
|
-
*
|
|
269
|
-
* @example
|
|
270
|
-
* ```ts
|
|
271
|
-
* const width = this.gridElement.clientWidth;
|
|
272
|
-
* this.gridElement.classList.add('my-plugin-active');
|
|
273
|
-
* ```
|
|
274
|
-
*/
|
|
275
|
-
get gridElement() {
|
|
276
|
-
return this.grid;
|
|
277
|
-
}
|
|
278
|
-
/**
|
|
279
|
-
* Get the disconnect signal for event listener cleanup.
|
|
280
|
-
* This signal is aborted when the grid disconnects from the DOM.
|
|
281
|
-
* Use this when adding event listeners that should be cleaned up automatically.
|
|
282
|
-
*
|
|
283
|
-
* Best for:
|
|
284
|
-
* - Document/window-level listeners added in attach()
|
|
285
|
-
* - Listeners on the grid element itself
|
|
286
|
-
* - Any listener that should persist across renders
|
|
287
|
-
*
|
|
288
|
-
* Not needed for:
|
|
289
|
-
* - Listeners on elements created in afterRender() (removed with element)
|
|
290
|
-
*
|
|
291
|
-
* @example
|
|
292
|
-
* element.addEventListener('click', handler, { signal: this.disconnectSignal });
|
|
293
|
-
* document.addEventListener('keydown', handler, { signal: this.disconnectSignal });
|
|
294
|
-
*/
|
|
295
|
-
get disconnectSignal() {
|
|
296
|
-
return this.#e?.signal ?? this.grid?.disconnectSignal;
|
|
297
|
-
}
|
|
298
|
-
/**
|
|
299
|
-
* Get the grid-level icons configuration.
|
|
300
|
-
* Returns merged icons (user config + defaults).
|
|
301
|
-
*/
|
|
302
|
-
get gridIcons() {
|
|
303
|
-
const e = this.grid?.gridConfig?.icons ?? {};
|
|
304
|
-
return { ...x, ...e };
|
|
305
|
-
}
|
|
306
|
-
// #region Animation Helpers
|
|
307
|
-
/**
|
|
308
|
-
* Check if animations are enabled at the grid level.
|
|
309
|
-
* Respects gridConfig.animation.mode and the CSS variable set by the grid.
|
|
310
|
-
*
|
|
311
|
-
* Plugins should use this to skip animations when:
|
|
312
|
-
* - Animation mode is 'off' or `false`
|
|
313
|
-
* - User prefers reduced motion and mode is 'reduced-motion' (default)
|
|
314
|
-
*
|
|
315
|
-
* @example
|
|
316
|
-
* ```ts
|
|
317
|
-
* private get animationStyle(): 'slide' | 'fade' | false {
|
|
318
|
-
* if (!this.isAnimationEnabled) return false;
|
|
319
|
-
* return this.config.animation ?? 'slide';
|
|
320
|
-
* }
|
|
321
|
-
* ```
|
|
322
|
-
*/
|
|
323
|
-
get isAnimationEnabled() {
|
|
324
|
-
const e = this.grid?.effectiveConfig?.animation?.mode ?? "reduced-motion";
|
|
325
|
-
if (e === !1 || e === "off") return !1;
|
|
326
|
-
if (e === !0 || e === "on") return !0;
|
|
327
|
-
const t = this.gridElement;
|
|
328
|
-
return t ? getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim() !== "0" : !0;
|
|
329
|
-
}
|
|
330
|
-
/**
|
|
331
|
-
* Get the animation duration in milliseconds from CSS variable.
|
|
332
|
-
* Falls back to 200ms if not set.
|
|
333
|
-
*
|
|
334
|
-
* Plugins can use this for their animation timing to stay consistent
|
|
335
|
-
* with the grid-level animation.duration setting.
|
|
336
|
-
*
|
|
337
|
-
* @example
|
|
338
|
-
* ```ts
|
|
339
|
-
* element.animate(keyframes, { duration: this.animationDuration });
|
|
340
|
-
* ```
|
|
341
|
-
*/
|
|
342
|
-
get animationDuration() {
|
|
343
|
-
const e = this.gridElement;
|
|
344
|
-
if (e) {
|
|
345
|
-
const t = getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(), n = parseInt(t, 10);
|
|
346
|
-
if (!isNaN(n)) return n;
|
|
347
|
-
}
|
|
348
|
-
return 200;
|
|
349
|
-
}
|
|
350
|
-
// #endregion
|
|
351
|
-
/**
|
|
352
|
-
* Resolve an icon value to string or HTMLElement.
|
|
353
|
-
* Checks plugin config first, then grid-level icons, then defaults.
|
|
354
|
-
*
|
|
355
|
-
* @param iconKey - The icon key in GridIcons (e.g., 'expand', 'collapse')
|
|
356
|
-
* @param pluginOverride - Optional plugin-level override
|
|
357
|
-
* @returns The resolved icon value
|
|
358
|
-
*/
|
|
359
|
-
resolveIcon(e, t) {
|
|
360
|
-
return t !== void 0 ? t : this.gridIcons[e];
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* Set an icon value on an element.
|
|
364
|
-
* Handles both string (text/HTML) and HTMLElement values.
|
|
365
|
-
*
|
|
366
|
-
* @param element - The element to set the icon on
|
|
367
|
-
* @param icon - The icon value (string or HTMLElement)
|
|
368
|
-
*/
|
|
369
|
-
setIcon(e, t) {
|
|
370
|
-
typeof t == "string" ? e.innerHTML = t : t instanceof HTMLElement && (e.innerHTML = "", e.appendChild(t.cloneNode(!0)));
|
|
371
|
-
}
|
|
372
|
-
/**
|
|
373
|
-
* Log a warning message.
|
|
374
|
-
*/
|
|
375
|
-
warn(e) {
|
|
376
|
-
console.warn(`[tbw-grid:${this.name}] ${e}`);
|
|
377
|
-
}
|
|
378
|
-
// #endregion
|
|
379
|
-
}
|
|
380
|
-
function v(s, e, t = !0) {
|
|
381
|
-
let n = s;
|
|
382
|
-
if (t && (n = n.filter((o) => !o.hidden && !o.field.startsWith("__") && o.meta?.utility !== !0)), e?.length) {
|
|
383
|
-
const o = new Set(e);
|
|
384
|
-
n = n.filter((c) => o.has(c.field));
|
|
385
|
-
}
|
|
386
|
-
return n;
|
|
387
|
-
}
|
|
388
|
-
function b(s, e) {
|
|
389
|
-
return e?.length ? [...e].sort((t, n) => t - n).map((t) => s[t]).filter((t) => t != null) : s;
|
|
390
|
-
}
|
|
391
|
-
function C(s, e = !0) {
|
|
392
|
-
if (s == null) return "";
|
|
393
|
-
if (s instanceof Date) return s.toISOString();
|
|
394
|
-
if (typeof s == "object") return JSON.stringify(s);
|
|
395
|
-
const t = String(s);
|
|
396
|
-
return e && (t.includes(",") || t.includes('"') || t.includes(`
|
|
397
|
-
`) || t.includes("\r")) ? `"${t.replace(/"/g, '""')}"` : t;
|
|
398
|
-
}
|
|
399
|
-
function S(s, e, t, n = {}) {
|
|
400
|
-
const o = n.delimiter ?? ",", c = n.newline ?? `
|
|
401
|
-
`, r = [], i = n.bom ? "\uFEFF" : "";
|
|
402
|
-
if (t.includeHeaders !== !1) {
|
|
403
|
-
const l = e.map((u) => {
|
|
404
|
-
const a = u.header || u.field, d = t.processHeader ? t.processHeader(a, u.field) : a;
|
|
405
|
-
return C(d);
|
|
406
|
-
});
|
|
407
|
-
r.push(l.join(o));
|
|
408
|
-
}
|
|
409
|
-
for (const l of s) {
|
|
410
|
-
const u = e.map((a) => {
|
|
411
|
-
let d = l[a.field];
|
|
412
|
-
return t.processCell && (d = t.processCell(d, a.field, l)), C(d);
|
|
413
|
-
});
|
|
414
|
-
r.push(u.join(o));
|
|
415
|
-
}
|
|
416
|
-
return i + r.join(c);
|
|
417
|
-
}
|
|
418
|
-
function h(s, e) {
|
|
419
|
-
const t = URL.createObjectURL(s), n = document.createElement("a");
|
|
420
|
-
n.href = t, n.download = e, n.style.display = "none", document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(t);
|
|
421
|
-
}
|
|
422
|
-
function y(s, e) {
|
|
423
|
-
const t = new Blob([s], { type: "text/csv;charset=utf-8;" });
|
|
424
|
-
h(t, e);
|
|
425
|
-
}
|
|
426
|
-
function w(s) {
|
|
427
|
-
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
428
|
-
}
|
|
429
|
-
function R(s, e, t) {
|
|
430
|
-
let n = `<?xml version="1.0" encoding="UTF-8"?>
|
|
431
|
-
<?mso-application progid="Excel.Sheet"?>
|
|
432
|
-
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
|
|
433
|
-
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
|
|
434
|
-
<Worksheet ss:Name="Sheet1">
|
|
435
|
-
<Table>`;
|
|
436
|
-
if (t.includeHeaders !== !1) {
|
|
437
|
-
n += `
|
|
438
|
-
<Row>`;
|
|
439
|
-
for (const o of e) {
|
|
440
|
-
const c = o.header || o.field, r = t.processHeader ? t.processHeader(c, o.field) : c;
|
|
441
|
-
n += `<Cell><Data ss:Type="String">${w(r)}</Data></Cell>`;
|
|
442
|
-
}
|
|
443
|
-
n += "</Row>";
|
|
444
|
-
}
|
|
445
|
-
for (const o of s) {
|
|
446
|
-
n += `
|
|
447
|
-
<Row>`;
|
|
448
|
-
for (const c of e) {
|
|
449
|
-
let r = o[c.field];
|
|
450
|
-
t.processCell && (r = t.processCell(r, c.field, o));
|
|
451
|
-
let i = "String", l = "";
|
|
452
|
-
r == null ? l = "" : typeof r == "number" && !isNaN(r) ? (i = "Number", l = String(r)) : r instanceof Date ? (i = "DateTime", l = r.toISOString()) : l = w(String(r)), n += `<Cell><Data ss:Type="${i}">${l}</Data></Cell>`;
|
|
453
|
-
}
|
|
454
|
-
n += "</Row>";
|
|
455
|
-
}
|
|
456
|
-
return n += `
|
|
457
|
-
</Table>
|
|
458
|
-
</Worksheet>
|
|
459
|
-
</Workbook>`, n;
|
|
460
|
-
}
|
|
461
|
-
function I(s, e) {
|
|
462
|
-
const t = e.endsWith(".xls") ? e : `${e}.xls`, n = new Blob([s], {
|
|
463
|
-
type: "application/vnd.ms-excel;charset=utf-8;"
|
|
464
|
-
});
|
|
465
|
-
h(n, t);
|
|
466
|
-
}
|
|
467
|
-
class _ extends E {
|
|
468
|
-
/** @internal */
|
|
469
|
-
name = "export";
|
|
470
|
-
/** @internal */
|
|
471
|
-
get defaultConfig() {
|
|
472
|
-
return {
|
|
473
|
-
fileName: "export",
|
|
474
|
-
includeHeaders: !0,
|
|
475
|
-
onlyVisible: !0,
|
|
476
|
-
onlySelected: !1
|
|
477
|
-
};
|
|
478
|
-
}
|
|
479
|
-
// #region Internal State
|
|
480
|
-
isExportingFlag = !1;
|
|
481
|
-
lastExportInfo = null;
|
|
482
|
-
// #endregion
|
|
483
|
-
// #region Private Methods
|
|
484
|
-
performExport(e, t) {
|
|
485
|
-
const n = this.config, o = {
|
|
486
|
-
format: e,
|
|
487
|
-
fileName: t?.fileName ?? n.fileName ?? "export",
|
|
488
|
-
includeHeaders: t?.includeHeaders ?? n.includeHeaders,
|
|
489
|
-
processCell: t?.processCell,
|
|
490
|
-
processHeader: t?.processHeader,
|
|
491
|
-
columns: t?.columns,
|
|
492
|
-
rowIndices: t?.rowIndices
|
|
493
|
-
}, c = v(this.columns, t?.columns, n.onlyVisible);
|
|
494
|
-
let r;
|
|
495
|
-
if (t?.rowIndices)
|
|
496
|
-
r = b(this.rows, t.rowIndices);
|
|
497
|
-
else if (n.onlySelected) {
|
|
498
|
-
const l = this.getSelectionState();
|
|
499
|
-
l?.selected?.size ? r = b(this.rows, [...l.selected]) : r = [...this.rows];
|
|
500
|
-
} else
|
|
501
|
-
r = [...this.rows];
|
|
502
|
-
this.isExportingFlag = !0;
|
|
503
|
-
let i = o.fileName;
|
|
504
|
-
try {
|
|
505
|
-
switch (e) {
|
|
506
|
-
case "csv": {
|
|
507
|
-
const l = S(r, c, o, { bom: !0 });
|
|
508
|
-
i = i.endsWith(".csv") ? i : `${i}.csv`, y(l, i);
|
|
509
|
-
break;
|
|
510
|
-
}
|
|
511
|
-
case "excel": {
|
|
512
|
-
const l = R(r, c, o);
|
|
513
|
-
i = i.endsWith(".xls") ? i : `${i}.xls`, I(l, i);
|
|
514
|
-
break;
|
|
515
|
-
}
|
|
516
|
-
case "json": {
|
|
517
|
-
const l = r.map((d) => {
|
|
518
|
-
const p = {};
|
|
519
|
-
for (const f of c) {
|
|
520
|
-
let g = d[f.field];
|
|
521
|
-
o.processCell && (g = o.processCell(g, f.field, d)), p[f.field] = g;
|
|
522
|
-
}
|
|
523
|
-
return p;
|
|
524
|
-
}), u = JSON.stringify(l, null, 2);
|
|
525
|
-
i = i.endsWith(".json") ? i : `${i}.json`;
|
|
526
|
-
const a = new Blob([u], { type: "application/json" });
|
|
527
|
-
h(a, i);
|
|
528
|
-
break;
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
this.lastExportInfo = { format: e, timestamp: /* @__PURE__ */ new Date() }, this.emit("export-complete", {
|
|
532
|
-
format: e,
|
|
533
|
-
fileName: i,
|
|
534
|
-
rowCount: r.length,
|
|
535
|
-
columnCount: c.length
|
|
536
|
-
});
|
|
537
|
-
} finally {
|
|
538
|
-
this.isExportingFlag = !1;
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
getSelectionState() {
|
|
542
|
-
try {
|
|
543
|
-
return this.grid?.getPluginState?.("selection") ?? null;
|
|
544
|
-
} catch {
|
|
545
|
-
return null;
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
// #endregion
|
|
549
|
-
// #region Public API
|
|
550
|
-
/**
|
|
551
|
-
* Export data to CSV format.
|
|
552
|
-
* @param params - Optional export parameters
|
|
553
|
-
*/
|
|
554
|
-
exportCsv(e) {
|
|
555
|
-
this.performExport("csv", e);
|
|
556
|
-
}
|
|
557
|
-
/**
|
|
558
|
-
* Export data to Excel format (XML Spreadsheet).
|
|
559
|
-
* @param params - Optional export parameters
|
|
560
|
-
*/
|
|
561
|
-
exportExcel(e) {
|
|
562
|
-
this.performExport("excel", e);
|
|
563
|
-
}
|
|
564
|
-
/**
|
|
565
|
-
* Export data to JSON format.
|
|
566
|
-
* @param params - Optional export parameters
|
|
567
|
-
*/
|
|
568
|
-
exportJson(e) {
|
|
569
|
-
this.performExport("json", e);
|
|
570
|
-
}
|
|
571
|
-
/**
|
|
572
|
-
* Check if an export is currently in progress.
|
|
573
|
-
* @returns Whether export is in progress
|
|
574
|
-
*/
|
|
575
|
-
isExporting() {
|
|
576
|
-
return this.isExportingFlag;
|
|
577
|
-
}
|
|
578
|
-
/**
|
|
579
|
-
* Get information about the last export.
|
|
580
|
-
* @returns Export info or null if no export has occurred
|
|
581
|
-
*/
|
|
582
|
-
getLastExport() {
|
|
583
|
-
return this.lastExportInfo;
|
|
584
|
-
}
|
|
585
|
-
// #endregion
|
|
586
|
-
}
|
|
587
|
-
export {
|
|
588
|
-
_ as ExportPlugin
|
|
589
|
-
};
|
|
1
|
+
const e='<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>',t={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:e,filterActive:e,print:"🖨️"};class n{static dependencies;static manifest;version="undefined"!=typeof __GRID_VERSION__?__GRID_VERSION__:"dev";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#e;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}attach(e){this.#e?.abort(),this.#e=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#e?.abort(),this.#e=void 0}getPlugin(e){return this.grid?.getPlugin(e)}emit(e,t){this.grid?.dispatchEvent?.(new CustomEvent(e,{detail:t,bubbles:!0}))}emitCancelable(e,t){const n=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(n),n.defaultPrevented}on(e,t){this.grid?._pluginManager?.subscribe(this,e,t)}off(e){this.grid?._pluginManager?.unsubscribe(this,e)}emitPluginEvent(e,t){this.grid?._pluginManager?.emitPluginEvent(e,t)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid}get disconnectSignal(){return this.#e?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...t,...e}}get isAnimationEnabled(){const e=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===e||"off"===e)return!1;if(!0===e||"on"===e)return!0;const t=this.gridElement;if(t){return"0"!==getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim()}return!0}get animationDuration(){const e=this.gridElement;if(e){const t=getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),n=parseInt(t,10);if(!isNaN(n))return n}return 200}resolveIcon(e,t){return void 0!==t?t:this.gridIcons[e]}setIcon(e,t){"string"==typeof t?e.innerHTML=t:t instanceof HTMLElement&&(e.innerHTML="",e.appendChild(t.cloneNode(!0)))}warn(e){console.warn(`[tbw-grid:${this.name}] ${e}`)}}function r(e,t){return t?.length?[...t].sort((e,t)=>e-t).map(t=>e[t]).filter(e=>null!=e):e}function s(e,t=!0){if(null==e)return"";if(e instanceof Date)return e.toISOString();if("object"==typeof e)return JSON.stringify(e);const n=String(e);return t&&(n.includes(",")||n.includes('"')||n.includes("\n")||n.includes("\r"))?`"${n.replace(/"/g,'""')}"`:n}function i(e,t){const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}function o(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}class l extends n{name="export";get defaultConfig(){return{fileName:"export",includeHeaders:!0,onlyVisible:!0,onlySelected:!1}}isExportingFlag=!1;lastExportInfo=null;performExport(e,t){const n=this.config,l={format:e,fileName:t?.fileName??n.fileName??"export",includeHeaders:t?.includeHeaders??n.includeHeaders,processCell:t?.processCell,processHeader:t?.processHeader,columns:t?.columns,rowIndices:t?.rowIndices},c=function(e,t,n=!0){let r=e;if(n&&(r=r.filter(e=>!e.hidden&&!e.field.startsWith("__")&&!0!==e.meta?.utility)),t?.length){const e=new Set(t);r=r.filter(t=>e.has(t.field))}return r}(this.columns,t?.columns,n.onlyVisible);let a;if(t?.rowIndices)a=r(this.rows,t.rowIndices);else if(n.onlySelected){const e=this.getSelectionState();a=e?.selected?.size?r(this.rows,[...e.selected]):[...this.rows]}else a=[...this.rows];this.isExportingFlag=!0;let d=l.fileName;try{switch(e){case"csv":{const e=function(e,t,n,r={}){const i=r.delimiter??",",o=r.newline??"\n",l=[],c=r.bom?"\ufeff":"";if(!1!==n.includeHeaders){const e=t.map(e=>{const t=e.header||e.field;return s(n.processHeader?n.processHeader(t,e.field):t)});l.push(e.join(i))}for(const a of e){const e=t.map(e=>{let t=a[e.field];return n.processCell&&(t=n.processCell(t,e.field,a)),s(t)});l.push(e.join(i))}return c+l.join(o)}(a,c,l,{bom:!0});d=d.endsWith(".csv")?d:`${d}.csv`,function(e,t){i(new Blob([e],{type:"text/csv;charset=utf-8;"}),t)}(e,d);break}case"excel":{const e=function(e,t,n){let r='<?xml version="1.0" encoding="UTF-8"?>\n<?mso-application progid="Excel.Sheet"?>\n<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"\n xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">\n<Worksheet ss:Name="Sheet1">\n<Table>';if(!1!==n.includeHeaders){r+="\n<Row>";for(const e of t){const t=e.header||e.field;r+=`<Cell><Data ss:Type="String">${o(n.processHeader?n.processHeader(t,e.field):t)}</Data></Cell>`}r+="</Row>"}for(const s of e){r+="\n<Row>";for(const e of t){let t=s[e.field];n.processCell&&(t=n.processCell(t,e.field,s));let i="String",l="";null==t?l="":"number"!=typeof t||isNaN(t)?t instanceof Date?(i="DateTime",l=t.toISOString()):l=o(String(t)):(i="Number",l=String(t)),r+=`<Cell><Data ss:Type="${i}">${l}</Data></Cell>`}r+="</Row>"}return r+="\n</Table>\n</Worksheet>\n</Workbook>",r}(a,c,l);d=d.endsWith(".xls")?d:`${d}.xls`,function(e,t){const n=t.endsWith(".xls")?t:`${t}.xls`;i(new Blob([e],{type:"application/vnd.ms-excel;charset=utf-8;"}),n)}(e,d);break}case"json":{const e=a.map(e=>{const t={};for(const n of c){let r=e[n.field];l.processCell&&(r=l.processCell(r,n.field,e)),t[n.field]=r}return t}),t=JSON.stringify(e,null,2);d=d.endsWith(".json")?d:`${d}.json`;i(new Blob([t],{type:"application/json"}),d);break}}this.lastExportInfo={format:e,timestamp:/* @__PURE__ */new Date},this.emit("export-complete",{format:e,fileName:d,rowCount:a.length,columnCount:c.length})}finally{this.isExportingFlag=!1}}getSelectionState(){try{return this.grid?.getPluginState?.("selection")??null}catch{return null}}exportCsv(e){this.performExport("csv",e)}exportExcel(e){this.performExport("excel",e)}exportJson(e){this.performExport("json",e)}isExporting(){return this.isExportingFlag}getLastExport(){return this.lastExportInfo}}export{l as ExportPlugin};
|
|
590
2
|
//# sourceMappingURL=index.js.map
|