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