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