@merkaly/nuxt 0.7.3 → 0.7.4
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/dist/module.json
CHANGED
|
@@ -21,14 +21,17 @@ function extractConstraints(constructor) {
|
|
|
21
21
|
return constraints;
|
|
22
22
|
}
|
|
23
23
|
function applyErrors(result, errors, state) {
|
|
24
|
-
|
|
25
|
-
errors[key] = "";
|
|
26
|
-
state[key] = true;
|
|
27
|
-
}
|
|
24
|
+
const failures = /* @__PURE__ */ new Map();
|
|
28
25
|
for (const error of result) {
|
|
29
26
|
const messages = error.constraints ? Object.values(error.constraints) : [];
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
failures.set(error.property, messages[0] || "Invalid");
|
|
28
|
+
}
|
|
29
|
+
const keys = /* @__PURE__ */ new Set([...Object.keys(errors), ...failures.keys()]);
|
|
30
|
+
for (const key of keys) {
|
|
31
|
+
const message = failures.get(key) ?? "";
|
|
32
|
+
const isValid = !failures.has(key);
|
|
33
|
+
if (errors[key] !== message) errors[key] = message;
|
|
34
|
+
if (state[key] !== isValid) state[key] = isValid;
|
|
32
35
|
}
|
|
33
36
|
}
|
|
34
37
|
function mergeAttrs(constraints, state) {
|
|
@@ -3,5 +3,17 @@ export interface FormatMoneyOptions {
|
|
|
3
3
|
currency?: string;
|
|
4
4
|
locale?: string;
|
|
5
5
|
mode?: Intl.NumberFormatOptionsStyle;
|
|
6
|
+
notation?: Intl.NumberFormatOptions['notation'];
|
|
7
|
+
maximumFractionDigits?: number;
|
|
6
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Formats a monetary value held as an **integer in the minor unit (cents)**.
|
|
11
|
+
*
|
|
12
|
+
* Across Merkaly money is stored and transported as integer cents ($1.00 -> 100),
|
|
13
|
+
* so this helper divides by `base` (default 100) before formatting. Pass cents in,
|
|
14
|
+
* get a currency string out: `formatMoney(100)` -> `"$1.00"`.
|
|
15
|
+
*
|
|
16
|
+
* For non-currency numbers (counts, units, percentages) use `formatNumber` /
|
|
17
|
+
* `MKFormatNumber` instead — those do NOT divide and would show the raw cents.
|
|
18
|
+
*/
|
|
7
19
|
export declare function formatMoney(value: number, options?: FormatMoneyOptions): string;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export function formatMoney(value, options = {}) {
|
|
2
2
|
return (value / (options.base ?? 100)).toLocaleString(options.locale ?? "en-US", {
|
|
3
3
|
style: options.mode ?? "currency",
|
|
4
|
-
currency: options.currency ?? "USD"
|
|
4
|
+
currency: options.currency ?? "USD",
|
|
5
|
+
notation: options.notation,
|
|
6
|
+
maximumFractionDigits: options.maximumFractionDigits
|
|
5
7
|
});
|
|
6
8
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@merkaly/nuxt",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/merkaly-io/nuxt.git"
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"notivue": "^2.4.5",
|
|
57
57
|
"nuxt": "^4.4.8",
|
|
58
58
|
"reflect-metadata": "^0.2.2",
|
|
59
|
-
"sass": "^1.
|
|
59
|
+
"sass": "^1.101.0",
|
|
60
60
|
"typescript": "~5.9.3",
|
|
61
61
|
"v-money3": "^3.26.1",
|
|
62
62
|
"vite-svg-loader": "^5.1.1",
|