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