adverich-kun-ui 0.1.183 → 0.1.184
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,15 +1,16 @@
|
|
|
1
1
|
const e = {
|
|
2
|
-
modelValue: [String, Number],
|
|
2
|
+
modelValue: [String, Number, Array, Object, Boolean],
|
|
3
|
+
formatModel: {
|
|
4
|
+
type: String,
|
|
5
|
+
default: "auto"
|
|
6
|
+
// auto | raw | json
|
|
7
|
+
},
|
|
3
8
|
label: String,
|
|
4
9
|
placeholder: String,
|
|
5
|
-
rows: {
|
|
6
|
-
type: [String, Number],
|
|
7
|
-
default: 1
|
|
8
|
-
},
|
|
10
|
+
rows: { type: [String, Number], default: 1 },
|
|
9
11
|
autoGrow: Boolean,
|
|
10
12
|
noResize: Boolean,
|
|
11
13
|
maxRows: [Number, String],
|
|
12
|
-
// 🔧 Agregado
|
|
13
14
|
clearable: Boolean,
|
|
14
15
|
clearIcon: {
|
|
15
16
|
type: [String, Function, Object],
|
|
@@ -17,14 +18,8 @@ const e = {
|
|
|
17
18
|
},
|
|
18
19
|
disabled: Boolean,
|
|
19
20
|
readonly: Boolean,
|
|
20
|
-
variant: {
|
|
21
|
-
|
|
22
|
-
default: "filled"
|
|
23
|
-
},
|
|
24
|
-
density: {
|
|
25
|
-
type: String,
|
|
26
|
-
default: "default"
|
|
27
|
-
},
|
|
21
|
+
variant: { type: String, default: "filled" },
|
|
22
|
+
density: { type: String, default: "default" },
|
|
28
23
|
// Estilo
|
|
29
24
|
rounded: [Boolean, String, Number],
|
|
30
25
|
tile: Boolean,
|
|
@@ -60,17 +55,11 @@ const e = {
|
|
|
60
55
|
validateOn: String,
|
|
61
56
|
hint: String,
|
|
62
57
|
persistentHint: Boolean,
|
|
63
|
-
hideDetails: {
|
|
64
|
-
type: [Boolean, String],
|
|
65
|
-
default: !1
|
|
66
|
-
},
|
|
58
|
+
hideDetails: { type: [Boolean, String], default: !1 },
|
|
67
59
|
persistentCounter: Boolean,
|
|
68
60
|
// Loader
|
|
69
61
|
loading: Boolean,
|
|
70
|
-
loadingColor: {
|
|
71
|
-
type: String,
|
|
72
|
-
default: "bg-slate-500"
|
|
73
|
-
}
|
|
62
|
+
loadingColor: { type: String, default: "bg-slate-500" }
|
|
74
63
|
};
|
|
75
64
|
export {
|
|
76
65
|
e as kunTextareaProps
|
|
@@ -1,58 +1,76 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
function
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { ref as n, watch as N, nextTick as M, onMounted as T, computed as V } from "vue";
|
|
2
|
+
function k(t, s, l) {
|
|
3
|
+
const h = n(!1), w = n(t.modelValue), g = (e) => {
|
|
4
|
+
if (t.formatModel === "raw") return String(e ?? "");
|
|
5
|
+
if ((t.formatModel === "json" || t.formatModel === "auto") && typeof e == "object" && e !== null)
|
|
6
|
+
try {
|
|
7
|
+
return JSON.stringify(e, null, 2);
|
|
8
|
+
} catch {
|
|
9
|
+
return String(e);
|
|
10
|
+
}
|
|
11
|
+
return String(e ?? "");
|
|
12
|
+
}, m = (e) => {
|
|
13
|
+
if (t.formatModel === "raw") return e;
|
|
14
|
+
try {
|
|
15
|
+
const a = JSON.parse(e);
|
|
16
|
+
if (t.formatModel === "json" || t.formatModel === "auto")
|
|
17
|
+
return a;
|
|
18
|
+
} catch {
|
|
19
|
+
}
|
|
20
|
+
return e;
|
|
21
|
+
}, o = n(g(t.modelValue));
|
|
22
|
+
N(() => t.modelValue, (e) => {
|
|
23
|
+
w.value = e, o.value = g(e), t.autoGrow && M(c);
|
|
6
24
|
});
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
25
|
+
const v = (e) => {
|
|
26
|
+
o.value = e;
|
|
27
|
+
const a = m(e);
|
|
28
|
+
s("update:modelValue", a);
|
|
29
|
+
}, H = () => {
|
|
30
|
+
v(""), s("click:clear");
|
|
11
31
|
}, c = () => {
|
|
12
|
-
if (!
|
|
13
|
-
|
|
14
|
-
e.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
e.style.height = Math.min(u, r) + "px";
|
|
32
|
+
if (!l.value) return;
|
|
33
|
+
l.value.style.height = "auto", l.value.style.overflowY = "hidden";
|
|
34
|
+
const e = l.value.scrollHeight, a = parseFloat(getComputedStyle(l.value).lineHeight || "24"), i = Number(t.maxRows || 0);
|
|
35
|
+
if (t.maxRows && i > 0) {
|
|
36
|
+
const u = i * a;
|
|
37
|
+
l.value.style.height = Math.min(e, u) + "px";
|
|
19
38
|
} else
|
|
20
|
-
|
|
39
|
+
l.value.style.height = e + "px";
|
|
21
40
|
};
|
|
22
|
-
|
|
23
|
-
t.autoGrow &&
|
|
41
|
+
T(() => {
|
|
42
|
+
t.autoGrow && M(c);
|
|
24
43
|
});
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
for (const
|
|
28
|
-
const
|
|
29
|
-
typeof
|
|
44
|
+
const r = n([]), S = n(!0), j = (e = !1) => {
|
|
45
|
+
const a = t.validationValue ?? m(o.value), i = t.rules ?? [], u = [];
|
|
46
|
+
for (const d of i) {
|
|
47
|
+
const f = typeof d == "function" ? d(a) : d;
|
|
48
|
+
typeof f == "string" ? u.push(f) : f === !1 && u.push("Campo inválido");
|
|
30
49
|
}
|
|
31
|
-
return
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
},
|
|
50
|
+
return r.value = u.slice(0, t.maxErrors ?? 1), e || s("update:focused", h.value), r.value;
|
|
51
|
+
}, y = () => {
|
|
52
|
+
r.value = [];
|
|
53
|
+
}, x = () => {
|
|
54
|
+
o.value = "", y(), s("update:modelValue", "");
|
|
55
|
+
}, C = V(() => t.error || r.value.length > 0), E = V(() => {
|
|
37
56
|
var e;
|
|
38
|
-
return (e = t.errorMessages) != null && e.length ? Array.isArray(t.errorMessages) ? t.errorMessages : [t.errorMessages] :
|
|
57
|
+
return (e = t.errorMessages) != null && e.length ? Array.isArray(t.errorMessages) ? t.errorMessages : [t.errorMessages] : r.value;
|
|
39
58
|
});
|
|
40
59
|
return {
|
|
41
|
-
isFocused:
|
|
42
|
-
internalValue:
|
|
43
|
-
updateValue:
|
|
44
|
-
handleClear:
|
|
60
|
+
isFocused: h,
|
|
61
|
+
internalValue: o,
|
|
62
|
+
updateValue: v,
|
|
63
|
+
handleClear: H,
|
|
45
64
|
adjustHeight: c,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
displayedMessages: C
|
|
65
|
+
isPristine: S,
|
|
66
|
+
validate: j,
|
|
67
|
+
reset: x,
|
|
68
|
+
resetValidation: y,
|
|
69
|
+
validationErrors: r,
|
|
70
|
+
hasError: C,
|
|
71
|
+
displayedMessages: E
|
|
54
72
|
};
|
|
55
73
|
}
|
|
56
74
|
export {
|
|
57
|
-
|
|
75
|
+
k as useKunTextarea
|
|
58
76
|
};
|