@toolbox-web/grid 0.4.1 → 0.5.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 +9 -13
- package/all.js +1678 -1588
- package/all.js.map +1 -1
- package/index.js +762 -568
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +21 -0
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/config-manager.d.ts +1 -0
- package/lib/core/internal/config-manager.d.ts.map +1 -1
- package/lib/core/internal/dom-builder.d.ts +2 -0
- package/lib/core/internal/dom-builder.d.ts.map +1 -1
- package/lib/core/internal/header.d.ts.map +1 -1
- package/lib/core/internal/keyboard.d.ts.map +1 -1
- package/lib/core/internal/resize.d.ts.map +1 -1
- package/lib/core/internal/rows.d.ts.map +1 -1
- package/lib/core/internal/shell.d.ts +19 -13
- package/lib/core/internal/shell.d.ts.map +1 -1
- package/lib/core/internal/utils.d.ts +1 -0
- package/lib/core/internal/utils.d.ts.map +1 -1
- package/lib/core/plugin/base-plugin.d.ts +70 -3
- package/lib/core/plugin/base-plugin.d.ts.map +1 -1
- package/lib/core/plugin/expander-column.d.ts +51 -0
- package/lib/core/plugin/expander-column.d.ts.map +1 -0
- package/lib/core/plugin/plugin-manager.d.ts +6 -2
- package/lib/core/plugin/plugin-manager.d.ts.map +1 -1
- package/lib/core/plugin/types.d.ts +117 -1
- package/lib/core/plugin/types.d.ts.map +1 -1
- package/lib/core/types.d.ts +10 -5
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts +5 -4
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.d.ts +1 -1
- package/lib/plugins/clipboard/index.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +295 -190
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/clipboard/types.d.ts +72 -2
- package/lib/plugins/clipboard/types.d.ts.map +1 -1
- package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts +0 -1
- package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts.map +1 -1
- package/lib/plugins/column-virtualization/index.js +143 -56
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/ContextMenuPlugin.d.ts +0 -1
- package/lib/plugins/context-menu/ContextMenuPlugin.d.ts.map +1 -1
- package/lib/plugins/context-menu/index.js +189 -102
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts +2 -7
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +227 -150
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/ExportPlugin.d.ts +0 -1
- package/lib/plugins/export/ExportPlugin.d.ts.map +1 -1
- package/lib/plugins/export/index.js +184 -97
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts +14 -3
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +296 -176
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts +2 -2
- package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts.map +1 -1
- package/lib/plugins/grouping-columns/grouping-columns.d.ts +1 -1
- package/lib/plugins/grouping-columns/grouping-columns.d.ts.map +1 -1
- package/lib/plugins/grouping-columns/index.js +169 -61
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts +14 -2
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/grouping-rows/index.js +243 -140
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +13 -11
- package/lib/plugins/master-detail/MasterDetailPlugin.d.ts.map +1 -1
- package/lib/plugins/master-detail/index.js +278 -196
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/master-detail/types.d.ts +0 -10
- package/lib/plugins/master-detail/types.d.ts.map +1 -1
- package/lib/plugins/multi-sort/MultiSortPlugin.d.ts +1 -2
- package/lib/plugins/multi-sort/MultiSortPlugin.d.ts.map +1 -1
- package/lib/plugins/multi-sort/index.js +125 -40
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts +0 -1
- package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts.map +1 -1
- package/lib/plugins/pinned-columns/index.js +156 -75
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-columns/pinned-columns.d.ts +2 -2
- package/lib/plugins/pinned-columns/pinned-columns.d.ts.map +1 -1
- package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts +1 -2
- package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/pinned-rows/index.js +202 -117
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/PivotPlugin.d.ts +26 -4
- package/lib/plugins/pivot/PivotPlugin.d.ts.map +1 -1
- package/lib/plugins/pivot/index.js +413 -314
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/pivot/pivot-rows.d.ts +2 -1
- package/lib/plugins/pivot/pivot-rows.d.ts.map +1 -1
- package/lib/plugins/reorder/ReorderPlugin.d.ts +13 -10
- package/lib/plugins/reorder/ReorderPlugin.d.ts.map +1 -1
- package/lib/plugins/reorder/index.d.ts +1 -1
- package/lib/plugins/reorder/index.d.ts.map +1 -1
- package/lib/plugins/reorder/index.js +296 -223
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/SelectionPlugin.d.ts +21 -3
- package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
- package/lib/plugins/selection/index.d.ts +2 -2
- package/lib/plugins/selection/index.d.ts.map +1 -1
- package/lib/plugins/selection/index.js +282 -141
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/selection/types.d.ts +24 -0
- package/lib/plugins/selection/types.d.ts.map +1 -1
- package/lib/plugins/server-side/ServerSidePlugin.d.ts +0 -1
- package/lib/plugins/server-side/ServerSidePlugin.d.ts.map +1 -1
- package/lib/plugins/server-side/index.js +96 -9
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/TreePlugin.d.ts +5 -1
- package/lib/plugins/tree/TreePlugin.d.ts.map +1 -1
- package/lib/plugins/tree/index.js +209 -113
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/tree/types.d.ts +0 -10
- package/lib/plugins/tree/types.d.ts.map +1 -1
- package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts +0 -1
- package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts.map +1 -1
- package/lib/plugins/undo-redo/index.js +98 -11
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/VisibilityPlugin.d.ts +7 -4
- package/lib/plugins/visibility/VisibilityPlugin.d.ts.map +1 -1
- package/lib/plugins/visibility/index.js +155 -64
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/themes/dg-theme-bootstrap.css +55 -53
- package/themes/dg-theme-contrast.css +42 -40
- package/themes/dg-theme-large.css +38 -37
- package/themes/dg-theme-material.css +54 -52
- package/themes/dg-theme-standard.css +19 -17
- package/themes/dg-theme-vibrant.css +16 -14
- package/umd/grid.all.umd.js +23 -24
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +12 -11
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js +5 -7
- 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 -1
- 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 -1
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js +1 -1
- package/umd/plugins/master-detail.umd.js.map +1 -1
- package/umd/plugins/multi-sort.umd.js +1 -1
- package/umd/plugins/multi-sort.umd.js.map +1 -1
- package/umd/plugins/pinned-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/reorder.umd.js +1 -1
- package/umd/plugins/reorder.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +1 -1
- package/umd/plugins/selection.umd.js.map +1 -1
- package/umd/plugins/server-side.umd.js +1 -1
- package/umd/plugins/server-side.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js +1 -1
- package/umd/plugins/tree.umd.js.map +1 -1
- 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
- package/lib/core/internal/editing.d.ts +0 -76
- 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;
|
|
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
|
|
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
|
|
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
|
-
/**
|
|
29
|
-
|
|
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(
|
|
59
|
-
this.userConfig =
|
|
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(
|
|
77
|
-
this.#e?.abort(), this.#e = new AbortController(), this.grid =
|
|
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(
|
|
108
|
-
return this.grid?.getPlugin(
|
|
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(
|
|
114
|
-
this.grid?.dispatchEvent?.(new CustomEvent(
|
|
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.
|
|
@@ -153,10 +172,34 @@ class w {
|
|
|
153
172
|
return this.grid?._visibleColumns ?? [];
|
|
154
173
|
}
|
|
155
174
|
/**
|
|
156
|
-
* Get the
|
|
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
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Get the render root of the grid for DOM queries.
|
|
189
|
+
* @deprecated Use `gridElement` instead. This getter exists only for backward compatibility.
|
|
190
|
+
*
|
|
191
|
+
* With Shadow DOM removed, the grid element itself is the render root.
|
|
192
|
+
* All new code should use `this.gridElement` for DOM queries.
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* // OLD (deprecated)
|
|
196
|
+
* const rows = this.shadowRoot?.querySelector('.rows');
|
|
197
|
+
*
|
|
198
|
+
* // NEW (preferred)
|
|
199
|
+
* const rows = this.gridElement.querySelector('.rows');
|
|
157
200
|
*/
|
|
158
201
|
get shadowRoot() {
|
|
159
|
-
return this.
|
|
202
|
+
return this.gridElement;
|
|
160
203
|
}
|
|
161
204
|
/**
|
|
162
205
|
* Get the disconnect signal for event listener cleanup.
|
|
@@ -183,9 +226,54 @@ class w {
|
|
|
183
226
|
* Returns merged icons (user config + defaults).
|
|
184
227
|
*/
|
|
185
228
|
get gridIcons() {
|
|
186
|
-
const
|
|
187
|
-
return { ...
|
|
229
|
+
const e = this.grid?.gridConfig?.icons ?? {};
|
|
230
|
+
return { ...w, ...e };
|
|
188
231
|
}
|
|
232
|
+
// #region Animation Helpers
|
|
233
|
+
/**
|
|
234
|
+
* Check if animations are enabled at the grid level.
|
|
235
|
+
* Respects gridConfig.animation.mode and the CSS variable set by the grid.
|
|
236
|
+
*
|
|
237
|
+
* Plugins should use this to skip animations when:
|
|
238
|
+
* - Animation mode is 'off' or `false`
|
|
239
|
+
* - User prefers reduced motion and mode is 'reduced-motion' (default)
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```ts
|
|
243
|
+
* private get animationStyle(): 'slide' | 'fade' | false {
|
|
244
|
+
* if (!this.isAnimationEnabled) return false;
|
|
245
|
+
* return this.config.animation ?? 'slide';
|
|
246
|
+
* }
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
get isAnimationEnabled() {
|
|
250
|
+
const e = this.grid?.effectiveConfig?.animation?.mode ?? "reduced-motion";
|
|
251
|
+
if (e === !1 || e === "off") return !1;
|
|
252
|
+
if (e === !0 || e === "on") return !0;
|
|
253
|
+
const t = this.gridElement;
|
|
254
|
+
return t ? getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim() !== "0" : !0;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Get the animation duration in milliseconds from CSS variable.
|
|
258
|
+
* Falls back to 200ms if not set.
|
|
259
|
+
*
|
|
260
|
+
* Plugins can use this for their animation timing to stay consistent
|
|
261
|
+
* with the grid-level animation.duration setting.
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* ```ts
|
|
265
|
+
* element.animate(keyframes, { duration: this.animationDuration });
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
get animationDuration() {
|
|
269
|
+
const e = this.gridElement;
|
|
270
|
+
if (e) {
|
|
271
|
+
const t = getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(), n = parseInt(t, 10);
|
|
272
|
+
if (!isNaN(n)) return n;
|
|
273
|
+
}
|
|
274
|
+
return 200;
|
|
275
|
+
}
|
|
276
|
+
// #endregion
|
|
189
277
|
/**
|
|
190
278
|
* Resolve an icon value to string or HTMLElement.
|
|
191
279
|
* Checks plugin config first, then grid-level icons, then defaults.
|
|
@@ -194,8 +282,8 @@ class w {
|
|
|
194
282
|
* @param pluginOverride - Optional plugin-level override
|
|
195
283
|
* @returns The resolved icon value
|
|
196
284
|
*/
|
|
197
|
-
resolveIcon(
|
|
198
|
-
return
|
|
285
|
+
resolveIcon(e, t) {
|
|
286
|
+
return t !== void 0 ? t : this.gridIcons[e];
|
|
199
287
|
}
|
|
200
288
|
/**
|
|
201
289
|
* Set an icon value on an element.
|
|
@@ -204,96 +292,95 @@ class w {
|
|
|
204
292
|
* @param element - The element to set the icon on
|
|
205
293
|
* @param icon - The icon value (string or HTMLElement)
|
|
206
294
|
*/
|
|
207
|
-
setIcon(
|
|
208
|
-
typeof
|
|
295
|
+
setIcon(e, t) {
|
|
296
|
+
typeof t == "string" ? e.innerHTML = t : t instanceof HTMLElement && (e.innerHTML = "", e.appendChild(t.cloneNode(!0)));
|
|
209
297
|
}
|
|
210
298
|
/**
|
|
211
299
|
* Log a warning message.
|
|
212
300
|
*/
|
|
213
|
-
warn(
|
|
214
|
-
console.warn(`[tbw-grid:${this.name}] ${
|
|
301
|
+
warn(e) {
|
|
302
|
+
console.warn(`[tbw-grid:${this.name}] ${e}`);
|
|
215
303
|
}
|
|
216
304
|
// #endregion
|
|
217
305
|
}
|
|
218
|
-
function
|
|
306
|
+
function m(i, e = !0) {
|
|
219
307
|
if (i == null) return "";
|
|
220
308
|
if (i instanceof Date) return i.toISOString();
|
|
221
309
|
if (typeof i == "object") return JSON.stringify(i);
|
|
222
|
-
const
|
|
223
|
-
return
|
|
224
|
-
`) ||
|
|
310
|
+
const t = String(i);
|
|
311
|
+
return e && (t.includes(",") || t.includes('"') || t.includes(`
|
|
312
|
+
`) || t.includes("\r")) ? `"${t.replace(/"/g, '""')}"` : t;
|
|
225
313
|
}
|
|
226
|
-
function C(i,
|
|
227
|
-
const c =
|
|
228
|
-
`, o = [], r =
|
|
229
|
-
if (
|
|
230
|
-
const
|
|
231
|
-
const d = u.header || u.field, a =
|
|
232
|
-
return
|
|
314
|
+
function C(i, e, t, n = {}) {
|
|
315
|
+
const c = n.delimiter ?? ",", l = n.newline ?? `
|
|
316
|
+
`, o = [], r = n.bom ? "\uFEFF" : "";
|
|
317
|
+
if (t.includeHeaders !== !1) {
|
|
318
|
+
const s = e.map((u) => {
|
|
319
|
+
const d = u.header || u.field, a = t.processHeader ? t.processHeader(d, u.field) : d;
|
|
320
|
+
return m(a);
|
|
233
321
|
});
|
|
234
|
-
o.push(
|
|
322
|
+
o.push(s.join(c));
|
|
235
323
|
}
|
|
236
|
-
for (const
|
|
237
|
-
const u =
|
|
238
|
-
let a =
|
|
239
|
-
return
|
|
324
|
+
for (const s of i) {
|
|
325
|
+
const u = e.map((d) => {
|
|
326
|
+
let a = s[d.field];
|
|
327
|
+
return t.processCell && (a = t.processCell(a, d.field, s)), m(a);
|
|
240
328
|
});
|
|
241
329
|
o.push(u.join(c));
|
|
242
330
|
}
|
|
243
331
|
return r + o.join(l);
|
|
244
332
|
}
|
|
245
|
-
function h(i,
|
|
246
|
-
const
|
|
247
|
-
|
|
333
|
+
function h(i, e) {
|
|
334
|
+
const t = URL.createObjectURL(i), n = document.createElement("a");
|
|
335
|
+
n.href = t, n.download = e, n.style.display = "none", document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(t);
|
|
248
336
|
}
|
|
249
|
-
function
|
|
250
|
-
const
|
|
251
|
-
h(
|
|
337
|
+
function E(i, e) {
|
|
338
|
+
const t = new Blob([i], { type: "text/csv;charset=utf-8;" });
|
|
339
|
+
h(t, e);
|
|
252
340
|
}
|
|
253
|
-
function
|
|
341
|
+
function b(i) {
|
|
254
342
|
return i.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
255
343
|
}
|
|
256
|
-
function
|
|
257
|
-
let
|
|
344
|
+
function S(i, e, t) {
|
|
345
|
+
let n = `<?xml version="1.0" encoding="UTF-8"?>
|
|
258
346
|
<?mso-application progid="Excel.Sheet"?>
|
|
259
347
|
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
|
|
260
348
|
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
|
|
261
349
|
<Worksheet ss:Name="Sheet1">
|
|
262
350
|
<Table>`;
|
|
263
|
-
if (
|
|
264
|
-
|
|
351
|
+
if (t.includeHeaders !== !1) {
|
|
352
|
+
n += `
|
|
265
353
|
<Row>`;
|
|
266
|
-
for (const c of
|
|
267
|
-
const l = c.header || c.field, o =
|
|
268
|
-
|
|
354
|
+
for (const c of e) {
|
|
355
|
+
const l = c.header || c.field, o = t.processHeader ? t.processHeader(l, c.field) : l;
|
|
356
|
+
n += `<Cell><Data ss:Type="String">${b(o)}</Data></Cell>`;
|
|
269
357
|
}
|
|
270
|
-
|
|
358
|
+
n += "</Row>";
|
|
271
359
|
}
|
|
272
360
|
for (const c of i) {
|
|
273
|
-
|
|
361
|
+
n += `
|
|
274
362
|
<Row>`;
|
|
275
|
-
for (const l of
|
|
363
|
+
for (const l of e) {
|
|
276
364
|
let o = c[l.field];
|
|
277
|
-
|
|
278
|
-
let r = "String",
|
|
279
|
-
o == null ?
|
|
365
|
+
t.processCell && (o = t.processCell(o, l.field, c));
|
|
366
|
+
let r = "String", s = "";
|
|
367
|
+
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
368
|
}
|
|
281
|
-
|
|
369
|
+
n += "</Row>";
|
|
282
370
|
}
|
|
283
|
-
return
|
|
371
|
+
return n += `
|
|
284
372
|
</Table>
|
|
285
373
|
</Worksheet>
|
|
286
|
-
</Workbook>`,
|
|
374
|
+
</Workbook>`, n;
|
|
287
375
|
}
|
|
288
|
-
function y(i,
|
|
289
|
-
const
|
|
376
|
+
function y(i, e) {
|
|
377
|
+
const t = e.endsWith(".xls") ? e : `${e}.xls`, n = new Blob([i], {
|
|
290
378
|
type: "application/vnd.ms-excel;charset=utf-8;"
|
|
291
379
|
});
|
|
292
|
-
h(
|
|
380
|
+
h(n, t);
|
|
293
381
|
}
|
|
294
|
-
class R extends
|
|
382
|
+
class R extends x {
|
|
295
383
|
name = "export";
|
|
296
|
-
version = "1.0.0";
|
|
297
384
|
get defaultConfig() {
|
|
298
385
|
return {
|
|
299
386
|
fileName: "export",
|
|
@@ -307,57 +394,57 @@ class R extends w {
|
|
|
307
394
|
lastExportInfo = null;
|
|
308
395
|
// #endregion
|
|
309
396
|
// #region Private Methods
|
|
310
|
-
performExport(
|
|
311
|
-
const
|
|
312
|
-
format:
|
|
313
|
-
fileName:
|
|
314
|
-
includeHeaders:
|
|
315
|
-
processCell:
|
|
316
|
-
processHeader:
|
|
317
|
-
columns:
|
|
318
|
-
rowIndices:
|
|
397
|
+
performExport(e, t) {
|
|
398
|
+
const n = this.config, c = {
|
|
399
|
+
format: e,
|
|
400
|
+
fileName: t?.fileName ?? n.fileName ?? "export",
|
|
401
|
+
includeHeaders: t?.includeHeaders ?? n.includeHeaders,
|
|
402
|
+
processCell: t?.processCell,
|
|
403
|
+
processHeader: t?.processHeader,
|
|
404
|
+
columns: t?.columns,
|
|
405
|
+
rowIndices: t?.rowIndices
|
|
319
406
|
};
|
|
320
407
|
let l = [...this.columns];
|
|
321
|
-
if (
|
|
322
|
-
const
|
|
323
|
-
l = l.filter((u) =>
|
|
408
|
+
if (n.onlyVisible && (l = l.filter((s) => !s.hidden && !s.field.startsWith("__"))), t?.columns) {
|
|
409
|
+
const s = new Set(t.columns);
|
|
410
|
+
l = l.filter((u) => s.has(u.field));
|
|
324
411
|
}
|
|
325
412
|
let o = [...this.rows];
|
|
326
|
-
if (
|
|
327
|
-
const
|
|
328
|
-
|
|
413
|
+
if (n.onlySelected) {
|
|
414
|
+
const s = this.getSelectionState();
|
|
415
|
+
s?.selected?.size && (o = [...s.selected].sort((d, a) => d - a).map((d) => this.rows[d]).filter(Boolean));
|
|
329
416
|
}
|
|
330
|
-
|
|
417
|
+
t?.rowIndices && (o = t.rowIndices.map((s) => this.rows[s]).filter(Boolean)), this.isExportingFlag = !0;
|
|
331
418
|
let r = c.fileName;
|
|
332
419
|
try {
|
|
333
|
-
switch (
|
|
420
|
+
switch (e) {
|
|
334
421
|
case "csv": {
|
|
335
|
-
const
|
|
336
|
-
r = r.endsWith(".csv") ? r : `${r}.csv`,
|
|
422
|
+
const s = C(o, l, c, { bom: !0 });
|
|
423
|
+
r = r.endsWith(".csv") ? r : `${r}.csv`, E(s, r);
|
|
337
424
|
break;
|
|
338
425
|
}
|
|
339
426
|
case "excel": {
|
|
340
|
-
const
|
|
341
|
-
r = r.endsWith(".xls") ? r : `${r}.xls`, y(
|
|
427
|
+
const s = S(o, l, c);
|
|
428
|
+
r = r.endsWith(".xls") ? r : `${r}.xls`, y(s, r);
|
|
342
429
|
break;
|
|
343
430
|
}
|
|
344
431
|
case "json": {
|
|
345
|
-
const
|
|
432
|
+
const s = o.map((a) => {
|
|
346
433
|
const p = {};
|
|
347
434
|
for (const f of l) {
|
|
348
435
|
let g = a[f.field];
|
|
349
436
|
c.processCell && (g = c.processCell(g, f.field, a)), p[f.field] = g;
|
|
350
437
|
}
|
|
351
438
|
return p;
|
|
352
|
-
}), u = JSON.stringify(
|
|
439
|
+
}), u = JSON.stringify(s, null, 2);
|
|
353
440
|
r = r.endsWith(".json") ? r : `${r}.json`;
|
|
354
441
|
const d = new Blob([u], { type: "application/json" });
|
|
355
442
|
h(d, r);
|
|
356
443
|
break;
|
|
357
444
|
}
|
|
358
445
|
}
|
|
359
|
-
this.lastExportInfo = { format:
|
|
360
|
-
format:
|
|
446
|
+
this.lastExportInfo = { format: e, timestamp: /* @__PURE__ */ new Date() }, this.emit("export-complete", {
|
|
447
|
+
format: e,
|
|
361
448
|
fileName: r,
|
|
362
449
|
rowCount: o.length,
|
|
363
450
|
columnCount: l.length
|
|
@@ -379,22 +466,22 @@ class R extends w {
|
|
|
379
466
|
* Export data to CSV format.
|
|
380
467
|
* @param params - Optional export parameters
|
|
381
468
|
*/
|
|
382
|
-
exportCsv(
|
|
383
|
-
this.performExport("csv",
|
|
469
|
+
exportCsv(e) {
|
|
470
|
+
this.performExport("csv", e);
|
|
384
471
|
}
|
|
385
472
|
/**
|
|
386
473
|
* Export data to Excel format (XML Spreadsheet).
|
|
387
474
|
* @param params - Optional export parameters
|
|
388
475
|
*/
|
|
389
|
-
exportExcel(
|
|
390
|
-
this.performExport("excel",
|
|
476
|
+
exportExcel(e) {
|
|
477
|
+
this.performExport("excel", e);
|
|
391
478
|
}
|
|
392
479
|
/**
|
|
393
480
|
* Export data to JSON format.
|
|
394
481
|
* @param params - Optional export parameters
|
|
395
482
|
*/
|
|
396
|
-
exportJson(
|
|
397
|
-
this.performExport("json",
|
|
483
|
+
exportJson(e) {
|
|
484
|
+
this.performExport("json", e);
|
|
398
485
|
}
|
|
399
486
|
/**
|
|
400
487
|
* Check if an export is currently in progress.
|