adverich-kun-ui 0.1.496 → 0.1.498
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,7 +1,7 @@
|
|
|
1
1
|
import { ref as d, computed as M, watch as H, nextTick as F } from "vue";
|
|
2
2
|
import { isArray as S, isObject as O, fullCopy as L } from "../../../../utils/utils.js";
|
|
3
3
|
function U(t, y, c, v) {
|
|
4
|
-
const l = d(null),
|
|
4
|
+
const l = d(null), g = d(null), x = d(null), i = d(!1), b = d(""), N = (e, n) => {
|
|
5
5
|
if (t.returnObject) return s(e, t.itemTitle);
|
|
6
6
|
const u = l.value.find((f) => f[t.itemValue] === e);
|
|
7
7
|
return s(u, t.itemTitle);
|
|
@@ -85,7 +85,7 @@ function U(t, y, c, v) {
|
|
|
85
85
|
c.value = c.value.filter((u) => u !== n);
|
|
86
86
|
}
|
|
87
87
|
function A(e) {
|
|
88
|
-
t.clearSearchOnSelect && (
|
|
88
|
+
t.clearSearchOnSelect && (b.value = ""), t.clearOnSelect && E(), t.focusOnSelect && j();
|
|
89
89
|
}
|
|
90
90
|
function k() {
|
|
91
91
|
i.value || (i.value = !0);
|
|
@@ -100,16 +100,16 @@ function U(t, y, c, v) {
|
|
|
100
100
|
return e.length === 1 && e.match(/\w/);
|
|
101
101
|
}
|
|
102
102
|
function j() {
|
|
103
|
-
|
|
103
|
+
g.value.inputField.focus(), console.log("sera???");
|
|
104
104
|
}
|
|
105
105
|
function K() {
|
|
106
|
-
i.value = !0, x.value &&
|
|
106
|
+
i.value = !0, x.value && g.value.$el.focus();
|
|
107
107
|
}
|
|
108
108
|
function $(e) {
|
|
109
109
|
const n = e.key;
|
|
110
110
|
(w(n) || n === "Backspace") && (k(), j(), F(() => {
|
|
111
111
|
var f;
|
|
112
|
-
const u = (f =
|
|
112
|
+
const u = (f = g.value) == null ? void 0 : f.inputField;
|
|
113
113
|
if (u) {
|
|
114
114
|
const r = u.selectionStart, o = u.selectionEnd, a = u.value, h = e.key.length === 1 ? e.key : "";
|
|
115
115
|
u.value = a.slice(0, r) + h + a.slice(o), u.selectionStart = u.selectionEnd = r + h.length, u.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
@@ -124,17 +124,17 @@ function U(t, y, c, v) {
|
|
|
124
124
|
c.value.splice(n, 1);
|
|
125
125
|
}
|
|
126
126
|
function E() {
|
|
127
|
-
|
|
127
|
+
b.value !== "" && (b.value = ""), c.value !== null && (c.value = null), l.value !== null && (l.value = null);
|
|
128
128
|
}
|
|
129
129
|
function G(e) {
|
|
130
130
|
return !!e.disabled;
|
|
131
131
|
}
|
|
132
132
|
return {
|
|
133
133
|
selectedItem: l,
|
|
134
|
-
textFieldRef:
|
|
134
|
+
textFieldRef: g,
|
|
135
135
|
listRef: x,
|
|
136
136
|
menuModel: i,
|
|
137
|
-
search:
|
|
137
|
+
search: b,
|
|
138
138
|
getArrayText: N,
|
|
139
139
|
placeholder: B,
|
|
140
140
|
textArr: R,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { ref as
|
|
1
|
+
import { ref as w, computed as q, watch as G, nextTick as V } from "vue";
|
|
2
2
|
import { format as h, clamp as x, toRawNumberString as D, fromRawString as C } from "./numberFormatUtils.js";
|
|
3
|
-
function W(i,
|
|
4
|
-
const l =
|
|
3
|
+
function W(i, s) {
|
|
4
|
+
const l = w(""), a = w(null), K = w(null), R = w(!1), o = w(0);
|
|
5
5
|
let t = "";
|
|
6
|
-
const
|
|
6
|
+
const L = q(() => {
|
|
7
7
|
const e = Number(i.precision);
|
|
8
8
|
return e > 0 ? e + 1 : 1;
|
|
9
9
|
});
|
|
10
|
-
function
|
|
11
|
-
return Number(i.precision) === 0 ? e === "" ? "0" : e.replace(/^0+(\d)/, "$1") : e.padStart(
|
|
10
|
+
function N(e) {
|
|
11
|
+
return Number(i.precision) === 0 ? e === "" ? "0" : e.replace(/^0+(\d)/, "$1") : e.padStart(L.value, "0");
|
|
12
12
|
}
|
|
13
13
|
G(
|
|
14
14
|
[() => i.modelValue, () => i.precision],
|
|
@@ -16,61 +16,61 @@ function W(i, o) {
|
|
|
16
16
|
if (e == null || isNaN(e))
|
|
17
17
|
l.value = h(0, { ...i, precision: n }), t = "0".repeat(Number(n) + 1);
|
|
18
18
|
else {
|
|
19
|
-
const
|
|
19
|
+
const v = parseFloat(e), g = x(v, i.min, i.max);
|
|
20
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 });
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
{ immediate: !0 }
|
|
24
24
|
);
|
|
25
|
-
function
|
|
26
|
-
const { key: n, target: r } = e, u = /^[0-9]$/.test(n),
|
|
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
27
|
if (n === "Tab")
|
|
28
28
|
return;
|
|
29
29
|
if (m) {
|
|
30
|
-
|
|
31
|
-
if (!
|
|
32
|
-
const
|
|
33
|
-
|
|
30
|
+
V(() => {
|
|
31
|
+
if (!a.value) return;
|
|
32
|
+
const S = l.value.search(/\d/);
|
|
33
|
+
a.value.setSelectionRange(S, S);
|
|
34
34
|
});
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
37
|
if (U) {
|
|
38
|
-
|
|
39
|
-
if (!
|
|
40
|
-
const
|
|
41
|
-
|
|
38
|
+
V(() => {
|
|
39
|
+
if (!a.value) return;
|
|
40
|
+
const c = l.value;
|
|
41
|
+
a.value.setSelectionRange(c.length, c.length);
|
|
42
42
|
});
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
|
-
if (
|
|
46
|
-
const
|
|
45
|
+
if (d || b) return;
|
|
46
|
+
const T = $(l.value, r.selectionStart);
|
|
47
47
|
e.preventDefault();
|
|
48
|
-
const
|
|
49
|
-
for (; t.length <
|
|
48
|
+
const F = Number(i.precision) + 1;
|
|
49
|
+
for (; t.length < F; )
|
|
50
50
|
t = "0" + t;
|
|
51
|
-
const f =
|
|
51
|
+
const f = y(l.value, T);
|
|
52
52
|
if (u)
|
|
53
|
-
t = t.substring(0, f) + n + t.substring(f),
|
|
54
|
-
else if (
|
|
55
|
-
const
|
|
53
|
+
t = t.substring(0, f) + n + t.substring(f), o.value = f + 1;
|
|
54
|
+
else if (v && T > 0) {
|
|
55
|
+
const c = y(l.value, T), S = c - 1;
|
|
56
56
|
if (t.length <= Number(i.precision) + 1) {
|
|
57
|
-
const j = Math.max(0,
|
|
58
|
-
t = t.slice(0, j) + t.slice(
|
|
57
|
+
const j = Math.max(0, c - 1);
|
|
58
|
+
t = t.slice(0, j) + t.slice(c), t = N(t), o.value = c, A();
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
} else g &&
|
|
63
|
-
for (t =
|
|
61
|
+
c > 0 && (t = t.slice(0, S) + t.slice(c), t = N(t), o.value = S);
|
|
62
|
+
} else g && T < l.value.length && f < t.length && (t = t.substring(0, f) + t.substring(f + 1), o.value = f);
|
|
63
|
+
for (t = N(t); t.length < F; )
|
|
64
64
|
t = "0" + t;
|
|
65
|
-
|
|
65
|
+
A();
|
|
66
66
|
}
|
|
67
|
-
function
|
|
67
|
+
function y(e, n) {
|
|
68
68
|
let r = 0;
|
|
69
69
|
for (let u = 0; u < n; u++)
|
|
70
70
|
/\d/.test(e[u]) && r++;
|
|
71
71
|
return r;
|
|
72
72
|
}
|
|
73
|
-
function
|
|
73
|
+
function E(e, n) {
|
|
74
74
|
let r = 0;
|
|
75
75
|
for (let u = 0; u < e.length; u++)
|
|
76
76
|
if (/\d/.test(e[u])) {
|
|
@@ -83,7 +83,7 @@ function W(i, o) {
|
|
|
83
83
|
return u + 1;
|
|
84
84
|
return e.length;
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function $(e, n) {
|
|
87
87
|
for (; n < e.length && !/\d/.test(e[n]); )
|
|
88
88
|
n++;
|
|
89
89
|
if (n >= e.length)
|
|
@@ -92,53 +92,60 @@ function W(i, o) {
|
|
|
92
92
|
const r = e.search(/\d/);
|
|
93
93
|
return n < r && (n = r), n;
|
|
94
94
|
}
|
|
95
|
-
function
|
|
95
|
+
function A() {
|
|
96
96
|
const e = Number(i.precision) + 1;
|
|
97
97
|
t.padStart(e, "0");
|
|
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)),
|
|
99
|
-
t = D(
|
|
100
|
-
if (
|
|
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)), v = `${r}.${u}`, g = parseFloat(v), d = x(g, i.min, i.max);
|
|
99
|
+
t = D(d, Number(i.precision)), l.value = h(d, i), s("update:modelValue", d), s("input", d), V(() => {
|
|
100
|
+
if (a.value)
|
|
101
101
|
try {
|
|
102
|
-
const
|
|
103
|
-
let m =
|
|
104
|
-
for (; m <
|
|
102
|
+
const b = l.value;
|
|
103
|
+
let m = E(b, o.value);
|
|
104
|
+
for (; m < b.length && !/\d/.test(b[m]); )
|
|
105
105
|
m++;
|
|
106
|
-
|
|
106
|
+
a.value.setSelectionRange(m, m);
|
|
107
107
|
} catch {
|
|
108
|
-
|
|
108
|
+
a.value.setSelectionRange(l.value.length, l.value.length);
|
|
109
109
|
}
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
|
-
function
|
|
113
|
-
R.value = !1, t =
|
|
112
|
+
function B() {
|
|
113
|
+
R.value = !1, t = N(t);
|
|
114
114
|
const e = C(t, Number(i.precision)), n = x(e, i.min, i.max);
|
|
115
|
-
t = D(n, Number(i.precision)), t =
|
|
115
|
+
t = D(n, Number(i.precision)), t = N(t), l.value = h(n, i), s("update:modelValue", n), s("blur");
|
|
116
116
|
}
|
|
117
|
-
function M() {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
117
|
+
function M(e) {
|
|
118
|
+
R.value = !0, V(() => {
|
|
119
|
+
var r;
|
|
120
|
+
if (!a.value) return;
|
|
121
|
+
if ((e == null ? void 0 : e.relatedTarget) !== void 0 || ((r = e == null ? void 0 : e.sourceCapabilities) == null ? void 0 : r.firesTouchEvents) === !1) {
|
|
122
|
+
const u = l.value.length;
|
|
123
|
+
a.value.setSelectionRange(u, u), o.value = l.value.replace(/\D/g, "").length;
|
|
124
|
+
} else {
|
|
125
|
+
const u = a.value.selectionStart || 0;
|
|
126
|
+
o.value = y(l.value, u);
|
|
127
|
+
}
|
|
128
|
+
}), s("focus");
|
|
122
129
|
}
|
|
123
130
|
function H() {
|
|
124
131
|
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),
|
|
132
|
+
e = x(e + Number(i.step), i.min, i.max), t = D(e, Number(i.precision)), l.value = h(e, i), s("update:modelValue", e);
|
|
126
133
|
}
|
|
127
134
|
function I() {
|
|
128
135
|
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),
|
|
136
|
+
e = x(e - Number(i.step), i.min, i.max), t = D(e, Number(i.precision)), l.value = h(e, i), s("update:modelValue", e);
|
|
130
137
|
}
|
|
131
138
|
function z() {
|
|
132
139
|
var e;
|
|
133
|
-
t = "0".repeat(Number(i.precision) + 1),
|
|
140
|
+
t = "0".repeat(Number(i.precision) + 1), o.value = Number(i.precision) + 1, A(), (e = a.value) == null || e.focus();
|
|
134
141
|
}
|
|
135
142
|
return {
|
|
136
143
|
inputValue: l,
|
|
137
|
-
numberInput:
|
|
138
|
-
rootRef:
|
|
139
|
-
validateKey:
|
|
144
|
+
numberInput: a,
|
|
145
|
+
rootRef: K,
|
|
146
|
+
validateKey: k,
|
|
140
147
|
handleFocus: M,
|
|
141
|
-
handleBlur:
|
|
148
|
+
handleBlur: B,
|
|
142
149
|
onIncrement: H,
|
|
143
150
|
onDecrement: I,
|
|
144
151
|
onClear: z,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ref as a, inject as V, computed as E, watch as g, onUnmounted as T } from "vue";
|
|
2
2
|
import { debounce as j } from "../../../../utils/utils.js";
|
|
3
3
|
function R(u, r) {
|
|
4
|
-
const l = a(u.modelValue ?? ""), o = a(!1), t = a(""), n = a(!1), F = a(null), h = a(null), s = a(!1), d = V("registerField", null), v = V("unregisterField", null),
|
|
4
|
+
const l = a(u.modelValue ?? ""), o = a(!1), t = a(""), n = a(!1), F = a(null), h = a(null), s = a(!1), d = V("registerField", null), v = V("unregisterField", null), y = E(() => u.error || !!t.value && n.value), c = async () => {
|
|
5
5
|
for (const e of u.rules) {
|
|
6
6
|
const m = await Promise.resolve(e(l.value));
|
|
7
7
|
if (m !== !0) return m;
|
|
@@ -20,7 +20,7 @@ function R(u, r) {
|
|
|
20
20
|
}
|
|
21
21
|
n.value = !0, r("update:modelValue", l.value), u.validateOnBlur || f();
|
|
22
22
|
});
|
|
23
|
-
const
|
|
23
|
+
const b = (e) => {
|
|
24
24
|
l.value = e.target.value;
|
|
25
25
|
}, w = async () => {
|
|
26
26
|
if (o.value = !1, u.validateOnBlur) {
|
|
@@ -29,7 +29,7 @@ function R(u, r) {
|
|
|
29
29
|
}
|
|
30
30
|
r("blur");
|
|
31
31
|
}, B = () => {
|
|
32
|
-
console.log("
|
|
32
|
+
console.log("aaa"), o.value = !0, r("focus");
|
|
33
33
|
}, I = () => {
|
|
34
34
|
l.value = "", r("update:modelValue", ""), n.value = !0, u.validateOnBlur || f();
|
|
35
35
|
}, i = async () => {
|
|
@@ -49,8 +49,8 @@ function R(u, r) {
|
|
|
49
49
|
rootRef: h,
|
|
50
50
|
inputFocused: o,
|
|
51
51
|
validationError: t,
|
|
52
|
-
hasError:
|
|
53
|
-
handleInput:
|
|
52
|
+
hasError: y,
|
|
53
|
+
handleInput: b,
|
|
54
54
|
handleBlur: w,
|
|
55
55
|
focusInput: B,
|
|
56
56
|
validate: i,
|