@selectwin/kit 0.1.200 → 0.1.201
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/SelectDocumentField.d.ts +1 -1
- package/dist/SelectDocumentField.js +5 -1
- package/dist/SelectFeeBreakdown.js +43 -40
- package/dist/SelectLocale.d.ts +7 -0
- package/dist/SelectLocale.js +14 -2
- package/dist/SelectMoney.js +71 -64
- package/dist/internal/document.d.ts +5 -6
- package/dist/internal/document.js +10 -9
- package/dist/internal/money.d.ts +5 -4
- package/dist/internal/money.js +12 -8
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare function SelectDocumentField({ label, value, onChange, hint, error, onBlur, required, name, }: {
|
|
2
2
|
label?: string;
|
|
3
|
-
/**
|
|
3
|
+
/** O valor limpo, sem a máscara: os dígitos e, no CNPJ alfanumérico, as letras em maiúsculas. */
|
|
4
4
|
value: string;
|
|
5
5
|
onChange: (clean: string) => void;
|
|
6
6
|
hint?: string;
|
|
@@ -8,7 +8,11 @@ function a({ label: a = "CPF/CNPJ", value: o, onChange: s, hint: c, error: l, on
|
|
|
8
8
|
label: a,
|
|
9
9
|
value: r(o),
|
|
10
10
|
onChange: (e) => s(t(e)),
|
|
11
|
-
inputMode: "
|
|
11
|
+
inputMode: "text",
|
|
12
|
+
inputProps: {
|
|
13
|
+
autoCapitalize: "characters",
|
|
14
|
+
spellCheck: !1
|
|
15
|
+
},
|
|
12
16
|
autoComplete: "off",
|
|
13
17
|
maxLength: 18,
|
|
14
18
|
hint: l ? void 0 : c ?? (p || void 0),
|
|
@@ -1,88 +1,91 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { useSelectLocale as e, useSelectMessages as t } from "./SelectLocale.js";
|
|
2
|
+
import { SelectMoney as n } from "./SelectMoney.js";
|
|
3
|
+
import { forwardRef as r } from "react";
|
|
4
|
+
import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
4
5
|
//#region src/SelectFeeBreakdown.tsx
|
|
5
|
-
var
|
|
6
|
-
let
|
|
7
|
-
return /* @__PURE__ */
|
|
8
|
-
ref:
|
|
9
|
-
...
|
|
10
|
-
className: `select-fees${
|
|
6
|
+
var s = r(function({ grossCents: r, fees: s, netCents: c, grossLabel: l, netLabel: u, bar: d = !1, barLabel: f, className: p, ...m }, h) {
|
|
7
|
+
let g = t().fees, _ = e(), v = l ?? g.gross, y = u ?? g.net, b = c ?? r - s.reduce((e, t) => e + t.cents, 0), x = Math.max(0, r - b), S = d && r > 0 && b >= 0, C = r > 0 ? x / r * 100 : 0;
|
|
8
|
+
return /* @__PURE__ */ o("div", {
|
|
9
|
+
ref: h,
|
|
10
|
+
...m,
|
|
11
|
+
className: `select-fees${S ? " select-fees--bar" : ""}${p ? " " + p : ""}`,
|
|
11
12
|
children: [
|
|
12
|
-
|
|
13
|
+
S && /* @__PURE__ */ o("div", {
|
|
13
14
|
className: "select-fees__visual",
|
|
14
|
-
children: [/* @__PURE__ */
|
|
15
|
+
children: [/* @__PURE__ */ o("div", {
|
|
15
16
|
className: "select-fees__bar",
|
|
16
17
|
"aria-hidden": "true",
|
|
17
|
-
children: [/* @__PURE__ */
|
|
18
|
+
children: [/* @__PURE__ */ a("span", {
|
|
18
19
|
className: "select-fees__barnet",
|
|
19
|
-
style: { flexGrow:
|
|
20
|
-
children: /* @__PURE__ */
|
|
20
|
+
style: { flexGrow: b },
|
|
21
|
+
children: /* @__PURE__ */ a("span", {
|
|
21
22
|
className: "select-fees__barlabel",
|
|
22
|
-
children:
|
|
23
|
-
|
|
23
|
+
children: f ?? /* @__PURE__ */ o(i, { children: [
|
|
24
|
+
y,
|
|
24
25
|
" · ",
|
|
25
|
-
/* @__PURE__ */
|
|
26
|
+
/* @__PURE__ */ a(n, { cents: b })
|
|
26
27
|
] })
|
|
27
28
|
})
|
|
28
|
-
}),
|
|
29
|
+
}), x > 0 && /* @__PURE__ */ a("span", {
|
|
29
30
|
className: "select-fees__barfee",
|
|
30
|
-
style: { flexGrow:
|
|
31
|
+
style: { flexGrow: x }
|
|
31
32
|
})]
|
|
32
|
-
}), /* @__PURE__ */
|
|
33
|
+
}), /* @__PURE__ */ o("div", {
|
|
33
34
|
className: "select-fees__legend",
|
|
34
|
-
children: [
|
|
35
|
+
children: [x > 0 && /* @__PURE__ */ o("span", {
|
|
35
36
|
className: "select-fees__legenditem",
|
|
36
37
|
children: [
|
|
37
|
-
/* @__PURE__ */
|
|
38
|
+
/* @__PURE__ */ a("span", {
|
|
38
39
|
className: "select-fees__dot select-fees__dot--fee",
|
|
39
40
|
"aria-hidden": "true"
|
|
40
41
|
}),
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
g.fees,
|
|
43
|
+
" ",
|
|
44
|
+
/* @__PURE__ */ a(n, { cents: x }),
|
|
43
45
|
" (",
|
|
44
|
-
|
|
46
|
+
C.toLocaleString(_ === "en" ? "en-US" : "pt-BR", {
|
|
45
47
|
maximumFractionDigits: 1,
|
|
46
48
|
minimumFractionDigits: 1
|
|
47
49
|
}),
|
|
48
50
|
"%)"
|
|
49
51
|
]
|
|
50
|
-
}), /* @__PURE__ */
|
|
52
|
+
}), /* @__PURE__ */ o("span", {
|
|
51
53
|
className: "select-fees__legenditem",
|
|
52
54
|
children: [
|
|
53
|
-
/* @__PURE__ */
|
|
55
|
+
/* @__PURE__ */ a("span", {
|
|
54
56
|
className: "select-fees__dot select-fees__dot--net",
|
|
55
57
|
"aria-hidden": "true"
|
|
56
58
|
}),
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
g.netShort,
|
|
60
|
+
" ",
|
|
61
|
+
/* @__PURE__ */ a(n, { cents: b })
|
|
59
62
|
]
|
|
60
63
|
})]
|
|
61
64
|
})]
|
|
62
65
|
}),
|
|
63
|
-
/* @__PURE__ */
|
|
66
|
+
/* @__PURE__ */ o("div", {
|
|
64
67
|
className: "select-fees__row",
|
|
65
|
-
children: [/* @__PURE__ */
|
|
68
|
+
children: [/* @__PURE__ */ a("span", { children: v }), /* @__PURE__ */ a("span", { children: /* @__PURE__ */ a(n, { cents: r }) })]
|
|
66
69
|
}),
|
|
67
|
-
|
|
70
|
+
s.map((e) => /* @__PURE__ */ o("div", {
|
|
68
71
|
className: "select-fees__row",
|
|
69
|
-
children: [/* @__PURE__ */
|
|
72
|
+
children: [/* @__PURE__ */ a("span", { children: e.label }), /* @__PURE__ */ o("span", {
|
|
70
73
|
className: "select-fees__neg",
|
|
71
|
-
children: ["−\xA0", /* @__PURE__ */
|
|
74
|
+
children: ["−\xA0", /* @__PURE__ */ a(n, { cents: e.cents })]
|
|
72
75
|
})]
|
|
73
|
-
},
|
|
74
|
-
/* @__PURE__ */
|
|
75
|
-
/* @__PURE__ */
|
|
76
|
+
}, e.label)),
|
|
77
|
+
/* @__PURE__ */ a("div", { className: "select-fees__divider" }),
|
|
78
|
+
/* @__PURE__ */ o("div", {
|
|
76
79
|
className: "select-fees__row select-fees__row--net",
|
|
77
|
-
children: [/* @__PURE__ */
|
|
80
|
+
children: [/* @__PURE__ */ a("span", { children: y }), /* @__PURE__ */ a("span", {
|
|
78
81
|
className: "select-fees__netvalue",
|
|
79
|
-
children: /* @__PURE__ */
|
|
82
|
+
children: /* @__PURE__ */ a(n, { cents: b })
|
|
80
83
|
})]
|
|
81
84
|
})
|
|
82
85
|
]
|
|
83
86
|
});
|
|
84
87
|
});
|
|
85
88
|
//#endregion
|
|
86
|
-
export {
|
|
89
|
+
export { s as SelectFeeBreakdown };
|
|
87
90
|
|
|
88
91
|
//# sourceMappingURL=SelectFeeBreakdown.js.map
|
package/dist/SelectLocale.d.ts
CHANGED
|
@@ -75,6 +75,13 @@ export interface SelectKitMessages {
|
|
|
75
75
|
sideNav: {
|
|
76
76
|
pending: (hint: string) => string;
|
|
77
77
|
};
|
|
78
|
+
/** 0.1.201: o SelectFeeBreakdown — os rótulos de sempre e a legenda da barra. */
|
|
79
|
+
fees: {
|
|
80
|
+
gross: string;
|
|
81
|
+
net: string;
|
|
82
|
+
fees: string;
|
|
83
|
+
netShort: string;
|
|
84
|
+
};
|
|
78
85
|
}
|
|
79
86
|
/** Os dicionários do kit, para quem quer conferir ou montar um texto do mesmo jeito. */
|
|
80
87
|
export declare const selectKitMessages: Readonly<Record<SelectLocaleCode, SelectKitMessages>>;
|
package/dist/SelectLocale.js
CHANGED
|
@@ -80,7 +80,13 @@ var r = {
|
|
|
80
80
|
progressLabel: "Progresso",
|
|
81
81
|
progress: (e, t) => `${e} de ${t}`
|
|
82
82
|
},
|
|
83
|
-
sideNav: { pending: (e) => `${e} (com pendências)` }
|
|
83
|
+
sideNav: { pending: (e) => `${e} (com pendências)` },
|
|
84
|
+
fees: {
|
|
85
|
+
gross: "Valor bruto",
|
|
86
|
+
net: "Valor líquido",
|
|
87
|
+
fees: "Taxas",
|
|
88
|
+
netShort: "Líquido"
|
|
89
|
+
}
|
|
84
90
|
},
|
|
85
91
|
en: {
|
|
86
92
|
common: {
|
|
@@ -161,7 +167,13 @@ var r = {
|
|
|
161
167
|
progressLabel: "Progress",
|
|
162
168
|
progress: (e, t) => `${e} of ${t}`
|
|
163
169
|
},
|
|
164
|
-
sideNav: { pending: (e) => `${e} (pending)` }
|
|
170
|
+
sideNav: { pending: (e) => `${e} (pending)` },
|
|
171
|
+
fees: {
|
|
172
|
+
gross: "Gross amount",
|
|
173
|
+
net: "Net amount",
|
|
174
|
+
fees: "Fees",
|
|
175
|
+
netShort: "Net"
|
|
176
|
+
}
|
|
165
177
|
}
|
|
166
178
|
}, i = e(null);
|
|
167
179
|
function a({ locale: e, children: t }) {
|
package/dist/SelectMoney.js
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
/* empty css */
|
|
2
2
|
import { EyeIcon as e, EyeOffIcon as t } from "./icons.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { useSelectLocale as n } from "./SelectLocale.js";
|
|
4
|
+
import { SelectIconButton as r } from "./SelectIconButton.js";
|
|
5
|
+
import { centsToBRL as i } from "./internal/money.js";
|
|
6
|
+
import { createContext as a, forwardRef as o, useCallback as s, useContext as c, useEffect as l, useMemo as u, useState as d, useSyncExternalStore as f } from "react";
|
|
7
|
+
import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
7
8
|
//#region src/SelectMoney.tsx
|
|
8
|
-
var
|
|
9
|
+
var g = "sw:hide-money", _ = {
|
|
9
10
|
hidden: !1,
|
|
10
11
|
toggle: () => {},
|
|
11
12
|
setHidden: () => {}
|
|
12
|
-
},
|
|
13
|
-
function
|
|
13
|
+
}, v = a(null);
|
|
14
|
+
function y() {
|
|
14
15
|
try {
|
|
15
|
-
return localStorage.getItem(
|
|
16
|
+
return localStorage.getItem(g) === "1";
|
|
16
17
|
} catch {
|
|
17
18
|
return !1;
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
|
-
function
|
|
21
|
+
function b(e) {
|
|
21
22
|
try {
|
|
22
|
-
localStorage.setItem(
|
|
23
|
+
localStorage.setItem(g, e ? "1" : "0");
|
|
23
24
|
} catch {}
|
|
24
25
|
}
|
|
25
|
-
function
|
|
26
|
+
function x() {
|
|
26
27
|
let e = 0, t = /* @__PURE__ */ new Set(), n = () => t.forEach((e) => e());
|
|
27
28
|
return {
|
|
28
29
|
mark() {
|
|
@@ -40,16 +41,16 @@ function b() {
|
|
|
40
41
|
present: () => e > 0
|
|
41
42
|
};
|
|
42
43
|
}
|
|
43
|
-
var
|
|
44
|
-
function
|
|
45
|
-
let [t] =
|
|
46
|
-
r(e),
|
|
47
|
-
}, []), a =
|
|
44
|
+
var S = a(null), C = () => () => {}, w = () => !1;
|
|
45
|
+
function T({ children: e }) {
|
|
46
|
+
let [t] = d(x), [n, r] = d(y), i = s((e) => {
|
|
47
|
+
r(e), b(e);
|
|
48
|
+
}, []), a = s(() => {
|
|
48
49
|
r((e) => {
|
|
49
50
|
let t = !e;
|
|
50
|
-
return
|
|
51
|
+
return b(t), t;
|
|
51
52
|
});
|
|
52
|
-
}, []),
|
|
53
|
+
}, []), o = u(() => ({
|
|
53
54
|
hidden: n,
|
|
54
55
|
toggle: a,
|
|
55
56
|
setHidden: i
|
|
@@ -58,28 +59,28 @@ function w({ children: e }) {
|
|
|
58
59
|
a,
|
|
59
60
|
i
|
|
60
61
|
]);
|
|
61
|
-
return /* @__PURE__ */
|
|
62
|
+
return /* @__PURE__ */ m(S.Provider, {
|
|
62
63
|
value: t,
|
|
63
|
-
children: /* @__PURE__ */
|
|
64
|
-
value:
|
|
64
|
+
children: /* @__PURE__ */ m(v.Provider, {
|
|
65
|
+
value: o,
|
|
65
66
|
children: e
|
|
66
67
|
})
|
|
67
68
|
});
|
|
68
69
|
}
|
|
69
|
-
function
|
|
70
|
-
return
|
|
70
|
+
function E() {
|
|
71
|
+
return c(v) ?? _;
|
|
71
72
|
}
|
|
72
|
-
function
|
|
73
|
-
let t =
|
|
74
|
-
|
|
73
|
+
function D(e = !0) {
|
|
74
|
+
let t = c(S);
|
|
75
|
+
l(() => e && t ? t.mark() : void 0, [t, e]);
|
|
75
76
|
}
|
|
76
|
-
function
|
|
77
|
-
let e =
|
|
78
|
-
return
|
|
77
|
+
function O() {
|
|
78
|
+
let e = c(S);
|
|
79
|
+
return f(e ? e.subscribe : C, e ? e.present : w, w);
|
|
79
80
|
}
|
|
80
|
-
var
|
|
81
|
-
let { hidden: a } =
|
|
82
|
-
return
|
|
81
|
+
var k = o(function({ children: e, label: t = "valor oculto", className: n, ...r }, i) {
|
|
82
|
+
let { hidden: a } = E();
|
|
83
|
+
return D(), /* @__PURE__ */ m("span", {
|
|
83
84
|
ref: i,
|
|
84
85
|
...r,
|
|
85
86
|
className: `select-sensitive${a ? " select-sensitive--hidden" : ""}${n ? " " + n : ""}`,
|
|
@@ -87,50 +88,56 @@ var O = a(function({ children: e, label: t = "valor oculto", className: n, ...r
|
|
|
87
88
|
children: e
|
|
88
89
|
});
|
|
89
90
|
});
|
|
90
|
-
function
|
|
91
|
-
let
|
|
92
|
-
return
|
|
91
|
+
function A({ cents: e, sensitive: t = !0 }) {
|
|
92
|
+
let r = i(e, n());
|
|
93
|
+
return m(t ? k : p, { children: r });
|
|
93
94
|
}
|
|
94
|
-
var
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
95
|
+
var j = /* @__PURE__ */ new Map();
|
|
96
|
+
function M(e) {
|
|
97
|
+
let t = j.get(e);
|
|
98
|
+
return t || (t = new Intl.NumberFormat(e === "en" ? "en-US" : "pt-BR", {
|
|
99
|
+
signDisplay: "exceptZero",
|
|
100
|
+
minimumFractionDigits: 1,
|
|
101
|
+
maximumFractionDigits: 1
|
|
102
|
+
}), j.set(e, t)), t;
|
|
103
|
+
}
|
|
104
|
+
var N = o(function({ value: e, invert: t = !1, caption: r, unit: i = "percent", className: a, ...o }, s) {
|
|
105
|
+
let c = n();
|
|
106
|
+
if (e == null || !Number.isFinite(e)) return /* @__PURE__ */ h("span", {
|
|
107
|
+
ref: s,
|
|
108
|
+
...o,
|
|
109
|
+
className: `select-delta select-delta--muted${a ? " " + a : ""}`,
|
|
110
|
+
children: ["—", r ? ` ${r}` : ""]
|
|
104
111
|
});
|
|
105
|
-
let
|
|
106
|
-
return /* @__PURE__ */
|
|
107
|
-
ref:
|
|
108
|
-
...
|
|
109
|
-
className: `select-delta${
|
|
110
|
-
children: [/* @__PURE__ */
|
|
111
|
-
className: `select-delta__value select-delta__value--${
|
|
112
|
+
let l = e === 0, u = e > 0, d = l ? null : t ? !u : u, f = d == null ? "muted" : d ? "up" : "down", p = l ? "" : u ? "▲" : "▼";
|
|
113
|
+
return /* @__PURE__ */ h("span", {
|
|
114
|
+
ref: s,
|
|
115
|
+
...o,
|
|
116
|
+
className: `select-delta${a ? " " + a : ""}`,
|
|
117
|
+
children: [/* @__PURE__ */ h("span", {
|
|
118
|
+
className: `select-delta__value select-delta__value--${f}`,
|
|
112
119
|
children: [
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
120
|
+
p ? `${p} ` : "",
|
|
121
|
+
M(c).format(e),
|
|
122
|
+
i === "points" ? c === "en" ? " pp" : " p.p." : "%"
|
|
116
123
|
]
|
|
117
|
-
}),
|
|
124
|
+
}), r != null && /* @__PURE__ */ m("span", {
|
|
118
125
|
className: "select-delta__caption",
|
|
119
|
-
children:
|
|
126
|
+
children: r
|
|
120
127
|
})]
|
|
121
128
|
});
|
|
122
129
|
});
|
|
123
|
-
function
|
|
124
|
-
let { hidden:
|
|
125
|
-
return /* @__PURE__ */
|
|
130
|
+
function P() {
|
|
131
|
+
let { hidden: n, toggle: i } = E();
|
|
132
|
+
return /* @__PURE__ */ m(r, {
|
|
126
133
|
variant: "outline",
|
|
127
|
-
icon:
|
|
128
|
-
label:
|
|
129
|
-
active:
|
|
134
|
+
icon: m(n ? t : e, {}),
|
|
135
|
+
label: n ? "Mostrar valores" : "Ocultar valores",
|
|
136
|
+
active: n,
|
|
130
137
|
onClick: i
|
|
131
138
|
});
|
|
132
139
|
}
|
|
133
140
|
//#endregion
|
|
134
|
-
export {
|
|
141
|
+
export { P as SelectHideMoneyToggle, N as SelectMetricDelta, A as SelectMoney, k as SelectSensitiveValue, T as SelectValueVisibilityProvider, O as useSelectHasSensitiveValues, D as useSelectSensitiveValueMark, E as useSelectValueVisibility };
|
|
135
142
|
|
|
136
143
|
//# sourceMappingURL=SelectMoney.js.map
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Brazilian document (CPF/CNPJ) helpers. The masked value is for display only —
|
|
3
|
-
* always send the CLEAN (digits-only) value to the backend (validation runs on
|
|
4
|
-
* the digits; nothing upstream strips the mask for you).
|
|
5
|
-
*/
|
|
1
|
+
/** O valor limpo: só dígitos e letras, em maiúsculas (o CPF e o CNPJ numérico seguem só com dígitos). */
|
|
6
2
|
export declare function cleanDocument(value: string | null | undefined): string;
|
|
7
3
|
export declare function documentType(value: string | null | undefined): 'CPF' | 'CNPJ' | '';
|
|
8
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Masks for display: CPF 000.000.000-00, CNPJ 00.000.000/0000-00 (o alfanumérico, AA.AAA.AAA/AAAA-00). Só com dígitos,
|
|
6
|
+
* até 11 é o CPF; com uma letra, só pode ser o CNPJ, e a máscara dele vem desde o primeiro caractere.
|
|
7
|
+
*/
|
|
9
8
|
export declare function formatDocument(value: string | null | undefined): string;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
//#region src/internal/document.ts
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
var e = /^\d{11}$/, t = /^[0-9A-Z]{12}\d{2}$/;
|
|
3
|
+
function n(e) {
|
|
4
|
+
return (e ?? "").toUpperCase().replace(/[^0-9A-Z]/g, "");
|
|
4
5
|
}
|
|
5
|
-
function
|
|
6
|
-
let
|
|
7
|
-
return
|
|
6
|
+
function r(r) {
|
|
7
|
+
let i = n(r);
|
|
8
|
+
return e.test(i) ? "CPF" : t.test(i) ? "CNPJ" : "";
|
|
8
9
|
}
|
|
9
|
-
function
|
|
10
|
-
let
|
|
11
|
-
return
|
|
10
|
+
function i(e) {
|
|
11
|
+
let t = n(e).slice(0, 14);
|
|
12
|
+
return t.length <= 11 && /^\d*$/.test(t) ? t.replace(/^(\d{3})(\d)/, "$1.$2").replace(/^(\d{3})\.(\d{3})(\d)/, "$1.$2.$3").replace(/\.(\d{3})(\d)/, ".$1-$2") : t.replace(/^([0-9A-Z]{2})([0-9A-Z])/, "$1.$2").replace(/^([0-9A-Z]{2})\.([0-9A-Z]{3})([0-9A-Z])/, "$1.$2.$3").replace(/\.([0-9A-Z]{3})([0-9A-Z])/, ".$1/$2").replace(/([0-9A-Z]{4})([0-9A-Z])/, "$1-$2");
|
|
12
13
|
}
|
|
13
14
|
//#endregion
|
|
14
|
-
export {
|
|
15
|
+
export { n as cleanDocument, r as documentType, i as formatDocument };
|
|
15
16
|
|
|
16
17
|
//# sourceMappingURL=document.js.map
|
package/dist/internal/money.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { SelectLocaleCode } from '../SelectLocale';
|
|
1
2
|
/** Coerce a value to a finite number. The backend frequently returns money fields
|
|
2
3
|
* as numeric STRINGS ("45998"), so coerce before any math/format —
|
|
3
4
|
* otherwise every amount renders as R$ 0,00. */
|
|
4
5
|
export declare function toNumber(value: unknown): number;
|
|
5
|
-
/** Cents → "R$ 1.234,56". Accepts numeric strings; null/NaN → "R$ 0,00". */
|
|
6
|
-
export declare function centsToBRL(cents: number | string | null | undefined): string;
|
|
7
|
-
/** A reais value (already divided) → BRL string. */
|
|
8
|
-
export declare function formatBRL(value: number): string;
|
|
6
|
+
/** Cents → "R$ 1.234,56" (ou "R$1,234.56" em inglês). Accepts numeric strings; null/NaN → "R$ 0,00". */
|
|
7
|
+
export declare function centsToBRL(cents: number | string | null | undefined, locale?: SelectLocaleCode): string;
|
|
8
|
+
/** A reais value (already divided) → BRL string, no idioma dado. */
|
|
9
|
+
export declare function formatBRL(value: number, locale?: SelectLocaleCode): string;
|
package/dist/internal/money.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
//#region src/internal/money.ts
|
|
2
|
-
var e = new
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var e = /* @__PURE__ */ new Map();
|
|
3
|
+
function t(t) {
|
|
4
|
+
let n = e.get(t);
|
|
5
|
+
return n || (n = new Intl.NumberFormat(t === "en" ? "en-US" : "pt-BR", {
|
|
6
|
+
style: "currency",
|
|
7
|
+
currency: "BRL"
|
|
8
|
+
}), e.set(t, n)), n;
|
|
9
|
+
}
|
|
10
|
+
function n(e) {
|
|
7
11
|
let t = typeof e == "string" ? Number(e) : e;
|
|
8
12
|
return typeof t == "number" && Number.isFinite(t) ? t : 0;
|
|
9
13
|
}
|
|
10
|
-
function
|
|
11
|
-
return
|
|
14
|
+
function r(e, r = "pt-BR") {
|
|
15
|
+
return t(r).format(n(e) / 100);
|
|
12
16
|
}
|
|
13
17
|
//#endregion
|
|
14
|
-
export {
|
|
18
|
+
export { r as centsToBRL, n as toNumber };
|
|
15
19
|
|
|
16
20
|
//# sourceMappingURL=money.js.map
|