@fiscozen/input 3.4.4 → 3.5.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/CHANGELOG.md +19 -0
- package/dist/input.js +428 -433
- package/dist/input.umd.cjs +1 -1
- package/dist/src/FzCurrencyInput.vue.d.ts +5 -360
- package/dist/src/FzInput.vue.d.ts +26 -61
- package/dist/src/index.d.ts +4 -0
- package/dist/src/types.d.ts +97 -54
- package/dist/src/useCurrencyInput.d.ts +59 -0
- package/dist/src/useInputStyle.d.ts +9 -2
- package/dist/src/utils.d.ts +14 -0
- package/package.json +3 -3
- package/src/FzCurrencyInput.vue +21 -747
- package/src/FzInput.vue +226 -27
- package/src/__tests__/FzCurrencyInput.spec.ts +81 -0
- package/src/__tests__/FzInput.spec.ts +743 -1
- package/src/index.ts +4 -0
- package/src/types.ts +111 -54
- package/src/useCurrencyInput.ts +537 -0
- package/src/useInputStyle.ts +12 -2
- package/src/utils.ts +29 -0
- package/tsconfig.tsbuildinfo +1 -1
package/dist/input.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { computed as e, createBlock as t, createCommentVNode as n, createElementBlock as r, createElementVNode as i, createSlots as a, createVNode as o, defineComponent as s, mergeModels as c, mergeProps as l, normalizeClass as u, onMounted as d, openBlock as f, ref as p, renderSlot as m, toDisplayString as h, toRefs as g, unref as _, useAttrs as v, useModel as y, useSlots as b, vModelDynamic as
|
|
2
|
-
import { FzAlert as
|
|
3
|
-
import { FzIcon as
|
|
4
|
-
import { FzIconButton as
|
|
5
|
-
import { clamp as
|
|
1
|
+
import { computed as e, createBlock as t, createCommentVNode as n, createElementBlock as r, createElementVNode as i, createSlots as a, createVNode as o, defineComponent as s, mergeModels as c, mergeProps as l, normalizeClass as u, onMounted as d, openBlock as f, ref as p, renderSlot as m, toDisplayString as h, toRefs as g, unref as _, useAttrs as v, useModel as y, useSlots as b, vModelDynamic as ee, watch as x, withCtx as S, withDirectives as C, withModifiers as w } from "vue";
|
|
2
|
+
import { FzAlert as te } from "@fiscozen/alert";
|
|
3
|
+
import { FzIcon as T } from "@fiscozen/icons";
|
|
4
|
+
import { FzIconButton as E } from "@fiscozen/button";
|
|
5
|
+
import { clamp as D, format as O, parse as k, roundTo as A, truncateDecimals as j } from "@fiscozen/composables";
|
|
6
6
|
//#region src/useInputStyle.ts
|
|
7
|
-
function
|
|
7
|
+
function ne(t, n, r, i, a) {
|
|
8
8
|
let o = {
|
|
9
9
|
backoffice: "h-32",
|
|
10
10
|
frontoffice: "h-44"
|
|
@@ -39,23 +39,146 @@ function N(t, n, r, i, a) {
|
|
|
39
39
|
}
|
|
40
40
|
//#endregion
|
|
41
41
|
//#region src/utils.ts
|
|
42
|
-
var
|
|
42
|
+
var M = /^-?\d+(\.\d+)?([eE][-+]?\d+)?$/, re = (e) => M.test(e), ie = (e) => {
|
|
43
|
+
let t = k(e);
|
|
44
|
+
return isNaN(t) || !isFinite(t) ? null : t;
|
|
45
|
+
}, N = {
|
|
43
46
|
sm: "backoffice",
|
|
44
47
|
md: "backoffice",
|
|
45
48
|
lg: "frontoffice"
|
|
46
|
-
},
|
|
47
|
-
function
|
|
48
|
-
return `${e}-${Date.now() - 16e11}-${++
|
|
49
|
+
}, P = 0;
|
|
50
|
+
function ae(e) {
|
|
51
|
+
return `${e}-${Date.now() - 16e11}-${++P}`;
|
|
49
52
|
}
|
|
50
|
-
function
|
|
51
|
-
return
|
|
53
|
+
function oe() {
|
|
54
|
+
return ae("fz-input");
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/useCurrencyInput.ts
|
|
58
|
+
function se(e) {
|
|
59
|
+
let { props: t, model: n, enabled: r } = e, i = p(), a = p(!1), o = !1, s = () => t.min ?? -Infinity, c = () => t.max ?? Infinity, l = () => t.step ?? 1, u = () => t.minimumFractionDigits ?? 2, f = () => t.maximumFractionDigits ?? 2, m = (e) => {
|
|
60
|
+
o = !0, n.value = e, o = !1;
|
|
61
|
+
}, h = (e) => O(e, {
|
|
62
|
+
minimumFractionDigits: u(),
|
|
63
|
+
maximumFractionDigits: f(),
|
|
64
|
+
roundDecimals: !1,
|
|
65
|
+
useGrouping: !0
|
|
66
|
+
}), g = () => {
|
|
67
|
+
if (t.nullOnEmpty) return null;
|
|
68
|
+
if (t.zeroOnEmpty) return 0;
|
|
69
|
+
}, _ = (e, t) => e ? t ? "" : h(0) : "", v = (e) => {
|
|
70
|
+
let t = e.replace(/[^0-9.,-]/g, ""), n = t.startsWith("-");
|
|
71
|
+
t = t.replace(/-/g, ""), t = t.replace(/\./g, ",");
|
|
72
|
+
let r = t.indexOf(",");
|
|
73
|
+
if (r !== -1) {
|
|
74
|
+
let e = t.substring(0, r), n = t.substring(r + 1).replace(/,/g, "");
|
|
75
|
+
t = e + "," + n;
|
|
76
|
+
}
|
|
77
|
+
return n ? "-" + t : t;
|
|
78
|
+
}, y = (e) => {
|
|
79
|
+
if (e == null || e === "") return e === null ? null : void 0;
|
|
80
|
+
if (typeof e == "number") return e;
|
|
81
|
+
if (typeof e == "string") {
|
|
82
|
+
console.warn(`[FzCurrencyInput] String values in v-model are deprecated. Please use number instead. Received: "${e}". This will be parsed to a number for retrocompatibility, but string support may be removed in a future version.`);
|
|
83
|
+
let t = k(e);
|
|
84
|
+
return isNaN(t) ? void 0 : t;
|
|
85
|
+
}
|
|
86
|
+
}, b = (e) => {
|
|
87
|
+
if (!(e.ctrlKey || e.metaKey || e.altKey || [
|
|
88
|
+
"Backspace",
|
|
89
|
+
"Delete",
|
|
90
|
+
"ArrowLeft",
|
|
91
|
+
"ArrowRight",
|
|
92
|
+
"ArrowUp",
|
|
93
|
+
"ArrowDown",
|
|
94
|
+
"Tab",
|
|
95
|
+
"Enter",
|
|
96
|
+
"Home",
|
|
97
|
+
"End"
|
|
98
|
+
].includes(e.key))) {
|
|
99
|
+
if (e.key === "-") {
|
|
100
|
+
let t = e.target, n = t.selectionStart ?? 0, r = (t.selectionEnd ?? 0) - n, i = t.value.length;
|
|
101
|
+
n !== 0 && r !== i && e.preventDefault();
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
/^[0-9.,]$/.test(e.key) || e.preventDefault();
|
|
105
|
+
}
|
|
106
|
+
}, ee = (e) => {
|
|
107
|
+
if (t.readonly || t.disabled) return;
|
|
108
|
+
e.preventDefault();
|
|
109
|
+
let n = e.clipboardData?.getData("text") || "";
|
|
110
|
+
if (!n) return;
|
|
111
|
+
let r = ie(n);
|
|
112
|
+
if (r !== null) {
|
|
113
|
+
let e = j(r, f());
|
|
114
|
+
m(e), i.value = v(String(e));
|
|
115
|
+
}
|
|
116
|
+
}, S = (e) => {
|
|
117
|
+
if (!e) {
|
|
118
|
+
m(g()), i.value = "";
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
let t = v(e);
|
|
122
|
+
i.value = t;
|
|
123
|
+
let n = k(t);
|
|
124
|
+
m(!isNaN(n) && isFinite(n) ? j(n, f()) : g());
|
|
125
|
+
}, C = () => {
|
|
126
|
+
if (t.readonly || t.disabled) return;
|
|
127
|
+
a.value = !1;
|
|
128
|
+
let e = y(n.value);
|
|
129
|
+
if (e == null) {
|
|
130
|
+
let e = g();
|
|
131
|
+
n.value !== e && m(e), i.value = _(e === 0, !1);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
let r = e;
|
|
135
|
+
t.forceStep && (r = A(l(), r)), r = D(s(), r, c()), r !== e && m(r), i.value = h(r);
|
|
136
|
+
}, w = () => {
|
|
137
|
+
if (t.readonly || t.disabled) return;
|
|
138
|
+
a.value = !0;
|
|
139
|
+
let e = y(n.value);
|
|
140
|
+
e !== void 0 && (i.value = h(e).replace(/\./g, ""));
|
|
141
|
+
}, te = (e) => {
|
|
142
|
+
if (t.readonly || t.disabled) return;
|
|
143
|
+
let r = j((y(n.value) ?? 0) + e * l(), f()), a = D(s(), r, c());
|
|
144
|
+
m(a), i.value = h(a);
|
|
145
|
+
}, T = (e, n) => {
|
|
146
|
+
if (e == null) {
|
|
147
|
+
let t = g();
|
|
148
|
+
e !== t && m(t), i.value = _(t === 0, n);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
let r = y(e);
|
|
152
|
+
if (r == null) {
|
|
153
|
+
let e = g();
|
|
154
|
+
m(e), i.value = _(e === 0, n);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
let a = j(r, f());
|
|
158
|
+
t.forceStep && (a = A(l(), a)), n || (a = D(s(), a, c())), a !== e && m(a), n || (i.value = h(a));
|
|
159
|
+
};
|
|
160
|
+
return d(() => {
|
|
161
|
+
r.value && T(n.value, !1);
|
|
162
|
+
}), x(r, (e) => {
|
|
163
|
+
e && T(n.value, !1);
|
|
164
|
+
}), x(() => n.value, (e) => {
|
|
165
|
+
!r.value || o || T(e, a.value);
|
|
166
|
+
}), {
|
|
167
|
+
displayValue: i,
|
|
168
|
+
handleDisplayUpdate: S,
|
|
169
|
+
handleKeydown: b,
|
|
170
|
+
handlePaste: ee,
|
|
171
|
+
handleFocus: w,
|
|
172
|
+
handleBlur: C,
|
|
173
|
+
stepBy: te
|
|
174
|
+
};
|
|
52
175
|
}
|
|
53
176
|
//#endregion
|
|
54
177
|
//#region src/FzInput.vue?vue&type=script&setup=true&lang.ts
|
|
55
|
-
var
|
|
178
|
+
var ce = ["id", "for"], le = ["tabindex"], ue = { class: "flex flex-col justify-around min-w-0 grow" }, de = {
|
|
56
179
|
key: 0,
|
|
57
180
|
class: "text-xs text-grey-300 grow-0 overflow-hidden text-ellipsis whitespace-nowrap"
|
|
58
|
-
},
|
|
181
|
+
}, fe = [
|
|
59
182
|
"type",
|
|
60
183
|
"required",
|
|
61
184
|
"disabled",
|
|
@@ -64,6 +187,9 @@ var te = ["id", "for"], ne = ["tabindex"], re = { class: "flex flex-col justify-
|
|
|
64
187
|
"pattern",
|
|
65
188
|
"name",
|
|
66
189
|
"maxlength",
|
|
190
|
+
"min",
|
|
191
|
+
"max",
|
|
192
|
+
"step",
|
|
67
193
|
"autocomplete",
|
|
68
194
|
"aria-required",
|
|
69
195
|
"aria-invalid",
|
|
@@ -72,7 +198,10 @@ var te = ["id", "for"], ne = ["tabindex"], re = { class: "flex flex-col justify-
|
|
|
72
198
|
"aria-describedby",
|
|
73
199
|
"aria-description",
|
|
74
200
|
"id"
|
|
75
|
-
],
|
|
201
|
+
], pe = { class: "flex items-center gap-4" }, me = {
|
|
202
|
+
key: 1,
|
|
203
|
+
class: "flex flex-col justify-between items-center"
|
|
204
|
+
}, he = ["id"], ge = "[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none", F = /* @__PURE__ */ s({
|
|
76
205
|
inheritAttrs: !1,
|
|
77
206
|
__name: "FzInput",
|
|
78
207
|
props: /* @__PURE__ */ c({
|
|
@@ -104,7 +233,7 @@ var te = ["id", "for"], ne = ["tabindex"], re = { class: "flex flex-col justify-
|
|
|
104
233
|
secondRightIconButton: { type: Boolean },
|
|
105
234
|
secondRightIconButtonVariant: { default: "invisible" },
|
|
106
235
|
secondRightIconAriaLabel: {},
|
|
107
|
-
type: {
|
|
236
|
+
type: {},
|
|
108
237
|
valid: { type: Boolean },
|
|
109
238
|
variant: { default: "normal" },
|
|
110
239
|
pattern: {},
|
|
@@ -134,7 +263,17 @@ var te = ["id", "for"], ne = ["tabindex"], re = { class: "flex flex-col justify-
|
|
|
134
263
|
default: !1
|
|
135
264
|
},
|
|
136
265
|
clearAriaLabel: { default: "Cancella" },
|
|
137
|
-
leftIconClass: {}
|
|
266
|
+
leftIconClass: {},
|
|
267
|
+
min: {},
|
|
268
|
+
max: {},
|
|
269
|
+
step: { default: 1 },
|
|
270
|
+
forceStep: { type: Boolean },
|
|
271
|
+
minimumFractionDigits: { default: 2 },
|
|
272
|
+
maximumFractionDigits: { default: 2 },
|
|
273
|
+
nullOnEmpty: { type: Boolean },
|
|
274
|
+
zeroOnEmpty: { type: Boolean },
|
|
275
|
+
stepUpAriaLabel: {},
|
|
276
|
+
stepDownAriaLabel: {}
|
|
138
277
|
}, {
|
|
139
278
|
modelValue: {},
|
|
140
279
|
modelModifiers: {}
|
|
@@ -149,89 +288,127 @@ var te = ["id", "for"], ne = ["tabindex"], re = { class: "flex flex-col justify-
|
|
|
149
288
|
"update:aiReasoning",
|
|
150
289
|
"fzinput:clear"
|
|
151
290
|
], ["update:modelValue"]),
|
|
152
|
-
setup(a, { expose:
|
|
153
|
-
let
|
|
154
|
-
let { class: e, id: t, ...n } =
|
|
291
|
+
setup(a, { expose: s, emit: c }) {
|
|
292
|
+
let d = a, D = v(), O = e(() => {
|
|
293
|
+
let { class: e, id: t, ...n } = D;
|
|
155
294
|
return n;
|
|
156
|
-
}), k = e(() =>
|
|
157
|
-
|
|
295
|
+
}), k = e(() => D.class);
|
|
296
|
+
x(() => d.size, (e) => {
|
|
158
297
|
if (e !== void 0) {
|
|
159
|
-
let t =
|
|
160
|
-
|
|
298
|
+
let t = N[e];
|
|
299
|
+
d.environment && d.environment !== t ? console.warn(`[FzInput] Both "size" and "environment" props are provided. "environment=${d.environment}" will be used and "size=${e}" will be ignored. Please remove the deprecated "size" prop.`) : console.warn(`[FzInput] The "size" prop is deprecated and will be removed in a future version. Please use environment="${t}" instead of size="${e}".`);
|
|
161
300
|
}
|
|
162
|
-
}, { immediate: !0 }),
|
|
301
|
+
}, { immediate: !0 }), x(() => d.rightIconSize, (e) => {
|
|
163
302
|
e !== void 0 && console.warn(`[FzInput] The "rightIconSize" prop is deprecated and will be removed in a future version. Icons now have a fixed size of "md". The provided value "${e}" will be ignored.`);
|
|
164
303
|
}, { immediate: !0 });
|
|
165
|
-
let A = e(() =>
|
|
166
|
-
|
|
304
|
+
let A = e(() => d.environment ? d.environment : d.size ? N[d.size] : "frontoffice"), j = y(a, "modelValue"), M = p(null), P = p(null), ae = oe(), F = e(() => d.id || ae), I = p(!1), L = j, R = e(() => d.type ?? "text"), z = e(() => R.value === "currency"), B = e(() => R.value === "number"), _e = e(() => z.value ? "text" : R.value), V = se({
|
|
305
|
+
props: d,
|
|
306
|
+
model: L,
|
|
307
|
+
enabled: z
|
|
308
|
+
}), H = e({
|
|
309
|
+
get: () => z.value ? V.displayValue.value : L.value,
|
|
310
|
+
set: (e) => {
|
|
311
|
+
z.value ? V.handleDisplayUpdate(e) : L.value = e;
|
|
312
|
+
}
|
|
313
|
+
}), U = p(d.highlighted), W = p(d.aiReasoning);
|
|
314
|
+
x(() => d.highlighted, (e) => {
|
|
167
315
|
U.value = e;
|
|
168
|
-
}),
|
|
316
|
+
}), x(() => d.aiReasoning, (e) => {
|
|
169
317
|
W.value = e;
|
|
170
318
|
});
|
|
171
|
-
let
|
|
172
|
-
|
|
173
|
-
}, { staticContainerClass:
|
|
174
|
-
...g(
|
|
319
|
+
let ve = () => {
|
|
320
|
+
d.disableEmphasisReset || (U.value && (U.value = !1, K("update:highlighted", !1)), W.value && (W.value = !1, K("update:aiReasoning", !1)));
|
|
321
|
+
}, { staticContainerClass: ye, computedContainerClass: be, computedLabelClass: xe, staticInputClass: Se, computedInputClass: Ce, computedHelpClass: we, showNormalPlaceholder: Te } = ne({
|
|
322
|
+
...g(d),
|
|
175
323
|
highlighted: U,
|
|
176
324
|
aiReasoning: W
|
|
177
|
-
}, M,
|
|
325
|
+
}, M, H, A, I);
|
|
178
326
|
b();
|
|
179
|
-
let
|
|
180
|
-
let e = !!
|
|
181
|
-
if (e && !t) return `${
|
|
182
|
-
}),
|
|
327
|
+
let G = b(), Ee = e(() => {
|
|
328
|
+
let e = !!d.label, t = !!G.label;
|
|
329
|
+
if (e && !t) return `${F.value}-label`;
|
|
330
|
+
}), De = e(() => {
|
|
183
331
|
let e = [];
|
|
184
|
-
return
|
|
185
|
-
}),
|
|
186
|
-
!
|
|
187
|
-
},
|
|
188
|
-
(e.key === "Enter" || e.key === " ") && (e.target === e.currentTarget || e.target === M.value) && (e.preventDefault(),
|
|
189
|
-
},
|
|
190
|
-
(e.key === "Enter" || e.key === " ") && (e.preventDefault(),
|
|
191
|
-
},
|
|
192
|
-
|
|
193
|
-
},
|
|
194
|
-
|
|
195
|
-
},
|
|
196
|
-
|
|
197
|
-
},
|
|
198
|
-
if (!(
|
|
199
|
-
if (U.value) return
|
|
200
|
-
if (W.value) return
|
|
332
|
+
return d.error && G.errorMessage && e.push(`${F.value}-error`), !d.error && G.helpText && e.push(`${F.value}-help`), e.length > 0 ? e.join(" ") : void 0;
|
|
333
|
+
}), K = c, Oe = () => {
|
|
334
|
+
!d.disabled && !d.readonly && P.value && P.value.focus();
|
|
335
|
+
}, ke = (e) => {
|
|
336
|
+
(e.key === "Enter" || e.key === " ") && (e.target === e.currentTarget || e.target === M.value) && (e.preventDefault(), Oe());
|
|
337
|
+
}, q = (e, t) => {
|
|
338
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), Y.value || K(t === "fzinput:left-icon-click" ? "fzinput:left-icon-click" : t === "fzinput:right-icon-click" ? "fzinput:right-icon-click" : "fzinput:second-right-icon-click"));
|
|
339
|
+
}, Ae = () => {
|
|
340
|
+
Y.value || K("fzinput:left-icon-click");
|
|
341
|
+
}, je = () => {
|
|
342
|
+
Y.value || K("fzinput:right-icon-click");
|
|
343
|
+
}, Me = () => {
|
|
344
|
+
Y.value || K("fzinput:second-right-icon-click");
|
|
345
|
+
}, Ne = e(() => !!d.leftIcon), J = e(() => Ne.value && !!d.leftIconAriaLabel), Y = e(() => !!d.disabled || !!d.readonly), Pe = e(() => Y.value || d.error ? "text-grey-300" : "text-purple-600"), Fe = e(() => {
|
|
346
|
+
if (!(Y.value || d.error)) {
|
|
347
|
+
if (U.value) return d.highlightedDescription;
|
|
348
|
+
if (W.value) return d.aiReasoningDescription;
|
|
349
|
+
}
|
|
350
|
+
}), Ie = e(() => !!d.rightIcon && !d.rightIconButton), X = e(() => Ie.value && !!d.rightIconAriaLabel), Le = e(() => !!d.secondRightIcon && !d.secondRightIconButton), Z = e(() => Le.value && !!d.secondRightIconAriaLabel), Re = e(() => d.clearable && !!H.value && !Y.value), ze = () => {
|
|
351
|
+
H.value = "", K("fzinput:clear"), P.value?.focus();
|
|
352
|
+
}, Be = (e) => {
|
|
353
|
+
I.value = !0, z.value && V.handleFocus(), K("focus", e);
|
|
354
|
+
}, Ve = (e) => {
|
|
355
|
+
I.value = !1, z.value && V.handleBlur(), K("blur", e);
|
|
356
|
+
}, He = (e) => {
|
|
357
|
+
z.value && V.handleKeydown(e);
|
|
358
|
+
}, Ue = (e) => {
|
|
359
|
+
if (d.readonly || d.disabled) return;
|
|
360
|
+
let t = e.clipboardData?.getData("text") || "";
|
|
361
|
+
if (!t || re(t)) return;
|
|
362
|
+
e.preventDefault();
|
|
363
|
+
let n = ie(t);
|
|
364
|
+
n !== null && (L.value = String(n));
|
|
365
|
+
}, We = (e) => {
|
|
366
|
+
z.value ? V.handlePaste(e) : B.value && Ue(e);
|
|
367
|
+
}, Ge = e(() => z.value || B.value), Ke = e(() => d.stepUpAriaLabel || `Incrementa di ${d.step}`), qe = e(() => d.stepDownAriaLabel || `Decrementa di ${d.step}`), Je = (e) => {
|
|
368
|
+
let t = P.value;
|
|
369
|
+
if (t) {
|
|
370
|
+
try {
|
|
371
|
+
e === 1 ? t.stepUp() : t.stepDown();
|
|
372
|
+
} catch {
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
t.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
201
376
|
}
|
|
202
|
-
}
|
|
203
|
-
|
|
377
|
+
}, Q = (e) => {
|
|
378
|
+
Y.value || (z.value ? V.stepBy(e) : B.value && Je(e));
|
|
379
|
+
}, $ = (e, t) => {
|
|
380
|
+
(e.key === "Enter" || e.key === " ") && !Y.value && (e.preventDefault(), Q(t));
|
|
204
381
|
};
|
|
205
|
-
return
|
|
206
|
-
inputRef:
|
|
382
|
+
return s({
|
|
383
|
+
inputRef: P,
|
|
207
384
|
containerRef: M
|
|
208
|
-
}), (e,
|
|
385
|
+
}), (e, s) => (f(), r("div", { class: u(["fz-input text-core-black w-full flex flex-col gap-8", k.value]) }, [
|
|
209
386
|
m(e.$slots, "label", {}, () => [a.label ? (f(), r("label", {
|
|
210
387
|
key: 0,
|
|
211
|
-
id: `${
|
|
212
|
-
class: u(_(
|
|
213
|
-
for:
|
|
214
|
-
}, h(a.label) + h(a.required ? " *" : ""), 11,
|
|
388
|
+
id: `${F.value}-label`,
|
|
389
|
+
class: u(_(xe)),
|
|
390
|
+
for: F.value
|
|
391
|
+
}, h(a.label) + h(a.required ? " *" : ""), 11, ce)) : n("", !0)]),
|
|
215
392
|
i("div", {
|
|
216
|
-
class: u([_(
|
|
393
|
+
class: u([_(ye), _(be)]),
|
|
217
394
|
ref_key: "containerRef",
|
|
218
395
|
ref: M,
|
|
219
|
-
tabindex:
|
|
220
|
-
onClick:
|
|
221
|
-
onKeydown:
|
|
396
|
+
tabindex: Y.value ? void 0 : 0,
|
|
397
|
+
onClick: Oe,
|
|
398
|
+
onKeydown: ke
|
|
222
399
|
}, [
|
|
223
|
-
m(e.$slots, "left-icon", {}, () => [a.leftIcon ? (f(), t(_(
|
|
400
|
+
m(e.$slots, "left-icon", {}, () => [a.leftIcon ? (f(), t(_(T), {
|
|
224
401
|
key: 0,
|
|
225
402
|
name: a.leftIcon,
|
|
226
403
|
size: "md",
|
|
227
404
|
variant: a.leftIconVariant,
|
|
228
|
-
role:
|
|
229
|
-
"aria-label":
|
|
230
|
-
"aria-disabled":
|
|
231
|
-
tabindex:
|
|
405
|
+
role: J.value ? "button" : void 0,
|
|
406
|
+
"aria-label": J.value ? a.leftIconAriaLabel : void 0,
|
|
407
|
+
"aria-disabled": J.value && Y.value ? "true" : void 0,
|
|
408
|
+
tabindex: J.value && !Y.value ? 0 : void 0,
|
|
232
409
|
class: u(a.leftIconClass),
|
|
233
|
-
onClick: w(
|
|
234
|
-
onKeydown:
|
|
410
|
+
onClick: w(Ae, ["stop"]),
|
|
411
|
+
onKeydown: s[0] ||= (e) => J.value ? (e) => q(e, "fzinput:left-icon-click") : void 0
|
|
235
412
|
}, null, 8, [
|
|
236
413
|
"name",
|
|
237
414
|
"variant",
|
|
@@ -240,161 +417,188 @@ var te = ["id", "for"], ne = ["tabindex"], re = { class: "flex flex-col justify-
|
|
|
240
417
|
"aria-disabled",
|
|
241
418
|
"tabindex",
|
|
242
419
|
"class"
|
|
243
|
-
])) : W.value && !U.value ? (f(), t(_(
|
|
420
|
+
])) : W.value && !U.value ? (f(), t(_(T), {
|
|
244
421
|
key: 1,
|
|
245
422
|
name: "sparkles",
|
|
246
423
|
variant: "fas",
|
|
247
424
|
size: "md",
|
|
248
425
|
"aria-hidden": "true",
|
|
249
|
-
class: u(
|
|
426
|
+
class: u(Pe.value)
|
|
250
427
|
}, null, 8, ["class"])) : n("", !0)]),
|
|
251
|
-
i("div",
|
|
252
|
-
type:
|
|
428
|
+
i("div", ue, [_(Te) ? n("", !0) : (f(), r("span", de, h(a.placeholder), 1)), C(i("input", l({
|
|
429
|
+
type: _e.value,
|
|
253
430
|
required: a.required,
|
|
254
431
|
disabled: a.disabled,
|
|
255
432
|
readonly: a.readonly,
|
|
256
|
-
placeholder: _(
|
|
257
|
-
"onUpdate:modelValue":
|
|
433
|
+
placeholder: _(Te) ? a.placeholder : "",
|
|
434
|
+
"onUpdate:modelValue": s[1] ||= (e) => H.value = e,
|
|
258
435
|
ref_key: "inputRef",
|
|
259
|
-
ref:
|
|
260
|
-
class: [
|
|
436
|
+
ref: P,
|
|
437
|
+
class: [
|
|
438
|
+
_(Se),
|
|
439
|
+
_(Ce),
|
|
440
|
+
B.value ? ge : ""
|
|
441
|
+
],
|
|
261
442
|
pattern: a.pattern,
|
|
262
443
|
name: a.name,
|
|
263
444
|
maxlength: a.maxlength,
|
|
445
|
+
min: B.value ? a.min : void 0,
|
|
446
|
+
max: B.value ? a.max : void 0,
|
|
447
|
+
step: B.value ? a.step : void 0,
|
|
264
448
|
autocomplete: a.autocomplete ? "on" : "off",
|
|
265
449
|
"aria-required": a.required ? "true" : "false",
|
|
266
450
|
"aria-invalid": a.error ? "true" : "false",
|
|
267
|
-
"aria-disabled":
|
|
268
|
-
"aria-labelledby":
|
|
269
|
-
"aria-describedby":
|
|
270
|
-
"aria-description":
|
|
451
|
+
"aria-disabled": Y.value ? "true" : "false",
|
|
452
|
+
"aria-labelledby": Ee.value,
|
|
453
|
+
"aria-describedby": De.value,
|
|
454
|
+
"aria-description": Fe.value
|
|
271
455
|
}, O.value, {
|
|
272
|
-
id:
|
|
273
|
-
onInput:
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
onFocus:
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
i("div", z, [Ce.value ? (f(), t(_(D), {
|
|
282
|
-
key: 0,
|
|
283
|
-
iconName: "xmark",
|
|
284
|
-
size: "md",
|
|
285
|
-
variant: "invisible",
|
|
286
|
-
ariaLabel: a.clearAriaLabel,
|
|
287
|
-
onClick: w(we, ["stop"])
|
|
288
|
-
}, null, 8, ["ariaLabel"])) : n("", !0), m(e.$slots, "right-icon", {}, () => [
|
|
289
|
-
a.secondRightIcon && !a.secondRightIconButton ? (f(), t(_(E), {
|
|
456
|
+
id: F.value,
|
|
457
|
+
onInput: ve,
|
|
458
|
+
onKeydown: He,
|
|
459
|
+
onPaste: We,
|
|
460
|
+
onBlur: Ve,
|
|
461
|
+
onFocus: Be
|
|
462
|
+
}), null, 16, fe), [[ee, H.value]])]),
|
|
463
|
+
i("div", pe, [
|
|
464
|
+
Re.value ? (f(), t(_(E), {
|
|
290
465
|
key: 0,
|
|
291
|
-
|
|
466
|
+
iconName: "xmark",
|
|
292
467
|
size: "md",
|
|
293
|
-
variant:
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
468
|
+
variant: "invisible",
|
|
469
|
+
ariaLabel: a.clearAriaLabel,
|
|
470
|
+
onClick: w(ze, ["stop"])
|
|
471
|
+
}, null, 8, ["ariaLabel"])) : n("", !0),
|
|
472
|
+
m(e.$slots, "right-icon", {}, () => [
|
|
473
|
+
a.secondRightIcon && !a.secondRightIconButton ? (f(), t(_(T), {
|
|
474
|
+
key: 0,
|
|
475
|
+
name: a.secondRightIcon,
|
|
476
|
+
size: "md",
|
|
477
|
+
variant: a.secondRightIconVariant,
|
|
478
|
+
role: Z.value ? "button" : void 0,
|
|
479
|
+
"aria-label": Z.value ? a.secondRightIconAriaLabel : void 0,
|
|
480
|
+
"aria-disabled": Z.value && Y.value ? "true" : void 0,
|
|
481
|
+
tabindex: Z.value && !Y.value ? 0 : void 0,
|
|
482
|
+
class: u(a.secondRightIconClass),
|
|
483
|
+
onClick: w(Me, ["stop"]),
|
|
484
|
+
onKeydown: s[2] ||= (e) => Z.value ? (e) => q(e, "fzinput:second-right-icon-click") : void 0
|
|
485
|
+
}, null, 8, [
|
|
486
|
+
"name",
|
|
487
|
+
"variant",
|
|
488
|
+
"role",
|
|
489
|
+
"aria-label",
|
|
490
|
+
"aria-disabled",
|
|
491
|
+
"tabindex",
|
|
492
|
+
"class"
|
|
493
|
+
])) : n("", !0),
|
|
494
|
+
a.secondRightIcon && a.secondRightIconButton ? (f(), t(_(E), {
|
|
495
|
+
key: 1,
|
|
496
|
+
iconName: a.secondRightIcon,
|
|
497
|
+
size: "md",
|
|
498
|
+
iconVariant: a.secondRightIconVariant,
|
|
499
|
+
variant: Y.value ? "invisible" : a.secondRightIconButtonVariant,
|
|
500
|
+
onClick: w(Me, ["stop"]),
|
|
501
|
+
class: u([{ "bg-grey-100 !text-grey-300": Y.value }, a.secondRightIconClass])
|
|
502
|
+
}, null, 8, [
|
|
503
|
+
"iconName",
|
|
504
|
+
"iconVariant",
|
|
505
|
+
"variant",
|
|
506
|
+
"class"
|
|
507
|
+
])) : n("", !0),
|
|
508
|
+
a.rightIcon && !a.rightIconButton ? (f(), t(_(T), {
|
|
509
|
+
key: 2,
|
|
510
|
+
name: a.rightIcon,
|
|
511
|
+
size: "md",
|
|
512
|
+
variant: a.rightIconVariant,
|
|
513
|
+
role: X.value ? "button" : void 0,
|
|
514
|
+
"aria-label": X.value ? a.rightIconAriaLabel : void 0,
|
|
515
|
+
"aria-disabled": X.value && Y.value ? "true" : void 0,
|
|
516
|
+
tabindex: X.value && !Y.value ? 0 : void 0,
|
|
517
|
+
class: u(a.rightIconClass),
|
|
518
|
+
onClick: w(je, ["stop"]),
|
|
519
|
+
onKeydown: s[3] ||= (e) => X.value ? (e) => q(e, "fzinput:right-icon-click") : void 0
|
|
520
|
+
}, null, 8, [
|
|
521
|
+
"name",
|
|
522
|
+
"variant",
|
|
523
|
+
"role",
|
|
524
|
+
"aria-label",
|
|
525
|
+
"aria-disabled",
|
|
526
|
+
"tabindex",
|
|
527
|
+
"class"
|
|
528
|
+
])) : n("", !0),
|
|
529
|
+
a.rightIcon && a.rightIconButton ? (f(), t(_(E), {
|
|
530
|
+
key: 3,
|
|
531
|
+
iconName: a.rightIcon,
|
|
532
|
+
size: "md",
|
|
533
|
+
iconVariant: a.rightIconVariant,
|
|
534
|
+
variant: Y.value ? "invisible" : a.rightIconButtonVariant,
|
|
535
|
+
onClick: w(je, ["stop"]),
|
|
536
|
+
class: u([{ "bg-grey-100 !text-grey-300": Y.value }, a.rightIconClass])
|
|
537
|
+
}, null, 8, [
|
|
538
|
+
"iconName",
|
|
539
|
+
"iconVariant",
|
|
540
|
+
"variant",
|
|
541
|
+
"class"
|
|
542
|
+
])) : n("", !0),
|
|
543
|
+
a.valid ? (f(), t(_(T), {
|
|
544
|
+
key: 4,
|
|
545
|
+
name: "check",
|
|
546
|
+
size: "md",
|
|
547
|
+
class: "text-semantic-success",
|
|
548
|
+
"aria-hidden": "true"
|
|
549
|
+
})) : n("", !0)
|
|
550
|
+
]),
|
|
551
|
+
Ge.value ? (f(), r("div", me, [o(_(T), {
|
|
552
|
+
name: "angle-up",
|
|
553
|
+
size: "xs",
|
|
554
|
+
role: "button",
|
|
555
|
+
"aria-label": Ke.value,
|
|
556
|
+
"aria-disabled": Y.value ? "true" : void 0,
|
|
557
|
+
tabindex: Y.value ? void 0 : "0",
|
|
558
|
+
class: "fz__input__arrowup fz__currencyinput__arrowup cursor-pointer",
|
|
559
|
+
onClick: s[4] ||= (e) => Q(1),
|
|
560
|
+
onKeydown: s[5] ||= (e) => $(e, 1)
|
|
301
561
|
}, null, 8, [
|
|
302
|
-
"name",
|
|
303
|
-
"variant",
|
|
304
|
-
"role",
|
|
305
562
|
"aria-label",
|
|
306
563
|
"aria-disabled",
|
|
307
|
-
"tabindex"
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
onClick:
|
|
317
|
-
|
|
318
|
-
}, null, 8, [
|
|
319
|
-
"iconName",
|
|
320
|
-
"iconVariant",
|
|
321
|
-
"variant",
|
|
322
|
-
"class"
|
|
323
|
-
])) : n("", !0),
|
|
324
|
-
a.rightIcon && !a.rightIconButton ? (f(), t(_(E), {
|
|
325
|
-
key: 2,
|
|
326
|
-
name: a.rightIcon,
|
|
327
|
-
size: "md",
|
|
328
|
-
variant: a.rightIconVariant,
|
|
329
|
-
role: Q.value ? "button" : void 0,
|
|
330
|
-
"aria-label": Q.value ? a.rightIconAriaLabel : void 0,
|
|
331
|
-
"aria-disabled": Q.value && Z.value ? "true" : void 0,
|
|
332
|
-
tabindex: Q.value && !Z.value ? 0 : void 0,
|
|
333
|
-
class: u(a.rightIconClass),
|
|
334
|
-
onClick: w(_e, ["stop"]),
|
|
335
|
-
onKeydown: o[5] ||= (e) => Q.value ? (e) => J(e, "fzinput:right-icon-click") : void 0
|
|
564
|
+
"tabindex"
|
|
565
|
+
]), o(_(T), {
|
|
566
|
+
name: "angle-down",
|
|
567
|
+
size: "xs",
|
|
568
|
+
role: "button",
|
|
569
|
+
"aria-label": qe.value,
|
|
570
|
+
"aria-disabled": Y.value ? "true" : void 0,
|
|
571
|
+
tabindex: Y.value ? void 0 : "0",
|
|
572
|
+
class: "fz__input__arrowdown fz__currencyinput__arrowdown cursor-pointer",
|
|
573
|
+
onClick: s[6] ||= (e) => Q(-1),
|
|
574
|
+
onKeydown: s[7] ||= (e) => $(e, -1)
|
|
336
575
|
}, null, 8, [
|
|
337
|
-
"name",
|
|
338
|
-
"variant",
|
|
339
|
-
"role",
|
|
340
576
|
"aria-label",
|
|
341
577
|
"aria-disabled",
|
|
342
|
-
"tabindex"
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
iconName: a.rightIcon,
|
|
348
|
-
size: "md",
|
|
349
|
-
iconVariant: a.rightIconVariant,
|
|
350
|
-
variant: Z.value ? "invisible" : a.rightIconButtonVariant,
|
|
351
|
-
onClick: w(_e, ["stop"]),
|
|
352
|
-
class: u([{ "bg-grey-100 !text-grey-300": Z.value }, a.rightIconClass])
|
|
353
|
-
}, null, 8, [
|
|
354
|
-
"iconName",
|
|
355
|
-
"iconVariant",
|
|
356
|
-
"variant",
|
|
357
|
-
"class"
|
|
358
|
-
])) : n("", !0),
|
|
359
|
-
a.valid ? (f(), t(_(E), {
|
|
360
|
-
key: 4,
|
|
361
|
-
name: "check",
|
|
362
|
-
size: "md",
|
|
363
|
-
class: "text-semantic-success",
|
|
364
|
-
"aria-hidden": "true"
|
|
365
|
-
})) : n("", !0)
|
|
366
|
-
])])
|
|
367
|
-
], 42, ne),
|
|
368
|
-
a.error && e.$slots.errorMessage ? (f(), t(_(T), {
|
|
578
|
+
"tabindex"
|
|
579
|
+
])])) : n("", !0)
|
|
580
|
+
])
|
|
581
|
+
], 42, le),
|
|
582
|
+
a.error && e.$slots.errorMessage ? (f(), t(_(te), {
|
|
369
583
|
key: 0,
|
|
370
|
-
id: `${
|
|
584
|
+
id: `${F.value}-error`,
|
|
371
585
|
role: "alert",
|
|
372
586
|
tone: "error",
|
|
373
587
|
variant: "text"
|
|
374
588
|
}, {
|
|
375
|
-
default:
|
|
589
|
+
default: S(() => [m(e.$slots, "errorMessage")]),
|
|
376
590
|
_: 3
|
|
377
591
|
}, 8, ["id"])) : e.$slots.helpText ? (f(), r("span", {
|
|
378
592
|
key: 1,
|
|
379
|
-
id: `${
|
|
380
|
-
class: u([_(
|
|
381
|
-
}, [m(e.$slots, "helpText")], 10,
|
|
593
|
+
id: `${F.value}-help`,
|
|
594
|
+
class: u([_(we)])
|
|
595
|
+
}, [m(e.$slots, "helpText")], 10, he)) : n("", !0)
|
|
382
596
|
], 2));
|
|
383
597
|
}
|
|
384
|
-
}),
|
|
598
|
+
}), I = /* @__PURE__ */ s({
|
|
385
599
|
__name: "FzCurrencyInput",
|
|
386
600
|
props: /* @__PURE__ */ c({
|
|
387
601
|
modelValue: {},
|
|
388
|
-
nullOnEmpty: { type: Boolean },
|
|
389
|
-
zeroOnEmpty: { type: Boolean },
|
|
390
|
-
minimumFractionDigits: { default: 2 },
|
|
391
|
-
maximumFractionDigits: { default: 2 },
|
|
392
|
-
min: { default: -Infinity },
|
|
393
|
-
max: { default: Infinity },
|
|
394
|
-
step: { default: 1 },
|
|
395
|
-
forceStep: { type: Boolean },
|
|
396
|
-
stepUpAriaLabel: {},
|
|
397
|
-
stepDownAriaLabel: {},
|
|
398
602
|
id: {},
|
|
399
603
|
label: {},
|
|
400
604
|
environment: {},
|
|
@@ -421,272 +625,63 @@ var te = ["id", "for"], ne = ["tabindex"], re = { class: "flex flex-col justify-
|
|
|
421
625
|
autocomplete: { type: Boolean },
|
|
422
626
|
clearable: { type: Boolean },
|
|
423
627
|
clearAriaLabel: {},
|
|
424
|
-
leftIconClass: {}
|
|
628
|
+
leftIconClass: {},
|
|
629
|
+
min: {},
|
|
630
|
+
max: {},
|
|
631
|
+
step: {},
|
|
632
|
+
forceStep: { type: Boolean },
|
|
633
|
+
minimumFractionDigits: {},
|
|
634
|
+
maximumFractionDigits: {},
|
|
635
|
+
nullOnEmpty: { type: Boolean },
|
|
636
|
+
zeroOnEmpty: { type: Boolean },
|
|
637
|
+
stepUpAriaLabel: {},
|
|
638
|
+
stepDownAriaLabel: {}
|
|
425
639
|
}, {
|
|
426
640
|
modelValue: {},
|
|
427
641
|
modelModifiers: {}
|
|
428
642
|
}),
|
|
429
643
|
emits: /* @__PURE__ */ c(["fzcurrencyinput:clear"], ["update:modelValue"]),
|
|
430
|
-
setup(
|
|
431
|
-
let
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
minimumFractionDigits: x.minimumFractionDigits,
|
|
436
|
-
maximumFractionDigits: x.maximumFractionDigits,
|
|
437
|
-
roundDecimals: !1,
|
|
438
|
-
useGrouping: !0
|
|
439
|
-
}) : "", P = e(() => x.stepUpAriaLabel ? x.stepUpAriaLabel : `Incrementa di ${x.step}`), F = e(() => x.stepDownAriaLabel ? x.stepDownAriaLabel : `Decrementa di ${x.step}`), I = e(() => x.readonly || x.disabled), L = (e) => {
|
|
440
|
-
let t = e.replace(/[^0-9.,-]/g, ""), n = t.startsWith("-");
|
|
441
|
-
t = t.replace(/-/g, ""), t = t.replace(/\./g, ",");
|
|
442
|
-
let r = t.indexOf(",");
|
|
443
|
-
if (r !== -1) {
|
|
444
|
-
let e = t.substring(0, r), n = t.substring(r + 1).replace(/,/g, "");
|
|
445
|
-
t = e + "," + n;
|
|
446
|
-
}
|
|
447
|
-
return n ? "-" + t : t;
|
|
448
|
-
}, te = (e) => {
|
|
449
|
-
if (!(e.ctrlKey || e.metaKey || e.altKey || [
|
|
450
|
-
"Backspace",
|
|
451
|
-
"Delete",
|
|
452
|
-
"ArrowLeft",
|
|
453
|
-
"ArrowRight",
|
|
454
|
-
"ArrowUp",
|
|
455
|
-
"ArrowDown",
|
|
456
|
-
"Tab",
|
|
457
|
-
"Enter",
|
|
458
|
-
"Home",
|
|
459
|
-
"End"
|
|
460
|
-
].includes(e.key))) {
|
|
461
|
-
if (e.key === "-") {
|
|
462
|
-
let t = e.target, n = t.selectionStart ?? 0, r = (t.selectionEnd ?? 0) - n, i = t.value.length;
|
|
463
|
-
n !== 0 && r !== i && e.preventDefault();
|
|
464
|
-
return;
|
|
465
|
-
}
|
|
466
|
-
/^[0-9.,]$/.test(e.key) || e.preventDefault();
|
|
467
|
-
}
|
|
468
|
-
}, ne = (e) => {
|
|
469
|
-
if (x.readonly || x.disabled) return;
|
|
470
|
-
e.preventDefault();
|
|
471
|
-
let t = e.clipboardData?.getData("text") || "";
|
|
472
|
-
if (!t) return;
|
|
473
|
-
let n = A(t);
|
|
474
|
-
if (!isNaN(n) && isFinite(n)) {
|
|
475
|
-
let e = M(n, x.maximumFractionDigits);
|
|
476
|
-
T = !0, w.value = e, T = !1, h.value = L(String(e));
|
|
477
|
-
}
|
|
478
|
-
}, re = (e) => {
|
|
479
|
-
if (!e) {
|
|
480
|
-
let e = D();
|
|
481
|
-
T = !0, w.value = e, T = !1, h.value = "";
|
|
482
|
-
return;
|
|
483
|
-
}
|
|
484
|
-
let t = L(e);
|
|
485
|
-
h.value = t;
|
|
486
|
-
let n = A(t);
|
|
487
|
-
if (!isNaN(n) && isFinite(n)) {
|
|
488
|
-
let e = M(n, x.maximumFractionDigits);
|
|
489
|
-
T = !0, w.value = e, T = !1;
|
|
490
|
-
} else T = !0, w.value = D(), T = !1;
|
|
491
|
-
}, ie = () => {
|
|
492
|
-
if (x.readonly || x.disabled) return;
|
|
493
|
-
b.value = !1;
|
|
494
|
-
let e = z(w.value);
|
|
495
|
-
if (e == null) {
|
|
496
|
-
let e = D();
|
|
497
|
-
w.value !== e && (T = !0, w.value = e, T = !1), h.value = N(e === 0, !1);
|
|
498
|
-
return;
|
|
499
|
-
}
|
|
500
|
-
let t = e;
|
|
501
|
-
x.forceStep && (t = j(x.step, t)), t = O(x.min, t, x.max), t !== e && (T = !0, w.value = t, T = !1), h.value = k(t, {
|
|
502
|
-
minimumFractionDigits: x.minimumFractionDigits,
|
|
503
|
-
maximumFractionDigits: x.maximumFractionDigits,
|
|
504
|
-
roundDecimals: !1,
|
|
505
|
-
useGrouping: !0
|
|
506
|
-
});
|
|
507
|
-
}, R = () => {
|
|
508
|
-
if (x.readonly || x.disabled) return;
|
|
509
|
-
b.value = !0;
|
|
510
|
-
let e = z(w.value);
|
|
511
|
-
e !== void 0 && (h.value = k(e, {
|
|
512
|
-
minimumFractionDigits: x.minimumFractionDigits,
|
|
513
|
-
maximumFractionDigits: x.maximumFractionDigits,
|
|
514
|
-
roundDecimals: !1,
|
|
515
|
-
useGrouping: !0
|
|
516
|
-
}).replace(/\./g, ""));
|
|
517
|
-
}, z = (e) => {
|
|
518
|
-
if (e == null || e === "") return e === null ? null : void 0;
|
|
519
|
-
if (typeof e == "number") return e;
|
|
520
|
-
if (typeof e == "string") {
|
|
521
|
-
console.warn(`[FzCurrencyInput] String values in v-model are deprecated. Please use number instead. Received: "${e}". This will be parsed to a number for retrocompatibility, but string support may be removed in a future version.`);
|
|
522
|
-
let t = A(e);
|
|
523
|
-
return isNaN(t) ? void 0 : t;
|
|
644
|
+
setup(n, { expose: r, emit: i }) {
|
|
645
|
+
let o = p(null), s = e(() => o.value?.containerRef), c = e(() => o.value?.inputRef), u = n, d = i, h = y(n, "modelValue"), g = e({
|
|
646
|
+
get: () => h.value,
|
|
647
|
+
set: (e) => {
|
|
648
|
+
h.value = e;
|
|
524
649
|
}
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
maximumFractionDigits: x.maximumFractionDigits,
|
|
531
|
-
roundDecimals: !1,
|
|
532
|
-
useGrouping: !0
|
|
533
|
-
});
|
|
534
|
-
}, W = () => {
|
|
535
|
-
if (x.readonly || x.disabled) return;
|
|
536
|
-
let e = M((z(w.value) ?? 0) - x.step, x.maximumFractionDigits), t = O(x.min, e, x.max);
|
|
537
|
-
T = !0, w.value = t, T = !1, h.value = k(t, {
|
|
538
|
-
minimumFractionDigits: x.minimumFractionDigits,
|
|
539
|
-
maximumFractionDigits: x.maximumFractionDigits,
|
|
540
|
-
roundDecimals: !1,
|
|
541
|
-
useGrouping: !0
|
|
542
|
-
});
|
|
543
|
-
};
|
|
544
|
-
return d(() => {
|
|
545
|
-
let e = w.value;
|
|
546
|
-
if (e == null) {
|
|
547
|
-
let t = D();
|
|
548
|
-
e !== t && (T = !0, w.value = t, T = !1), h.value = N(t === 0, !1);
|
|
549
|
-
return;
|
|
550
|
-
}
|
|
551
|
-
if (typeof e == "number") {
|
|
552
|
-
let t = M(e, x.maximumFractionDigits);
|
|
553
|
-
x.forceStep && (t = j(x.step, t)), t = O(x.min, t, x.max), t !== e && (T = !0, w.value = t, T = !1), h.value = k(t, {
|
|
554
|
-
minimumFractionDigits: x.minimumFractionDigits,
|
|
555
|
-
maximumFractionDigits: x.maximumFractionDigits,
|
|
556
|
-
roundDecimals: !1,
|
|
557
|
-
useGrouping: !0
|
|
558
|
-
});
|
|
559
|
-
return;
|
|
560
|
-
}
|
|
561
|
-
if (typeof e == "string") {
|
|
562
|
-
let t = z(e);
|
|
563
|
-
if (t != null) {
|
|
564
|
-
let e = M(t, x.maximumFractionDigits);
|
|
565
|
-
x.forceStep && (e = j(x.step, e)), e = O(x.min, e, x.max), T = !0, w.value = e, T = !1, h.value = k(e, {
|
|
566
|
-
minimumFractionDigits: x.minimumFractionDigits,
|
|
567
|
-
maximumFractionDigits: x.maximumFractionDigits,
|
|
568
|
-
roundDecimals: !1,
|
|
569
|
-
useGrouping: !0
|
|
570
|
-
});
|
|
571
|
-
} else {
|
|
572
|
-
let e = D();
|
|
573
|
-
T = !0, w.value = e, T = !1, h.value = N(e === 0, !1);
|
|
574
|
-
}
|
|
575
|
-
return;
|
|
576
|
-
}
|
|
577
|
-
}), S(() => w.value, (e) => {
|
|
578
|
-
if (!T) {
|
|
579
|
-
if (e == null) {
|
|
580
|
-
let t = D();
|
|
581
|
-
e !== t && (T = !0, w.value = t, T = !1), h.value = N(t === 0, b.value);
|
|
582
|
-
return;
|
|
583
|
-
}
|
|
584
|
-
if (typeof e == "number") {
|
|
585
|
-
let t = M(e, x.maximumFractionDigits);
|
|
586
|
-
x.forceStep && (t = j(x.step, t)), b.value || (t = O(x.min, t, x.max)), t !== e && (T = !0, w.value = t, T = !1), b.value || (h.value = k(t, {
|
|
587
|
-
minimumFractionDigits: x.minimumFractionDigits,
|
|
588
|
-
maximumFractionDigits: x.maximumFractionDigits,
|
|
589
|
-
roundDecimals: !1,
|
|
590
|
-
useGrouping: !0
|
|
591
|
-
}));
|
|
592
|
-
return;
|
|
593
|
-
}
|
|
594
|
-
if (typeof e == "string") {
|
|
595
|
-
let t = z(e);
|
|
596
|
-
if (t != null) {
|
|
597
|
-
let e = M(t, x.maximumFractionDigits);
|
|
598
|
-
x.forceStep && (e = j(x.step, e)), b.value || (e = O(x.min, e, x.max)), T = !0, w.value = e, T = !1, b.value || (h.value = k(e, {
|
|
599
|
-
minimumFractionDigits: x.minimumFractionDigits,
|
|
600
|
-
maximumFractionDigits: x.maximumFractionDigits,
|
|
601
|
-
roundDecimals: !1,
|
|
602
|
-
useGrouping: !0
|
|
603
|
-
}));
|
|
604
|
-
} else {
|
|
605
|
-
let e = D();
|
|
606
|
-
T = !0, w.value = e, T = !1, h.value = N(e === 0, b.value);
|
|
607
|
-
}
|
|
608
|
-
return;
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
}), s({
|
|
612
|
-
inputRef: v,
|
|
613
|
-
containerRef: g
|
|
614
|
-
}), (e, r) => (f(), t(V, l({
|
|
650
|
+
});
|
|
651
|
+
return r({
|
|
652
|
+
inputRef: c,
|
|
653
|
+
containerRef: s
|
|
654
|
+
}), (e, n) => (f(), t(F, l({
|
|
615
655
|
ref_key: "fzInputRef",
|
|
616
|
-
ref:
|
|
617
|
-
},
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
"onUpdate:modelValue":
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
onBlur: ie,
|
|
624
|
-
onPaste: ne,
|
|
625
|
-
"onFzinput:clear": r[2] ||= (e) => ee("fzcurrencyinput:clear")
|
|
626
|
-
}), a({
|
|
627
|
-
"right-icon": C(() => [i("div", H, [x.valid ? (f(), t(_(E), {
|
|
628
|
-
key: 0,
|
|
629
|
-
name: "check",
|
|
630
|
-
size: "md",
|
|
631
|
-
class: "text-semantic-success",
|
|
632
|
-
"aria-hidden": "true"
|
|
633
|
-
})) : n("", !0), i("div", U, [o(_(E), {
|
|
634
|
-
name: "angle-up",
|
|
635
|
-
size: "xs",
|
|
636
|
-
role: "button",
|
|
637
|
-
"aria-label": P.value,
|
|
638
|
-
"aria-disabled": I.value ? "true" : void 0,
|
|
639
|
-
tabindex: I.value ? void 0 : "0",
|
|
640
|
-
class: "fz__currencyinput__arrowup cursor-pointer",
|
|
641
|
-
onClick: B,
|
|
642
|
-
onKeydown: r[0] ||= (e) => {
|
|
643
|
-
(e.key === "Enter" || e.key === " ") && !I.value && (e.preventDefault(), B());
|
|
644
|
-
}
|
|
645
|
-
}, null, 8, [
|
|
646
|
-
"aria-label",
|
|
647
|
-
"aria-disabled",
|
|
648
|
-
"tabindex"
|
|
649
|
-
]), o(_(E), {
|
|
650
|
-
name: "angle-down",
|
|
651
|
-
size: "xs",
|
|
652
|
-
role: "button",
|
|
653
|
-
"aria-label": F.value,
|
|
654
|
-
"aria-disabled": I.value ? "true" : void 0,
|
|
655
|
-
tabindex: I.value ? void 0 : "0",
|
|
656
|
-
class: "fz__currencyinput__arrowdown cursor-pointer",
|
|
657
|
-
onClick: W,
|
|
658
|
-
onKeydown: r[1] ||= (e) => {
|
|
659
|
-
(e.key === "Enter" || e.key === " ") && !I.value && (e.preventDefault(), W());
|
|
660
|
-
}
|
|
661
|
-
}, null, 8, [
|
|
662
|
-
"aria-label",
|
|
663
|
-
"aria-disabled",
|
|
664
|
-
"tabindex"
|
|
665
|
-
])])])]),
|
|
666
|
-
_: 2
|
|
667
|
-
}, [
|
|
656
|
+
ref: o
|
|
657
|
+
}, u, {
|
|
658
|
+
type: "currency",
|
|
659
|
+
modelValue: g.value,
|
|
660
|
+
"onUpdate:modelValue": n[0] ||= (e) => g.value = e,
|
|
661
|
+
"onFzinput:clear": n[1] ||= (e) => d("fzcurrencyinput:clear")
|
|
662
|
+
}), a({ _: 2 }, [
|
|
668
663
|
e.$slots.label ? {
|
|
669
664
|
name: "label",
|
|
670
|
-
fn:
|
|
665
|
+
fn: S(() => [m(e.$slots, "label")]),
|
|
671
666
|
key: "0"
|
|
672
667
|
} : void 0,
|
|
673
668
|
e.$slots["left-icon"] ? {
|
|
674
669
|
name: "left-icon",
|
|
675
|
-
fn:
|
|
670
|
+
fn: S(() => [m(e.$slots, "left-icon")]),
|
|
676
671
|
key: "1"
|
|
677
672
|
} : void 0,
|
|
678
673
|
e.$slots.helpText ? {
|
|
679
674
|
name: "helpText",
|
|
680
|
-
fn:
|
|
675
|
+
fn: S(() => [m(e.$slots, "helpText")]),
|
|
681
676
|
key: "2"
|
|
682
677
|
} : void 0,
|
|
683
678
|
e.$slots.errorMessage ? {
|
|
684
679
|
name: "errorMessage",
|
|
685
|
-
fn:
|
|
680
|
+
fn: S(() => [m(e.$slots, "errorMessage")]),
|
|
686
681
|
key: "3"
|
|
687
682
|
} : void 0
|
|
688
683
|
]), 1040, ["modelValue"]));
|
|
689
684
|
}
|
|
690
685
|
});
|
|
691
686
|
//#endregion
|
|
692
|
-
export {
|
|
687
|
+
export { I as FzCurrencyInput, F as FzInput, N as sizeToEnvironmentMapping };
|