@toolbox-web/grid 0.4.1 → 0.4.2

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.
Files changed (157) hide show
  1. package/README.md +10 -13
  2. package/all.js +1101 -1048
  3. package/all.js.map +1 -1
  4. package/index.js +245 -137
  5. package/index.js.map +1 -1
  6. package/lib/core/grid.d.ts +10 -0
  7. package/lib/core/grid.d.ts.map +1 -1
  8. package/lib/core/internal/config-manager.d.ts +1 -0
  9. package/lib/core/internal/config-manager.d.ts.map +1 -1
  10. package/lib/core/internal/keyboard.d.ts.map +1 -1
  11. package/lib/core/internal/utils.d.ts +1 -0
  12. package/lib/core/internal/utils.d.ts.map +1 -1
  13. package/lib/core/plugin/base-plugin.d.ts +57 -1
  14. package/lib/core/plugin/base-plugin.d.ts.map +1 -1
  15. package/lib/core/plugin/expander-column.d.ts +51 -0
  16. package/lib/core/plugin/expander-column.d.ts.map +1 -0
  17. package/lib/core/plugin/types.d.ts +117 -1
  18. package/lib/core/plugin/types.d.ts.map +1 -1
  19. package/lib/core/types.d.ts +4 -2
  20. package/lib/core/types.d.ts.map +1 -1
  21. package/lib/plugins/clipboard/ClipboardPlugin.d.ts +5 -4
  22. package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
  23. package/lib/plugins/clipboard/index.d.ts +1 -1
  24. package/lib/plugins/clipboard/index.d.ts.map +1 -1
  25. package/lib/plugins/clipboard/index.js +282 -188
  26. package/lib/plugins/clipboard/index.js.map +1 -1
  27. package/lib/plugins/clipboard/types.d.ts +72 -2
  28. package/lib/plugins/clipboard/types.d.ts.map +1 -1
  29. package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts +0 -1
  30. package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts.map +1 -1
  31. package/lib/plugins/column-virtualization/index.js +102 -26
  32. package/lib/plugins/column-virtualization/index.js.map +1 -1
  33. package/lib/plugins/context-menu/ContextMenuPlugin.d.ts +0 -1
  34. package/lib/plugins/context-menu/ContextMenuPlugin.d.ts.map +1 -1
  35. package/lib/plugins/context-menu/index.js +154 -78
  36. package/lib/plugins/context-menu/index.js.map +1 -1
  37. package/lib/plugins/editing/EditingPlugin.d.ts +1 -7
  38. package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
  39. package/lib/plugins/editing/index.js +200 -136
  40. package/lib/plugins/editing/index.js.map +1 -1
  41. package/lib/plugins/export/ExportPlugin.d.ts +0 -1
  42. package/lib/plugins/export/ExportPlugin.d.ts.map +1 -1
  43. package/lib/plugins/export/index.js +175 -99
  44. package/lib/plugins/export/index.js.map +1 -1
  45. package/lib/plugins/filtering/FilteringPlugin.d.ts +5 -2
  46. package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
  47. package/lib/plugins/filtering/index.js +129 -43
  48. package/lib/plugins/filtering/index.js.map +1 -1
  49. package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts +1 -2
  50. package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts.map +1 -1
  51. package/lib/plugins/grouping-columns/grouping-columns.d.ts +1 -1
  52. package/lib/plugins/grouping-columns/grouping-columns.d.ts.map +1 -1
  53. package/lib/plugins/grouping-columns/index.js +144 -66
  54. package/lib/plugins/grouping-columns/index.js.map +1 -1
  55. package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts +14 -2
  56. package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
  57. package/lib/plugins/grouping-rows/index.js +230 -138
  58. package/lib/plugins/grouping-rows/index.js.map +1 -1
  59. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +13 -11
  60. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts.map +1 -1
  61. package/lib/plugins/master-detail/index.js +265 -196
  62. package/lib/plugins/master-detail/index.js.map +1 -1
  63. package/lib/plugins/master-detail/types.d.ts +0 -10
  64. package/lib/plugins/master-detail/types.d.ts.map +1 -1
  65. package/lib/plugins/multi-sort/MultiSortPlugin.d.ts +1 -2
  66. package/lib/plugins/multi-sort/MultiSortPlugin.d.ts.map +1 -1
  67. package/lib/plugins/multi-sort/index.js +105 -31
  68. package/lib/plugins/multi-sort/index.js.map +1 -1
  69. package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts +0 -1
  70. package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts.map +1 -1
  71. package/lib/plugins/pinned-columns/index.js +128 -52
  72. package/lib/plugins/pinned-columns/index.js.map +1 -1
  73. package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts +1 -2
  74. package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts.map +1 -1
  75. package/lib/plugins/pinned-rows/index.js +162 -88
  76. package/lib/plugins/pinned-rows/index.js.map +1 -1
  77. package/lib/plugins/pivot/PivotPlugin.d.ts +26 -4
  78. package/lib/plugins/pivot/PivotPlugin.d.ts.map +1 -1
  79. package/lib/plugins/pivot/index.js +398 -310
  80. package/lib/plugins/pivot/index.js.map +1 -1
  81. package/lib/plugins/pivot/pivot-rows.d.ts +2 -1
  82. package/lib/plugins/pivot/pivot-rows.d.ts.map +1 -1
  83. package/lib/plugins/reorder/ReorderPlugin.d.ts +13 -10
  84. package/lib/plugins/reorder/ReorderPlugin.d.ts.map +1 -1
  85. package/lib/plugins/reorder/index.js +288 -226
  86. package/lib/plugins/reorder/index.js.map +1 -1
  87. package/lib/plugins/selection/SelectionPlugin.d.ts +21 -3
  88. package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
  89. package/lib/plugins/selection/index.d.ts +2 -2
  90. package/lib/plugins/selection/index.d.ts.map +1 -1
  91. package/lib/plugins/selection/index.js +276 -145
  92. package/lib/plugins/selection/index.js.map +1 -1
  93. package/lib/plugins/selection/types.d.ts +24 -0
  94. package/lib/plugins/selection/types.d.ts.map +1 -1
  95. package/lib/plugins/server-side/ServerSidePlugin.d.ts +0 -1
  96. package/lib/plugins/server-side/ServerSidePlugin.d.ts.map +1 -1
  97. package/lib/plugins/server-side/index.js +83 -7
  98. package/lib/plugins/server-side/index.js.map +1 -1
  99. package/lib/plugins/tree/TreePlugin.d.ts +5 -1
  100. package/lib/plugins/tree/TreePlugin.d.ts.map +1 -1
  101. package/lib/plugins/tree/index.js +197 -112
  102. package/lib/plugins/tree/index.js.map +1 -1
  103. package/lib/plugins/tree/types.d.ts +0 -10
  104. package/lib/plugins/tree/types.d.ts.map +1 -1
  105. package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts +0 -1
  106. package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts.map +1 -1
  107. package/lib/plugins/undo-redo/index.js +93 -17
  108. package/lib/plugins/undo-redo/index.js.map +1 -1
  109. package/lib/plugins/visibility/VisibilityPlugin.d.ts +7 -4
  110. package/lib/plugins/visibility/VisibilityPlugin.d.ts.map +1 -1
  111. package/lib/plugins/visibility/index.js +144 -65
  112. package/lib/plugins/visibility/index.js.map +1 -1
  113. package/package.json +1 -1
  114. package/umd/grid.all.umd.js +17 -19
  115. package/umd/grid.all.umd.js.map +1 -1
  116. package/umd/grid.umd.js +7 -7
  117. package/umd/grid.umd.js.map +1 -1
  118. package/umd/plugins/clipboard.umd.js +5 -7
  119. package/umd/plugins/clipboard.umd.js.map +1 -1
  120. package/umd/plugins/column-virtualization.umd.js +1 -1
  121. package/umd/plugins/column-virtualization.umd.js.map +1 -1
  122. package/umd/plugins/context-menu.umd.js +1 -1
  123. package/umd/plugins/context-menu.umd.js.map +1 -1
  124. package/umd/plugins/editing.umd.js +1 -1
  125. package/umd/plugins/editing.umd.js.map +1 -1
  126. package/umd/plugins/export.umd.js +1 -1
  127. package/umd/plugins/export.umd.js.map +1 -1
  128. package/umd/plugins/filtering.umd.js +1 -1
  129. package/umd/plugins/filtering.umd.js.map +1 -1
  130. package/umd/plugins/grouping-columns.umd.js +1 -1
  131. package/umd/plugins/grouping-columns.umd.js.map +1 -1
  132. package/umd/plugins/grouping-rows.umd.js +1 -1
  133. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  134. package/umd/plugins/master-detail.umd.js +1 -1
  135. package/umd/plugins/master-detail.umd.js.map +1 -1
  136. package/umd/plugins/multi-sort.umd.js +1 -1
  137. package/umd/plugins/multi-sort.umd.js.map +1 -1
  138. package/umd/plugins/pinned-columns.umd.js +1 -1
  139. package/umd/plugins/pinned-columns.umd.js.map +1 -1
  140. package/umd/plugins/pinned-rows.umd.js +1 -1
  141. package/umd/plugins/pinned-rows.umd.js.map +1 -1
  142. package/umd/plugins/pivot.umd.js +1 -1
  143. package/umd/plugins/pivot.umd.js.map +1 -1
  144. package/umd/plugins/reorder.umd.js +1 -1
  145. package/umd/plugins/reorder.umd.js.map +1 -1
  146. package/umd/plugins/selection.umd.js +1 -1
  147. package/umd/plugins/selection.umd.js.map +1 -1
  148. package/umd/plugins/server-side.umd.js +1 -1
  149. package/umd/plugins/server-side.umd.js.map +1 -1
  150. package/umd/plugins/tree.umd.js +1 -1
  151. package/umd/plugins/tree.umd.js.map +1 -1
  152. package/umd/plugins/undo-redo.umd.js +1 -1
  153. package/umd/plugins/undo-redo.umd.js.map +1 -1
  154. package/umd/plugins/visibility.umd.js +1 -1
  155. package/umd/plugins/visibility.umd.js.map +1 -1
  156. package/lib/core/internal/editing.d.ts +0 -76
  157. package/lib/core/internal/editing.d.ts.map +0 -1
