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