@adamosuiteservices/ui 2.17.1 → 2.18.1
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/README.md +2 -2
- package/dist/components/ui/file-upload/file-upload.d.ts +5 -1
- package/dist/components/ui/file-upload-v2/file-upload-v2.d.ts +35 -0
- package/dist/components/ui/file-upload-v2/index.d.ts +1 -0
- package/dist/file-upload-v2.cjs +8 -0
- package/dist/file-upload-v2.js +339 -0
- package/dist/file-upload.cjs +4 -4
- package/dist/file-upload.js +160 -153
- package/dist/styles.css +1 -1
- package/docs/ai-guide.md +7 -7
- package/docs/components/ui/file-upload-v2.md +1116 -0
- package/docs/components/ui/file-upload.md +210 -0
- package/llm.txt +8 -5
- package/package.json +5 -1
package/dist/file-upload.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { B
|
|
3
|
-
import { I as
|
|
4
|
-
import { T as
|
|
1
|
+
import { j as t } from "./jsx-runtime-BzflLqGi.js";
|
|
2
|
+
import { B } from "./button-BnUlAtuD.js";
|
|
3
|
+
import { I as A } from "./icon-BFQz1tQC.js";
|
|
4
|
+
import { T as $ } from "./typography-MnY0LQoZ.js";
|
|
5
5
|
import { c as v } from "./index-CRiPKpXj.js";
|
|
6
|
-
import { useState as
|
|
7
|
-
function
|
|
8
|
-
isDragging:
|
|
6
|
+
import { useState as U, useRef as P, useEffect as F } from "react";
|
|
7
|
+
function S({
|
|
8
|
+
isDragging: i,
|
|
9
9
|
isMultiple: d,
|
|
10
10
|
invalid: a,
|
|
11
11
|
disabled: r,
|
|
12
12
|
accept: m,
|
|
13
|
-
acceptedExtensions:
|
|
14
|
-
maxSizeInMB:
|
|
15
|
-
maxFiles:
|
|
16
|
-
labels:
|
|
17
|
-
input:
|
|
18
|
-
onDragOver:
|
|
13
|
+
acceptedExtensions: c,
|
|
14
|
+
maxSizeInMB: h,
|
|
15
|
+
maxFiles: f,
|
|
16
|
+
labels: l,
|
|
17
|
+
input: p,
|
|
18
|
+
onDragOver: g,
|
|
19
19
|
onDragLeave: w,
|
|
20
|
-
onDrop:
|
|
21
|
-
onFileChange:
|
|
20
|
+
onDrop: j,
|
|
21
|
+
onFileChange: T
|
|
22
22
|
}) {
|
|
23
|
-
const
|
|
24
|
-
return /* @__PURE__ */
|
|
23
|
+
const y = p?.id || `file-upload-${Math.random().toString(36).substring(2, 11)}`;
|
|
24
|
+
return /* @__PURE__ */ t.jsxs(
|
|
25
25
|
"div",
|
|
26
26
|
{
|
|
27
|
-
onDragOver: r ? void 0 :
|
|
27
|
+
onDragOver: r ? void 0 : g,
|
|
28
28
|
onDragLeave: r ? void 0 : w,
|
|
29
|
-
onDrop: r ? void 0 :
|
|
29
|
+
onDrop: r ? void 0 : j,
|
|
30
30
|
className: v(
|
|
31
31
|
`
|
|
32
32
|
adm:flex adm:flex-col adm:items-center adm:gap-6 adm:rounded-2xl
|
|
@@ -34,22 +34,22 @@ function Y({
|
|
|
34
34
|
`,
|
|
35
35
|
"adm:border-dashed adm:bg-background adm:p-6 adm:transition-colors",
|
|
36
36
|
{
|
|
37
|
-
"adm:border-primary":
|
|
37
|
+
"adm:border-primary": i && !a && !r,
|
|
38
38
|
"adm:border-destructive": a && !r,
|
|
39
|
-
"adm:border-input": !
|
|
39
|
+
"adm:border-input": !i && !a,
|
|
40
40
|
"adm:cursor-not-allowed adm:opacity-50": r
|
|
41
41
|
}
|
|
42
42
|
),
|
|
43
43
|
children: [
|
|
44
|
-
/* @__PURE__ */
|
|
44
|
+
/* @__PURE__ */ t.jsx(
|
|
45
45
|
"div",
|
|
46
46
|
{
|
|
47
47
|
className: v(
|
|
48
48
|
"adm:flex adm:items-center adm:justify-center adm:rounded-xl adm:p-2.5",
|
|
49
49
|
a && !r ? "adm:bg-destructive/10" : "adm:bg-primary-50"
|
|
50
50
|
),
|
|
51
|
-
children: /* @__PURE__ */
|
|
52
|
-
|
|
51
|
+
children: /* @__PURE__ */ t.jsx(
|
|
52
|
+
A,
|
|
53
53
|
{
|
|
54
54
|
symbol: "text_snippet",
|
|
55
55
|
className: a && !r ? "adm:text-destructive" : "adm:text-primary"
|
|
@@ -57,24 +57,24 @@ function Y({
|
|
|
57
57
|
)
|
|
58
58
|
}
|
|
59
59
|
),
|
|
60
|
-
/* @__PURE__ */
|
|
61
|
-
/* @__PURE__ */
|
|
62
|
-
/* @__PURE__ */
|
|
63
|
-
/* @__PURE__ */
|
|
60
|
+
/* @__PURE__ */ t.jsxs("div", { className: "adm:flex adm:flex-col adm:items-center adm:gap-2", children: [
|
|
61
|
+
/* @__PURE__ */ t.jsx($, { color: a && !r ? "destructive" : void 0, children: l?.dragDrop || (d ? "Drag and drop your files here or" : "Drag and drop your file here or") }),
|
|
62
|
+
/* @__PURE__ */ t.jsxs("label", { htmlFor: y, children: [
|
|
63
|
+
/* @__PURE__ */ t.jsx(
|
|
64
64
|
"input",
|
|
65
65
|
{
|
|
66
|
-
...
|
|
67
|
-
id:
|
|
66
|
+
...p,
|
|
67
|
+
id: y,
|
|
68
68
|
type: "file",
|
|
69
69
|
accept: m,
|
|
70
70
|
multiple: d,
|
|
71
|
-
onChange:
|
|
71
|
+
onChange: T,
|
|
72
72
|
disabled: r,
|
|
73
73
|
className: "adm:hidden"
|
|
74
74
|
}
|
|
75
75
|
),
|
|
76
|
-
/* @__PURE__ */
|
|
77
|
-
|
|
76
|
+
/* @__PURE__ */ t.jsx(
|
|
77
|
+
B,
|
|
78
78
|
{
|
|
79
79
|
asChild: !0,
|
|
80
80
|
type: "button",
|
|
@@ -83,18 +83,18 @@ function Y({
|
|
|
83
83
|
adm:pointer-events-none
|
|
84
84
|
`),
|
|
85
85
|
disabled: r,
|
|
86
|
-
children: /* @__PURE__ */
|
|
86
|
+
children: /* @__PURE__ */ t.jsx("span", { children: l?.selectFile || (d ? "Select files" : "Select the file") })
|
|
87
87
|
}
|
|
88
88
|
)
|
|
89
89
|
] })
|
|
90
90
|
] }),
|
|
91
|
-
/* @__PURE__ */
|
|
91
|
+
/* @__PURE__ */ t.jsx($, { className: "adm:text-center", color: a && !r ? "destructive" : "muted", children: l?.fileRequirements || (c && c.length > 0 ? `Allowed files: ${c.join(", ")}. Maximum size ${h} MB${d ? `. Up to ${f} files` : ""}.` : `Maximum size ${h} MB${d ? `. Up to ${f} files` : ""}.`) })
|
|
92
92
|
]
|
|
93
93
|
}
|
|
94
94
|
);
|
|
95
95
|
}
|
|
96
|
-
function
|
|
97
|
-
return /* @__PURE__ */
|
|
96
|
+
function ee({ file: i, invalid: d, disabled: a, onRemove: r }) {
|
|
97
|
+
return /* @__PURE__ */ t.jsxs(
|
|
98
98
|
"div",
|
|
99
99
|
{
|
|
100
100
|
className: v(
|
|
@@ -103,15 +103,15 @@ function Z({ file: n, invalid: d, disabled: a, onRemove: r }) {
|
|
|
103
103
|
a && "adm:cursor-not-allowed adm:opacity-50"
|
|
104
104
|
),
|
|
105
105
|
children: [
|
|
106
|
-
/* @__PURE__ */
|
|
106
|
+
/* @__PURE__ */ t.jsx(
|
|
107
107
|
"div",
|
|
108
108
|
{
|
|
109
109
|
className: v(
|
|
110
110
|
"adm:flex adm:items-center adm:justify-center adm:rounded-xl adm:p-2.5",
|
|
111
111
|
d && !a ? "adm:bg-destructive/10" : "adm:bg-primary-50"
|
|
112
112
|
),
|
|
113
|
-
children: /* @__PURE__ */
|
|
114
|
-
|
|
113
|
+
children: /* @__PURE__ */ t.jsx(
|
|
114
|
+
A,
|
|
115
115
|
{
|
|
116
116
|
symbol: "text_snippet",
|
|
117
117
|
className: d && !a ? "adm:text-destructive" : "adm:text-primary"
|
|
@@ -119,199 +119,206 @@ function Z({ file: n, invalid: d, disabled: a, onRemove: r }) {
|
|
|
119
119
|
)
|
|
120
120
|
}
|
|
121
121
|
),
|
|
122
|
-
/* @__PURE__ */
|
|
122
|
+
/* @__PURE__ */ t.jsxs(
|
|
123
123
|
"div",
|
|
124
124
|
{
|
|
125
125
|
className: `
|
|
126
126
|
adm:flex adm:min-w-0 adm:flex-1 adm:items-start adm:gap-3
|
|
127
127
|
`,
|
|
128
128
|
children: [
|
|
129
|
-
/* @__PURE__ */
|
|
130
|
-
/* @__PURE__ */
|
|
131
|
-
(
|
|
129
|
+
/* @__PURE__ */ t.jsx("div", { className: "adm:min-w-0 adm:flex-1", children: /* @__PURE__ */ t.jsx($, { className: "adm:truncate adm:font-semibold", children: i.name }) }),
|
|
130
|
+
/* @__PURE__ */ t.jsxs($, { className: "adm:shrink-0", color: "muted", children: [
|
|
131
|
+
(i.size / 1024 / 1024).toFixed(1),
|
|
132
132
|
" MB"
|
|
133
133
|
] })
|
|
134
134
|
]
|
|
135
135
|
}
|
|
136
136
|
),
|
|
137
|
-
/* @__PURE__ */
|
|
138
|
-
|
|
137
|
+
/* @__PURE__ */ t.jsx(
|
|
138
|
+
B,
|
|
139
139
|
{
|
|
140
140
|
variant: "destructive-medium",
|
|
141
141
|
onClick: r,
|
|
142
142
|
type: "button",
|
|
143
143
|
disabled: a,
|
|
144
|
-
children: /* @__PURE__ */
|
|
144
|
+
children: /* @__PURE__ */ t.jsx(A, { symbol: "delete", className: "adm:text-destructive" })
|
|
145
145
|
}
|
|
146
146
|
)
|
|
147
147
|
]
|
|
148
148
|
}
|
|
149
149
|
);
|
|
150
150
|
}
|
|
151
|
-
function
|
|
152
|
-
return
|
|
153
|
-
d &&
|
|
154
|
-
/* @__PURE__ */
|
|
155
|
-
/* @__PURE__ */
|
|
156
|
-
|
|
151
|
+
function R({ files: i, isMultiple: d, invalid: a, disabled: r, labels: m, onRemoveFile: c, onClearAll: h }) {
|
|
152
|
+
return i.length === 0 ? null : /* @__PURE__ */ t.jsxs("div", { className: "adm:flex adm:flex-col adm:gap-3", children: [
|
|
153
|
+
d && i.length > 1 && /* @__PURE__ */ t.jsxs("div", { className: "adm:flex adm:items-center adm:justify-between", children: [
|
|
154
|
+
/* @__PURE__ */ t.jsx($, { className: "adm:text-sm adm:font-medium", color: a && !r ? "destructive" : void 0, children: m?.filesSelected?.(i.length) || `${i.length} file${i.length !== 1 ? "s" : ""} selected` }),
|
|
155
|
+
/* @__PURE__ */ t.jsx(
|
|
156
|
+
B,
|
|
157
157
|
{
|
|
158
158
|
variant: "ghost",
|
|
159
159
|
size: "sm",
|
|
160
|
-
onClick:
|
|
160
|
+
onClick: h,
|
|
161
161
|
type: "button",
|
|
162
162
|
disabled: r,
|
|
163
163
|
children: "Clear all"
|
|
164
164
|
}
|
|
165
165
|
)
|
|
166
166
|
] }),
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
i.map((f, l) => /* @__PURE__ */ t.jsx(
|
|
168
|
+
ee,
|
|
169
169
|
{
|
|
170
|
-
file:
|
|
170
|
+
file: f,
|
|
171
171
|
invalid: a,
|
|
172
172
|
disabled: r,
|
|
173
|
-
onRemove: () => l
|
|
173
|
+
onRemove: () => c(l)
|
|
174
174
|
},
|
|
175
|
-
`${
|
|
175
|
+
`${f.name}-${l}`
|
|
176
176
|
))
|
|
177
177
|
] });
|
|
178
178
|
}
|
|
179
|
-
function
|
|
180
|
-
className:
|
|
179
|
+
function de({
|
|
180
|
+
className: i,
|
|
181
181
|
selectedFile: d,
|
|
182
182
|
selectedFiles: a,
|
|
183
183
|
onFileSelect: r,
|
|
184
184
|
onFilesSelect: m,
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
185
|
+
onFileAdd: c,
|
|
186
|
+
onFileRemove: h,
|
|
187
|
+
onFilesAdd: f,
|
|
188
|
+
onFilesRemove: l,
|
|
189
|
+
onInvalidFile: p,
|
|
190
|
+
acceptedExtensions: g,
|
|
191
|
+
maxSizeInMB: w = 50,
|
|
192
|
+
maxFiles: j = 10,
|
|
193
|
+
multiple: T = !1,
|
|
194
|
+
filesPosition: y = "below",
|
|
195
|
+
invalid: V = !1,
|
|
196
|
+
disabled: _ = !1,
|
|
197
|
+
"aria-invalid": M,
|
|
198
|
+
labels: C,
|
|
199
|
+
input: q,
|
|
200
|
+
...G
|
|
197
201
|
}) {
|
|
198
|
-
const [
|
|
199
|
-
|
|
200
|
-
const
|
|
201
|
-
if (
|
|
202
|
-
const
|
|
203
|
-
|
|
202
|
+
const [H, I] = U(!1), [J, K] = U(!1), b = P(null);
|
|
203
|
+
F(() => {
|
|
204
|
+
const e = () => {
|
|
205
|
+
if (b.current) {
|
|
206
|
+
const n = b.current.closest("fieldset");
|
|
207
|
+
K(n?.disabled ?? !1);
|
|
204
208
|
}
|
|
205
209
|
};
|
|
206
|
-
|
|
207
|
-
const s = new MutationObserver(
|
|
208
|
-
if (
|
|
209
|
-
const
|
|
210
|
-
|
|
210
|
+
e();
|
|
211
|
+
const s = new MutationObserver(e);
|
|
212
|
+
if (b.current) {
|
|
213
|
+
const n = b.current.closest("fieldset");
|
|
214
|
+
n && s.observe(n, { attributes: !0, attributeFilter: ["disabled"] });
|
|
211
215
|
}
|
|
212
216
|
return () => s.disconnect();
|
|
213
217
|
}, []);
|
|
214
|
-
const
|
|
215
|
-
u || (
|
|
216
|
-
},
|
|
217
|
-
u || (
|
|
218
|
-
},
|
|
218
|
+
const Q = g?.join(",") || "", W = w * 1024 * 1024, o = T || a !== void 0 || m !== void 0, x = o ? a || [] : d ? [d] : [], k = V || M, u = _ || J, X = (e) => {
|
|
219
|
+
u || (e.preventDefault(), I(!0));
|
|
220
|
+
}, Y = (e) => {
|
|
221
|
+
u || (e.preventDefault(), I(!1));
|
|
222
|
+
}, Z = (e) => {
|
|
219
223
|
if (!u)
|
|
220
|
-
if (
|
|
221
|
-
const
|
|
222
|
-
if (
|
|
223
|
-
const
|
|
224
|
-
m && m(
|
|
224
|
+
if (e.preventDefault(), I(!1), o) {
|
|
225
|
+
const n = Array.from(e.dataTransfer.files).filter(z);
|
|
226
|
+
if (n.length > 0) {
|
|
227
|
+
const N = [...a || [], ...n].slice(0, j);
|
|
228
|
+
m && m(N), f && f(n);
|
|
225
229
|
}
|
|
226
230
|
} else {
|
|
227
|
-
const s =
|
|
228
|
-
s &&
|
|
231
|
+
const s = e.dataTransfer.files[0];
|
|
232
|
+
s && z(s) && (r && r(s), c && c(s));
|
|
229
233
|
}
|
|
230
|
-
},
|
|
234
|
+
}, E = (e) => {
|
|
231
235
|
if (!u) {
|
|
232
236
|
if (o) {
|
|
233
|
-
const
|
|
234
|
-
if (
|
|
235
|
-
const
|
|
236
|
-
m && m(
|
|
237
|
+
const n = (e.target.files ? Array.from(e.target.files) : []).filter(z);
|
|
238
|
+
if (n.length > 0) {
|
|
239
|
+
const N = [...a || [], ...n].slice(0, j);
|
|
240
|
+
m && m(N), f && f(n);
|
|
237
241
|
}
|
|
238
242
|
} else {
|
|
239
|
-
const s =
|
|
240
|
-
s &&
|
|
243
|
+
const s = e.target.files?.[0];
|
|
244
|
+
s && z(s) && (r && r(s), c && c(s));
|
|
241
245
|
}
|
|
242
|
-
|
|
246
|
+
e.target.value = "";
|
|
243
247
|
}
|
|
244
|
-
},
|
|
245
|
-
if (
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
248
|
+
}, L = (e) => {
|
|
249
|
+
if (u) return;
|
|
250
|
+
const s = x[e];
|
|
251
|
+
if (o) {
|
|
252
|
+
const n = x.filter((D, N) => N !== e);
|
|
253
|
+
m && m(n), l && s && l([s]);
|
|
254
|
+
} else
|
|
255
|
+
r && r(null), h && s && h(s);
|
|
256
|
+
}, z = (e) => {
|
|
257
|
+
const s = e.name.substring(e.name.lastIndexOf(".")), n = !g || g.length === 0 || g.includes(s.toLowerCase()), D = e.size <= W;
|
|
258
|
+
return !n && p ? p(e, "extension") : !D && p && p(e, "size"), n && D;
|
|
259
|
+
}, O = () => {
|
|
260
|
+
if (u) return;
|
|
261
|
+
const e = [...x];
|
|
262
|
+
o ? (m && m([]), l && e.length > 0 && l(e)) : (r && r(null), h && e.length > 0 && h(e[0]));
|
|
256
263
|
};
|
|
257
|
-
return /* @__PURE__ */
|
|
258
|
-
o &&
|
|
259
|
-
|
|
264
|
+
return /* @__PURE__ */ t.jsxs("div", { ref: b, className: v("adm:flex adm:flex-col adm:gap-4", i), ...G, children: [
|
|
265
|
+
o && y === "above" && /* @__PURE__ */ t.jsx(
|
|
266
|
+
R,
|
|
260
267
|
{
|
|
261
|
-
files:
|
|
268
|
+
files: x,
|
|
262
269
|
isMultiple: o,
|
|
263
|
-
invalid:
|
|
270
|
+
invalid: k,
|
|
264
271
|
disabled: u,
|
|
265
|
-
labels:
|
|
266
|
-
onRemoveFile:
|
|
267
|
-
onClearAll:
|
|
272
|
+
labels: C,
|
|
273
|
+
onRemoveFile: L,
|
|
274
|
+
onClearAll: O
|
|
268
275
|
}
|
|
269
276
|
),
|
|
270
|
-
(o ||
|
|
271
|
-
|
|
277
|
+
(o || x.length === 0) && /* @__PURE__ */ t.jsx(
|
|
278
|
+
S,
|
|
272
279
|
{
|
|
273
|
-
isDragging:
|
|
280
|
+
isDragging: H,
|
|
274
281
|
isMultiple: o,
|
|
275
|
-
invalid:
|
|
282
|
+
invalid: k,
|
|
276
283
|
disabled: u,
|
|
277
|
-
accept:
|
|
278
|
-
acceptedExtensions:
|
|
279
|
-
maxSizeInMB:
|
|
280
|
-
maxFiles:
|
|
281
|
-
labels:
|
|
282
|
-
input:
|
|
283
|
-
onDragOver:
|
|
284
|
-
onDragLeave:
|
|
285
|
-
onDrop:
|
|
286
|
-
onFileChange:
|
|
284
|
+
accept: Q,
|
|
285
|
+
acceptedExtensions: g,
|
|
286
|
+
maxSizeInMB: w,
|
|
287
|
+
maxFiles: j,
|
|
288
|
+
labels: C,
|
|
289
|
+
input: q,
|
|
290
|
+
onDragOver: X,
|
|
291
|
+
onDragLeave: Y,
|
|
292
|
+
onDrop: Z,
|
|
293
|
+
onFileChange: E
|
|
287
294
|
}
|
|
288
295
|
),
|
|
289
|
-
!o &&
|
|
290
|
-
|
|
296
|
+
!o && x.length > 0 && /* @__PURE__ */ t.jsx(
|
|
297
|
+
R,
|
|
291
298
|
{
|
|
292
|
-
files:
|
|
299
|
+
files: x,
|
|
293
300
|
isMultiple: o,
|
|
294
|
-
invalid:
|
|
301
|
+
invalid: k,
|
|
295
302
|
disabled: u,
|
|
296
|
-
labels:
|
|
297
|
-
onRemoveFile:
|
|
298
|
-
onClearAll:
|
|
303
|
+
labels: C,
|
|
304
|
+
onRemoveFile: L,
|
|
305
|
+
onClearAll: O
|
|
299
306
|
}
|
|
300
307
|
),
|
|
301
|
-
o &&
|
|
302
|
-
|
|
308
|
+
o && y === "below" && /* @__PURE__ */ t.jsx(
|
|
309
|
+
R,
|
|
303
310
|
{
|
|
304
|
-
files:
|
|
311
|
+
files: x,
|
|
305
312
|
isMultiple: o,
|
|
306
|
-
invalid:
|
|
313
|
+
invalid: k,
|
|
307
314
|
disabled: u,
|
|
308
|
-
labels:
|
|
309
|
-
onRemoveFile:
|
|
310
|
-
onClearAll:
|
|
315
|
+
labels: C,
|
|
316
|
+
onRemoveFile: L,
|
|
317
|
+
onClearAll: O
|
|
311
318
|
}
|
|
312
319
|
)
|
|
313
320
|
] });
|
|
314
321
|
}
|
|
315
322
|
export {
|
|
316
|
-
|
|
323
|
+
de as FileUpload
|
|
317
324
|
};
|