@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.
- package/README.md +10 -13
- package/all.js +1101 -1048
- package/all.js.map +1 -1
- package/index.js +245 -137
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +10 -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/keyboard.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 +57 -1
- 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/types.d.ts +117 -1
- package/lib/core/plugin/types.d.ts.map +1 -1
- package/lib/core/types.d.ts +4 -2
- 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 +282 -188
- 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 +102 -26
- 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 +154 -78
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts +1 -7
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +200 -136
- 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 +175 -99
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts +5 -2
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +129 -43
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts +1 -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 +144 -66
- 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 +230 -138
- 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 +265 -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 +105 -31
- 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 +128 -52
- package/lib/plugins/pinned-columns/index.js.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 +162 -88
- 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 +398 -310
- 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.js +288 -226
- 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 +276 -145
- 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 +83 -7
- 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 +197 -112
- 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 +93 -17
- 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 +144 -65
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +17 -19
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +7 -7
- 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const L = {
|
|
2
2
|
expand: "▶",
|
|
3
3
|
collapse: "▼",
|
|
4
4
|
sortAsc: "▲",
|
|
@@ -25,8 +25,11 @@ class P {
|
|
|
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 */
|
|
@@ -113,12 +116,28 @@ class P {
|
|
|
113
116
|
emit(e, t) {
|
|
114
117
|
this.grid?.dispatchEvent?.(new CustomEvent(e, { detail: t, bubbles: !0 }));
|
|
115
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 i = new CustomEvent(e, { detail: t, bubbles: !0, cancelable: !0 });
|
|
125
|
+
return this.grid?.dispatchEvent?.(i), i.defaultPrevented;
|
|
126
|
+
}
|
|
116
127
|
/**
|
|
117
128
|
* Request a re-render of the grid.
|
|
118
129
|
*/
|
|
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 P {
|
|
|
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
|
*/
|
|
@@ -184,8 +216,53 @@ class P {
|
|
|
184
216
|
*/
|
|
185
217
|
get gridIcons() {
|
|
186
218
|
const e = this.grid?.gridConfig?.icons ?? {};
|
|
187
|
-
return { ...
|
|
219
|
+
return { ...L, ...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;
|
|
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(), i = parseInt(t, 10);
|
|
261
|
+
if (!isNaN(i)) return i;
|
|
262
|
+
}
|
|
263
|
+
return 200;
|
|
188
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.
|
|
@@ -216,237 +293,237 @@ class P {
|
|
|
216
293
|
// #endregion
|
|
217
294
|
}
|
|
218
295
|
const m = {
|
|
219
|
-
sum: (
|
|
220
|
-
avg: (
|
|
221
|
-
const t =
|
|
222
|
-
return
|
|
296
|
+
sum: (o, e) => o.reduce((t, i) => t + (Number(i[e]) || 0), 0),
|
|
297
|
+
avg: (o, e) => {
|
|
298
|
+
const t = o.reduce((i, n) => i + (Number(n[e]) || 0), 0);
|
|
299
|
+
return o.length ? t / o.length : 0;
|
|
223
300
|
},
|
|
224
|
-
count: (
|
|
225
|
-
min: (
|
|
226
|
-
max: (
|
|
227
|
-
first: (
|
|
228
|
-
last: (
|
|
229
|
-
},
|
|
301
|
+
count: (o) => o.length,
|
|
302
|
+
min: (o, e) => Math.min(...o.map((t) => Number(t[e]) || 1 / 0)),
|
|
303
|
+
max: (o, e) => Math.max(...o.map((t) => Number(t[e]) || -1 / 0)),
|
|
304
|
+
first: (o, e) => o[0]?.[e],
|
|
305
|
+
last: (o, e) => o[o.length - 1]?.[e]
|
|
306
|
+
}, f = /* @__PURE__ */ new Map(), h = {
|
|
230
307
|
/**
|
|
231
308
|
* Register a custom aggregator function.
|
|
232
309
|
*/
|
|
233
|
-
register(
|
|
234
|
-
|
|
310
|
+
register(o, e) {
|
|
311
|
+
f.set(o, e);
|
|
235
312
|
},
|
|
236
313
|
/**
|
|
237
314
|
* Unregister a custom aggregator function.
|
|
238
315
|
*/
|
|
239
|
-
unregister(
|
|
240
|
-
|
|
316
|
+
unregister(o) {
|
|
317
|
+
f.delete(o);
|
|
241
318
|
},
|
|
242
319
|
/**
|
|
243
320
|
* Get an aggregator function by reference.
|
|
244
321
|
*/
|
|
245
|
-
get(
|
|
246
|
-
if (
|
|
247
|
-
return typeof
|
|
322
|
+
get(o) {
|
|
323
|
+
if (o !== void 0)
|
|
324
|
+
return typeof o == "function" ? o : f.get(o) ?? m[o];
|
|
248
325
|
},
|
|
249
326
|
/**
|
|
250
327
|
* Run an aggregator on a set of rows.
|
|
251
328
|
*/
|
|
252
|
-
run(
|
|
253
|
-
const n = this.get(
|
|
254
|
-
return n ? n(e, t,
|
|
329
|
+
run(o, e, t, i) {
|
|
330
|
+
const n = this.get(o);
|
|
331
|
+
return n ? n(e, t, i) : void 0;
|
|
255
332
|
},
|
|
256
333
|
/**
|
|
257
334
|
* Check if an aggregator exists.
|
|
258
335
|
*/
|
|
259
|
-
has(
|
|
260
|
-
return
|
|
336
|
+
has(o) {
|
|
337
|
+
return f.has(o) || o in m;
|
|
261
338
|
},
|
|
262
339
|
/**
|
|
263
340
|
* List all available aggregator names.
|
|
264
341
|
*/
|
|
265
342
|
list() {
|
|
266
|
-
return [...Object.keys(m), ...
|
|
267
|
-
}
|
|
268
|
-
},
|
|
269
|
-
sum: (
|
|
270
|
-
avg: (
|
|
271
|
-
count: (
|
|
272
|
-
min: (
|
|
273
|
-
max: (
|
|
274
|
-
first: (
|
|
275
|
-
last: (
|
|
343
|
+
return [...Object.keys(m), ...f.keys()];
|
|
344
|
+
}
|
|
345
|
+
}, A = {
|
|
346
|
+
sum: (o) => o.reduce((e, t) => e + t, 0),
|
|
347
|
+
avg: (o) => o.length ? o.reduce((e, t) => e + t, 0) / o.length : 0,
|
|
348
|
+
count: (o) => o.length,
|
|
349
|
+
min: (o) => o.length ? Math.min(...o) : 0,
|
|
350
|
+
max: (o) => o.length ? Math.max(...o) : 0,
|
|
351
|
+
first: (o) => o[0] ?? 0,
|
|
352
|
+
last: (o) => o[o.length - 1] ?? 0
|
|
276
353
|
};
|
|
277
|
-
function
|
|
278
|
-
return
|
|
354
|
+
function k(o) {
|
|
355
|
+
return A[o] ?? A.sum;
|
|
279
356
|
}
|
|
280
357
|
h.register.bind(h);
|
|
281
358
|
h.unregister.bind(h);
|
|
282
359
|
h.get.bind(h);
|
|
283
360
|
h.run.bind(h);
|
|
284
361
|
h.list.bind(h);
|
|
285
|
-
const
|
|
286
|
-
function S(
|
|
362
|
+
const N = k;
|
|
363
|
+
function S(o) {
|
|
287
364
|
const e = [];
|
|
288
|
-
return !
|
|
365
|
+
return !o.rowGroupFields?.length && !o.columnGroupFields?.length && e.push("At least one row or column group field is required"), o.valueFields?.length || e.push("At least one value field is required"), e;
|
|
289
366
|
}
|
|
290
|
-
function
|
|
291
|
-
return [...
|
|
367
|
+
function x(o, e) {
|
|
368
|
+
return [...o, e].join("|");
|
|
292
369
|
}
|
|
293
|
-
function
|
|
294
|
-
const t = e.rowGroupFields ?? [],
|
|
295
|
-
i,
|
|
296
|
-
t,
|
|
370
|
+
function K(o, e) {
|
|
371
|
+
const t = e.rowGroupFields ?? [], i = e.columnGroupFields ?? [], n = e.valueFields ?? [], r = I(o, i), a = G(
|
|
297
372
|
o,
|
|
373
|
+
t,
|
|
374
|
+
i,
|
|
298
375
|
r,
|
|
299
376
|
n,
|
|
300
377
|
0,
|
|
301
378
|
// starting depth
|
|
302
379
|
""
|
|
303
380
|
// parent key prefix
|
|
304
|
-
),
|
|
381
|
+
), s = D(a, r, n), l = Object.values(s).reduce((d, c) => d + c, 0);
|
|
305
382
|
return {
|
|
306
|
-
rows:
|
|
383
|
+
rows: a,
|
|
307
384
|
columnKeys: r,
|
|
308
|
-
totals:
|
|
385
|
+
totals: s,
|
|
309
386
|
grandTotal: l
|
|
310
387
|
};
|
|
311
388
|
}
|
|
312
|
-
function
|
|
389
|
+
function I(o, e) {
|
|
313
390
|
if (e.length === 0) return ["value"];
|
|
314
391
|
const t = /* @__PURE__ */ new Set();
|
|
315
|
-
for (const
|
|
316
|
-
const n = e.map((r) => String(
|
|
392
|
+
for (const i of o) {
|
|
393
|
+
const n = e.map((r) => String(i[r] ?? "")).join("|");
|
|
317
394
|
t.add(n);
|
|
318
395
|
}
|
|
319
396
|
return [...t].sort();
|
|
320
397
|
}
|
|
321
|
-
function
|
|
398
|
+
function V(o, e) {
|
|
322
399
|
const t = /* @__PURE__ */ new Map();
|
|
323
|
-
for (const
|
|
324
|
-
const n = String(
|
|
325
|
-
r ? r.push(
|
|
400
|
+
for (const i of o) {
|
|
401
|
+
const n = String(i[e] ?? ""), r = t.get(n);
|
|
402
|
+
r ? r.push(i) : t.set(n, [i]);
|
|
326
403
|
}
|
|
327
404
|
return t;
|
|
328
405
|
}
|
|
329
|
-
function
|
|
330
|
-
const
|
|
406
|
+
function G(o, e, t, i, n, r, a) {
|
|
407
|
+
const s = [];
|
|
331
408
|
if (e.length === 0) {
|
|
332
|
-
const u =
|
|
333
|
-
return
|
|
334
|
-
rowKey:
|
|
335
|
-
rowLabel:
|
|
409
|
+
const u = R(o, t, i, n), g = _(u);
|
|
410
|
+
return s.push({
|
|
411
|
+
rowKey: a || "all",
|
|
412
|
+
rowLabel: a || "All",
|
|
336
413
|
depth: r,
|
|
337
414
|
values: u,
|
|
338
415
|
total: g,
|
|
339
416
|
isGroup: !1,
|
|
340
|
-
rowCount:
|
|
341
|
-
}),
|
|
417
|
+
rowCount: o.length
|
|
418
|
+
}), s;
|
|
342
419
|
}
|
|
343
|
-
const l = e[0], d = e.slice(1), c = d.length > 0, p =
|
|
420
|
+
const l = e[0], d = e.slice(1), c = d.length > 0, p = V(o, l);
|
|
344
421
|
for (const [u, g] of p) {
|
|
345
|
-
const
|
|
346
|
-
let
|
|
347
|
-
c && (
|
|
422
|
+
const C = a ? `${a}|${u}` : u, y = R(g, t, i, n), E = _(y);
|
|
423
|
+
let F;
|
|
424
|
+
c && (F = G(
|
|
348
425
|
g,
|
|
349
426
|
d,
|
|
350
427
|
t,
|
|
351
|
-
|
|
428
|
+
i,
|
|
352
429
|
n,
|
|
353
430
|
r + 1,
|
|
354
|
-
|
|
355
|
-
)),
|
|
356
|
-
rowKey:
|
|
431
|
+
C
|
|
432
|
+
)), s.push({
|
|
433
|
+
rowKey: C,
|
|
357
434
|
rowLabel: u || "(blank)",
|
|
358
435
|
depth: r,
|
|
359
|
-
values:
|
|
360
|
-
total:
|
|
436
|
+
values: y,
|
|
437
|
+
total: E,
|
|
361
438
|
isGroup: c,
|
|
362
|
-
children:
|
|
439
|
+
children: F,
|
|
363
440
|
rowCount: g.length
|
|
364
441
|
});
|
|
365
442
|
}
|
|
366
|
-
return
|
|
443
|
+
return s;
|
|
367
444
|
}
|
|
368
|
-
function
|
|
445
|
+
function R(o, e, t, i) {
|
|
369
446
|
const n = {};
|
|
370
447
|
for (const r of t)
|
|
371
|
-
for (const
|
|
372
|
-
const l = (e.length > 0 ?
|
|
448
|
+
for (const a of i) {
|
|
449
|
+
const l = (e.length > 0 ? o.filter((u) => e.map((g) => String(u[g] ?? "")).join("|") === r) : o).map((u) => Number(u[a.field]) || 0), d = N(a.aggFunc), c = l.length > 0 ? d(l) : null, p = x([r], a.field);
|
|
373
450
|
n[p] = c;
|
|
374
451
|
}
|
|
375
452
|
return n;
|
|
376
453
|
}
|
|
377
|
-
function _(
|
|
454
|
+
function _(o) {
|
|
378
455
|
let e = 0;
|
|
379
|
-
for (const t of Object.values(
|
|
456
|
+
for (const t of Object.values(o))
|
|
380
457
|
e += t ?? 0;
|
|
381
458
|
return e;
|
|
382
459
|
}
|
|
383
|
-
function D(
|
|
384
|
-
const
|
|
460
|
+
function D(o, e, t) {
|
|
461
|
+
const i = {};
|
|
385
462
|
function n(r) {
|
|
386
|
-
for (const
|
|
387
|
-
if (!
|
|
388
|
-
for (const
|
|
463
|
+
for (const a of r)
|
|
464
|
+
if (!a.isGroup || !a.children?.length)
|
|
465
|
+
for (const s of e)
|
|
389
466
|
for (const l of t) {
|
|
390
|
-
const d =
|
|
391
|
-
|
|
467
|
+
const d = x([s], l.field);
|
|
468
|
+
i[d] = (i[d] ?? 0) + (a.values[d] ?? 0);
|
|
392
469
|
}
|
|
393
|
-
else
|
|
470
|
+
else a.children && n(a.children);
|
|
394
471
|
}
|
|
395
|
-
return n(
|
|
472
|
+
return n(o), i;
|
|
396
473
|
}
|
|
397
|
-
function
|
|
398
|
-
const
|
|
474
|
+
function q(o, e, t = !0) {
|
|
475
|
+
const i = [];
|
|
399
476
|
function n(r) {
|
|
400
|
-
|
|
401
|
-
const
|
|
402
|
-
if (r.children &&
|
|
403
|
-
for (const
|
|
404
|
-
n(
|
|
477
|
+
i.push(r);
|
|
478
|
+
const a = e ? e.has(r.rowKey) : t;
|
|
479
|
+
if (r.children && a)
|
|
480
|
+
for (const s of r.children)
|
|
481
|
+
n(s);
|
|
405
482
|
}
|
|
406
|
-
for (const r of
|
|
483
|
+
for (const r of o)
|
|
407
484
|
n(r);
|
|
408
|
-
return
|
|
485
|
+
return i;
|
|
409
486
|
}
|
|
410
|
-
function
|
|
487
|
+
function H(o) {
|
|
411
488
|
const e = [];
|
|
412
|
-
function t(
|
|
413
|
-
if (
|
|
414
|
-
for (const n of
|
|
489
|
+
function t(i) {
|
|
490
|
+
if (i.isGroup && e.push(i.rowKey), i.children)
|
|
491
|
+
for (const n of i.children)
|
|
415
492
|
t(n);
|
|
416
493
|
}
|
|
417
|
-
for (const
|
|
418
|
-
t(
|
|
494
|
+
for (const i of o)
|
|
495
|
+
t(i);
|
|
419
496
|
return e;
|
|
420
497
|
}
|
|
421
|
-
const
|
|
422
|
-
function z(
|
|
423
|
-
const n = new AbortController(), r = { config: e, callbacks:
|
|
424
|
-
return
|
|
425
|
-
n.abort(),
|
|
498
|
+
const M = ["sum", "avg", "count", "min", "max", "first", "last"];
|
|
499
|
+
function z(o, e, t, i) {
|
|
500
|
+
const n = new AbortController(), r = { config: e, callbacks: i, signal: n.signal }, a = document.createElement("div");
|
|
501
|
+
return a.className = "tbw-pivot-panel", a.appendChild(b("Options", () => W(t, r))), a.appendChild(b("Row Groups", () => T("rowGroups", r))), a.appendChild(b("Column Groups", () => T("columnGroups", r))), a.appendChild(b("Values", () => Z(r))), a.appendChild(b("Available Fields", () => j(r))), o.appendChild(a), () => {
|
|
502
|
+
n.abort(), a.remove();
|
|
426
503
|
};
|
|
427
504
|
}
|
|
428
|
-
function
|
|
505
|
+
function b(o, e) {
|
|
429
506
|
const t = document.createElement("div");
|
|
430
507
|
t.className = "tbw-pivot-section";
|
|
431
|
-
const
|
|
432
|
-
|
|
508
|
+
const i = document.createElement("div");
|
|
509
|
+
i.className = "tbw-pivot-section-header", i.textContent = o;
|
|
433
510
|
const n = document.createElement("div");
|
|
434
|
-
return n.className = "tbw-pivot-section-content", n.appendChild(e()), t.appendChild(
|
|
511
|
+
return n.className = "tbw-pivot-section-content", n.appendChild(e()), t.appendChild(i), t.appendChild(n), t;
|
|
435
512
|
}
|
|
436
|
-
function
|
|
437
|
-
const { config: t, callbacks:
|
|
438
|
-
r.className = "tbw-pivot-drop-zone", r.setAttribute("data-zone",
|
|
439
|
-
const
|
|
440
|
-
if (
|
|
441
|
-
const
|
|
442
|
-
|
|
513
|
+
function T(o, e) {
|
|
514
|
+
const { config: t, callbacks: i, signal: n } = e, r = document.createElement("div");
|
|
515
|
+
r.className = "tbw-pivot-drop-zone", r.setAttribute("data-zone", o);
|
|
516
|
+
const a = o === "rowGroups" ? t.rowGroupFields ?? [] : t.columnGroupFields ?? [];
|
|
517
|
+
if (a.length === 0) {
|
|
518
|
+
const s = document.createElement("div");
|
|
519
|
+
s.className = "tbw-pivot-placeholder", s.textContent = "Drag fields here or click to add", r.appendChild(s);
|
|
443
520
|
} else
|
|
444
|
-
for (const
|
|
445
|
-
r.appendChild(O(
|
|
521
|
+
for (const s of a)
|
|
522
|
+
r.appendChild(O(s, o, e));
|
|
446
523
|
return r.addEventListener(
|
|
447
524
|
"dragover",
|
|
448
|
-
(
|
|
449
|
-
|
|
525
|
+
(s) => {
|
|
526
|
+
s.preventDefault(), r.classList.add("drag-over");
|
|
450
527
|
},
|
|
451
528
|
{ signal: n }
|
|
452
529
|
), r.addEventListener(
|
|
@@ -457,30 +534,30 @@ function G(i, e) {
|
|
|
457
534
|
{ signal: n }
|
|
458
535
|
), r.addEventListener(
|
|
459
536
|
"drop",
|
|
460
|
-
(
|
|
461
|
-
|
|
462
|
-
const l =
|
|
463
|
-
l &&
|
|
537
|
+
(s) => {
|
|
538
|
+
s.preventDefault(), r.classList.remove("drag-over");
|
|
539
|
+
const l = s.dataTransfer?.getData("text/plain");
|
|
540
|
+
l && i.onAddFieldToZone(l, o);
|
|
464
541
|
},
|
|
465
542
|
{ signal: n }
|
|
466
543
|
), r;
|
|
467
544
|
}
|
|
468
|
-
function O(
|
|
469
|
-
const { callbacks:
|
|
545
|
+
function O(o, e, t) {
|
|
546
|
+
const { callbacks: i, signal: n } = t, r = document.createElement("div");
|
|
470
547
|
r.className = "tbw-pivot-field-chip", r.draggable = !0;
|
|
471
|
-
const
|
|
472
|
-
|
|
548
|
+
const a = i.getAvailableFields().find((d) => d.field === o), s = document.createElement("span");
|
|
549
|
+
s.className = "tbw-pivot-chip-label", s.textContent = a?.header ?? o;
|
|
473
550
|
const l = document.createElement("button");
|
|
474
551
|
return l.className = "tbw-pivot-chip-remove", l.innerHTML = "×", l.title = "Remove field", l.addEventListener(
|
|
475
552
|
"click",
|
|
476
553
|
(d) => {
|
|
477
|
-
d.stopPropagation(),
|
|
554
|
+
d.stopPropagation(), i.onRemoveFieldFromZone(o, e);
|
|
478
555
|
},
|
|
479
556
|
{ signal: n }
|
|
480
|
-
), r.appendChild(
|
|
557
|
+
), r.appendChild(s), r.appendChild(l), r.addEventListener(
|
|
481
558
|
"dragstart",
|
|
482
559
|
(d) => {
|
|
483
|
-
d.dataTransfer?.setData("text/plain",
|
|
560
|
+
d.dataTransfer?.setData("text/plain", o), d.dataTransfer?.setData("source-zone", e), r.classList.add("dragging");
|
|
484
561
|
},
|
|
485
562
|
{ signal: n }
|
|
486
563
|
), r.addEventListener(
|
|
@@ -491,189 +568,189 @@ function O(i, e, t) {
|
|
|
491
568
|
{ signal: n }
|
|
492
569
|
), r;
|
|
493
570
|
}
|
|
494
|
-
function Z(
|
|
495
|
-
const { config: e, callbacks: t, signal:
|
|
571
|
+
function Z(o) {
|
|
572
|
+
const { config: e, callbacks: t, signal: i } = o, n = document.createElement("div");
|
|
496
573
|
n.className = "tbw-pivot-drop-zone tbw-pivot-values-zone", n.setAttribute("data-zone", "values");
|
|
497
574
|
const r = e.valueFields ?? [];
|
|
498
575
|
if (r.length === 0) {
|
|
499
|
-
const
|
|
500
|
-
|
|
576
|
+
const a = document.createElement("div");
|
|
577
|
+
a.className = "tbw-pivot-placeholder", a.textContent = "Drag numeric fields here for aggregation", n.appendChild(a);
|
|
501
578
|
} else
|
|
502
|
-
for (const
|
|
503
|
-
n.appendChild($(
|
|
579
|
+
for (const a of r)
|
|
580
|
+
n.appendChild($(a, o));
|
|
504
581
|
return n.addEventListener(
|
|
505
582
|
"dragover",
|
|
506
|
-
(
|
|
507
|
-
|
|
583
|
+
(a) => {
|
|
584
|
+
a.preventDefault(), n.classList.add("drag-over");
|
|
508
585
|
},
|
|
509
|
-
{ signal:
|
|
586
|
+
{ signal: i }
|
|
510
587
|
), n.addEventListener(
|
|
511
588
|
"dragleave",
|
|
512
589
|
() => {
|
|
513
590
|
n.classList.remove("drag-over");
|
|
514
591
|
},
|
|
515
|
-
{ signal:
|
|
592
|
+
{ signal: i }
|
|
516
593
|
), n.addEventListener(
|
|
517
594
|
"drop",
|
|
518
|
-
(
|
|
519
|
-
|
|
520
|
-
const
|
|
521
|
-
|
|
595
|
+
(a) => {
|
|
596
|
+
a.preventDefault(), n.classList.remove("drag-over");
|
|
597
|
+
const s = a.dataTransfer?.getData("text/plain");
|
|
598
|
+
s && t.onAddValueField(s, "sum");
|
|
522
599
|
},
|
|
523
|
-
{ signal:
|
|
600
|
+
{ signal: i }
|
|
524
601
|
), n;
|
|
525
602
|
}
|
|
526
|
-
function $(
|
|
527
|
-
const { callbacks: t, signal:
|
|
603
|
+
function $(o, e) {
|
|
604
|
+
const { callbacks: t, signal: i } = e, n = document.createElement("div");
|
|
528
605
|
n.className = "tbw-pivot-field-chip tbw-pivot-value-chip";
|
|
529
|
-
const r = t.getAvailableFields().find((c) => c.field ===
|
|
530
|
-
|
|
531
|
-
const
|
|
532
|
-
|
|
606
|
+
const r = t.getAvailableFields().find((c) => c.field === o.field), a = document.createElement("div");
|
|
607
|
+
a.className = "tbw-pivot-value-label-wrapper";
|
|
608
|
+
const s = document.createElement("span");
|
|
609
|
+
s.className = "tbw-pivot-chip-label", s.textContent = r?.header ?? o.field;
|
|
533
610
|
const l = document.createElement("select");
|
|
534
611
|
l.className = "tbw-pivot-agg-select", l.title = "Aggregation function";
|
|
535
|
-
for (const c of
|
|
612
|
+
for (const c of M) {
|
|
536
613
|
const p = document.createElement("option");
|
|
537
|
-
p.value = c, p.textContent = c.toUpperCase(), p.selected = c ===
|
|
614
|
+
p.value = c, p.textContent = c.toUpperCase(), p.selected = c === o.aggFunc, l.appendChild(p);
|
|
538
615
|
}
|
|
539
616
|
l.addEventListener(
|
|
540
617
|
"change",
|
|
541
618
|
() => {
|
|
542
|
-
t.onUpdateValueAggFunc(
|
|
619
|
+
t.onUpdateValueAggFunc(o.field, l.value);
|
|
543
620
|
},
|
|
544
|
-
{ signal:
|
|
621
|
+
{ signal: i }
|
|
545
622
|
);
|
|
546
623
|
const d = document.createElement("button");
|
|
547
624
|
return d.className = "tbw-pivot-chip-remove", d.innerHTML = "×", d.title = "Remove value field", d.addEventListener(
|
|
548
625
|
"click",
|
|
549
626
|
(c) => {
|
|
550
|
-
c.stopPropagation(), t.onRemoveValueField(
|
|
627
|
+
c.stopPropagation(), t.onRemoveValueField(o.field);
|
|
551
628
|
},
|
|
552
|
-
{ signal:
|
|
553
|
-
),
|
|
629
|
+
{ signal: i }
|
|
630
|
+
), a.appendChild(s), a.appendChild(l), n.appendChild(a), n.appendChild(d), n;
|
|
554
631
|
}
|
|
555
|
-
function j(
|
|
556
|
-
const { config: e, callbacks: t, signal:
|
|
632
|
+
function j(o) {
|
|
633
|
+
const { config: e, callbacks: t, signal: i } = o, n = document.createElement("div");
|
|
557
634
|
n.className = "tbw-pivot-available-fields";
|
|
558
|
-
const r = t.getAvailableFields(),
|
|
635
|
+
const r = t.getAvailableFields(), a = /* @__PURE__ */ new Set([
|
|
559
636
|
...e.rowGroupFields ?? [],
|
|
560
637
|
...e.columnGroupFields ?? [],
|
|
561
638
|
...e.valueFields?.map((l) => l.field) ?? []
|
|
562
|
-
]),
|
|
563
|
-
if (
|
|
639
|
+
]), s = r.filter((l) => !a.has(l.field));
|
|
640
|
+
if (s.length === 0) {
|
|
564
641
|
const l = document.createElement("div");
|
|
565
642
|
l.className = "tbw-pivot-placeholder", l.textContent = "All fields are in use", n.appendChild(l);
|
|
566
643
|
} else
|
|
567
|
-
for (const l of
|
|
644
|
+
for (const l of s) {
|
|
568
645
|
const d = document.createElement("div");
|
|
569
646
|
d.className = "tbw-pivot-field-chip available", d.textContent = l.header, d.draggable = !0, d.title = `Drag to add "${l.field}" to a zone`, d.addEventListener(
|
|
570
647
|
"dragstart",
|
|
571
648
|
(c) => {
|
|
572
649
|
c.dataTransfer?.setData("text/plain", l.field), d.classList.add("dragging");
|
|
573
650
|
},
|
|
574
|
-
{ signal:
|
|
651
|
+
{ signal: i }
|
|
575
652
|
), d.addEventListener(
|
|
576
653
|
"dragend",
|
|
577
654
|
() => {
|
|
578
655
|
d.classList.remove("dragging");
|
|
579
656
|
},
|
|
580
|
-
{ signal:
|
|
657
|
+
{ signal: i }
|
|
581
658
|
), n.appendChild(d);
|
|
582
659
|
}
|
|
583
660
|
return n;
|
|
584
661
|
}
|
|
585
|
-
function
|
|
586
|
-
const { config: t, callbacks:
|
|
662
|
+
function W(o, e) {
|
|
663
|
+
const { config: t, callbacks: i, signal: n } = e, r = document.createElement("div");
|
|
587
664
|
return r.className = "tbw-pivot-options", r.appendChild(
|
|
588
|
-
|
|
665
|
+
w(
|
|
589
666
|
"Enable Pivot View",
|
|
590
|
-
|
|
591
|
-
(
|
|
592
|
-
|
|
667
|
+
o,
|
|
668
|
+
(a) => {
|
|
669
|
+
i.onTogglePivot(a);
|
|
593
670
|
},
|
|
594
671
|
n
|
|
595
672
|
)
|
|
596
673
|
), r.appendChild(
|
|
597
|
-
|
|
674
|
+
w(
|
|
598
675
|
"Show Row Totals",
|
|
599
676
|
t.showTotals ?? !0,
|
|
600
|
-
(
|
|
601
|
-
|
|
677
|
+
(a) => {
|
|
678
|
+
i.onOptionChange("showTotals", a);
|
|
602
679
|
},
|
|
603
680
|
n
|
|
604
681
|
)
|
|
605
682
|
), r.appendChild(
|
|
606
|
-
|
|
683
|
+
w(
|
|
607
684
|
"Show Grand Total",
|
|
608
685
|
t.showGrandTotal ?? !0,
|
|
609
|
-
(
|
|
610
|
-
|
|
686
|
+
(a) => {
|
|
687
|
+
i.onOptionChange("showGrandTotal", a);
|
|
611
688
|
},
|
|
612
689
|
n
|
|
613
690
|
)
|
|
614
691
|
), r;
|
|
615
692
|
}
|
|
616
|
-
function
|
|
693
|
+
function w(o, e, t, i) {
|
|
617
694
|
const n = document.createElement("label");
|
|
618
695
|
n.className = "tbw-pivot-checkbox";
|
|
619
696
|
const r = document.createElement("input");
|
|
620
|
-
r.type = "checkbox", r.checked = e, r.addEventListener("change", () => t(r.checked), { signal:
|
|
621
|
-
const
|
|
622
|
-
return
|
|
697
|
+
r.type = "checkbox", r.checked = e, r.addEventListener("change", () => t(r.checked), { signal: i });
|
|
698
|
+
const a = document.createElement("span");
|
|
699
|
+
return a.textContent = o, n.appendChild(r), n.appendChild(a), n;
|
|
623
700
|
}
|
|
624
|
-
function
|
|
625
|
-
return e.className = "pivot-group-row", e.setAttribute("data-pivot-depth", String(
|
|
701
|
+
function U(o, e, t) {
|
|
702
|
+
return e.className = "data-grid-row pivot-group-row", e.setAttribute("data-pivot-depth", String(o.__pivotDepth ?? 0)), e.setAttribute("data-pivot-key", String(o.__pivotRowKey ?? "")), e.setAttribute("role", "row"), e.innerHTML = "", t.columns.forEach((i, n) => {
|
|
626
703
|
const r = document.createElement("div");
|
|
627
|
-
if (r.className = "cell", r.setAttribute("data-col", String(n)), r.setAttribute("role", "gridcell"), n === 0) {
|
|
628
|
-
const
|
|
629
|
-
r.style.paddingLeft = `${
|
|
630
|
-
const
|
|
631
|
-
l.type = "button", l.className = "pivot-toggle", l.setAttribute("aria-label",
|
|
632
|
-
p.stopPropagation(), t.onToggle(
|
|
704
|
+
if (r.className = "cell", r.setAttribute("data-col", String(n)), r.setAttribute("data-row", String(t.rowIndex)), r.setAttribute("role", "gridcell"), n === 0) {
|
|
705
|
+
const a = Number(o.__pivotIndent) || 0;
|
|
706
|
+
r.style.paddingLeft = `${a}px`;
|
|
707
|
+
const s = String(o.__pivotRowKey), l = document.createElement("button");
|
|
708
|
+
l.type = "button", l.className = "pivot-toggle", l.setAttribute("aria-label", o.__pivotExpanded ? "Collapse group" : "Expand group"), t.setIcon(l, t.resolveIcon(o.__pivotExpanded ? "collapse" : "expand")), l.addEventListener("click", (p) => {
|
|
709
|
+
p.stopPropagation(), t.onToggle(s);
|
|
633
710
|
}), r.appendChild(l);
|
|
634
711
|
const d = document.createElement("span");
|
|
635
|
-
d.className = "pivot-label", d.textContent = String(
|
|
712
|
+
d.className = "pivot-label", d.textContent = String(o.__pivotLabel ?? ""), r.appendChild(d);
|
|
636
713
|
const c = document.createElement("span");
|
|
637
|
-
c.className = "pivot-count", c.textContent = ` (${Number(
|
|
714
|
+
c.className = "pivot-count", c.textContent = ` (${Number(o.__pivotRowCount) || 0})`, r.appendChild(c);
|
|
638
715
|
} else {
|
|
639
|
-
const
|
|
640
|
-
r.textContent =
|
|
716
|
+
const a = o[i.field];
|
|
717
|
+
r.textContent = a != null ? String(a) : "";
|
|
641
718
|
}
|
|
642
719
|
e.appendChild(r);
|
|
643
720
|
}), !0;
|
|
644
721
|
}
|
|
645
|
-
function
|
|
646
|
-
return e.className = "pivot-leaf-row", e.setAttribute("data-pivot-depth", String(
|
|
647
|
-
const
|
|
648
|
-
if (
|
|
649
|
-
const s = Number(
|
|
650
|
-
|
|
651
|
-
const
|
|
652
|
-
|
|
722
|
+
function B(o, e, t, i) {
|
|
723
|
+
return e.className = "data-grid-row pivot-leaf-row", e.setAttribute("data-pivot-depth", String(o.__pivotDepth ?? 0)), e.setAttribute("data-pivot-key", String(o.__pivotRowKey ?? "")), e.innerHTML = "", t.forEach((n, r) => {
|
|
724
|
+
const a = document.createElement("div");
|
|
725
|
+
if (a.className = "cell", a.setAttribute("data-col", String(r)), a.setAttribute("data-row", String(i)), a.setAttribute("role", "gridcell"), r === 0) {
|
|
726
|
+
const s = Number(o.__pivotIndent) || 0;
|
|
727
|
+
a.style.paddingLeft = `${s + 20}px`;
|
|
728
|
+
const l = document.createElement("span");
|
|
729
|
+
l.className = "pivot-label", l.textContent = String(o.__pivotLabel ?? ""), a.appendChild(l);
|
|
653
730
|
} else {
|
|
654
|
-
const s =
|
|
655
|
-
|
|
731
|
+
const s = o[n.field];
|
|
732
|
+
a.textContent = s != null ? String(s) : "";
|
|
656
733
|
}
|
|
657
|
-
e.appendChild(
|
|
734
|
+
e.appendChild(a);
|
|
658
735
|
}), !0;
|
|
659
736
|
}
|
|
660
|
-
function J(
|
|
661
|
-
return e.className = "pivot-grand-total-row", e.setAttribute("role", "presentation"), e.innerHTML = "", t.forEach((
|
|
737
|
+
function J(o, e, t) {
|
|
738
|
+
return e.className = "pivot-grand-total-row", e.setAttribute("role", "presentation"), e.innerHTML = "", t.forEach((i, n) => {
|
|
662
739
|
const r = document.createElement("div");
|
|
663
740
|
if (r.className = "cell", r.setAttribute("data-col", String(n)), n === 0) {
|
|
664
|
-
const
|
|
665
|
-
|
|
741
|
+
const a = document.createElement("span");
|
|
742
|
+
a.className = "pivot-label", a.textContent = "Grand Total", r.appendChild(a);
|
|
666
743
|
} else {
|
|
667
|
-
const
|
|
668
|
-
r.textContent =
|
|
744
|
+
const a = o[i.field];
|
|
745
|
+
r.textContent = a != null ? String(a) : "";
|
|
669
746
|
}
|
|
670
747
|
e.appendChild(r);
|
|
671
748
|
}), !0;
|
|
672
749
|
}
|
|
673
750
|
const Q = '.pivot-group-row{display:grid;grid-template-columns:var(--tbw-column-template);font-weight:600;background:var(--tbw-pivot-group-bg, var(--tbw-color-row-alt));min-height:var(--tbw-row-height);border-bottom:var(--tbw-row-divider)}.pivot-group-row:hover{background:var(--tbw-pivot-group-hover, var(--tbw-color-row-hover))}.pivot-leaf-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-pivot-leaf-bg, var(--tbw-color-bg));min-height:var(--tbw-row-height);border-bottom:var(--tbw-row-divider)}.pivot-grand-total-row{display:grid;grid-template-columns:var(--tbw-column-template);font-weight:700;background:var(--tbw-pivot-grand-total-bg, var(--tbw-color-header-bg));min-height:var(--tbw-row-height);border-top:2px solid var(--tbw-color-border-strong)}.pivot-grand-total-row>.cell{display:flex;align-items:center;padding:var(--tbw-cell-padding);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}.pivot-grand-total-row>.cell:last-child{border-right:0}.pivot-grand-total-footer{position:sticky;bottom:0;z-index:var(--tbw-z-layer-pinned-rows, 20);background:var(--tbw-pivot-grand-total-bg, var(--tbw-color-header-bg));min-width:fit-content}.pivot-group-row>.cell,.pivot-leaf-row>.cell{display:flex;align-items:center;padding:var(--tbw-cell-padding);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}.pivot-group-row>.cell:last-child,.pivot-leaf-row>.cell:last-child{border-right:0}.pivot-toggle{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;margin-right:6px;border:none;background:transparent;cursor:pointer;color:var(--tbw-pivot-toggle-color, var(--tbw-color-fg-muted));border-radius:var(--tbw-border-radius);transition:background .15s,color .15s}.pivot-toggle:hover{background:var(--tbw-pivot-toggle-hover-bg, var(--tbw-color-row-hover));color:var(--tbw-pivot-toggle-hover-color, var(--tbw-color-fg))}.pivot-toggle:focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}.pivot-label{font-weight:inherit}.pivot-count{color:var(--tbw-pivot-count-color, var(--tbw-color-fg-muted));font-size:.9em;font-weight:400}.pivot-total-row{font-weight:700;border-top:2px solid var(--tbw-pivot-border, var(--tbw-color-border-strong))}[data-pivot-depth="1"]{--tbw-pivot-depth: 1}[data-pivot-depth="2"]{--tbw-pivot-depth: 2}[data-pivot-depth="3"]{--tbw-pivot-depth: 3}[data-pivot-depth="4"]{--tbw-pivot-depth: 4}.tbw-pivot-panel{display:flex;flex-direction:column;gap:12px;padding:12px;height:100%;overflow-y:auto;font-size:13px}.tbw-pivot-section{border:1px solid var(--tbw-pivot-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);background:var(--tbw-pivot-section-bg, var(--tbw-color-bg))}.tbw-pivot-section-header{padding:8px 12px;font-weight:600;background:var(--tbw-pivot-header-bg, var(--tbw-color-header-bg));border-bottom:1px solid var(--tbw-pivot-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius) var(--tbw-border-radius) 0 0}.tbw-pivot-section-content{padding:8px}.tbw-pivot-toggle-wrapper{display:flex;align-items:center}.tbw-pivot-toggle-label{display:flex;align-items:center;gap:8px;cursor:pointer}.tbw-pivot-toggle-label input{width:16px;height:16px;cursor:pointer}.tbw-pivot-drop-zone{min-height:60px;padding:8px;border:2px dashed var(--tbw-pivot-drop-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);background:var(--tbw-pivot-drop-bg, var(--tbw-color-row-alt));display:flex;flex-wrap:wrap;gap:6px;align-content:flex-start;transition:all .15s ease}.tbw-pivot-drop-zone.drag-over{border-color:var(--tbw-color-accent);background:var(--tbw-pivot-drop-active, var(--tbw-focus-background))}.tbw-pivot-placeholder{color:var(--tbw-color-fg-muted);font-style:italic;padding:8px;text-align:center;width:100%}.tbw-pivot-field-chip{display:inline-flex;align-items:center;gap:6px;padding:4px 8px;background:var(--tbw-pivot-chip-bg, var(--tbw-color-header-bg));border:1px solid var(--tbw-pivot-chip-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);cursor:grab;font-size:12px;transition:all .15s ease}.tbw-pivot-field-chip:hover{background:var(--tbw-pivot-chip-hover, var(--tbw-color-row-hover));border-color:var(--tbw-color-accent)}.tbw-pivot-field-chip.available{background:var(--tbw-color-bg)}.tbw-pivot-field-chip.dragging{opacity:.5;cursor:grabbing}.tbw-pivot-chip-label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:120px}.tbw-pivot-chip-remove{display:flex;align-items:center;justify-content:center;width:16px;height:16px;padding:0;border:none;background:transparent;color:var(--tbw-color-fg-muted);font-size:14px;font-weight:700;cursor:pointer;border-radius:50%;transition:all .15s ease}.tbw-pivot-chip-remove:hover{background:var(--tbw-pivot-chip-remove-hover-bg, var(--tbw-color-accent));color:var(--tbw-pivot-chip-remove-hover-fg, var(--tbw-color-accent-fg))}.tbw-pivot-value-chip{padding:4px 8px}.tbw-pivot-value-label-wrapper{display:flex;align-items:center;gap:8px;flex:1;min-width:0}.tbw-pivot-agg-select{padding:2px 4px;font-size:11px;border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);background:var(--tbw-color-bg);cursor:pointer}.tbw-pivot-available-fields{display:flex;flex-wrap:wrap;gap:6px;min-height:40px}.tbw-pivot-options{display:flex;flex-direction:column;gap:8px}.tbw-pivot-checkbox{display:flex;align-items:center;gap:8px;cursor:pointer}.tbw-pivot-checkbox input{width:14px;height:14px;cursor:pointer}.pivot-group-row.tbw-pivot-slide-in,.pivot-leaf-row.tbw-pivot-slide-in{animation:tbw-pivot-slide-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-pivot-slide-in{0%{opacity:0;transform:translate(-8px)}to{opacity:1;transform:translate(0)}}.pivot-group-row.tbw-pivot-fade-in,.pivot-leaf-row.tbw-pivot-fade-in{animation:tbw-pivot-fade-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-pivot-fade-in{0%{opacity:0}to{opacity:1}}';
|
|
674
|
-
class
|
|
751
|
+
class v extends P {
|
|
675
752
|
name = "pivot";
|
|
676
|
-
|
|
753
|
+
styles = Q;
|
|
677
754
|
/** Tool panel ID for shell integration */
|
|
678
755
|
static PANEL_ID = "pivot";
|
|
679
756
|
get defaultConfig() {
|
|
@@ -704,17 +781,11 @@ class b extends P {
|
|
|
704
781
|
return (this.config.valueFields?.length ?? 0) > 0;
|
|
705
782
|
}
|
|
706
783
|
/**
|
|
707
|
-
* Get animation style
|
|
784
|
+
* Get expand/collapse animation style from plugin config.
|
|
785
|
+
* Uses base class isAnimationEnabled to respect grid-level settings.
|
|
708
786
|
*/
|
|
709
787
|
get animationStyle() {
|
|
710
|
-
|
|
711
|
-
if (t === !1 || t === "off") return !1;
|
|
712
|
-
if (t !== !0 && t !== "on") {
|
|
713
|
-
const o = this.shadowRoot?.host;
|
|
714
|
-
if (o && getComputedStyle(o).getPropertyValue("--tbw-animation-enabled").trim() === "0")
|
|
715
|
-
return !1;
|
|
716
|
-
}
|
|
717
|
-
return this.config.animation ?? "slide";
|
|
788
|
+
return this.isAnimationEnabled ? this.config.animation ?? "slide" : !1;
|
|
718
789
|
}
|
|
719
790
|
// #endregion
|
|
720
791
|
// #region Lifecycle
|
|
@@ -726,7 +797,7 @@ class b extends P {
|
|
|
726
797
|
getToolPanel() {
|
|
727
798
|
if ((this.config?.showToolPanel ?? this.userConfig?.showToolPanel ?? !0) !== !1)
|
|
728
799
|
return {
|
|
729
|
-
id:
|
|
800
|
+
id: v.PANEL_ID,
|
|
730
801
|
title: "Pivot",
|
|
731
802
|
icon: "⊞",
|
|
732
803
|
tooltip: "Configure pivot table",
|
|
@@ -742,55 +813,46 @@ class b extends P {
|
|
|
742
813
|
const t = S(this.config);
|
|
743
814
|
if (t.length > 0)
|
|
744
815
|
return this.warn(`Config errors: ${t.join(", ")}`), [...e];
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
for (const a of s)
|
|
748
|
-
this.expandedKeys.add(a);
|
|
749
|
-
}
|
|
750
|
-
if (this.pivotResult = I(e, this.config), this.expandedKeys.size === 0 && this.defaultExpanded) {
|
|
751
|
-
const s = w(this.pivotResult.rows);
|
|
752
|
-
for (const a of s)
|
|
753
|
-
this.expandedKeys.add(a);
|
|
754
|
-
}
|
|
755
|
-
const o = this.config.indentWidth ?? 20, n = H(
|
|
816
|
+
this.buildFieldHeaderMap(), this.defaultExpanded = this.config.defaultExpanded ?? !0, this.expandedKeys.size === 0 && this.defaultExpanded && this.pivotResult && this.expandAllKeys(), this.pivotResult = K(e, this.config), this.expandedKeys.size === 0 && this.defaultExpanded && this.expandAllKeys();
|
|
817
|
+
const i = this.config.indentWidth ?? 20, n = q(
|
|
756
818
|
this.pivotResult.rows,
|
|
757
819
|
this.expandedKeys,
|
|
758
820
|
this.defaultExpanded
|
|
759
|
-
).map((
|
|
760
|
-
__pivotRowKey:
|
|
761
|
-
__pivotLabel:
|
|
762
|
-
__pivotDepth:
|
|
763
|
-
__pivotIsGroup:
|
|
764
|
-
__pivotHasChildren: !!
|
|
765
|
-
__pivotExpanded: this.expandedKeys.has(
|
|
766
|
-
__pivotRowCount:
|
|
767
|
-
__pivotIndent:
|
|
768
|
-
__pivotTotal:
|
|
769
|
-
...
|
|
821
|
+
).map((a) => ({
|
|
822
|
+
__pivotRowKey: a.rowKey,
|
|
823
|
+
__pivotLabel: a.rowLabel,
|
|
824
|
+
__pivotDepth: a.depth,
|
|
825
|
+
__pivotIsGroup: a.isGroup,
|
|
826
|
+
__pivotHasChildren: !!a.children?.length,
|
|
827
|
+
__pivotExpanded: this.expandedKeys.has(a.rowKey),
|
|
828
|
+
__pivotRowCount: a.rowCount ?? 0,
|
|
829
|
+
__pivotIndent: a.depth * i,
|
|
830
|
+
__pivotTotal: a.total,
|
|
831
|
+
...a.values
|
|
770
832
|
}));
|
|
771
833
|
this.keysToAnimate.clear();
|
|
772
834
|
const r = /* @__PURE__ */ new Set();
|
|
773
|
-
for (const
|
|
774
|
-
const
|
|
775
|
-
r.add(
|
|
835
|
+
for (const a of n) {
|
|
836
|
+
const s = a.__pivotRowKey;
|
|
837
|
+
r.add(s), !this.previousVisibleKeys.has(s) && a.__pivotDepth > 0 && this.keysToAnimate.add(s);
|
|
776
838
|
}
|
|
777
839
|
return this.previousVisibleKeys = r, n;
|
|
778
840
|
}
|
|
779
841
|
processColumns(e) {
|
|
780
842
|
if (!this.isActive || !this.pivotResult)
|
|
781
843
|
return [...e];
|
|
782
|
-
const t = [],
|
|
844
|
+
const t = [], i = (this.config.rowGroupFields ?? []).map((n) => this.fieldHeaderMap.get(n) ?? n).join(" / ");
|
|
783
845
|
t.push({
|
|
784
846
|
field: "__pivotLabel",
|
|
785
|
-
header:
|
|
847
|
+
header: i || "Group",
|
|
786
848
|
width: 200
|
|
787
849
|
});
|
|
788
850
|
for (const n of this.pivotResult.columnKeys)
|
|
789
851
|
for (const r of this.config.valueFields ?? []) {
|
|
790
|
-
const
|
|
852
|
+
const a = x([n], r.field), s = r.header || this.fieldHeaderMap.get(r.field) || r.field;
|
|
791
853
|
t.push({
|
|
792
|
-
field:
|
|
793
|
-
header: `${n} - ${
|
|
854
|
+
field: a,
|
|
855
|
+
header: `${n} - ${s} (${r.aggFunc})`,
|
|
794
856
|
width: 120,
|
|
795
857
|
type: "number"
|
|
796
858
|
});
|
|
@@ -802,14 +864,15 @@ class b extends P {
|
|
|
802
864
|
type: "number"
|
|
803
865
|
}), t;
|
|
804
866
|
}
|
|
805
|
-
renderRow(e, t) {
|
|
806
|
-
const
|
|
807
|
-
return
|
|
867
|
+
renderRow(e, t, i) {
|
|
868
|
+
const n = e;
|
|
869
|
+
return n.__pivotRowKey && n.__pivotHasChildren ? U(n, t, {
|
|
808
870
|
columns: this.gridColumns,
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
871
|
+
rowIndex: i,
|
|
872
|
+
onToggle: (r) => this.toggle(r),
|
|
873
|
+
resolveIcon: (r) => this.resolveIcon(r),
|
|
874
|
+
setIcon: (r, a) => this.setIcon(r, a)
|
|
875
|
+
}) : n.__pivotRowKey !== void 0 && this.isActive ? B(n, t, this.gridColumns, i) : (this.cleanupPivotStyling(t), !1);
|
|
813
876
|
}
|
|
814
877
|
/**
|
|
815
878
|
* Remove pivot-specific classes, attributes, and inline styles from a row element.
|
|
@@ -819,16 +882,22 @@ class b extends P {
|
|
|
819
882
|
cleanupPivotStyling(e) {
|
|
820
883
|
(e.classList.contains("pivot-group-row") || e.classList.contains("pivot-leaf-row") || e.classList.contains("pivot-grand-total-row")) && (e.classList.remove("pivot-group-row", "pivot-leaf-row", "pivot-grand-total-row"), e.classList.add("data-grid-row"), e.removeAttribute("data-pivot-depth"), e.innerHTML = "");
|
|
821
884
|
}
|
|
885
|
+
onKeyDown(e) {
|
|
886
|
+
if (e.key !== " " || !this.isActive) return;
|
|
887
|
+
const t = this.grid._focusRow, i = this.rows[t];
|
|
888
|
+
if (!(!i?.__pivotIsGroup || !i.__pivotHasChildren))
|
|
889
|
+
return e.preventDefault(), this.toggle(i.__pivotRowKey), this.requestRenderWithFocus(), !0;
|
|
890
|
+
}
|
|
822
891
|
afterRender() {
|
|
823
892
|
this.isActive && this.config.showGrandTotal && this.pivotResult ? this.renderGrandTotalFooter() : this.cleanupGrandTotalFooter();
|
|
824
893
|
const e = this.animationStyle;
|
|
825
894
|
if (e === !1 || this.keysToAnimate.size === 0) return;
|
|
826
895
|
const t = this.shadowRoot?.querySelector(".rows");
|
|
827
896
|
if (!t) return;
|
|
828
|
-
const
|
|
897
|
+
const i = e === "fade" ? "tbw-pivot-fade-in" : "tbw-pivot-slide-in";
|
|
829
898
|
for (const n of t.querySelectorAll(".pivot-group-row, .pivot-leaf-row")) {
|
|
830
899
|
const r = n.dataset.pivotKey;
|
|
831
|
-
r && this.keysToAnimate.has(r) && (n.classList.add(
|
|
900
|
+
r && this.keysToAnimate.has(r) && (n.classList.add(i), n.addEventListener("animationend", () => n.classList.remove(i), { once: !0 }));
|
|
832
901
|
}
|
|
833
902
|
this.keysToAnimate.clear();
|
|
834
903
|
}
|
|
@@ -842,14 +911,14 @@ class b extends P {
|
|
|
842
911
|
const t = e.querySelector(".tbw-scroll-area") ?? e.querySelector(".tbw-grid-content") ?? e.children[0];
|
|
843
912
|
if (!t) return;
|
|
844
913
|
this.grandTotalFooter || (this.grandTotalFooter = document.createElement("div"), this.grandTotalFooter.className = "pivot-grand-total-footer", t.appendChild(this.grandTotalFooter));
|
|
845
|
-
const
|
|
914
|
+
const i = {
|
|
846
915
|
__pivotRowKey: "__grandTotal",
|
|
847
916
|
__pivotLabel: "Grand Total",
|
|
848
917
|
__pivotIsGrandTotal: !0,
|
|
849
918
|
__pivotTotal: this.pivotResult.grandTotal,
|
|
850
919
|
...this.pivotResult.totals
|
|
851
920
|
};
|
|
852
|
-
J(
|
|
921
|
+
J(i, this.grandTotalFooter, this.gridColumns);
|
|
853
922
|
}
|
|
854
923
|
/**
|
|
855
924
|
* Remove the grand total footer element.
|
|
@@ -869,16 +938,20 @@ class b extends P {
|
|
|
869
938
|
this.expandedKeys.delete(e), this.requestRender();
|
|
870
939
|
}
|
|
871
940
|
expandAll() {
|
|
872
|
-
|
|
873
|
-
const e = w(this.pivotResult.rows);
|
|
874
|
-
for (const t of e)
|
|
875
|
-
this.expandedKeys.add(t);
|
|
876
|
-
this.requestRender();
|
|
877
|
-
}
|
|
941
|
+
this.expandAllKeys(), this.requestRender();
|
|
878
942
|
}
|
|
879
943
|
collapseAll() {
|
|
880
944
|
this.expandedKeys.clear(), this.requestRender();
|
|
881
945
|
}
|
|
946
|
+
/**
|
|
947
|
+
* Add all group keys from the current pivot result to expandedKeys.
|
|
948
|
+
*/
|
|
949
|
+
expandAllKeys() {
|
|
950
|
+
if (!this.pivotResult) return;
|
|
951
|
+
const e = H(this.pivotResult.rows);
|
|
952
|
+
for (const t of e)
|
|
953
|
+
this.expandedKeys.add(t);
|
|
954
|
+
}
|
|
882
955
|
isExpanded(e) {
|
|
883
956
|
return this.expandedKeys.has(e);
|
|
884
957
|
}
|
|
@@ -910,23 +983,42 @@ class b extends P {
|
|
|
910
983
|
}
|
|
911
984
|
// #endregion
|
|
912
985
|
// #region Tool Panel API
|
|
986
|
+
/**
|
|
987
|
+
* Show the pivot tool panel.
|
|
988
|
+
* Opens the tool panel and ensures this section is expanded.
|
|
989
|
+
*/
|
|
913
990
|
showPanel() {
|
|
914
|
-
this.grid.openToolPanel(
|
|
991
|
+
this.grid.openToolPanel(), this.grid.expandedToolPanelSections.includes(v.PANEL_ID) || this.grid.toggleToolPanelSection(v.PANEL_ID);
|
|
915
992
|
}
|
|
993
|
+
/**
|
|
994
|
+
* Hide the tool panel.
|
|
995
|
+
*/
|
|
916
996
|
hidePanel() {
|
|
917
997
|
this.grid.closeToolPanel();
|
|
918
998
|
}
|
|
999
|
+
/**
|
|
1000
|
+
* Toggle the pivot tool panel section.
|
|
1001
|
+
*/
|
|
919
1002
|
togglePanel() {
|
|
920
|
-
this.grid.
|
|
1003
|
+
this.grid.isToolPanelOpen || this.grid.openToolPanel(), this.grid.toggleToolPanelSection(v.PANEL_ID);
|
|
921
1004
|
}
|
|
1005
|
+
/**
|
|
1006
|
+
* Check if the pivot panel section is currently expanded.
|
|
1007
|
+
*/
|
|
922
1008
|
isPanelVisible() {
|
|
923
|
-
return this.grid.
|
|
1009
|
+
return this.grid.isToolPanelOpen && this.grid.expandedToolPanelSections.includes(v.PANEL_ID);
|
|
924
1010
|
}
|
|
925
1011
|
// #endregion
|
|
926
1012
|
// #region Private Helpers
|
|
927
1013
|
get gridColumns() {
|
|
928
1014
|
return this.grid.columns ?? [];
|
|
929
1015
|
}
|
|
1016
|
+
/**
|
|
1017
|
+
* Refresh pivot and update tool panel if active.
|
|
1018
|
+
*/
|
|
1019
|
+
refreshIfActive() {
|
|
1020
|
+
this.isActive && this.refresh(), this.refreshPanel();
|
|
1021
|
+
}
|
|
930
1022
|
buildFieldHeaderMap() {
|
|
931
1023
|
const e = this.getAvailableFields();
|
|
932
1024
|
this.fieldHeaderMap.clear();
|
|
@@ -937,12 +1029,11 @@ class b extends P {
|
|
|
937
1029
|
return this.originalColumns.length > 0 ? this.originalColumns : this.captureOriginalColumns();
|
|
938
1030
|
}
|
|
939
1031
|
captureOriginalColumns() {
|
|
940
|
-
const e = this.grid;
|
|
941
1032
|
try {
|
|
942
|
-
const
|
|
943
|
-
return this.originalColumns =
|
|
944
|
-
field:
|
|
945
|
-
header:
|
|
1033
|
+
const e = this.grid.getAllColumns?.() ?? this.grid.columns ?? [];
|
|
1034
|
+
return this.originalColumns = e.filter((t) => !t.field.startsWith("__pivot")).map((t) => ({
|
|
1035
|
+
field: t.field,
|
|
1036
|
+
header: t.header ?? t.field
|
|
946
1037
|
})), this.originalColumns;
|
|
947
1038
|
} catch {
|
|
948
1039
|
return [];
|
|
@@ -951,16 +1042,16 @@ class b extends P {
|
|
|
951
1042
|
renderPanel(e) {
|
|
952
1043
|
this.panelContainer = e, this.originalColumns.length === 0 && this.captureOriginalColumns();
|
|
953
1044
|
const t = {
|
|
954
|
-
onTogglePivot: (
|
|
955
|
-
|
|
1045
|
+
onTogglePivot: (i) => {
|
|
1046
|
+
i ? this.enablePivot() : this.disablePivot(), this.refreshPanel();
|
|
956
1047
|
},
|
|
957
|
-
onAddFieldToZone: (
|
|
958
|
-
onRemoveFieldFromZone: (
|
|
959
|
-
onAddValueField: (
|
|
960
|
-
onRemoveValueField: (
|
|
961
|
-
onUpdateValueAggFunc: (
|
|
962
|
-
onOptionChange: (
|
|
963
|
-
this.config[
|
|
1048
|
+
onAddFieldToZone: (i, n) => this.addFieldToZone(i, n),
|
|
1049
|
+
onRemoveFieldFromZone: (i, n) => this.removeFieldFromZone(i, n),
|
|
1050
|
+
onAddValueField: (i, n) => this.addValueField(i, n),
|
|
1051
|
+
onRemoveValueField: (i) => this.removeValueField(i),
|
|
1052
|
+
onUpdateValueAggFunc: (i, n) => this.updateValueAggFunc(i, n),
|
|
1053
|
+
onOptionChange: (i, n) => {
|
|
1054
|
+
this.config[i] = n, this.isActive && this.refresh();
|
|
964
1055
|
},
|
|
965
1056
|
getAvailableFields: () => this.getAvailableFields()
|
|
966
1057
|
};
|
|
@@ -971,37 +1062,34 @@ class b extends P {
|
|
|
971
1062
|
}
|
|
972
1063
|
addFieldToZone(e, t) {
|
|
973
1064
|
if (t === "rowGroups") {
|
|
974
|
-
const
|
|
975
|
-
|
|
1065
|
+
const i = this.config.rowGroupFields ?? [];
|
|
1066
|
+
i.includes(e) || (this.config.rowGroupFields = [...i, e]);
|
|
976
1067
|
} else {
|
|
977
|
-
const
|
|
978
|
-
|
|
1068
|
+
const i = this.config.columnGroupFields ?? [];
|
|
1069
|
+
i.includes(e) || (this.config.columnGroupFields = [...i, e]);
|
|
979
1070
|
}
|
|
980
|
-
this.removeFromOtherZones(e, t), this.
|
|
1071
|
+
this.removeFromOtherZones(e, t), this.refreshIfActive();
|
|
981
1072
|
}
|
|
982
1073
|
removeFieldFromZone(e, t) {
|
|
983
|
-
t === "rowGroups" ? this.config.rowGroupFields = (this.config.rowGroupFields ?? []).filter((
|
|
1074
|
+
t === "rowGroups" ? this.config.rowGroupFields = (this.config.rowGroupFields ?? []).filter((i) => i !== e) : this.config.columnGroupFields = (this.config.columnGroupFields ?? []).filter((i) => i !== e), this.refreshIfActive();
|
|
984
1075
|
}
|
|
985
1076
|
removeFromOtherZones(e, t) {
|
|
986
|
-
t !== "rowGroups" && (this.config.rowGroupFields = (this.config.rowGroupFields ?? []).filter((
|
|
1077
|
+
t !== "rowGroups" && (this.config.rowGroupFields = (this.config.rowGroupFields ?? []).filter((i) => i !== e)), t !== "columnGroups" && (this.config.columnGroupFields = (this.config.columnGroupFields ?? []).filter((i) => i !== e)), t !== "values" && (this.config.valueFields = (this.config.valueFields ?? []).filter((i) => i.field !== e));
|
|
987
1078
|
}
|
|
988
1079
|
addValueField(e, t) {
|
|
989
|
-
const
|
|
990
|
-
|
|
1080
|
+
const i = this.config.valueFields ?? [];
|
|
1081
|
+
i.some((n) => n.field === e) || (this.config.valueFields = [...i, { field: e, aggFunc: t }]), this.removeFromOtherZones(e, "values"), this.refreshIfActive();
|
|
991
1082
|
}
|
|
992
1083
|
removeValueField(e) {
|
|
993
|
-
this.config.valueFields = (this.config.valueFields ?? []).filter((t) => t.field !== e), this.
|
|
1084
|
+
this.config.valueFields = (this.config.valueFields ?? []).filter((t) => t.field !== e), this.refreshIfActive();
|
|
994
1085
|
}
|
|
995
1086
|
updateValueAggFunc(e, t) {
|
|
996
|
-
const
|
|
997
|
-
n >= 0 && (
|
|
1087
|
+
const i = this.config.valueFields ?? [], n = i.findIndex((r) => r.field === e);
|
|
1088
|
+
n >= 0 && (i[n] = { ...i[n], aggFunc: t }, this.config.valueFields = [...i]), this.isActive && this.refresh();
|
|
998
1089
|
}
|
|
999
1090
|
// #endregion
|
|
1000
|
-
// #region Styles
|
|
1001
|
-
styles = Q;
|
|
1002
|
-
// #endregion
|
|
1003
1091
|
}
|
|
1004
1092
|
export {
|
|
1005
|
-
|
|
1093
|
+
v as PivotPlugin
|
|
1006
1094
|
};
|
|
1007
1095
|
//# sourceMappingURL=index.js.map
|