adverich-kun-ui 0.1.409 → 0.1.411
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,45 +1,53 @@
|
|
|
1
|
-
import { useAttrs as
|
|
2
|
-
import { kunTextareaProps as
|
|
3
|
-
import
|
|
4
|
-
import { renderIconSlot as
|
|
5
|
-
|
|
1
|
+
import { useAttrs as oe, ref as te, getCurrentInstance as ne, computed as a, createElementBlock as l, openBlock as t, mergeProps as M, renderSlot as d, createElementVNode as i, createCommentVNode as u, normalizeClass as b, toDisplayString as g, normalizeProps as z, guardReactiveProps as B, unref as n, createBlock as y, resolveDynamicComponent as m, Fragment as re, renderList as se, withDirectives as le, vShow as ae, createTextVNode as de } from "vue";
|
|
2
|
+
import { kunTextareaProps as ie } from "../composables/KunTextareaProps.js";
|
|
3
|
+
import ue from "../composables/useKunTextareaComposable.js";
|
|
4
|
+
import { renderIconSlot as h } from "../../../../utils/renderIcon.js";
|
|
5
|
+
import { debounce as pe } from "../../../../utils/utils.js";
|
|
6
|
+
const ce = { class: "relative" }, ve = {
|
|
6
7
|
key: 0,
|
|
7
8
|
class: "absolute left-2 top-2 flex items-center"
|
|
8
|
-
},
|
|
9
|
+
}, fe = {
|
|
9
10
|
key: 1,
|
|
10
11
|
class: "absolute left-2 top-2 ml-1"
|
|
11
|
-
},
|
|
12
|
+
}, be = ["value", "rows", "disabled", "readonly", "placeholder"], ge = {
|
|
12
13
|
key: 3,
|
|
13
14
|
class: "absolute right-2 top-2 mr-1"
|
|
14
|
-
},
|
|
15
|
+
}, ye = {
|
|
15
16
|
key: 4,
|
|
16
17
|
class: "absolute right-2 top-2 flex items-center"
|
|
17
|
-
},
|
|
18
|
+
}, me = {
|
|
18
19
|
key: 5,
|
|
19
20
|
class: "mt-1"
|
|
20
|
-
},
|
|
21
|
+
}, he = { class: "h-1 w-full bg-gray-200 rounded overflow-hidden" }, ke = {
|
|
21
22
|
key: 7,
|
|
22
23
|
class: "text-xs text-right mt-1 text-gray-400"
|
|
23
|
-
},
|
|
24
|
+
}, Ce = { key: 0 }, Re = {
|
|
24
25
|
__name: "KunTextarea",
|
|
25
|
-
props: { ...
|
|
26
|
+
props: { ...ie },
|
|
26
27
|
emits: ["update:modelValue", "click:clear", "click:control", "update:focused", "mousedown:control"],
|
|
27
|
-
setup(
|
|
28
|
-
const o =
|
|
29
|
-
isFocused:
|
|
30
|
-
internalValue:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
reset: L,
|
|
37
|
-
resetValidation: j,
|
|
28
|
+
setup(A, { expose: D, emit: F }) {
|
|
29
|
+
const o = A, k = F, G = oe(), p = te(null), R = `textarea-${ne().uid}`, {
|
|
30
|
+
isFocused: c,
|
|
31
|
+
internalValue: v,
|
|
32
|
+
updateModel: P,
|
|
33
|
+
handleClear: S,
|
|
34
|
+
validate: T,
|
|
35
|
+
reset: E,
|
|
36
|
+
resetValidation: N,
|
|
38
37
|
hasError: f,
|
|
39
38
|
displayedMessages: C,
|
|
40
|
-
adjustHeight:
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
adjustHeight: H
|
|
40
|
+
} = ue(o, k, p), L = (e) => {
|
|
41
|
+
v.value = e.target.value, j(e.target.value), o.autoGrow && H();
|
|
42
|
+
}, j = pe((e) => {
|
|
43
|
+
P(e);
|
|
44
|
+
}, 2e3), K = () => {
|
|
45
|
+
c.value = !0, k("update:focused", !0);
|
|
46
|
+
}, U = () => {
|
|
47
|
+
c.value = !1, k("update:focused", !1);
|
|
48
|
+
}, V = a(() => c.value || !!v.value || o.dirty), w = a(() => typeof v.value == "string" ? v.value.length : 0), I = a(() => o.counter === !0 ? 25 : o.counter || null), q = a(() => o.persistentCounter || o.counter && c.value), J = a(() => ["relative w-full flex flex-col", o.class, o.wrapperClass]), O = a(
|
|
49
|
+
() => o.persistentClear ? "opacity-100" : "hover:opacity-100 opacity-0 transition-opacity duration-200"
|
|
50
|
+
), Q = a(() => {
|
|
43
51
|
const e = o.bgColor ? "" : o.variant === "filled" ? "bg-gray-100 dark:bg-gray-900" : "";
|
|
44
52
|
switch (o.variant) {
|
|
45
53
|
case "filled":
|
|
@@ -53,10 +61,9 @@ const de = { class: "relative" }, ue = {
|
|
|
53
61
|
default:
|
|
54
62
|
return "";
|
|
55
63
|
}
|
|
56
|
-
}),
|
|
64
|
+
}), W = a(
|
|
57
65
|
() => o.density === "compact" ? "p-1" : o.density === "comfortable" ? "p-2" : "p-3"
|
|
58
|
-
)
|
|
59
|
-
a(() => [
|
|
66
|
+
), X = a(() => [
|
|
60
67
|
"w-full resize-none p-2 transition-colors duration-150 py-3",
|
|
61
68
|
o.inputClass,
|
|
62
69
|
{
|
|
@@ -74,161 +81,169 @@ const de = { class: "relative" }, ue = {
|
|
|
74
81
|
"resize-none": o.noResize || o.autoGrow,
|
|
75
82
|
resize: !o.noResize && !o.autoGrow
|
|
76
83
|
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
])
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
84
|
+
Q.value,
|
|
85
|
+
W.value
|
|
86
|
+
]), Y = {
|
|
87
|
+
label: o.label,
|
|
88
|
+
isFocused: c,
|
|
89
|
+
isActive: V,
|
|
90
|
+
controlRef: p,
|
|
91
|
+
focus: () => {
|
|
92
|
+
var e;
|
|
93
|
+
return (e = p.value) == null ? void 0 : e.focus();
|
|
94
|
+
},
|
|
95
|
+
blur: () => {
|
|
96
|
+
var e;
|
|
97
|
+
return (e = p.value) == null ? void 0 : e.blur();
|
|
98
|
+
},
|
|
99
|
+
props: o
|
|
100
|
+
}, $ = {
|
|
101
|
+
isActive: !!v.value,
|
|
102
|
+
isFocused: c,
|
|
103
|
+
controlRef: p,
|
|
104
|
+
focus: () => {
|
|
105
|
+
var e;
|
|
106
|
+
return (e = p.value) == null ? void 0 : e.focus();
|
|
107
|
+
},
|
|
108
|
+
blur: () => {
|
|
109
|
+
var e;
|
|
110
|
+
return (e = p.value) == null ? void 0 : e.blur();
|
|
111
|
+
},
|
|
112
|
+
props: o
|
|
113
|
+
}, Z = $, x = $, _ = a(() => {
|
|
114
|
+
const { class: e, ...r } = G;
|
|
115
|
+
return r;
|
|
95
116
|
});
|
|
96
|
-
return
|
|
97
|
-
validate:
|
|
98
|
-
reset:
|
|
99
|
-
resetValidation:
|
|
117
|
+
return D({
|
|
118
|
+
validate: T,
|
|
119
|
+
reset: E,
|
|
120
|
+
resetValidation: N,
|
|
100
121
|
errorMessages: C,
|
|
101
122
|
isValid: a(() => !f.value),
|
|
102
|
-
rootRef: V,
|
|
103
123
|
focus: () => {
|
|
104
124
|
var e;
|
|
105
125
|
return (e = p.value) == null ? void 0 : e.focus();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
ref:
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
e.label ? (
|
|
126
|
+
},
|
|
127
|
+
rootRef: p
|
|
128
|
+
}), (e, r) => (t(), l("div", M({
|
|
129
|
+
class: J.value,
|
|
130
|
+
ref: "rootRef"
|
|
131
|
+
}, _.value), [
|
|
132
|
+
d(e.$slots, "label", M({ for: R }, Y), () => [
|
|
133
|
+
e.label ? (t(), l("label", {
|
|
114
134
|
key: 0,
|
|
115
|
-
|
|
116
|
-
|
|
135
|
+
for: R,
|
|
136
|
+
class: b(["absolute left-2 transition-all duration-200 ease-in-out pointer-events-none select-none z-10", V.value || e.placeholder ? "-top-2.25 text-xs opacity-80" : "top-3 text-sm opacity-80"])
|
|
137
|
+
}, g(e.label), 3)) : u("", !0)
|
|
117
138
|
]),
|
|
118
|
-
|
|
119
|
-
e.prependIcon || e.$slots.prepend ? (
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
onClick:
|
|
139
|
+
i("div", ce, [
|
|
140
|
+
e.prependIcon || e.$slots.prepend ? (t(), l("div", ve, [
|
|
141
|
+
d(e.$slots, "prepend", z(B(n(Z))), () => [
|
|
142
|
+
i("div", {
|
|
143
|
+
onClick: r[0] || (r[0] = (s) => e.handleIconClick(s, "prepend"))
|
|
123
144
|
}, [
|
|
124
|
-
(
|
|
145
|
+
(t(), y(m(n(h)(e.prependIcon))))
|
|
125
146
|
])
|
|
126
147
|
])
|
|
127
148
|
])) : u("", !0),
|
|
128
|
-
e.prependInnerIcon || e.$slots["prepend-inner"] ? (
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
onClick:
|
|
149
|
+
e.prependInnerIcon || e.$slots["prepend-inner"] ? (t(), l("div", fe, [
|
|
150
|
+
d(e.$slots, "prepend-inner", {}, () => [
|
|
151
|
+
i("div", {
|
|
152
|
+
onClick: r[1] || (r[1] = (s) => e.handleIconClick(s, "prependInner"))
|
|
132
153
|
}, [
|
|
133
|
-
(
|
|
154
|
+
(t(), y(m(n(h)(e.prependInnerIcon))))
|
|
134
155
|
])
|
|
135
156
|
])
|
|
136
157
|
])) : u("", !0),
|
|
137
|
-
|
|
158
|
+
i("textarea", {
|
|
138
159
|
ref_key: "textareaRef",
|
|
139
160
|
ref: p,
|
|
140
|
-
value:
|
|
141
|
-
rows: e.rows,
|
|
161
|
+
value: n(v),
|
|
162
|
+
rows: e.autoGrow ? void 0 : e.rows,
|
|
142
163
|
disabled: e.disabled,
|
|
143
164
|
readonly: e.readonly,
|
|
144
165
|
placeholder: e.placeholder,
|
|
145
|
-
onInput:
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
onClick: t[5] || (t[5] = (n) => e.$emit("click:control", n)),
|
|
155
|
-
onMousedown: t[6] || (t[6] = (n) => e.$emit("mousedown:control", n)),
|
|
156
|
-
onKeydown: t[7] || (t[7] = oe((...n) => r(B) && r(B)(...n), ["enter"])),
|
|
157
|
-
class: g([[A.value, D.value, e.inputClasses], "py-3"])
|
|
158
|
-
}, null, 42, ve),
|
|
159
|
-
e.clearable && r(c) ? (s(), l("div", {
|
|
166
|
+
onInput: L,
|
|
167
|
+
onFocus: K,
|
|
168
|
+
onBlur: U,
|
|
169
|
+
onClick: r[2] || (r[2] = (s) => e.$emit("click:control", s)),
|
|
170
|
+
onMousedown: r[3] || (r[3] = (s) => e.$emit("mousedown:control", s)),
|
|
171
|
+
class: b([X.value]),
|
|
172
|
+
style: { width: "100%", "box-sizing": "border-box", "overflow-y": "hidden" }
|
|
173
|
+
}, null, 42, be),
|
|
174
|
+
e.clearable && n(v) ? (t(), l("div", {
|
|
160
175
|
key: 2,
|
|
161
|
-
class:
|
|
176
|
+
class: b(["absolute right-2 top-2", O.value])
|
|
162
177
|
}, [
|
|
163
|
-
|
|
164
|
-
|
|
178
|
+
d(e.$slots, "clear", z(B($)), () => [
|
|
179
|
+
i("button", {
|
|
165
180
|
type: "button",
|
|
166
|
-
onClick:
|
|
181
|
+
onClick: r[4] || (r[4] = (...s) => n(S) && n(S)(...s)),
|
|
167
182
|
class: "text-gray-500 hover:text-gray-700"
|
|
168
183
|
}, [
|
|
169
|
-
(
|
|
184
|
+
(t(), y(m(n(h)(e.clearIcon))))
|
|
170
185
|
])
|
|
171
186
|
])
|
|
172
187
|
], 2)) : u("", !0),
|
|
173
|
-
e.appendInnerIcon || e.$slots["append-inner"] ? (
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
onClick:
|
|
188
|
+
e.appendInnerIcon || e.$slots["append-inner"] ? (t(), l("div", ge, [
|
|
189
|
+
d(e.$slots, "append-inner", {}, () => [
|
|
190
|
+
i("div", {
|
|
191
|
+
onClick: r[5] || (r[5] = (s) => e.handleIconClick(s, "appendInner"))
|
|
177
192
|
}, [
|
|
178
|
-
(
|
|
193
|
+
(t(), y(m(n(h)(e.appendInnerIcon))))
|
|
179
194
|
])
|
|
180
195
|
])
|
|
181
196
|
])) : u("", !0),
|
|
182
|
-
e.appendIcon || e.$slots.append ? (
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
onClick:
|
|
197
|
+
e.appendIcon || e.$slots.append ? (t(), l("div", ye, [
|
|
198
|
+
d(e.$slots, "append", z(B(n(x))), () => [
|
|
199
|
+
i("div", {
|
|
200
|
+
onClick: r[6] || (r[6] = (s) => e.handleIconClick(s, "append"))
|
|
186
201
|
}, [
|
|
187
|
-
(
|
|
202
|
+
(t(), y(m(n(h)(e.appendIcon))))
|
|
188
203
|
])
|
|
189
204
|
])
|
|
190
205
|
])) : u("", !0),
|
|
191
|
-
e.loading ? (
|
|
192
|
-
|
|
206
|
+
e.loading ? (t(), l("div", me, [
|
|
207
|
+
d(e.$slots, "loader", {
|
|
193
208
|
color: e.loadingColor,
|
|
194
209
|
isActive: !0
|
|
195
210
|
}, () => [
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
class:
|
|
211
|
+
i("div", he, [
|
|
212
|
+
i("div", {
|
|
213
|
+
class: b(["h-full transition-all duration-300", [e.loadingColor]]),
|
|
199
214
|
style: { width: "100%" }
|
|
200
215
|
}, null, 2)
|
|
201
216
|
])
|
|
202
217
|
])
|
|
203
218
|
])) : u("", !0),
|
|
204
|
-
!e.hideDetails || e.hideDetails === "auto" && (
|
|
219
|
+
!e.hideDetails || e.hideDetails === "auto" && (n(C).length || e.hint) ? (t(), l("div", {
|
|
205
220
|
key: 6,
|
|
206
|
-
class:
|
|
221
|
+
class: b(["text-xs mt-1 space-y-1", { "text-red-500": n(f), "text-gray-500": !n(f) }])
|
|
207
222
|
}, [
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
key:
|
|
211
|
-
message:
|
|
223
|
+
d(e.$slots, "details", {}, () => [
|
|
224
|
+
n(f) ? (t(!0), l(re, { key: 0 }, se(n(C), (s, ee) => d(e.$slots, "message", {
|
|
225
|
+
key: ee,
|
|
226
|
+
message: s
|
|
212
227
|
}, () => [
|
|
213
|
-
|
|
214
|
-
])), 128)) : e.hint ?
|
|
228
|
+
i("div", null, g(s), 1)
|
|
229
|
+
])), 128)) : e.hint ? d(e.$slots, "hint", {
|
|
215
230
|
key: 1,
|
|
216
231
|
hint: e.hint
|
|
217
232
|
}, () => [
|
|
218
|
-
|
|
219
|
-
[
|
|
233
|
+
le(i("div", null, g(e.hint), 513), [
|
|
234
|
+
[ae, e.persistentHint || n(c)]
|
|
220
235
|
])
|
|
221
236
|
]) : u("", !0)
|
|
222
237
|
])
|
|
223
238
|
], 2)) : u("", !0),
|
|
224
|
-
q.value ? (
|
|
225
|
-
|
|
226
|
-
counter:
|
|
227
|
-
max:
|
|
228
|
-
value:
|
|
239
|
+
q.value ? (t(), l("div", ke, [
|
|
240
|
+
d(e.$slots, "counter", {
|
|
241
|
+
counter: w.value,
|
|
242
|
+
max: I.value,
|
|
243
|
+
value: w.value
|
|
229
244
|
}, () => [
|
|
230
|
-
|
|
231
|
-
|
|
245
|
+
de(g(w.value), 1),
|
|
246
|
+
I.value ? (t(), l("span", Ce, " / " + g(I.value), 1)) : u("", !0)
|
|
232
247
|
])
|
|
233
248
|
])) : u("", !0)
|
|
234
249
|
])
|
|
@@ -236,5 +251,5 @@ const de = { class: "relative" }, ue = {
|
|
|
236
251
|
}
|
|
237
252
|
};
|
|
238
253
|
export {
|
|
239
|
-
|
|
254
|
+
Re as default
|
|
240
255
|
};
|
|
@@ -1,47 +1,37 @@
|
|
|
1
1
|
const e = {
|
|
2
|
-
modelValue: [String, Number],
|
|
3
|
-
// Etiqueta visible del textarea
|
|
2
|
+
modelValue: [String, Number, Object],
|
|
4
3
|
label: String,
|
|
5
|
-
// Texto de ayuda o descripción secundaria
|
|
6
4
|
hint: String,
|
|
7
|
-
// Clases de estilo personalizadas
|
|
8
5
|
class: String,
|
|
9
6
|
bgColor: String,
|
|
10
7
|
textColor: String,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
type: String,
|
|
14
|
-
default: "left"
|
|
15
|
-
},
|
|
16
|
-
// Define si se debe mostrar el loader
|
|
8
|
+
textAlign: { type: String, default: "left" },
|
|
9
|
+
formatModel: { type: String, default: "auto" },
|
|
17
10
|
loading: Boolean,
|
|
18
|
-
|
|
11
|
+
prependIcon: [String, Object, Function],
|
|
12
|
+
appendIcon: [String, Object, Function],
|
|
19
13
|
prependInnerIcon: [String, Object, Function],
|
|
20
|
-
// Slot para ícono al final
|
|
21
14
|
appendInnerIcon: [String, Object, Function],
|
|
22
|
-
|
|
15
|
+
clearable: Boolean,
|
|
16
|
+
persistentClear: Boolean,
|
|
23
17
|
loader: Boolean,
|
|
24
|
-
hideDetails: Boolean,
|
|
25
|
-
// Deshabilita la entrada
|
|
18
|
+
hideDetails: [Boolean, String],
|
|
26
19
|
disabled: Boolean,
|
|
27
20
|
readonly: Boolean,
|
|
28
|
-
// Valida errores sólo al blur (desenfocar)
|
|
29
21
|
blurValidation: Boolean,
|
|
30
|
-
// Validaciones
|
|
31
22
|
rules: Array,
|
|
32
23
|
errorMessages: [String, Array],
|
|
33
|
-
maxErrors:
|
|
34
|
-
|
|
24
|
+
maxErrors: {
|
|
25
|
+
type: Number,
|
|
26
|
+
default: 3
|
|
27
|
+
},
|
|
35
28
|
error: Boolean,
|
|
36
|
-
// Contador de caracteres
|
|
37
29
|
counter: Boolean,
|
|
30
|
+
persistentCounter: Boolean,
|
|
38
31
|
maxLength: [Number, String],
|
|
39
|
-
// Crecimiento dinámico
|
|
40
32
|
autoGrow: Boolean,
|
|
41
33
|
noResize: Boolean,
|
|
42
34
|
maxRows: [Number, String],
|
|
43
|
-
// aplica si autoGrow está activo
|
|
44
|
-
// Atributos HTML nativos
|
|
45
35
|
placeholder: String,
|
|
46
36
|
name: String,
|
|
47
37
|
id: String,
|
|
@@ -49,7 +39,23 @@ const e = {
|
|
|
49
39
|
rows: {
|
|
50
40
|
type: [Number, String],
|
|
51
41
|
default: 5
|
|
52
|
-
}
|
|
42
|
+
},
|
|
43
|
+
dirty: Boolean,
|
|
44
|
+
variant: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: "outlined"
|
|
47
|
+
},
|
|
48
|
+
density: {
|
|
49
|
+
type: String,
|
|
50
|
+
default: "default"
|
|
51
|
+
},
|
|
52
|
+
inputClass: [String, Array],
|
|
53
|
+
wrapperClass: [String, Array],
|
|
54
|
+
tile: Boolean,
|
|
55
|
+
rounded: [String, Number],
|
|
56
|
+
flat: Boolean,
|
|
57
|
+
color: String,
|
|
58
|
+
loadingColor: String
|
|
53
59
|
};
|
|
54
60
|
export {
|
|
55
61
|
e as kunTextareaProps
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
function
|
|
3
|
-
const
|
|
4
|
-
function
|
|
5
|
-
if (
|
|
1
|
+
import { ref as i, computed as h, watch as E, nextTick as m, onMounted as A, onBeforeUnmount as F } from "vue";
|
|
2
|
+
function $(t, H, l) {
|
|
3
|
+
const s = i(""), c = i(t.modelValue), J = i(!1), a = i([]), f = h(() => t.formatModel === "json" || t.formatModel === "auto" && typeof t.modelValue == "object");
|
|
4
|
+
function v(e) {
|
|
5
|
+
if (f.value && e != null)
|
|
6
6
|
try {
|
|
7
7
|
return JSON.stringify(e, null, 2);
|
|
8
8
|
} catch {
|
|
@@ -10,8 +10,8 @@ function L(t, v) {
|
|
|
10
10
|
}
|
|
11
11
|
return e ?? "";
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
if (
|
|
13
|
+
function y(e) {
|
|
14
|
+
if (f.value && typeof e == "string")
|
|
15
15
|
try {
|
|
16
16
|
return JSON.parse(e);
|
|
17
17
|
} catch {
|
|
@@ -19,72 +19,74 @@ function L(t, v) {
|
|
|
19
19
|
}
|
|
20
20
|
return e;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
const
|
|
24
|
-
|
|
22
|
+
function x(e) {
|
|
23
|
+
const u = y(e);
|
|
24
|
+
c.value = u, H("update:modelValue", u);
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
E(
|
|
27
|
+
() => t.modelValue,
|
|
28
|
+
(e) => {
|
|
29
|
+
const u = JSON.stringify(e), n = JSON.stringify(c.value);
|
|
30
|
+
u !== n && (c.value = e, s.value = v(e), t.autoGrow && m(() => d()));
|
|
31
|
+
},
|
|
32
|
+
{ immediate: !0 }
|
|
33
|
+
);
|
|
34
|
+
const d = () => {
|
|
35
|
+
if (!l.value) return;
|
|
36
|
+
l.value.style.height = "auto", l.value.style.overflowY = "hidden";
|
|
37
|
+
const e = l.value.scrollHeight, u = parseFloat(getComputedStyle(l.value).lineHeight) || 24, n = Number(t.maxRows || 0);
|
|
38
|
+
if (t.maxRows && n > 0) {
|
|
39
|
+
const o = n * u;
|
|
40
|
+
l.value.style.height = Math.min(e, o) + "px";
|
|
37
41
|
} else
|
|
38
|
-
|
|
42
|
+
l.value.style.height = e + "px";
|
|
39
43
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
function N(e) {
|
|
45
|
+
var S;
|
|
46
|
+
if (!f.value) return;
|
|
47
|
+
const u = l.value;
|
|
48
|
+
if (!u) return;
|
|
49
|
+
const n = u.selectionStart, o = s.value, r = " ", g = o.slice(0, n), j = o.slice(n), C = g.lastIndexOf(`
|
|
50
|
+
`) + 1, w = `
|
|
51
|
+
${((S = g.slice(C).match(/^\s*/)) == null ? void 0 : S[0]) ?? ""}${r}`;
|
|
52
|
+
s.value = g + w + j, m(() => {
|
|
53
|
+
const V = n + w.length;
|
|
54
|
+
u.setSelectionRange(V, V);
|
|
55
|
+
}), e.preventDefault();
|
|
56
|
+
}
|
|
57
|
+
A(() => {
|
|
58
|
+
s.value = v(t.modelValue), m(() => {
|
|
59
|
+
t.autoGrow && d();
|
|
43
60
|
});
|
|
44
61
|
}), F(() => {
|
|
45
|
-
x.value && cancelAnimationFrame(x.value);
|
|
46
62
|
});
|
|
47
|
-
const M =
|
|
63
|
+
const M = h(() => {
|
|
48
64
|
var e;
|
|
49
|
-
return !!(
|
|
50
|
-
}),
|
|
51
|
-
function
|
|
52
|
-
const e = t.rules || [],
|
|
53
|
-
for (const
|
|
54
|
-
const
|
|
55
|
-
Array.isArray(
|
|
65
|
+
return !!(a.value.length || (e = t.errorMessages) != null && e.length);
|
|
66
|
+
}), O = h(() => M.value ? [...t.errorMessages || [], ...a.value].slice(0, t.maxErrors) : []);
|
|
67
|
+
function I() {
|
|
68
|
+
const e = t.rules || [], u = t.required && !s.value ? null : y(s.value), n = [];
|
|
69
|
+
for (const o of e) {
|
|
70
|
+
const r = typeof o == "function" ? o(u) : o;
|
|
71
|
+
Array.isArray(r) ? n.push(...r) : typeof r == "string" ? n.push(r) : r === !1 && n.push("Campo inválido");
|
|
56
72
|
}
|
|
57
|
-
return
|
|
58
|
-
}
|
|
59
|
-
function E() {
|
|
60
|
-
s.value = [];
|
|
73
|
+
return a.value = n, n.length === 0;
|
|
61
74
|
}
|
|
62
|
-
function
|
|
63
|
-
|
|
64
|
-
if (!c.value || e.key !== "Enter") return;
|
|
65
|
-
const n = m.value;
|
|
66
|
-
if (!n) return;
|
|
67
|
-
const a = n.selectionStart, u = r.value, l = " ", d = u.slice(0, a), b = u.slice(a), j = d.lastIndexOf(`
|
|
68
|
-
`) + 1, w = `
|
|
69
|
-
${((S = d.slice(j).match(/^\s*/)) == null ? void 0 : S[0]) ?? ""}${l}`;
|
|
70
|
-
r.value = d + w + b, h(() => {
|
|
71
|
-
const V = a + w.length;
|
|
72
|
-
n.setSelectionRange(V, V);
|
|
73
|
-
}), e.preventDefault();
|
|
75
|
+
function b() {
|
|
76
|
+
a.value = [];
|
|
74
77
|
}
|
|
75
78
|
return {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
isFocused: H,
|
|
79
|
+
internalValue: s,
|
|
80
|
+
isFocused: J,
|
|
79
81
|
hasError: M,
|
|
80
|
-
displayedMessages:
|
|
81
|
-
validate:
|
|
82
|
-
resetValidation:
|
|
83
|
-
updateModel:
|
|
84
|
-
adjustHeight:
|
|
85
|
-
handleJsonEnter:
|
|
82
|
+
displayedMessages: O,
|
|
83
|
+
validate: I,
|
|
84
|
+
resetValidation: b,
|
|
85
|
+
updateModel: x,
|
|
86
|
+
adjustHeight: d,
|
|
87
|
+
handleJsonEnter: N
|
|
86
88
|
};
|
|
87
89
|
}
|
|
88
90
|
export {
|
|
89
|
-
|
|
91
|
+
$ as default
|
|
90
92
|
};
|