@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.
@@ -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;
@@ -1,8 +1,6 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./jsx-runtime-BB_1_6y_.cjs"),A=require("./button-CFJs0esR.cjs"),L=require("./icon-B7joBr0A.cjs"),N=require("./typography-Bj8oEDuE.cjs"),y=require("./index-DoxiiusW.cjs"),I=require("react");function te({isDragging:m,isMultiple:o,invalid:a,disabled:r,accept:i,acceptedExtensions:l,maxSizeInMB:p,maxFiles:c,labels:u,input:g,onDragOver:h,onDragLeave:w,onDrop:R,onFileChange:q}){const b=g?.id||`file-upload-v2-${Math.random().toString(36).substring(2,11)}`;return t.jsxRuntimeExports.jsxs("div",{onDragOver:r?void 0:h,onDragLeave:r?void 0:w,onDrop:r?void 0:R,className:y.cn(`
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":m&&!a&&!r,"adm:border-destructive":a&&!r,"adm:border-input":!m&&!a,"adm:cursor-not-allowed adm:opacity-50":r}),children:[t.jsxRuntimeExports.jsx("div",{className:y.cn("adm:flex adm:items-center adm:justify-center adm:rounded-xl adm:p-2.5",a&&!r?"adm:bg-destructive/10":"adm:bg-primary-50"),children:t.jsxRuntimeExports.jsx(L.Icon,{symbol:"text_snippet",className:a&&!r?"adm:text-destructive":"adm:text-primary"})}),t.jsxRuntimeExports.jsxs("div",{className:"adm:flex adm:flex-col adm:items-center adm:gap-2",children:[t.jsxRuntimeExports.jsx(N.Typography,{color:a&&!r?"destructive":void 0,children:u?.dragDrop||(o?"Drag and drop your files here or":"Drag and drop your file here or")}),t.jsxRuntimeExports.jsxs("label",{htmlFor:b,children:[t.jsxRuntimeExports.jsx("input",{...g,id:b,type:"file",accept:i,multiple:o,onChange:q,disabled:r,className:"adm:hidden"}),t.jsxRuntimeExports.jsx(A.Button,{asChild:!0,type:"button",variant:"link",className:y.cn("adm:cursor-pointer",r&&`
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:r,children:t.jsxRuntimeExports.jsx("span",{children:u?.selectFile||(o?"Select files":"Select the file")})})]})]}),t.jsxRuntimeExports.jsx(N.Typography,{className:"adm:text-center",color:a&&!r?"destructive":"muted",children:u?.fileRequirements||(l&&l.length>0?`Allowed files: ${l.join(", ")}. Maximum size ${p} MB${o?`. Up to ${c} files`:""}.`:`Maximum size ${p} MB${o?`. Up to ${c} files`:""}.`)})]})}function re({fileWithMetadata:m,invalid:o,disabled:a,onRemove:r}){const{file:i}=m;return t.jsxRuntimeExports.jsxs("div",{className:y.cn("adm:flex adm:items-center adm:gap-4 adm:rounded-2xl adm:border adm:p-6",o&&!a?"adm:border-destructive adm:bg-destructive/5":"adm:border-input adm:bg-muted",a&&"adm:cursor-not-allowed adm:opacity-50"),children:[t.jsxRuntimeExports.jsx("div",{className:y.cn("adm:flex adm:items-center adm:justify-center adm:rounded-xl adm:p-2.5",o&&!a?"adm:bg-destructive/10":"adm:bg-primary-50"),children:t.jsxRuntimeExports.jsx(L.Icon,{symbol:"text_snippet",className:o&&!a?"adm:text-destructive":"adm:text-primary"})}),t.jsxRuntimeExports.jsxs("div",{className:`
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;
@@ -1,339 +1,351 @@
1
- import { j as t } from "./jsx-runtime-BzflLqGi.js";
2
- import { B as G } from "./button-BnUlAtuD.js";
3
- import { I as B } from "./icon-BFQz1tQC.js";
4
- import { T as $ } from "./typography-MnY0LQoZ.js";
5
- import { c as y } from "./index-CRiPKpXj.js";
6
- import { useState as U, useRef as te, useEffect as re } from "react";
7
- function ae({
8
- isDragging: o,
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: s,
11
- disabled: r,
10
+ invalid: n,
11
+ disabled: t,
12
12
  accept: i,
13
13
  acceptedExtensions: l,
14
- maxSizeInMB: x,
15
- maxFiles: c,
16
- labels: f,
17
- input: g,
18
- onDragOver: v,
19
- onDragLeave: C,
20
- onDrop: b,
21
- onFileChange: T
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 D = g?.id || `file-upload-v2-${Math.random().toString(36).substring(2, 11)}`;
24
- return /* @__PURE__ */ t.jsxs(
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: r ? void 0 : v,
28
- onDragLeave: r ? void 0 : C,
29
- onDrop: r ? void 0 : b,
30
- className: y(
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": o && !s && !r,
38
- "adm:border-destructive": s && !r,
39
- "adm:border-input": !o && !s,
40
- "adm:cursor-not-allowed adm:opacity-50": r
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__ */ t.jsx(
44
+ /* @__PURE__ */ r.jsx(
45
45
  "div",
46
46
  {
47
- className: y(
47
+ className: N(
48
48
  "adm:flex adm:items-center adm:justify-center adm:rounded-xl adm:p-2.5",
49
- s && !r ? "adm:bg-destructive/10" : "adm:bg-primary-50"
49
+ n && !t ? "adm:bg-destructive/10" : "adm:bg-primary-50"
50
50
  ),
51
- children: /* @__PURE__ */ t.jsx(
52
- B,
51
+ children: /* @__PURE__ */ r.jsx(
52
+ M,
53
53
  {
54
54
  symbol: "text_snippet",
55
- className: s && !r ? "adm:text-destructive" : "adm:text-primary"
55
+ className: n && !t ? "adm:text-destructive" : "adm:text-primary"
56
56
  }
57
57
  )
58
58
  }
59
59
  ),
60
- /* @__PURE__ */ t.jsxs("div", { className: "adm:flex adm:flex-col adm:items-center adm:gap-2", children: [
61
- /* @__PURE__ */ t.jsx($, { color: s && !r ? "destructive" : void 0, children: f?.dragDrop || (d ? "Drag and drop your files here or" : "Drag and drop your file here or") }),
62
- /* @__PURE__ */ t.jsxs("label", { htmlFor: D, children: [
63
- /* @__PURE__ */ t.jsx(
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
- ...g,
67
- id: D,
66
+ ...v,
67
+ id: u,
68
68
  type: "file",
69
69
  accept: i,
70
70
  multiple: d,
71
- onChange: T,
72
- disabled: r,
71
+ onChange: h,
72
+ disabled: t,
73
73
  className: "adm:hidden"
74
74
  }
75
75
  ),
76
- /* @__PURE__ */ t.jsx(
77
- G,
76
+ /* @__PURE__ */ r.jsx(
77
+ q,
78
78
  {
79
79
  asChild: !0,
80
80
  type: "button",
81
81
  variant: "link",
82
- className: y("adm:cursor-pointer", r && `
82
+ className: N("adm:cursor-pointer", t && `
83
83
  adm:pointer-events-none
84
84
  `),
85
- disabled: r,
86
- children: /* @__PURE__ */ t.jsx("span", { children: f?.selectFile || (d ? "Select files" : "Select the file") })
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__ */ t.jsx($, { className: "adm:text-center", color: s && !r ? "destructive" : "muted", children: f?.fileRequirements || (l && l.length > 0 ? `Allowed files: ${l.join(", ")}. Maximum size ${x} MB${d ? `. Up to ${c} files` : ""}.` : `Maximum size ${x} MB${d ? `. Up to ${c} files` : ""}.`) })
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 se({ fileWithMetadata: o, invalid: d, disabled: s, onRemove: r }) {
97
- const { file: i } = o;
98
- return /* @__PURE__ */ t.jsxs(
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: y(
101
+ className: N(
102
102
  "adm:flex adm:items-center adm:gap-4 adm:rounded-2xl adm:border adm:p-6",
103
- d && !s ? "adm:border-destructive adm:bg-destructive/5" : "adm:border-input adm:bg-muted",
104
- s && "adm:cursor-not-allowed adm:opacity-50"
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__ */ t.jsx(
107
+ /* @__PURE__ */ r.jsx(
108
108
  "div",
109
109
  {
110
- className: y(
110
+ className: N(
111
111
  "adm:flex adm:items-center adm:justify-center adm:rounded-xl adm:p-2.5",
112
- d && !s ? "adm:bg-destructive/10" : "adm:bg-primary-50"
112
+ L()
113
113
  ),
114
- children: /* @__PURE__ */ t.jsx(
115
- B,
114
+ children: /* @__PURE__ */ r.jsx(
115
+ M,
116
116
  {
117
- symbol: "text_snippet",
118
- className: d && !s ? "adm:text-destructive" : "adm:text-primary"
117
+ symbol: V(),
118
+ className: N(
119
+ B(),
120
+ U && "adm:animate-spin"
121
+ )
119
122
  }
120
123
  )
121
124
  }
122
125
  ),
123
- /* @__PURE__ */ t.jsxs(
124
- "div",
125
- {
126
- className: `
127
- adm:flex adm:min-w-0 adm:flex-1 adm:items-start adm:gap-3
128
- `,
129
- children: [
130
- /* @__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 }) }),
131
- /* @__PURE__ */ t.jsxs($, { className: "adm:shrink-0", color: "muted", children: [
132
- (i.size / 1024 / 1024).toFixed(1),
133
- " MB"
134
- ] })
135
- ]
136
- }
137
- ),
138
- /* @__PURE__ */ t.jsx(
139
- G,
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: r,
153
+ onClick: i,
143
154
  type: "button",
144
- disabled: s,
145
- children: /* @__PURE__ */ t.jsx(B, { symbol: "delete", className: "adm:text-destructive" })
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 A({ files: o, isMultiple: d, invalid: s, disabled: r, labels: i, onRemoveFile: l, onClearAll: x }) {
153
- return o.length === 0 ? null : /* @__PURE__ */ t.jsxs("div", { className: "adm:flex adm:flex-col adm:gap-3", children: [
154
- d && o.length > 1 && /* @__PURE__ */ t.jsxs("div", { className: "adm:flex adm:items-center adm:justify-between", children: [
155
- /* @__PURE__ */ t.jsx($, { className: "adm:text-sm adm:font-medium", color: s && !r ? "destructive" : void 0, children: i?.filesSelected?.(o.length) || `${o.length} file${o.length !== 1 ? "s" : ""} selected` }),
156
- /* @__PURE__ */ t.jsx(
157
- G,
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: x,
172
+ onClick: o,
162
173
  type: "button",
163
- disabled: r,
174
+ disabled: t,
164
175
  children: "Clear all"
165
176
  }
166
177
  )
167
178
  ] }),
168
- o.map((c, f) => /* @__PURE__ */ t.jsx(
169
- se,
179
+ c.map((p, g) => /* @__PURE__ */ r.jsx(
180
+ ae,
170
181
  {
171
- fileWithMetadata: c,
172
- invalid: s,
173
- disabled: r,
174
- onRemove: () => l(f)
182
+ fileWithMetadata: p,
183
+ invalid: n,
184
+ disabled: t,
185
+ labels: i,
186
+ onRemove: () => l(g)
175
187
  },
176
- c.id
188
+ p.id
177
189
  ))
178
190
  ] });
179
191
  }
180
- function fe({
181
- className: o,
192
+ function ue({
193
+ className: c,
182
194
  selectedFile: d,
183
- selectedFiles: s,
184
- onFileSelect: r,
195
+ selectedFiles: n,
196
+ onFileSelect: t,
185
197
  onFilesSelect: i,
186
198
  onFileAdd: l,
187
- onFileRemove: x,
188
- onFilesAdd: c,
189
- onFilesRemove: f,
190
- onInvalidFile: g,
191
- acceptedExtensions: v,
192
- maxSizeInMB: C = 50,
193
- maxFiles: b = 10,
194
- multiple: T = !1,
195
- filesPosition: D = "below",
196
- invalid: _ = !1,
197
- disabled: M = !1,
198
- "aria-invalid": q,
199
- generateId: F,
200
- labels: I,
201
- input: H,
202
- ...J
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 [K, V] = U(!1), [Q, X] = U(!1), N = te(null);
216
+ const [J, O] = E(!1), [K, Q] = E(!1), $ = te(null);
205
217
  re(() => {
206
218
  const e = () => {
207
- if (N.current) {
208
- const a = N.current.closest("fieldset");
209
- X(a?.disabled ?? !1);
219
+ if ($.current) {
220
+ const s = $.current.closest("fieldset");
221
+ Q(s?.disabled ?? !1);
210
222
  }
211
223
  };
212
224
  e();
213
- const n = new MutationObserver(e);
214
- if (N.current) {
215
- const a = N.current.closest("fieldset");
216
- a && n.observe(a, { attributes: !0, attributeFilter: ["disabled"] });
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 () => n.disconnect();
230
+ return () => a.disconnect();
219
231
  }, []);
220
- const Y = v?.join(",") || "", Z = C * 1024 * 1024, m = T || s !== void 0 || i !== void 0, h = m ? s || [] : d ? [d] : [], k = _ || q, u = M || Q, W = F || ((e) => `${Date.now()}-${Math.random().toString(36).substring(2, 11)}-${e.name}`), w = (e) => ({
221
- id: W(e),
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
- }), E = (e) => {
224
- u || (e.preventDefault(), V(!0));
225
- }, P = (e) => {
226
- u || (e.preventDefault(), V(!1));
235
+ }), P = (e) => {
236
+ b || (e.preventDefault(), O(!0));
237
+ }, W = (e) => {
238
+ b || (e.preventDefault(), O(!1));
227
239
  }, S = (e) => {
228
- if (!u)
229
- if (e.preventDefault(), V(!1), m) {
230
- const a = Array.from(e.dataTransfer.files).filter(z);
231
- if (a.length > 0) {
232
- const p = a.map(w), R = [...s || [], ...p].slice(0, b);
233
- i && i(R), c && c(p);
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 n = e.dataTransfer.files[0];
237
- if (n && z(n)) {
238
- const a = w(n);
239
- r && r(a), l && l(a);
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 (!u) {
244
- if (m) {
245
- const a = (e.target.files ? Array.from(e.target.files) : []).filter(z);
246
- if (a.length > 0) {
247
- const p = a.map(w), R = [...s || [], ...p].slice(0, b);
248
- i && i(R), c && c(p);
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 n = e.target.files?.[0];
252
- if (n && z(n)) {
253
- const a = w(n);
254
- r && r(a), l && l(a);
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
- }, L = (e) => {
260
- if (u) return;
261
- const n = h[e];
262
- if (m) {
263
- const a = h.filter((p, j) => j !== e);
264
- i && i(a), f && n && f([n]);
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
- r && r(null), x && n && x(n);
267
- }, z = (e) => {
268
- const n = e.name.substring(e.name.lastIndexOf(".")), a = !v || v.length === 0 || v.includes(n.toLowerCase()), p = e.size <= Z;
269
- if (!a || !p) {
270
- const j = w(e);
271
- !a && g ? g(j, "extension") : !p && g && g(j, "size");
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 a && p;
274
- }, O = () => {
275
- if (u) return;
276
- const e = [...h];
277
- m ? (i && i([]), f && e.length > 0 && f(e)) : (r && r(null), x && e.length > 0 && x(e[0]));
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__ */ t.jsxs("div", { ref: N, className: y("adm:flex adm:flex-col adm:gap-4", o), ...J, children: [
280
- m && D === "above" && /* @__PURE__ */ t.jsx(
281
- A,
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: h,
284
- isMultiple: m,
285
- invalid: k,
286
- disabled: u,
287
- labels: I,
288
- onRemoveFile: L,
289
- onClearAll: O
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
- (m || h.length === 0) && /* @__PURE__ */ t.jsx(
293
- ae,
304
+ (f || D.length === 0) && /* @__PURE__ */ r.jsx(
305
+ se,
294
306
  {
295
- isDragging: K,
296
- isMultiple: m,
297
- invalid: k,
298
- disabled: u,
299
- accept: Y,
300
- acceptedExtensions: v,
301
- maxSizeInMB: C,
302
- maxFiles: b,
303
- labels: I,
304
- input: H,
305
- onDragOver: E,
306
- onDragLeave: P,
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
- !m && h.length > 0 && /* @__PURE__ */ t.jsx(
312
- A,
323
+ !f && D.length > 0 && /* @__PURE__ */ r.jsx(
324
+ G,
313
325
  {
314
- files: h,
315
- isMultiple: m,
316
- invalid: k,
317
- disabled: u,
318
- labels: I,
319
- onRemoveFile: L,
320
- onClearAll: O
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
- m && D === "below" && /* @__PURE__ */ t.jsx(
324
- A,
335
+ f && u === "below" && /* @__PURE__ */ r.jsx(
336
+ G,
325
337
  {
326
- files: h,
327
- isMultiple: m,
328
- invalid: k,
329
- disabled: u,
330
- labels: I,
331
- onRemoveFile: L,
332
- onClearAll: O
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
- fe as FileUploadV2
350
+ ue as FileUploadV2
339
351
  };