@aiaiai-pt/design-system 0.46.2 → 0.46.3
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.
|
@@ -22,15 +22,24 @@
|
|
|
22
22
|
* Everything here is PURE and dependency-free.
|
|
23
23
|
*/
|
|
24
24
|
export type ObjectFallback = "redact" | "json";
|
|
25
|
+
/** How a boolean renders: "raw" (default) → "true"/"false" (both hosts'
|
|
26
|
+
* historical output); "yes-no" → "Yes"/"No" (the staff admin's cell copy —
|
|
27
|
+
* #748 lifts it here so the admin's private renderCell fork can retire). */
|
|
28
|
+
export type BooleanDisplay = "raw" | "yes-no";
|
|
25
29
|
/**
|
|
26
|
-
* Pure value → display string. Scalars stringify
|
|
27
|
-
* formatted members; a
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
30
|
+
* Pure value → display string. Scalars stringify (booleans per
|
|
31
|
+
* `booleanDisplay`); arrays join their non-empty formatted members; a
|
|
32
|
+
* disclosed relationship object renders its human handle
|
|
33
|
+
* (label→name→display_name→title→code) then its id — `display_name`/`code`
|
|
34
|
+
* joined the order in #748 so an expanded rel carrying only those (ontology
|
|
35
|
+
* rows commonly do) renders its handle, not its UUID. An UNKNOWN object
|
|
36
|
+
* renders per `objectFallback`: "redact" (default) → "" (never dumps
|
|
37
|
+
* internals — the public security boundary); "json" → pretty JSON (the admin
|
|
38
|
+
* operator view).
|
|
31
39
|
*/
|
|
32
40
|
export declare function formatScalar(value: unknown, opts?: {
|
|
33
41
|
objectFallback?: ObjectFallback;
|
|
42
|
+
booleanDisplay?: BooleanDisplay;
|
|
34
43
|
}): string;
|
|
35
44
|
/** True for an ISO-8601 timestamp STRING (not a bare date). Value-shape
|
|
36
45
|
* detection — used where the schema can't tell us the field is a datetime. */
|
|
@@ -60,6 +69,7 @@ export declare function displayCell(value: unknown, locale: string, opts?: {
|
|
|
60
69
|
treatAsDate?: boolean;
|
|
61
70
|
treatAsDateTime?: boolean;
|
|
62
71
|
objectFallback?: ObjectFallback;
|
|
72
|
+
booleanDisplay?: BooleanDisplay;
|
|
63
73
|
}): string;
|
|
64
74
|
/** Operator copy for a status value (falls back to the raw value). `labels` is
|
|
65
75
|
* untrusted DATA — a non-object/array is ignored. */
|
|
@@ -24,21 +24,37 @@
|
|
|
24
24
|
|
|
25
25
|
export type ObjectFallback = "redact" | "json";
|
|
26
26
|
|
|
27
|
+
/** How a boolean renders: "raw" (default) → "true"/"false" (both hosts'
|
|
28
|
+
* historical output); "yes-no" → "Yes"/"No" (the staff admin's cell copy —
|
|
29
|
+
* #748 lifts it here so the admin's private renderCell fork can retire). */
|
|
30
|
+
export type BooleanDisplay = "raw" | "yes-no";
|
|
31
|
+
|
|
27
32
|
/**
|
|
28
|
-
* Pure value → display string. Scalars stringify
|
|
29
|
-
* formatted members; a
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
+
* Pure value → display string. Scalars stringify (booleans per
|
|
34
|
+
* `booleanDisplay`); arrays join their non-empty formatted members; a
|
|
35
|
+
* disclosed relationship object renders its human handle
|
|
36
|
+
* (label→name→display_name→title→code) then its id — `display_name`/`code`
|
|
37
|
+
* joined the order in #748 so an expanded rel carrying only those (ontology
|
|
38
|
+
* rows commonly do) renders its handle, not its UUID. An UNKNOWN object
|
|
39
|
+
* renders per `objectFallback`: "redact" (default) → "" (never dumps
|
|
40
|
+
* internals — the public security boundary); "json" → pretty JSON (the admin
|
|
41
|
+
* operator view).
|
|
33
42
|
*/
|
|
34
43
|
export function formatScalar(
|
|
35
44
|
value: unknown,
|
|
36
|
-
opts: {
|
|
45
|
+
opts: {
|
|
46
|
+
objectFallback?: ObjectFallback;
|
|
47
|
+
booleanDisplay?: BooleanDisplay;
|
|
48
|
+
} = {},
|
|
37
49
|
): string {
|
|
38
50
|
// `== null` catches both null and undefined.
|
|
39
51
|
if (value == null) return "";
|
|
40
52
|
if (typeof value === "string") return value;
|
|
41
|
-
if (typeof value === "
|
|
53
|
+
if (typeof value === "boolean") {
|
|
54
|
+
if (opts.booleanDisplay === "yes-no") return value ? "Yes" : "No";
|
|
55
|
+
return String(value);
|
|
56
|
+
}
|
|
57
|
+
if (typeof value === "number") {
|
|
42
58
|
return String(value);
|
|
43
59
|
}
|
|
44
60
|
if (Array.isArray(value)) {
|
|
@@ -49,7 +65,7 @@ export function formatScalar(
|
|
|
49
65
|
}
|
|
50
66
|
if (typeof value === "object") {
|
|
51
67
|
const o = value as Record<string, unknown>;
|
|
52
|
-
for (const k of ["label", "name", "title"]) {
|
|
68
|
+
for (const k of ["label", "name", "display_name", "title", "code"]) {
|
|
53
69
|
const v = o[k];
|
|
54
70
|
if (typeof v === "string" && v) return v;
|
|
55
71
|
}
|
|
@@ -130,6 +146,7 @@ export function displayCell(
|
|
|
130
146
|
treatAsDate?: boolean;
|
|
131
147
|
treatAsDateTime?: boolean;
|
|
132
148
|
objectFallback?: ObjectFallback;
|
|
149
|
+
booleanDisplay?: BooleanDisplay;
|
|
133
150
|
} = {},
|
|
134
151
|
): string {
|
|
135
152
|
if (typeof value === "string" && value) {
|
|
@@ -137,7 +154,10 @@ export function displayCell(
|
|
|
137
154
|
if (opts.treatAsDateTime) return formatDateTime(value, locale);
|
|
138
155
|
}
|
|
139
156
|
if (isIsoTimestamp(value)) return formatTimestamp(value, locale);
|
|
140
|
-
return formatScalar(value, {
|
|
157
|
+
return formatScalar(value, {
|
|
158
|
+
objectFallback: opts.objectFallback,
|
|
159
|
+
booleanDisplay: opts.booleanDisplay,
|
|
160
|
+
});
|
|
141
161
|
}
|
|
142
162
|
|
|
143
163
|
/** Operator copy for a status value (falls back to the raw value). `labels` is
|