@appmax_npm/ds-prime 1.0.0-alpha.118 → 1.0.0-alpha.119
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/aminputcurrency/index.js +52 -41
- package/package.json +1 -1
package/aminputcurrency/index.js
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { InputText as
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
return t ? -
|
|
6
|
-
},
|
|
1
|
+
import { defineComponent as v, mergeModels as S, useModel as B, ref as E, computed as H, watch as M, openBlock as T, createBlock as h, unref as b, mergeProps as P } from "vue";
|
|
2
|
+
import { InputText as _ } from "primevue";
|
|
3
|
+
const i = (e, t = !1) => {
|
|
4
|
+
const n = Number(e) || 0;
|
|
5
|
+
return t ? -n : n;
|
|
6
|
+
}, w = (e) => {
|
|
7
7
|
if (!e) return 0;
|
|
8
|
-
const t = e.startsWith("-"),
|
|
9
|
-
if (!
|
|
10
|
-
const
|
|
11
|
-
return
|
|
12
|
-
},
|
|
8
|
+
const t = e.startsWith("-"), n = e.replace(/[^\d]/g, "");
|
|
9
|
+
if (!n) return 0;
|
|
10
|
+
const a = n.padStart(3, "0").replace(/(\d{2})$/, ".$1");
|
|
11
|
+
return i(a, t);
|
|
12
|
+
}, N = (e, t = !1) => {
|
|
13
|
+
const n = i(e);
|
|
14
|
+
return t ? n / 100 : n;
|
|
15
|
+
}, Y = (e, t = !1) => {
|
|
16
|
+
const n = i(e);
|
|
17
|
+
return t ? Math.round(n * 100) : n;
|
|
18
|
+
}, g = (e, t) => Math.round((e + t) * 100) / 100, D = {
|
|
13
19
|
AUD: "en-AU",
|
|
14
20
|
BGN: "bg-BG",
|
|
15
21
|
BRL: "pt-BR",
|
|
@@ -43,21 +49,21 @@ const d = (e, t = !1) => {
|
|
|
43
49
|
TRY: "tr-TR",
|
|
44
50
|
USD: "en-US",
|
|
45
51
|
ZAR: "en-ZA"
|
|
46
|
-
},
|
|
47
|
-
if (e in
|
|
48
|
-
const t =
|
|
52
|
+
}, F = "pt-BR", C = "BRL", x = (e = C) => {
|
|
53
|
+
if (e in D) {
|
|
54
|
+
const t = D[e];
|
|
49
55
|
return Array.isArray(t) ? t[0] : t;
|
|
50
56
|
} else
|
|
51
|
-
return
|
|
52
|
-
},
|
|
53
|
-
const
|
|
54
|
-
return new Intl.NumberFormat(
|
|
57
|
+
return F;
|
|
58
|
+
}, R = (e, t = C, n) => {
|
|
59
|
+
const a = n || x(t);
|
|
60
|
+
return new Intl.NumberFormat(a, {
|
|
55
61
|
style: "currency",
|
|
56
62
|
currency: t
|
|
57
|
-
}).format(
|
|
58
|
-
},
|
|
59
|
-
...
|
|
60
|
-
props: /* @__PURE__ */
|
|
63
|
+
}).format(i(e));
|
|
64
|
+
}, G = { name: "AmInputCurrency" }, z = /* @__PURE__ */ v({
|
|
65
|
+
...G,
|
|
66
|
+
props: /* @__PURE__ */ S({
|
|
61
67
|
currency: {},
|
|
62
68
|
locale: {},
|
|
63
69
|
inCents: { type: Boolean },
|
|
@@ -69,28 +75,33 @@ const d = (e, t = !1) => {
|
|
|
69
75
|
}),
|
|
70
76
|
emits: ["update:modelValue"],
|
|
71
77
|
setup(e) {
|
|
72
|
-
const t = e, { currency:
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
const t = e, { currency: n, locale: a, inCents: s, max: V, modelValue: O, ...y } = t, u = B(e, "modelValue"), f = E(""), l = H(() => V), m = (r) => r < 0 ? 0 : typeof l.value != "number" ? r : l.value <= 0 ? 0 : l.value < r ? l.value : r, A = (r) => {
|
|
79
|
+
const o = N(r, s);
|
|
80
|
+
f.value = R(o, n, a);
|
|
81
|
+
}, K = (r) => {
|
|
82
|
+
const o = r.target, d = w(o.value), p = Y(d, s), c = m(p);
|
|
83
|
+
u.value = c;
|
|
84
|
+
const U = N(c, s);
|
|
85
|
+
o.value = R(U, n, a);
|
|
86
|
+
}, I = (r) => {
|
|
87
|
+
if (!["ArrowUp", "ArrowDown"].includes(r.key)) return;
|
|
88
|
+
r.preventDefault();
|
|
89
|
+
const d = s ? 100 : 1, p = r.key === "ArrowUp" ? 1 : -1, c = g(u.value, d * p);
|
|
90
|
+
u.value = m(c);
|
|
83
91
|
};
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
M(u, (r) => {
|
|
93
|
+
const o = m(r);
|
|
94
|
+
r !== o && (u.value = o), A(o);
|
|
95
|
+
}, { immediate: !0 });
|
|
96
|
+
const L = "numberic";
|
|
97
|
+
return (r, o) => (T(), h(b(_), P(y, {
|
|
98
|
+
inputmode: L,
|
|
99
|
+
value: f.value,
|
|
100
|
+
onInput: K,
|
|
101
|
+
onKeydown: I
|
|
91
102
|
}), null, 16, ["value"]));
|
|
92
103
|
}
|
|
93
104
|
});
|
|
94
105
|
export {
|
|
95
|
-
|
|
106
|
+
z as default
|
|
96
107
|
};
|