adverich-kun-ui 0.1.329 → 0.1.330
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,10 +1,10 @@
|
|
|
1
|
-
import { ref as D, watch as E, computed as f, createElementBlock as r, openBlock as o,
|
|
1
|
+
import { ref as D, watch as E, computed as f, createElementBlock as r, openBlock as o, mergeProps as F, unref as t, createCommentVNode as a, createElementVNode as $, withDirectives as M, renderSlot as s, createBlock as w, withKeys as j, normalizeClass as C, withModifiers as H, createVNode as K, createTextVNode as V, toDisplayString as g, Fragment as R, renderList as T } from "vue";
|
|
2
2
|
import h from "../../../KunIcon/src/components/KunIcon.vue.js";
|
|
3
3
|
import { useCheckboxModel as L } from "../composables/useCheckboxModel.js";
|
|
4
|
-
import { useValidation as
|
|
5
|
-
import { vRipple as
|
|
6
|
-
import { icons as
|
|
7
|
-
const
|
|
4
|
+
import { useValidation as P } from "../composables/useValidation.js";
|
|
5
|
+
import { vRipple as q } from "../../../../directives/ripple.js";
|
|
6
|
+
import { icons as y } from "../../../../icons/index.js";
|
|
7
|
+
const G = ["name", "checked", "value"], J = ["aria-checked", "aria-disabled", "tabindex"], Q = {
|
|
8
8
|
key: 1,
|
|
9
9
|
class: "cursor-pointer"
|
|
10
10
|
}, U = {
|
|
@@ -60,49 +60,49 @@ const J = ["name", "checked", "value"], P = ["aria-checked", "aria-disabled", "t
|
|
|
60
60
|
"click:append",
|
|
61
61
|
"click:prepend"
|
|
62
62
|
],
|
|
63
|
-
setup(
|
|
64
|
-
const c = N, e =
|
|
65
|
-
E(() => e.focused, (
|
|
63
|
+
setup(v, { expose: I, emit: N }) {
|
|
64
|
+
const c = N, e = v, d = D(e.focused ?? !1);
|
|
65
|
+
E(() => e.focused, (n) => d.value = n);
|
|
66
66
|
const {
|
|
67
67
|
isChecked: p,
|
|
68
68
|
toggle: u,
|
|
69
69
|
internalValue: W
|
|
70
70
|
} = L(e, c), {
|
|
71
71
|
errorMessages: m,
|
|
72
|
-
isValid:
|
|
73
|
-
validate:
|
|
72
|
+
isValid: b,
|
|
73
|
+
validate: k,
|
|
74
74
|
resetValidation: z
|
|
75
|
-
} =
|
|
76
|
-
I({ validate:
|
|
77
|
-
const O = f(() => e.indeterminate ? e.indeterminateIcon ||
|
|
75
|
+
} = P(e, W);
|
|
76
|
+
I({ validate: k, resetValidation: z });
|
|
77
|
+
const O = f(() => e.indeterminate ? e.indeterminateIcon || y.checkboxIndeterminate : p.value ? e.trueIcon || y.checkboxOn : e.falseIcon || y.checkboxBlank), A = f(() => [
|
|
78
78
|
typeof e.iconColor == "string" ? `text-${e.iconColor}` : "",
|
|
79
79
|
e.glow && d.value ? "opacity-100" : "opacity-70"
|
|
80
|
-
]),
|
|
80
|
+
]), x = f(() => ({
|
|
81
81
|
sm: "w-4 h-4 text-sm",
|
|
82
82
|
md: "w-5 h-5 text-base",
|
|
83
83
|
lg: "w-6 h-6 text-lg"
|
|
84
84
|
})[e.size] || e.size);
|
|
85
|
-
return (
|
|
86
|
-
var
|
|
87
|
-
return o(), r("div", {
|
|
88
|
-
class:
|
|
85
|
+
return (n, i) => {
|
|
86
|
+
var S;
|
|
87
|
+
return o(), r("div", F({
|
|
88
|
+
class: [
|
|
89
89
|
"kun-checkbox",
|
|
90
90
|
"flex",
|
|
91
|
-
|
|
91
|
+
v.direction === "vertical" ? "flex-col items-start" : "flex-row items-center",
|
|
92
92
|
"gap-2",
|
|
93
93
|
e.color && `text-${e.color}`,
|
|
94
94
|
{
|
|
95
95
|
"opacity-50 pointer-events-none": e.disabled || e.readonly,
|
|
96
|
-
"text-red-600": e.error || !t(
|
|
96
|
+
"text-red-600": e.error || !t(b),
|
|
97
97
|
"focus-within:ring-2 ring-primary-500": d.value
|
|
98
98
|
}
|
|
99
|
-
]
|
|
100
|
-
style:
|
|
99
|
+
],
|
|
100
|
+
style: {
|
|
101
101
|
width: e.width && `${e.width}px`,
|
|
102
102
|
minWidth: e.minWidth && `${e.minWidth}px`,
|
|
103
103
|
maxWidth: e.maxWidth && `${e.maxWidth}px`
|
|
104
|
-
}
|
|
105
|
-
}, [
|
|
104
|
+
}
|
|
105
|
+
}, n.$attrs), [
|
|
106
106
|
e.name ? (o(), r("input", {
|
|
107
107
|
key: 0,
|
|
108
108
|
type: "checkbox",
|
|
@@ -110,71 +110,71 @@ const J = ["name", "checked", "value"], P = ["aria-checked", "aria-disabled", "t
|
|
|
110
110
|
checked: t(p),
|
|
111
111
|
value: e.value ?? e.trueValue,
|
|
112
112
|
class: "hidden"
|
|
113
|
-
}, null, 8,
|
|
114
|
-
|
|
113
|
+
}, null, 8, G)) : a("", !0),
|
|
114
|
+
$("div", {
|
|
115
115
|
class: "flex items-center gap-2",
|
|
116
|
-
onClick:
|
|
116
|
+
onClick: i[0] || (i[0] = (l) => n.$emit("click:prepend"))
|
|
117
117
|
}, [
|
|
118
|
-
s(
|
|
119
|
-
e.prependIcon ? (o(),
|
|
118
|
+
s(n.$slots, "prepend"),
|
|
119
|
+
e.prependIcon ? (o(), w(h, {
|
|
120
120
|
key: 0,
|
|
121
121
|
icon: e.prependIcon
|
|
122
122
|
}, null, 8, ["icon"])) : a("", !0)
|
|
123
123
|
]),
|
|
124
124
|
M((o(), r("div", {
|
|
125
|
-
class:
|
|
125
|
+
class: C(["relative inline-flex items-center justify-center cursor-pointer", [x.value]]),
|
|
126
126
|
role: "checkbox",
|
|
127
127
|
"aria-checked": e.indeterminate ? "mixed" : t(p),
|
|
128
128
|
"aria-disabled": e.disabled,
|
|
129
129
|
tabindex: e.disabled ? -1 : 0,
|
|
130
|
-
onClick:
|
|
131
|
-
onFocus:
|
|
130
|
+
onClick: i[1] || (i[1] = (...l) => t(u) && t(u)(...l)),
|
|
131
|
+
onFocus: i[2] || (i[2] = () => {
|
|
132
132
|
d.value = !0, c("update:focused", !0);
|
|
133
133
|
}),
|
|
134
|
-
onBlur:
|
|
134
|
+
onBlur: i[3] || (i[3] = () => {
|
|
135
135
|
var l;
|
|
136
|
-
d.value = !1, c("update:focused", !1), (l = e.validateOn) != null && l.includes("blur") && t(
|
|
136
|
+
d.value = !1, c("update:focused", !1), (l = e.validateOn) != null && l.includes("blur") && t(k)();
|
|
137
137
|
}),
|
|
138
|
-
onKeydown:
|
|
138
|
+
onKeydown: i[4] || (i[4] = j(H((...l) => t(u) && t(u)(...l), ["prevent"]), ["space"]))
|
|
139
139
|
}, [
|
|
140
140
|
K(h, {
|
|
141
141
|
icon: O.value,
|
|
142
|
-
class:
|
|
142
|
+
class: C([...A.value, x.value])
|
|
143
143
|
}, null, 8, ["icon", "class"]),
|
|
144
|
-
s(
|
|
145
|
-
], 42,
|
|
146
|
-
[t(
|
|
144
|
+
s(n.$slots, "input")
|
|
145
|
+
], 42, J)), [
|
|
146
|
+
[t(q), e.ripple]
|
|
147
147
|
]),
|
|
148
|
-
e.label ||
|
|
149
|
-
s(
|
|
148
|
+
e.label || n.$slots.label ? (o(), r("div", Q, [
|
|
149
|
+
s(n.$slots, "label", {
|
|
150
150
|
label: e.label
|
|
151
151
|
}, () => [
|
|
152
152
|
V(g(e.label), 1)
|
|
153
153
|
])
|
|
154
154
|
])) : a("", !0),
|
|
155
|
-
|
|
155
|
+
$("div", {
|
|
156
156
|
class: "flex items-center gap-2",
|
|
157
|
-
onClick:
|
|
157
|
+
onClick: i[5] || (i[5] = (l) => n.$emit("click:append"))
|
|
158
158
|
}, [
|
|
159
|
-
s(
|
|
160
|
-
e.appendIcon ? (o(),
|
|
159
|
+
s(n.$slots, "append"),
|
|
160
|
+
e.appendIcon ? (o(), w(h, {
|
|
161
161
|
key: 0,
|
|
162
162
|
icon: e.appendIcon
|
|
163
163
|
}, null, 8, ["icon"])) : a("", !0)
|
|
164
164
|
]),
|
|
165
|
-
!e.hideDetails && ((
|
|
166
|
-
s(
|
|
165
|
+
!e.hideDetails && ((S = t(m)) != null && S.length || e.hint || e.persistentHint) ? (o(), r("div", U, [
|
|
166
|
+
s(n.$slots, "details", {}, () => {
|
|
167
167
|
var l;
|
|
168
168
|
return [
|
|
169
|
-
(e.error || !t(
|
|
170
|
-
(o(!0), r(R, null, T(t(m).slice(0, Number(e.maxErrors)), (
|
|
171
|
-
V(g(
|
|
169
|
+
(e.error || !t(b)) && ((l = t(m)) != null && l.length) ? (o(), r("div", X, [
|
|
170
|
+
(o(!0), r(R, null, T(t(m).slice(0, Number(e.maxErrors)), (B) => s(n.$slots, "message", { message: B }, () => [
|
|
171
|
+
V(g(B), 1)
|
|
172
172
|
])), 256))
|
|
173
173
|
])) : e.hint || e.persistentHint ? (o(), r("div", Y, g(e.hint), 1)) : a("", !0)
|
|
174
174
|
];
|
|
175
175
|
})
|
|
176
176
|
])) : a("", !0)
|
|
177
|
-
],
|
|
177
|
+
], 16);
|
|
178
178
|
};
|
|
179
179
|
}
|
|
180
180
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ref as L, computed as p, createElementBlock as l, openBlock as s, normalizeClass as m, renderSlot as i, createElementVNode as a, normalizeProps as y, guardReactiveProps as k, unref as
|
|
1
|
+
import { ref as L, computed as p, createElementBlock as l, openBlock as s, normalizeClass as m, renderSlot as i, createElementVNode as a, normalizeProps as y, guardReactiveProps as k, unref as t, createCommentVNode as d, toDisplayString as b, 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
4
|
import { renderIconSlot as $ } from "../../../../utils/renderIcon.js";
|
|
@@ -11,37 +11,37 @@ const Y = {
|
|
|
11
11
|
}, _ = {
|
|
12
12
|
key: 1,
|
|
13
13
|
class: "absolute left-2 top-2 ml-1"
|
|
14
|
-
}, ee = ["value", "rows", "disabled", "readonly", "placeholder"],
|
|
14
|
+
}, ee = ["value", "rows", "disabled", "readonly", "placeholder"], oe = {
|
|
15
15
|
key: 3,
|
|
16
16
|
class: "absolute right-2 top-2 mr-1"
|
|
17
|
-
},
|
|
17
|
+
}, re = {
|
|
18
18
|
key: 4,
|
|
19
19
|
class: "absolute right-2 top-2 flex items-center"
|
|
20
|
-
},
|
|
20
|
+
}, te = {
|
|
21
21
|
key: 5,
|
|
22
22
|
class: "mt-1"
|
|
23
|
-
},
|
|
23
|
+
}, ne = { class: "h-1 w-full bg-gray-200 rounded overflow-hidden" }, se = {
|
|
24
24
|
key: 7,
|
|
25
25
|
class: "text-xs text-right mt-1 text-gray-400"
|
|
26
26
|
}, le = { key: 0 }, pe = {
|
|
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
|
|
30
|
+
setup(z, { expose: B, emit: S }) {
|
|
31
|
+
const o = z, R = S, u = L(null), {
|
|
32
32
|
isFocused: v,
|
|
33
33
|
internalValue: c,
|
|
34
34
|
updateValue: D,
|
|
35
|
-
handleClear:
|
|
35
|
+
handleClear: V,
|
|
36
36
|
adjustHeight: F,
|
|
37
37
|
validate: M,
|
|
38
38
|
reset: T,
|
|
39
39
|
resetValidation: A,
|
|
40
40
|
hasError: f,
|
|
41
41
|
displayedMessages: w
|
|
42
|
-
} = X(
|
|
43
|
-
const e = !!
|
|
44
|
-
switch (
|
|
42
|
+
} = X(o, R, u), E = p(() => {
|
|
43
|
+
const e = !!o.bgColor;
|
|
44
|
+
switch (o.variant) {
|
|
45
45
|
case "filled":
|
|
46
46
|
return [
|
|
47
47
|
e ? "" : "bg-gray-100 dark:bg-gray-900",
|
|
@@ -60,7 +60,7 @@ const Y = {
|
|
|
60
60
|
return "";
|
|
61
61
|
}
|
|
62
62
|
}), G = p(() => {
|
|
63
|
-
switch (
|
|
63
|
+
switch (o.density) {
|
|
64
64
|
case "comfortable":
|
|
65
65
|
return "py-2";
|
|
66
66
|
case "compact":
|
|
@@ -70,102 +70,108 @@ const Y = {
|
|
|
70
70
|
}
|
|
71
71
|
}), N = p(() => [
|
|
72
72
|
"w-full resize-none p-2 transition-colors duration-150",
|
|
73
|
-
|
|
73
|
+
o.inputClass,
|
|
74
74
|
{
|
|
75
|
-
"rounded-md": !
|
|
76
|
-
"rounded-none":
|
|
77
|
-
[`rounded-${
|
|
78
|
-
"shadow-md":
|
|
79
|
-
"shadow-none":
|
|
80
|
-
[`text-${
|
|
81
|
-
[`${
|
|
82
|
-
"text-gray-500 bg-gray-200":
|
|
83
|
-
"focus:outline-none focus:ring-2": !
|
|
84
|
-
[`focus:ring-${
|
|
75
|
+
"rounded-md": !o.tile,
|
|
76
|
+
"rounded-none": o.tile,
|
|
77
|
+
[`rounded-${o.rounded}`]: typeof o.rounded == "string" || typeof o.rounded == "number",
|
|
78
|
+
"shadow-md": o.variant === "solo" && !o.flat,
|
|
79
|
+
"shadow-none": o.flat,
|
|
80
|
+
[`text-${o.textColor}`]: o.textColor,
|
|
81
|
+
[`${o.bgColor}`]: o.bgColor,
|
|
82
|
+
"text-gray-500 bg-gray-200": o.disabled,
|
|
83
|
+
"focus:outline-none focus:ring-2": !o.disabled,
|
|
84
|
+
[`focus:ring-${o.color}`]: o.color && !o.disabled && !f.value,
|
|
85
85
|
"border-red-500 ring-red-500 focus:ring-red-500": f.value,
|
|
86
|
-
"resize-none":
|
|
87
|
-
resize: !
|
|
86
|
+
"resize-none": o.noResize || o.autoGrow,
|
|
87
|
+
resize: !o.noResize && !o.autoGrow
|
|
88
88
|
}
|
|
89
89
|
]), P = p(() => [
|
|
90
90
|
"relative w-full",
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
]), I = p(() =>
|
|
94
|
-
function g(e,
|
|
95
|
-
|
|
91
|
+
o.class,
|
|
92
|
+
o.wrapperClass
|
|
93
|
+
]), I = p(() => o.counter === !0 ? 25 : typeof o.counter == "number" || typeof o.counter == "string" ? o.counter : null), H = p(() => o.persistentCounter ? !0 : !!o.counter && v.value), K = p(() => typeof o.clearIcon == "string" ? o.clearIcon : "i-heroicons-x-mark-20-solid");
|
|
94
|
+
function g(e, n) {
|
|
95
|
+
R(`click:${n}`, e);
|
|
96
96
|
}
|
|
97
|
-
return
|
|
97
|
+
return B({
|
|
98
98
|
validate: M,
|
|
99
99
|
reset: T,
|
|
100
100
|
resetValidation: A,
|
|
101
101
|
errorMessages: w,
|
|
102
|
-
isValid: p(() => !f.value)
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
isValid: p(() => !f.value),
|
|
103
|
+
rootRef,
|
|
104
|
+
focus: () => {
|
|
105
|
+
var e;
|
|
106
|
+
return (e = u.value) == null ? void 0 : e.focus();
|
|
107
|
+
}
|
|
108
|
+
}), (e, n) => (s(), l("div", {
|
|
109
|
+
class: m(P.value),
|
|
110
|
+
ref: "rootRef"
|
|
105
111
|
}, [
|
|
106
|
-
i(e.$slots, "label", y(k({ label: e.label, isFocused:
|
|
107
|
-
var
|
|
108
|
-
return (
|
|
112
|
+
i(e.$slots, "label", y(k({ label: e.label, isFocused: t(v), isActive: !!t(c), controlRef: u.value, focus: () => {
|
|
113
|
+
var r;
|
|
114
|
+
return (r = u.value) == null ? void 0 : r.focus();
|
|
109
115
|
}, blur: () => {
|
|
110
|
-
var
|
|
111
|
-
return (
|
|
112
|
-
}, props:
|
|
116
|
+
var r;
|
|
117
|
+
return (r = u.value) == null ? void 0 : r.blur();
|
|
118
|
+
}, props: o })), () => [
|
|
113
119
|
e.label ? (s(), l("label", Y, b(e.label), 1)) : d("", !0)
|
|
114
120
|
]),
|
|
115
121
|
a("div", Z, [
|
|
116
122
|
e.prependIcon || e.$slots.prepend ? (s(), l("div", x, [
|
|
117
123
|
i(e.$slots, "prepend", y(k(e.prependSlotBindings)), () => [
|
|
118
124
|
a("div", {
|
|
119
|
-
onClick:
|
|
125
|
+
onClick: n[0] || (n[0] = (r) => g(r, "prepend"))
|
|
120
126
|
}, [
|
|
121
|
-
(s(), h(C(
|
|
127
|
+
(s(), h(C(t($)(e.prependIcon))))
|
|
122
128
|
])
|
|
123
129
|
])
|
|
124
130
|
])) : d("", !0),
|
|
125
131
|
e.prependInnerIcon || e.$slots["prepend-inner"] ? (s(), l("div", _, [
|
|
126
132
|
i(e.$slots, "prepend-inner", {}, () => [
|
|
127
133
|
a("div", {
|
|
128
|
-
onClick:
|
|
134
|
+
onClick: n[1] || (n[1] = (r) => g(r, "prependInner"))
|
|
129
135
|
}, [
|
|
130
|
-
(s(), h(C(
|
|
136
|
+
(s(), h(C(t($)(e.prependInnerIcon))))
|
|
131
137
|
])
|
|
132
138
|
])
|
|
133
139
|
])) : d("", !0),
|
|
134
140
|
a("textarea", {
|
|
135
141
|
ref_key: "textareaRef",
|
|
136
142
|
ref: u,
|
|
137
|
-
value:
|
|
143
|
+
value: t(c),
|
|
138
144
|
rows: e.rows,
|
|
139
145
|
disabled: e.disabled,
|
|
140
146
|
readonly: e.readonly,
|
|
141
147
|
placeholder: e.placeholder,
|
|
142
|
-
onInput:
|
|
143
|
-
|
|
148
|
+
onInput: n[2] || (n[2] = (r) => {
|
|
149
|
+
t(D)(r.target.value), e.autoGrow && t(F)();
|
|
144
150
|
}),
|
|
145
|
-
onFocus:
|
|
151
|
+
onFocus: n[3] || (n[3] = (r) => {
|
|
146
152
|
v.value = !0, e.$emit("update:focused", !0);
|
|
147
153
|
}),
|
|
148
|
-
onBlur:
|
|
154
|
+
onBlur: n[4] || (n[4] = (r) => {
|
|
149
155
|
v.value = !1, e.$emit("update:focused", !1);
|
|
150
156
|
}),
|
|
151
|
-
onClick:
|
|
152
|
-
onMousedown:
|
|
157
|
+
onClick: n[5] || (n[5] = (r) => e.$emit("click:control", r)),
|
|
158
|
+
onMousedown: n[6] || (n[6] = (r) => e.$emit("mousedown:control", r)),
|
|
153
159
|
class: m([E.value, G.value, N.value])
|
|
154
160
|
}, null, 42, ee),
|
|
155
|
-
e.clearable &&
|
|
161
|
+
e.clearable && t(c) ? (s(), l("div", {
|
|
156
162
|
key: 2,
|
|
157
163
|
class: m(["absolute right-2 top-2", { "opacity-100": e.persistentClear, "hover:opacity-100 opacity-0 transition-opacity duration-200": !e.persistentClear }])
|
|
158
164
|
}, [
|
|
159
|
-
i(e.$slots, "clear", y(k({ isActive: !!
|
|
160
|
-
var
|
|
161
|
-
return (
|
|
165
|
+
i(e.$slots, "clear", y(k({ isActive: !!t(c), isFocused: t(v), controlRef: u.value, focus: () => {
|
|
166
|
+
var r;
|
|
167
|
+
return (r = u.value) == null ? void 0 : r.focus();
|
|
162
168
|
}, blur: () => {
|
|
163
|
-
var
|
|
164
|
-
return (
|
|
165
|
-
}, props:
|
|
169
|
+
var r;
|
|
170
|
+
return (r = u.value) == null ? void 0 : r.blur();
|
|
171
|
+
}, props: o })), () => [
|
|
166
172
|
a("button", {
|
|
167
173
|
type: "button",
|
|
168
|
-
onClick:
|
|
174
|
+
onClick: n[7] || (n[7] = (...r) => t(V) && t(V)(...r)),
|
|
169
175
|
class: "text-gray-500 hover:text-gray-700"
|
|
170
176
|
}, [
|
|
171
177
|
a("span", {
|
|
@@ -174,30 +180,30 @@ const Y = {
|
|
|
174
180
|
])
|
|
175
181
|
])
|
|
176
182
|
], 2)) : d("", !0),
|
|
177
|
-
e.appendInnerIcon || e.$slots["append-inner"] ? (s(), l("div",
|
|
183
|
+
e.appendInnerIcon || e.$slots["append-inner"] ? (s(), l("div", oe, [
|
|
178
184
|
i(e.$slots, "append-inner", {}, () => [
|
|
179
185
|
a("div", {
|
|
180
|
-
onClick:
|
|
186
|
+
onClick: n[8] || (n[8] = (r) => g(r, "appendInner"))
|
|
181
187
|
}, [
|
|
182
|
-
(s(), h(C(
|
|
188
|
+
(s(), h(C(t($)(e.appendInnerIcon))))
|
|
183
189
|
])
|
|
184
190
|
])
|
|
185
191
|
])) : d("", !0),
|
|
186
|
-
e.appendIcon || e.$slots.append ? (s(), l("div",
|
|
192
|
+
e.appendIcon || e.$slots.append ? (s(), l("div", re, [
|
|
187
193
|
i(e.$slots, "append", y(k(e.appendSlotBindings)), () => [
|
|
188
194
|
a("div", {
|
|
189
|
-
onClick:
|
|
195
|
+
onClick: n[9] || (n[9] = (r) => g(r, "append"))
|
|
190
196
|
}, [
|
|
191
|
-
(s(), h(C(
|
|
197
|
+
(s(), h(C(t($)(e.appendIcon))))
|
|
192
198
|
])
|
|
193
199
|
])
|
|
194
200
|
])) : d("", !0),
|
|
195
|
-
e.loading ? (s(), l("div",
|
|
201
|
+
e.loading ? (s(), l("div", te, [
|
|
196
202
|
i(e.$slots, "loader", {
|
|
197
203
|
color: e.loadingColor,
|
|
198
204
|
isActive: !0
|
|
199
205
|
}, () => [
|
|
200
|
-
a("div",
|
|
206
|
+
a("div", ne, [
|
|
201
207
|
a("div", {
|
|
202
208
|
class: m(["h-full transition-all duration-300", [`${e.loadingColor}`]]),
|
|
203
209
|
style: { width: "100%" }
|
|
@@ -205,33 +211,33 @@ const Y = {
|
|
|
205
211
|
])
|
|
206
212
|
])
|
|
207
213
|
])) : d("", !0),
|
|
208
|
-
!e.hideDetails || e.hideDetails === "auto" && (
|
|
214
|
+
!e.hideDetails || e.hideDetails === "auto" && (t(w).length || e.hint) ? (s(), l("div", {
|
|
209
215
|
key: 6,
|
|
210
|
-
class: m(["text-xs mt-1 space-y-1", { "text-red-500":
|
|
216
|
+
class: m(["text-xs mt-1 space-y-1", { "text-red-500": t(f), "text-gray-500": !t(f) }])
|
|
211
217
|
}, [
|
|
212
218
|
i(e.$slots, "details", {}, () => [
|
|
213
|
-
|
|
219
|
+
t(f) ? (s(!0), l(q, { key: 0 }, J(t(w), (r, j) => i(e.$slots, "message", {
|
|
214
220
|
key: j,
|
|
215
|
-
message:
|
|
221
|
+
message: r
|
|
216
222
|
}, () => [
|
|
217
|
-
a("div", null, b(
|
|
223
|
+
a("div", null, b(r), 1)
|
|
218
224
|
])), 128)) : e.hint ? i(e.$slots, "hint", {
|
|
219
225
|
key: 1,
|
|
220
226
|
hint: e.hint
|
|
221
227
|
}, () => [
|
|
222
228
|
O(a("div", null, b(e.hint), 513), [
|
|
223
|
-
[Q, e.persistentHint ||
|
|
229
|
+
[Q, e.persistentHint || t(v)]
|
|
224
230
|
])
|
|
225
231
|
]) : d("", !0)
|
|
226
232
|
])
|
|
227
233
|
], 2)) : d("", !0),
|
|
228
234
|
H.value ? (s(), l("div", se, [
|
|
229
235
|
i(e.$slots, "counter", {
|
|
230
|
-
counter:
|
|
236
|
+
counter: t(c).length,
|
|
231
237
|
max: I.value,
|
|
232
|
-
value:
|
|
238
|
+
value: t(c).length
|
|
233
239
|
}, () => [
|
|
234
|
-
U(b(
|
|
240
|
+
U(b(t(c).length), 1),
|
|
235
241
|
I.value ? (s(), l("span", le, " / " + b(I.value), 1)) : d("", !0)
|
|
236
242
|
])
|
|
237
243
|
])) : d("", !0)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
function
|
|
3
|
-
const h =
|
|
1
|
+
import { ref as o, watch as T, nextTick as M, onMounted as b, computed as V } from "vue";
|
|
2
|
+
function A(t, s, a) {
|
|
3
|
+
const h = o(!1), w = o(t.modelValue), H = o(null), g = (e) => {
|
|
4
4
|
if (t.formatModel === "raw") return String(e ?? "");
|
|
5
5
|
if ((t.formatModel === "json" || t.formatModel === "auto") && typeof e == "object" && e !== null)
|
|
6
6
|
try {
|
|
@@ -12,65 +12,66 @@ function k(t, s, l) {
|
|
|
12
12
|
}, m = (e) => {
|
|
13
13
|
if (t.formatModel === "raw") return e;
|
|
14
14
|
try {
|
|
15
|
-
const
|
|
15
|
+
const l = JSON.parse(e);
|
|
16
16
|
if (t.formatModel === "json" || t.formatModel === "auto")
|
|
17
|
-
return
|
|
17
|
+
return l;
|
|
18
18
|
} catch {
|
|
19
19
|
}
|
|
20
20
|
return e;
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
w.value = e,
|
|
21
|
+
}, u = o(g(t.modelValue));
|
|
22
|
+
T(() => t.modelValue, (e) => {
|
|
23
|
+
w.value = e, u.value = g(e), t.autoGrow && M(c);
|
|
24
24
|
});
|
|
25
25
|
const v = (e) => {
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
s("update:modelValue",
|
|
29
|
-
},
|
|
26
|
+
u.value = e;
|
|
27
|
+
const l = m(e);
|
|
28
|
+
s("update:modelValue", l);
|
|
29
|
+
}, S = () => {
|
|
30
30
|
v(""), s("click:clear");
|
|
31
31
|
}, c = () => {
|
|
32
|
-
if (!
|
|
33
|
-
|
|
34
|
-
const e =
|
|
32
|
+
if (!a.value) return;
|
|
33
|
+
a.value.style.height = "auto", a.value.style.overflowY = "hidden";
|
|
34
|
+
const e = a.value.scrollHeight, l = parseFloat(getComputedStyle(a.value).lineHeight || "24"), i = Number(t.maxRows || 0);
|
|
35
35
|
if (t.maxRows && i > 0) {
|
|
36
|
-
const
|
|
37
|
-
|
|
36
|
+
const n = i * l;
|
|
37
|
+
a.value.style.height = Math.min(e, n) + "px";
|
|
38
38
|
} else
|
|
39
|
-
|
|
39
|
+
a.value.style.height = e + "px";
|
|
40
40
|
};
|
|
41
|
-
|
|
41
|
+
b(() => {
|
|
42
42
|
t.autoGrow && M(c);
|
|
43
43
|
});
|
|
44
|
-
const r =
|
|
45
|
-
const
|
|
44
|
+
const r = o([]), j = o(!0), x = (e = !1) => {
|
|
45
|
+
const l = t.validationValue ?? m(u.value), i = t.rules ?? [], n = [];
|
|
46
46
|
for (const d of i) {
|
|
47
|
-
const f = typeof d == "function" ? d(
|
|
48
|
-
typeof f == "string" ?
|
|
47
|
+
const f = typeof d == "function" ? d(l) : d;
|
|
48
|
+
typeof f == "string" ? n.push(f) : f === !1 && n.push("Campo inválido");
|
|
49
49
|
}
|
|
50
|
-
return r.value =
|
|
50
|
+
return r.value = n.slice(0, t.maxErrors ?? 1), e || s("update:focused", h.value), r.value;
|
|
51
51
|
}, y = () => {
|
|
52
52
|
r.value = [];
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
},
|
|
53
|
+
}, C = () => {
|
|
54
|
+
u.value = "", y(), s("update:modelValue", "");
|
|
55
|
+
}, E = V(() => t.error || r.value.length > 0), N = V(() => {
|
|
56
56
|
var e;
|
|
57
57
|
return (e = t.errorMessages) != null && e.length ? Array.isArray(t.errorMessages) ? t.errorMessages : [t.errorMessages] : r.value;
|
|
58
58
|
});
|
|
59
59
|
return {
|
|
60
60
|
isFocused: h,
|
|
61
|
-
internalValue:
|
|
61
|
+
internalValue: u,
|
|
62
|
+
rootRef: H,
|
|
62
63
|
updateValue: v,
|
|
63
|
-
handleClear:
|
|
64
|
+
handleClear: S,
|
|
64
65
|
adjustHeight: c,
|
|
65
|
-
isPristine:
|
|
66
|
-
validate:
|
|
67
|
-
reset:
|
|
66
|
+
isPristine: j,
|
|
67
|
+
validate: x,
|
|
68
|
+
reset: C,
|
|
68
69
|
resetValidation: y,
|
|
69
70
|
validationErrors: r,
|
|
70
|
-
hasError:
|
|
71
|
-
displayedMessages:
|
|
71
|
+
hasError: E,
|
|
72
|
+
displayedMessages: N
|
|
72
73
|
};
|
|
73
74
|
}
|
|
74
75
|
export {
|
|
75
|
-
|
|
76
|
+
A as useKunTextarea
|
|
76
77
|
};
|