adverich-kun-ui 0.1.520 → 0.1.522
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/components/KunAutocomplete/src/components/KunAutocomplete.vue.js +19 -19
- package/dist/components/KunNumberField/src/components/KunNumberField.vue.js +85 -81
- package/dist/components/KunNumberField/src/composables/KunNumberFieldProps.js +6 -1
- package/dist/components/KunNumberField/src/composables/useKunNumberFieldComposable.js +211 -131
- package/package.json +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { mergeModels as z, useModel as A, onMounted as se, ref as E, watch as ue, nextTick as F, createElementBlock as
|
|
1
|
+
import { mergeModels as z, useModel as A, onMounted as se, ref as E, watch as ue, nextTick as F, createElementBlock as h, openBlock as c, createVNode as s, unref as t, withKeys as de, withModifiers as x, isRef as O, createSlots as ce, withCtx as r, createCommentVNode as g, normalizeClass as fe, createTextVNode as C, toDisplayString as D, createBlock as p, Fragment as me, renderList as pe, createElementVNode as ve } from "vue";
|
|
2
2
|
import { icons as v } from "../../../../icons/index.js";
|
|
3
|
-
import { isNotEmpty as R, isArray as
|
|
3
|
+
import { isNotEmpty as R, isArray as B } from "../../../../utils/utils.js";
|
|
4
4
|
import ke from "../../../KunInfiniteScroll/src/components/KunInfiniteScroll.vue.js";
|
|
5
5
|
import ye from "../../../KunList/src/components/KunList.vue.js";
|
|
6
|
-
import
|
|
6
|
+
import N from "../../../KunListItem/src/components/KunListItem.vue.js";
|
|
7
7
|
import T from "../../../KunListItemTitle/src/components/KunListItemTitle.vue.js";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
8
|
+
import he from "../../../KunListItemSubtitle/src/components/KunListItemSubtitle.vue.js";
|
|
9
|
+
import ge from "../../../KunMenu/src/components/KunMenu.vue.js";
|
|
10
10
|
import { useAutocomplete as Ce } from "../composables/useAutocomplete.js";
|
|
11
11
|
import { KunAutocompleteProps as be } from "../composables/KunAutocompleteProps.js";
|
|
12
12
|
import we from "../../../KunTextField/src/components/KunTextField.vue.js";
|
|
@@ -96,7 +96,7 @@ const De = { class: "flex items-center" }, Ie = {
|
|
|
96
96
|
(l) => String(l[a.itemValue]).toLowerCase() === String(n.value).toLowerCase()
|
|
97
97
|
) : o = m.value.find(
|
|
98
98
|
(l) => typeof l == "object" ? Object.values(l).some((i) => String(i).toLowerCase() === String(n.value).toLowerCase()) : String(l).toLowerCase() === String(n.value).toLowerCase()
|
|
99
|
-
), o ? K(o) : (
|
|
99
|
+
), o ? K(o) : (f("notFound", n.value), a.clearOnNotFound && (n.value = "", d.value = !1)), F(() => {
|
|
100
100
|
f("keyDownEnter", e);
|
|
101
101
|
});
|
|
102
102
|
}
|
|
@@ -105,7 +105,7 @@ const De = { class: "flex items-center" }, Ie = {
|
|
|
105
105
|
var e;
|
|
106
106
|
return (e = k.value) == null ? void 0 : e.focus();
|
|
107
107
|
})
|
|
108
|
-
}), (e, o) => (c(),
|
|
108
|
+
}), (e, o) => (c(), h("div", {
|
|
109
109
|
class: "w-full h-fit",
|
|
110
110
|
ref_key: "parentRef",
|
|
111
111
|
ref: M
|
|
@@ -131,17 +131,17 @@ const De = { class: "flex items-center" }, Ie = {
|
|
|
131
131
|
le,
|
|
132
132
|
de(x(ae, ["prevent"]), ["enter"])
|
|
133
133
|
],
|
|
134
|
-
placeholder: a.multiple && t(
|
|
134
|
+
placeholder: a.multiple && t(B)(u.value) && u.value.length ? "" : t(Z),
|
|
135
135
|
error: !!y.value,
|
|
136
136
|
"error-messages": y.value
|
|
137
137
|
}, ce({
|
|
138
138
|
"prepend-input-content": r(() => [
|
|
139
|
-
t(
|
|
139
|
+
t(B)(u.value) && t(R)(u.value) ? (c(), h("div", {
|
|
140
140
|
key: 0,
|
|
141
141
|
class: "flex flex-nowrap items-center space-x-1 min-w-[calc(100%-56px)] overflow-x-auto overflow-y-hidden",
|
|
142
142
|
onClick: o[0] || (o[0] = (...l) => t(V) && t(V)(...l))
|
|
143
143
|
}, [
|
|
144
|
-
(c(!0),
|
|
144
|
+
(c(!0), h(me, null, pe(u.value, (l) => (c(), p(Ve, {
|
|
145
145
|
key: l.id ?? l.name,
|
|
146
146
|
size: "small",
|
|
147
147
|
variant: "pill"
|
|
@@ -160,10 +160,10 @@ const De = { class: "flex items-center" }, Ie = {
|
|
|
160
160
|
]),
|
|
161
161
|
_: 2
|
|
162
162
|
}, 1024))), 128))
|
|
163
|
-
])) :
|
|
163
|
+
])) : g("", !0)
|
|
164
164
|
]),
|
|
165
165
|
default: r(() => [
|
|
166
|
-
s(
|
|
166
|
+
s(ge, {
|
|
167
167
|
transition: "fade",
|
|
168
168
|
"onClick:outside": t(q),
|
|
169
169
|
modelValue: t(d),
|
|
@@ -180,7 +180,7 @@ const De = { class: "flex items-center" }, Ie = {
|
|
|
180
180
|
"hide-details": e.hideDetails
|
|
181
181
|
}, {
|
|
182
182
|
default: r(() => [
|
|
183
|
-
e.hasCreateItem ? (c(),
|
|
183
|
+
e.hasCreateItem ? (c(), h("div", Ie, [
|
|
184
184
|
s(Se, {
|
|
185
185
|
onClick: t(X),
|
|
186
186
|
bgColor: e.btnCreateBg,
|
|
@@ -191,7 +191,7 @@ const De = { class: "flex items-center" }, Ie = {
|
|
|
191
191
|
]),
|
|
192
192
|
_: 1
|
|
193
193
|
}, 8, ["onClick", "bgColor", "class"])
|
|
194
|
-
])) :
|
|
194
|
+
])) : g("", !0),
|
|
195
195
|
s(ye, {
|
|
196
196
|
"onClick:select": t(K),
|
|
197
197
|
ref_key: "listRef",
|
|
@@ -210,7 +210,7 @@ const De = { class: "flex items-center" }, Ie = {
|
|
|
210
210
|
"item-height": 48
|
|
211
211
|
}, {
|
|
212
212
|
default: r(({ item: l, index: i, empty: ie }) => [
|
|
213
|
-
!ie && l != null ? (c(), p(
|
|
213
|
+
!ie && l != null ? (c(), p(N, {
|
|
214
214
|
value: l,
|
|
215
215
|
key: `kun-list-${i + 1}`,
|
|
216
216
|
id: `kun-item-${i + 1}`,
|
|
@@ -228,12 +228,12 @@ const De = { class: "flex items-center" }, Ie = {
|
|
|
228
228
|
]),
|
|
229
229
|
_: 2
|
|
230
230
|
}, 1024),
|
|
231
|
-
s(
|
|
231
|
+
s(he, {
|
|
232
232
|
text: e.itemSubtitle ? t(L)(l, e.itemSubtitle) : ""
|
|
233
233
|
}, null, 8, ["text"])
|
|
234
234
|
]),
|
|
235
235
|
_: 2
|
|
236
|
-
}, 1032, ["value", "id", "disabled", "bg-items", "hover-bg", "activeClass", "density"])) : (c(), p(
|
|
236
|
+
}, 1032, ["value", "id", "disabled", "bg-items", "hover-bg", "activeClass", "density"])) : (c(), p(N, {
|
|
237
237
|
key: 1,
|
|
238
238
|
disabled: ""
|
|
239
239
|
}, {
|
|
@@ -270,7 +270,7 @@ const De = { class: "flex items-center" }, Ie = {
|
|
|
270
270
|
color: "error",
|
|
271
271
|
icon: t(v).close,
|
|
272
272
|
class: "mr-1 mt-1"
|
|
273
|
-
}, null, 8, ["onClick", "icon"])) :
|
|
273
|
+
}, null, 8, ["onClick", "icon"])) : g("", !0),
|
|
274
274
|
s(b, {
|
|
275
275
|
color: "teal-darken-1",
|
|
276
276
|
size: "large",
|
|
@@ -284,7 +284,7 @@ const De = { class: "flex items-center" }, Ie = {
|
|
|
284
284
|
size: "x-small",
|
|
285
285
|
class: "mb-4",
|
|
286
286
|
icon: t(v).asterisk
|
|
287
|
-
}, null, 8, ["icon"])) :
|
|
287
|
+
}, null, 8, ["icon"])) : g("", !0)
|
|
288
288
|
]),
|
|
289
289
|
key: "0"
|
|
290
290
|
} : void 0
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { getCurrentInstance as
|
|
2
|
-
import { KunNumberFieldProps as
|
|
3
|
-
import { useKunNumberField as
|
|
4
|
-
import
|
|
1
|
+
import { getCurrentInstance as E, useSlots as P, nextTick as R, computed as U, createElementBlock as l, openBlock as s, createCommentVNode as n, createElementVNode as d, normalizeClass as c, toDisplayString as u, mergeProps as H, unref as o, createBlock as x, renderSlot as V, createVNode as j, withCtx as L, Fragment as D, renderList as T } from "vue";
|
|
2
|
+
import { KunNumberFieldProps as q } from "../composables/KunNumberFieldProps.js";
|
|
3
|
+
import { useKunNumberField as G } from "../composables/useKunNumberFieldComposable.js";
|
|
4
|
+
import J from "../../../KunBtn/src/components/KunBtn.vue.js";
|
|
5
5
|
import f from "../../../KunIcon/src/components/KunIcon.vue.js";
|
|
6
|
-
import
|
|
7
|
-
const
|
|
6
|
+
import O from "../../../../icons/IconClose.vue.js";
|
|
7
|
+
const Q = {
|
|
8
8
|
key: 0,
|
|
9
9
|
class: "h-full"
|
|
10
|
-
},
|
|
10
|
+
}, W = ["disabled"], X = {
|
|
11
11
|
key: 1,
|
|
12
12
|
class: "mx-2"
|
|
13
|
-
},
|
|
13
|
+
}, Y = {
|
|
14
14
|
key: 2,
|
|
15
15
|
class: "flex items-center justify-center h-full pl-2"
|
|
16
|
-
},
|
|
16
|
+
}, Z = ["value", "placeholder", "readonly", "disabled", "maxlength", "aria-invalid"], _ = {
|
|
17
17
|
key: 3,
|
|
18
18
|
class: "px-2"
|
|
19
|
-
},
|
|
19
|
+
}, ee = {
|
|
20
20
|
key: 0,
|
|
21
21
|
class: "flex items-center h-full"
|
|
22
|
-
},
|
|
22
|
+
}, te = ["disabled"], oe = ["disabled"], re = {
|
|
23
23
|
key: 1,
|
|
24
24
|
class: "flex flex-col items-center justify-center border-l border-slate-600"
|
|
25
|
-
},
|
|
25
|
+
}, se = ["disabled"], le = ["disabled"], ne = {
|
|
26
26
|
key: 5,
|
|
27
27
|
class: "flex items-center justify-center h-full pr-1"
|
|
28
|
-
},
|
|
28
|
+
}, de = {
|
|
29
29
|
key: 6,
|
|
30
30
|
class: "h-full"
|
|
31
|
-
},
|
|
31
|
+
}, ie = ["disabled"], ae = {
|
|
32
32
|
key: 7,
|
|
33
33
|
class: "ml-2"
|
|
34
|
-
},
|
|
34
|
+
}, ue = {
|
|
35
35
|
key: 0,
|
|
36
36
|
class: "h-[1.25rem]"
|
|
37
|
-
},
|
|
37
|
+
}, pe = {
|
|
38
38
|
key: 0,
|
|
39
39
|
class: "text-red-500 text-sm text-center"
|
|
40
|
-
},
|
|
40
|
+
}, be = { key: 0 }, ye = { key: 1 }, ce = {
|
|
41
41
|
key: 1,
|
|
42
42
|
class: "text-xs text-center"
|
|
43
|
-
},
|
|
43
|
+
}, ge = {
|
|
44
44
|
__name: "KunNumberField",
|
|
45
|
-
props:
|
|
45
|
+
props: q,
|
|
46
46
|
emits: [
|
|
47
47
|
"update:modelValue",
|
|
48
48
|
"focus",
|
|
@@ -52,47 +52,50 @@ const O = {
|
|
|
52
52
|
"keyDown",
|
|
53
53
|
"keyUp"
|
|
54
54
|
],
|
|
55
|
-
setup(
|
|
56
|
-
const p =
|
|
55
|
+
setup(F, { expose: K, emit: N }) {
|
|
56
|
+
const p = F, b = N, k = `number-input-${E().uid}`, m = P(), A = !!m["prepend-icon"], B = !!m["append-icon"], {
|
|
57
57
|
inputValue: h,
|
|
58
|
-
numberInput:
|
|
58
|
+
numberInput: y,
|
|
59
59
|
rootRef: v,
|
|
60
60
|
onIncrement: i,
|
|
61
61
|
onDecrement: a,
|
|
62
|
-
onClear:
|
|
63
|
-
validateKey:
|
|
62
|
+
onClear: M,
|
|
63
|
+
validateKey: S,
|
|
64
64
|
focus: w,
|
|
65
65
|
handleFocus: g,
|
|
66
|
-
handleBlur: C
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
handleBlur: C,
|
|
67
|
+
handleInput: I
|
|
68
|
+
} = G(p, b);
|
|
69
|
+
K({
|
|
70
|
+
numberInput: y,
|
|
70
71
|
rootRef: v,
|
|
71
72
|
focus: () => {
|
|
72
|
-
|
|
73
|
+
R(() => {
|
|
73
74
|
var e;
|
|
74
|
-
(e =
|
|
75
|
+
(e = y.value) == null || e.focus();
|
|
75
76
|
});
|
|
76
77
|
}
|
|
77
78
|
});
|
|
78
|
-
const
|
|
79
|
-
|
|
79
|
+
const $ = U(
|
|
80
|
+
() => p.density === "compact" ? "p-1" : p.density === "comfortable" ? "p-2" : "p-3"
|
|
81
|
+
);
|
|
82
|
+
return (e, r) => (s(), l("div", {
|
|
80
83
|
class: "w-full flex flex-col relative h-fit",
|
|
81
84
|
ref_key: "rootRef",
|
|
82
85
|
ref: v
|
|
83
86
|
}, [
|
|
84
|
-
e.label ? (
|
|
87
|
+
e.label ? (s(), l("label", {
|
|
85
88
|
key: 0,
|
|
86
89
|
for: k,
|
|
87
|
-
class:
|
|
90
|
+
class: c([
|
|
88
91
|
e.labelColor,
|
|
89
92
|
"absolute left-2 transition-all duration-200 ease-in-out pointer-events-none select-none z-10",
|
|
90
93
|
"-top-2.25 text-xs opacity-80"
|
|
91
94
|
])
|
|
92
95
|
}, u(e.label), 3)) : n("", !0),
|
|
93
|
-
d("div",
|
|
96
|
+
d("div", H({ class: "w-full flex flex-col justify-center relative" }, e.$attrs), [
|
|
94
97
|
d("div", {
|
|
95
|
-
class:
|
|
98
|
+
class: c(["flex items-center w-full h-full border", [
|
|
96
99
|
e.bgInput,
|
|
97
100
|
e.rounded,
|
|
98
101
|
o(w) ? "border-slate-400 dark:border-slate-600 shadow-[0_0_0_1px_rgba(59,130,246,0.5)]" : e.borderColor,
|
|
@@ -100,25 +103,25 @@ const O = {
|
|
|
100
103
|
e.error ? "bg-red-200 dark:bg-red-900" : ""
|
|
101
104
|
]])
|
|
102
105
|
}, [
|
|
103
|
-
!e.noArrows && e.controlVariant === "split" ? (
|
|
106
|
+
!e.noArrows && e.controlVariant === "split" ? (s(), l("div", Q, [
|
|
104
107
|
d("button", {
|
|
105
108
|
type: "button",
|
|
106
109
|
class: "p-3 text-lg border-r border-slate-600 text-black dark:text-white disabled:opacity-50 cursor-pointer hover:opacity-80",
|
|
107
|
-
onClick:
|
|
110
|
+
onClick: r[0] || (r[0] = (...t) => o(a) && o(a)(...t)),
|
|
108
111
|
disabled: e.disabled || e.readonly
|
|
109
|
-
}, "−", 8,
|
|
112
|
+
}, "−", 8, W)
|
|
110
113
|
])) : n("", !0),
|
|
111
|
-
e.prefix ? (
|
|
112
|
-
e.prependIcon ||
|
|
113
|
-
e.prependIcon ? (
|
|
114
|
+
e.prefix ? (s(), l("div", X, u(e.prefix), 1)) : n("", !0),
|
|
115
|
+
e.prependIcon || A ? (s(), l("div", Y, [
|
|
116
|
+
e.prependIcon ? (s(), x(f, {
|
|
114
117
|
key: 0,
|
|
115
118
|
icon: e.prependIcon
|
|
116
|
-
}, null, 8, ["icon"])) :
|
|
119
|
+
}, null, 8, ["icon"])) : V(e.$slots, "prepend-icon", { key: 1 })
|
|
117
120
|
])) : n("", !0),
|
|
118
121
|
d("input", {
|
|
119
122
|
id: k,
|
|
120
123
|
ref_key: "numberInput",
|
|
121
|
-
ref:
|
|
124
|
+
ref: y,
|
|
122
125
|
type: "text",
|
|
123
126
|
value: o(h),
|
|
124
127
|
placeholder: e.placeholder,
|
|
@@ -126,97 +129,98 @@ const O = {
|
|
|
126
129
|
disabled: e.disabled,
|
|
127
130
|
maxlength: e.maxlength,
|
|
128
131
|
autocomplete: "off",
|
|
129
|
-
class:
|
|
132
|
+
class: c(["w-full h-full bg-transparent rounded focus:outline-none", [$.value, e.textColor, e.placeholderColor, e.textCenter ? "text-center" : ""]]),
|
|
130
133
|
"aria-invalid": e.error ? "true" : "false",
|
|
131
|
-
onBlur:
|
|
132
|
-
onFocus:
|
|
133
|
-
|
|
134
|
-
|
|
134
|
+
onBlur: r[1] || (r[1] = (...t) => o(C) && o(C)(...t)),
|
|
135
|
+
onFocus: r[2] || (r[2] = (...t) => o(g) && o(g)(...t)),
|
|
136
|
+
onInput: r[3] || (r[3] = (...t) => o(I) && o(I)(...t)),
|
|
137
|
+
onKeydown: r[4] || (r[4] = (t) => (o(S)(t), b("keyDown", t))),
|
|
138
|
+
onKeyup: r[5] || (r[5] = (t) => b("keyUp", t)),
|
|
135
139
|
inputmode: "decimal",
|
|
136
140
|
pattern: "[0-9]+([\\.,][0-9]+)?"
|
|
137
|
-
}, null, 42,
|
|
138
|
-
e.clearable && o(h) != null ? (
|
|
139
|
-
|
|
140
|
-
onClick: o(
|
|
141
|
+
}, null, 42, Z),
|
|
142
|
+
e.clearable && o(h) != null ? (s(), l("div", _, [
|
|
143
|
+
j(J, {
|
|
144
|
+
onClick: o(M),
|
|
141
145
|
rounded: "rounded-full",
|
|
142
146
|
bgColor: "bg-red-500/75",
|
|
143
147
|
disabled: e.disabled || e.readonly,
|
|
144
148
|
class: "h-6 w-6"
|
|
145
149
|
}, {
|
|
146
|
-
default:
|
|
147
|
-
|
|
148
|
-
icon:
|
|
150
|
+
default: L(() => [
|
|
151
|
+
j(f, {
|
|
152
|
+
icon: O,
|
|
149
153
|
size: "text-xs"
|
|
150
154
|
})
|
|
151
155
|
]),
|
|
152
156
|
_: 1
|
|
153
157
|
}, 8, ["onClick", "disabled"])
|
|
154
158
|
])) : n("", !0),
|
|
155
|
-
e.noArrows ? n("", !0) : (
|
|
156
|
-
e.controlVariant === "default" ? (
|
|
159
|
+
e.noArrows ? n("", !0) : (s(), l(D, { key: 4 }, [
|
|
160
|
+
e.controlVariant === "default" ? (s(), l("div", ee, [
|
|
157
161
|
d("button", {
|
|
158
162
|
type: "button",
|
|
159
163
|
class: "flex items-center border-l border-slate-600 p-3 justify-center text-black dark:text-white hover:text-black/80 dark:hover:text-white/80 disabled:opacity-50 cursor-pointer hover:opacity-80",
|
|
160
|
-
onClick:
|
|
164
|
+
onClick: r[6] || (r[6] = (...t) => o(i) && o(i)(...t)),
|
|
161
165
|
disabled: e.disabled || e.readonly
|
|
162
|
-
}, "
|
|
166
|
+
}, "▲", 8, te),
|
|
163
167
|
d("button", {
|
|
164
168
|
type: "button",
|
|
165
169
|
class: "flex items-center border-l border-slate-600 p-3 justify-center text-black dark:text-white hover:text-black/80 dark:hover:text-white/80 disabled:opacity-50 cursor-pointer hover:opacity-80",
|
|
166
|
-
onClick:
|
|
170
|
+
onClick: r[7] || (r[7] = (...t) => o(a) && o(a)(...t)),
|
|
167
171
|
disabled: e.disabled || e.readonly
|
|
168
|
-
}, "
|
|
172
|
+
}, "▼", 8, oe)
|
|
169
173
|
])) : n("", !0),
|
|
170
|
-
e.controlVariant === "stacked" ? (
|
|
174
|
+
e.controlVariant === "stacked" ? (s(), l("div", re, [
|
|
171
175
|
d("div", {
|
|
172
176
|
class: "border-b border-slate-600 pb-1 px-3 flex hover:opacity-80 cursor-pointer",
|
|
173
|
-
onClick:
|
|
177
|
+
onClick: r[8] || (r[8] = (...t) => o(i) && o(i)(...t))
|
|
174
178
|
}, [
|
|
175
179
|
d("button", {
|
|
176
180
|
type: "button",
|
|
177
181
|
class: "text-xs text-black dark:text-white hover:text-black/80 dark:hover:text-white/80 disabled:opacity-50 cursor-pointer",
|
|
178
182
|
disabled: e.disabled || e.readonly
|
|
179
|
-
}, "▲", 8,
|
|
183
|
+
}, "▲", 8, se)
|
|
180
184
|
]),
|
|
181
185
|
d("div", {
|
|
182
186
|
class: "border-t border-slate-600 pt-1 px-3 flex hover:opacity-80 cursor-pointer",
|
|
183
|
-
onClick:
|
|
187
|
+
onClick: r[9] || (r[9] = (...t) => o(a) && o(a)(...t))
|
|
184
188
|
}, [
|
|
185
189
|
d("button", {
|
|
186
190
|
type: "button",
|
|
187
191
|
class: "text-xs text-black dark:text-white hover:text-black/80 dark:hover:text-white/80 disabled:opacity-50 cursor-pointer",
|
|
188
192
|
disabled: e.disabled || e.readonly
|
|
189
|
-
}, "▼", 8,
|
|
193
|
+
}, "▼", 8, le)
|
|
190
194
|
])
|
|
191
195
|
])) : n("", !0)
|
|
192
196
|
], 64)),
|
|
193
|
-
e.appendIcon ||
|
|
194
|
-
e.appendIcon ? (
|
|
197
|
+
e.appendIcon || B ? (s(), l("div", ne, [
|
|
198
|
+
e.appendIcon ? (s(), x(f, {
|
|
195
199
|
key: 0,
|
|
196
200
|
icon: e.appendIcon
|
|
197
|
-
}, null, 8, ["icon"])) :
|
|
201
|
+
}, null, 8, ["icon"])) : V(e.$slots, "append-icon", { key: 1 })
|
|
198
202
|
])) : n("", !0),
|
|
199
|
-
!e.noArrows && e.controlVariant === "split" ? (
|
|
203
|
+
!e.noArrows && e.controlVariant === "split" ? (s(), l("div", de, [
|
|
200
204
|
d("button", {
|
|
201
205
|
type: "button",
|
|
202
206
|
class: "p-3 text-lg border-l border-slate-600 text-black dark:text-white disabled:opacity-50 cursor-pointer hover:opacity-80",
|
|
203
|
-
onClick:
|
|
207
|
+
onClick: r[10] || (r[10] = (...t) => o(i) && o(i)(...t)),
|
|
204
208
|
disabled: e.disabled || e.readonly
|
|
205
|
-
}, "+", 8,
|
|
209
|
+
}, "+", 8, ie)
|
|
206
210
|
])) : n("", !0),
|
|
207
|
-
e.suffix ? (
|
|
211
|
+
e.suffix ? (s(), l("div", ae, u(e.suffix), 1)) : n("", !0)
|
|
208
212
|
], 2),
|
|
209
|
-
e.hideDetails ? n("", !0) : (
|
|
210
|
-
e.error || e.errorMessages ? (
|
|
211
|
-
Array.isArray(e.errorMessages) ? (
|
|
212
|
-
(
|
|
213
|
-
])) : typeof e.errorMessages == "string" ? (
|
|
214
|
-
])) : e.hint && (e.persistentHint || o(w)) ? (
|
|
213
|
+
e.hideDetails ? n("", !0) : (s(), l("div", ue, [
|
|
214
|
+
e.error || e.errorMessages ? (s(), l("div", pe, [
|
|
215
|
+
Array.isArray(e.errorMessages) ? (s(), l("div", be, [
|
|
216
|
+
(s(!0), l(D, null, T(e.errorMessages, (t, z) => (s(), l("div", { key: z }, u(t), 1))), 128))
|
|
217
|
+
])) : typeof e.errorMessages == "string" ? (s(), l("div", ye, u(e.errorMessages), 1)) : n("", !0)
|
|
218
|
+
])) : e.hint && (e.persistentHint || o(w)) ? (s(), l("div", ce, u(e.hint), 1)) : n("", !0)
|
|
215
219
|
]))
|
|
216
220
|
], 16)
|
|
217
221
|
], 512));
|
|
218
222
|
}
|
|
219
223
|
};
|
|
220
224
|
export {
|
|
221
|
-
|
|
225
|
+
ge as default
|
|
222
226
|
};
|
|
@@ -43,7 +43,12 @@ const e = {
|
|
|
43
43
|
locale: { type: String, default: "es-AR" },
|
|
44
44
|
separator: { type: String, default: "," },
|
|
45
45
|
useGrouping: { type: Boolean, default: !0 },
|
|
46
|
-
precision: { type: [Number, String], default: 2 }
|
|
46
|
+
precision: { type: [Number, String], default: 2 },
|
|
47
|
+
formatMode: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: "natural"
|
|
50
|
+
// 'bank' | 'natural'
|
|
51
|
+
}
|
|
47
52
|
};
|
|
48
53
|
export {
|
|
49
54
|
e as KunNumberFieldProps
|
|
@@ -1,158 +1,238 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { format as
|
|
3
|
-
function
|
|
4
|
-
const l =
|
|
5
|
-
let
|
|
6
|
-
const
|
|
7
|
-
const e = Number(
|
|
1
|
+
import { ref as M, computed as Y, watch as _, nextTick as h } from "vue";
|
|
2
|
+
import { format as d, clamp as v, toRawNumberString as w, fromRawString as y } from "./numberFormatUtils.js";
|
|
3
|
+
function ne(n, o) {
|
|
4
|
+
const l = M(""), c = M(null), B = M(null), k = M(!1), b = M(0);
|
|
5
|
+
let a = "";
|
|
6
|
+
const C = Y(() => {
|
|
7
|
+
const e = Number(n.precision);
|
|
8
8
|
return e > 0 ? e + 1 : 1;
|
|
9
9
|
});
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
{ immediate: !0 }
|
|
24
|
-
);
|
|
25
|
-
function k(e) {
|
|
26
|
-
const { key: n, target: r } = e, u = /^[0-9]$/.test(n), v = n === "Backspace", g = n === "Delete", d = ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(n), b = e.ctrlKey || e.metaKey, m = n === "Home", U = n === "End";
|
|
27
|
-
if (n === "Tab")
|
|
28
|
-
return;
|
|
29
|
-
if (m) {
|
|
30
|
-
V(() => {
|
|
31
|
-
if (!a.value) return;
|
|
32
|
-
const S = l.value.search(/\d/);
|
|
33
|
-
a.value.setSelectionRange(S, S);
|
|
34
|
-
});
|
|
10
|
+
function K(e) {
|
|
11
|
+
const t = c.value;
|
|
12
|
+
if (!t) return;
|
|
13
|
+
let u = t.value;
|
|
14
|
+
const i = Number(n.precision), s = t.selectionStart || 0;
|
|
15
|
+
if (i === 0) {
|
|
16
|
+
let r = u.replace(/[^0-9]/g, "");
|
|
17
|
+
r = r.replace(/^0+(\d)/, "$1"), l.value = r, h(() => {
|
|
18
|
+
if (!c.value) return;
|
|
19
|
+
c.value.value = r;
|
|
20
|
+
const f = Math.min(r.length, s);
|
|
21
|
+
c.value.setSelectionRange(f, f);
|
|
22
|
+
}), o("input", r);
|
|
35
23
|
return;
|
|
36
24
|
}
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
25
|
+
if (u = u.replace(/\./g, ",").replace(/\s+/g, ""), u = u.replace(/[^0-9,]/g, ""), (u.match(/,/g) || []).length > 1) {
|
|
26
|
+
const r = u.split(","), f = r.shift() || "", m = r.join("");
|
|
27
|
+
u = f + (m.length ? "," + m : "");
|
|
28
|
+
}
|
|
29
|
+
if (u.includes(",")) {
|
|
30
|
+
const [r, f = ""] = u.split(","), m = f.slice(0, i);
|
|
31
|
+
u = r + (m.length ? "," + m : ",");
|
|
32
|
+
}
|
|
33
|
+
l.value = u, h(L), h(() => {
|
|
34
|
+
const r = s;
|
|
35
|
+
t.setSelectionRange(r, r);
|
|
36
|
+
}), o("input", u);
|
|
37
|
+
}
|
|
38
|
+
function L() {
|
|
39
|
+
c.value && (c.value.value = l.value);
|
|
40
|
+
}
|
|
41
|
+
function A(e) {
|
|
42
|
+
if (k.value = !0, !c.value) return;
|
|
43
|
+
const t = parseFloat(n.modelValue ?? 0), u = Number(n.precision);
|
|
44
|
+
if (isNaN(t)) {
|
|
45
|
+
l.value = "", o("focus");
|
|
43
46
|
return;
|
|
44
47
|
}
|
|
45
|
-
if (
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return;
|
|
48
|
+
if (u === 0)
|
|
49
|
+
l.value = String(Math.trunc(t));
|
|
50
|
+
else {
|
|
51
|
+
const s = w(t, u).slice(-u), r = /^0+$/.test(s);
|
|
52
|
+
l.value = r ? String(Math.trunc(t)) : d(t, { ...n, precision: u }).replace(".", ",");
|
|
53
|
+
}
|
|
54
|
+
h(() => {
|
|
55
|
+
var i;
|
|
56
|
+
try {
|
|
57
|
+
if ((e == null ? void 0 : e.relatedTarget) !== void 0 || ((i = e == null ? void 0 : e.sourceCapabilities) == null ? void 0 : i.firesTouchEvents) === !1) {
|
|
58
|
+
const r = l.value.length;
|
|
59
|
+
c.value.setSelectionRange(r, r);
|
|
60
|
+
}
|
|
61
|
+
} catch {
|
|
60
62
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return
|
|
72
|
-
}
|
|
73
|
-
function
|
|
74
|
-
let
|
|
75
|
-
for (let
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
63
|
+
}), o("focus");
|
|
64
|
+
}
|
|
65
|
+
function I() {
|
|
66
|
+
k.value = !1;
|
|
67
|
+
let e = (l.value ?? "").toString().trim();
|
|
68
|
+
e || (e = "0"), e = e.replace(",", ".");
|
|
69
|
+
let t = parseFloat(e);
|
|
70
|
+
isNaN(t) && (t = 0), t = v(t, n.min, n.max), l.value = d(t, { ...n }), o("update:modelValue", t), o("blur");
|
|
71
|
+
}
|
|
72
|
+
function x(e) {
|
|
73
|
+
return Number(n.precision) === 0 ? e === "" ? "0" : e.replace(/^0+(\d)/, "$1") : e.padStart(C.value, "0");
|
|
74
|
+
}
|
|
75
|
+
function D(e, t) {
|
|
76
|
+
let u = 0;
|
|
77
|
+
for (let i = 0; i < t; i++)
|
|
78
|
+
/\d/.test(e[i]) && u++;
|
|
79
|
+
return u;
|
|
80
|
+
}
|
|
81
|
+
function $(e, t) {
|
|
82
|
+
let u = 0;
|
|
83
|
+
for (let i = 0; i < e.length; i++)
|
|
84
|
+
if (/\d/.test(e[i])) {
|
|
85
|
+
if (u === t) return i;
|
|
86
|
+
u++;
|
|
80
87
|
}
|
|
81
|
-
for (let
|
|
82
|
-
if (/\d/.test(e[
|
|
83
|
-
return u + 1;
|
|
88
|
+
for (let i = e.length - 1; i >= 0; i--)
|
|
89
|
+
if (/\d/.test(e[i])) return i + 1;
|
|
84
90
|
return e.length;
|
|
85
91
|
}
|
|
86
|
-
function
|
|
87
|
-
for (;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
t = D(d, Number(i.precision)), l.value = h(d, i), s("update:modelValue", d), s("input", d), V(() => {
|
|
100
|
-
if (a.value)
|
|
92
|
+
function E(e, t) {
|
|
93
|
+
for (; t < e.length && !/\d/.test(e[t]); ) t++;
|
|
94
|
+
if (t >= e.length)
|
|
95
|
+
for (t = e.length; t > 0 && !/\d/.test(e[t - 1]); ) t--;
|
|
96
|
+
const u = e.search(/\d/);
|
|
97
|
+
return t < u ? u : t;
|
|
98
|
+
}
|
|
99
|
+
function R() {
|
|
100
|
+
const e = Number(n.precision) + 1;
|
|
101
|
+
a = String(a || "").padStart(e, "0");
|
|
102
|
+
const t = Math.max(1, a.length - Number(n.precision)), u = a.slice(0, t) || "0", i = a.slice(t).padEnd(Number(n.precision), "0").slice(0, Number(n.precision)), s = `${u}.${i}`, r = parseFloat(s), f = v(r, n.min, n.max);
|
|
103
|
+
a = w(f, Number(n.precision)), l.value = d(f, n), o("update:modelValue", f), o("input", f), h(() => {
|
|
104
|
+
if (c.value)
|
|
101
105
|
try {
|
|
102
|
-
const
|
|
103
|
-
let
|
|
104
|
-
for (;
|
|
105
|
-
|
|
106
|
-
a.value.setSelectionRange(m, m);
|
|
106
|
+
const m = l.value;
|
|
107
|
+
let N = $(m, b.value);
|
|
108
|
+
for (; N < m.length && !/\d/.test(m[N]); ) N++;
|
|
109
|
+
c.value.setSelectionRange(N, N);
|
|
107
110
|
} catch {
|
|
108
|
-
|
|
111
|
+
c.value.setSelectionRange(l.value.length, l.value.length);
|
|
109
112
|
}
|
|
110
113
|
});
|
|
111
114
|
}
|
|
112
|
-
function
|
|
113
|
-
|
|
114
|
-
const e =
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
function
|
|
118
|
-
|
|
119
|
-
var
|
|
120
|
-
if (!
|
|
121
|
-
if ((e == null ? void 0 : e.relatedTarget) !== void 0 || ((
|
|
122
|
-
const
|
|
123
|
-
|
|
115
|
+
function P() {
|
|
116
|
+
k.value = !1, a = x(a);
|
|
117
|
+
const e = y(a, Number(n.precision)), t = v(e, n.min, n.max);
|
|
118
|
+
a = w(t, Number(n.precision)), a = x(a), l.value = d(t, n), o("update:modelValue", t), o("blur");
|
|
119
|
+
}
|
|
120
|
+
function H(e) {
|
|
121
|
+
k.value = !0, h(() => {
|
|
122
|
+
var u;
|
|
123
|
+
if (!c.value) return;
|
|
124
|
+
if ((e == null ? void 0 : e.relatedTarget) !== void 0 || ((u = e == null ? void 0 : e.sourceCapabilities) == null ? void 0 : u.firesTouchEvents) === !1) {
|
|
125
|
+
const i = l.value.length;
|
|
126
|
+
c.value.setSelectionRange(i, i), b.value = l.value.replace(/\D/g, "").length;
|
|
124
127
|
} else {
|
|
125
|
-
const
|
|
126
|
-
|
|
128
|
+
const i = c.value.selectionStart || 0;
|
|
129
|
+
b.value = D(l.value, i);
|
|
127
130
|
}
|
|
128
|
-
}),
|
|
131
|
+
}), o("focus");
|
|
129
132
|
}
|
|
130
|
-
function
|
|
131
|
-
|
|
132
|
-
|
|
133
|
+
function j(e) {
|
|
134
|
+
var t;
|
|
135
|
+
(t = e.preventDefault) == null || t.call(e);
|
|
133
136
|
}
|
|
134
|
-
function
|
|
135
|
-
|
|
136
|
-
|
|
137
|
+
function z(e) {
|
|
138
|
+
if (n.formatMode !== "bank") return;
|
|
139
|
+
const { key: t, target: u } = e, i = /^[0-9]$/.test(t), s = t === "Backspace", r = t === "Delete", f = ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(t), m = e.ctrlKey || e.metaKey, N = t === "Home", Q = t === "End";
|
|
140
|
+
if (t === "Tab") return;
|
|
141
|
+
if (N) {
|
|
142
|
+
h(() => {
|
|
143
|
+
if (!c.value) return;
|
|
144
|
+
const F = l.value.search(/\d/);
|
|
145
|
+
c.value.setSelectionRange(F, F);
|
|
146
|
+
});
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
if (Q) {
|
|
150
|
+
h(() => {
|
|
151
|
+
if (!c.value) return;
|
|
152
|
+
const g = l.value;
|
|
153
|
+
c.value.setSelectionRange(g.length, g.length);
|
|
154
|
+
});
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (f || m) return;
|
|
158
|
+
const W = (u == null ? void 0 : u.selectionStart) ?? 0, V = E(l.value, W);
|
|
159
|
+
e.preventDefault();
|
|
160
|
+
const T = Number(n.precision) + 1;
|
|
161
|
+
for (; a.length < T; ) a = "0" + a;
|
|
162
|
+
const S = D(l.value, V);
|
|
163
|
+
if (i)
|
|
164
|
+
a = a.substring(0, S) + t + a.substring(S), b.value = S + 1;
|
|
165
|
+
else if (s && V > 0) {
|
|
166
|
+
const g = D(l.value, V), F = g - 1;
|
|
167
|
+
if (a.length <= Number(n.precision) + 1) {
|
|
168
|
+
const X = Math.max(0, g - 1);
|
|
169
|
+
a = a.slice(0, X) + a.slice(g), a = x(a), b.value = g, R();
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
g > 0 && (a = a.slice(0, F) + a.slice(g), a = x(a), b.value = F);
|
|
173
|
+
} else if (r && V < l.value.length)
|
|
174
|
+
S < a.length && (a = a.substring(0, S) + a.substring(S + 1), b.value = S);
|
|
175
|
+
else return;
|
|
176
|
+
for (a = x(a); a.length < T; ) a = "0" + a;
|
|
177
|
+
R();
|
|
178
|
+
}
|
|
179
|
+
function U() {
|
|
180
|
+
let e;
|
|
181
|
+
n.formatMode === "bank" ? (e = y(a, Number(n.precision)) || 0, e = v(e + Number(n.step), n.min, n.max), a = w(e, Number(n.precision)), l.value = d(e, n), o("update:modelValue", e), o("input", e)) : (e = parseFloat(n.modelValue ?? 0) || 0, e = v(e + Number(n.step), n.min, n.max), l.value = d(e, n), o("update:modelValue", e), o("input", e));
|
|
182
|
+
}
|
|
183
|
+
function Z() {
|
|
184
|
+
let e;
|
|
185
|
+
n.formatMode === "bank" ? (e = y(a, Number(n.precision)) || 0, e = v(e - Number(n.step), n.min, n.max), a = w(e, Number(n.precision)), l.value = d(e, n), o("update:modelValue", e), o("input", e)) : (e = parseFloat(n.modelValue ?? 0) || 0, e = v(e - Number(n.step), n.min, n.max), l.value = d(e, n), o("update:modelValue", e), o("input", e));
|
|
186
|
+
}
|
|
187
|
+
function q() {
|
|
188
|
+
n.formatMode === "bank" ? (a = "0".repeat(Number(n.precision) + 1), b.value = Number(n.precision) + 1, R(), h(() => {
|
|
189
|
+
var e, t;
|
|
190
|
+
return (t = (e = c.value) == null ? void 0 : e.focus) == null ? void 0 : t.call(e);
|
|
191
|
+
})) : (l.value = "", o("update:modelValue", null), h(() => {
|
|
192
|
+
var e, t;
|
|
193
|
+
return (t = (e = c.value) == null ? void 0 : e.focus) == null ? void 0 : t.call(e);
|
|
194
|
+
}));
|
|
195
|
+
}
|
|
196
|
+
_(
|
|
197
|
+
[() => n.modelValue, () => n.precision, () => n.formatMode],
|
|
198
|
+
([e, t, u]) => {
|
|
199
|
+
if (u !== "bank") {
|
|
200
|
+
l.value = d(e ?? 0, { ...n, precision: t });
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
if (e == null || isNaN(e))
|
|
204
|
+
l.value = d(0, { ...n, precision: t }), a = "0".repeat(Number(t) + 1);
|
|
205
|
+
else {
|
|
206
|
+
const i = parseFloat(e), s = v(i, n.min, n.max);
|
|
207
|
+
a = w(s, Number(t)), a.length < Number(t) + 1 && (a = a.padStart(Number(t) + 1, "0")), l.value = d(s, { ...n, precision: t });
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
{ immediate: !0 }
|
|
211
|
+
);
|
|
212
|
+
function G(e) {
|
|
213
|
+
return n.formatMode !== "bank" ? K() : j(e);
|
|
214
|
+
}
|
|
215
|
+
function J(e) {
|
|
216
|
+
return n.formatMode !== "bank" ? A(e) : H(e);
|
|
137
217
|
}
|
|
138
|
-
function
|
|
139
|
-
|
|
140
|
-
t = "0".repeat(Number(i.precision) + 1), o.value = Number(i.precision) + 1, A(), (e = a.value) == null || e.focus();
|
|
218
|
+
function O(e) {
|
|
219
|
+
return n.formatMode !== "bank" ? I() : P();
|
|
141
220
|
}
|
|
142
221
|
return {
|
|
143
222
|
inputValue: l,
|
|
144
|
-
numberInput:
|
|
145
|
-
rootRef:
|
|
146
|
-
validateKey:
|
|
147
|
-
handleFocus:
|
|
148
|
-
handleBlur:
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
223
|
+
numberInput: c,
|
|
224
|
+
rootRef: B,
|
|
225
|
+
validateKey: z,
|
|
226
|
+
handleFocus: J,
|
|
227
|
+
handleBlur: O,
|
|
228
|
+
handleInput: G,
|
|
229
|
+
onIncrement: U,
|
|
230
|
+
onDecrement: Z,
|
|
231
|
+
onClear: q,
|
|
232
|
+
isActive: k,
|
|
233
|
+
focus: k
|
|
154
234
|
};
|
|
155
235
|
}
|
|
156
236
|
export {
|
|
157
|
-
|
|
237
|
+
ne as useKunNumberField
|
|
158
238
|
};
|