@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 R = {
|
|
2
2
|
expand: "▶",
|
|
3
3
|
collapse: "▼",
|
|
4
4
|
sortAsc: "▲",
|
|
@@ -8,7 +8,7 @@ const A = {
|
|
|
8
8
|
dragHandle: "⋮⋮",
|
|
9
9
|
toolPanel: "☰"
|
|
10
10
|
};
|
|
11
|
-
class
|
|
11
|
+
class A {
|
|
12
12
|
/**
|
|
13
13
|
* Plugin dependencies - declare other plugins this one requires.
|
|
14
14
|
*
|
|
@@ -25,8 +25,11 @@ class R {
|
|
|
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 */
|
|
@@ -110,8 +113,16 @@ class R {
|
|
|
110
113
|
/**
|
|
111
114
|
* Emit a custom event from the grid.
|
|
112
115
|
*/
|
|
113
|
-
emit(t,
|
|
114
|
-
this.grid?.dispatchEvent?.(new CustomEvent(t, { detail:
|
|
116
|
+
emit(t, e) {
|
|
117
|
+
this.grid?.dispatchEvent?.(new CustomEvent(t, { detail: e, bubbles: !0 }));
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Emit a cancelable custom event from the grid.
|
|
121
|
+
* @returns `true` if the event was cancelled (preventDefault called), `false` otherwise
|
|
122
|
+
*/
|
|
123
|
+
emitCancelable(t, e) {
|
|
124
|
+
const i = new CustomEvent(t, { detail: e, bubbles: !0, cancelable: !0 });
|
|
125
|
+
return this.grid?.dispatchEvent?.(i), i.defaultPrevented;
|
|
115
126
|
}
|
|
116
127
|
/**
|
|
117
128
|
* Request a re-render of the grid.
|
|
@@ -119,6 +130,14 @@ class R {
|
|
|
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 R {
|
|
|
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 R {
|
|
|
184
216
|
*/
|
|
185
217
|
get gridIcons() {
|
|
186
218
|
const t = this.grid?.gridConfig?.icons ?? {};
|
|
187
|
-
return { ...
|
|
219
|
+
return { ...R, ...t };
|
|
188
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 t = this.grid?.effectiveConfig?.animation?.mode ?? "reduced-motion";
|
|
240
|
+
if (t === !1 || t === "off") return !1;
|
|
241
|
+
if (t === !0 || t === "on") return !0;
|
|
242
|
+
const e = this.shadowRoot?.host;
|
|
243
|
+
return e ? getComputedStyle(e).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 t = this.shadowRoot?.host;
|
|
259
|
+
if (t) {
|
|
260
|
+
const e = getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(), i = parseInt(e, 10);
|
|
261
|
+
if (!isNaN(i)) return i;
|
|
262
|
+
}
|
|
263
|
+
return 200;
|
|
264
|
+
}
|
|
265
|
+
// #endregion
|
|
189
266
|
/**
|
|
190
267
|
* Resolve an icon value to string or HTMLElement.
|
|
191
268
|
* Checks plugin config first, then grid-level icons, then defaults.
|
|
@@ -194,8 +271,8 @@ class R {
|
|
|
194
271
|
* @param pluginOverride - Optional plugin-level override
|
|
195
272
|
* @returns The resolved icon value
|
|
196
273
|
*/
|
|
197
|
-
resolveIcon(t,
|
|
198
|
-
return
|
|
274
|
+
resolveIcon(t, e) {
|
|
275
|
+
return e !== void 0 ? e : this.gridIcons[t];
|
|
199
276
|
}
|
|
200
277
|
/**
|
|
201
278
|
* Set an icon value on an element.
|
|
@@ -204,8 +281,8 @@ class R {
|
|
|
204
281
|
* @param element - The element to set the icon on
|
|
205
282
|
* @param icon - The icon value (string or HTMLElement)
|
|
206
283
|
*/
|
|
207
|
-
setIcon(t,
|
|
208
|
-
typeof
|
|
284
|
+
setIcon(t, e) {
|
|
285
|
+
typeof e == "string" ? t.innerHTML = e : e instanceof HTMLElement && (t.innerHTML = "", t.appendChild(e.cloneNode(!0)));
|
|
209
286
|
}
|
|
210
287
|
/**
|
|
211
288
|
* Log a warning message.
|
|
@@ -216,87 +293,87 @@ class R {
|
|
|
216
293
|
// #endregion
|
|
217
294
|
}
|
|
218
295
|
const p = {
|
|
219
|
-
sum: (
|
|
220
|
-
avg: (
|
|
221
|
-
const
|
|
222
|
-
return
|
|
296
|
+
sum: (n, t) => n.reduce((e, i) => e + (Number(i[t]) || 0), 0),
|
|
297
|
+
avg: (n, t) => {
|
|
298
|
+
const e = n.reduce((i, r) => i + (Number(r[t]) || 0), 0);
|
|
299
|
+
return n.length ? e / n.length : 0;
|
|
223
300
|
},
|
|
224
|
-
count: (
|
|
225
|
-
min: (
|
|
226
|
-
max: (
|
|
227
|
-
first: (
|
|
228
|
-
last: (
|
|
229
|
-
},
|
|
301
|
+
count: (n) => n.length,
|
|
302
|
+
min: (n, t) => Math.min(...n.map((e) => Number(e[t]) || 1 / 0)),
|
|
303
|
+
max: (n, t) => Math.max(...n.map((e) => Number(e[t]) || -1 / 0)),
|
|
304
|
+
first: (n, t) => n[0]?.[t],
|
|
305
|
+
last: (n, t) => n[n.length - 1]?.[t]
|
|
306
|
+
}, f = /* @__PURE__ */ new Map(), d = {
|
|
230
307
|
/**
|
|
231
308
|
* Register a custom aggregator function.
|
|
232
309
|
*/
|
|
233
|
-
register(
|
|
234
|
-
|
|
310
|
+
register(n, t) {
|
|
311
|
+
f.set(n, t);
|
|
235
312
|
},
|
|
236
313
|
/**
|
|
237
314
|
* Unregister a custom aggregator function.
|
|
238
315
|
*/
|
|
239
|
-
unregister(
|
|
240
|
-
|
|
316
|
+
unregister(n) {
|
|
317
|
+
f.delete(n);
|
|
241
318
|
},
|
|
242
319
|
/**
|
|
243
320
|
* Get an aggregator function by reference.
|
|
244
321
|
*/
|
|
245
|
-
get(
|
|
246
|
-
if (
|
|
247
|
-
return typeof
|
|
322
|
+
get(n) {
|
|
323
|
+
if (n !== void 0)
|
|
324
|
+
return typeof n == "function" ? n : f.get(n) ?? p[n];
|
|
248
325
|
},
|
|
249
326
|
/**
|
|
250
327
|
* Run an aggregator on a set of rows.
|
|
251
328
|
*/
|
|
252
|
-
run(
|
|
253
|
-
const r = this.get(
|
|
254
|
-
return r ? r(t,
|
|
329
|
+
run(n, t, e, i) {
|
|
330
|
+
const r = this.get(n);
|
|
331
|
+
return r ? r(t, e, i) : void 0;
|
|
255
332
|
},
|
|
256
333
|
/**
|
|
257
334
|
* Check if an aggregator exists.
|
|
258
335
|
*/
|
|
259
|
-
has(
|
|
260
|
-
return
|
|
336
|
+
has(n) {
|
|
337
|
+
return f.has(n) || n in p;
|
|
261
338
|
},
|
|
262
339
|
/**
|
|
263
340
|
* List all available aggregator names.
|
|
264
341
|
*/
|
|
265
342
|
list() {
|
|
266
|
-
return [...Object.keys(p), ...
|
|
343
|
+
return [...Object.keys(p), ...f.keys()];
|
|
267
344
|
}
|
|
268
345
|
};
|
|
269
346
|
d.register.bind(d);
|
|
270
347
|
d.unregister.bind(d);
|
|
271
|
-
const
|
|
348
|
+
const b = d.get.bind(d);
|
|
272
349
|
d.run.bind(d);
|
|
273
350
|
d.list.bind(d);
|
|
274
|
-
function E(
|
|
275
|
-
return typeof
|
|
351
|
+
function E(n) {
|
|
352
|
+
return typeof n == "object" && n !== null && "aggFunc" in n;
|
|
276
353
|
}
|
|
277
|
-
function m(
|
|
278
|
-
const
|
|
279
|
-
|
|
354
|
+
function m(n, t) {
|
|
355
|
+
const e = document.createElement("div");
|
|
356
|
+
e.className = "tbw-pinned-rows", e.setAttribute("role", "presentation"), e.setAttribute("aria-live", "polite");
|
|
280
357
|
const i = document.createElement("div");
|
|
281
358
|
i.className = "tbw-pinned-rows-left";
|
|
282
359
|
const r = document.createElement("div");
|
|
283
360
|
r.className = "tbw-pinned-rows-center";
|
|
284
361
|
const s = document.createElement("div");
|
|
285
|
-
if (s.className = "tbw-pinned-rows-right",
|
|
362
|
+
if (s.className = "tbw-pinned-rows-right", n.showRowCount !== !1) {
|
|
286
363
|
const o = document.createElement("span");
|
|
287
364
|
o.className = "tbw-status-panel tbw-status-panel-row-count", o.textContent = `Total: ${t.totalRows} rows`, i.appendChild(o);
|
|
288
365
|
}
|
|
289
|
-
if (
|
|
366
|
+
if (n.showFilteredCount && t.filteredRows !== t.totalRows) {
|
|
290
367
|
const o = document.createElement("span");
|
|
291
368
|
o.className = "tbw-status-panel tbw-status-panel-filtered-count", o.textContent = `Filtered: ${t.filteredRows}`, i.appendChild(o);
|
|
292
369
|
}
|
|
293
|
-
if (
|
|
370
|
+
if (n.showSelectedCount && t.selectedRows > 0) {
|
|
294
371
|
const o = document.createElement("span");
|
|
295
372
|
o.className = "tbw-status-panel tbw-status-panel-selected-count", o.textContent = `Selected: ${t.selectedRows}`, s.appendChild(o);
|
|
296
373
|
}
|
|
297
|
-
if (
|
|
298
|
-
for (const o of
|
|
299
|
-
const a =
|
|
374
|
+
if (n.customPanels)
|
|
375
|
+
for (const o of n.customPanels) {
|
|
376
|
+
const a = y(o, t);
|
|
300
377
|
switch (o.position) {
|
|
301
378
|
case "left":
|
|
302
379
|
i.appendChild(a);
|
|
@@ -309,62 +386,62 @@ function m(e, t) {
|
|
|
309
386
|
break;
|
|
310
387
|
}
|
|
311
388
|
}
|
|
312
|
-
return
|
|
389
|
+
return e.appendChild(i), e.appendChild(r), e.appendChild(s), e;
|
|
313
390
|
}
|
|
314
|
-
function
|
|
391
|
+
function w(n) {
|
|
315
392
|
const t = document.createElement("div");
|
|
316
|
-
return t.className = `tbw-aggregation-rows tbw-aggregation-rows-${
|
|
393
|
+
return t.className = `tbw-aggregation-rows tbw-aggregation-rows-${n}`, t.setAttribute("role", "presentation"), t;
|
|
317
394
|
}
|
|
318
|
-
function C(
|
|
319
|
-
|
|
395
|
+
function C(n, t, e, i) {
|
|
396
|
+
n.innerHTML = "";
|
|
320
397
|
for (const r of t) {
|
|
321
398
|
const s = document.createElement("div");
|
|
322
399
|
if (s.className = "tbw-aggregation-row", s.setAttribute("role", "presentation"), r.id && s.setAttribute("data-aggregation-id", r.id), r.fullWidth) {
|
|
323
400
|
const o = document.createElement("div");
|
|
324
401
|
o.className = "tbw-aggregation-cell tbw-aggregation-cell-full", o.style.gridColumn = "1 / -1", o.textContent = r.label || "", s.appendChild(o);
|
|
325
402
|
} else
|
|
326
|
-
for (const o of
|
|
403
|
+
for (const o of e) {
|
|
327
404
|
const a = document.createElement("div");
|
|
328
405
|
a.className = "tbw-aggregation-cell", a.setAttribute("data-field", o.field);
|
|
329
|
-
let l,
|
|
406
|
+
let l, u;
|
|
330
407
|
const h = r.aggregators?.[o.field];
|
|
331
408
|
if (h)
|
|
332
409
|
if (E(h)) {
|
|
333
|
-
const g =
|
|
334
|
-
g && (l = g(i, o.field, o)),
|
|
410
|
+
const g = b(h.aggFunc);
|
|
411
|
+
g && (l = g(i, o.field, o)), u = h.formatter;
|
|
335
412
|
} else {
|
|
336
|
-
const g =
|
|
413
|
+
const g = b(h);
|
|
337
414
|
g && (l = g(i, o.field, o));
|
|
338
415
|
}
|
|
339
416
|
else if (r.cells && Object.prototype.hasOwnProperty.call(r.cells, o.field)) {
|
|
340
417
|
const g = r.cells[o.field];
|
|
341
418
|
typeof g == "function" ? l = g(i, o.field, o) : l = g;
|
|
342
419
|
}
|
|
343
|
-
l != null ? a.textContent =
|
|
420
|
+
l != null ? a.textContent = u ? u(l, o.field, o) : String(l) : a.textContent = "", s.appendChild(a);
|
|
344
421
|
}
|
|
345
|
-
|
|
422
|
+
n.appendChild(s);
|
|
346
423
|
}
|
|
347
424
|
}
|
|
348
|
-
function
|
|
349
|
-
const
|
|
350
|
-
|
|
351
|
-
const i =
|
|
352
|
-
return typeof i == "string" ?
|
|
425
|
+
function y(n, t) {
|
|
426
|
+
const e = document.createElement("div");
|
|
427
|
+
e.className = "tbw-status-panel tbw-status-panel-custom", e.id = `status-panel-${n.id}`;
|
|
428
|
+
const i = n.render(t);
|
|
429
|
+
return typeof i == "string" ? e.innerHTML = i : e.appendChild(i), e;
|
|
353
430
|
}
|
|
354
|
-
function v(
|
|
431
|
+
function v(n, t, e, i, r) {
|
|
355
432
|
return {
|
|
356
|
-
totalRows:
|
|
357
|
-
filteredRows: r?.cachedResult?.length ??
|
|
433
|
+
totalRows: n.length,
|
|
434
|
+
filteredRows: r?.cachedResult?.length ?? n.length,
|
|
358
435
|
selectedRows: i?.selected?.size ?? 0,
|
|
359
436
|
columns: t,
|
|
360
|
-
rows:
|
|
361
|
-
grid:
|
|
437
|
+
rows: n,
|
|
438
|
+
grid: e
|
|
362
439
|
};
|
|
363
440
|
}
|
|
364
|
-
const
|
|
365
|
-
class
|
|
441
|
+
const S = ".tbw-footer{flex-shrink:0;z-index:var(--tbw-z-layer-pinned-rows, 20);background:var(--tbw-color-panel-bg)}.tbw-pinned-rows{display:flex;align-items:center;justify-content:space-between;padding:8px 12px;background:var(--tbw-pinned-rows-bg, var(--tbw-color-panel-bg));border-top:1px solid var(--tbw-pinned-rows-border, var(--tbw-color-border));font-size:12px;color:var(--tbw-pinned-rows-color, var(--tbw-color-fg-muted));min-height:32px;box-sizing:border-box;min-width:fit-content}.tbw-pinned-rows-left,.tbw-pinned-rows-center,.tbw-pinned-rows-right{display:flex;align-items:center;gap:16px}.tbw-pinned-rows-left{justify-content:flex-start}.tbw-pinned-rows-center{justify-content:center;flex:1}.tbw-pinned-rows-right{justify-content:flex-end}.tbw-status-panel{white-space:nowrap}.tbw-aggregation-rows{min-width:fit-content;background:var(--tbw-aggregation-bg, var(--tbw-color-header-bg))}.tbw-aggregation-rows-top{border-bottom:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-rows-bottom{border-top:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-row{display:grid;grid-template-columns:var(--tbw-column-template);font-size:var(--tbw-aggregation-font-size, .8em);font-weight:var(--tbw-aggregation-font-weight, 600)}.tbw-aggregation-cell{padding:var(--tbw-cell-padding, 2px 8px);min-height:var(--tbw-row-height, 28px);display:flex;align-items:center;border-right:1px solid var(--tbw-color-border-cell)}.tbw-aggregation-cell:last-child{border-right:0}.tbw-aggregation-cell-full{grid-column:1 / -1;border-right:0}";
|
|
442
|
+
class x extends A {
|
|
366
443
|
name = "pinnedRows";
|
|
367
|
-
|
|
444
|
+
styles = S;
|
|
368
445
|
get defaultConfig() {
|
|
369
446
|
return {
|
|
370
447
|
position: "bottom",
|
|
@@ -388,9 +465,9 @@ class y extends R {
|
|
|
388
465
|
afterRender() {
|
|
389
466
|
const t = this.shadowRoot;
|
|
390
467
|
if (!t) return;
|
|
391
|
-
const
|
|
392
|
-
if (!
|
|
393
|
-
this.footerWrapper && !
|
|
468
|
+
const e = t.querySelector(".tbw-scroll-area") ?? t.querySelector(".tbw-grid-content") ?? t.children[0];
|
|
469
|
+
if (!e) return;
|
|
470
|
+
this.footerWrapper && !e.contains(this.footerWrapper) && (this.footerWrapper = null, this.bottomAggregationContainer = null, this.infoBarElement = null), this.topAggregationContainer && !e.contains(this.topAggregationContainer) && (this.topAggregationContainer = null), this.infoBarElement && !e.contains(this.infoBarElement) && (this.infoBarElement = null);
|
|
394
471
|
const i = this.getSelectionState(), r = this.getFilterState(), s = v(
|
|
395
472
|
this.rows,
|
|
396
473
|
this.columns,
|
|
@@ -400,9 +477,9 @@ class y extends R {
|
|
|
400
477
|
), o = this.config.aggregationRows || [], a = o.filter((c) => c.position === "top"), l = o.filter((c) => c.position !== "top");
|
|
401
478
|
if (a.length > 0) {
|
|
402
479
|
if (!this.topAggregationContainer) {
|
|
403
|
-
this.topAggregationContainer =
|
|
480
|
+
this.topAggregationContainer = w("top");
|
|
404
481
|
const c = t.querySelector(".header");
|
|
405
|
-
c && c.nextSibling ?
|
|
482
|
+
c && c.nextSibling ? e.insertBefore(this.topAggregationContainer, c.nextSibling) : e.appendChild(this.topAggregationContainer);
|
|
406
483
|
}
|
|
407
484
|
C(
|
|
408
485
|
this.topAggregationContainer,
|
|
@@ -411,16 +488,16 @@ class y extends R {
|
|
|
411
488
|
this.rows
|
|
412
489
|
);
|
|
413
490
|
} else this.topAggregationContainer && (this.topAggregationContainer.remove(), this.topAggregationContainer = null);
|
|
414
|
-
const
|
|
415
|
-
if (
|
|
491
|
+
const u = this.config.showRowCount !== !1 || this.config.showSelectedCount && s.selectedRows > 0 || this.config.showFilteredCount && s.filteredRows !== s.totalRows || this.config.customPanels && this.config.customPanels.length > 0, h = u && this.config.position !== "top", g = l.length > 0 || h;
|
|
492
|
+
if (u && this.config.position === "top")
|
|
416
493
|
if (!this.infoBarElement)
|
|
417
|
-
this.infoBarElement = m(this.config, s),
|
|
494
|
+
this.infoBarElement = m(this.config, s), e.insertBefore(this.infoBarElement, e.firstChild);
|
|
418
495
|
else {
|
|
419
496
|
const c = m(this.config, s);
|
|
420
497
|
this.infoBarElement.replaceWith(c), this.infoBarElement = c;
|
|
421
498
|
}
|
|
422
499
|
else this.config.position === "top" && this.infoBarElement && (this.infoBarElement.remove(), this.infoBarElement = null);
|
|
423
|
-
g ? (this.footerWrapper || (this.footerWrapper = document.createElement("div"), this.footerWrapper.className = "tbw-footer",
|
|
500
|
+
g ? (this.footerWrapper || (this.footerWrapper = document.createElement("div"), this.footerWrapper.className = "tbw-footer", e.appendChild(this.footerWrapper)), this.footerWrapper.innerHTML = "", l.length > 0 && (this.bottomAggregationContainer || (this.bottomAggregationContainer = w("bottom")), this.footerWrapper.appendChild(this.bottomAggregationContainer), C(
|
|
424
501
|
this.bottomAggregationContainer,
|
|
425
502
|
l,
|
|
426
503
|
this.visibleColumns,
|
|
@@ -462,13 +539,13 @@ class y extends R {
|
|
|
462
539
|
* @returns The context with row counts and other info
|
|
463
540
|
*/
|
|
464
541
|
getContext() {
|
|
465
|
-
const t = this.getSelectionState(),
|
|
542
|
+
const t = this.getSelectionState(), e = this.getFilterState();
|
|
466
543
|
return v(
|
|
467
544
|
this.rows,
|
|
468
545
|
this.columns,
|
|
469
546
|
this.grid,
|
|
470
547
|
t,
|
|
471
|
-
|
|
548
|
+
e
|
|
472
549
|
);
|
|
473
550
|
}
|
|
474
551
|
/**
|
|
@@ -483,7 +560,7 @@ class y extends R {
|
|
|
483
560
|
* @param id - The panel ID to remove
|
|
484
561
|
*/
|
|
485
562
|
removePanel(t) {
|
|
486
|
-
this.config.customPanels && (this.config.customPanels = this.config.customPanels.filter((
|
|
563
|
+
this.config.customPanels && (this.config.customPanels = this.config.customPanels.filter((e) => e.id !== t), this.requestRender());
|
|
487
564
|
}
|
|
488
565
|
/**
|
|
489
566
|
* Add an aggregation row.
|
|
@@ -497,14 +574,11 @@ class y extends R {
|
|
|
497
574
|
* @param id - The aggregation row ID to remove
|
|
498
575
|
*/
|
|
499
576
|
removeAggregationRow(t) {
|
|
500
|
-
this.config.aggregationRows && (this.config.aggregationRows = this.config.aggregationRows.filter((
|
|
577
|
+
this.config.aggregationRows && (this.config.aggregationRows = this.config.aggregationRows.filter((e) => e.id !== t), this.requestRender());
|
|
501
578
|
}
|
|
502
579
|
// #endregion
|
|
503
|
-
// #region Styles
|
|
504
|
-
styles = B;
|
|
505
|
-
// #endregion
|
|
506
580
|
}
|
|
507
581
|
export {
|
|
508
|
-
|
|
582
|
+
x as PinnedRowsPlugin
|
|
509
583
|
};
|
|
510
584
|
//# sourceMappingURL=index.js.map
|