adverich-kun-ui 0.1.480 → 0.1.481
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,69 +1,68 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { format as
|
|
3
|
-
function W(i,
|
|
4
|
-
const l =
|
|
1
|
+
import { ref as S, computed as q, watch as G, nextTick as y } from "vue";
|
|
2
|
+
import { format as h, clamp as x, toRawNumberString as D, fromRawString as C } from "./numberFormatUtils.js";
|
|
3
|
+
function W(i, o) {
|
|
4
|
+
const l = S(""), c = S(null), k = S(null), R = S(!1), s = S(0);
|
|
5
5
|
let t = "";
|
|
6
6
|
const F = q(() => {
|
|
7
7
|
const e = Number(i.precision);
|
|
8
8
|
return e > 0 ? e + 1 : 1;
|
|
9
9
|
});
|
|
10
|
-
function
|
|
10
|
+
function v(e) {
|
|
11
11
|
return Number(i.precision) === 0 ? e === "" ? "0" : e.replace(/^0+(\d)/, "$1") : e.padStart(F.value, "0");
|
|
12
12
|
}
|
|
13
13
|
G(
|
|
14
14
|
[() => i.modelValue, () => i.precision],
|
|
15
15
|
([e, n], [r, u]) => {
|
|
16
|
-
const N = Number(n) !== Number(u);
|
|
17
16
|
if (e == null || isNaN(e))
|
|
18
|
-
l.value =
|
|
17
|
+
l.value = h(0, { ...i, precision: n }), t = "0".repeat(Number(n) + 1);
|
|
19
18
|
else {
|
|
20
|
-
const
|
|
21
|
-
|
|
19
|
+
const N = parseFloat(e), g = x(N, i.min, i.max);
|
|
20
|
+
t = D(g, Number(n)), t.length < Number(n) + 1 && (t = t.padStart(Number(n) + 1, "0")), l.value = h(g, { ...i, precision: n });
|
|
22
21
|
}
|
|
23
22
|
},
|
|
24
23
|
{ immediate: !0 }
|
|
25
24
|
);
|
|
26
25
|
function K(e) {
|
|
27
|
-
const { key: n, target: r } = e, u = /^[0-9]$/.test(n), N = n === "Backspace",
|
|
26
|
+
const { key: n, target: r } = e, u = /^[0-9]$/.test(n), N = n === "Backspace", g = n === "Delete", b = ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(n), d = e.ctrlKey || e.metaKey, m = n === "Home", U = n === "End";
|
|
28
27
|
if (n === "Tab")
|
|
29
28
|
return;
|
|
30
|
-
if (
|
|
31
|
-
|
|
29
|
+
if (m) {
|
|
30
|
+
y(() => {
|
|
32
31
|
if (!c.value) return;
|
|
33
|
-
const
|
|
34
|
-
c.value.setSelectionRange(
|
|
32
|
+
const w = l.value.search(/\d/);
|
|
33
|
+
c.value.setSelectionRange(w, w);
|
|
35
34
|
});
|
|
36
35
|
return;
|
|
37
36
|
}
|
|
38
37
|
if (U) {
|
|
39
|
-
|
|
38
|
+
y(() => {
|
|
40
39
|
if (!c.value) return;
|
|
41
40
|
const a = l.value;
|
|
42
41
|
c.value.setSelectionRange(a.length, a.length);
|
|
43
42
|
});
|
|
44
43
|
return;
|
|
45
44
|
}
|
|
46
|
-
if (
|
|
45
|
+
if (b || d) return;
|
|
47
46
|
const V = B(l.value, r.selectionStart);
|
|
48
47
|
e.preventDefault();
|
|
49
48
|
const L = Number(i.precision) + 1;
|
|
50
49
|
for (; t.length < L; )
|
|
51
50
|
t = "0" + t;
|
|
52
|
-
const
|
|
51
|
+
const f = A(l.value, V);
|
|
53
52
|
if (u)
|
|
54
|
-
t = t.substring(0,
|
|
53
|
+
t = t.substring(0, f) + n + t.substring(f), s.value = f + 1;
|
|
55
54
|
else if (N && V > 0) {
|
|
56
|
-
const a = A(l.value, V),
|
|
55
|
+
const a = A(l.value, V), w = a - 1;
|
|
57
56
|
if (t.length <= Number(i.precision) + 1) {
|
|
58
57
|
const j = Math.max(0, a - 1);
|
|
59
|
-
t = t.slice(0, j) + t.slice(a), t =
|
|
58
|
+
t = t.slice(0, j) + t.slice(a), t = v(t), s.value = a, T();
|
|
60
59
|
return;
|
|
61
60
|
}
|
|
62
|
-
a > 0 && (t = t.slice(0,
|
|
63
|
-
} else
|
|
64
|
-
for (t =
|
|
61
|
+
a > 0 && (t = t.slice(0, w) + t.slice(a), t = v(t), s.value = w);
|
|
62
|
+
} else g && V < l.value.length && f < t.length && (t = t.substring(0, f) + t.substring(f + 1), s.value = f);
|
|
63
|
+
for (t = v(t); t.length < L; )
|
|
65
64
|
t = "0" + t;
|
|
66
|
-
|
|
65
|
+
T();
|
|
67
66
|
}
|
|
68
67
|
function A(e, n) {
|
|
69
68
|
let r = 0;
|
|
@@ -93,45 +92,45 @@ function W(i, s) {
|
|
|
93
92
|
const r = e.search(/\d/);
|
|
94
93
|
return n < r && (n = r), n;
|
|
95
94
|
}
|
|
96
|
-
function
|
|
95
|
+
function T() {
|
|
97
96
|
const e = Number(i.precision) + 1;
|
|
98
97
|
t.padStart(e, "0");
|
|
99
|
-
const n = Math.max(1, t.length - Number(i.precision)), r = t.slice(0, n) || "0", u = t.slice(n).padEnd(Number(i.precision), "0").slice(0, Number(i.precision)), N = `${r}.${u}`,
|
|
100
|
-
t = D(
|
|
98
|
+
const n = Math.max(1, t.length - Number(i.precision)), r = t.slice(0, n) || "0", u = t.slice(n).padEnd(Number(i.precision), "0").slice(0, Number(i.precision)), N = `${r}.${u}`, g = parseFloat(N), b = x(g, i.min, i.max);
|
|
99
|
+
t = D(b, Number(i.precision)), l.value = h(b, i), o("update:modelValue", b), o("input", b), y(() => {
|
|
101
100
|
if (c.value)
|
|
102
101
|
try {
|
|
103
|
-
const
|
|
104
|
-
let
|
|
105
|
-
for (;
|
|
106
|
-
|
|
107
|
-
c.value.setSelectionRange(
|
|
102
|
+
const d = l.value;
|
|
103
|
+
let m = $(d, s.value);
|
|
104
|
+
for (; m < d.length && !/\d/.test(d[m]); )
|
|
105
|
+
m++;
|
|
106
|
+
c.value.setSelectionRange(m, m);
|
|
108
107
|
} catch {
|
|
109
108
|
c.value.setSelectionRange(l.value.length, l.value.length);
|
|
110
109
|
}
|
|
111
110
|
});
|
|
112
111
|
}
|
|
113
112
|
function E() {
|
|
114
|
-
R.value = !1, t =
|
|
115
|
-
const e =
|
|
116
|
-
t = D(n, Number(i.precision)), t =
|
|
113
|
+
R.value = !1, t = v(t);
|
|
114
|
+
const e = C(t, Number(i.precision)), n = x(e, i.min, i.max);
|
|
115
|
+
t = D(n, Number(i.precision)), t = v(t), l.value = h(n, i), o("update:modelValue", n), o("blur");
|
|
117
116
|
}
|
|
118
117
|
function M() {
|
|
119
118
|
var n;
|
|
120
119
|
R.value = !0;
|
|
121
120
|
const e = ((n = c.value) == null ? void 0 : n.selectionStart) || 0;
|
|
122
|
-
|
|
121
|
+
s.value = A(l.value, e), o("focus");
|
|
123
122
|
}
|
|
124
123
|
function H() {
|
|
125
|
-
let e =
|
|
126
|
-
e = x(e + Number(i.step), i.min, i.max), t = D(e, Number(i.precision)), l.value =
|
|
124
|
+
let e = C(t, Number(i.precision)) || 0;
|
|
125
|
+
e = x(e + Number(i.step), i.min, i.max), t = D(e, Number(i.precision)), l.value = h(e, i), o("update:modelValue", e);
|
|
127
126
|
}
|
|
128
127
|
function I() {
|
|
129
|
-
let e =
|
|
130
|
-
e = x(e - Number(i.step), i.min, i.max), t = D(e, Number(i.precision)), l.value =
|
|
128
|
+
let e = C(t, Number(i.precision)) || 0;
|
|
129
|
+
e = x(e - Number(i.step), i.min, i.max), t = D(e, Number(i.precision)), l.value = h(e, i), o("update:modelValue", e);
|
|
131
130
|
}
|
|
132
131
|
function z() {
|
|
133
132
|
var e;
|
|
134
|
-
t = "0".repeat(Number(i.precision) + 1),
|
|
133
|
+
t = "0".repeat(Number(i.precision) + 1), s.value = Number(i.precision) + 1, T(), (e = c.value) == null || e.focus();
|
|
135
134
|
}
|
|
136
135
|
return {
|
|
137
136
|
inputValue: l,
|