@toolbox-web/grid 0.4.0 → 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 +1124 -1047
- package/all.js.map +1 -1
- package/index.js +688 -515
- 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/internal/validate-config.d.ts +14 -0
- package/lib/core/internal/validate-config.d.ts.map +1 -1
- package/lib/core/plugin/base-plugin.d.ts +105 -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/index.d.ts +1 -0
- package/lib/core/plugin/index.d.ts.map +1 -1
- package/lib/core/plugin/plugin-manager.d.ts +1 -1
- 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 +4 -2
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts +9 -2
- 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 +303 -185
- 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 +116 -24
- 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 +164 -72
- 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 +213 -133
- 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 +195 -103
- 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 +145 -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 +162 -68
- 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 +246 -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 +281 -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 +121 -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 +144 -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 +178 -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 +414 -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 +304 -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 +292 -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 +95 -3
- 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 +213 -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 +7 -2
- package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts.map +1 -1
- package/lib/plugins/undo-redo/index.js +112 -12
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/VisibilityPlugin.d.ts +14 -5
- package/lib/plugins/visibility/VisibilityPlugin.d.ts.map +1 -1
- package/lib/plugins/visibility/index.js +168 -65
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +21 -17
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +14 -8
- 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const R = {
|
|
2
2
|
expand: "▶",
|
|
3
3
|
collapse: "▼",
|
|
4
4
|
sortAsc: "▲",
|
|
@@ -8,9 +8,28 @@ const A = {
|
|
|
8
8
|
dragHandle: "⋮⋮",
|
|
9
9
|
toolPanel: "☰"
|
|
10
10
|
};
|
|
11
|
-
class
|
|
12
|
-
/**
|
|
13
|
-
|
|
11
|
+
class A {
|
|
12
|
+
/**
|
|
13
|
+
* Plugin dependencies - declare other plugins this one requires.
|
|
14
|
+
*
|
|
15
|
+
* Dependencies are validated when the plugin is attached.
|
|
16
|
+
* Required dependencies throw an error if missing.
|
|
17
|
+
* Optional dependencies log an info message if missing.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* static readonly dependencies: PluginDependency[] = [
|
|
22
|
+
* { name: 'editing', required: true, reason: 'Tracks cell edits for undo/redo' },
|
|
23
|
+
* { name: 'selection', required: false, reason: 'Enables selection-based undo' },
|
|
24
|
+
* ];
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
static dependencies;
|
|
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";
|
|
14
33
|
/** CSS styles to inject into the grid's shadow DOM */
|
|
15
34
|
styles;
|
|
16
35
|
/** Custom cell renderers keyed by type name */
|
|
@@ -94,8 +113,16 @@ class R {
|
|
|
94
113
|
/**
|
|
95
114
|
* Emit a custom event from the grid.
|
|
96
115
|
*/
|
|
97
|
-
emit(t,
|
|
98
|
-
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;
|
|
99
126
|
}
|
|
100
127
|
/**
|
|
101
128
|
* Request a re-render of the grid.
|
|
@@ -103,6 +130,14 @@ class R {
|
|
|
103
130
|
requestRender() {
|
|
104
131
|
this.grid?.requestRender?.();
|
|
105
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
|
+
}
|
|
106
141
|
/**
|
|
107
142
|
* Request a lightweight style update without rebuilding DOM.
|
|
108
143
|
* Use this instead of requestRender() when only CSS classes need updating.
|
|
@@ -136,6 +171,19 @@ class R {
|
|
|
136
171
|
get visibleColumns() {
|
|
137
172
|
return this.grid?._visibleColumns ?? [];
|
|
138
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
|
+
}
|
|
139
187
|
/**
|
|
140
188
|
* Get the shadow root of the grid.
|
|
141
189
|
*/
|
|
@@ -168,8 +216,53 @@ class R {
|
|
|
168
216
|
*/
|
|
169
217
|
get gridIcons() {
|
|
170
218
|
const t = this.grid?.gridConfig?.icons ?? {};
|
|
171
|
-
return { ...
|
|
219
|
+
return { ...R, ...t };
|
|
172
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
|
|
173
266
|
/**
|
|
174
267
|
* Resolve an icon value to string or HTMLElement.
|
|
175
268
|
* Checks plugin config first, then grid-level icons, then defaults.
|
|
@@ -178,8 +271,8 @@ class R {
|
|
|
178
271
|
* @param pluginOverride - Optional plugin-level override
|
|
179
272
|
* @returns The resolved icon value
|
|
180
273
|
*/
|
|
181
|
-
resolveIcon(t,
|
|
182
|
-
return
|
|
274
|
+
resolveIcon(t, e) {
|
|
275
|
+
return e !== void 0 ? e : this.gridIcons[t];
|
|
183
276
|
}
|
|
184
277
|
/**
|
|
185
278
|
* Set an icon value on an element.
|
|
@@ -188,8 +281,8 @@ class R {
|
|
|
188
281
|
* @param element - The element to set the icon on
|
|
189
282
|
* @param icon - The icon value (string or HTMLElement)
|
|
190
283
|
*/
|
|
191
|
-
setIcon(t,
|
|
192
|
-
typeof
|
|
284
|
+
setIcon(t, e) {
|
|
285
|
+
typeof e == "string" ? t.innerHTML = e : e instanceof HTMLElement && (t.innerHTML = "", t.appendChild(e.cloneNode(!0)));
|
|
193
286
|
}
|
|
194
287
|
/**
|
|
195
288
|
* Log a warning message.
|
|
@@ -200,87 +293,87 @@ class R {
|
|
|
200
293
|
// #endregion
|
|
201
294
|
}
|
|
202
295
|
const p = {
|
|
203
|
-
sum: (
|
|
204
|
-
avg: (
|
|
205
|
-
const
|
|
206
|
-
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;
|
|
207
300
|
},
|
|
208
|
-
count: (
|
|
209
|
-
min: (
|
|
210
|
-
max: (
|
|
211
|
-
first: (
|
|
212
|
-
last: (
|
|
213
|
-
},
|
|
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 = {
|
|
214
307
|
/**
|
|
215
308
|
* Register a custom aggregator function.
|
|
216
309
|
*/
|
|
217
|
-
register(
|
|
218
|
-
|
|
310
|
+
register(n, t) {
|
|
311
|
+
f.set(n, t);
|
|
219
312
|
},
|
|
220
313
|
/**
|
|
221
314
|
* Unregister a custom aggregator function.
|
|
222
315
|
*/
|
|
223
|
-
unregister(
|
|
224
|
-
|
|
316
|
+
unregister(n) {
|
|
317
|
+
f.delete(n);
|
|
225
318
|
},
|
|
226
319
|
/**
|
|
227
320
|
* Get an aggregator function by reference.
|
|
228
321
|
*/
|
|
229
|
-
get(
|
|
230
|
-
if (
|
|
231
|
-
return typeof
|
|
322
|
+
get(n) {
|
|
323
|
+
if (n !== void 0)
|
|
324
|
+
return typeof n == "function" ? n : f.get(n) ?? p[n];
|
|
232
325
|
},
|
|
233
326
|
/**
|
|
234
327
|
* Run an aggregator on a set of rows.
|
|
235
328
|
*/
|
|
236
|
-
run(
|
|
237
|
-
const r = this.get(
|
|
238
|
-
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;
|
|
239
332
|
},
|
|
240
333
|
/**
|
|
241
334
|
* Check if an aggregator exists.
|
|
242
335
|
*/
|
|
243
|
-
has(
|
|
244
|
-
return
|
|
336
|
+
has(n) {
|
|
337
|
+
return f.has(n) || n in p;
|
|
245
338
|
},
|
|
246
339
|
/**
|
|
247
340
|
* List all available aggregator names.
|
|
248
341
|
*/
|
|
249
342
|
list() {
|
|
250
|
-
return [...Object.keys(p), ...
|
|
343
|
+
return [...Object.keys(p), ...f.keys()];
|
|
251
344
|
}
|
|
252
345
|
};
|
|
253
346
|
d.register.bind(d);
|
|
254
347
|
d.unregister.bind(d);
|
|
255
|
-
const
|
|
348
|
+
const b = d.get.bind(d);
|
|
256
349
|
d.run.bind(d);
|
|
257
350
|
d.list.bind(d);
|
|
258
|
-
function E(
|
|
259
|
-
return typeof
|
|
351
|
+
function E(n) {
|
|
352
|
+
return typeof n == "object" && n !== null && "aggFunc" in n;
|
|
260
353
|
}
|
|
261
|
-
function m(
|
|
262
|
-
const
|
|
263
|
-
|
|
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");
|
|
264
357
|
const i = document.createElement("div");
|
|
265
358
|
i.className = "tbw-pinned-rows-left";
|
|
266
359
|
const r = document.createElement("div");
|
|
267
360
|
r.className = "tbw-pinned-rows-center";
|
|
268
361
|
const s = document.createElement("div");
|
|
269
|
-
if (s.className = "tbw-pinned-rows-right",
|
|
362
|
+
if (s.className = "tbw-pinned-rows-right", n.showRowCount !== !1) {
|
|
270
363
|
const o = document.createElement("span");
|
|
271
364
|
o.className = "tbw-status-panel tbw-status-panel-row-count", o.textContent = `Total: ${t.totalRows} rows`, i.appendChild(o);
|
|
272
365
|
}
|
|
273
|
-
if (
|
|
366
|
+
if (n.showFilteredCount && t.filteredRows !== t.totalRows) {
|
|
274
367
|
const o = document.createElement("span");
|
|
275
368
|
o.className = "tbw-status-panel tbw-status-panel-filtered-count", o.textContent = `Filtered: ${t.filteredRows}`, i.appendChild(o);
|
|
276
369
|
}
|
|
277
|
-
if (
|
|
370
|
+
if (n.showSelectedCount && t.selectedRows > 0) {
|
|
278
371
|
const o = document.createElement("span");
|
|
279
372
|
o.className = "tbw-status-panel tbw-status-panel-selected-count", o.textContent = `Selected: ${t.selectedRows}`, s.appendChild(o);
|
|
280
373
|
}
|
|
281
|
-
if (
|
|
282
|
-
for (const o of
|
|
283
|
-
const a =
|
|
374
|
+
if (n.customPanels)
|
|
375
|
+
for (const o of n.customPanels) {
|
|
376
|
+
const a = y(o, t);
|
|
284
377
|
switch (o.position) {
|
|
285
378
|
case "left":
|
|
286
379
|
i.appendChild(a);
|
|
@@ -293,62 +386,62 @@ function m(e, t) {
|
|
|
293
386
|
break;
|
|
294
387
|
}
|
|
295
388
|
}
|
|
296
|
-
return
|
|
389
|
+
return e.appendChild(i), e.appendChild(r), e.appendChild(s), e;
|
|
297
390
|
}
|
|
298
|
-
function
|
|
391
|
+
function w(n) {
|
|
299
392
|
const t = document.createElement("div");
|
|
300
|
-
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;
|
|
301
394
|
}
|
|
302
|
-
function C(
|
|
303
|
-
|
|
395
|
+
function C(n, t, e, i) {
|
|
396
|
+
n.innerHTML = "";
|
|
304
397
|
for (const r of t) {
|
|
305
398
|
const s = document.createElement("div");
|
|
306
399
|
if (s.className = "tbw-aggregation-row", s.setAttribute("role", "presentation"), r.id && s.setAttribute("data-aggregation-id", r.id), r.fullWidth) {
|
|
307
400
|
const o = document.createElement("div");
|
|
308
401
|
o.className = "tbw-aggregation-cell tbw-aggregation-cell-full", o.style.gridColumn = "1 / -1", o.textContent = r.label || "", s.appendChild(o);
|
|
309
402
|
} else
|
|
310
|
-
for (const o of
|
|
403
|
+
for (const o of e) {
|
|
311
404
|
const a = document.createElement("div");
|
|
312
405
|
a.className = "tbw-aggregation-cell", a.setAttribute("data-field", o.field);
|
|
313
|
-
let l,
|
|
406
|
+
let l, u;
|
|
314
407
|
const h = r.aggregators?.[o.field];
|
|
315
408
|
if (h)
|
|
316
409
|
if (E(h)) {
|
|
317
|
-
const g =
|
|
318
|
-
g && (l = g(i, o.field, o)),
|
|
410
|
+
const g = b(h.aggFunc);
|
|
411
|
+
g && (l = g(i, o.field, o)), u = h.formatter;
|
|
319
412
|
} else {
|
|
320
|
-
const g =
|
|
413
|
+
const g = b(h);
|
|
321
414
|
g && (l = g(i, o.field, o));
|
|
322
415
|
}
|
|
323
416
|
else if (r.cells && Object.prototype.hasOwnProperty.call(r.cells, o.field)) {
|
|
324
417
|
const g = r.cells[o.field];
|
|
325
418
|
typeof g == "function" ? l = g(i, o.field, o) : l = g;
|
|
326
419
|
}
|
|
327
|
-
l != null ? a.textContent =
|
|
420
|
+
l != null ? a.textContent = u ? u(l, o.field, o) : String(l) : a.textContent = "", s.appendChild(a);
|
|
328
421
|
}
|
|
329
|
-
|
|
422
|
+
n.appendChild(s);
|
|
330
423
|
}
|
|
331
424
|
}
|
|
332
|
-
function
|
|
333
|
-
const
|
|
334
|
-
|
|
335
|
-
const i =
|
|
336
|
-
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;
|
|
337
430
|
}
|
|
338
|
-
function v(
|
|
431
|
+
function v(n, t, e, i, r) {
|
|
339
432
|
return {
|
|
340
|
-
totalRows:
|
|
341
|
-
filteredRows: r?.cachedResult?.length ??
|
|
433
|
+
totalRows: n.length,
|
|
434
|
+
filteredRows: r?.cachedResult?.length ?? n.length,
|
|
342
435
|
selectedRows: i?.selected?.size ?? 0,
|
|
343
436
|
columns: t,
|
|
344
|
-
rows:
|
|
345
|
-
grid:
|
|
437
|
+
rows: n,
|
|
438
|
+
grid: e
|
|
346
439
|
};
|
|
347
440
|
}
|
|
348
|
-
const
|
|
349
|
-
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 {
|
|
350
443
|
name = "pinnedRows";
|
|
351
|
-
|
|
444
|
+
styles = S;
|
|
352
445
|
get defaultConfig() {
|
|
353
446
|
return {
|
|
354
447
|
position: "bottom",
|
|
@@ -372,9 +465,9 @@ class y extends R {
|
|
|
372
465
|
afterRender() {
|
|
373
466
|
const t = this.shadowRoot;
|
|
374
467
|
if (!t) return;
|
|
375
|
-
const
|
|
376
|
-
if (!
|
|
377
|
-
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);
|
|
378
471
|
const i = this.getSelectionState(), r = this.getFilterState(), s = v(
|
|
379
472
|
this.rows,
|
|
380
473
|
this.columns,
|
|
@@ -384,9 +477,9 @@ class y extends R {
|
|
|
384
477
|
), o = this.config.aggregationRows || [], a = o.filter((c) => c.position === "top"), l = o.filter((c) => c.position !== "top");
|
|
385
478
|
if (a.length > 0) {
|
|
386
479
|
if (!this.topAggregationContainer) {
|
|
387
|
-
this.topAggregationContainer =
|
|
480
|
+
this.topAggregationContainer = w("top");
|
|
388
481
|
const c = t.querySelector(".header");
|
|
389
|
-
c && c.nextSibling ?
|
|
482
|
+
c && c.nextSibling ? e.insertBefore(this.topAggregationContainer, c.nextSibling) : e.appendChild(this.topAggregationContainer);
|
|
390
483
|
}
|
|
391
484
|
C(
|
|
392
485
|
this.topAggregationContainer,
|
|
@@ -395,16 +488,16 @@ class y extends R {
|
|
|
395
488
|
this.rows
|
|
396
489
|
);
|
|
397
490
|
} else this.topAggregationContainer && (this.topAggregationContainer.remove(), this.topAggregationContainer = null);
|
|
398
|
-
const
|
|
399
|
-
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")
|
|
400
493
|
if (!this.infoBarElement)
|
|
401
|
-
this.infoBarElement = m(this.config, s),
|
|
494
|
+
this.infoBarElement = m(this.config, s), e.insertBefore(this.infoBarElement, e.firstChild);
|
|
402
495
|
else {
|
|
403
496
|
const c = m(this.config, s);
|
|
404
497
|
this.infoBarElement.replaceWith(c), this.infoBarElement = c;
|
|
405
498
|
}
|
|
406
499
|
else this.config.position === "top" && this.infoBarElement && (this.infoBarElement.remove(), this.infoBarElement = null);
|
|
407
|
-
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(
|
|
408
501
|
this.bottomAggregationContainer,
|
|
409
502
|
l,
|
|
410
503
|
this.visibleColumns,
|
|
@@ -446,13 +539,13 @@ class y extends R {
|
|
|
446
539
|
* @returns The context with row counts and other info
|
|
447
540
|
*/
|
|
448
541
|
getContext() {
|
|
449
|
-
const t = this.getSelectionState(),
|
|
542
|
+
const t = this.getSelectionState(), e = this.getFilterState();
|
|
450
543
|
return v(
|
|
451
544
|
this.rows,
|
|
452
545
|
this.columns,
|
|
453
546
|
this.grid,
|
|
454
547
|
t,
|
|
455
|
-
|
|
548
|
+
e
|
|
456
549
|
);
|
|
457
550
|
}
|
|
458
551
|
/**
|
|
@@ -467,7 +560,7 @@ class y extends R {
|
|
|
467
560
|
* @param id - The panel ID to remove
|
|
468
561
|
*/
|
|
469
562
|
removePanel(t) {
|
|
470
|
-
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());
|
|
471
564
|
}
|
|
472
565
|
/**
|
|
473
566
|
* Add an aggregation row.
|
|
@@ -481,14 +574,11 @@ class y extends R {
|
|
|
481
574
|
* @param id - The aggregation row ID to remove
|
|
482
575
|
*/
|
|
483
576
|
removeAggregationRow(t) {
|
|
484
|
-
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());
|
|
485
578
|
}
|
|
486
579
|
// #endregion
|
|
487
|
-
// #region Styles
|
|
488
|
-
styles = B;
|
|
489
|
-
// #endregion
|
|
490
580
|
}
|
|
491
581
|
export {
|
|
492
|
-
|
|
582
|
+
x as PinnedRowsPlugin
|
|
493
583
|
};
|
|
494
584
|
//# sourceMappingURL=index.js.map
|