vlite3 0.3.1 → 0.3.4
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.
- package/components/AvatarUploader/AvatarUploader.vue.d.ts +2 -2
- package/components/AvatarUploader/AvatarUploader.vue.js +53 -36
- package/components/DataList/DataList.vue.d.ts +47 -0
- package/components/DataList/DataList.vue.js +98 -0
- package/components/DataList/DataList.vue2.js +4 -0
- package/components/DataList/index.d.ts +2 -0
- package/components/DataList/types.d.ts +23 -0
- package/components/FilePicker/FilePicker.vue.d.ts +1 -0
- package/components/FilePicker/FilePicker.vue.js +159 -139
- package/components/Form/FormField.vue.js +53 -50
- package/components/Form/composables/useForm.js +80 -63
- package/components/Form/types.d.ts +4 -0
- package/components/ThemeToggle.vue.d.ts +8 -1
- package/components/ThemeToggle.vue.js +23 -14
- package/index.d.ts +1 -0
- package/index.js +13 -11
- package/package.json +1 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
const
|
|
1
|
+
import { defineComponent as q, ref as F, useSlots as H, computed as y, openBlock as r, createElementBlock as c, createElementVNode as n, renderSlot as J, normalizeClass as S, createBlock as x, withModifiers as D, createVNode as k, createTextVNode as Q, toDisplayString as A, createCommentVNode as w, Fragment as X, renderList as Y } from "vue";
|
|
2
|
+
import g from "../Icon.vue.js";
|
|
3
|
+
import $ from "../Button.vue.js";
|
|
4
|
+
const Z = { class: "w-full" }, _ = ["multiple", "accept"], ee = ["value", "placeholder", "disabled"], le = { class: "absolute right-3 top-1/2 -translate-y-1/2 flex items-center justify-center gap-2 bg-background" }, te = { class: "p-3 bg-muted rounded-full text-muted-foreground" }, ae = { class: "space-y-1" }, ie = {
|
|
5
5
|
key: 0,
|
|
6
6
|
class: "text-xs text-muted-foreground"
|
|
7
7
|
}, oe = {
|
|
8
8
|
key: 1,
|
|
9
9
|
class: "space-y-2"
|
|
10
|
-
},
|
|
10
|
+
}, re = { class: "shrink-0 mr-3" }, se = { class: "p-2 bg-primary-light rounded text-primary-fg-light" }, ne = { class: "flex-1 min-w-0" }, de = { class: "text-sm font-medium text-foreground truncate" }, ue = { class: "text-xs text-muted-foreground" }, ce = { class: "flex-shrink-0 ml-3 flex gap-2" }, fe = {
|
|
11
11
|
key: 0,
|
|
12
12
|
class: "flex gap-2"
|
|
13
|
-
},
|
|
13
|
+
}, me = {
|
|
14
14
|
key: 2,
|
|
15
15
|
class: "absolute inset-0 bg-white/60 backdrop-blur-[1px] flex items-center justify-center rounded-lg z-10"
|
|
16
|
-
},
|
|
16
|
+
}, ge = { class: "bg-white p-2 rounded-full shadow-lg" }, ye = /* @__PURE__ */ q({
|
|
17
17
|
name: "FilePicker",
|
|
18
18
|
__name: "FilePicker",
|
|
19
19
|
props: {
|
|
@@ -24,106 +24,126 @@ const X = { class: "w-full" }, Y = ["multiple", "accept"], Z = ["value", "placeh
|
|
|
24
24
|
loading: { type: Boolean, default: !1 },
|
|
25
25
|
disabled: { type: Boolean, default: !1 },
|
|
26
26
|
maxSize: {},
|
|
27
|
+
maxFiles: {},
|
|
27
28
|
variant: { default: "dropzone" },
|
|
28
29
|
placeholder: {},
|
|
29
30
|
size: { default: "md" },
|
|
30
31
|
rounded: { default: "md" }
|
|
31
32
|
},
|
|
32
33
|
emits: ["update:modelValue", "change", "error"],
|
|
33
|
-
setup(
|
|
34
|
-
const e =
|
|
35
|
-
|
|
36
|
-
const N =
|
|
37
|
-
let
|
|
38
|
-
return Array.isArray(e.modelValue) ?
|
|
39
|
-
if (typeof
|
|
40
|
-
const
|
|
34
|
+
setup(a, { emit: M }) {
|
|
35
|
+
const e = a, d = M, C = F(null), h = F(!1), u = F(!1);
|
|
36
|
+
H();
|
|
37
|
+
const N = y(() => e.fileTypes.join(",")), V = y(() => Array.isArray(e.modelValue) ? e.modelValue.length > 0 : e.modelValue !== null), b = y(() => {
|
|
38
|
+
let l = [];
|
|
39
|
+
return Array.isArray(e.modelValue) ? l = e.modelValue : e.modelValue && (l = [e.modelValue]), l.map((t) => {
|
|
40
|
+
if (typeof t == "string") {
|
|
41
|
+
const o = t.split("/").pop() || "Unknown File";
|
|
41
42
|
return {
|
|
42
|
-
fileName: decodeURIComponent(
|
|
43
|
+
fileName: decodeURIComponent(o),
|
|
43
44
|
fileType: "unknown",
|
|
44
45
|
fileSize: 0,
|
|
45
46
|
file: null,
|
|
46
|
-
base64:
|
|
47
|
+
base64: t,
|
|
47
48
|
isUrl: !0
|
|
48
49
|
};
|
|
49
50
|
}
|
|
50
|
-
return
|
|
51
|
+
return t;
|
|
51
52
|
});
|
|
52
|
-
}),
|
|
53
|
-
e.disabled || e.loading ||
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
53
|
+
}), p = () => {
|
|
54
|
+
if (!(e.disabled || e.loading || u.value)) {
|
|
55
|
+
if (e.multiSelect && e.maxFiles && (Array.isArray(e.modelValue) ? e.modelValue.length : e.modelValue ? 1 : 0) >= e.maxFiles) {
|
|
56
|
+
d("error", `Maximum ${e.maxFiles} files allowed`);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
C.value?.click();
|
|
60
|
+
}
|
|
61
|
+
}, j = (l) => {
|
|
62
|
+
l.preventDefault(), !(e.disabled || e.loading) && (h.value = !0);
|
|
63
|
+
}, L = (l) => {
|
|
64
|
+
l.preventDefault(), h.value = !1;
|
|
65
|
+
}, I = (l) => {
|
|
66
|
+
l.preventDefault(), h.value = !1, !(e.disabled || e.loading || u.value) && l.dataTransfer?.files && z(l.dataTransfer.files);
|
|
67
|
+
}, P = (l) => {
|
|
68
|
+
const t = l.target;
|
|
69
|
+
t.files && z(t.files), t.value = "";
|
|
70
|
+
}, E = (l) => {
|
|
71
|
+
if (l === 0 || !l) return "";
|
|
72
|
+
const t = 1024, o = ["Bytes", "KB", "MB", "GB", "TB"], s = Math.floor(Math.log(l) / Math.log(t));
|
|
73
|
+
return parseFloat((l / Math.pow(t, s)).toFixed(2)) + " " + o[s];
|
|
74
|
+
}, U = (l) => new Promise((t, o) => {
|
|
75
|
+
const s = new FileReader();
|
|
76
|
+
s.readAsDataURL(l), s.onload = () => {
|
|
77
|
+
typeof s.result == "string" ? t(s.result) : o(new Error("Failed to read file as base64"));
|
|
78
|
+
}, s.onerror = (f) => o(f);
|
|
79
|
+
}), z = async (l) => {
|
|
80
|
+
if (l.length === 0) return;
|
|
81
|
+
u.value = !0;
|
|
82
|
+
const t = [], o = [], s = Array.from(l);
|
|
83
|
+
let f = e.multiSelect ? s : [s[0]];
|
|
84
|
+
if (e.multiSelect && e.maxFiles) {
|
|
85
|
+
const i = Array.isArray(e.modelValue) ? e.modelValue.length : e.modelValue ? 1 : 0, m = e.maxFiles - i;
|
|
86
|
+
if (m <= 0) {
|
|
87
|
+
d("error", `Maximum ${e.maxFiles} files allowed`), u.value = !1;
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
f.length > m && (o.push(`Only ${m} more file(s) allowed. Maximum ${e.maxFiles} files.`), f = f.slice(0, m));
|
|
91
|
+
}
|
|
76
92
|
try {
|
|
77
|
-
for (const i of
|
|
78
|
-
if (e.fileTypes.length > 0 && !e.fileTypes.some((
|
|
79
|
-
if (
|
|
80
|
-
return i.name.toLowerCase().endsWith(
|
|
81
|
-
if (
|
|
82
|
-
const
|
|
83
|
-
return i.type.startsWith(
|
|
93
|
+
for (const i of f) {
|
|
94
|
+
if (e.fileTypes.length > 0 && !e.fileTypes.some((v) => {
|
|
95
|
+
if (v.startsWith("."))
|
|
96
|
+
return i.name.toLowerCase().endsWith(v.toLowerCase());
|
|
97
|
+
if (v.endsWith("/*")) {
|
|
98
|
+
const K = v.split("/")[0];
|
|
99
|
+
return i.type.startsWith(K);
|
|
84
100
|
}
|
|
85
|
-
return i.type ===
|
|
101
|
+
return i.type === v;
|
|
86
102
|
})) {
|
|
87
|
-
|
|
103
|
+
o.push(`File type not allowed: ${i.name}`);
|
|
88
104
|
continue;
|
|
89
105
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
106
|
+
let m = !1;
|
|
107
|
+
e.maxSize && i.size > e.maxSize && (o.push(`File too large: ${i.name}`), m = !0);
|
|
108
|
+
let T = "";
|
|
109
|
+
if (e.returnFormat === "base64" && !m)
|
|
110
|
+
try {
|
|
111
|
+
T = await U(i);
|
|
112
|
+
} catch (B) {
|
|
113
|
+
console.error("Base64 read failed", B);
|
|
114
|
+
}
|
|
115
|
+
t.push({
|
|
96
116
|
fileName: i.name,
|
|
97
117
|
fileType: i.type,
|
|
98
118
|
fileSize: i.size,
|
|
99
119
|
file: i,
|
|
100
|
-
base64:
|
|
120
|
+
base64: T
|
|
101
121
|
});
|
|
102
122
|
}
|
|
103
|
-
if (
|
|
123
|
+
if (o.length > 0 && d("error", o.join("; ")), t.length > 0) {
|
|
104
124
|
let i;
|
|
105
|
-
e.multiSelect ? i = [...Array.isArray(e.modelValue) ? e.modelValue : [], ...
|
|
125
|
+
e.multiSelect ? i = [...Array.isArray(e.modelValue) ? e.modelValue : e.modelValue ? [e.modelValue] : [], ...t] : i = t[0], d("update:modelValue", i), d("change", i);
|
|
106
126
|
}
|
|
107
127
|
} catch (i) {
|
|
108
|
-
console.error("Error processing files:", i),
|
|
128
|
+
console.error("Error processing files:", i), d("error", "Failed to process files");
|
|
109
129
|
} finally {
|
|
110
|
-
|
|
130
|
+
u.value = !1;
|
|
111
131
|
}
|
|
112
|
-
},
|
|
132
|
+
}, W = (l) => {
|
|
113
133
|
if (!(e.disabled || e.loading))
|
|
114
134
|
if (e.multiSelect && Array.isArray(e.modelValue)) {
|
|
115
|
-
const
|
|
116
|
-
|
|
135
|
+
const t = [...e.modelValue];
|
|
136
|
+
t.splice(l, 1), d("update:modelValue", t), d("change", t);
|
|
117
137
|
} else
|
|
118
|
-
|
|
119
|
-
},
|
|
120
|
-
e.disabled || e.loading || (
|
|
121
|
-
},
|
|
122
|
-
const
|
|
138
|
+
d("update:modelValue", null), d("change", null);
|
|
139
|
+
}, R = () => {
|
|
140
|
+
e.disabled || e.loading || (d("update:modelValue", null), d("change", null));
|
|
141
|
+
}, O = y(() => V.value ? b.value.map((t) => t.fileName).join(", ") : ""), G = y(() => {
|
|
142
|
+
const l = "block w-full bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50 transition-all focus-visible:outline-none cursor-pointer", t = {
|
|
123
143
|
sm: "h-8 text-xs",
|
|
124
144
|
md: "h-10 text-sm",
|
|
125
145
|
lg: "h-12 text-base"
|
|
126
|
-
},
|
|
146
|
+
}, o = {
|
|
127
147
|
none: "rounded-none",
|
|
128
148
|
sm: "rounded-sm",
|
|
129
149
|
md: "rounded-md",
|
|
@@ -133,153 +153,153 @@ const X = { class: "w-full" }, Y = ["multiple", "accept"], Z = ["value", "placeh
|
|
|
133
153
|
full: "rounded-full"
|
|
134
154
|
};
|
|
135
155
|
return [
|
|
136
|
-
|
|
156
|
+
l,
|
|
137
157
|
"border border-input focus-visible:border-primary",
|
|
138
158
|
// Default outline style
|
|
139
|
-
|
|
140
|
-
|
|
159
|
+
t[e.size],
|
|
160
|
+
o[e.rounded],
|
|
141
161
|
"pr-10",
|
|
142
162
|
// Space for icon
|
|
143
163
|
e.disabled ? "cursor-not-allowed opacity-50" : ""
|
|
144
164
|
].join(" ");
|
|
145
165
|
});
|
|
146
|
-
return (
|
|
147
|
-
|
|
166
|
+
return (l, t) => (r(), c("div", Z, [
|
|
167
|
+
n("input", {
|
|
148
168
|
ref_key: "fileInput",
|
|
149
169
|
ref: C,
|
|
150
170
|
type: "file",
|
|
151
|
-
multiple:
|
|
171
|
+
multiple: a.multiSelect,
|
|
152
172
|
accept: N.value,
|
|
153
173
|
class: "hidden",
|
|
154
|
-
onChange:
|
|
155
|
-
}, null, 40,
|
|
156
|
-
|
|
157
|
-
trigger:
|
|
158
|
-
isDragging:
|
|
159
|
-
isLoading:
|
|
160
|
-
files:
|
|
174
|
+
onChange: P
|
|
175
|
+
}, null, 40, _),
|
|
176
|
+
J(l.$slots, "trigger", {
|
|
177
|
+
trigger: p,
|
|
178
|
+
isDragging: h.value,
|
|
179
|
+
isLoading: a.loading || u.value,
|
|
180
|
+
files: b.value
|
|
161
181
|
}, () => [
|
|
162
|
-
|
|
182
|
+
a.variant === "input" ? (r(), c("div", {
|
|
163
183
|
key: 0,
|
|
164
184
|
class: "relative",
|
|
165
|
-
onClick:
|
|
185
|
+
onClick: p
|
|
166
186
|
}, [
|
|
167
|
-
|
|
187
|
+
n("input", {
|
|
168
188
|
type: "text",
|
|
169
|
-
value:
|
|
170
|
-
placeholder:
|
|
189
|
+
value: O.value,
|
|
190
|
+
placeholder: a.placeholder || "Select file...",
|
|
171
191
|
readonly: "",
|
|
172
|
-
class:
|
|
173
|
-
disabled:
|
|
174
|
-
}, null, 10,
|
|
175
|
-
|
|
176
|
-
|
|
192
|
+
class: S(G.value),
|
|
193
|
+
disabled: a.disabled || a.loading || u.value
|
|
194
|
+
}, null, 10, ee),
|
|
195
|
+
n("div", le, [
|
|
196
|
+
a.loading || u.value ? (r(), x(g, {
|
|
177
197
|
key: 0,
|
|
178
198
|
icon: "lucide:loader-2",
|
|
179
199
|
class: "h-4 w-4 animate-spin text-muted-foreground"
|
|
180
|
-
})) :
|
|
200
|
+
})) : V.value && !a.disabled ? (r(), c("button", {
|
|
181
201
|
key: 1,
|
|
182
202
|
type: "button",
|
|
183
203
|
class: "text-muted-foreground hover:text-foreground focus:outline-none",
|
|
184
|
-
onClick: D(
|
|
204
|
+
onClick: D(R, ["stop"])
|
|
185
205
|
}, [
|
|
186
|
-
|
|
206
|
+
k(g, {
|
|
187
207
|
icon: "lucide:x-circle",
|
|
188
208
|
class: "h-4 w-4"
|
|
189
209
|
})
|
|
190
|
-
])) : (
|
|
210
|
+
])) : (r(), x(g, {
|
|
191
211
|
key: 2,
|
|
192
212
|
icon: "lucide:upload",
|
|
193
213
|
class: "h-4 w-4 text-muted-foreground"
|
|
194
214
|
}))
|
|
195
215
|
])
|
|
196
|
-
])) : (
|
|
216
|
+
])) : (r(), c("div", {
|
|
197
217
|
key: 1,
|
|
198
218
|
class: "relative",
|
|
199
219
|
onDragover: j,
|
|
200
|
-
onDragleave:
|
|
201
|
-
onDrop:
|
|
220
|
+
onDragleave: L,
|
|
221
|
+
onDrop: I
|
|
202
222
|
}, [
|
|
203
|
-
|
|
204
|
-
(
|
|
205
|
-
key:
|
|
206
|
-
class:
|
|
207
|
-
onClick:
|
|
223
|
+
V.value ? (r(), c("div", oe, [
|
|
224
|
+
(r(!0), c(X, null, Y(b.value, (o, s) => (r(), c("div", {
|
|
225
|
+
key: s,
|
|
226
|
+
class: S(["relative flex items-center p-3 border border-border rounded-lg bg-card shadow-sm transition-colors group", [!a.multiSelect && !a.disabled ? "cursor-pointer hover:border-primary/50" : ""]]),
|
|
227
|
+
onClick: t[0] || (t[0] = (f) => !a.multiSelect && !a.disabled ? p() : null)
|
|
208
228
|
}, [
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
229
|
+
n("div", re, [
|
|
230
|
+
n("div", se, [
|
|
231
|
+
k(g, {
|
|
212
232
|
icon: "lucide:file-text",
|
|
213
233
|
class: "w-5 h-5"
|
|
214
234
|
})
|
|
215
235
|
])
|
|
216
236
|
]),
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
237
|
+
n("div", ne, [
|
|
238
|
+
n("p", de, A(o.fileName), 1),
|
|
239
|
+
n("p", ue, A(E(o.fileSize)), 1)
|
|
220
240
|
]),
|
|
221
|
-
|
|
222
|
-
!
|
|
241
|
+
n("div", ce, [
|
|
242
|
+
!a.disabled && !a.loading ? (r(), x($, {
|
|
223
243
|
key: 0,
|
|
224
244
|
size: "xs",
|
|
225
245
|
variant: "ghost",
|
|
226
246
|
icon: "lucide:x",
|
|
227
247
|
rounded: "full",
|
|
228
248
|
class: "text-muted-foreground hover:text-destructive hover:bg-destructive/10",
|
|
229
|
-
onClick: D((
|
|
230
|
-
}, null, 8, ["onClick"])) :
|
|
249
|
+
onClick: D((f) => W(s), ["stop"])
|
|
250
|
+
}, null, 8, ["onClick"])) : w("", !0)
|
|
231
251
|
])
|
|
232
252
|
], 2))), 128)),
|
|
233
|
-
|
|
234
|
-
|
|
253
|
+
a.multiSelect && (!a.maxFiles || b.value.length < a.maxFiles) ? (r(), c("div", fe, [
|
|
254
|
+
k($, {
|
|
235
255
|
size: "sm",
|
|
236
256
|
variant: "outline",
|
|
237
257
|
icon: "lucide:plus",
|
|
238
258
|
text: "Add more",
|
|
239
|
-
disabled:
|
|
240
|
-
onClick:
|
|
259
|
+
disabled: a.disabled || a.loading || u.value,
|
|
260
|
+
onClick: p
|
|
241
261
|
}, null, 8, ["disabled"])
|
|
242
|
-
])) :
|
|
243
|
-
])) : (
|
|
262
|
+
])) : w("", !0)
|
|
263
|
+
])) : (r(), c("div", {
|
|
244
264
|
key: 0,
|
|
245
|
-
class:
|
|
246
|
-
|
|
247
|
-
|
|
265
|
+
class: S(["border-2 border-dashed border-border rounded-lg p-6 transition-all duration-200 ease-in-out cursor-pointer flex flex-col items-center justify-center text-center gap-2", [
|
|
266
|
+
h.value ? "border-primary bg-primary/5" : "hover:border-primary/50 hover:bg-muted/50",
|
|
267
|
+
a.disabled || a.loading || u.value ? "opacity-50 cursor-not-allowed" : ""
|
|
248
268
|
]]),
|
|
249
|
-
onClick:
|
|
269
|
+
onClick: p
|
|
250
270
|
}, [
|
|
251
|
-
|
|
252
|
-
|
|
271
|
+
n("div", te, [
|
|
272
|
+
a.loading || u.value ? (r(), x(g, {
|
|
253
273
|
key: 0,
|
|
254
274
|
icon: "lucide:loader-2",
|
|
255
275
|
class: "w-6 h-6 animate-spin"
|
|
256
|
-
})) : (
|
|
276
|
+
})) : (r(), x(g, {
|
|
257
277
|
key: 1,
|
|
258
278
|
icon: "lucide:upload-cloud",
|
|
259
279
|
class: "w-6 h-6"
|
|
260
280
|
}))
|
|
261
281
|
]),
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
282
|
+
n("div", ae, [
|
|
283
|
+
t[1] || (t[1] = n("p", { class: "text-sm font-medium text-foreground" }, [
|
|
284
|
+
n("span", { class: "text-primary hover:underline" }, "Click to upload"),
|
|
285
|
+
Q(" or drag and drop ")
|
|
266
286
|
], -1)),
|
|
267
|
-
|
|
287
|
+
a.fileTypes.length ? (r(), c("p", ie, A(a.fileTypes.join(", ")), 1)) : w("", !0)
|
|
268
288
|
])
|
|
269
289
|
], 2)),
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
290
|
+
a.loading || u.value ? (r(), c("div", me, [
|
|
291
|
+
n("div", ge, [
|
|
292
|
+
k(g, {
|
|
273
293
|
icon: "lucide:loader-2",
|
|
274
294
|
class: "w-6 h-6 animate-spin text-primary"
|
|
275
295
|
})
|
|
276
296
|
])
|
|
277
|
-
])) :
|
|
297
|
+
])) : w("", !0)
|
|
278
298
|
], 32))
|
|
279
299
|
])
|
|
280
300
|
]));
|
|
281
301
|
}
|
|
282
302
|
});
|
|
283
303
|
export {
|
|
284
|
-
|
|
304
|
+
ye as default
|
|
285
305
|
};
|