@cosmicdrift/kumiko-headless 0.204.0 → 0.205.0
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/package.json +2 -2
- package/src/format/index.ts +17 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmicdrift/kumiko-headless",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.205.0",
|
|
4
4
|
"description": "Headless UI logic for Kumiko — Dispatcher contract, Form-Controller, View-Model, Nav-Resolver. Plattform- und React-frei; jeder Renderer (renderer, renderer-web, renderer-native, …) komponiert darauf.",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@cosmicdrift/kumiko-framework": "0.
|
|
39
|
+
"@cosmicdrift/kumiko-framework": "0.205.0",
|
|
40
40
|
"temporal-polyfill": "^0.3.2",
|
|
41
41
|
"zod": "^4.4.3"
|
|
42
42
|
},
|
package/src/format/index.ts
CHANGED
|
@@ -67,6 +67,19 @@ function formatDateCell(
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
// No `locale` fallback to a browser API here (headless has none) — passing
|
|
71
|
+
// `undefined` to Intl.NumberFormat resolves the runtime's default locale,
|
|
72
|
+
// the same value a browser's navigator.language-based guess would produce.
|
|
73
|
+
function formatNumberCell(value: unknown, locale?: string): string {
|
|
74
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return String(value);
|
|
75
|
+
try {
|
|
76
|
+
return new Intl.NumberFormat(locale).format(value);
|
|
77
|
+
} catch {
|
|
78
|
+
// Malformed BCP-47 locale tag — mirrors formatDateCell's fallback above.
|
|
79
|
+
return String(value);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
70
83
|
export { escapeHtml, escapeHtmlAttr, escapeXml, isSafeHref, stripControlChars } from "./escape";
|
|
71
84
|
export { type HtmlValue, html, RawHtml, raw } from "./html-template";
|
|
72
85
|
export { currencyDecimals } from "./money";
|
|
@@ -98,6 +111,10 @@ export function applyFormatSpec(
|
|
|
98
111
|
const sym = (spec["symbol"] as string | undefined) ?? "";
|
|
99
112
|
return sym.length > 0 ? `${value} ${sym}` : String(value);
|
|
100
113
|
}
|
|
114
|
+
case "number":
|
|
115
|
+
case "decimal":
|
|
116
|
+
case "bigInt":
|
|
117
|
+
return formatNumberCell(value, spec["locale"] as string | undefined);
|
|
101
118
|
case "priority": {
|
|
102
119
|
const emptyLabel = (spec["emptyLabel"] as string | undefined) ?? "—";
|
|
103
120
|
const prefix = (spec["prefix"] as string | undefined) ?? "";
|