vlite3 1.4.3 → 1.4.5

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.
Files changed (77) hide show
  1. package/components/AppShell/AppShellLayoutStorefront.vue.js +2 -2
  2. package/components/AvatarUploader/AvatarUploader.vue.d.ts +2 -2
  3. package/components/Cart/Cart.vue.d.ts +27 -0
  4. package/components/Cart/Cart.vue.js +242 -0
  5. package/components/Cart/Cart.vue2.js +4 -0
  6. package/components/Cart/CartCouponInput.vue.d.ts +32 -0
  7. package/components/Cart/CartCouponInput.vue.js +176 -0
  8. package/components/Cart/CartCouponInput.vue2.js +4 -0
  9. package/components/Cart/CartEmptyState.vue.d.ts +17 -0
  10. package/components/Cart/CartEmptyState.vue.js +48 -0
  11. package/components/Cart/CartEmptyState.vue2.js +4 -0
  12. package/components/Cart/CartLineItem.vue.d.ts +29 -0
  13. package/components/Cart/CartLineItem.vue.js +341 -0
  14. package/components/Cart/CartLineItem.vue2.js +4 -0
  15. package/components/Cart/CartSummary.vue.d.ts +29 -0
  16. package/components/Cart/CartSummary.vue.js +157 -0
  17. package/components/Cart/CartSummary.vue2.js +4 -0
  18. package/components/Cart/CartVariant1.vue.d.ts +42 -0
  19. package/components/Cart/CartVariant1.vue.js +156 -0
  20. package/components/Cart/CartVariant1.vue2.js +4 -0
  21. package/components/Cart/CartVariant2.vue.d.ts +42 -0
  22. package/components/Cart/CartVariant2.vue.js +154 -0
  23. package/components/Cart/CartVariant2.vue2.js +4 -0
  24. package/components/Cart/CartVariant3.vue.d.ts +41 -0
  25. package/components/Cart/CartVariant3.vue.js +192 -0
  26. package/components/Cart/CartVariant3.vue2.js +4 -0
  27. package/components/Cart/CartVariant4.vue.d.ts +41 -0
  28. package/components/Cart/CartVariant4.vue.js +145 -0
  29. package/components/Cart/CartVariant4.vue2.js +4 -0
  30. package/components/Cart/composables/useCart.d.ts +46 -0
  31. package/components/Cart/composables/useCart.js +110 -0
  32. package/components/Cart/composables/useCartCalculation.d.ts +91 -0
  33. package/components/Cart/composables/useCartCalculation.js +145 -0
  34. package/components/Cart/index.d.ts +9 -0
  35. package/components/Cart/types.d.ts +391 -0
  36. package/components/CategoryManager/CategoryManager.vue.d.ts +2 -2
  37. package/components/CategoryManager/CategoryManager.vue.js +3 -3
  38. package/components/CategoryManager/CategoryManager.vue2.js +224 -248
  39. package/components/CategoryManager/utils.d.ts +3 -0
  40. package/components/CategoryManager/utils.js +31 -0
  41. package/components/CategoryMenu/CategoryMenu.vue.d.ts +2 -0
  42. package/components/CategoryMenu/CategoryMenu.vue.js +46 -40
  43. package/components/CategoryMenu/CategoryMenuVariant1.vue.d.ts +5 -1
  44. package/components/CategoryMenu/CategoryMenuVariant1.vue.js +5 -144
  45. package/components/CategoryMenu/CategoryMenuVariant1.vue2.js +220 -2
  46. package/components/CategoryMenu/CategoryMenuVariant2.vue.d.ts +5 -1
  47. package/components/CategoryMenu/CategoryMenuVariant2.vue.js +5 -160
  48. package/components/CategoryMenu/CategoryMenuVariant2.vue2.js +235 -2
  49. package/components/CategoryMenu/types.d.ts +5 -2
  50. package/components/Clipboard.vue.d.ts +2 -2
  51. package/components/Dropdown/Dropdown.vue.d.ts +1 -0
  52. package/components/Dropdown/Dropdown.vue.js +31 -29
  53. package/components/FilePicker/FilePicker.vue.d.ts +2 -2
  54. package/components/FilePicker/FilePicker.vue.js +278 -202
  55. package/components/Form/CustomFields.vue.d.ts +4 -0
  56. package/components/Form/CustomFields.vue.js +2 -2
  57. package/components/Form/CustomFields.vue2.js +349 -145
  58. package/components/Form/FormField.vue.d.ts +1 -1
  59. package/components/Form/FormField.vue.js +1 -1
  60. package/components/Form/types.d.ts +3 -0
  61. package/components/Modal.vue.d.ts +2 -0
  62. package/components/Modal.vue.js +1 -1
  63. package/components/Modal.vue2.js +30 -28
  64. package/components/OTPInput/OTPInput.vue.d.ts +1 -1
  65. package/components/Rating/Rating.vue.d.ts +1 -1
  66. package/components/Screen/ScreenFilter.vue.js +3 -2
  67. package/components/SidePanel.vue.d.ts +2 -0
  68. package/components/SidePanel.vue.js +1 -1
  69. package/components/SidePanel.vue2.js +25 -23
  70. package/components/SidebarMenu/SidebarMenu.vue.js +145 -128
  71. package/components/index.d.ts +1 -0
  72. package/core/config.d.ts +128 -0
  73. package/index.d.ts +1 -0
  74. package/index.js +327 -306
  75. package/package.json +1 -1
  76. package/style.css +1 -1
  77. package/types/config.type.d.ts +2 -0
