runeforge 0.0.39 → 0.0.40
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const formatBoolean: (trueLabel?: string, falseLabel?: string) => () => (value: boolean) => string;
|
|
2
|
-
export declare const formatDatetime: (format?: string) => () => (value: Date) => string;
|
|
2
|
+
export declare const formatDatetime: (format?: string) => (() => (value: Date) => string);
|
|
3
3
|
export declare function formatTruncateTextUpTo(maxLength: number): () => (value: string) => string;
|
|
4
4
|
export declare function formatInstance<T extends Record<string, unknown>>(attribute: keyof T & string, instances: T[], urlPath: string, idKey?: keyof T & string): (value: unknown) => string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const formatBoolean = (trueLabel = 'Sí', falseLabel = 'No') => () => (value) =>
|
|
1
|
+
export const formatBoolean = (trueLabel = 'Sí', falseLabel = 'No') => () => (value) => value ? trueLabel : falseLabel;
|
|
2
2
|
// Supported tokens: dd · mm · YYYY · HH · MM · ss
|
|
3
3
|
const TOKENS = {
|
|
4
4
|
dd: (d) => String(d.getDate()).padStart(2, '0'),
|
|
@@ -6,10 +6,15 @@ const TOKENS = {
|
|
|
6
6
|
YYYY: (d) => String(d.getFullYear()),
|
|
7
7
|
HH: (d) => String(d.getHours()).padStart(2, '0'),
|
|
8
8
|
MM: (d) => String(d.getMinutes()).padStart(2, '0'),
|
|
9
|
-
ss: (d) => String(d.getSeconds()).padStart(2, '0')
|
|
9
|
+
ss: (d) => String(d.getSeconds()).padStart(2, '0')
|
|
10
10
|
};
|
|
11
11
|
export const formatDatetime = (format = 'dd/mm/YYYY HH:MM') => {
|
|
12
12
|
const fmt = (value) => {
|
|
13
|
+
// `null`/`undefined`/`''` (an unset field) must render blank, not epoch 0
|
|
14
|
+
// — `new Date(null)` is 1970-01-01, a "valid" Date whose getTime() isn't
|
|
15
|
+
// NaN, so it would otherwise slip past the invalid-date check below.
|
|
16
|
+
if (value === null || value === undefined || value === '')
|
|
17
|
+
return '';
|
|
13
18
|
const d = new Date(value);
|
|
14
19
|
if (isNaN(d.getTime()))
|
|
15
20
|
return '';
|