@toolbox-web/grid 1.6.2 → 1.8.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 +51 -15
- package/all.js +267 -158
- package/all.js.map +1 -1
- package/index.js +866 -722
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +68 -1
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/header.d.ts.map +1 -1
- package/lib/core/plugin/base-plugin.d.ts +182 -1
- package/lib/core/plugin/base-plugin.d.ts.map +1 -1
- package/lib/core/plugin/index.d.ts +1 -1
- package/lib/core/plugin/index.d.ts.map +1 -1
- package/lib/core/plugin/plugin-manager.d.ts +56 -1
- package/lib/core/plugin/plugin-manager.d.ts.map +1 -1
- package/lib/core/plugin/types.d.ts +36 -0
- package/lib/core/plugin/types.d.ts.map +1 -1
- package/lib/core/types.d.ts +1349 -31
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +140 -87
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +64 -7
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/ContextMenuPlugin.d.ts.map +1 -1
- package/lib/plugins/context-menu/index.js +123 -65
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts +6 -1
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +95 -13
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js +91 -34
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts +6 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +192 -123
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +57 -0
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts +7 -2
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/grouping-rows/index.js +142 -60
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +69 -12
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +70 -13
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts +3 -3
- package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts.map +1 -1
- package/lib/plugins/pinned-columns/index.js +106 -36
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +57 -0
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +57 -0
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/print/PrintPlugin.d.ts.map +1 -1
- package/lib/plugins/print/index.js +58 -1
- package/lib/plugins/print/index.js.map +1 -1
- package/lib/plugins/reorder/ReorderPlugin.d.ts.map +1 -1
- package/lib/plugins/reorder/column-drag.d.ts +2 -2
- package/lib/plugins/reorder/index.js +68 -17
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/responsive/ResponsivePlugin.d.ts +6 -1
- package/lib/plugins/responsive/ResponsivePlugin.d.ts.map +1 -1
- package/lib/plugins/responsive/index.js +125 -54
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-reorder/index.js +169 -112
- package/lib/plugins/row-reorder/index.js.map +1 -1
- package/lib/plugins/selection/SelectionPlugin.d.ts +14 -2
- package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
- package/lib/plugins/selection/index.js +84 -7
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +79 -22
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/TreePlugin.d.ts +7 -1
- package/lib/plugins/tree/TreePlugin.d.ts.map +1 -1
- package/lib/plugins/tree/index.js +140 -58
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts +6 -1
- package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts.map +1 -1
- package/lib/plugins/undo-redo/index.js +79 -10
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +57 -0
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/public.d.ts +80 -2
- package/public.d.ts.map +1 -1
- package/umd/grid.all.umd.js +25 -25
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +15 -15
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js +5 -5
- package/umd/plugins/clipboard.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/filtering.umd.js +1 -1
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js +2 -2
- package/umd/plugins/grouping-rows.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/print.umd.js +1 -1
- package/umd/plugins/print.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/responsive.umd.js +1 -1
- package/umd/plugins/responsive.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +2 -2
- package/umd/plugins/selection.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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseGridPlugin, GridElement, PluginManifest } from '../../core/plugin/base-plugin';
|
|
1
|
+
import { BaseGridPlugin, GridElement, PluginManifest, PluginQuery } from '../../core/plugin/base-plugin';
|
|
2
2
|
import { BreakpointConfig, ResponsivePluginConfig } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Responsive Plugin for tbw-grid
|
|
@@ -90,6 +90,11 @@ export declare class ResponsivePlugin<T = unknown> extends BaseGridPlugin<Respon
|
|
|
90
90
|
getActiveBreakpoint(): BreakpointConfig | null;
|
|
91
91
|
attach(grid: GridElement): void;
|
|
92
92
|
detach(): void;
|
|
93
|
+
/**
|
|
94
|
+
* Handle plugin queries.
|
|
95
|
+
* @internal
|
|
96
|
+
*/
|
|
97
|
+
handleQuery(query: PluginQuery): unknown;
|
|
93
98
|
/**
|
|
94
99
|
* Apply hidden and value-only columns.
|
|
95
100
|
* In legacy mode (single breakpoint), only applies when in responsive mode.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResponsivePlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/responsive/ResponsivePlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"ResponsivePlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/responsive/ResponsivePlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAGxH,OAAO,KAAK,EAAE,gBAAgB,EAA8C,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEpH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,qBAAa,gBAAgB,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,cAAc,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC;;IAC1F,QAAQ,CAAC,IAAI,gBAAgB;IAC7B,SAAkB,OAAO,WAAW;IACpC,SAAkB,MAAM,SAAU;IAElC;;OAEG;IACH,gBAAyB,QAAQ,EAAE,cAAc,CAe/C;IAgBF;;;OAGG;IACH,YAAY,IAAI,OAAO;IAIvB;;;;OAIG;IACH,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAYrC;;;OAGG;IACH,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKlC;;;;OAIG;IACH,eAAe,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,GAAG,IAAI;IAQ1E;;;OAGG;IACH,QAAQ,IAAI,MAAM;IAIlB;;;OAGG;IACH,mBAAmB,IAAI,gBAAgB,GAAG,IAAI;IAIrC,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IA+C/B,MAAM,IAAI,IAAI;IAcvB;;;OAGG;IACM,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO;IAOjD;;;;OAIG;IACM,WAAW,IAAI,IAAI;IAyL5B;;;;;;;;;;OAUG;IACM,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI;IAqCtF;;;;;;;;;;;;;OAaG;IACM,SAAS,CAAC,CAAC,EAAE,aAAa,GAAG,OAAO;IAkK7C;;;;;;;;;;OAUG;IACM,cAAc,IAAI,MAAM;IAyBjC;;;;;OAKG;IACM,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM;CA8H9D"}
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
function b(
|
|
2
|
-
|
|
1
|
+
function b(o) {
|
|
2
|
+
o && o.querySelectorAll(".cell-focus").forEach((t) => t.classList.remove("cell-focus"));
|
|
3
3
|
}
|
|
4
4
|
const m = 'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])', R = document.createElement("template");
|
|
5
5
|
R.innerHTML = '<div class="cell" role="gridcell" part="cell"></div>';
|
|
6
6
|
const y = document.createElement("template");
|
|
7
7
|
y.innerHTML = '<div class="data-grid-row" role="row" part="row"></div>';
|
|
8
|
-
function u(
|
|
9
|
-
if (
|
|
10
|
-
const { rowHeight: r, container:
|
|
8
|
+
function u(o, t) {
|
|
9
|
+
if (o._virtualization?.enabled) {
|
|
10
|
+
const { rowHeight: r, container: s, viewportEl: l } = o._virtualization, d = s, h = l?.clientHeight ?? d?.clientHeight ?? 0;
|
|
11
11
|
if (d && h > 0) {
|
|
12
|
-
const c =
|
|
12
|
+
const c = o._focusRow * r;
|
|
13
13
|
c < d.scrollTop ? d.scrollTop = c : c + r > d.scrollTop + h && (d.scrollTop = c - h + r);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
const e =
|
|
17
|
-
e ||
|
|
16
|
+
const e = o._activeEditRows !== void 0 && o._activeEditRows !== -1;
|
|
17
|
+
e || o.refreshVirtualWindow(!1), b(o._bodyEl), Array.from(o._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach((r) => {
|
|
18
18
|
r.setAttribute("aria-selected", "false");
|
|
19
19
|
});
|
|
20
|
-
const i =
|
|
20
|
+
const i = o._focusRow, n = o._virtualization.start ?? 0, a = o._virtualization.end ?? o._rows.length;
|
|
21
21
|
if (i >= n && i < a) {
|
|
22
|
-
const r =
|
|
23
|
-
let
|
|
24
|
-
if ((!
|
|
25
|
-
|
|
26
|
-
const l =
|
|
27
|
-
if (l &&
|
|
28
|
-
const d =
|
|
22
|
+
const r = o._bodyEl.querySelectorAll(".data-grid-row")[i - n];
|
|
23
|
+
let s = r?.children[o._focusCol];
|
|
24
|
+
if ((!s || !s.classList?.contains("cell")) && (s = r?.querySelector(`.cell[data-col="${o._focusCol}"]`) ?? r?.querySelector(".cell[data-col]")), s) {
|
|
25
|
+
s.classList.add("cell-focus"), s.setAttribute("aria-selected", "true");
|
|
26
|
+
const l = o.querySelector(".tbw-scroll-area");
|
|
27
|
+
if (l && s && !e) {
|
|
28
|
+
const d = o._getHorizontalScrollOffsets?.(r ?? void 0, s) ?? { left: 0, right: 0 };
|
|
29
29
|
if (!d.skipScroll) {
|
|
30
|
-
const h =
|
|
31
|
-
g < w ? l.scrollLeft = g - d.left :
|
|
30
|
+
const h = s.getBoundingClientRect(), c = l.getBoundingClientRect(), g = h.left - c.left + l.scrollLeft, p = g + h.width, w = l.scrollLeft + d.left, v = l.scrollLeft + l.clientWidth - d.right;
|
|
31
|
+
g < w ? l.scrollLeft = g - d.left : p > v && (l.scrollLeft = p - l.clientWidth + d.right);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
if (
|
|
35
|
-
const d =
|
|
34
|
+
if (o._activeEditRows !== void 0 && o._activeEditRows !== -1 && s.classList.contains("editing")) {
|
|
35
|
+
const d = s.querySelector(m);
|
|
36
36
|
if (d && document.activeElement !== d)
|
|
37
37
|
try {
|
|
38
38
|
d.focus({ preventScroll: !0 });
|
|
39
39
|
} catch {
|
|
40
40
|
}
|
|
41
|
-
} else if (!
|
|
42
|
-
|
|
41
|
+
} else if (!s.contains(document.activeElement)) {
|
|
42
|
+
s.hasAttribute("tabindex") || s.setAttribute("tabindex", "-1");
|
|
43
43
|
try {
|
|
44
|
-
|
|
44
|
+
s.focus({ preventScroll: !0 });
|
|
45
45
|
} catch {
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
const
|
|
51
|
+
const f = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>', _ = {
|
|
52
52
|
expand: "▶",
|
|
53
53
|
collapse: "▼",
|
|
54
54
|
sortAsc: "▲",
|
|
@@ -57,11 +57,11 @@ const p = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentCo
|
|
|
57
57
|
submenuArrow: "▶",
|
|
58
58
|
dragHandle: "⋮⋮",
|
|
59
59
|
toolPanel: "☰",
|
|
60
|
-
filter:
|
|
61
|
-
filterActive:
|
|
60
|
+
filter: f,
|
|
61
|
+
filterActive: f,
|
|
62
62
|
print: "🖨️"
|
|
63
63
|
};
|
|
64
|
-
class
|
|
64
|
+
class C {
|
|
65
65
|
/**
|
|
66
66
|
* Plugin dependencies - declare other plugins this one requires.
|
|
67
67
|
*
|
|
@@ -199,6 +199,63 @@ class _ {
|
|
|
199
199
|
const i = new CustomEvent(t, { detail: e, bubbles: !0, cancelable: !0 });
|
|
200
200
|
return this.grid?.dispatchEvent?.(i), i.defaultPrevented;
|
|
201
201
|
}
|
|
202
|
+
// =========================================================================
|
|
203
|
+
// Event Bus - Plugin-to-Plugin Communication
|
|
204
|
+
// =========================================================================
|
|
205
|
+
/**
|
|
206
|
+
* Subscribe to an event from another plugin.
|
|
207
|
+
* The subscription is automatically cleaned up when this plugin is detached.
|
|
208
|
+
*
|
|
209
|
+
* @category Plugin Development
|
|
210
|
+
* @param eventType - The event type to listen for (e.g., 'filter-change')
|
|
211
|
+
* @param callback - The callback to invoke when the event is emitted
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```typescript
|
|
215
|
+
* // In attach() or other initialization
|
|
216
|
+
* this.on('filter-change', (detail) => {
|
|
217
|
+
* console.log('Filter changed:', detail);
|
|
218
|
+
* });
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
on(t, e) {
|
|
222
|
+
this.grid?._pluginManager?.subscribe(this, t, e);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Unsubscribe from a plugin event.
|
|
226
|
+
*
|
|
227
|
+
* @category Plugin Development
|
|
228
|
+
* @param eventType - The event type to stop listening for
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* ```typescript
|
|
232
|
+
* this.off('filter-change');
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
off(t) {
|
|
236
|
+
this.grid?._pluginManager?.unsubscribe(this, t);
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Emit an event to other plugins via the Event Bus.
|
|
240
|
+
* This is for inter-plugin communication only; it does NOT dispatch DOM events.
|
|
241
|
+
* Use `emit()` to dispatch DOM events that external consumers can listen to.
|
|
242
|
+
*
|
|
243
|
+
* @category Plugin Development
|
|
244
|
+
* @param eventType - The event type to emit (should be declared in manifest.events)
|
|
245
|
+
* @param detail - The event payload
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* ```typescript
|
|
249
|
+
* // Emit to other plugins (not DOM)
|
|
250
|
+
* this.emitPluginEvent('filter-change', { field: 'name', value: 'Alice' });
|
|
251
|
+
*
|
|
252
|
+
* // For DOM events that consumers can addEventListener to:
|
|
253
|
+
* this.emit('filter-change', { field: 'name', value: 'Alice' });
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
256
|
+
emitPluginEvent(t, e) {
|
|
257
|
+
this.grid?._pluginManager?.emitPluginEvent(t, e);
|
|
258
|
+
}
|
|
202
259
|
/**
|
|
203
260
|
* Request a re-render of the grid.
|
|
204
261
|
*/
|
|
@@ -285,7 +342,7 @@ class _ {
|
|
|
285
342
|
*/
|
|
286
343
|
get gridIcons() {
|
|
287
344
|
const t = this.grid?.gridConfig?.icons ?? {};
|
|
288
|
-
return { ...
|
|
345
|
+
return { ..._, ...t };
|
|
289
346
|
}
|
|
290
347
|
// #region Animation Helpers
|
|
291
348
|
/**
|
|
@@ -362,7 +419,7 @@ class _ {
|
|
|
362
419
|
// #endregion
|
|
363
420
|
}
|
|
364
421
|
const E = 'tbw-grid[data-responsive-animate] .data-grid-row,tbw-grid[data-responsive-animate] .data-grid-row>.cell{transition:opacity var(--tbw-responsive-duration, .2s) ease-out,transform var(--tbw-responsive-duration, .2s) ease-out}tbw-grid[data-responsive][data-responsive-animate] .data-grid-row{animation:responsive-card-enter var(--tbw-responsive-duration, .2s) ease-out}@keyframes responsive-card-enter{0%{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}tbw-grid[data-responsive] .header{display:none!important}tbw-grid[data-responsive] .footer-row{display:none}tbw-grid[data-responsive] .tbw-scroll-area{overflow-x:hidden;min-width:0!important}tbw-grid[data-responsive] .rows-body-wrapper{min-width:0!important}tbw-grid[data-responsive] .data-grid-row:not(.group-row){display:block!important;grid-template-columns:none!important;padding:var(--tbw-cell-padding);padding-left:var(--tbw-spacing-xl);border-bottom:1px solid var(--tbw-color-border);min-height:auto!important;height:auto!important;contain:none!important;content-visibility:visible!important;background:var(--tbw-color-bg);position:relative}tbw-grid[data-responsive] .data-grid-row:not(.group-row):nth-child(2n){background:var(--tbw-color-row-alt)}tbw-grid[data-responsive] .data-grid-row:not(.group-row):hover{background:var(--tbw-color-row-hover)}tbw-grid[data-responsive] .data-grid-row:not(.group-row)[aria-selected=true]{background:var(--tbw-color-selection)}tbw-grid[data-responsive] .data-grid-row:not(.group-row)[aria-selected=true]:before{content:"";position:absolute;left:0;top:0;bottom:0;width:4px;background:var(--tbw-color-accent)}tbw-grid[data-responsive] .data-grid-row:not(.group-row)>.cell{display:flex!important;justify-content:space-between;align-items:center;padding:var(--tbw-spacing-xs) var(--tbw-spacing-md);width:100%!important;min-width:0!important;min-height:auto!important;height:auto!important;line-height:1.5!important;position:static!important;left:auto!important;right:auto!important;border:none!important;border-bottom:none!important;border-right:none!important;background:transparent!important;white-space:normal!important;overflow:visible!important}tbw-grid[data-responsive] .data-grid-row:not(.group-row)>.cell:before{content:attr(data-header) ": ";font-weight:600;color:var(--tbw-color-header-fg);flex-shrink:0;margin-right:var(--tbw-spacing-md);min-width:100px}tbw-grid[data-responsive] .data-grid-row:not(.group-row)>.cell:after{content:none}tbw-grid[data-responsive] .cell[data-utility]{display:none!important}tbw-grid[data-responsive] .cell[data-responsive-hidden]{display:none!important}tbw-grid[data-responsive] .cell[data-responsive-value-only]{justify-content:flex-start!important;font-weight:500}tbw-grid[data-responsive] .cell[data-responsive-value-only]:before{display:none!important}tbw-grid:not([data-responsive]) .cell[data-responsive-hidden]{display:none!important}tbw-grid[data-responsive] .tbw-footer,tbw-grid[data-responsive] .tbw-pinned-rows,tbw-grid[data-responsive] .tbw-aggregation-rows{display:none!important}tbw-grid[data-responsive] .tbw-pinned-rows,tbw-grid[data-responsive] .tbw-aggregation-rows,tbw-grid[data-responsive] .tbw-aggregation-row{min-width:0!important}tbw-grid[data-responsive] .data-grid-row.responsive-card{display:block!important;padding:var(--tbw-cell-padding);border-bottom:1px solid var(--tbw-color-border)}tbw-grid[data-responsive] .data-grid-row.responsive-card>*{width:100%}tbw-grid[data-responsive] .data-grid-row.responsive-card .cell:before{display:none}';
|
|
365
|
-
class A extends
|
|
422
|
+
class A extends C {
|
|
366
423
|
name = "responsive";
|
|
367
424
|
version = "1.0.0";
|
|
368
425
|
styles = E;
|
|
@@ -375,6 +432,12 @@ class A extends _ {
|
|
|
375
432
|
name: "groupingRows",
|
|
376
433
|
reason: "Responsive card layout does not yet support row grouping. The variable row heights (cards vs group headers) cause scroll calculation issues."
|
|
377
434
|
}
|
|
435
|
+
],
|
|
436
|
+
queries: [
|
|
437
|
+
{
|
|
438
|
+
type: "isCardMode",
|
|
439
|
+
description: "Returns whether the grid is currently in responsive card mode"
|
|
440
|
+
}
|
|
378
441
|
]
|
|
379
442
|
};
|
|
380
443
|
#e;
|
|
@@ -383,7 +446,7 @@ class A extends _ {
|
|
|
383
446
|
#w = !1;
|
|
384
447
|
#a = 0;
|
|
385
448
|
/** Set of column fields to completely hide */
|
|
386
|
-
#
|
|
449
|
+
#o = /* @__PURE__ */ new Set();
|
|
387
450
|
/** Set of column fields to show value only (no header label) */
|
|
388
451
|
#d = /* @__PURE__ */ new Set();
|
|
389
452
|
/** Currently active breakpoint, or null if none */
|
|
@@ -450,28 +513,36 @@ class A extends _ {
|
|
|
450
513
|
* Build the hidden and value-only column sets from config.
|
|
451
514
|
*/
|
|
452
515
|
#h(t) {
|
|
453
|
-
if (this.#
|
|
516
|
+
if (this.#o.clear(), this.#d.clear(), !!t)
|
|
454
517
|
for (const e of t)
|
|
455
|
-
typeof e == "string" ? this.#
|
|
518
|
+
typeof e == "string" ? this.#o.add(e) : e.showValue ? this.#d.add(e.field) : this.#o.add(e.field);
|
|
456
519
|
}
|
|
457
520
|
detach() {
|
|
458
521
|
this.#e?.disconnect(), this.#e = void 0, clearTimeout(this.#n), this.#n = void 0, this.gridElement && this.gridElement.removeAttribute("data-responsive"), super.detach();
|
|
459
522
|
}
|
|
523
|
+
/**
|
|
524
|
+
* Handle plugin queries.
|
|
525
|
+
* @internal
|
|
526
|
+
*/
|
|
527
|
+
handleQuery(t) {
|
|
528
|
+
if (t.type === "isCardMode")
|
|
529
|
+
return this.#t;
|
|
530
|
+
}
|
|
460
531
|
/**
|
|
461
532
|
* Apply hidden and value-only columns.
|
|
462
533
|
* In legacy mode (single breakpoint), only applies when in responsive mode.
|
|
463
534
|
* In multi-breakpoint mode, applies whenever there's an active breakpoint.
|
|
464
535
|
*/
|
|
465
536
|
afterRender() {
|
|
466
|
-
if (this.#
|
|
537
|
+
if (this.#C(), !(this.#c.length > 0 ? this.#l !== null : this.#t))
|
|
467
538
|
return;
|
|
468
|
-
const e = this.#
|
|
539
|
+
const e = this.#o.size > 0, i = this.#d.size > 0;
|
|
469
540
|
if (!e && !i)
|
|
470
541
|
return;
|
|
471
542
|
const n = this.gridElement.querySelectorAll(".cell[data-field]");
|
|
472
543
|
for (const a of n) {
|
|
473
544
|
const r = a.getAttribute("data-field");
|
|
474
|
-
r && (this.#
|
|
545
|
+
r && (this.#o.has(r) ? (a.setAttribute("data-responsive-hidden", ""), a.removeAttribute("data-responsive-value-only")) : this.#d.has(r) ? (a.setAttribute("data-responsive-value-only", ""), a.removeAttribute("data-responsive-hidden")) : (a.removeAttribute("data-responsive-hidden"), a.removeAttribute("data-responsive-value-only")));
|
|
475
546
|
}
|
|
476
547
|
}
|
|
477
548
|
/**
|
|
@@ -531,7 +602,7 @@ class A extends _ {
|
|
|
531
602
|
const i = this.gridElement.querySelectorAll(".data-grid-row");
|
|
532
603
|
for (const n of i)
|
|
533
604
|
n.style.height = "", n.classList.remove("responsive-card");
|
|
534
|
-
this.#i && this.#i > 0 && e._virtualization && (e._virtualization.rowHeight = this.#i, this.#i = void 0), this.#r = void 0, this.#
|
|
605
|
+
this.#i && this.#i > 0 && e._virtualization && (e._virtualization.rowHeight = this.#i, this.#i = void 0), this.#r = void 0, this.#s = void 0, this.#g = void 0;
|
|
535
606
|
}
|
|
536
607
|
}
|
|
537
608
|
/**
|
|
@@ -602,7 +673,7 @@ class A extends _ {
|
|
|
602
673
|
/** Measured card height from DOM for virtualization calculations */
|
|
603
674
|
#r;
|
|
604
675
|
/** Measured group row height from DOM for virtualization calculations */
|
|
605
|
-
#
|
|
676
|
+
#s;
|
|
606
677
|
/** Last known card row count for detecting changes (e.g., group expand/collapse) */
|
|
607
678
|
#g;
|
|
608
679
|
/**
|
|
@@ -621,13 +692,13 @@ class A extends _ {
|
|
|
621
692
|
* Uses DOM-measured height, falling back to original row height.
|
|
622
693
|
*/
|
|
623
694
|
#m() {
|
|
624
|
-
return this.#
|
|
695
|
+
return this.#s && this.#s > 0 ? this.#s : this.#i ?? 28;
|
|
625
696
|
}
|
|
626
697
|
/**
|
|
627
698
|
* Check if there are any group rows in the current dataset.
|
|
628
699
|
* Used to determine if we have mixed row heights.
|
|
629
700
|
*/
|
|
630
|
-
#
|
|
701
|
+
#p() {
|
|
631
702
|
for (const t of this.rows)
|
|
632
703
|
if (t.__isGroupRow)
|
|
633
704
|
return !0;
|
|
@@ -654,10 +725,10 @@ class A extends _ {
|
|
|
654
725
|
* - Extra for cards: cardCount * (cardHeight - baseHeight)
|
|
655
726
|
*/
|
|
656
727
|
getExtraHeight() {
|
|
657
|
-
if (!this.#t || !this.config.cardRenderer || !this.#
|
|
728
|
+
if (!this.#t || !this.config.cardRenderer || !this.#p())
|
|
658
729
|
return 0;
|
|
659
|
-
const t = this.#i ?? 28, e = this.#m(), i = this.#b(), { groupCount: n, cardCount: a } = this.#y(), r = n * Math.max(0, e - t),
|
|
660
|
-
return r +
|
|
730
|
+
const t = this.#i ?? 28, e = this.#m(), i = this.#b(), { groupCount: n, cardCount: a } = this.#y(), r = n * Math.max(0, e - t), s = a * Math.max(0, i - t);
|
|
731
|
+
return r + s;
|
|
661
732
|
}
|
|
662
733
|
/**
|
|
663
734
|
* Return extra height that appears before a given row index.
|
|
@@ -666,26 +737,26 @@ class A extends _ {
|
|
|
666
737
|
* Like getExtraHeight, this accounts for both group and card row heights.
|
|
667
738
|
*/
|
|
668
739
|
getExtraHeightBefore(t) {
|
|
669
|
-
if (!this.#t || !this.config.cardRenderer || !this.#
|
|
740
|
+
if (!this.#t || !this.config.cardRenderer || !this.#p())
|
|
670
741
|
return 0;
|
|
671
742
|
const e = this.#i ?? 28, i = this.#m(), n = this.#b(), a = Math.max(0, i - e), r = Math.max(0, n - e);
|
|
672
|
-
let
|
|
743
|
+
let s = 0, l = 0;
|
|
673
744
|
const d = this.rows, h = Math.min(t, d.length);
|
|
674
745
|
for (let c = 0; c < h; c++)
|
|
675
|
-
d[c].__isGroupRow ?
|
|
676
|
-
return
|
|
746
|
+
d[c].__isGroupRow ? s++ : l++;
|
|
747
|
+
return s * a + l * r;
|
|
677
748
|
}
|
|
678
749
|
/**
|
|
679
750
|
* Count the number of card rows (non-group rows) in the current dataset.
|
|
680
751
|
*/
|
|
681
|
-
#
|
|
752
|
+
#_() {
|
|
682
753
|
let t = 0;
|
|
683
754
|
for (const e of this.rows)
|
|
684
755
|
e.__isGroupRow || t++;
|
|
685
756
|
return t;
|
|
686
757
|
}
|
|
687
758
|
/** Pending refresh scheduled via microtask */
|
|
688
|
-
#
|
|
759
|
+
#f = !1;
|
|
689
760
|
/**
|
|
690
761
|
* Measure card height from DOM after render and detect row count changes.
|
|
691
762
|
* Called in afterRender to ensure scroll calculations are accurate.
|
|
@@ -701,16 +772,16 @@ class A extends _ {
|
|
|
701
772
|
*
|
|
702
773
|
* The refresh is deferred via microtask to avoid nested render cycles.
|
|
703
774
|
*/
|
|
704
|
-
#
|
|
775
|
+
#C() {
|
|
705
776
|
if (!this.#t || !this.config.cardRenderer)
|
|
706
777
|
return;
|
|
707
778
|
let t = !1;
|
|
708
|
-
const e = this.grid, i = this.#
|
|
779
|
+
const e = this.grid, i = this.#p(), n = this.#_();
|
|
709
780
|
if (n !== this.#g && (this.#g = n, t = !0), i) {
|
|
710
781
|
const r = this.gridElement.querySelector(".data-grid-row.group-row");
|
|
711
782
|
if (r) {
|
|
712
|
-
const
|
|
713
|
-
|
|
783
|
+
const s = r.getBoundingClientRect().height;
|
|
784
|
+
s > 0 && s !== this.#s && (this.#s = s, t = !0);
|
|
714
785
|
}
|
|
715
786
|
}
|
|
716
787
|
const a = this.gridElement.querySelector(".data-grid-row.responsive-card");
|
|
@@ -718,8 +789,8 @@ class A extends _ {
|
|
|
718
789
|
const r = a.getBoundingClientRect().height;
|
|
719
790
|
r > 0 && r !== this.#r && (this.#r = r, t = !0, !i && e._virtualization && (e._virtualization.rowHeight = r));
|
|
720
791
|
}
|
|
721
|
-
t && !this.#
|
|
722
|
-
this.#
|
|
792
|
+
t && !this.#f && (this.#f = !0, queueMicrotask(() => {
|
|
793
|
+
this.#f = !1, this.grid && this.#t && this.grid.refreshVirtualWindow?.(!0, !0);
|
|
723
794
|
}));
|
|
724
795
|
}
|
|
725
796
|
}
|