@toolbox-web/grid 1.1.0 → 1.1.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/all.js +189 -113
- package/all.js.map +1 -1
- package/index.js +757 -716
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +7 -1
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/validate-config.d.ts +10 -0
- package/lib/core/internal/validate-config.d.ts.map +1 -1
- package/lib/core/plugin/base-plugin.d.ts +30 -0
- 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 +6 -0
- package/lib/core/plugin/plugin-manager.d.ts.map +1 -1
- package/lib/core/types.d.ts +1 -1
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/grouping-rows/index.js +5 -5
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/responsive/ResponsivePlugin.d.ts +24 -1
- package/lib/plugins/responsive/ResponsivePlugin.d.ts.map +1 -1
- package/lib/plugins/responsive/index.js +225 -88
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +25 -19
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +18 -12
- package/umd/grid.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/responsive.umd.js +1 -1
- package/umd/plugins/responsive.umd.js.map +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseGridPlugin, GridElement } from '../../core/plugin/base-plugin';
|
|
1
|
+
import { BaseGridPlugin, GridElement, PluginManifest } from '../../core/plugin/base-plugin';
|
|
2
2
|
import { BreakpointConfig, ResponsivePluginConfig } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Responsive Plugin for tbw-grid
|
|
@@ -52,6 +52,10 @@ export declare class ResponsivePlugin<T = unknown> extends BaseGridPlugin<Respon
|
|
|
52
52
|
readonly name = "responsive";
|
|
53
53
|
readonly version = "1.0.0";
|
|
54
54
|
readonly styles: string;
|
|
55
|
+
/**
|
|
56
|
+
* Plugin manifest declaring incompatibilities with other plugins.
|
|
57
|
+
*/
|
|
58
|
+
static readonly manifest: PluginManifest;
|
|
55
59
|
/**
|
|
56
60
|
* Check if currently in responsive mode.
|
|
57
61
|
* @returns `true` if the grid is in card layout mode
|
|
@@ -119,5 +123,24 @@ export declare class ResponsivePlugin<T = unknown> extends BaseGridPlugin<Respon
|
|
|
119
123
|
* @returns `true` if the event was handled and default behavior should be prevented
|
|
120
124
|
*/
|
|
121
125
|
onKeyDown(e: KeyboardEvent): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Return total extra height contributed by mixed row heights.
|
|
128
|
+
* This is called by the grid's virtualization system to adjust scrollbar height.
|
|
129
|
+
*
|
|
130
|
+
* The grid calculates: totalRows * baseRowHeight + pluginExtraHeight
|
|
131
|
+
*
|
|
132
|
+
* For mixed layouts (groups + cards), we need to report the difference between
|
|
133
|
+
* actual heights and what the base calculation assumes:
|
|
134
|
+
* - Extra for groups: groupCount * (groupHeight - baseHeight)
|
|
135
|
+
* - Extra for cards: cardCount * (cardHeight - baseHeight)
|
|
136
|
+
*/
|
|
137
|
+
getExtraHeight(): number;
|
|
138
|
+
/**
|
|
139
|
+
* Return extra height that appears before a given row index.
|
|
140
|
+
* Used by virtualization to correctly calculate scroll positions.
|
|
141
|
+
*
|
|
142
|
+
* Like getExtraHeight, this accounts for both group and card row heights.
|
|
143
|
+
*/
|
|
144
|
+
getExtraHeightBefore(beforeRowIndex: number): number;
|
|
122
145
|
}
|
|
123
146
|
//# sourceMappingURL=ResponsivePlugin.d.ts.map
|
|
@@ -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,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,MAAM,+BAA+B,CAAC;AAGtG,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,CAS/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;;;;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
|
|
2
|
-
|
|
1
|
+
function v(s) {
|
|
2
|
+
s && s.querySelectorAll(".cell-focus").forEach((t) => t.classList.remove("cell-focus"));
|
|
3
3
|
}
|
|
4
|
-
const
|
|
4
|
+
const b = 'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])', m = document.createElement("template");
|
|
5
5
|
m.innerHTML = '<div class="cell" role="gridcell" part="cell"></div>';
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
function u(
|
|
9
|
-
if (
|
|
10
|
-
const { rowHeight:
|
|
11
|
-
if (
|
|
12
|
-
const
|
|
13
|
-
|
|
6
|
+
const R = document.createElement("template");
|
|
7
|
+
R.innerHTML = '<div class="data-grid-row" role="row" part="row"></div>';
|
|
8
|
+
function u(s, t) {
|
|
9
|
+
if (s._virtualization?.enabled) {
|
|
10
|
+
const { rowHeight: r, container: o, viewportEl: l } = s._virtualization, d = o, h = l?.clientHeight ?? d?.clientHeight ?? 0;
|
|
11
|
+
if (d && h > 0) {
|
|
12
|
+
const c = s._focusRow * r;
|
|
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 ||
|
|
18
|
-
|
|
16
|
+
const e = s._activeEditRows !== void 0 && s._activeEditRows !== -1;
|
|
17
|
+
e || s.refreshVirtualWindow(!1), v(s._bodyEl), Array.from(s._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach((r) => {
|
|
18
|
+
r.setAttribute("aria-selected", "false");
|
|
19
19
|
});
|
|
20
|
-
const i =
|
|
21
|
-
if (i >=
|
|
22
|
-
const
|
|
23
|
-
let
|
|
24
|
-
if ((!
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
28
|
-
const
|
|
29
|
-
if (!
|
|
30
|
-
const
|
|
31
|
-
g <
|
|
20
|
+
const i = s._focusRow, n = s._virtualization.start ?? 0, a = s._virtualization.end ?? s._rows.length;
|
|
21
|
+
if (i >= n && i < a) {
|
|
22
|
+
const r = s._bodyEl.querySelectorAll(".data-grid-row")[i - n];
|
|
23
|
+
let o = r?.children[s._focusCol];
|
|
24
|
+
if ((!o || !o.classList?.contains("cell")) && (o = r?.querySelector(`.cell[data-col="${s._focusCol}"]`) ?? r?.querySelector(".cell[data-col]")), o) {
|
|
25
|
+
o.classList.add("cell-focus"), o.setAttribute("aria-selected", "true");
|
|
26
|
+
const l = s.querySelector(".tbw-scroll-area");
|
|
27
|
+
if (l && o && !e) {
|
|
28
|
+
const d = s._getHorizontalScrollOffsets?.(r ?? void 0, o) ?? { left: 0, right: 0 };
|
|
29
|
+
if (!d.skipScroll) {
|
|
30
|
+
const h = o.getBoundingClientRect(), c = l.getBoundingClientRect(), g = h.left - c.left + l.scrollLeft, f = g + h.width, p = l.scrollLeft + d.left, w = l.scrollLeft + l.clientWidth - d.right;
|
|
31
|
+
g < p ? l.scrollLeft = g - d.left : f > w && (l.scrollLeft = f - l.clientWidth + d.right);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
if (
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
34
|
+
if (s._activeEditRows !== void 0 && s._activeEditRows !== -1 && o.classList.contains("editing")) {
|
|
35
|
+
const d = o.querySelector(b);
|
|
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 (!o.contains(document.activeElement)) {
|
|
42
|
+
o.hasAttribute("tabindex") || o.setAttribute("tabindex", "-1");
|
|
43
43
|
try {
|
|
44
|
-
|
|
44
|
+
o.focus({ preventScroll: !0 });
|
|
45
45
|
} catch {
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
const
|
|
51
|
+
const y = {
|
|
52
52
|
expand: "▶",
|
|
53
53
|
collapse: "▼",
|
|
54
54
|
sortAsc: "▲",
|
|
@@ -58,7 +58,7 @@ const R = {
|
|
|
58
58
|
dragHandle: "⋮⋮",
|
|
59
59
|
toolPanel: "☰"
|
|
60
60
|
};
|
|
61
|
-
class
|
|
61
|
+
class C {
|
|
62
62
|
/**
|
|
63
63
|
* Plugin dependencies - declare other plugins this one requires.
|
|
64
64
|
*
|
|
@@ -282,7 +282,7 @@ class _ {
|
|
|
282
282
|
*/
|
|
283
283
|
get gridIcons() {
|
|
284
284
|
const t = this.grid?.gridConfig?.icons ?? {};
|
|
285
|
-
return { ...
|
|
285
|
+
return { ...y, ...t };
|
|
286
286
|
}
|
|
287
287
|
// #region Animation Helpers
|
|
288
288
|
/**
|
|
@@ -358,24 +358,35 @@ class _ {
|
|
|
358
358
|
}
|
|
359
359
|
// #endregion
|
|
360
360
|
}
|
|
361
|
-
const
|
|
362
|
-
class
|
|
361
|
+
const _ = '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}';
|
|
362
|
+
class E extends C {
|
|
363
363
|
name = "responsive";
|
|
364
364
|
version = "1.0.0";
|
|
365
|
-
styles =
|
|
365
|
+
styles = _;
|
|
366
|
+
/**
|
|
367
|
+
* Plugin manifest declaring incompatibilities with other plugins.
|
|
368
|
+
*/
|
|
369
|
+
static manifest = {
|
|
370
|
+
incompatibleWith: [
|
|
371
|
+
{
|
|
372
|
+
name: "groupingRows",
|
|
373
|
+
reason: "Responsive card layout does not yet support row grouping. The variable row heights (cards vs group headers) cause scroll calculation issues."
|
|
374
|
+
}
|
|
375
|
+
]
|
|
376
|
+
};
|
|
366
377
|
#e;
|
|
367
378
|
#t = !1;
|
|
368
|
-
#
|
|
369
|
-
#
|
|
370
|
-
#
|
|
379
|
+
#n;
|
|
380
|
+
#w = !1;
|
|
381
|
+
#a = 0;
|
|
371
382
|
/** Set of column fields to completely hide */
|
|
372
|
-
#
|
|
383
|
+
#s = /* @__PURE__ */ new Set();
|
|
373
384
|
/** Set of column fields to show value only (no header label) */
|
|
374
|
-
#
|
|
385
|
+
#d = /* @__PURE__ */ new Set();
|
|
375
386
|
/** Currently active breakpoint, or null if none */
|
|
376
|
-
#
|
|
387
|
+
#l = null;
|
|
377
388
|
/** Sorted breakpoints from largest to smallest */
|
|
378
|
-
#
|
|
389
|
+
#c = [];
|
|
379
390
|
/**
|
|
380
391
|
* Check if currently in responsive mode.
|
|
381
392
|
* @returns `true` if the grid is in card layout mode
|
|
@@ -389,9 +400,9 @@ class A extends _ {
|
|
|
389
400
|
* @param enabled - Whether to enable responsive mode
|
|
390
401
|
*/
|
|
391
402
|
setResponsive(t) {
|
|
392
|
-
t !== this.#t && (this.#t = t, this.#
|
|
403
|
+
t !== this.#t && (this.#t = t, this.#u(), this.emit("responsive-change", {
|
|
393
404
|
isResponsive: t,
|
|
394
|
-
width: this.#
|
|
405
|
+
width: this.#a,
|
|
395
406
|
breakpoint: this.config.breakpoint ?? 0
|
|
396
407
|
}));
|
|
397
408
|
}
|
|
@@ -400,7 +411,7 @@ class A extends _ {
|
|
|
400
411
|
* @param width - New breakpoint width in pixels
|
|
401
412
|
*/
|
|
402
413
|
setBreakpoint(t) {
|
|
403
|
-
this.config.breakpoint = t, this.#
|
|
414
|
+
this.config.breakpoint = t, this.#v(this.#a);
|
|
404
415
|
}
|
|
405
416
|
/**
|
|
406
417
|
* Set a custom card renderer.
|
|
@@ -415,33 +426,33 @@ class A extends _ {
|
|
|
415
426
|
* @returns Width of the grid element in pixels
|
|
416
427
|
*/
|
|
417
428
|
getWidth() {
|
|
418
|
-
return this.#
|
|
429
|
+
return this.#a;
|
|
419
430
|
}
|
|
420
431
|
/**
|
|
421
432
|
* Get the currently active breakpoint config (multi-breakpoint mode only).
|
|
422
433
|
* @returns The active BreakpointConfig, or null if no breakpoint is active
|
|
423
434
|
*/
|
|
424
435
|
getActiveBreakpoint() {
|
|
425
|
-
return this.#
|
|
436
|
+
return this.#l;
|
|
426
437
|
}
|
|
427
438
|
attach(t) {
|
|
428
|
-
super.attach(t), this.#
|
|
439
|
+
super.attach(t), this.#h(this.config.hiddenColumns), this.config.breakpoints?.length && (this.#c = [...this.config.breakpoints].sort((e, i) => i.maxWidth - e.maxWidth)), this.#e = new ResizeObserver((e) => {
|
|
429
440
|
const i = e[0]?.contentRect.width ?? 0;
|
|
430
|
-
this.#
|
|
431
|
-
this.#
|
|
441
|
+
this.#a = i, clearTimeout(this.#n), this.#n = setTimeout(() => {
|
|
442
|
+
this.#v(i);
|
|
432
443
|
}, this.config.debounceMs ?? 100);
|
|
433
444
|
}), this.#e.observe(this.gridElement);
|
|
434
445
|
}
|
|
435
446
|
/**
|
|
436
447
|
* Build the hidden and value-only column sets from config.
|
|
437
448
|
*/
|
|
438
|
-
#
|
|
439
|
-
if (this.#
|
|
449
|
+
#h(t) {
|
|
450
|
+
if (this.#s.clear(), this.#d.clear(), !!t)
|
|
440
451
|
for (const e of t)
|
|
441
|
-
typeof e == "string" ? this.#
|
|
452
|
+
typeof e == "string" ? this.#s.add(e) : e.showValue ? this.#d.add(e.field) : this.#s.add(e.field);
|
|
442
453
|
}
|
|
443
454
|
detach() {
|
|
444
|
-
this.#e?.disconnect(), this.#e = void 0, clearTimeout(this.#
|
|
455
|
+
this.#e?.disconnect(), this.#e = void 0, clearTimeout(this.#n), this.#n = void 0, this.gridElement && this.gridElement.removeAttribute("data-responsive"), super.detach();
|
|
445
456
|
}
|
|
446
457
|
/**
|
|
447
458
|
* Apply hidden and value-only columns.
|
|
@@ -449,32 +460,32 @@ class A extends _ {
|
|
|
449
460
|
* In multi-breakpoint mode, applies whenever there's an active breakpoint.
|
|
450
461
|
*/
|
|
451
462
|
afterRender() {
|
|
452
|
-
if (!(this.#
|
|
463
|
+
if (this.#_(), !(this.#c.length > 0 ? this.#l !== null : this.#t))
|
|
453
464
|
return;
|
|
454
|
-
const e = this.#
|
|
465
|
+
const e = this.#s.size > 0, i = this.#d.size > 0;
|
|
455
466
|
if (!e && !i)
|
|
456
467
|
return;
|
|
457
|
-
const
|
|
458
|
-
for (const
|
|
459
|
-
const
|
|
460
|
-
|
|
468
|
+
const n = this.gridElement.querySelectorAll(".cell[data-field]");
|
|
469
|
+
for (const a of n) {
|
|
470
|
+
const r = a.getAttribute("data-field");
|
|
471
|
+
r && (this.#s.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")));
|
|
461
472
|
}
|
|
462
473
|
}
|
|
463
474
|
/**
|
|
464
475
|
* Check if width has crossed any breakpoint threshold.
|
|
465
476
|
* Handles both single breakpoint (legacy) and multi-breakpoint modes.
|
|
466
477
|
*/
|
|
467
|
-
#
|
|
468
|
-
if (this.#
|
|
469
|
-
this.#
|
|
478
|
+
#v(t) {
|
|
479
|
+
if (this.#c.length > 0) {
|
|
480
|
+
this.#R(t);
|
|
470
481
|
return;
|
|
471
482
|
}
|
|
472
483
|
const e = this.config.breakpoint ?? 0;
|
|
473
|
-
e === 0 && !this.#
|
|
484
|
+
e === 0 && !this.#w && (this.#w = !0, console.warn(
|
|
474
485
|
"[tbw-grid:ResponsivePlugin] No breakpoint configured. Responsive mode is disabled. Set a breakpoint based on your grid's column count."
|
|
475
486
|
));
|
|
476
487
|
const i = e > 0 && t < e;
|
|
477
|
-
i !== this.#t && (this.#t = i, this.#
|
|
488
|
+
i !== this.#t && (this.#t = i, this.#u(), this.emit("responsive-change", {
|
|
478
489
|
isResponsive: i,
|
|
479
490
|
width: t,
|
|
480
491
|
breakpoint: e
|
|
@@ -484,14 +495,14 @@ class A extends _ {
|
|
|
484
495
|
* Check breakpoints in multi-breakpoint mode.
|
|
485
496
|
* Evaluates breakpoints from largest to smallest, applying the first match.
|
|
486
497
|
*/
|
|
487
|
-
#
|
|
498
|
+
#R(t) {
|
|
488
499
|
let e = null;
|
|
489
|
-
for (const
|
|
490
|
-
t <=
|
|
491
|
-
if (e !== this.#
|
|
492
|
-
this.#
|
|
493
|
-
const
|
|
494
|
-
|
|
500
|
+
for (const n of this.#c)
|
|
501
|
+
t <= n.maxWidth && (e = n);
|
|
502
|
+
if (e !== this.#l) {
|
|
503
|
+
this.#l = e, e?.hiddenColumns ? this.#h(e.hiddenColumns) : this.#h(this.config.hiddenColumns);
|
|
504
|
+
const n = e?.cardLayout === !0;
|
|
505
|
+
n !== this.#t && (this.#t = n, this.#u()), this.emit("responsive-change", {
|
|
495
506
|
isResponsive: this.#t,
|
|
496
507
|
width: t,
|
|
497
508
|
breakpoint: e?.maxWidth ?? 0
|
|
@@ -499,25 +510,25 @@ class A extends _ {
|
|
|
499
510
|
}
|
|
500
511
|
}
|
|
501
512
|
/** Original row height before entering responsive mode, for restoration on exit */
|
|
502
|
-
#
|
|
513
|
+
#i;
|
|
503
514
|
/**
|
|
504
515
|
* Apply the responsive state to the grid element.
|
|
505
516
|
* Handles scroll reset when entering responsive mode and row height restoration on exit.
|
|
506
517
|
*/
|
|
507
|
-
#
|
|
518
|
+
#u() {
|
|
508
519
|
this.gridElement.toggleAttribute("data-responsive", this.#t);
|
|
509
520
|
const t = this.config.animate !== !1;
|
|
510
521
|
this.gridElement.toggleAttribute("data-responsive-animate", t), this.config.animationDuration && this.gridElement.style.setProperty("--tbw-responsive-duration", `${this.config.animationDuration}ms`);
|
|
511
522
|
const e = this.grid;
|
|
512
523
|
if (this.#t) {
|
|
513
|
-
e._virtualization && (this.#
|
|
524
|
+
e._virtualization && (this.#i = e._virtualization.rowHeight);
|
|
514
525
|
const i = this.gridElement.querySelector(".tbw-scroll-area");
|
|
515
526
|
i && (i.scrollLeft = 0);
|
|
516
527
|
} else {
|
|
517
528
|
const i = this.gridElement.querySelectorAll(".data-grid-row");
|
|
518
|
-
for (const
|
|
519
|
-
|
|
520
|
-
this.#
|
|
529
|
+
for (const n of i)
|
|
530
|
+
n.style.height = "", n.classList.remove("responsive-card");
|
|
531
|
+
this.#i && this.#i > 0 && e._virtualization && (e._virtualization.rowHeight = this.#i, this.#i = void 0), this.#r = void 0, this.#o = void 0, this.#g = void 0;
|
|
521
532
|
}
|
|
522
533
|
}
|
|
523
534
|
/**
|
|
@@ -532,13 +543,13 @@ class A extends _ {
|
|
|
532
543
|
* @returns `true` if rendered (prevents default), `void` for default rendering
|
|
533
544
|
*/
|
|
534
545
|
renderRow(t, e, i) {
|
|
535
|
-
if (!this.#t || !this.config.cardRenderer)
|
|
546
|
+
if (!this.#t || !this.config.cardRenderer || t.__isGroupRow)
|
|
536
547
|
return;
|
|
537
548
|
e.replaceChildren();
|
|
538
|
-
const
|
|
539
|
-
e.
|
|
540
|
-
const
|
|
541
|
-
return
|
|
549
|
+
const n = this.config.cardRenderer(t, i);
|
|
550
|
+
e.className = "data-grid-row responsive-card";
|
|
551
|
+
const a = this.config.cardRowHeight ?? "auto";
|
|
552
|
+
return a !== "auto" ? e.style.height = `${a}px` : e.style.height = "auto", e.appendChild(n), !0;
|
|
542
553
|
}
|
|
543
554
|
/**
|
|
544
555
|
* Handle keyboard navigation in responsive mode.
|
|
@@ -582,8 +593,134 @@ class A extends _ {
|
|
|
582
593
|
}
|
|
583
594
|
return !1;
|
|
584
595
|
}
|
|
596
|
+
// ============================================
|
|
597
|
+
// Variable Height Support for Mixed Row Types
|
|
598
|
+
// ============================================
|
|
599
|
+
/** Measured card height from DOM for virtualization calculations */
|
|
600
|
+
#r;
|
|
601
|
+
/** Measured group row height from DOM for virtualization calculations */
|
|
602
|
+
#o;
|
|
603
|
+
/** Last known card row count for detecting changes (e.g., group expand/collapse) */
|
|
604
|
+
#g;
|
|
605
|
+
/**
|
|
606
|
+
* Get the effective card height for virtualization calculations.
|
|
607
|
+
* Prioritizes DOM-measured height (actual rendered size) over config,
|
|
608
|
+
* since content can overflow the configured height.
|
|
609
|
+
*/
|
|
610
|
+
#b() {
|
|
611
|
+
if (this.#r && this.#r > 0)
|
|
612
|
+
return this.#r;
|
|
613
|
+
const t = this.config.cardRowHeight;
|
|
614
|
+
return typeof t == "number" && t > 0 ? t : 80;
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* Get the effective group row height for virtualization calculations.
|
|
618
|
+
* Uses DOM-measured height, falling back to original row height.
|
|
619
|
+
*/
|
|
620
|
+
#m() {
|
|
621
|
+
return this.#o && this.#o > 0 ? this.#o : this.#i ?? 28;
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Check if there are any group rows in the current dataset.
|
|
625
|
+
* Used to determine if we have mixed row heights.
|
|
626
|
+
*/
|
|
627
|
+
#f() {
|
|
628
|
+
for (const t of this.rows)
|
|
629
|
+
if (t.__isGroupRow)
|
|
630
|
+
return !0;
|
|
631
|
+
return !1;
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Count group rows and card rows in the current dataset.
|
|
635
|
+
*/
|
|
636
|
+
#y() {
|
|
637
|
+
let t = 0, e = 0;
|
|
638
|
+
for (const i of this.rows)
|
|
639
|
+
i.__isGroupRow ? t++ : e++;
|
|
640
|
+
return { groupCount: t, cardCount: e };
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* Return total extra height contributed by mixed row heights.
|
|
644
|
+
* This is called by the grid's virtualization system to adjust scrollbar height.
|
|
645
|
+
*
|
|
646
|
+
* The grid calculates: totalRows * baseRowHeight + pluginExtraHeight
|
|
647
|
+
*
|
|
648
|
+
* For mixed layouts (groups + cards), we need to report the difference between
|
|
649
|
+
* actual heights and what the base calculation assumes:
|
|
650
|
+
* - Extra for groups: groupCount * (groupHeight - baseHeight)
|
|
651
|
+
* - Extra for cards: cardCount * (cardHeight - baseHeight)
|
|
652
|
+
*/
|
|
653
|
+
getExtraHeight() {
|
|
654
|
+
if (!this.#t || !this.config.cardRenderer || !this.#f())
|
|
655
|
+
return 0;
|
|
656
|
+
const t = this.#i ?? 28, e = this.#m(), i = this.#b(), { groupCount: n, cardCount: a } = this.#y(), r = n * Math.max(0, e - t), o = a * Math.max(0, i - t);
|
|
657
|
+
return r + o;
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* Return extra height that appears before a given row index.
|
|
661
|
+
* Used by virtualization to correctly calculate scroll positions.
|
|
662
|
+
*
|
|
663
|
+
* Like getExtraHeight, this accounts for both group and card row heights.
|
|
664
|
+
*/
|
|
665
|
+
getExtraHeightBefore(t) {
|
|
666
|
+
if (!this.#t || !this.config.cardRenderer || !this.#f())
|
|
667
|
+
return 0;
|
|
668
|
+
const e = this.#i ?? 28, i = this.#m(), n = this.#b(), a = Math.max(0, i - e), r = Math.max(0, n - e);
|
|
669
|
+
let o = 0, l = 0;
|
|
670
|
+
const d = this.rows, h = Math.min(t, d.length);
|
|
671
|
+
for (let c = 0; c < h; c++)
|
|
672
|
+
d[c].__isGroupRow ? o++ : l++;
|
|
673
|
+
return o * a + l * r;
|
|
674
|
+
}
|
|
675
|
+
/**
|
|
676
|
+
* Count the number of card rows (non-group rows) in the current dataset.
|
|
677
|
+
*/
|
|
678
|
+
#C() {
|
|
679
|
+
let t = 0;
|
|
680
|
+
for (const e of this.rows)
|
|
681
|
+
e.__isGroupRow || t++;
|
|
682
|
+
return t;
|
|
683
|
+
}
|
|
684
|
+
/** Pending refresh scheduled via microtask */
|
|
685
|
+
#p = !1;
|
|
686
|
+
/**
|
|
687
|
+
* Measure card height from DOM after render and detect row count changes.
|
|
688
|
+
* Called in afterRender to ensure scroll calculations are accurate.
|
|
689
|
+
*
|
|
690
|
+
* This handles two scenarios:
|
|
691
|
+
* 1. Card height changes (content overflow, dynamic sizing)
|
|
692
|
+
* 2. Card row count changes (group expand/collapse)
|
|
693
|
+
* 3. Group row height changes
|
|
694
|
+
*
|
|
695
|
+
* For uniform card layouts (no groups), we update the virtualization row height
|
|
696
|
+
* directly to the card height. For mixed layouts (groups + cards), we use the
|
|
697
|
+
* getExtraHeight mechanism to report height differences.
|
|
698
|
+
*
|
|
699
|
+
* The refresh is deferred via microtask to avoid nested render cycles.
|
|
700
|
+
*/
|
|
701
|
+
#_() {
|
|
702
|
+
if (!this.#t || !this.config.cardRenderer)
|
|
703
|
+
return;
|
|
704
|
+
let t = !1;
|
|
705
|
+
const e = this.grid, i = this.#f(), n = this.#C();
|
|
706
|
+
if (n !== this.#g && (this.#g = n, t = !0), i) {
|
|
707
|
+
const r = this.gridElement.querySelector(".data-grid-row.group-row");
|
|
708
|
+
if (r) {
|
|
709
|
+
const o = r.getBoundingClientRect().height;
|
|
710
|
+
o > 0 && o !== this.#o && (this.#o = o, t = !0);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
const a = this.gridElement.querySelector(".data-grid-row.responsive-card");
|
|
714
|
+
if (a) {
|
|
715
|
+
const r = a.getBoundingClientRect().height;
|
|
716
|
+
r > 0 && r !== this.#r && (this.#r = r, t = !0, !i && e._virtualization && (e._virtualization.rowHeight = r));
|
|
717
|
+
}
|
|
718
|
+
t && !this.#p && (this.#p = !0, queueMicrotask(() => {
|
|
719
|
+
this.#p = !1, this.grid && this.#t && this.grid.refreshVirtualWindow?.(!0, !0);
|
|
720
|
+
}));
|
|
721
|
+
}
|
|
585
722
|
}
|
|
586
723
|
export {
|
|
587
|
-
|
|
724
|
+
E as ResponsivePlugin
|
|
588
725
|
};
|
|
589
726
|
//# sourceMappingURL=index.js.map
|