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