adverich-kun-ui 0.1.377 → 0.1.379
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,48 +1,46 @@
|
|
|
1
1
|
import { ref as o, watch as R } from "vue";
|
|
2
|
-
import { format as
|
|
3
|
-
function I(e,
|
|
4
|
-
const
|
|
2
|
+
import { format as i, toRawNumberString as m, fromRawString as r, clamp as f } from "./numberFormatUtils.js";
|
|
3
|
+
function I(e, a) {
|
|
4
|
+
const u = o(""), x = o(null), N = o(null), c = o(!1);
|
|
5
5
|
let t = "";
|
|
6
6
|
R(
|
|
7
7
|
() => e.modelValue,
|
|
8
8
|
(n) => {
|
|
9
|
-
n == null || isNaN(n) ? (
|
|
9
|
+
n == null || isNaN(n) ? (u.value = i(0, e), t = "") : (t = m(n, e.precision), u.value = i(parseFloat(n), e));
|
|
10
10
|
},
|
|
11
11
|
{ immediate: !0 }
|
|
12
12
|
);
|
|
13
13
|
function V(n) {
|
|
14
|
-
const
|
|
14
|
+
const l = n.key, s = /^[0-9]$/.test(l), v = l === "Backspace";
|
|
15
15
|
if (!s && !v) {
|
|
16
16
|
n.preventDefault();
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
-
s ? t +=
|
|
19
|
+
s ? t += l : v && (t = t.slice(0, -1));
|
|
20
20
|
const b = t.padStart(e.precision + 1, "0"), h = b.slice(0, -e.precision), y = b.slice(-e.precision), B = parseFloat(`${h}.${y}`), d = f(B, e.min, e.max);
|
|
21
|
-
|
|
22
|
-
u("input", d);
|
|
23
|
-
}, 100), n.preventDefault();
|
|
21
|
+
u.value = i(d, e), a("update:modelValue", d), a("input", d), n.preventDefault();
|
|
24
22
|
}
|
|
25
23
|
function g() {
|
|
26
24
|
c.value = !1;
|
|
27
|
-
const n = r(t, e.precision),
|
|
28
|
-
t = m(
|
|
25
|
+
const n = r(t, e.precision), l = f(n, e.min, e.max);
|
|
26
|
+
t = m(l, e.precision), u.value = i(l, e), a("update:modelValue", l), a("blur");
|
|
29
27
|
}
|
|
30
28
|
function k() {
|
|
31
|
-
c.value = !0,
|
|
29
|
+
c.value = !0, a("focus");
|
|
32
30
|
}
|
|
33
31
|
function D() {
|
|
34
32
|
let n = r(t, e.precision) || 0;
|
|
35
|
-
n = f(n + Number(e.step), e.min, e.max), t = m(n, e.precision),
|
|
33
|
+
n = f(n + Number(e.step), e.min, e.max), t = m(n, e.precision), u.value = i(n, e), a("update:modelValue", n);
|
|
36
34
|
}
|
|
37
35
|
function F() {
|
|
38
36
|
let n = r(t, e.precision) || 0;
|
|
39
|
-
n = f(n - Number(e.step), e.min, e.max), t = m(n, e.precision),
|
|
37
|
+
n = f(n - Number(e.step), e.min, e.max), t = m(n, e.precision), u.value = i(n, e), a("update:modelValue", n);
|
|
40
38
|
}
|
|
41
39
|
function S() {
|
|
42
|
-
t = "",
|
|
40
|
+
t = "", u.value = i(0, e), a("update:modelValue", null);
|
|
43
41
|
}
|
|
44
42
|
return {
|
|
45
|
-
inputValue:
|
|
43
|
+
inputValue: u,
|
|
46
44
|
numberInput: x,
|
|
47
45
|
rootRef: N,
|
|
48
46
|
validateKey: V,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getCurrentInstance as U, computed as
|
|
2
|
-
import { icons as
|
|
1
|
+
import { getCurrentInstance as U, computed as u, useSlots as H, ref as q, createElementBlock as o, openBlock as s, createCommentVNode as r, createElementVNode as c, normalizeClass as i, toDisplayString as a, mergeProps as G, unref as l, renderSlot as k, withModifiers as J, createVNode as L } from "vue";
|
|
2
|
+
import { icons as V } from "../../../../icons/index.js";
|
|
3
3
|
import Q from "../composables/KunTextFieldProps.js";
|
|
4
4
|
import W from "../composables/useKunTextFieldComposable.js";
|
|
5
5
|
import X from "../../../KunIcon/src/components/KunIcon.vue.js";
|
|
@@ -9,16 +9,16 @@ const Y = {
|
|
|
9
9
|
}, Z = ["type", "value", "placeholder", "disabled", "readonly", "maxlength", "aria-invalid", "aria-describedby"], _ = ["disabled"], ee = {
|
|
10
10
|
key: 3,
|
|
11
11
|
class: "flex items-center justify-center min-w-[32px] h-full px-1"
|
|
12
|
-
},
|
|
12
|
+
}, le = {
|
|
13
13
|
key: 5,
|
|
14
14
|
class: "ml-2"
|
|
15
|
-
},
|
|
15
|
+
}, te = {
|
|
16
16
|
key: 0,
|
|
17
17
|
class: "h-[1.25rem]"
|
|
18
|
-
},
|
|
18
|
+
}, ne = ["id"], oe = {
|
|
19
19
|
key: 1,
|
|
20
20
|
class: "text-xs text-center"
|
|
21
|
-
},
|
|
21
|
+
}, se = {
|
|
22
22
|
key: 2,
|
|
23
23
|
class: "text-xs text-right"
|
|
24
24
|
}, pe = {
|
|
@@ -32,121 +32,125 @@ const Y = {
|
|
|
32
32
|
"keyDown",
|
|
33
33
|
"keyUp"
|
|
34
34
|
],
|
|
35
|
-
setup(
|
|
36
|
-
const
|
|
37
|
-
inputField:
|
|
35
|
+
setup(j, { expose: D, emit: B }) {
|
|
36
|
+
const d = j, p = B, {
|
|
37
|
+
inputField: b,
|
|
38
38
|
inputValue: f,
|
|
39
39
|
rootRef: w,
|
|
40
|
-
inputFocused:
|
|
41
|
-
validationError:
|
|
40
|
+
inputFocused: h,
|
|
41
|
+
validationError: E,
|
|
42
42
|
hasError: y,
|
|
43
43
|
handleInput: g,
|
|
44
44
|
handleBlur: C,
|
|
45
45
|
focusInput: I,
|
|
46
|
-
validate:
|
|
47
|
-
reset:
|
|
48
|
-
resetValidation:
|
|
46
|
+
validate: K,
|
|
47
|
+
reset: S,
|
|
48
|
+
resetValidation: T,
|
|
49
49
|
clearInput: $
|
|
50
|
-
} = W(
|
|
50
|
+
} = W(d, p);
|
|
51
51
|
D({
|
|
52
|
-
validate:
|
|
53
|
-
reset:
|
|
54
|
-
resetValidation:
|
|
55
|
-
inputField:
|
|
52
|
+
validate: K,
|
|
53
|
+
reset: S,
|
|
54
|
+
resetValidation: T,
|
|
55
|
+
inputField: b,
|
|
56
56
|
rootRef: w,
|
|
57
57
|
focus: () => {
|
|
58
58
|
var e;
|
|
59
|
-
return (e =
|
|
59
|
+
return (e = b.value) == null ? void 0 : e.focus();
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
|
-
const m = `input-${U().uid}`,
|
|
63
|
-
function
|
|
62
|
+
const m = `input-${U().uid}`, N = u(() => h.value || !!f.value || d.dirty), x = H(), O = u(() => !!x["prepend-inner"]), z = u(() => !!x["append-inner"]), v = q(!1), A = u(() => v.value ? V.eyeOffOutline : V.eyeOutline);
|
|
63
|
+
function M() {
|
|
64
64
|
v.value = !v.value;
|
|
65
65
|
}
|
|
66
|
-
const
|
|
67
|
-
return (e,
|
|
68
|
-
var
|
|
69
|
-
return
|
|
66
|
+
const R = u(() => d.type === "password" ? v.value ? "text" : "password" : d.type), F = u(() => d.density === "compact" ? "p-1" : d.density === "comfortable" ? "p-2" : "p-3");
|
|
67
|
+
return (e, t) => {
|
|
68
|
+
var P;
|
|
69
|
+
return s(), o("div", {
|
|
70
70
|
class: "w-full flex flex-col relative",
|
|
71
71
|
ref_key: "rootRef",
|
|
72
72
|
ref: w
|
|
73
73
|
}, [
|
|
74
|
-
e.label ? (
|
|
74
|
+
e.label ? (s(), o("label", {
|
|
75
75
|
key: 0,
|
|
76
76
|
for: m,
|
|
77
|
-
class:
|
|
77
|
+
class: i([
|
|
78
78
|
e.labelColor,
|
|
79
79
|
"absolute left-2 transition-all duration-200 ease-in-out pointer-events-none select-none z-10",
|
|
80
|
-
|
|
80
|
+
N.value || e.placeholder ? "-top-2.25 text-xs opacity-80" : "top-3 text-sm opacity-80"
|
|
81
81
|
])
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
class:
|
|
82
|
+
}, a(e.label), 3)) : r("", !0),
|
|
83
|
+
c("div", G({ class: "w-full flex flex-col justify-center relative" }, e.$attrs), [
|
|
84
|
+
c("div", {
|
|
85
|
+
class: i(["flex flex-row items-center w-full h-full border", [
|
|
86
86
|
e.bgInput,
|
|
87
87
|
e.rounded,
|
|
88
|
-
|
|
88
|
+
l(h) ? "border-blue-600 shadow-[0_0_0_1px_rgba(59,130,246,0.5)]" : e.borderColor,
|
|
89
89
|
e.disabled ? "opacity-60 cursor-not-allowed" : "cursor-text",
|
|
90
|
-
|
|
90
|
+
l(y) ? "bg-red-200 dark:bg-red-900" : ""
|
|
91
91
|
]])
|
|
92
92
|
}, [
|
|
93
|
-
e.prefix ? (
|
|
94
|
-
|
|
93
|
+
e.prefix ? (s(), o("div", Y, a(e.prefix), 1)) : r("", !0),
|
|
94
|
+
O.value ? (s(), o("div", {
|
|
95
95
|
key: 1,
|
|
96
|
-
class:
|
|
96
|
+
class: i([e.prependInnerClass, "flex items-center justify-center min-w-[32px] h-full px-1"])
|
|
97
97
|
}, [
|
|
98
98
|
k(e.$slots, "prepend-inner")
|
|
99
99
|
], 2)) : r("", !0),
|
|
100
|
-
|
|
100
|
+
c("input", {
|
|
101
101
|
ref_key: "inputField",
|
|
102
|
-
ref:
|
|
103
|
-
type:
|
|
104
|
-
value:
|
|
102
|
+
ref: b,
|
|
103
|
+
type: R.value,
|
|
104
|
+
value: l(f),
|
|
105
105
|
id: m,
|
|
106
106
|
placeholder: e.placeholder,
|
|
107
107
|
disabled: e.disabled,
|
|
108
108
|
readonly: e.readonly,
|
|
109
109
|
maxlength: e.maxlength,
|
|
110
110
|
autocomplete: "off",
|
|
111
|
-
class:
|
|
112
|
-
"aria-invalid":
|
|
113
|
-
"aria-describedby":
|
|
114
|
-
onInput:
|
|
115
|
-
onBlur:
|
|
116
|
-
onFocus:
|
|
117
|
-
onClick:
|
|
118
|
-
onKeydown:
|
|
119
|
-
onKeyup:
|
|
111
|
+
class: i(["w-full h-full bg-transparent focus:outline-none", [F.value, e.textColor, e.placeholderColor, e.rounded, e.textCenter ? "text-center" : ""]]),
|
|
112
|
+
"aria-invalid": l(y) ? "true" : "false",
|
|
113
|
+
"aria-describedby": l(y) ? `error-${m}` : null,
|
|
114
|
+
onInput: t[0] || (t[0] = (...n) => l(g) && l(g)(...n)),
|
|
115
|
+
onBlur: t[1] || (t[1] = (...n) => l(C) && l(C)(...n)),
|
|
116
|
+
onFocus: t[2] || (t[2] = (...n) => l(I) && l(I)(...n)),
|
|
117
|
+
onClick: t[3] || (t[3] = J((n) => p("handleClick"), ["stop"])),
|
|
118
|
+
onKeydown: t[4] || (t[4] = (n) => p("keyDown", n)),
|
|
119
|
+
onKeyup: t[5] || (t[5] = (n) => p("keyUp", n))
|
|
120
120
|
}, null, 42, Z),
|
|
121
|
-
e.clearable &&
|
|
121
|
+
e.clearable && l(f) ? (s(), o("button", {
|
|
122
122
|
key: 2,
|
|
123
123
|
type: "button",
|
|
124
|
-
onClick:
|
|
125
|
-
class:
|
|
124
|
+
onClick: t[6] || (t[6] = (...n) => l($) && l($)(...n)),
|
|
125
|
+
class: i(["ml-2", e.textColor]),
|
|
126
126
|
disabled: e.disabled || e.readonly
|
|
127
127
|
}, " × ", 10, _)) : r("", !0),
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
c("div", {
|
|
129
|
+
class: i(["w-full h-full bg-transparent focus:outline-none flex items-center", [F.value, e.textColor, e.placeholderColor, e.rounded, e.textCenter ? "justify-center" : ""]])
|
|
130
|
+
}, [
|
|
131
|
+
k(e.$slots, "default")
|
|
132
|
+
], 2),
|
|
133
|
+
e.type === "password" && e.showPasswordToggle ? (s(), o("div", ee, [
|
|
130
134
|
L(X, {
|
|
131
|
-
icon:
|
|
132
|
-
onClick:
|
|
135
|
+
icon: A.value,
|
|
136
|
+
onClick: M
|
|
133
137
|
}, null, 8, ["icon"])
|
|
134
138
|
])) : r("", !0),
|
|
135
|
-
|
|
139
|
+
z.value ? (s(), o("div", {
|
|
136
140
|
key: 4,
|
|
137
|
-
class:
|
|
141
|
+
class: i([e.appendInnerClass, "flex items-center justify-center min-w-[32px] h-full px-1"])
|
|
138
142
|
}, [
|
|
139
143
|
k(e.$slots, "append-inner")
|
|
140
144
|
], 2)) : r("", !0),
|
|
141
|
-
e.suffix ? (
|
|
145
|
+
e.suffix ? (s(), o("div", le, a(e.suffix), 1)) : r("", !0)
|
|
142
146
|
], 2),
|
|
143
|
-
e.hideDetails ? r("", !0) : (
|
|
144
|
-
|
|
147
|
+
e.hideDetails ? r("", !0) : (s(), o("div", te, [
|
|
148
|
+
l(y) ? (s(), o("div", {
|
|
145
149
|
key: 0,
|
|
146
150
|
id: `error-${m}`,
|
|
147
151
|
class: "text-red-500 text-sm text-center"
|
|
148
|
-
},
|
|
149
|
-
e.counter && e.maxlength ? (
|
|
152
|
+
}, a(l(E) || e.errorMessage), 9, ne)) : e.hint && (e.persistentHint || l(h)) ? (s(), o("div", oe, a(e.hint), 1)) : r("", !0),
|
|
153
|
+
e.counter && e.maxlength ? (s(), o("div", se, a(((P = l(f)) == null ? void 0 : P.length) || 0) + " / " + a(e.maxlength), 1)) : r("", !0)
|
|
150
154
|
]))
|
|
151
155
|
], 16)
|
|
152
156
|
], 512);
|