@r2digisolutions/components 0.3.5 → 0.3.6
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.
|
@@ -260,14 +260,19 @@
|
|
|
260
260
|
let contextTarget = $state<CellRef | null>(null);
|
|
261
261
|
let contextOpen = $state(false);
|
|
262
262
|
let contextAnchor = $state<ContextMenuAnchor | null>(null);
|
|
263
|
-
/**
|
|
264
|
-
|
|
263
|
+
/**
|
|
264
|
+
* SSR + first client paint: do not apply `hideBelow` yet (show full table).
|
|
265
|
+
* After mount, measure window and refine columns — no hydration mismatch.
|
|
266
|
+
*/
|
|
267
|
+
let viewportMeasured = $state(false);
|
|
268
|
+
let viewportWidth = $state(Number.POSITIVE_INFINITY);
|
|
265
269
|
let filterColumnDraft = $state('');
|
|
266
270
|
let filterValueDraft = $state('');
|
|
267
271
|
|
|
268
272
|
$effect(() => {
|
|
269
273
|
const onResize = () => {
|
|
270
274
|
viewportWidth = window.innerWidth;
|
|
275
|
+
viewportMeasured = true;
|
|
271
276
|
};
|
|
272
277
|
window.addEventListener('resize', onResize);
|
|
273
278
|
onResize();
|
|
@@ -275,12 +280,14 @@
|
|
|
275
280
|
});
|
|
276
281
|
|
|
277
282
|
const autoHiddenColumns = $derived(
|
|
278
|
-
|
|
279
|
-
(
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
283
|
+
viewportMeasured
|
|
284
|
+
? columns.filter(
|
|
285
|
+
(c) =>
|
|
286
|
+
!c.hidden &&
|
|
287
|
+
c.hideBelow &&
|
|
288
|
+
!isColumnVisibleAtWidth(c.hideBelow, viewportWidth)
|
|
289
|
+
)
|
|
290
|
+
: []
|
|
284
291
|
);
|
|
285
292
|
|
|
286
293
|
/** Expand controls only when there is content to reveal. */
|
|
@@ -297,7 +304,13 @@
|
|
|
297
304
|
const visibleColumns = $derived(
|
|
298
305
|
columns.filter((c) => {
|
|
299
306
|
if (c.hidden) return false;
|
|
300
|
-
if (
|
|
307
|
+
if (
|
|
308
|
+
viewportMeasured &&
|
|
309
|
+
c.hideBelow &&
|
|
310
|
+
!isColumnVisibleAtWidth(c.hideBelow, viewportWidth)
|
|
311
|
+
) {
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
301
314
|
return true;
|
|
302
315
|
})
|
|
303
316
|
);
|
|
@@ -392,11 +405,20 @@
|
|
|
392
405
|
);
|
|
393
406
|
|
|
394
407
|
function getKey(row: T, index: number): string {
|
|
395
|
-
|
|
408
|
+
try {
|
|
409
|
+
return resolveRowKey(row, rowKey, index);
|
|
410
|
+
} catch {
|
|
411
|
+
// Bad accessor/rowKey must not take down SSR (e.g. null profile).
|
|
412
|
+
return String(index);
|
|
413
|
+
}
|
|
396
414
|
}
|
|
397
415
|
|
|
398
416
|
function getValue(row: T, column: DataGridColumn<T>): unknown {
|
|
399
|
-
|
|
417
|
+
try {
|
|
418
|
+
return resolveAccessor(row, column.accessor, column.id);
|
|
419
|
+
} catch {
|
|
420
|
+
return undefined;
|
|
421
|
+
}
|
|
400
422
|
}
|
|
401
423
|
|
|
402
424
|
function formatCell(value: unknown): string {
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { resolveAccessor } from '../../../utils/columnAccessor.js';
|
|
2
2
|
export function cellText(row, column) {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
try {
|
|
4
|
+
const value = resolveAccessor(row, column.accessor, column.id);
|
|
5
|
+
if (value == null)
|
|
6
|
+
return '';
|
|
7
|
+
if (typeof value === 'boolean')
|
|
8
|
+
return value ? 'Yes' : 'No';
|
|
9
|
+
return String(value);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
5
12
|
return '';
|
|
6
|
-
|
|
7
|
-
return value ? 'Yes' : 'No';
|
|
8
|
-
return String(value);
|
|
13
|
+
}
|
|
9
14
|
}
|
|
10
15
|
/** Client-side search + equality/contains filters. */
|
|
11
16
|
export function filterRows(rows, columns, query, filters) {
|
|
@@ -60,11 +60,19 @@
|
|
|
60
60
|
let sortDir = $state<SortDir>(null);
|
|
61
61
|
|
|
62
62
|
function getKey(row: T, index: number): string {
|
|
63
|
-
|
|
63
|
+
try {
|
|
64
|
+
return resolveRowKey(row, rowKey, index);
|
|
65
|
+
} catch {
|
|
66
|
+
return String(index);
|
|
67
|
+
}
|
|
64
68
|
}
|
|
65
69
|
|
|
66
70
|
function getValue(row: T, column: DataTableColumn<T>): unknown {
|
|
67
|
-
|
|
71
|
+
try {
|
|
72
|
+
return resolveAccessor(row, column.accessor, column.id);
|
|
73
|
+
} catch {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
68
76
|
}
|
|
69
77
|
|
|
70
78
|
function formatCell(value: unknown): string {
|