@@ -1,23 +1,32 @@
1
- import { defineComponent as te, computed as f, ref as $, useSlots as ie, openBlock as n, createElementBlock as m, createElementVNode as d, renderSlot as ae, normalizeClass as C, createBlock as h, withModifiers as V, createVNode as F, toDisplayString as y, createTextVNode as oe, createCommentVNode as T, Fragment as re, renderList as ne } from "vue";
2
- import p from "../Icon.vue.js";
3
- import P from "../Button.vue.js";
4
- import { $t as S } from "../../utils/i18n.js";
5
- const se = { class: "w-full" }, de = ["multiple", "accept", "data-testid"], ue = ["data-testid"], ce = ["value", "placeholder", "disabled"], fe = { class: "absolute right-3 top-1/2 -translate-y-1/2 flex items-center justify-center gap-2 bg-background" }, me = ["data-testid"], ge = { class: "p-3 bg-muted rounded-full text-muted-foreground" }, pe = { class: "space-y-1" }, ve = { class: "text-sm font-medium text-foreground" }, he = { class: "text-primary hover:underline" }, ye = {
1
+ import { defineComponent as pe, computed as s, ref as N, useSlots as ge, onBeforeUnmount as ve, openBlock as r, createElementBlock as c, normalizeClass as k, createElementVNode as o, renderSlot as he, withKeys as q, withModifiers as w, createVNode as F, toDisplayString as g, createBlock as A, createCommentVNode as z, createTextVNode as ye, Fragment as xe, renderList as be } from "vue";
2
+ import v from "../Icon.vue.js";
3
+ import G from "../Button.vue.js";
4
+ import { $t as C } from "../../utils/i18n.js";
5
+ const ke = ["multiple", "accept", "data-testid"], we = ["data-testid"], Fe = ["aria-disabled", "aria-label", "onKeydown"], Ve = {
6
+ key: 0,
7
+ class: "flex min-w-0 flex-1 items-center gap-2.5"
8
+ }, Se = ["src", "alt"], $e = { class: "min-w-0 flex-1" }, Ae = { class: "truncate font-medium leading-tight text-foreground" }, ze = { class: "truncate text-[11px] leading-tight text-muted-foreground" }, Ce = {
9
+ key: 1,
10
+ class: "flex min-w-0 flex-1 items-center gap-2 text-muted-foreground"
11
+ }, Te = { class: "truncate" }, De = {
12
+ key: 0,
13
+ class: "absolute right-3 top-1/2 -translate-y-1/2 flex items-center justify-center gap-2 bg-background"
14
+ }, Ne = ["data-testid"], je = { class: "p-3 bg-muted rounded-full text-muted-foreground" }, Pe = { class: "space-y-1" }, Be = { class: "text-sm font-medium text-foreground" }, Ue = { class: "text-primary hover:underline" }, Ie = {
6
15
  key: 0,
7
16
  class: "text-xs text-muted-foreground"
8
- }, be = {
17
+ }, Me = {
9
18
  key: 1,
10
19
  class: "space-y-2"
11
- }, xe = { class: "shrink-0 mr-3" }, ke = { class: "p-2 bg-primary-light rounded text-primary-fg-light" }, we = { class: "flex-1 min-w-0 flex flex-col items-start overflow-hidden" }, Ve = {
20
+ }, Le = { class: "shrink-0 mr-3" }, Re = { class: "p-2 bg-primary-light rounded text-primary-fg-light" }, We = { class: "flex-1 min-w-0 flex flex-col items-start overflow-hidden" }, Ee = {
12
21
  key: 0,
13
22
  class: "inline-flex items-center group/rename w-fit max-w-full mb-0.5"
14
- }, Fe = { class: "grid relative w-fit max-w-full items-center -ml-1" }, Se = { class: "invisible whitespace-pre col-start-1 row-start-1 text-sm font-medium px-1 py-0.5 max-w-full overflow-hidden text-ellipsis" }, Ae = ["value", "onInput", "placeholder"], $e = ["title"], Ce = {
23
+ }, Ke = { class: "grid relative w-fit max-w-full items-center -ml-1" }, Oe = { class: "invisible whitespace-pre col-start-1 row-start-1 text-sm font-medium px-1 py-0.5 max-w-full overflow-hidden text-ellipsis" }, qe = ["value", "onInput", "placeholder"], Ge = ["title"], He = {
15
24
  key: 1,
16
25
  class: "text-sm font-medium text-foreground truncate w-full"
17
- }, Te = { class: "text-xs text-muted-foreground -mt-1" }, ze = { class: "shrink-0 ml-3 flex gap-2 items-center" }, De = {
26
+ }, Je = { class: "text-xs text-muted-foreground -mt-1" }, Qe = { class: "shrink-0 ml-3 flex gap-2 items-center" }, Xe = {
18
27
  key: 0,
19
28
  class: "flex gap-2"
20
- }, Me = /* @__PURE__ */ te({
29
+ }, tt = /* @__PURE__ */ pe({
21
30
  name: "FilePicker",
22
31
  __name: "FilePicker",
23
32
  props: {
@@ -38,141 +47,176 @@ const se = { class: "w-full" }, de = ["multiple", "accept", "data-testid"], ue =
38
47
  allowRename: { type: Boolean, default: !1 }
39
48
  },
40
49
  emits: ["update:modelValue", "change", "error"],
41
- setup(a, { emit: M }) {
42
- const e = a, u = M, v = (l, t, i) => {
43
- const r = i ? S(l, i) : S(l);
44
- return r !== l ? r : t;
45
- }, j = f(
46
- () => e.placeholderI18n ? S(e.placeholderI18n) : e.placeholder !== void 0 ? e.placeholder : v("vlite.filePicker.selectFile", "Select file...")
47
- ), U = f(() => e.textI18n ? S(e.textI18n) : v("vlite.filePicker.clickToUpload", "Click to upload")), E = f(() => v("vlite.filePicker.dragAndDrop", "or drag and drop")), R = f(() => v("vlite.filePicker.addMore", "Add more")), L = f(() => v("vlite.filePicker.unknownFile", "Unknown File")), z = f(() => v("vlite.filePicker.enterFileName", "Enter file name")), W = f(() => v("vlite.filePicker.renameFile", "Rename file")), D = $(null), b = $(!1), s = $(!1);
48
- ie();
49
- const O = f(() => e.fileTypes.join(",")), A = f(() => Array.isArray(e.modelValue) ? e.modelValue.length > 0 : e.modelValue !== null), w = f(() => {
50
- let l = [];
51
- return Array.isArray(e.modelValue) ? l = e.modelValue : e.modelValue && (l = [e.modelValue]), l.map((t) => {
52
- if (typeof t == "string") {
53
- const i = t.split("/").pop() || L.value;
50
+ setup(a, { emit: H }) {
51
+ const t = a, f = H, p = (e, l, i) => {
52
+ const d = i ? C(e, i) : C(e);
53
+ return d !== e ? d : l;
54
+ }, j = s(
55
+ () => t.placeholderI18n ? C(t.placeholderI18n) : t.placeholder !== void 0 ? t.placeholder : p("vlite.filePicker.selectFile", "Select file...")
56
+ ), J = s(() => t.textI18n ? C(t.textI18n) : p("vlite.filePicker.clickToUpload", "Click to upload")), Q = s(() => p("vlite.filePicker.dragAndDrop", "or drag and drop")), X = s(() => p("vlite.filePicker.addMore", "Add more")), T = s(() => p("vlite.filePicker.unknownFile", "Unknown File")), P = s(() => p("vlite.filePicker.enterFileName", "Enter file name")), Y = s(() => p("vlite.filePicker.renameFile", "Rename file"));
57
+ s(() => p("vlite.filePicker.emptyTitle", "No file selected")), s(
58
+ () => p("vlite.filePicker.emptyDescription", "Drop a file here or browse from your device")
59
+ );
60
+ const B = N(null), V = N(!1), u = N(!1), U = /* @__PURE__ */ new WeakMap(), D = /* @__PURE__ */ new Set();
61
+ ge();
62
+ const Z = s(() => t.fileTypes.join(",")), b = s(() => Array.isArray(t.modelValue) ? t.modelValue.length > 0 : t.modelValue !== null), y = s(() => {
63
+ let e = [];
64
+ return Array.isArray(t.modelValue) ? e = t.modelValue : t.modelValue && (e = [t.modelValue]), e.map((l) => {
65
+ if (typeof l == "string") {
66
+ const i = l.split("/").pop() || T.value;
54
67
  return {
55
68
  fileName: decodeURIComponent(i),
56
69
  fileType: "unknown",
57
70
  fileSize: 0,
58
71
  file: null,
59
- base64: t,
72
+ base64: l,
60
73
  isUrl: !0
61
74
  };
62
75
  }
63
- return t;
76
+ return l;
64
77
  });
65
78
  }), x = () => {
66
- if (!(e.disabled || e.loading || s.value)) {
67
- if (e.multiSelect && e.maxFiles && (Array.isArray(e.modelValue) ? e.modelValue.length : e.modelValue ? 1 : 0) >= e.maxFiles) {
68
- u("error", `Maximum ${e.maxFiles} files allowed`);
79
+ if (!(t.disabled || t.loading || u.value)) {
80
+ if (t.multiSelect && t.maxFiles && (Array.isArray(t.modelValue) ? t.modelValue.length : t.modelValue ? 1 : 0) >= t.maxFiles) {
81
+ f("error", `Maximum ${t.maxFiles} files allowed`);
69
82
  return;
70
83
  }
71
- D.value?.click();
84
+ B.value?.click();
72
85
  }
73
- }, q = (l) => {
74
- l.preventDefault(), !(e.disabled || e.loading) && (b.value = !0);
75
- }, G = (l) => {
76
- l.preventDefault(), b.value = !1;
77
- }, K = (l) => {
78
- l.preventDefault(), b.value = !1, !(e.disabled || e.loading || s.value) && l.dataTransfer?.files && B(l.dataTransfer.files);
79
- }, H = (l) => {
80
- const t = l.target;
81
- t.files && B(t.files), t.value = "";
82
- }, J = (l) => {
83
- if (l === 0 || !l) return "";
84
- const t = 1024, i = ["Bytes", "KB", "MB", "GB", "TB"], r = Math.floor(Math.log(l) / Math.log(t));
85
- return parseFloat((l / Math.pow(t, r)).toFixed(2)) + " " + i[r];
86
- }, Q = (l) => new Promise((t, i) => {
87
- const r = new FileReader();
88
- r.readAsDataURL(l), r.onload = () => {
89
- typeof r.result == "string" ? t(r.result) : i(new Error("Failed to read file as base64"));
90
- }, r.onerror = (c) => i(c);
91
- }), B = async (l) => {
92
- if (l.length === 0) return;
93
- s.value = !0;
94
- const t = [], i = [], r = Array.from(l);
95
- let c = e.multiSelect ? r : [r[0]];
96
- if (e.multiSelect && e.maxFiles) {
97
- const o = Array.isArray(e.modelValue) ? e.modelValue.length : e.modelValue ? 1 : 0, g = e.maxFiles - o;
98
- if (g <= 0) {
99
- u("error", `Maximum ${e.maxFiles} files allowed`), s.value = !1;
86
+ }, _ = (e) => {
87
+ e.preventDefault(), !(t.disabled || t.loading) && (V.value = !0);
88
+ }, ee = (e) => {
89
+ e.preventDefault(), V.value = !1;
90
+ }, te = (e) => {
91
+ e.preventDefault(), V.value = !1, !(t.disabled || t.loading || u.value) && e.dataTransfer?.files && W(e.dataTransfer.files);
92
+ }, le = (e) => {
93
+ const l = e.target;
94
+ l.files && W(l.files), l.value = "";
95
+ }, I = (e) => {
96
+ if (e === 0 || !e) return "";
97
+ const l = 1024, i = ["Bytes", "KB", "MB", "GB", "TB"], d = Math.floor(Math.log(e) / Math.log(l));
98
+ return parseFloat((e / Math.pow(l, d)).toFixed(2)) + " " + i[d];
99
+ }, M = (e = "") => e.split("?")[0].split("#")[0].split(".").pop()?.toLowerCase() || "", L = (e) => {
100
+ const l = e.fileType || "", i = M(e.fileName || e.base64 || "");
101
+ return l.startsWith("image/") || e.base64?.startsWith("data:image/") || ["apng", "avif", "gif", "jpg", "jpeg", "png", "svg", "webp"].includes(i);
102
+ }, R = (e) => {
103
+ if (!L(e)) return "";
104
+ if (e.base64?.startsWith("data:image/") || e.isUrl) return e.base64;
105
+ if (typeof File < "u" && e.file instanceof File) {
106
+ const l = U.get(e.file);
107
+ if (l) return l;
108
+ const i = URL.createObjectURL(e.file);
109
+ return U.set(e.file, i), D.add(i), i;
110
+ }
111
+ return "";
112
+ }, ie = (e) => {
113
+ const l = e.fileType || "", i = M(e.fileName || e.base64 || "");
114
+ return L(e) ? "lucide:image" : l.includes("pdf") || i === "pdf" || l.includes("word") || l.includes("document") || ["doc", "docx", "odt", "rtf"].includes(i) ? "lucide:file-text" : l.includes("spreadsheet") || l.includes("excel") || ["csv", "xls", "xlsx", "ods"].includes(i) ? "lucide:table" : l.includes("presentation") || ["ppt", "pptx", "odp", "key"].includes(i) ? "lucide:presentation" : l.startsWith("video/") || ["mp4", "mov", "webm", "avi", "mkv"].includes(i) ? "lucide:file-video" : l.startsWith("audio/") || ["mp3", "wav", "ogg", "m4a"].includes(i) ? "lucide:file-audio" : ["zip", "rar", "7z", "tar", "gz"].includes(i) ? "lucide:file-archive" : ["js", "ts", "vue", "html", "css", "json", "xml"].includes(i) ? "lucide:file-code" : "lucide:file";
115
+ }, ae = s(() => t.fileTypes.join(", ")), re = (e) => new Promise((l, i) => {
116
+ const d = new FileReader();
117
+ d.readAsDataURL(e), d.onload = () => {
118
+ typeof d.result == "string" ? l(d.result) : i(new Error("Failed to read file as base64"));
119
+ }, d.onerror = (m) => i(m);
120
+ });
121
+ ve(() => {
122
+ D.forEach((e) => URL.revokeObjectURL(e)), D.clear();
123
+ });
124
+ const W = async (e) => {
125
+ if (e.length === 0) return;
126
+ u.value = !0;
127
+ const l = [], i = [], d = Array.from(e);
128
+ let m = t.multiSelect ? d : [d[0]];
129
+ if (t.multiSelect && t.maxFiles) {
130
+ const n = Array.isArray(t.modelValue) ? t.modelValue.length : t.modelValue ? 1 : 0, h = t.maxFiles - n;
131
+ if (h <= 0) {
132
+ f("error", `Maximum ${t.maxFiles} files allowed`), u.value = !1;
100
133
  return;
101
134
  }
102
- c.length > g && (i.push(`Only ${g} more file(s) allowed. Maximum ${e.maxFiles} files.`), c = c.slice(0, g));
135
+ m.length > h && (i.push(`Only ${h} more file(s) allowed. Maximum ${t.maxFiles} files.`), m = m.slice(0, h));
103
136
  }
104
137
  try {
105
- for (const o of c) {
106
- if (e.fileTypes.length > 0 && !e.fileTypes.some((k) => {
107
- if (k.startsWith("."))
108
- return o.name.toLowerCase().endsWith(k.toLowerCase());
109
- if (k.endsWith("/*")) {
110
- const le = k.split("/")[0];
111
- return o.type.startsWith(le);
138
+ for (const n of m) {
139
+ if (t.fileTypes.length > 0 && !t.fileTypes.some(($) => {
140
+ if ($.startsWith("."))
141
+ return n.name.toLowerCase().endsWith($.toLowerCase());
142
+ if ($.endsWith("/*")) {
143
+ const me = $.split("/")[0];
144
+ return n.type.startsWith(me);
112
145
  }
113
- return o.type === k;
146
+ return n.type === $;
114
147
  })) {
115
- i.push(`File type not allowed: ${o.name}`);
148
+ i.push(`File type not allowed: ${n.name}`);
116
149
  continue;
117
150
  }
118
- let g = !1;
119
- e.maxSize && o.size > e.maxSize && (i.push(`File too large: ${o.name}`), g = !0);
120
- let N = "";
121
- if (e.returnFormat === "base64" && !g)
151
+ let h = !1;
152
+ t.maxSize && n.size > t.maxSize && (i.push(`File too large: ${n.name}`), h = !0);
153
+ let K = "";
154
+ if (t.returnFormat === "base64" && !h)
122
155
  try {
123
- N = await Q(o);
124
- } catch (I) {
125
- console.error("Base64 read failed", I);
156
+ K = await re(n);
157
+ } catch (O) {
158
+ console.error("Base64 read failed", O);
126
159
  }
127
- t.push({
128
- fileName: o.name,
129
- fileType: o.type,
130
- fileSize: o.size,
131
- file: o,
132
- base64: N
160
+ l.push({
161
+ fileName: n.name,
162
+ fileType: n.type,
163
+ fileSize: n.size,
164
+ file: n,
165
+ base64: K
133
166
  });
134
167
  }
135
- if (i.length > 0 && u("error", i.join("; ")), t.length > 0) {
136
- let o;
137
- e.multiSelect ? o = [...Array.isArray(e.modelValue) ? e.modelValue : e.modelValue ? [e.modelValue] : [], ...t] : o = t[0], u("update:modelValue", o), u("change", o);
168
+ if (i.length > 0 && f("error", i.join("; ")), l.length > 0) {
169
+ let n;
170
+ t.multiSelect ? n = [...Array.isArray(t.modelValue) ? t.modelValue : t.modelValue ? [t.modelValue] : [], ...l] : n = l[0], f("update:modelValue", n), f("change", n);
138
171
  }
139
- } catch (o) {
140
- console.error("Error processing files:", o), u("error", "Failed to process files");
172
+ } catch (n) {
173
+ console.error("Error processing files:", n), f("error", "Failed to process files");
141
174
  } finally {
142
- s.value = !1;
175
+ u.value = !1;
143
176
  }
144
- }, X = (l) => {
145
- if (!(e.disabled || e.loading))
146
- if (e.multiSelect && Array.isArray(e.modelValue)) {
147
- const t = [...e.modelValue];
148
- t.splice(l, 1), u("update:modelValue", t), u("change", t);
177
+ }, ne = (e) => {
178
+ if (!(t.disabled || t.loading))
179
+ if (t.multiSelect && Array.isArray(t.modelValue)) {
180
+ const l = [...t.modelValue];
181
+ l.splice(e, 1), f("update:modelValue", l), f("change", l);
149
182
  } else
150
- u("update:modelValue", null), u("change", null);
151
- }, Y = () => {
152
- e.disabled || e.loading || (u("update:modelValue", null), u("change", null));
153
- }, Z = (l, t) => {
154
- if (e.disabled || e.loading || s.value) return;
183
+ f("update:modelValue", null), f("change", null);
184
+ }, se = () => {
185
+ t.disabled || t.loading || (f("update:modelValue", null), f("change", null));
186
+ }, oe = (e, l) => {
187
+ if (t.disabled || t.loading || u.value) return;
155
188
  let i;
156
- e.multiSelect && Array.isArray(e.modelValue) ? (i = [...e.modelValue], typeof i[l] == "object" && i[l] !== null ? i[l] = { ...i[l], fileName: t } : typeof i[l] == "string" && (i[l] = {
157
- fileName: t,
189
+ t.multiSelect && Array.isArray(t.modelValue) ? (i = [...t.modelValue], typeof i[e] == "object" && i[e] !== null ? i[e] = { ...i[e], fileName: l } : typeof i[e] == "string" && (i[e] = {
190
+ fileName: l,
158
191
  fileType: "unknown",
159
192
  fileSize: 0,
160
193
  file: null,
161
- base64: i[l],
194
+ base64: i[e],
162
195
  isUrl: !0
163
- })) : e.modelValue && typeof e.modelValue == "object" && !Array.isArray(e.modelValue) ? i = { ...e.modelValue, fileName: t } : typeof e.modelValue == "string" && (i = {
164
- fileName: t,
196
+ })) : t.modelValue && typeof t.modelValue == "object" && !Array.isArray(t.modelValue) ? i = { ...t.modelValue, fileName: l } : typeof t.modelValue == "string" && (i = {
197
+ fileName: l,
165
198
  fileType: "unknown",
166
199
  fileSize: 0,
167
200
  file: null,
168
- base64: e.modelValue,
201
+ base64: t.modelValue,
169
202
  isUrl: !0
170
- }), i !== void 0 && (u("update:modelValue", i), u("change", i));
171
- }, _ = f(() => A.value ? w.value.map((t) => t.fileName).join(", ") : ""), ee = f(() => {
172
- 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 = {
173
- sm: "h-8 text-xs",
174
- md: "h-10 text-sm",
175
- lg: "h-12 text-base"
203
+ }), i !== void 0 && (f("update:modelValue", i), f("change", i));
204
+ }, de = s(() => b.value ? y.value.map((l) => l.fileName).join(", ") : ""), S = s(() => y.value[0]), ue = s(() => {
205
+ if (!b.value) return "";
206
+ const e = y.value, l = e[0]?.fileName || T.value;
207
+ return !t.multiSelect || e.length <= 1 ? l : `${l} +${e.length - 1}`;
208
+ }), ce = s(() => {
209
+ const e = y.value;
210
+ if (!e.length) return ae.value;
211
+ if (t.multiSelect && e.length > 1)
212
+ return `${e.length} files selected`;
213
+ const l = e[0];
214
+ return I(l.fileSize) || l.fileType || T.value;
215
+ }), fe = s(() => {
216
+ const e = "group flex w-full items-center bg-background text-sm ring-offset-background transition-all focus-visible:outline-none cursor-pointer", l = {
217
+ sm: "min-h-8 px-2 py-1 text-xs gap-2",
218
+ md: "min-h-10 px-3 py-1.5 text-sm gap-2.5",
219
+ lg: "min-h-12 px-3 py-2 text-base gap-3"
176
220
  }, i = {
177
221
  none: "rounded-none",
178
222
  sm: "rounded-sm",
@@ -183,179 +227,211 @@ const se = { class: "w-full" }, de = ["multiple", "accept", "data-testid"], ue =
183
227
  full: "rounded-full"
184
228
  };
185
229
  return [
186
- l,
230
+ e,
187
231
  "border border-input focus-visible:border-primary",
188
232
  // Default outline style
189
- t[e.size],
190
- i[e.rounded],
191
- "pr-10",
192
- // Space for icon
193
- e.disabled ? "cursor-not-allowed opacity-50" : ""
233
+ l[t.size],
234
+ i[t.rounded],
235
+ "pr-10 text-left",
236
+ // Space for action icon
237
+ t.disabled ? "cursor-not-allowed opacity-50" : ""
194
238
  ].join(" ");
195
- });
196
- return (l, t) => (n(), m("div", se, [
197
- d("input", {
239
+ }), E = s(() => ({
240
+ sm: "h-6 w-6 rounded",
241
+ md: "h-7 w-7 rounded-md",
242
+ lg: "h-8 w-8 rounded-md"
243
+ })[t.size]);
244
+ return (e, l) => (r(), c("div", {
245
+ class: k(["vl-file-picker w-full", { "vl-file-picker--input": a.variant === "input" }])
246
+ }, [
247
+ o("input", {
198
248
  ref_key: "fileInput",
199
- ref: D,
249
+ ref: B,
200
250
  type: "file",
201
251
  multiple: a.multiSelect,
202
- accept: O.value,
252
+ accept: Z.value,
203
253
  class: "hidden",
204
- "data-testid": l.$attrs["data-testid"] ? `${l.$attrs["data-testid"]}-input` : l.$attrs.name ? `filepicker-input-${l.$attrs.name}` : "filepicker-input",
205
- onChange: H
206
- }, null, 40, de),
207
- ae(l.$slots, "trigger", {
254
+ "data-testid": e.$attrs["data-testid"] ? `${e.$attrs["data-testid"]}-input` : e.$attrs.name ? `filepicker-input-${e.$attrs.name}` : "filepicker-input",
255
+ onChange: le
256
+ }, null, 40, ke),
257
+ he(e.$slots, "trigger", {
208
258
  trigger: x,
209
- isDragging: b.value,
210
- isLoading: a.loading || s.value,
211
- files: w.value
259
+ isDragging: V.value,
260
+ isLoading: a.loading || u.value,
261
+ files: y.value
212
262
  }, () => [
213
- a.variant === "input" ? (n(), m("div", {
263
+ a.variant === "input" ? (r(), c("div", {
214
264
  key: 0,
215
265
  class: "relative",
216
- onClick: x,
217
- "data-testid": l.$attrs["data-testid"] || (l.$attrs.name ? `filepicker-${l.$attrs.name}` : "filepicker")
266
+ "data-testid": e.$attrs["data-testid"] || (e.$attrs.name ? `filepicker-${e.$attrs.name}` : "filepicker")
218
267
  }, [
219
- d("input", {
220
- type: "text",
221
- value: _.value,
222
- placeholder: j.value,
223
- readonly: "",
224
- class: C(ee.value),
225
- disabled: a.disabled || a.loading || s.value
226
- }, null, 10, ce),
227
- d("div", fe, [
228
- a.loading || s.value ? (n(), h(p, {
268
+ o("div", {
269
+ role: "button",
270
+ tabindex: "0",
271
+ "aria-disabled": a.disabled || a.loading || u.value,
272
+ "aria-label": de.value || j.value,
273
+ class: k(fe.value),
274
+ onClick: x,
275
+ onKeydown: [
276
+ q(w(x, ["prevent"]), ["enter"]),
277
+ q(w(x, ["prevent"]), ["space"])
278
+ ]
279
+ }, [
280
+ b.value && S.value ? (r(), c("div", Ve, [
281
+ R(S.value) ? (r(), c("img", {
282
+ key: 0,
283
+ src: R(S.value),
284
+ alt: S.value.fileName,
285
+ class: k(["shrink-0 border border-border bg-muted object-cover", E.value])
286
+ }, null, 10, Se)) : (r(), c("div", {
287
+ key: 1,
288
+ class: k(["shrink-0 border border-primary/15 bg-primary/10 text-primary flex items-center justify-center", E.value])
289
+ }, [
290
+ F(v, {
291
+ icon: ie(S.value),
292
+ class: "h-4 w-4"
293
+ }, null, 8, ["icon"])
294
+ ], 2)),
295
+ o("div", $e, [
296
+ o("p", Ae, g(ue.value), 1),
297
+ o("p", ze, g(ce.value), 1)
298
+ ])
299
+ ])) : (r(), c("div", Ce, [
300
+ F(v, {
301
+ icon: "lucide:upload",
302
+ class: "h-4 w-4 shrink-0"
303
+ }),
304
+ o("span", Te, g(j.value), 1)
305
+ ]))
306
+ ], 42, Fe),
307
+ a.loading || u.value || b.value && !a.disabled ? (r(), c("div", De, [
308
+ a.loading || u.value ? (r(), A(v, {
229
309
  key: 0,
230
310
  icon: "lucide:loader-2",
231
311
  class: "h-4 w-4 animate-spin text-muted-foreground"
232
- })) : A.value && !a.disabled ? (n(), m("button", {
312
+ })) : b.value && !a.disabled ? (r(), c("button", {
233
313
  key: 1,
234
314
  type: "button",
235
315
  class: "text-muted-foreground hover:text-foreground focus:outline-none",
236
- onClick: V(Y, ["stop"])
316
+ onClick: w(se, ["stop"])
237
317
  }, [
238
- F(p, {
318
+ F(v, {
239
319
  icon: "lucide:x-circle",
240
320
  class: "h-4 w-4"
241
321
  })
242
- ])) : (n(), h(p, {
243
- key: 2,
244
- icon: "lucide:upload",
245
- class: "h-4 w-4 text-muted-foreground"
246
- }))
247
- ])
248
- ], 8, ue)) : (n(), m("div", {
322
+ ])) : z("", !0)
323
+ ])) : z("", !0)
324
+ ], 8, we)) : (r(), c("div", {
249
325
  key: 1,
250
326
  class: "relative",
251
- onDragover: q,
252
- onDragleave: G,
253
- onDrop: K,
254
- "data-testid": l.$attrs["data-testid"] || (l.$attrs.name ? `filepicker-${l.$attrs.name}` : "filepicker")
327
+ onDragover: _,
328
+ onDragleave: ee,
329
+ onDrop: te,
330
+ "data-testid": e.$attrs["data-testid"] || (e.$attrs.name ? `filepicker-${e.$attrs.name}` : "filepicker")
255
331
  }, [
256
- A.value ? (n(), m("div", be, [
257
- (n(!0), m(re, null, ne(w.value, (i, r) => (n(), m("div", {
258
- key: r,
259
- class: C(["relative flex items-center p-3 border border-border rounded-lg bg-body transition-colors group", [
260
- !a.multiSelect && !a.disabled && !a.loading && !s.value ? "cursor-pointer hover:border-primary/50" : ""
332
+ b.value ? (r(), c("div", Me, [
333
+ (r(!0), c(xe, null, be(y.value, (i, d) => (r(), c("div", {
334
+ key: d,
335
+ class: k(["relative flex items-center p-3 border border-border rounded-lg bg-body transition-colors group", [
336
+ !a.multiSelect && !a.disabled && !a.loading && !u.value ? "cursor-pointer hover:border-primary/50" : ""
261
337
  ]]),
262
- onClick: t[2] || (t[2] = (c) => !a.multiSelect && !a.disabled && !a.loading && !s.value ? x() : null)
338
+ onClick: l[2] || (l[2] = (m) => !a.multiSelect && !a.disabled && !a.loading && !u.value ? x() : null)
263
339
  }, [
264
- d("div", xe, [
265
- d("div", ke, [
266
- F(p, {
340
+ o("div", Le, [
341
+ o("div", Re, [
342
+ F(v, {
267
343
  icon: "lucide:file-text",
268
344
  class: "w-5 h-5"
269
345
  })
270
346
  ])
271
347
  ]),
272
- d("div", we, [
273
- a.allowRename && !a.disabled && !a.loading && !s.value ? (n(), m("div", Ve, [
274
- d("div", Fe, [
275
- d("span", Se, y(i.fileName || z.value), 1),
276
- d("input", {
348
+ o("div", We, [
349
+ a.allowRename && !a.disabled && !a.loading && !u.value ? (r(), c("div", Ee, [
350
+ o("div", Ke, [
351
+ o("span", Oe, g(i.fileName || P.value), 1),
352
+ o("input", {
277
353
  value: i.fileName,
278
- onClick: t[0] || (t[0] = V(() => {
354
+ onClick: l[0] || (l[0] = w(() => {
279
355
  }, ["stop"])),
280
- onInput: (c) => Z(r, c.target.value),
356
+ onInput: (m) => oe(d, m.target.value),
281
357
  class: "col-start-1 row-start-1 w-auto min-w-[2ch] text-sm font-medium text-foreground bg-transparent border-b border-transparent hover:border-border focus:border-primary outline-none transition-colors py-0.5 px-1",
282
- placeholder: z.value
283
- }, null, 40, Ae)
358
+ placeholder: P.value
359
+ }, null, 40, qe)
284
360
  ]),
285
- d("div", {
361
+ o("div", {
286
362
  class: "shrink-0 ml-1 text-muted-foreground/50 group-hover/rename:text-foreground transition-colors cursor-text",
287
- onClick: t[1] || (t[1] = V(
288
- (c) => c.currentTarget.previousElementSibling?.querySelector("input")?.focus(),
363
+ onClick: l[1] || (l[1] = w(
364
+ (m) => m.currentTarget.previousElementSibling?.querySelector("input")?.focus(),
289
365
  ["stop"]
290
366
  )),
291
- title: W.value
367
+ title: Y.value
292
368
  }, [
293
- F(p, {
369
+ F(v, {
294
370
  icon: "lucide:pencil",
295
371
  class: "w-3 h-3"
296
372
  })
297
- ], 8, $e)
298
- ])) : (n(), m("p", Ce, y(i.fileName), 1)),
299
- d("p", Te, y(J(i.fileSize)), 1)
373
+ ], 8, Ge)
374
+ ])) : (r(), c("p", He, g(i.fileName), 1)),
375
+ o("p", Je, g(I(i.fileSize)), 1)
300
376
  ]),
301
- d("div", ze, [
302
- a.loading || s.value ? (n(), h(p, {
377
+ o("div", Qe, [
378
+ a.loading || u.value ? (r(), A(v, {
303
379
  key: 0,
304
380
  icon: "lucide:loader-2",
305
381
  class: "w-4 h-4 animate-spin text-primary"
306
- })) : a.disabled ? T("", !0) : (n(), h(P, {
382
+ })) : a.disabled ? z("", !0) : (r(), A(G, {
307
383
  key: 1,
308
384
  size: "xs",
309
385
  variant: "ghost",
310
386
  icon: "lucide:x",
311
387
  rounded: "full",
312
388
  class: "text-muted-foreground hover:text-destructive hover:bg-destructive/10",
313
- onClick: V((c) => X(r), ["stop"])
389
+ onClick: w((m) => ne(d), ["stop"])
314
390
  }, null, 8, ["onClick"]))
315
391
  ])
316
392
  ], 2))), 128)),
317
- a.multiSelect && (!a.maxFiles || w.value.length < a.maxFiles) ? (n(), m("div", De, [
318
- F(P, {
393
+ a.multiSelect && (!a.maxFiles || y.value.length < a.maxFiles) ? (r(), c("div", Xe, [
394
+ F(G, {
319
395
  size: "sm",
320
396
  variant: "outline",
321
397
  icon: "lucide:plus",
322
- text: R.value,
323
- disabled: a.disabled || a.loading || s.value,
398
+ text: X.value,
399
+ disabled: a.disabled || a.loading || u.value,
324
400
  onClick: x
325
401
  }, null, 8, ["text", "disabled"])
326
- ])) : T("", !0)
327
- ])) : (n(), m("div", {
402
+ ])) : z("", !0)
403
+ ])) : (r(), c("div", {
328
404
  key: 0,
329
- class: C(["border-2 bg-body 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", [
330
- b.value ? "border-primary bg-primary/5" : "hover:border-primary/50 ",
331
- a.disabled || a.loading || s.value ? "opacity-50 cursor-not-allowed" : ""
405
+ class: k(["border-2 bg-body 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", [
406
+ V.value ? "border-primary bg-primary/5" : "hover:border-primary/50 ",
407
+ a.disabled || a.loading || u.value ? "opacity-50 cursor-not-allowed" : ""
332
408
  ]]),
333
409
  onClick: x
334
410
  }, [
335
- d("div", ge, [
336
- a.loading || s.value ? (n(), h(p, {
411
+ o("div", je, [
412
+ a.loading || u.value ? (r(), A(v, {
337
413
  key: 0,
338
414
  icon: "lucide:loader-2",
339
415
  class: "w-6 h-6 animate-spin"
340
- })) : (n(), h(p, {
416
+ })) : (r(), A(v, {
341
417
  key: 1,
342
418
  icon: "lucide:upload-cloud",
343
419
  class: "w-6 h-6"
344
420
  }))
345
421
  ]),
346
- d("div", pe, [
347
- d("p", ve, [
348
- d("span", he, y(U.value), 1),
349
- oe(" " + y(E.value), 1)
422
+ o("div", Pe, [
423
+ o("p", Be, [
424
+ o("span", Ue, g(J.value), 1),
425
+ ye(" " + g(Q.value), 1)
350
426
  ]),
351
- a.fileTypes.length ? (n(), m("p", ye, y(a.fileTypes.join(", ")), 1)) : T("", !0)
427
+ a.fileTypes.length ? (r(), c("p", Ie, g(a.fileTypes.join(", ")), 1)) : z("", !0)
352
428
  ])
353
429
  ], 2))
354
- ], 40, me))
430
+ ], 40, Ne))
355
431
  ])
356
- ]));
432
+ ], 2));
357
433
  }
358
434
  });
359
435
  export {
360
- Me as default
436
+ tt as default
361
437
  };