@lavalogic/scoria 0.37.23 → 0.37.24
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.
|
@@ -24,6 +24,33 @@
|
|
|
24
24
|
cell.column.columnDef.getDisplayValue?.(cell.row.original, cell.row.originalIndex) ?? value
|
|
25
25
|
);
|
|
26
26
|
|
|
27
|
+
/** For Date-typed display columns, expose both the local-time and UTC
|
|
28
|
+
* representations of the raw accessor value as a multi-line tooltip.
|
|
29
|
+
* The cell's body shows the locale-formatted value (via
|
|
30
|
+
* `getDisplayValue`); the title attribute below lets users hover to
|
|
31
|
+
* see Local + UTC side-by-side without expanding the column. */
|
|
32
|
+
const dateTooltip: string | undefined = $derived.by(() => {
|
|
33
|
+
if (cell.column.columnDef.filterValueType !== 'Date') {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
if (value == null || value === '' || value instanceof Promise) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
let d: Date | undefined;
|
|
40
|
+
if (value instanceof Date) {
|
|
41
|
+
d = value;
|
|
42
|
+
} else if (typeof value === 'string' || typeof value === 'number') {
|
|
43
|
+
const parsed = new Date(value);
|
|
44
|
+
if (!Number.isNaN(parsed.getTime())) {
|
|
45
|
+
d = parsed;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (d == null) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
return `Local: ${d.toLocaleString()}\nUTC: ${d.toUTCString()}`;
|
|
52
|
+
});
|
|
53
|
+
|
|
27
54
|
const tableContext = getContext<TableContext<T, RowIdType>>(TableContext.identifier);
|
|
28
55
|
|
|
29
56
|
const options: Array<SelectOption<unknown>> = $derived(
|
|
@@ -106,6 +133,7 @@
|
|
|
106
133
|
class:has-modal={!!modalComponent}
|
|
107
134
|
tabIndex={hasValue ? 0 : undefined}
|
|
108
135
|
class="focusable"
|
|
136
|
+
title={dateTooltip}
|
|
109
137
|
style={focusDetails.outline}
|
|
110
138
|
class:multifocus={hasValue && focusDetails.isMultiFocused}
|
|
111
139
|
class:multifocus-start={hasValue && focusDetails.isMultiFocusStart}
|
|
@@ -325,26 +325,33 @@ export function createColumnFactory() {
|
|
|
325
325
|
: opts.filterValueType === 'String'
|
|
326
326
|
? 'text'
|
|
327
327
|
: 'display';
|
|
328
|
-
//
|
|
329
|
-
//
|
|
330
|
-
//
|
|
331
|
-
//
|
|
332
|
-
//
|
|
333
|
-
//
|
|
328
|
+
// For Date-typed display columns, leave the accessor returning
|
|
329
|
+
// the raw Date / ISO string (filter / sort logic still operates
|
|
330
|
+
// on the raw value) and surface the formatted local-time
|
|
331
|
+
// string via `getDisplayValue`. The cell renders
|
|
332
|
+
// `getDisplayValue` for visible text and reads the raw value
|
|
333
|
+
// from `accessorFn` to compose the hover tooltip showing both
|
|
334
|
+
// the local-time and UTC representations.
|
|
334
335
|
const rawValue = opts.value;
|
|
335
|
-
const valueAccessor =
|
|
336
|
+
const valueAccessor = rawValue;
|
|
337
|
+
const dateDisplayValue = opts.filterValueType === 'Date'
|
|
336
338
|
? (row, index) => {
|
|
337
339
|
const v = rawValue(row, index);
|
|
338
340
|
if (v instanceof Promise) {
|
|
339
|
-
return v.then(
|
|
341
|
+
return v.then((resolved) => {
|
|
342
|
+
const formatted = formatLocaleDate(resolved);
|
|
343
|
+
return formatted == null ? null : String(formatted);
|
|
344
|
+
});
|
|
340
345
|
}
|
|
341
|
-
|
|
346
|
+
const formatted = formatLocaleDate(v);
|
|
347
|
+
return formatted == null ? null : String(formatted);
|
|
342
348
|
}
|
|
343
|
-
:
|
|
349
|
+
: undefined;
|
|
344
350
|
const def = new DisplayDef({
|
|
345
351
|
id,
|
|
346
352
|
...commonProps(opts, inferredKind),
|
|
347
353
|
accessorFn: valueAccessor,
|
|
354
|
+
getDisplayValue: dateDisplayValue,
|
|
348
355
|
modal: opts.modal,
|
|
349
356
|
// Display columns have no implicit filter type (unlike the
|
|
350
357
|
// typed kinds where the factory pins one based on the
|