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