@@ -15,7 +15,6 @@ import { ExportConfig, ExportFormat, ExportParams } from './types';
15
15
  */
16
16
  export declare class ExportPlugin extends BaseGridPlugin<ExportConfig> {
17
17
  readonly name = "export";
18
- readonly version = "1.0.0";
19
18
  protected get defaultConfig(): Partial<ExportConfig>;
20
19
  private isExportingFlag;
21
20
  private lastExportInfo;
@@ -1 +1 @@
1
- {"version":3,"file":"ExportPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/export/ExportPlugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAI/D,OAAO,KAAK,EAAwB,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAO9F;;;;;;;;;;;;GAYG;AACH,qBAAa,YAAa,SAAQ,cAAc,CAAC,YAAY,CAAC;IAC5D,QAAQ,CAAC,IAAI,YAAY;IACzB,SAAkB,OAAO,WAAW;IAEpC,cAAuB,aAAa,IAAI,OAAO,CAAC,YAAY,CAAC,CAO5D;IAGD,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,cAAc,CAA0D;IAKhF,OAAO,CAAC,aAAa;IAyFrB,OAAO,CAAC,iBAAiB;IAWzB;;;OAGG;IACH,SAAS,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI;IAI/C;;;OAGG;IACH,WAAW,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI;IAIjD;;;OAGG;IACH,UAAU,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI;IAIhD;;;OAGG;IACH,WAAW,IAAI,OAAO;IAItB;;;OAGG;IACH,aAAa,IAAI;QAAE,MAAM,EAAE,YAAY,CAAC;QAAC,SAAS,EAAE,IAAI,CAAA;KAAE,GAAG,IAAI;CAIlE"}
1
+ {"version":3,"file":"ExportPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/export/ExportPlugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAI/D,OAAO,KAAK,EAAwB,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAO9F;;;;;;;;;;;;GAYG;AACH,qBAAa,YAAa,SAAQ,cAAc,CAAC,YAAY,CAAC;IAC5D,QAAQ,CAAC,IAAI,YAAY;IAEzB,cAAuB,aAAa,IAAI,OAAO,CAAC,YAAY,CAAC,CAO5D;IAGD,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,cAAc,CAA0D;IAKhF,OAAO,CAAC,aAAa;IAyFrB,OAAO,CAAC,iBAAiB;IAWzB;;;OAGG;IACH,SAAS,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI;IAI/C;;;OAGG;IACH,WAAW,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI;IAIjD;;;OAGG;IACH,UAAU,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI;IAIhD;;;OAGG;IACH,WAAW,IAAI,OAAO;IAItB;;;OAGG;IACH,aAAa,IAAI;QAAE,MAAM,EAAE,YAAY,CAAC;QAAC,SAAS,EAAE,IAAI,CAAA;KAAE,GAAG,IAAI;CAIlE"}
@@ -1,4 +1,4 @@
1
- const x = {
1
+ const w = {
2
2
  expand: "▶",
3
3
  collapse: "▼",
4
4
  sortAsc: "▲",
@@ -8,7 +8,7 @@ const x = {
8
8
  dragHandle: "⋮⋮",
9
9
  toolPanel: "☰"
10
10
  };
11
- class w {
11
+ class x {
12
12
  /**
13
13
  * Plugin dependencies - declare other plugins this one requires.
14
14
  *
@@ -25,8 +25,11 @@ class w {
25
25
  * ```
26
26
  */
27
27
  static dependencies;
28
- /** Plugin version - override in subclass if needed */
29
- version = "1.0.0";
28
+ /**
29
+ * Plugin version - defaults to grid version for built-in plugins.
30
+ * Third-party plugins can override with their own semver.
31
+ */
32
+ version = typeof __GRID_VERSION__ < "u" ? __GRID_VERSION__ : "dev";
30
33
  /** CSS styles to inject into the grid's shadow DOM */
31
34
  styles;
32
35
  /** Custom cell renderers keyed by type name */
@@ -55,8 +58,8 @@ class w {
55
58
  get defaultConfig() {
56
59
  return {};
57
60
  }
58
- constructor(t = {}) {
59
- this.userConfig = t;
61
+ constructor(e = {}) {
62
+ this.userConfig = e;
60
63
  }
61
64
  /**
62
65
  * Called when the plugin is attached to a grid.
@@ -73,8 +76,8 @@ class w {
73
76
  * }
74
77
  * ```
75
78
  */
76
- attach(t) {
77
- this.#e?.abort(), this.#e = new AbortController(), this.grid = t, this.config = { ...this.defaultConfig, ...this.userConfig };
79
+ attach(e) {
80
+ this.#e?.abort(), this.#e = new AbortController(), this.grid = e, this.config = { ...this.defaultConfig, ...this.userConfig };
78
81
  }
79
82
  /**
80
83
  * Called when the plugin is detached from a grid.
@@ -104,14 +107,22 @@ class w {
104
107
  * }
105
108
  * ```
106
109
  */
107
- getPlugin(t) {
108
- return this.grid?.getPlugin(t);
110
+ getPlugin(e) {
111
+ return this.grid?.getPlugin(e);
109
112
  }
110
113
  /**
111
114
  * Emit a custom event from the grid.
112
115
  */
113
- emit(t, e) {
114
- this.grid?.dispatchEvent?.(new CustomEvent(t, { detail: e, bubbles: !0 }));
116
+ emit(e, t) {
117
+ this.grid?.dispatchEvent?.(new CustomEvent(e, { detail: t, bubbles: !0 }));
118
+ }
119
+ /**
120
+ * Emit a cancelable custom event from the grid.
121
+ * @returns `true` if the event was cancelled (preventDefault called), `false` otherwise
122
+ */
123
+ emitCancelable(e, t) {
124
+ const n = new CustomEvent(e, { detail: t, bubbles: !0, cancelable: !0 });
125
+ return this.grid?.dispatchEvent?.(n), n.defaultPrevented;
115
126
  }
116
127
  /**
117
128
  * Request a re-render of the grid.
@@ -119,6 +130,14 @@ class w {
119
130
  requestRender() {
120
131
  this.grid?.requestRender?.();
121
132
  }
133
+ /**
134
+ * Request a re-render and restore focus styling afterward.
135
+ * Use this when a plugin action (like expand/collapse) triggers a render
136
+ * but needs to maintain keyboard navigation focus.
137
+ */
138
+ requestRenderWithFocus() {
139
+ this.grid?.requestRenderWithFocus?.();
140
+ }
122
141
  /**
123
142
  * Request a lightweight style update without rebuilding DOM.
124
143
  * Use this instead of requestRender() when only CSS classes need updating.
@@ -152,6 +171,19 @@ class w {
152
171
  get visibleColumns() {
153
172
  return this.grid?._visibleColumns ?? [];
154
173
  }
174
+ /**
175
+ * Get the grid as an HTMLElement for direct DOM operations.
176
+ * Use sparingly - prefer the typed GridElementRef API when possible.
177
+ *
178
+ * @example
179
+ * ```ts
180
+ * const width = this.gridElement.clientWidth;
181
+ * this.gridElement.classList.add('my-plugin-active');
182
+ * ```
183
+ */
184
+ get gridElement() {
185
+ return this.grid;
186
+ }
155
187
  /**
156
188
  * Get the shadow root of the grid.
157
189
  */
@@ -183,9 +215,54 @@ class w {
183
215
  * Returns merged icons (user config + defaults).
184
216
  */
185
217
  get gridIcons() {
186
- const t = this.grid?.gridConfig?.icons ?? {};
187
- return { ...x, ...t };
218
+ const e = this.grid?.gridConfig?.icons ?? {};
219
+ return { ...w, ...e };
220
+ }
221
+ // #region Animation Helpers
222
+ /**
223
+ * Check if animations are enabled at the grid level.
224
+ * Respects gridConfig.animation.mode and the CSS variable set by the grid.
225
+ *
226
+ * Plugins should use this to skip animations when:
227
+ * - Animation mode is 'off' or `false`
228
+ * - User prefers reduced motion and mode is 'reduced-motion' (default)
229
+ *
230
+ * @example
231
+ * ```ts
232
+ * private get animationStyle(): 'slide' | 'fade' | false {
233
+ * if (!this.isAnimationEnabled) return false;
234
+ * return this.config.animation ?? 'slide';
235
+ * }
236
+ * ```
237
+ */
238
+ get isAnimationEnabled() {
239
+ const e = this.grid?.effectiveConfig?.animation?.mode ?? "reduced-motion";
240
+ if (e === !1 || e === "off") return !1;
241
+ if (e === !0 || e === "on") return !0;
242
+ const t = this.shadowRoot?.host;
243
+ return t ? getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim() !== "0" : !0;
188
244
  }
245
+ /**
246
+ * Get the animation duration in milliseconds from CSS variable.
247
+ * Falls back to 200ms if not set.
248
+ *
249
+ * Plugins can use this for their animation timing to stay consistent
250
+ * with the grid-level animation.duration setting.
251
+ *
252
+ * @example
253
+ * ```ts
254
+ * element.animate(keyframes, { duration: this.animationDuration });
255
+ * ```
256
+ */
257
+ get animationDuration() {
258
+ const e = this.shadowRoot?.host;
259
+ if (e) {
260
+ const t = getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(), n = parseInt(t, 10);
261
+ if (!isNaN(n)) return n;
262
+ }
263
+ return 200;
264
+ }
265
+ // #endregion
189
266
  /**
190
267
  * Resolve an icon value to string or HTMLElement.
191
268
  * Checks plugin config first, then grid-level icons, then defaults.
@@ -194,8 +271,8 @@ class w {
194
271
  * @param pluginOverride - Optional plugin-level override
195
272
  * @returns The resolved icon value
196
273
  */
197
- resolveIcon(t, e) {
198
- return e !== void 0 ? e : this.gridIcons[t];
274
+ resolveIcon(e, t) {
275
+ return t !== void 0 ? t : this.gridIcons[e];
199
276
  }
200
277
  /**
201
278
  * Set an icon value on an element.
@@ -204,96 +281,95 @@ class w {
204
281
  * @param element - The element to set the icon on
205
282
  * @param icon - The icon value (string or HTMLElement)
206
283
  */
207
- setIcon(t, e) {
208
- typeof e == "string" ? t.innerHTML = e : e instanceof HTMLElement && (t.innerHTML = "", t.appendChild(e.cloneNode(!0)));
284
+ setIcon(e, t) {
285
+ typeof t == "string" ? e.innerHTML = t : t instanceof HTMLElement && (e.innerHTML = "", e.appendChild(t.cloneNode(!0)));
209
286
  }
210
287
  /**
211
288
  * Log a warning message.
212
289
  */
213
- warn(t) {
214
- console.warn(`[tbw-grid:${this.name}] ${t}`);
290
+ warn(e) {
291
+ console.warn(`[tbw-grid:${this.name}] ${e}`);
215
292
  }
216
293
  // #endregion
217
294
  }
218
- function b(i, t = !0) {
295
+ function m(i, e = !0) {
219
296
  if (i == null) return "";
220
297
  if (i instanceof Date) return i.toISOString();
221
298
  if (typeof i == "object") return JSON.stringify(i);
222
- const e = String(i);
223
- return t && (e.includes(",") || e.includes('"') || e.includes(`
224
- `) || e.includes("\r")) ? `"${e.replace(/"/g, '""')}"` : e;
299
+ const t = String(i);
300
+ return e && (t.includes(",") || t.includes('"') || t.includes(`
301
+ `) || t.includes("\r")) ? `"${t.replace(/"/g, '""')}"` : t;
225
302
  }
226
- function C(i, t, e, s = {}) {
227
- const c = s.delimiter ?? ",", l = s.newline ?? `
228
- `, o = [], r = s.bom ? "\uFEFF" : "";
229
- if (e.includeHeaders !== !1) {
230
- const n = t.map((u) => {
231
- const d = u.header || u.field, a = e.processHeader ? e.processHeader(d, u.field) : d;
232
- return b(a);
303
+ function C(i, e, t, n = {}) {
304
+ const c = n.delimiter ?? ",", l = n.newline ?? `
305
+ `, o = [], r = n.bom ? "\uFEFF" : "";
306
+ if (t.includeHeaders !== !1) {
307
+ const s = e.map((a) => {
308
+ const d = a.header || a.field, u = t.processHeader ? t.processHeader(d, a.field) : d;
309
+ return m(u);
233
310
  });
234
- o.push(n.join(c));
311
+ o.push(s.join(c));
235
312
  }
236
- for (const n of i) {
237
- const u = t.map((d) => {
238
- let a = n[d.field];
239
- return e.processCell && (a = e.processCell(a, d.field, n)), b(a);
313
+ for (const s of i) {
314
+ const a = e.map((d) => {
315
+ let u = s[d.field];
316
+ return t.processCell && (u = t.processCell(u, d.field, s)), m(u);
240
317
  });
241
- o.push(u.join(c));
318
+ o.push(a.join(c));
242
319
  }
243
320
  return r + o.join(l);
244
321
  }
245
- function h(i, t) {
246
- const e = URL.createObjectURL(i), s = document.createElement("a");
247
- s.href = e, s.download = t, s.style.display = "none", document.body.appendChild(s), s.click(), document.body.removeChild(s), URL.revokeObjectURL(e);
322
+ function h(i, e) {
323
+ const t = URL.createObjectURL(i), n = document.createElement("a");
324
+ n.href = t, n.download = e, n.style.display = "none", document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(t);
248
325
  }
249
- function S(i, t) {
250
- const e = new Blob([i], { type: "text/csv;charset=utf-8;" });
251
- h(e, t);
326
+ function E(i, e) {
327
+ const t = new Blob([i], { type: "text/csv;charset=utf-8;" });
328
+ h(t, e);
252
329
  }
253
- function m(i) {
330
+ function b(i) {
254
331
  return i.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
255
332
  }
256
- function E(i, t, e) {
257
- let s = `<?xml version="1.0" encoding="UTF-8"?>
333
+ function S(i, e, t) {
334
+ let n = `<?xml version="1.0" encoding="UTF-8"?>
258
335
  <?mso-application progid="Excel.Sheet"?>
259
336
  <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
260
337
  xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
261
338
  <Worksheet ss:Name="Sheet1">
262
339
  <Table>`;
263
- if (e.includeHeaders !== !1) {
264
- s += `
340
+ if (t.includeHeaders !== !1) {
341
+ n += `
265
342
  <Row>`;
266
- for (const c of t) {
267
- const l = c.header || c.field, o = e.processHeader ? e.processHeader(l, c.field) : l;
268
- s += `<Cell><Data ss:Type="String">${m(o)}</Data></Cell>`;
343
+ for (const c of e) {
344
+ const l = c.header || c.field, o = t.processHeader ? t.processHeader(l, c.field) : l;
345
+ n += `<Cell><Data ss:Type="String">${b(o)}</Data></Cell>`;
269
346
  }
270
- s += "</Row>";
347
+ n += "</Row>";
271
348
  }
272
349
  for (const c of i) {
273
- s += `
350
+ n += `
274
351
  <Row>`;
275
- for (const l of t) {
352
+ for (const l of e) {
276
353
  let o = c[l.field];
277
- e.processCell && (o = e.processCell(o, l.field, c));
278
- let r = "String", n = "";
279
- o == null ? n = "" : typeof o == "number" && !isNaN(o) ? (r = "Number", n = String(o)) : o instanceof Date ? (r = "DateTime", n = o.toISOString()) : n = m(String(o)), s += `<Cell><Data ss:Type="${r}">${n}</Data></Cell>`;
354
+ t.processCell && (o = t.processCell(o, l.field, c));
355
+ let r = "String", s = "";
356
+ o == null ? s = "" : typeof o == "number" && !isNaN(o) ? (r = "Number", s = String(o)) : o instanceof Date ? (r = "DateTime", s = o.toISOString()) : s = b(String(o)), n += `<Cell><Data ss:Type="${r}">${s}</Data></Cell>`;
280
357
  }
281
- s += "</Row>";
358
+ n += "</Row>";
282
359
  }
283
- return s += `
360
+ return n += `
284
361
  </Table>
285
362
  </Worksheet>
286
- </Workbook>`, s;
363
+ </Workbook>`, n;
287
364
  }
288
- function y(i, t) {
289
- const e = t.endsWith(".xls") ? t : `${t}.xls`, s = new Blob([i], {
365
+ function y(i, e) {
366
+ const t = e.endsWith(".xls") ? e : `${e}.xls`, n = new Blob([i], {
290
367
  type: "application/vnd.ms-excel;charset=utf-8;"
291
368
  });
292
- h(s, e);
369
+ h(n, t);
293
370
  }
294
- class R extends w {
371
+ class R extends x {
295
372
  name = "export";
296
- version = "1.0.0";
297
373
  get defaultConfig() {
298
374
  return {
299
375
  fileName: "export",
@@ -307,57 +383,57 @@ class R extends w {
307
383
  lastExportInfo = null;
308
384
  // #endregion
309
385
  // #region Private Methods
310
- performExport(t, e) {
311
- const s = this.config, c = {
312
- format: t,
313
- fileName: e?.fileName ?? s.fileName ?? "export",
314
- includeHeaders: e?.includeHeaders ?? s.includeHeaders,
315
- processCell: e?.processCell,
316
- processHeader: e?.processHeader,
317
- columns: e?.columns,
318
- rowIndices: e?.rowIndices
386
+ performExport(e, t) {
387
+ const n = this.config, c = {
388
+ format: e,
389
+ fileName: t?.fileName ?? n.fileName ?? "export",
390
+ includeHeaders: t?.includeHeaders ?? n.includeHeaders,
391
+ processCell: t?.processCell,
392
+ processHeader: t?.processHeader,
393
+ columns: t?.columns,
394
+ rowIndices: t?.rowIndices
319
395
  };
320
396
  let l = [...this.columns];
321
- if (s.onlyVisible && (l = l.filter((n) => !n.hidden && !n.field.startsWith("__"))), e?.columns) {
322
- const n = new Set(e.columns);
323
- l = l.filter((u) => n.has(u.field));
397
+ if (n.onlyVisible && (l = l.filter((s) => !s.hidden && !s.field.startsWith("__"))), t?.columns) {
398
+ const s = new Set(t.columns);
399
+ l = l.filter((a) => s.has(a.field));
324
400
  }
325
401
  let o = [...this.rows];
326
- if (s.onlySelected) {
327
- const n = this.getSelectionState();
328
- n?.selected?.size && (o = [...n.selected].sort((d, a) => d - a).map((d) => this.rows[d]).filter(Boolean));
402
+ if (n.onlySelected) {
403
+ const s = this.getSelectionState();
404
+ s?.selected?.size && (o = [...s.selected].sort((d, u) => d - u).map((d) => this.rows[d]).filter(Boolean));
329
405
  }
330
- e?.rowIndices && (o = e.rowIndices.map((n) => this.rows[n]).filter(Boolean)), this.isExportingFlag = !0;
406
+ t?.rowIndices && (o = t.rowIndices.map((s) => this.rows[s]).filter(Boolean)), this.isExportingFlag = !0;
331
407
  let r = c.fileName;
332
408
  try {
333
- switch (t) {
409
+ switch (e) {
334
410
  case "csv": {
335
- const n = C(o, l, c, { bom: !0 });
336
- r = r.endsWith(".csv") ? r : `${r}.csv`, S(n, r);
411
+ const s = C(o, l, c, { bom: !0 });
412
+ r = r.endsWith(".csv") ? r : `${r}.csv`, E(s, r);
337
413
  break;
338
414
  }
339
415
  case "excel": {
340
- const n = E(o, l, c);
341
- r = r.endsWith(".xls") ? r : `${r}.xls`, y(n, r);
416
+ const s = S(o, l, c);
417
+ r = r.endsWith(".xls") ? r : `${r}.xls`, y(s, r);
342
418
  break;
343
419
  }
344
420
  case "json": {
345
- const n = o.map((a) => {
421
+ const s = o.map((u) => {
346
422
  const p = {};
347
423
  for (const f of l) {
348
- let g = a[f.field];
349
- c.processCell && (g = c.processCell(g, f.field, a)), p[f.field] = g;
424
+ let g = u[f.field];
425
+ c.processCell && (g = c.processCell(g, f.field, u)), p[f.field] = g;
350
426
  }
351
427
  return p;
352
- }), u = JSON.stringify(n, null, 2);
428
+ }), a = JSON.stringify(s, null, 2);
353
429
  r = r.endsWith(".json") ? r : `${r}.json`;
354
- const d = new Blob([u], { type: "application/json" });
430
+ const d = new Blob([a], { type: "application/json" });
355
431
  h(d, r);
356
432
  break;
357
433
  }
358
434
  }
359
- this.lastExportInfo = { format: t, timestamp: /* @__PURE__ */ new Date() }, this.emit("export-complete", {
360
- format: t,
435
+ this.lastExportInfo = { format: e, timestamp: /* @__PURE__ */ new Date() }, this.emit("export-complete", {
436
+ format: e,
361
437
  fileName: r,
362
438
  rowCount: o.length,
363
439
  columnCount: l.length
@@ -379,22 +455,22 @@ class R extends w {
379
455
  * Export data to CSV format.
380
456
  * @param params - Optional export parameters
381
457
  */
382
- exportCsv(t) {
383
- this.performExport("csv", t);
458
+ exportCsv(e) {
459
+ this.performExport("csv", e);
384
460
  }
385
461
  /**
386
462
  * Export data to Excel format (XML Spreadsheet).
387
463
  * @param params - Optional export parameters
388
464
  */
389
- exportExcel(t) {
390
- this.performExport("excel", t);
465
+ exportExcel(e) {
466
+ this.performExport("excel", e);
391
467
  }
392
468
  /**
393
469
  * Export data to JSON format.
394
470
  * @param params - Optional export parameters
395
471
  */
396
- exportJson(t) {
397
- this.performExport("json", t);
472
+ exportJson(e) {
473
+ this.performExport("json", e);
398
474
  }
399
475
  /**
400
476
  * Check if an export is currently in progress.