adverich-kun-ui 0.1.183 → 0.1.185
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
|
-
import { ref as L, computed as p, createElementBlock as l, openBlock as s, normalizeClass as f, renderSlot as i, createElementVNode as a, normalizeProps as y, guardReactiveProps as k, unref as n, createCommentVNode as d, toDisplayString as
|
|
1
|
+
import { ref as L, computed as p, createElementBlock as l, openBlock as s, normalizeClass as f, renderSlot as i, createElementVNode as a, normalizeProps as y, guardReactiveProps as k, unref as n, createCommentVNode as d, toDisplayString as g, createBlock as h, resolveDynamicComponent as C, Fragment as q, renderList as J, withDirectives as O, vShow as Q, createTextVNode as U } from "vue";
|
|
2
2
|
import { kunTextareaProps as W } from "../composables/KunTextareaProps.js";
|
|
3
3
|
import { useKunTextarea as X } from "../composables/useKunTextareaComposable.js";
|
|
4
|
-
import { renderIconSlot as
|
|
4
|
+
import { renderIconSlot as $ } from "../../../../utils/renderIcon.js";
|
|
5
5
|
const Y = {
|
|
6
6
|
key: 0,
|
|
7
7
|
class: "block text-sm font-medium mb-1"
|
|
@@ -27,8 +27,8 @@ const Y = {
|
|
|
27
27
|
__name: "KunTextarea",
|
|
28
28
|
props: W,
|
|
29
29
|
emits: ["update:modelValue", "click:clear", "click:control", "update:focused", "mousedown:control"],
|
|
30
|
-
setup(
|
|
31
|
-
const r =
|
|
30
|
+
setup(B, { expose: R, emit: S }) {
|
|
31
|
+
const r = B, V = S, u = L(null), {
|
|
32
32
|
isFocused: v,
|
|
33
33
|
internalValue: c,
|
|
34
34
|
updateValue: D,
|
|
@@ -40,15 +40,22 @@ const Y = {
|
|
|
40
40
|
hasError: b,
|
|
41
41
|
displayedMessages: w
|
|
42
42
|
} = X(r, V, u), E = p(() => {
|
|
43
|
+
const e = !!r.bgColor;
|
|
43
44
|
switch (r.variant) {
|
|
44
45
|
case "filled":
|
|
45
|
-
return
|
|
46
|
+
return [
|
|
47
|
+
e ? "" : "bg-gray-100 dark:bg-gray-900",
|
|
48
|
+
"border border-transparent"
|
|
49
|
+
];
|
|
46
50
|
case "outlined":
|
|
47
51
|
return "border border-gray-300 bg-transparent";
|
|
48
52
|
case "underlined":
|
|
49
53
|
return "border-b border-gray-300 bg-transparent rounded-none";
|
|
50
54
|
case "solo":
|
|
51
|
-
return
|
|
55
|
+
return [
|
|
56
|
+
e ? "" : "bg-white dark:bg-black",
|
|
57
|
+
"shadow-md border-transparent"
|
|
58
|
+
];
|
|
52
59
|
default:
|
|
53
60
|
return "";
|
|
54
61
|
}
|
|
@@ -84,10 +91,10 @@ const Y = {
|
|
|
84
91
|
r.class,
|
|
85
92
|
r.wrapperClass
|
|
86
93
|
]), I = p(() => r.counter === !0 ? 25 : typeof r.counter == "number" || typeof r.counter == "string" ? r.counter : null), H = p(() => r.persistentCounter ? !0 : !!r.counter && v.value), K = p(() => typeof r.clearIcon == "string" ? r.clearIcon : "i-heroicons-x-mark-20-solid");
|
|
87
|
-
function
|
|
94
|
+
function m(e, t) {
|
|
88
95
|
V(`click:${t}`, e);
|
|
89
96
|
}
|
|
90
|
-
return
|
|
97
|
+
return R({
|
|
91
98
|
validate: M,
|
|
92
99
|
reset: T,
|
|
93
100
|
resetValidation: A,
|
|
@@ -103,24 +110,24 @@ const Y = {
|
|
|
103
110
|
var o;
|
|
104
111
|
return (o = u.value) == null ? void 0 : o.blur();
|
|
105
112
|
}, props: r })), () => [
|
|
106
|
-
e.label ? (s(), l("label", Y,
|
|
113
|
+
e.label ? (s(), l("label", Y, g(e.label), 1)) : d("", !0)
|
|
107
114
|
]),
|
|
108
115
|
a("div", Z, [
|
|
109
116
|
e.prependIcon || e.$slots.prepend ? (s(), l("div", x, [
|
|
110
117
|
i(e.$slots, "prepend", y(k(e.prependSlotBindings)), () => [
|
|
111
118
|
a("div", {
|
|
112
|
-
onClick: t[0] || (t[0] = (o) =>
|
|
119
|
+
onClick: t[0] || (t[0] = (o) => m(o, "prepend"))
|
|
113
120
|
}, [
|
|
114
|
-
(s(), h(
|
|
121
|
+
(s(), h(C(n($)(e.prependIcon))))
|
|
115
122
|
])
|
|
116
123
|
])
|
|
117
124
|
])) : d("", !0),
|
|
118
125
|
e.prependInnerIcon || e.$slots["prepend-inner"] ? (s(), l("div", _, [
|
|
119
126
|
i(e.$slots, "prepend-inner", {}, () => [
|
|
120
127
|
a("div", {
|
|
121
|
-
onClick: t[1] || (t[1] = (o) =>
|
|
128
|
+
onClick: t[1] || (t[1] = (o) => m(o, "prependInner"))
|
|
122
129
|
}, [
|
|
123
|
-
(s(), h(
|
|
130
|
+
(s(), h(C(n($)(e.prependInnerIcon))))
|
|
124
131
|
])
|
|
125
132
|
])
|
|
126
133
|
])) : d("", !0),
|
|
@@ -170,18 +177,18 @@ const Y = {
|
|
|
170
177
|
e.appendInnerIcon || e.$slots["append-inner"] ? (s(), l("div", re, [
|
|
171
178
|
i(e.$slots, "append-inner", {}, () => [
|
|
172
179
|
a("div", {
|
|
173
|
-
onClick: t[8] || (t[8] = (o) =>
|
|
180
|
+
onClick: t[8] || (t[8] = (o) => m(o, "appendInner"))
|
|
174
181
|
}, [
|
|
175
|
-
(s(), h(
|
|
182
|
+
(s(), h(C(n($)(e.appendInnerIcon))))
|
|
176
183
|
])
|
|
177
184
|
])
|
|
178
185
|
])) : d("", !0),
|
|
179
186
|
e.appendIcon || e.$slots.append ? (s(), l("div", oe, [
|
|
180
187
|
i(e.$slots, "append", y(k(e.appendSlotBindings)), () => [
|
|
181
188
|
a("div", {
|
|
182
|
-
onClick: t[9] || (t[9] = (o) =>
|
|
189
|
+
onClick: t[9] || (t[9] = (o) => m(o, "append"))
|
|
183
190
|
}, [
|
|
184
|
-
(s(), h(
|
|
191
|
+
(s(), h(C(n($)(e.appendIcon))))
|
|
185
192
|
])
|
|
186
193
|
])
|
|
187
194
|
])) : d("", !0),
|
|
@@ -207,12 +214,12 @@ const Y = {
|
|
|
207
214
|
key: j,
|
|
208
215
|
message: o
|
|
209
216
|
}, () => [
|
|
210
|
-
a("div", null,
|
|
217
|
+
a("div", null, g(o), 1)
|
|
211
218
|
])), 128)) : e.hint ? i(e.$slots, "hint", {
|
|
212
219
|
key: 1,
|
|
213
220
|
hint: e.hint
|
|
214
221
|
}, () => [
|
|
215
|
-
O(a("div", null,
|
|
222
|
+
O(a("div", null, g(e.hint), 513), [
|
|
216
223
|
[Q, e.persistentHint || n(v)]
|
|
217
224
|
])
|
|
218
225
|
]) : d("", !0)
|
|
@@ -224,8 +231,8 @@ const Y = {
|
|
|
224
231
|
max: I.value,
|
|
225
232
|
value: n(c).length
|
|
226
233
|
}, () => [
|
|
227
|
-
U(
|
|
228
|
-
I.value ? (s(), l("span", le, " / " +
|
|
234
|
+
U(g(n(c).length), 1),
|
|
235
|
+
I.value ? (s(), l("span", le, " / " + g(I.value), 1)) : d("", !0)
|
|
229
236
|
])
|
|
230
237
|
])) : d("", !0)
|
|
231
238
|
])
|
|
@@ -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
|
};
|