adverich-kun-ui 0.1.383 → 0.1.385
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mergeModels as R, useModel as S, onMounted as te, ref as _, watch as oe, createElementBlock as
|
|
1
|
+
import { mergeModels as R, useModel as S, onMounted as te, ref as _, watch as oe, createElementBlock as w, openBlock as s, createVNode as n, unref as l, isRef as $, createSlots as ie, withCtx as i, createCommentVNode as C, Fragment as ne, renderList as ae, createBlock as m, createElementVNode as re, createTextVNode as V, toDisplayString as x, withModifiers as se } from "vue";
|
|
2
2
|
import { icons as f } from "../../../../icons/index.js";
|
|
3
3
|
import { isNotEmpty as ue, isArray as A } from "../../../../utils/utils.js";
|
|
4
4
|
import de from "../../../KunInfiniteScroll/src/components/KunInfiniteScroll.vue.js";
|
|
@@ -14,7 +14,7 @@ import ke from "../../../KunChip/src/components/KunChip.vue.js";
|
|
|
14
14
|
import v from "../../../KunIcon/src/components/KunIcon.vue.js";
|
|
15
15
|
const ye = {
|
|
16
16
|
key: 0,
|
|
17
|
-
class: "flex overflow-x-auto whitespace-nowrap space-x-1"
|
|
17
|
+
class: "w-full flex overflow-x-auto whitespace-nowrap space-x-1"
|
|
18
18
|
}, be = { class: "flex items-center" }, ze = {
|
|
19
19
|
__name: "KunAutocomplete",
|
|
20
20
|
props: /* @__PURE__ */ R(he, {
|
|
@@ -83,7 +83,7 @@ const ye = {
|
|
|
83
83
|
}
|
|
84
84
|
function ee() {
|
|
85
85
|
}
|
|
86
|
-
return (e, o) => (s(),
|
|
86
|
+
return (e, o) => (s(), w("div", {
|
|
87
87
|
class: "w-full h-fit",
|
|
88
88
|
ref_key: "parentRef",
|
|
89
89
|
ref: K
|
|
@@ -111,8 +111,8 @@ const ye = {
|
|
|
111
111
|
"error-messages": h.value
|
|
112
112
|
}, ie({
|
|
113
113
|
default: i(() => [
|
|
114
|
-
l(A)(a.value) ? (s(),
|
|
115
|
-
(s(!0),
|
|
114
|
+
l(A)(a.value) ? (s(), w("div", ye, [
|
|
115
|
+
(s(!0), w(ne, null, ae(a.value, (t) => (s(), m(ke, {
|
|
116
116
|
key: t.id ?? t.name,
|
|
117
117
|
size: "small"
|
|
118
118
|
}, {
|
|
@@ -130,7 +130,7 @@ const ye = {
|
|
|
130
130
|
]),
|
|
131
131
|
_: 2
|
|
132
132
|
}, 1024))), 128))
|
|
133
|
-
])) :
|
|
133
|
+
])) : C("", !0),
|
|
134
134
|
n(fe, {
|
|
135
135
|
transition: "fade",
|
|
136
136
|
"onClick:outside": l(T),
|
|
@@ -226,7 +226,7 @@ const ye = {
|
|
|
226
226
|
color: "error",
|
|
227
227
|
icon: l(f).close,
|
|
228
228
|
class: "mr-1 mt-1"
|
|
229
|
-
}, null, 8, ["onClick", "icon"])) :
|
|
229
|
+
}, null, 8, ["onClick", "icon"])) : C("", !0),
|
|
230
230
|
n(v, {
|
|
231
231
|
color: "teal-darken-1",
|
|
232
232
|
size: "large",
|
|
@@ -240,7 +240,7 @@ const ye = {
|
|
|
240
240
|
size: "x-small",
|
|
241
241
|
class: "mb-4",
|
|
242
242
|
icon: l(f).asterisk
|
|
243
|
-
}, null, 8, ["icon"])) :
|
|
243
|
+
}, null, 8, ["icon"])) : C("", !0)
|
|
244
244
|
]),
|
|
245
245
|
key: "0"
|
|
246
246
|
} : void 0
|
|
@@ -1,58 +1,141 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { format as
|
|
3
|
-
function
|
|
4
|
-
const
|
|
5
|
-
let
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { ref as S, watch as j, nextTick as C } from "vue";
|
|
2
|
+
import { format as d, clamp as b, toRawNumberString as x, fromRawString as L } from "./numberFormatUtils.js";
|
|
3
|
+
function J(t, o) {
|
|
4
|
+
const l = S(""), r = S(null), F = S(null), D = S(!1), s = S(0);
|
|
5
|
+
let e = "";
|
|
6
|
+
const K = t.precision + 1;
|
|
7
|
+
function v(n) {
|
|
8
|
+
return n.padStart(K, "0");
|
|
9
|
+
}
|
|
10
|
+
j(() => t.modelValue, (n) => {
|
|
11
|
+
if (n == null || isNaN(n))
|
|
12
|
+
l.value = d(0, t), e = "0".repeat(t.precision + 1);
|
|
13
|
+
else {
|
|
14
|
+
const i = parseFloat(n), u = b(i, t.min, t.max);
|
|
15
|
+
e = x(u, t.precision), e.length < t.precision + 1 && (e = e.padStart(t.precision + 1, "0")), l.value = d(u, t);
|
|
16
|
+
}
|
|
17
|
+
}, { immediate: !0 });
|
|
18
|
+
function B(n) {
|
|
19
|
+
const { key: i, target: u } = n, c = /^[0-9]$/.test(i), A = i === "Backspace", y = i === "Delete", m = ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(i), h = n.ctrlKey || n.metaKey, f = i === "Home", z = i === "End";
|
|
20
|
+
if (f) {
|
|
21
|
+
C(() => {
|
|
22
|
+
if (!r.value) return;
|
|
23
|
+
const w = l.value.search(/\d/);
|
|
24
|
+
r.value.setSelectionRange(w, w);
|
|
25
|
+
});
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (z) {
|
|
29
|
+
C(() => {
|
|
30
|
+
if (!r.value) return;
|
|
31
|
+
const a = l.value;
|
|
32
|
+
r.value.setSelectionRange(a.length, a.length);
|
|
33
|
+
});
|
|
17
34
|
return;
|
|
18
35
|
}
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
36
|
+
if (m || h) return;
|
|
37
|
+
const R = M(l.value, u.selectionStart);
|
|
38
|
+
n.preventDefault();
|
|
39
|
+
const k = t.precision + 1;
|
|
40
|
+
for (; e.length < k; )
|
|
41
|
+
e = "0" + e;
|
|
42
|
+
const g = N(l.value, R);
|
|
43
|
+
if (c)
|
|
44
|
+
e = e.substring(0, g) + i + e.substring(g), s.value = g + 1;
|
|
45
|
+
else if (A && R > 0) {
|
|
46
|
+
const a = N(l.value, R), w = a - 1;
|
|
47
|
+
if (e.length <= 3) {
|
|
48
|
+
const U = Math.max(0, a - 1);
|
|
49
|
+
e = e.slice(0, U) + e.slice(a), e = v(e), s.value = a, V();
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
a > 0 && (e = e.slice(0, w) + e.slice(a), e = v(e), s.value = w);
|
|
53
|
+
} else y && R < l.value.length && g < e.length && (e = e.substring(0, g) + e.substring(g + 1), s.value = g);
|
|
54
|
+
for (e = v(e); e.length < k; )
|
|
55
|
+
e = "0" + e;
|
|
56
|
+
V();
|
|
57
|
+
}
|
|
58
|
+
function N(n, i) {
|
|
59
|
+
let u = 0;
|
|
60
|
+
for (let c = 0; c < i; c++)
|
|
61
|
+
/\d/.test(n[c]) && u++;
|
|
62
|
+
return u;
|
|
63
|
+
}
|
|
64
|
+
function E(n, i) {
|
|
65
|
+
let u = 0;
|
|
66
|
+
for (let c = 0; c < n.length; c++)
|
|
67
|
+
if (/\d/.test(n[c])) {
|
|
68
|
+
if (u === i)
|
|
69
|
+
return c;
|
|
70
|
+
u++;
|
|
71
|
+
}
|
|
72
|
+
for (let c = n.length - 1; c >= 0; c--)
|
|
73
|
+
if (/\d/.test(n[c]))
|
|
74
|
+
return c + 1;
|
|
75
|
+
return n.length;
|
|
76
|
+
}
|
|
77
|
+
function M(n, i) {
|
|
78
|
+
for (; i < n.length && !/\d/.test(n[i]); )
|
|
79
|
+
i++;
|
|
80
|
+
if (i >= n.length)
|
|
81
|
+
for (i = n.length; i > 0 && !/\d/.test(n[i - 1]); )
|
|
82
|
+
i--;
|
|
83
|
+
const u = n.search(/\d/);
|
|
84
|
+
return i < u && (i = u), i;
|
|
85
|
+
}
|
|
86
|
+
function V() {
|
|
87
|
+
const n = t.precision + 1;
|
|
88
|
+
e.padStart(n, "0");
|
|
89
|
+
const i = Math.max(1, e.length - t.precision), u = e.slice(0, i) || "0", c = e.slice(i).padEnd(t.precision, "0").slice(0, t.precision), A = `${u}.${c}`, y = parseFloat(A), m = b(y, t.min, t.max);
|
|
90
|
+
e = x(m, t.precision), l.value = d(m, t), o("update:modelValue", m), o("input", m), C(() => {
|
|
91
|
+
if (r.value)
|
|
92
|
+
try {
|
|
93
|
+
const h = l.value;
|
|
94
|
+
let f = E(h, s.value);
|
|
95
|
+
for (; f < h.length && !/\d/.test(h[f]); )
|
|
96
|
+
f++;
|
|
97
|
+
r.value.setSelectionRange(f, f);
|
|
98
|
+
} catch {
|
|
99
|
+
r.value.setSelectionRange(l.value.length, l.value.length);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
22
102
|
}
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
const n =
|
|
26
|
-
|
|
103
|
+
function P() {
|
|
104
|
+
D.value = !1, e = v(e);
|
|
105
|
+
const n = L(e, t.precision), i = b(n, t.min, t.max);
|
|
106
|
+
e = x(i, t.precision), e = v(e), l.value = d(i, t), o("update:modelValue", i), o("blur");
|
|
27
107
|
}
|
|
28
|
-
function
|
|
29
|
-
|
|
108
|
+
function T() {
|
|
109
|
+
var i;
|
|
110
|
+
D.value = !0;
|
|
111
|
+
const n = ((i = r.value) == null ? void 0 : i.selectionStart) || 0;
|
|
112
|
+
s.value = N(l.value, n), o("focus");
|
|
30
113
|
}
|
|
31
|
-
function
|
|
32
|
-
let n =
|
|
33
|
-
n =
|
|
114
|
+
function $() {
|
|
115
|
+
let n = L(e, t.precision) || 0;
|
|
116
|
+
n = b(n + Number(t.step), t.min, t.max), e = x(n, t.precision), l.value = d(n, t), o("update:modelValue", n);
|
|
34
117
|
}
|
|
35
|
-
function
|
|
36
|
-
let n =
|
|
37
|
-
n =
|
|
118
|
+
function H() {
|
|
119
|
+
let n = L(e, t.precision) || 0;
|
|
120
|
+
n = b(n - Number(t.step), t.min, t.max), e = x(n, t.precision), l.value = d(n, t), o("update:modelValue", n);
|
|
38
121
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
122
|
+
function I() {
|
|
123
|
+
e = "0".repeat(t.precision + 1), s.value = t.precision + 1, V();
|
|
41
124
|
}
|
|
42
125
|
return {
|
|
43
|
-
inputValue:
|
|
44
|
-
numberInput:
|
|
45
|
-
rootRef:
|
|
46
|
-
validateKey:
|
|
47
|
-
handleFocus:
|
|
48
|
-
handleBlur:
|
|
49
|
-
onIncrement:
|
|
50
|
-
onDecrement:
|
|
51
|
-
onClear:
|
|
52
|
-
isActive:
|
|
53
|
-
focus:
|
|
126
|
+
inputValue: l,
|
|
127
|
+
numberInput: r,
|
|
128
|
+
rootRef: F,
|
|
129
|
+
validateKey: B,
|
|
130
|
+
handleFocus: T,
|
|
131
|
+
handleBlur: P,
|
|
132
|
+
onIncrement: $,
|
|
133
|
+
onDecrement: H,
|
|
134
|
+
onClear: I,
|
|
135
|
+
isActive: D,
|
|
136
|
+
focus: D
|
|
54
137
|
};
|
|
55
138
|
}
|
|
56
139
|
export {
|
|
57
|
-
|
|
140
|
+
J as useKunNumberField
|
|
58
141
|
};
|