adverich-kun-ui 0.1.407 → 0.1.408
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,4 +1,4 @@
|
|
|
1
|
-
import { useAttrs as
|
|
1
|
+
import { useAttrs as re, ref as se, getCurrentInstance as le, computed as a, createElementBlock as l, openBlock as r, mergeProps as E, renderSlot as i, createElementVNode as d, createCommentVNode as u, normalizeClass as b, toDisplayString as y, normalizeProps as S, guardReactiveProps as V, unref as s, createBlock as m, resolveDynamicComponent as h, withKeys as ae, Fragment as ie, renderList as de, withDirectives as ue, vShow as pe, createTextVNode as ce, nextTick as ve } from "vue";
|
|
2
2
|
import { kunTextareaProps as fe } from "../composables/KunTextareaProps.js";
|
|
3
3
|
import ge from "../composables/useKunTextareaComposable.js";
|
|
4
4
|
import { renderIconSlot as k } from "../../../../utils/renderIcon.js";
|
|
@@ -24,8 +24,8 @@ const be = { class: "relative" }, ye = {
|
|
|
24
24
|
__name: "KunTextarea",
|
|
25
25
|
props: { ...fe },
|
|
26
26
|
emits: ["update:modelValue", "click:clear", "click:control", "update:focused", "mousedown:control"],
|
|
27
|
-
setup(F, { expose:
|
|
28
|
-
const o = F, C =
|
|
27
|
+
setup(F, { expose: G, emit: P }) {
|
|
28
|
+
const o = F, C = P, K = re(), p = se(null), N = `textarea-${le().uid}`, {
|
|
29
29
|
isFocused: c,
|
|
30
30
|
internalValue: v,
|
|
31
31
|
rootRef: B,
|
|
@@ -43,9 +43,9 @@ const be = { class: "relative" }, ye = {
|
|
|
43
43
|
var T;
|
|
44
44
|
if (!o.jsonMode) return;
|
|
45
45
|
e.preventDefault();
|
|
46
|
-
const
|
|
47
|
-
` + g +
|
|
48
|
-
|
|
46
|
+
const n = e.target, t = n.selectionStart, g = ((T = n.value.substring(0, t).match(/(^|\n)(\s*)[^\n]*$/)) == null ? void 0 : T[2]) ?? "", M = n.value.slice(0, t) + `
|
|
47
|
+
` + g + n.value.slice(t);
|
|
48
|
+
n.value = M, z(M), ve(() => n.setSelectionRange(t + 1 + g.length, t + 1 + g.length));
|
|
49
49
|
}, Q = () => {
|
|
50
50
|
c.value = !0, C("update:focused", !0);
|
|
51
51
|
}, U = () => {
|
|
@@ -98,11 +98,11 @@ const be = { class: "relative" }, ye = {
|
|
|
98
98
|
}, blur: () => {
|
|
99
99
|
var e;
|
|
100
100
|
return (e = p.value) == null ? void 0 : e.blur();
|
|
101
|
-
}, props: o }, oe = R,
|
|
102
|
-
const { class: e, ...
|
|
103
|
-
return
|
|
101
|
+
}, props: o }, oe = R, ne = R, te = a(() => {
|
|
102
|
+
const { class: e, ...n } = K;
|
|
103
|
+
return n;
|
|
104
104
|
});
|
|
105
|
-
return
|
|
105
|
+
return G({
|
|
106
106
|
validate: j,
|
|
107
107
|
reset: H,
|
|
108
108
|
resetValidation: L,
|
|
@@ -113,41 +113,41 @@ const be = { class: "relative" }, ye = {
|
|
|
113
113
|
var e;
|
|
114
114
|
return (e = p.value) == null ? void 0 : e.focus();
|
|
115
115
|
}
|
|
116
|
-
}), (e,
|
|
116
|
+
}), (e, n) => (r(), l("div", E({
|
|
117
117
|
class: X.value,
|
|
118
118
|
ref_key: "rootRef",
|
|
119
119
|
ref: B
|
|
120
|
-
},
|
|
120
|
+
}, te.value), [
|
|
121
121
|
i(e.$slots, "label", E({ for: N }, ee), () => [
|
|
122
|
-
e.label ? (
|
|
122
|
+
e.label ? (r(), l("label", {
|
|
123
123
|
key: 0,
|
|
124
124
|
class: b(["absolute left-2 transition-all duration-200 ease-in-out pointer-events-none select-none z-10", A.value || e.placeholder ? "-top-2.25 text-xs opacity-80" : "top-3 text-sm opacity-80"])
|
|
125
125
|
}, y(e.label), 3)) : u("", !0)
|
|
126
126
|
]),
|
|
127
127
|
d("div", be, [
|
|
128
|
-
e.prependIcon || e.$slots.prepend ? (
|
|
129
|
-
i(e.$slots, "prepend", S(V(
|
|
128
|
+
e.prependIcon || e.$slots.prepend ? (r(), l("div", ye, [
|
|
129
|
+
i(e.$slots, "prepend", S(V(s(oe))), () => [
|
|
130
130
|
d("div", {
|
|
131
|
-
onClick:
|
|
131
|
+
onClick: n[0] || (n[0] = (t) => e.handleIconClick(t, "prepend"))
|
|
132
132
|
}, [
|
|
133
|
-
(
|
|
133
|
+
(r(), m(h(s(k)(e.prependIcon))))
|
|
134
134
|
])
|
|
135
135
|
])
|
|
136
136
|
])) : u("", !0),
|
|
137
|
-
e.prependInnerIcon || e.$slots["prepend-inner"] ? (
|
|
137
|
+
e.prependInnerIcon || e.$slots["prepend-inner"] ? (r(), l("div", me, [
|
|
138
138
|
i(e.$slots, "prepend-inner", {}, () => [
|
|
139
139
|
d("div", {
|
|
140
|
-
onClick:
|
|
140
|
+
onClick: n[1] || (n[1] = (t) => e.handleIconClick(t, "prependInner"))
|
|
141
141
|
}, [
|
|
142
|
-
(
|
|
142
|
+
(r(), m(h(s(k)(e.prependInnerIcon))))
|
|
143
143
|
])
|
|
144
144
|
])
|
|
145
145
|
])) : u("", !0),
|
|
146
146
|
d("textarea", {
|
|
147
147
|
ref_key: "textareaRef",
|
|
148
148
|
ref: p,
|
|
149
|
-
value:
|
|
150
|
-
rows: e.rows,
|
|
149
|
+
value: s(v),
|
|
150
|
+
rows: e.autoGrow ? void 0 : e.rows,
|
|
151
151
|
disabled: e.disabled,
|
|
152
152
|
readonly: e.readonly,
|
|
153
153
|
placeholder: e.placeholder,
|
|
@@ -157,42 +157,42 @@ const be = { class: "relative" }, ye = {
|
|
|
157
157
|
onKeydown: ae(O, ["enter"]),
|
|
158
158
|
onFocus: Q,
|
|
159
159
|
onBlur: U,
|
|
160
|
-
onClick:
|
|
161
|
-
onMousedown:
|
|
160
|
+
onClick: n[2] || (n[2] = (t) => e.$emit("click:control", t)),
|
|
161
|
+
onMousedown: n[3] || (n[3] = (t) => e.$emit("mousedown:control", t))
|
|
162
162
|
}, null, 42, he),
|
|
163
|
-
e.clearable &&
|
|
163
|
+
e.clearable && s(v) ? (r(), l("div", {
|
|
164
164
|
key: 2,
|
|
165
165
|
class: b(["absolute right-2 top-2", Y.value])
|
|
166
166
|
}, [
|
|
167
167
|
i(e.$slots, "clear", S(V(R)), () => [
|
|
168
168
|
d("button", {
|
|
169
169
|
type: "button",
|
|
170
|
-
onClick:
|
|
170
|
+
onClick: n[4] || (n[4] = (...t) => s(D) && s(D)(...t)),
|
|
171
171
|
class: "text-gray-500 hover:text-gray-700"
|
|
172
172
|
}, [
|
|
173
|
-
(
|
|
173
|
+
(r(), m(h(s(k)(e.clearIcon))))
|
|
174
174
|
])
|
|
175
175
|
])
|
|
176
176
|
], 2)) : u("", !0),
|
|
177
|
-
e.appendInnerIcon || e.$slots["append-inner"] ? (
|
|
177
|
+
e.appendInnerIcon || e.$slots["append-inner"] ? (r(), l("div", ke, [
|
|
178
178
|
i(e.$slots, "append-inner", {}, () => [
|
|
179
179
|
d("div", {
|
|
180
|
-
onClick:
|
|
180
|
+
onClick: n[5] || (n[5] = (t) => e.handleIconClick(t, "appendInner"))
|
|
181
181
|
}, [
|
|
182
|
-
(
|
|
182
|
+
(r(), m(h(s(k)(e.appendInnerIcon))))
|
|
183
183
|
])
|
|
184
184
|
])
|
|
185
185
|
])) : u("", !0),
|
|
186
|
-
e.appendIcon || e.$slots.append ? (
|
|
187
|
-
i(e.$slots, "append", S(V(
|
|
186
|
+
e.appendIcon || e.$slots.append ? (r(), l("div", Ce, [
|
|
187
|
+
i(e.$slots, "append", S(V(s(ne))), () => [
|
|
188
188
|
d("div", {
|
|
189
|
-
onClick:
|
|
189
|
+
onClick: n[6] || (n[6] = (t) => e.handleIconClick(t, "append"))
|
|
190
190
|
}, [
|
|
191
|
-
(
|
|
191
|
+
(r(), m(h(s(k)(e.appendIcon))))
|
|
192
192
|
])
|
|
193
193
|
])
|
|
194
194
|
])) : u("", !0),
|
|
195
|
-
e.loading ? (
|
|
195
|
+
e.loading ? (r(), l("div", we, [
|
|
196
196
|
i(e.$slots, "loader", {
|
|
197
197
|
color: e.loadingColor,
|
|
198
198
|
isActive: !0
|
|
@@ -205,34 +205,34 @@ const be = { class: "relative" }, ye = {
|
|
|
205
205
|
])
|
|
206
206
|
])
|
|
207
207
|
])) : u("", !0),
|
|
208
|
-
!e.hideDetails || e.hideDetails === "auto" && (
|
|
208
|
+
!e.hideDetails || e.hideDetails === "auto" && (s(w).length || e.hint) ? (r(), l("div", {
|
|
209
209
|
key: 6,
|
|
210
|
-
class: b(["text-xs mt-1 space-y-1", { "text-red-500":
|
|
210
|
+
class: b(["text-xs mt-1 space-y-1", { "text-red-500": s(f), "text-gray-500": !s(f) }])
|
|
211
211
|
}, [
|
|
212
212
|
i(e.$slots, "details", {}, () => [
|
|
213
|
-
|
|
213
|
+
s(f) ? (r(!0), l(ie, { key: 0 }, de(s(w), (t, g) => i(e.$slots, "message", {
|
|
214
214
|
key: g,
|
|
215
|
-
message:
|
|
215
|
+
message: t
|
|
216
216
|
}, () => [
|
|
217
|
-
d("div", null, y(
|
|
217
|
+
d("div", null, y(t), 1)
|
|
218
218
|
])), 128)) : e.hint ? i(e.$slots, "hint", {
|
|
219
219
|
key: 1,
|
|
220
220
|
hint: e.hint
|
|
221
221
|
}, () => [
|
|
222
222
|
ue(d("div", null, y(e.hint), 513), [
|
|
223
|
-
[pe, e.persistentHint ||
|
|
223
|
+
[pe, e.persistentHint || s(c)]
|
|
224
224
|
])
|
|
225
225
|
]) : u("", !0)
|
|
226
226
|
])
|
|
227
227
|
], 2)) : u("", !0),
|
|
228
|
-
W.value ? (
|
|
228
|
+
W.value ? (r(), l("div", $e, [
|
|
229
229
|
i(e.$slots, "counter", {
|
|
230
230
|
counter: I.value,
|
|
231
231
|
max: $.value,
|
|
232
232
|
value: I.value
|
|
233
233
|
}, () => [
|
|
234
234
|
ce(y(I.value), 1),
|
|
235
|
-
$.value ? (
|
|
235
|
+
$.value ? (r(), l("span", Re, " / " + y($.value), 1)) : u("", !0)
|
|
236
236
|
])
|
|
237
237
|
])) : u("", !0)
|
|
238
238
|
])
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ref as l, computed as
|
|
2
|
-
function
|
|
3
|
-
const
|
|
4
|
-
function
|
|
5
|
-
if (
|
|
1
|
+
import { ref as l, computed as m, watch as R, nextTick as i, onMounted as T, onBeforeUnmount as $ } from "vue";
|
|
2
|
+
function F(t, v) {
|
|
3
|
+
const c = l(null), o = l(""), f = l(t.modelValue), H = l(!1), s = l([]), y = l(null), d = m(() => t.formatModel === "json" || t.formatModel === "auto" && typeof t.modelValue == "object");
|
|
4
|
+
function M(e) {
|
|
5
|
+
if (d.value && e != null)
|
|
6
6
|
try {
|
|
7
7
|
return JSON.stringify(e, null, 2);
|
|
8
8
|
} catch {
|
|
@@ -10,8 +10,8 @@ function k(t, M) {
|
|
|
10
10
|
}
|
|
11
11
|
return e ?? "";
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
if (
|
|
13
|
+
function S(e) {
|
|
14
|
+
if (d.value && typeof e == "string")
|
|
15
15
|
try {
|
|
16
16
|
return JSON.parse(e);
|
|
17
17
|
} catch {
|
|
@@ -19,72 +19,72 @@ function k(t, M) {
|
|
|
19
19
|
}
|
|
20
20
|
return e;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
const n =
|
|
24
|
-
|
|
22
|
+
function O(e) {
|
|
23
|
+
const n = S(e);
|
|
24
|
+
f.value = n, v("update:modelValue", n), v("change", n);
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
const n = JSON.stringify(e), u = JSON.stringify(
|
|
28
|
-
n !== u && (
|
|
26
|
+
R(() => t.modelValue, (e) => {
|
|
27
|
+
const n = JSON.stringify(e), u = JSON.stringify(f.value);
|
|
28
|
+
n !== u && (f.value = e, o.value = M(e), t.autoGrow && i(g));
|
|
29
29
|
});
|
|
30
|
-
function
|
|
31
|
-
const e =
|
|
32
|
-
!e || !t.autoGrow ||
|
|
30
|
+
function g() {
|
|
31
|
+
const e = c.value;
|
|
32
|
+
!e || !t.autoGrow || i(() => {
|
|
33
33
|
e.style.height = "auto";
|
|
34
|
-
const n =
|
|
35
|
-
e.style.height = `${Math.
|
|
36
|
-
const
|
|
37
|
-
e.setSelectionRange(
|
|
34
|
+
const n = t.maxHeight || 9999, u = e.scrollHeight;
|
|
35
|
+
e.style.height = `${Math.min(u, n)}px`;
|
|
36
|
+
const r = e.selectionStart;
|
|
37
|
+
e.setSelectionRange(r, r);
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
t.autoGrow &&
|
|
40
|
+
T(() => {
|
|
41
|
+
o.value = M(t.modelValue), i(() => {
|
|
42
|
+
t.autoGrow && g();
|
|
43
43
|
});
|
|
44
|
-
}),
|
|
45
|
-
|
|
44
|
+
}), $(() => {
|
|
45
|
+
y.value && cancelAnimationFrame(y.value);
|
|
46
46
|
});
|
|
47
|
-
const
|
|
47
|
+
const V = m(() => {
|
|
48
48
|
var e;
|
|
49
|
-
return !!(
|
|
50
|
-
}),
|
|
51
|
-
function
|
|
52
|
-
const e = t.rules || [], n = t.required && !
|
|
49
|
+
return !!(s.value.length || (e = t.errorMessages) != null && e.length);
|
|
50
|
+
}), E = m(() => V.value ? [...t.errorMessages || [], ...s.value].slice(0, t.maxErrors) : []);
|
|
51
|
+
function I() {
|
|
52
|
+
const e = t.rules || [], n = t.required && !o.value ? null : S(o.value), u = [];
|
|
53
53
|
for (const r of e) {
|
|
54
|
-
const
|
|
55
|
-
Array.isArray(
|
|
54
|
+
const a = typeof r == "function" ? r(n) : r;
|
|
55
|
+
Array.isArray(a) ? u.push(...a) : typeof a == "string" ? u.push(a) : a === !1 && u.push("Campo inválido");
|
|
56
56
|
}
|
|
57
|
-
return
|
|
57
|
+
return s.value = u, u.length === 0;
|
|
58
58
|
}
|
|
59
|
-
function
|
|
60
|
-
|
|
59
|
+
function N() {
|
|
60
|
+
s.value = [];
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
var
|
|
64
|
-
if (!
|
|
65
|
-
const n =
|
|
62
|
+
function j(e) {
|
|
63
|
+
var w;
|
|
64
|
+
if (!d.value || e.key !== "Enter") return;
|
|
65
|
+
const n = c.value;
|
|
66
66
|
if (!n) return;
|
|
67
|
-
const u = n.selectionStart, r =
|
|
68
|
-
`) + 1,
|
|
69
|
-
${((
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
n.setSelectionRange(
|
|
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
73
|
}), e.preventDefault();
|
|
74
74
|
}
|
|
75
75
|
return {
|
|
76
|
-
inputRef:
|
|
77
|
-
internalValue:
|
|
78
|
-
isFocused:
|
|
79
|
-
hasError:
|
|
80
|
-
displayedMessages:
|
|
81
|
-
validate:
|
|
82
|
-
resetValidation:
|
|
83
|
-
updateModel:
|
|
84
|
-
adjustHeight:
|
|
85
|
-
handleJsonEnter:
|
|
76
|
+
inputRef: c,
|
|
77
|
+
internalValue: o,
|
|
78
|
+
isFocused: H,
|
|
79
|
+
hasError: V,
|
|
80
|
+
displayedMessages: E,
|
|
81
|
+
validate: I,
|
|
82
|
+
resetValidation: N,
|
|
83
|
+
updateModel: O,
|
|
84
|
+
adjustHeight: g,
|
|
85
|
+
handleJsonEnter: j
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
88
|
export {
|
|
89
|
-
|
|
89
|
+
F as default
|
|
90
90
|
};
|