adverich-kun-ui 0.1.613 → 0.1.614
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,7 @@
|
|
|
1
|
-
import { ref as
|
|
1
|
+
import { ref as h, watch as M, computed as f, openBlock as l, createElementBlock as o, normalizeClass as K, toDisplayString as a, createCommentVNode as u, createElementVNode as y, mergeProps as L, renderSlot as b, unref as k, withModifiers as P, Fragment as j, renderList as x, createTextVNode as D } from "vue";
|
|
2
2
|
import { renderIconSlot as g } from "../../../../utils/renderIcon.js";
|
|
3
3
|
import { kunFileInputProps as G } from "../composables/kunFileInputProps.js";
|
|
4
|
-
const
|
|
5
|
-
key: 0,
|
|
6
|
-
class: "block text-sm font-medium mb-1"
|
|
7
|
-
}, q = { key: 0 }, H = ["multiple", "disabled"], J = { class: "flex-1 truncate" }, O = { key: 0 }, Q = {
|
|
4
|
+
const T = { class: "relative flex w-full flex-col" }, q = { key: 0 }, H = ["multiple", "disabled"], J = { class: "flex-1 truncate" }, O = { key: 0 }, Q = {
|
|
8
5
|
key: 1,
|
|
9
6
|
class: "text-gray-400"
|
|
10
7
|
}, U = { key: 0 }, W = { key: 0 }, X = { key: 1 }, Y = {
|
|
@@ -13,13 +10,13 @@ const L = { class: "relative w-full" }, T = {
|
|
|
13
10
|
}, Z = {
|
|
14
11
|
key: 0,
|
|
15
12
|
class: "text-red-500"
|
|
16
|
-
},
|
|
13
|
+
}, ee = {
|
|
17
14
|
key: 1,
|
|
18
15
|
class: "text-gray-500"
|
|
19
|
-
},
|
|
16
|
+
}, te = {
|
|
20
17
|
key: 2,
|
|
21
18
|
class: "mt-1 text-xs text-gray-400 text-right"
|
|
22
|
-
},
|
|
19
|
+
}, le = { key: 0 }, re = {
|
|
23
20
|
__name: "KunFileInput",
|
|
24
21
|
props: G,
|
|
25
22
|
emits: [
|
|
@@ -28,64 +25,70 @@ const L = { class: "relative w-full" }, T = {
|
|
|
28
25
|
"click:control",
|
|
29
26
|
"update:focused"
|
|
30
27
|
],
|
|
31
|
-
setup(
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
() =>
|
|
28
|
+
setup(_, { expose: S, emit: $ }) {
|
|
29
|
+
const i = _, c = $, B = h(null), v = h(!1), d = h([]), n = h([]);
|
|
30
|
+
M(
|
|
31
|
+
() => i.modelValue,
|
|
35
32
|
(e) => {
|
|
36
33
|
d.value = Array.isArray(e) ? e : e ? [e] : [];
|
|
37
34
|
},
|
|
38
35
|
{ immediate: !0 }
|
|
39
36
|
);
|
|
40
|
-
function
|
|
37
|
+
function z(e) {
|
|
41
38
|
const t = e.target.files;
|
|
42
39
|
if (!t) return;
|
|
43
40
|
const s = Array.from(t);
|
|
44
|
-
d.value =
|
|
41
|
+
d.value = i.multiple ? s : [s[0]], c("update:modelValue", i.multiple ? s : s[0]), I();
|
|
45
42
|
}
|
|
46
43
|
function V() {
|
|
47
|
-
d.value = [], c("update:modelValue",
|
|
44
|
+
d.value = [], c("update:modelValue", i.multiple ? [] : null), c("click:clear"), n.value = [];
|
|
48
45
|
}
|
|
49
|
-
function
|
|
46
|
+
function C() {
|
|
50
47
|
v.value = !0, c("update:focused", !0);
|
|
51
48
|
}
|
|
52
|
-
function
|
|
49
|
+
function A() {
|
|
53
50
|
v.value = !1, c("update:focused", !1);
|
|
54
51
|
}
|
|
55
|
-
const p =
|
|
56
|
-
const e = F.value, t =
|
|
57
|
-
let
|
|
58
|
-
for (;
|
|
59
|
-
|
|
60
|
-
return `${
|
|
52
|
+
const p = f(() => d.value.map((e) => e.name)), N = f(() => i.dirty || v.value || p.value.length > 0), F = f(() => d.value.reduce((e, t) => e + t.size, 0)), w = f(() => {
|
|
53
|
+
const e = F.value, t = i.showSize === 1024 ? 1024 : 1e3, s = ["B", "KB", "MB", "GB"];
|
|
54
|
+
let r = 0, m = e;
|
|
55
|
+
for (; m >= t && r < s.length - 1; )
|
|
56
|
+
m /= t, r++;
|
|
57
|
+
return `${m.toFixed(1)} ${s[r]}`;
|
|
61
58
|
});
|
|
62
59
|
async function I(e = !1) {
|
|
63
60
|
const t = [];
|
|
64
|
-
for (const s of
|
|
65
|
-
const
|
|
66
|
-
typeof
|
|
61
|
+
for (const s of i.rules) {
|
|
62
|
+
const r = typeof s == "function" ? s(i.multiple ? d.value : d.value[0]) : !0;
|
|
63
|
+
typeof r == "string" ? t.push(r) : r === !1 && t.push("Valor inválido");
|
|
67
64
|
}
|
|
68
|
-
return
|
|
65
|
+
return n.value = t, !e && t.length && c("update:focused", !0), t;
|
|
69
66
|
}
|
|
70
|
-
async function
|
|
67
|
+
async function R() {
|
|
71
68
|
V();
|
|
72
69
|
}
|
|
73
|
-
async function
|
|
74
|
-
|
|
70
|
+
async function E() {
|
|
71
|
+
n.value = [];
|
|
75
72
|
}
|
|
76
73
|
return S({
|
|
77
|
-
reset:
|
|
78
|
-
resetValidation:
|
|
74
|
+
reset: R,
|
|
75
|
+
resetValidation: E,
|
|
79
76
|
validate: I,
|
|
80
|
-
isValid:
|
|
81
|
-
errorMessages:
|
|
82
|
-
}), (e, t) => (l(), o("div",
|
|
83
|
-
e.label ? (l(), o("label",
|
|
84
|
-
|
|
77
|
+
isValid: f(() => n.value.length === 0),
|
|
78
|
+
errorMessages: n
|
|
79
|
+
}), (e, t) => (l(), o("div", T, [
|
|
80
|
+
e.label ? (l(), o("label", {
|
|
81
|
+
key: 0,
|
|
82
|
+
class: K([
|
|
83
|
+
"absolute left-2 z-10 px-1 text-black/80 transition-all duration-200 ease-in-out pointer-events-none select-none dark:text-white/80",
|
|
84
|
+
N.value ? "-top-2.25 text-xs opacity-80" : "top-3 text-sm opacity-80"
|
|
85
|
+
])
|
|
86
|
+
}, a(e.label), 3)) : u("", !0),
|
|
87
|
+
y("div", L({
|
|
85
88
|
class: ["flex items-center gap-2 rounded px-3 py-2 cursor-pointer transition", [
|
|
86
89
|
e.variant === "outlined" ? "border border-slate-400 dark:border-slate-600" : e.variant === "solo" ? "border-slate-400 dark:border-slate-600 shadow-inner" : "bg-surface border border-slate-400 dark:border-slate-600",
|
|
87
90
|
e.disabled ? "border-slate-400 dark:border-slate-600 cursor-not-allowed" : "hover:border-blue-500",
|
|
88
|
-
e.error ||
|
|
91
|
+
e.error || n.value.length ? "border-red-500" : "",
|
|
89
92
|
v.value ? "ring-2 ring-blue-500" : ""
|
|
90
93
|
]]
|
|
91
94
|
}, e.$attrs, {
|
|
@@ -93,11 +96,11 @@ const L = { class: "relative w-full" }, T = {
|
|
|
93
96
|
var s;
|
|
94
97
|
return (s = B.value) == null ? void 0 : s.click();
|
|
95
98
|
}),
|
|
96
|
-
onFocusin:
|
|
97
|
-
onFocusout:
|
|
99
|
+
onFocusin: C,
|
|
100
|
+
onFocusout: A
|
|
98
101
|
}), [
|
|
99
102
|
b(e.$slots, "prepend", {}, () => [
|
|
100
|
-
e.prependIcon ? (l(), o("span", q, a(k(g)(e.prependIcon)), 1)) :
|
|
103
|
+
e.prependIcon ? (l(), o("span", q, a(k(g)(e.prependIcon)), 1)) : u("", !0)
|
|
101
104
|
]),
|
|
102
105
|
y("input", {
|
|
103
106
|
ref_key: "inputRef",
|
|
@@ -106,37 +109,37 @@ const L = { class: "relative w-full" }, T = {
|
|
|
106
109
|
class: "hidden",
|
|
107
110
|
multiple: e.multiple,
|
|
108
111
|
disabled: e.disabled,
|
|
109
|
-
onChange:
|
|
112
|
+
onChange: z
|
|
110
113
|
}, null, 40, H),
|
|
111
114
|
y("div", J, [
|
|
112
115
|
b(e.$slots, "selection", {
|
|
113
116
|
fileNames: p.value,
|
|
114
117
|
totalBytes: F.value,
|
|
115
|
-
totalBytesReadable:
|
|
118
|
+
totalBytesReadable: w.value
|
|
116
119
|
}, () => [
|
|
117
120
|
p.value.length ? (l(), o("span", O, a(p.value.join(", ")), 1)) : (l(), o("span", Q, "Seleccionar archivo"))
|
|
118
121
|
])
|
|
119
122
|
]),
|
|
120
123
|
b(e.$slots, "append", {}, () => [
|
|
121
|
-
e.appendIcon ? (l(), o("span", U, a(k(g)(e.appendIcon)), 1)) :
|
|
124
|
+
e.appendIcon ? (l(), o("span", U, a(k(g)(e.appendIcon)), 1)) : u("", !0)
|
|
122
125
|
]),
|
|
123
126
|
e.clearable && p.value.length ? (l(), o("button", {
|
|
124
127
|
key: 0,
|
|
125
|
-
onClick:
|
|
126
|
-
class: "text-gray-500 hover:text-red-500"
|
|
128
|
+
onClick: P(V, ["stop"]),
|
|
129
|
+
class: "cursor-pointer text-gray-500 hover:text-red-500"
|
|
127
130
|
}, [
|
|
128
131
|
e.clearIcon ? (l(), o("span", W, a(k(g)(e.clearIcon)), 1)) : (l(), o("span", X, "✕"))
|
|
129
|
-
])) :
|
|
132
|
+
])) : u("", !0)
|
|
130
133
|
], 16),
|
|
131
|
-
e.hint ||
|
|
132
|
-
|
|
133
|
-
(l(!0), o(
|
|
134
|
-
])) : e.hint ? (l(), o("div",
|
|
135
|
-
])) :
|
|
136
|
-
e.counter ? (l(), o("div",
|
|
134
|
+
e.hint || n.value.length ? (l(), o("div", Y, [
|
|
135
|
+
n.value.length ? (l(), o("div", Z, [
|
|
136
|
+
(l(!0), o(j, null, x(n.value, (s, r) => (l(), o("div", { key: r }, a(s), 1))), 128))
|
|
137
|
+
])) : e.hint ? (l(), o("div", ee, a(e.hint), 1)) : u("", !0)
|
|
138
|
+
])) : u("", !0),
|
|
139
|
+
e.counter ? (l(), o("div", te, [
|
|
137
140
|
D(a(e.counterString ?? `${p.value.length} archivo(s)`) + " ", 1),
|
|
138
|
-
e.showSize ? (l(), o("span",
|
|
139
|
-
])) :
|
|
141
|
+
e.showSize ? (l(), o("span", le, " — " + a(w.value), 1)) : u("", !0)
|
|
142
|
+
])) : u("", !0)
|
|
140
143
|
]));
|
|
141
144
|
}
|
|
142
145
|
};
|