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