@vlrc-fe/components 3.0.2 → 3.0.3

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/CHANGELOG.md CHANGED
@@ -1,6 +1,16 @@
1
1
  # Changelog
2
2
 
3
- ## 3.0.2
3
+ ## [3.0.3] - 2026-11-15
4
+
5
+ ### Patch Changes
6
+
7
+ - **FormFileUpload & FileUpload Error Handling**:
8
+ - Integrated `<FieldError>` display into `FileUpload` across all variants (`default`, `compact`, `avatar`) when a file is rejected (e.g. exceeding `maxSize` or invalid format) or when external `error` / `errors` props are provided.
9
+ - Connected `FormFileUpload` with React Hook Form validation via `formContext` and fallback `control`, dynamically setting `fieldState.error` (`{ type: 'validate', message }`) upon file rejection so `<Field data-invalid="true">` and `<FieldError errors={[fieldState.error]} />` render consistently with all other form fields.
10
+ - Automatically clears validation error upon selecting valid files or clearing the file selection.
11
+ - Enforced strict 0% `any` and direct imports of React hooks and types.
12
+
13
+ ## [3.0.2] - 2026-11-15
4
14
 
5
15
  ### Patch Changes
6
16
 
@@ -11,6 +21,8 @@
11
21
  - Reorganized all component stories into cohesive hierarchies (`Foundations/`, `Actions/`, `Feedback/`, `Forms/`, `Layout/`, `Navigation/`).
12
22
  - Added theme switching support in Storybook preview.
13
23
 
24
+ ## [3.0.1] - 2026-11-14
25
+
14
26
  ## [2.8.0] - 2026-11-10
15
27
 
16
28
  ### Minor Changes
@@ -1 +1 @@
1
- const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../Icons/Icons.cjs"),n=require("../../Typography/Text.cjs"),r=require("../../ui/button.cjs"),i=require("../../ui/file-upload-adapters.cjs"),a=require("../../ui/file-upload.cjs");let o=require("@stylexjs/stylex");o=e.__toESM(o,1);let s=require("react/jsx-runtime"),c=require("react"),l=e.__toESM(c,1);c=e.__toESM(c);let u=require("react/compiler-runtime");var d={avatarDropzone:{kVAEAm:`x1n2onr6`,kzqmXN:`x1eyvef`,kZKoxP:`xw76nk8`,kaIpWk:`x9psvww`,kMzoRj:`xdh2fpr`,ksu8eU:`xbsl7fq`,kVAM5u:`xb30jbz`,kWkggS:`x1mlyrtw`,kVQacm:`xb3r6kr`,kmVPX3:`x1717udv`,kkrTdU:`x1ypdohk`,k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kjj79g:`xl56j7k`,k1ekBW:`xq90yva`,kIyJzY:`x13dflua`,kaVNsj:`x14aqmuz`,$$css:!0},avatarItem:{kVAEAm:`x1n2onr6`,k1xSpc:`x78zum5`,kzqmXN:`xh8yej3`,kZKoxP:`x5yr21d`,kXwgrk:`xdt5ytf`,kaIpWk:`x2u8bby`,kMzoRj:`xc342km`,kmVPX3:`x1717udv`,$$css:!0},avatarPreview:{kzqmXN:`xh8yej3`,kZKoxP:`x5yr21d`,kaIpWk:`x2u8bby`,kMzoRj:`xc342km`,kWkggS:`xjbqb8w`,$$css:!0},avatarImg:{kzqmXN:`xh8yej3`,kZKoxP:`x5yr21d`,kVIFPx:`xl1xv1r`,$$css:!0},compactDropzone:{kVAEAm:`x1n2onr6`,k1xSpc:`x78zum5`,kXwgrk:`x1q0g3np`,kGNEyG:`x6s0dn4`,kOIVth:`x8233eu`,kaIpWk:`x1ez7q3a`,kMzoRj:`xmkeg23`,ksu8eU:`xbsl7fq`,kVAM5u:`xb30jbz`,kWkggS:`x1mlyrtw`,kmVPX3:`x19btat0`,kkrTdU:`x1ypdohk`,k1ekBW:`xq90yva`,kIyJzY:`xx6bhzk`,kaVNsj:`x14aqmuz`,kGzVvX:`x9p52ec`,$$css:!0},clearBtnRow:{k1xSpc:`x78zum5`,kjj79g:`x13a6bvl`,kzqmXN:`xh8yej3`,$$css:!0},clearBtn:{k1xSpc:`x3nfvp2`,kGNEyG:`x6s0dn4`,kOIVth:`xvh977a`,kGuDYH:`xboafo0`,kMwMTN:`xw3nh4a`,kWkggS:`xjbqb8w`,kMzoRj:`xc342km`,kkrTdU:`x1ypdohk`,kmVPX3:`x48ff29`,kaIpWk:`xqfady0`,kGzVvX:`x9p52ec`,kDPRdz:`x1mqvv6a`,$$css:!0},deleteBtn:{k1xSpc:`x3nfvp2`,kGNEyG:`x6s0dn4`,kjj79g:`xl56j7k`,kzqmXN:`xs5h3dt`,kZKoxP:`xettwda`,kaIpWk:`xqfady0`,kMzoRj:`xc342km`,kWkggS:`xjbqb8w`,kMwMTN:`xw3nh4a`,kkrTdU:`x1ypdohk`,kmuXW:`x2lah0s`,k1ekBW:`x1gbuem2`,kIyJzY:`xx6bhzk`,kGzVvX:`x9p52ec`,kDPRdz:`x1mqvv6a`,$$css:!0},whiteText:{kMwMTN:`xstwp1q`,$$css:!0}};function f(e){let t=(0,u.c)(6),{onChange:n,autoUpload:r,maxFiles:i}=e,o=a.useFileUpload(_),s=l.useRef(null),c=l.useRef(!0),d,f;return t[0]!==r||t[1]!==i||t[2]!==n||t[3]!==o?(d=()=>{if(!n)return;let e=Array.from(o.files.values());if(c.current&&(c.current=!1,e.length===0))return;let t=(()=>{if(r){let t=e.filter(g).map(h).filter(m);return i===1?t.length>0?t[t.length-1]:null:t}let t=e.map(p);return i===1?t.length>0?t[t.length-1]:null:t})(),a=s.current;(r?JSON.stringify(a)===JSON.stringify(t):Array.isArray(t)&&Array.isArray(a)?t.length===a.length&&t.every((e,t)=>e===a[t]):t===a)||(s.current=t,n(t))},f=[o,r,i,n],t[0]=r,t[1]=i,t[2]=n,t[3]=o,t[4]=d,t[5]=f):(d=t[4],f=t[5]),l.useEffect(d,f),null}function p(e){return e.file}function m(e){return!!e}function h(e){return e.file.uploadedUrl}function g(e){return e.status===`success`}function _(e){return e}function v(e,t=``){let n=e.split(`/`).pop()?.split(`?`)[0]||`file`,r=n.split(`.`).pop()?.toLowerCase(),i=r&&{jpg:`image/jpeg`,jpeg:`image/jpeg`,png:`image/png`,gif:`image/gif`,webp:`image/webp`,pdf:`application/pdf`}[r];i||=t.includes(`image`)?`image/jpeg`:`application/octet-stream`;let a=new File([``],n,{type:i});return a.isUploadedUrl=!0,a.uploadedUrl=e,a}function y({showPreview:e,showProgress:n,orientation:i=`vertical`,avatarImgSx:c,deleteBtnSx:l}){let u=a.useFileUpload(e=>Array.from(e.files.values()).map(e=>e.file));return u.length===0?null:(0,s.jsx)(a.FileUploadList,{orientation:i,children:u.map((u,d)=>(0,s.jsxs)(a.FileUploadItem,{value:u,children:[e&&(0,s.jsx)(a.FileUploadItemPreview,{render:(e,t)=>{let n=e.uploadedUrl||(e.type.startsWith(`image/`)&&typeof URL<`u`&&URL.createObjectURL?URL.createObjectURL(e):null);return n&&e.type.startsWith(`image/`)?(0,s.jsx)(`img`,{src:n,alt:e.name,...o.props(c)}):t()}}),(0,s.jsx)(a.FileUploadItemMetadata,{}),n&&(0,s.jsx)(a.FileUploadItemProgress,{variant:`bottom`}),(0,s.jsx)(a.FileUploadItemDelete,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,"aria-label":`Delete ${u.name}`,sx:l,children:(0,s.jsx)(t.Icons.Trash2,{size:i===`horizontal`?15:16})})})]},`${u.name}-${d}`))})}function b(e){let n=(0,u.c)(10),{clearBtnRowSx:r,clearBtnSx:i}=e;if(a.useFileUpload(x)===0)return null;let c;n[0]===r?c=n[1]:(c=o.props(r),n[0]=r,n[1]=c);let l;n[2]===i?l=n[3]:(l=o.props(i),n[2]=i,n[3]=l);let d;n[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,s.jsx)(t.Icons.Trash2,{size:13}),n[4]=d):d=n[4];let f;n[5]===l?f=n[6]:(f=(0,s.jsx)(a.FileUploadClear,{asChild:!0,children:(0,s.jsxs)(`button`,{type:`button`,...l,children:[d,`Clear all`]})}),n[5]=l,n[6]=f);let p;return n[7]!==c||n[8]!==f?(p=(0,s.jsx)(`div`,{...c,children:f}),n[7]=c,n[8]=f,n[9]=p):p=n[9],p}function x(e){return e.files.size}function S(e){let r=(0,u.c)(8),{showProgress:o,maxSize:c}=e,l=a.useFileUpload(w),f;r[0]!==l||r[1]!==o?(f=(0,s.jsx)(a.FileUploadDropzone,{sx:d.avatarDropzone,children:l?(0,s.jsxs)(a.FileUploadItem,{value:l,sx:d.avatarItem,children:[(0,s.jsx)(a.FileUploadItemPreview,{sx:d.avatarPreview,render:C}),(0,s.jsxs)(`div`,{className:`x10l6tqk x10a8y8t x78zum5 xdt5ytf x6s0dn4 xl56j7k xvh977a xa44r0r xstwp1q xg01cxk x19991ni x13dflua x1o7uuvo`,children:[(0,s.jsx)(t.Icons.Camera,{size:22}),(0,s.jsx)(n.Text,{size:`xs`,weight:`semibold`,sx:d.whiteText,children:`Change photo`})]}),o&&(0,s.jsx)(a.FileUploadItemProgress,{variant:`fill`,style:{opacity:.5}})]}):(0,s.jsxs)(`div`,{className:`x78zum5 xh8yej3 x5yr21d xdt5ytf x6s0dn4 xl56j7k xvh977a x1jgryid xw3nh4a x15406qy x13dflua`,children:[(0,s.jsx)(t.Icons.Camera,{size:24}),(0,s.jsx)(n.Text,{size:`xs`,weight:`medium`,children:`Upload`})]})}),r[0]=l,r[1]=o,r[2]=f):f=r[2];let p;r[3]===c?p=r[4]:(p=c?(0,s.jsxs)(n.Text,{size:`xs`,type:`muted`,children:[`Max `,i.formatFileSize(c)]}):null,r[3]=c,r[4]=p);let m;return r[5]!==f||r[6]!==p?(m=(0,s.jsxs)(`div`,{className:`x78zum5 xdt5ytf x6s0dn4 x13z6uf9`,children:[f,p]}),r[5]=f,r[6]=p,r[7]=m):m=r[7],m}function C(e){let r=e.uploadedUrl||(e.type.startsWith(`image/`)&&typeof URL<`u`&&URL.createObjectURL?URL.createObjectURL(e):null);return r?(0,s.jsx)(`img`,{src:r,alt:`Avatar`,className:`xh8yej3 x5yr21d xl1xv1r`}):(0,s.jsxs)(`div`,{className:`x78zum5 xh8yej3 x5yr21d xdt5ytf x6s0dn4 xl56j7k xvh977a x1jgryid xw3nh4a x15406qy x13dflua`,children:[(0,s.jsx)(t.Icons.Camera,{size:24}),(0,s.jsx)(n.Text,{size:`xs`,weight:`medium`,children:`Upload`})]})}function w(e){let t=e.files.values().next();return t.done?null:t.value.file}function T({value:e,onChange:o,autoUpload:c=!1,uploadFile:u,apiConfig:p,uploadThingConfig:m,uploadHandler:h,maxFiles:g=1,maxSize:_=5242880,accept:x=`image/*`,multiple:C,disabled:w,className:T,sx:E,variant:D=`default`,dropzoneTitle:O,dropzoneSubtitle:k,icon:A,showFileList:j=!0,showProgress:M=!0,showPreview:N=!0,showClear:P=!1}){let F=l.useRef(new Map),I=l.useMemo(()=>(Array.isArray(e)?e:e?[e]:[]).map(e=>{if(e instanceof File)return e;if(typeof e==`string`){let t=F.current.get(e);return t||(t=v(e,x),F.current.set(e,t)),t}return e}),[e,x]),L=l.useMemo(()=>h||(m?i.createUploadThingUploadHandler(m):p?i.createApiUploadHandler(p):null),[h,m,p]),R=async(e,t)=>{if(!c)e.forEach(e=>t.onSuccess(e));else if(L)try{(await L(e,{onProgress:t.onProgress,onSuccess:(e,n)=>{e.uploadedUrl=n.url,t.onSuccess(e)},onError:(e,n)=>{t.onError(e,n)}})).forEach((t,n)=>{let r=e[n];r&&(r.uploadedUrl=t.url)})}catch{}else u?await Promise.all(e.map(async e=>{let n=e;if(n.isUploadedUrl)t.onSuccess(e);else try{t.onProgress(e,20),n.uploadedUrl=await u(e),t.onProgress(e,100),t.onSuccess(e)}catch(n){t.onError(e,n instanceof Error?n:Error(`Upload failed`))}})):(console.warn(`FileUpload: autoUpload is true but no upload handler or config was provided.`),e.forEach(e=>t.onError(e,Error(`Missing upload configuration`))))},z=`${g>1?`Up to ${g} files`:`1 file max`} ${_?`(Max ${i.formatFileSize(_)})`:``}`,B=D===`avatar`?!1:C??g>1;return(0,s.jsxs)(a.FileUpload,{value:I,maxFiles:D===`avatar`?1:g,maxSize:_,accept:x,multiple:B,disabled:w,onUpload:R,className:T,sx:E,children:[(0,s.jsx)(f,{onChange:o,autoUpload:!!c,maxFiles:D===`avatar`?1:g}),D===`avatar`?(0,s.jsx)(S,{showProgress:M,maxSize:_}):D===`compact`?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(a.FileUploadDropzone,{sx:d.compactDropzone,children:[(0,s.jsx)(`div`,{className:`x78zum5 x6s0dn4 xl56j7k xs5h3dt xettwda x9psvww xmkeg23 x1y0btm7 xb30jbz x1rexohn xw3nh4a x2lah0s`,children:A||(0,s.jsx)(t.Icons.CloudUpload,{size:18})}),(0,s.jsxs)(`div`,{className:`x78zum5 xdt5ytf x98rzlu xeuugli`,children:[(0,s.jsx)(n.Text,{size:`sm`,weight:`medium`,children:O||`Choose or drop files to upload`}),(0,s.jsx)(n.Text,{size:`xs`,type:`muted`,children:k||z})]}),(0,s.jsx)(a.FileUploadTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:`outline`,size:`sm`,disabled:w,children:`Browse`})})]}),P&&(0,s.jsx)(b,{clearBtnRowSx:d.clearBtnRow,clearBtnSx:d.clearBtn}),j&&(0,s.jsx)(y,{showPreview:N,showProgress:M,orientation:`horizontal`,avatarImgSx:d.avatarImg,deleteBtnSx:d.deleteBtn})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(a.FileUploadDropzone,{children:[(0,s.jsx)(`div`,{className:`x78zum5 x6s0dn4 xl56j7k xvm51jw xwaiz5r x9psvww xmkeg23 x1y0btm7 xb30jbz x1rexohn xw3nh4a x1hpqcdg`,children:A||(0,s.jsx)(t.Icons.CloudUpload,{size:20})}),(0,s.jsx)(n.Text,{size:`md`,weight:`medium`,children:O||`Drag & drop files here, or click to select`}),(0,s.jsx)(n.Text,{size:`xs`,type:`muted`,children:k||z})]}),P&&(0,s.jsx)(b,{clearBtnRowSx:d.clearBtnRow,clearBtnSx:d.clearBtn}),j&&(0,s.jsx)(y,{showPreview:N,showProgress:M,orientation:`vertical`,avatarImgSx:d.avatarImg,deleteBtnSx:d.deleteBtn})]})]})}exports.FileUpload=T;
1
+ const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../Icons/Icons.cjs"),n=require("../../Typography/Text.cjs"),r=require("../../ui/button.cjs"),i=require("../../ui/field.cjs"),a=require("../../ui/file-upload-adapters.cjs"),o=require("../../ui/file-upload.cjs");let s=require("@stylexjs/stylex");s=e.__toESM(s,1);let c=require("react/jsx-runtime"),l=require("react"),u=require("react/compiler-runtime");var d={avatarDropzone:{kVAEAm:`x1n2onr6`,kzqmXN:`x1eyvef`,kZKoxP:`xw76nk8`,kaIpWk:`x9psvww`,kMzoRj:`xdh2fpr`,ksu8eU:`xbsl7fq`,kVAM5u:`xb30jbz`,kWkggS:`x1mlyrtw`,kVQacm:`xb3r6kr`,kmVPX3:`x1717udv`,kkrTdU:`x1ypdohk`,k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kjj79g:`xl56j7k`,k1ekBW:`xq90yva`,kIyJzY:`x13dflua`,kaVNsj:`x14aqmuz`,$$css:!0},avatarItem:{kVAEAm:`x1n2onr6`,k1xSpc:`x78zum5`,kzqmXN:`xh8yej3`,kZKoxP:`x5yr21d`,kXwgrk:`xdt5ytf`,kaIpWk:`x2u8bby`,kMzoRj:`xc342km`,kmVPX3:`x1717udv`,$$css:!0},avatarPreview:{kzqmXN:`xh8yej3`,kZKoxP:`x5yr21d`,kaIpWk:`x2u8bby`,kMzoRj:`xc342km`,kWkggS:`xjbqb8w`,$$css:!0},avatarImg:{kzqmXN:`xh8yej3`,kZKoxP:`x5yr21d`,kVIFPx:`xl1xv1r`,$$css:!0},compactDropzone:{kVAEAm:`x1n2onr6`,k1xSpc:`x78zum5`,kXwgrk:`x1q0g3np`,kGNEyG:`x6s0dn4`,kOIVth:`x8233eu`,kaIpWk:`x1ez7q3a`,kMzoRj:`xmkeg23`,ksu8eU:`xbsl7fq`,kVAM5u:`xb30jbz`,kWkggS:`x1mlyrtw`,kmVPX3:`x19btat0`,kkrTdU:`x1ypdohk`,k1ekBW:`xq90yva`,kIyJzY:`xx6bhzk`,kaVNsj:`x14aqmuz`,kGzVvX:`x9p52ec`,$$css:!0},clearBtnRow:{k1xSpc:`x78zum5`,kjj79g:`x13a6bvl`,kzqmXN:`xh8yej3`,$$css:!0},clearBtn:{k1xSpc:`x3nfvp2`,kGNEyG:`x6s0dn4`,kOIVth:`xvh977a`,kGuDYH:`xboafo0`,kMwMTN:`xw3nh4a`,kWkggS:`xjbqb8w`,kMzoRj:`xc342km`,kkrTdU:`x1ypdohk`,kmVPX3:`x48ff29`,kaIpWk:`xqfady0`,kGzVvX:`x9p52ec`,kDPRdz:`x1mqvv6a`,$$css:!0},deleteBtn:{k1xSpc:`x3nfvp2`,kGNEyG:`x6s0dn4`,kjj79g:`xl56j7k`,kzqmXN:`xs5h3dt`,kZKoxP:`xettwda`,kaIpWk:`xqfady0`,kMzoRj:`xc342km`,kWkggS:`xjbqb8w`,kMwMTN:`xw3nh4a`,kkrTdU:`x1ypdohk`,kmuXW:`x2lah0s`,k1ekBW:`x1gbuem2`,kIyJzY:`xx6bhzk`,kGzVvX:`x9p52ec`,kDPRdz:`x1mqvv6a`,$$css:!0},whiteText:{kMwMTN:`xstwp1q`,$$css:!0}};function f(e){let t=(0,u.c)(7),{onChange:n,autoUpload:r,maxFiles:i,onResetReject:a}=e,s=o.useFileUpload(_),c=(0,l.useRef)(null),d=(0,l.useRef)(!0),f,v;return t[0]!==r||t[1]!==i||t[2]!==n||t[3]!==a||t[4]!==s?(f=()=>{if(!n)return;let e=Array.from(s.files.values());if(d.current&&(d.current=!1,e.length===0))return;let t=(()=>{if(r){let t=e.filter(g).map(h).filter(m);return i===1?t.length>0?t[t.length-1]:null:t}let t=e.map(p);return i===1?t.length>0?t[t.length-1]:null:t})(),o=c.current;(r?JSON.stringify(o)===JSON.stringify(t):Array.isArray(t)&&Array.isArray(o)?t.length===o.length&&t.every((e,t)=>e===o[t]):t===o)||(c.current=t,n(t),a?.())},v=[s,r,i,n,a],t[0]=r,t[1]=i,t[2]=n,t[3]=a,t[4]=s,t[5]=f,t[6]=v):(f=t[5],v=t[6]),(0,l.useEffect)(f,v),null}function p(e){return e.file}function m(e){return!!e}function h(e){return e.file.uploadedUrl}function g(e){return e.status===`success`}function _(e){return e}function v(e,t=``){let n=e.split(`/`).pop()?.split(`?`)[0]||`file`,r=n.split(`.`).pop()?.toLowerCase(),i=r&&{jpg:`image/jpeg`,jpeg:`image/jpeg`,png:`image/png`,gif:`image/gif`,webp:`image/webp`,pdf:`application/pdf`}[r];i||=t.includes(`image`)?`image/jpeg`:`application/octet-stream`;let a=new File([``],n,{type:i});return a.isUploadedUrl=!0,a.uploadedUrl=e,a}function y({showPreview:e,showProgress:n,orientation:i=`vertical`,avatarImgSx:a,deleteBtnSx:l}){let u=o.useFileUpload(e=>Array.from(e.files.values()).map(e=>e.file));return u.length===0?null:(0,c.jsx)(o.FileUploadList,{orientation:i,children:u.map((u,d)=>(0,c.jsxs)(o.FileUploadItem,{value:u,children:[e&&(0,c.jsx)(o.FileUploadItemPreview,{render:(e,t)=>{let n=e.uploadedUrl||(e.type.startsWith(`image/`)&&typeof URL<`u`&&URL.createObjectURL?URL.createObjectURL(e):null);return n&&e.type.startsWith(`image/`)?(0,c.jsx)(`img`,{src:n,alt:e.name,...s.props(a)}):t()}}),(0,c.jsx)(o.FileUploadItemMetadata,{}),n&&(0,c.jsx)(o.FileUploadItemProgress,{variant:`bottom`}),(0,c.jsx)(o.FileUploadItemDelete,{asChild:!0,children:(0,c.jsx)(r.Button,{variant:`ghost`,size:`icon`,"aria-label":`Delete ${u.name}`,sx:l,children:(0,c.jsx)(t.Icons.Trash2,{size:i===`horizontal`?15:16})})})]},`${u.name}-${d}`))})}function b(e){let n=(0,u.c)(10),{clearBtnRowSx:r,clearBtnSx:i}=e;if(o.useFileUpload(x)===0)return null;let a;n[0]===r?a=n[1]:(a=s.props(r),n[0]=r,n[1]=a);let l;n[2]===i?l=n[3]:(l=s.props(i),n[2]=i,n[3]=l);let d;n[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,c.jsx)(t.Icons.Trash2,{size:13}),n[4]=d):d=n[4];let f;n[5]===l?f=n[6]:(f=(0,c.jsx)(o.FileUploadClear,{asChild:!0,children:(0,c.jsxs)(`button`,{type:`button`,...l,children:[d,`Clear all`]})}),n[5]=l,n[6]=f);let p;return n[7]!==a||n[8]!==f?(p=(0,c.jsx)(`div`,{...a,children:f}),n[7]=a,n[8]=f,n[9]=p):p=n[9],p}function x(e){return e.files.size}function ee(e){let r=(0,u.c)(9),{showProgress:i,maxSize:s,errorElem:l}=e,f=o.useFileUpload(C),p;r[0]!==f||r[1]!==i?(p=(0,c.jsx)(o.FileUploadDropzone,{sx:d.avatarDropzone,children:f?(0,c.jsxs)(o.FileUploadItem,{value:f,sx:d.avatarItem,children:[(0,c.jsx)(o.FileUploadItemPreview,{sx:d.avatarPreview,render:S}),(0,c.jsxs)(`div`,{className:`x10l6tqk x10a8y8t x78zum5 xdt5ytf x6s0dn4 xl56j7k xvh977a xa44r0r xstwp1q xg01cxk x19991ni x13dflua x1o7uuvo`,children:[(0,c.jsx)(t.Icons.Camera,{size:22}),(0,c.jsx)(n.Text,{size:`xs`,weight:`semibold`,sx:d.whiteText,children:`Change photo`})]}),i&&(0,c.jsx)(o.FileUploadItemProgress,{variant:`fill`,style:{opacity:.5}})]}):(0,c.jsxs)(`div`,{className:`x78zum5 xh8yej3 x5yr21d xdt5ytf x6s0dn4 xl56j7k xvh977a x1jgryid xw3nh4a x15406qy x13dflua`,children:[(0,c.jsx)(t.Icons.Camera,{size:24}),(0,c.jsx)(n.Text,{size:`xs`,weight:`medium`,children:`Upload`})]})}),r[0]=f,r[1]=i,r[2]=p):p=r[2];let m;r[3]===s?m=r[4]:(m=s?(0,c.jsxs)(n.Text,{size:`xs`,type:`muted`,children:[`Max `,a.formatFileSize(s)]}):null,r[3]=s,r[4]=m);let h;return r[5]!==l||r[6]!==p||r[7]!==m?(h=(0,c.jsxs)(`div`,{className:`x78zum5 xdt5ytf x6s0dn4 x13z6uf9`,children:[p,m,l]}),r[5]=l,r[6]=p,r[7]=m,r[8]=h):h=r[8],h}function S(e){let r=e.uploadedUrl||(e.type.startsWith(`image/`)&&typeof URL<`u`&&URL.createObjectURL?URL.createObjectURL(e):null);return r?(0,c.jsx)(`img`,{src:r,alt:`Avatar`,className:`xh8yej3 x5yr21d xl1xv1r`}):(0,c.jsxs)(`div`,{className:`x78zum5 xh8yej3 x5yr21d xdt5ytf x6s0dn4 xl56j7k xvh977a x1jgryid xw3nh4a x15406qy x13dflua`,children:[(0,c.jsx)(t.Icons.Camera,{size:24}),(0,c.jsx)(n.Text,{size:`xs`,weight:`medium`,children:`Upload`})]})}function C(e){let t=e.files.values().next();return t.done?null:t.value.file}function w(e,t,n=[]){if(e&&e.length>0)return e;if(t)return[typeof t==`string`?{message:t}:t];if(n.length>0)return n.map(e=>({message:e}))}function T({value:e,onChange:s,autoUpload:u=!1,uploadFile:p,apiConfig:m,uploadThingConfig:h,uploadHandler:g,maxFiles:_=1,maxSize:x=5242880,minSize:S,accept:C=`image/*`,multiple:T,disabled:E,className:D,sx:O,variant:k=`default`,dropzoneTitle:A,dropzoneSubtitle:j,icon:M,showFileList:N=!0,showProgress:P=!0,showPreview:F=!0,showClear:I=!1,error:L,errors:R,onFileReject:z,onAccept:B,hideError:V=!1,invalid:H,"aria-invalid":te}){let[U,W]=(0,l.useState)([]),G=(0,l.useCallback)((e,t)=>{W(e=>e.includes(t)?e:[...e,t]),z?.(e,t)},[z]),K=(0,l.useCallback)(e=>{W([]),B?.(e)},[B]),q=(0,l.useCallback)(()=>{W([])},[]);(0,l.useEffect)(()=>{W([])},[e]);let J=(0,l.useMemo)(()=>w(R,L,U),[R,L,U]),Y=!V&&J&&J.length>0?(0,c.jsx)(i.FieldError,{errors:J}):null,X=(0,l.useRef)(new Map),Z=(0,l.useMemo)(()=>(Array.isArray(e)?e:e?[e]:[]).map(e=>{if(e instanceof File)return e;if(typeof e==`string`){let t=X.current.get(e);return t||(t=v(e,C),X.current.set(e,t)),t}return e}),[e,C]),Q=(0,l.useMemo)(()=>g||(h?a.createUploadThingUploadHandler(h):m?a.createApiUploadHandler(m):null),[g,h,m]),ne=async(e,t)=>{if(!u)e.forEach(e=>t.onSuccess(e));else if(Q)try{(await Q(e,{onProgress:t.onProgress,onSuccess:(e,n)=>{e.uploadedUrl=n.url,t.onSuccess(e)},onError:(e,n)=>{t.onError(e,n)}})).forEach((t,n)=>{let r=e[n];r&&(r.uploadedUrl=t.url)})}catch{}else p?await Promise.all(e.map(async e=>{let n=e;if(n.isUploadedUrl)t.onSuccess(e);else try{t.onProgress(e,20),n.uploadedUrl=await p(e),t.onProgress(e,100),t.onSuccess(e)}catch(n){t.onError(e,n instanceof Error?n:Error(`Upload failed`))}})):(console.warn(`FileUpload: autoUpload is true but no upload handler or config was provided.`),e.forEach(e=>t.onError(e,Error(`Missing upload configuration`))))},$=`${_>1?`Up to ${_} files`:`1 file max`} ${x?`(Max ${a.formatFileSize(x)})`:``}`,re=k===`avatar`?!1:T??_>1;return(0,c.jsxs)(o.FileUpload,{value:Z,maxFiles:k===`avatar`?1:_,maxSize:x,minSize:S,accept:C,multiple:re,disabled:E,invalid:!!(H||te||J&&J.length>0),onUpload:ne,onFileReject:G,onAccept:K,className:D,sx:O,children:[(0,c.jsx)(f,{onChange:s,autoUpload:!!u,maxFiles:k===`avatar`?1:_,onResetReject:q}),k===`avatar`?(0,c.jsx)(ee,{showProgress:P,maxSize:x,errorElem:Y}):k===`compact`?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)(o.FileUploadDropzone,{sx:d.compactDropzone,children:[(0,c.jsx)(`div`,{className:`x78zum5 x6s0dn4 xl56j7k xs5h3dt xettwda x9psvww xmkeg23 x1y0btm7 xb30jbz x1rexohn xw3nh4a x2lah0s`,children:M||(0,c.jsx)(t.Icons.CloudUpload,{size:18})}),(0,c.jsxs)(`div`,{className:`x78zum5 xdt5ytf x98rzlu xeuugli`,children:[(0,c.jsx)(n.Text,{size:`sm`,weight:`medium`,children:A||`Choose or drop files to upload`}),(0,c.jsx)(n.Text,{size:`xs`,type:`muted`,children:j||$})]}),(0,c.jsx)(o.FileUploadTrigger,{asChild:!0,children:(0,c.jsx)(r.Button,{variant:`outline`,size:`sm`,disabled:E,children:`Browse`})})]}),I&&(0,c.jsx)(b,{clearBtnRowSx:d.clearBtnRow,clearBtnSx:d.clearBtn}),N&&(0,c.jsx)(y,{showPreview:F,showProgress:P,orientation:`horizontal`,avatarImgSx:d.avatarImg,deleteBtnSx:d.deleteBtn}),Y]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)(o.FileUploadDropzone,{children:[(0,c.jsx)(`div`,{className:`x78zum5 x6s0dn4 xl56j7k xvm51jw xwaiz5r x9psvww xmkeg23 x1y0btm7 xb30jbz x1rexohn xw3nh4a x1hpqcdg`,children:M||(0,c.jsx)(t.Icons.CloudUpload,{size:20})}),(0,c.jsx)(n.Text,{size:`md`,weight:`medium`,children:A||`Drag & drop files here, or click to select`}),(0,c.jsx)(n.Text,{size:`xs`,type:`muted`,children:j||$})]}),I&&(0,c.jsx)(b,{clearBtnRowSx:d.clearBtnRow,clearBtnSx:d.clearBtn}),N&&(0,c.jsx)(y,{showPreview:F,showProgress:P,orientation:`vertical`,avatarImgSx:d.avatarImg,deleteBtnSx:d.deleteBtn}),Y]})]})}exports.FileUpload=T;
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import { type ReactElement, type ReactNode } from 'react';
2
2
  import * as stylex from '@stylexjs/stylex';
3
3
  import { type ApiStorageConfig, type UploadThingStorageConfig, type UploadHandler } from '../../ui/file-upload';
4
4
  /**
@@ -25,6 +25,10 @@ export type FileUploadBaseProps = {
25
25
  * @default 5242880
26
26
  */
27
27
  maxSize?: number;
28
+ /**
29
+ * Minimum allowed file size in bytes.
30
+ */
31
+ minSize?: number;
28
32
  /**
29
33
  * Accepted MIME types or extensions (e.g., 'image/*', '.pdf').
30
34
  * @default "image/*"
@@ -66,7 +70,7 @@ export type FileUploadBaseProps = {
66
70
  /**
67
71
  * Custom icon element rendered inside dropzone.
68
72
  */
69
- icon?: React.ReactNode;
73
+ icon?: ReactNode;
70
74
  /**
71
75
  * Whether to display the uploaded file list below the dropzone.
72
76
  * @default true
@@ -87,6 +91,40 @@ export type FileUploadBaseProps = {
87
91
  * @default false
88
92
  */
89
93
  showClear?: boolean;
94
+ /**
95
+ * Single error message or error object to display.
96
+ */
97
+ error?: string | {
98
+ message?: string;
99
+ } | null;
100
+ /**
101
+ * Array of errors to display via `<FieldError>`.
102
+ */
103
+ errors?: Array<{
104
+ message?: string;
105
+ } | undefined>;
106
+ /**
107
+ * Callback fired when a file is rejected during selection/drop (e.g. exceeds maxSize, invalid format).
108
+ */
109
+ onFileReject?: (file: File, message: string) => void;
110
+ /**
111
+ * Callback fired when valid files are accepted.
112
+ */
113
+ onAccept?: (files: File[]) => void;
114
+ /**
115
+ * If true, suppresses the internal `<FieldError>` rendering.
116
+ * Useful when wrapped by FormBase which renders its own FieldError.
117
+ * @default false
118
+ */
119
+ hideError?: boolean;
120
+ /**
121
+ * Whether the field is marked as invalid.
122
+ */
123
+ invalid?: boolean;
124
+ /**
125
+ * Accessibility attribute indicating the field has an error.
126
+ */
127
+ 'aria-invalid'?: boolean | 'true' | 'false';
90
128
  };
91
129
  /**
92
130
  * Props for automatic upload mode.
@@ -134,5 +172,5 @@ export type FileUploadProps = FileUploadBaseProps & (FileUploadAutoProps | FileU
134
172
  * Supports auto-upload via UploadThing (AWS S3) or custom HTTP APIs,
135
173
  * as well as manual deferred upload on form submission.
136
174
  */
137
- export declare function FileUpload({ value, onChange, autoUpload, uploadFile, apiConfig, uploadThingConfig, uploadHandler, maxFiles, maxSize, accept, multiple, disabled, className, sx, variant, dropzoneTitle, dropzoneSubtitle, icon, showFileList, showProgress, showPreview, showClear, }: FileUploadProps): React.JSX.Element;
175
+ export declare function FileUpload({ value, onChange, autoUpload, uploadFile, apiConfig, uploadThingConfig, uploadHandler, maxFiles, maxSize, minSize, accept, multiple, disabled, className, sx, variant, dropzoneTitle, dropzoneSubtitle, icon, showFileList, showProgress, showPreview, showClear, error, errors, onFileReject, onAccept, hideError, invalid, 'aria-invalid': ariaInvalid, }: FileUploadProps): ReactElement;
138
176
  //# sourceMappingURL=FileUpload.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FileUpload.d.ts","sourceRoot":"","sources":["../../../src/Form/FormFileUpload/FileUpload.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAeL,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,KAAK,aAAa,EACnB,MAAM,sBAAsB,CAAC;AAyL9B;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC;IAC1C;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,GAAG,IAAI,EAAE,GAAG,IAAI,KAAK,IAAI,CAAC;IACrE;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC,YAAY,CAAC;IACzB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;IAC3C;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,wDAAwD;IACxD,UAAU,EAAE,IAAI,CAAC;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,KAAK,GAAG,aAAa,GAAG,QAAQ,CAAC;IAC3C;;OAEG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7C;;OAEG;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B;;OAEG;IACH,iBAAiB,CAAC,EAAE,wBAAwB,CAAC;IAC7C;;OAEG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB,iBAAiB,CAAC,EAAE,KAAK,CAAC;IAC1B,aAAa,CAAC,EAAE,KAAK,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,CAAC,mBAAmB,GAAG,qBAAqB,CAAC,CAAC;AAqOlG;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,QAAQ,EACR,UAAkB,EAClB,UAAU,EACV,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,QAAY,EACZ,OAAyB,EACzB,MAAkB,EAClB,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,EAAE,EACF,OAAmB,EACnB,aAAa,EACb,gBAAgB,EAChB,IAAI,EACJ,YAAmB,EACnB,YAAmB,EACnB,WAAkB,EAClB,SAAiB,GAClB,EAAE,eAAe,qBAyLjB"}
1
+ {"version":3,"file":"FileUpload.d.ts","sourceRoot":"","sources":["../../../src/Form/FormFileUpload/FileUpload.tsx"],"names":[],"mappings":"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"}
@@ -1,14 +1,15 @@
1
1
  import { Icons as e } from "../../Icons/Icons.js";
2
2
  import { Text as t } from "../../Typography/Text.js";
3
3
  import { Button as n } from "../../ui/button.js";
4
- import { createApiUploadHandler as r, createUploadThingUploadHandler as i, formatFileSize as a } from "../../ui/file-upload-adapters.js";
5
- import { FileUpload as o, FileUploadClear as s, FileUploadDropzone as c, FileUploadItem as l, FileUploadItemDelete as u, FileUploadItemMetadata as d, FileUploadItemPreview as f, FileUploadItemProgress as p, FileUploadList as m, FileUploadTrigger as h, useFileUpload as g } from "../../ui/file-upload.js";
4
+ import { FieldError as r } from "../../ui/field.js";
5
+ import { createApiUploadHandler as i, createUploadThingUploadHandler as a, formatFileSize as o } from "../../ui/file-upload-adapters.js";
6
+ import { FileUpload as s, FileUploadClear as c, FileUploadDropzone as l, FileUploadItem as u, FileUploadItemDelete as d, FileUploadItemMetadata as f, FileUploadItemPreview as p, FileUploadItemProgress as m, FileUploadList as h, FileUploadTrigger as ee, useFileUpload as g } from "../../ui/file-upload.js";
6
7
  import * as _ from "@stylexjs/stylex";
7
8
  import { Fragment as v, jsx as y, jsxs as b } from "react/jsx-runtime";
8
- import * as x from "react";
9
- import { c as S } from "react/compiler-runtime";
9
+ import { useCallback as x, useEffect as S, useMemo as C, useRef as w, useState as te } from "react";
10
+ import { c as T } from "react/compiler-runtime";
10
11
  // src/Form/FormFileUpload/FileUpload.tsx
11
- var C = {
12
+ var E = {
12
13
  avatarDropzone: {
13
14
  kVAEAm: "x1n2onr6",
14
15
  kzqmXN: "x1eyvef",
@@ -117,44 +118,45 @@ var C = {
117
118
  $$css: !0
118
119
  }
119
120
  };
120
- function w(e) {
121
- let t = S(6), { onChange: n, autoUpload: r, maxFiles: i } = e, a = g(k), o = x.useRef(null), s = x.useRef(!0), c, l;
122
- return t[0] !== r || t[1] !== i || t[2] !== n || t[3] !== a ? (c = () => {
121
+ function ne(e) {
122
+ let t = T(7), { onChange: n, autoUpload: r, maxFiles: i, onResetReject: a } = e, o = g(j), s = w(null), c = w(!0), l, u;
123
+ return t[0] !== r || t[1] !== i || t[2] !== n || t[3] !== a || t[4] !== o ? (l = () => {
123
124
  if (!n) return;
124
- let e = Array.from(a.files.values());
125
- if (s.current && (s.current = !1, e.length === 0)) return;
125
+ let e = Array.from(o.files.values());
126
+ if (c.current && (c.current = !1, e.length === 0)) return;
126
127
  let t = (() => {
127
128
  if (r) {
128
- let t = e.filter(O).map(D).filter(E);
129
+ let t = e.filter(A).map(k).filter(O);
129
130
  return i === 1 ? t.length > 0 ? t[t.length - 1] : null : t;
130
131
  }
131
- let t = e.map(T);
132
+ let t = e.map(D);
132
133
  return i === 1 ? t.length > 0 ? t[t.length - 1] : null : t;
133
- })(), c = o.current;
134
- (r ? JSON.stringify(c) === JSON.stringify(t) : Array.isArray(t) && Array.isArray(c) ? t.length === c.length && t.every((e, t) => e === c[t]) : t === c) || (o.current = t, n(t));
135
- }, l = [
136
- a,
134
+ })(), l = s.current;
135
+ (r ? JSON.stringify(l) === JSON.stringify(t) : Array.isArray(t) && Array.isArray(l) ? t.length === l.length && t.every((e, t) => e === l[t]) : t === l) || (s.current = t, n(t), a?.());
136
+ }, u = [
137
+ o,
137
138
  r,
138
139
  i,
139
- n
140
- ], t[0] = r, t[1] = i, t[2] = n, t[3] = a, t[4] = c, t[5] = l) : (c = t[4], l = t[5]), x.useEffect(c, l), null;
140
+ n,
141
+ a
142
+ ], t[0] = r, t[1] = i, t[2] = n, t[3] = a, t[4] = o, t[5] = l, t[6] = u) : (l = t[5], u = t[6]), S(l, u), null;
141
143
  }
142
- function T(e) {
144
+ function D(e) {
143
145
  return e.file;
144
146
  }
145
- function E(e) {
147
+ function O(e) {
146
148
  return !!e;
147
149
  }
148
- function D(e) {
150
+ function k(e) {
149
151
  return e.file.uploadedUrl;
150
152
  }
151
- function O(e) {
153
+ function A(e) {
152
154
  return e.status === "success";
153
155
  }
154
- function k(e) {
156
+ function j(e) {
155
157
  return e;
156
158
  }
157
- function A(e, t = "") {
159
+ function re(e, t = "") {
158
160
  let n = e.split("/").pop()?.split("?")[0] || "file", r = n.split(".").pop()?.toLowerCase(), i = r && {
159
161
  jpg: "image/jpeg",
160
162
  jpeg: "image/jpeg",
@@ -167,14 +169,14 @@ function A(e, t = "") {
167
169
  let a = new File([""], n, { type: i });
168
170
  return a.isUploadedUrl = !0, a.uploadedUrl = e, a;
169
171
  }
170
- function j({ showPreview: t, showProgress: r, orientation: i = "vertical", avatarImgSx: a, deleteBtnSx: o }) {
172
+ function M({ showPreview: t, showProgress: r, orientation: i = "vertical", avatarImgSx: a, deleteBtnSx: o }) {
171
173
  let s = g((e) => Array.from(e.files.values()).map((e) => e.file));
172
- return s.length === 0 ? null : /* @__PURE__ */ y(m, {
174
+ return s.length === 0 ? null : /* @__PURE__ */ y(h, {
173
175
  orientation: i,
174
- children: s.map((s, c) => /* @__PURE__ */ b(l, {
176
+ children: s.map((s, c) => /* @__PURE__ */ b(u, {
175
177
  value: s,
176
178
  children: [
177
- t && /* @__PURE__ */ y(f, { render: (e, t) => {
179
+ t && /* @__PURE__ */ y(p, { render: (e, t) => {
178
180
  let n = e.uploadedUrl || (e.type.startsWith("image/") && typeof URL < "u" && URL.createObjectURL ? URL.createObjectURL(e) : null);
179
181
  return n && e.type.startsWith("image/") ? /* @__PURE__ */ y("img", {
180
182
  src: n,
@@ -182,9 +184,9 @@ function j({ showPreview: t, showProgress: r, orientation: i = "vertical", avata
182
184
  ..._.props(a)
183
185
  }) : t();
184
186
  } }),
185
- /* @__PURE__ */ y(d, {}),
186
- r && /* @__PURE__ */ y(p, { variant: "bottom" }),
187
- /* @__PURE__ */ y(u, {
187
+ /* @__PURE__ */ y(f, {}),
188
+ r && /* @__PURE__ */ y(m, { variant: "bottom" }),
189
+ /* @__PURE__ */ y(d, {
188
190
  asChild: !0,
189
191
  children: /* @__PURE__ */ y(n, {
190
192
  variant: "ghost",
@@ -198,22 +200,22 @@ function j({ showPreview: t, showProgress: r, orientation: i = "vertical", avata
198
200
  }, `${s.name}-${c}`))
199
201
  });
200
202
  }
201
- function M(t) {
202
- let n = S(10), { clearBtnRowSx: r, clearBtnSx: i } = t;
203
- if (g(N) === 0) return null;
203
+ function N(t) {
204
+ let n = T(10), { clearBtnRowSx: r, clearBtnSx: i } = t;
205
+ if (g(P) === 0) return null;
204
206
  let a;
205
207
  n[0] === r ? a = n[1] : (a = _.props(r), n[0] = r, n[1] = a);
206
208
  let o;
207
209
  n[2] === i ? o = n[3] : (o = _.props(i), n[2] = i, n[3] = o);
208
- let c;
209
- n[4] === Symbol.for("react.memo_cache_sentinel") ? (c = /* @__PURE__ */ y(e.Trash2, { size: 13 }), n[4] = c) : c = n[4];
210
+ let s;
211
+ n[4] === Symbol.for("react.memo_cache_sentinel") ? (s = /* @__PURE__ */ y(e.Trash2, { size: 13 }), n[4] = s) : s = n[4];
210
212
  let l;
211
- n[5] === o ? l = n[6] : (l = /* @__PURE__ */ y(s, {
213
+ n[5] === o ? l = n[6] : (l = /* @__PURE__ */ y(c, {
212
214
  asChild: !0,
213
215
  children: /* @__PURE__ */ b("button", {
214
216
  type: "button",
215
217
  ...o,
216
- children: [c, "Clear all"]
218
+ children: [s, "Clear all"]
217
219
  })
218
220
  }), n[5] = o, n[6] = l);
219
221
  let u;
@@ -222,31 +224,31 @@ function M(t) {
222
224
  children: l
223
225
  }), n[7] = a, n[8] = l, n[9] = u) : u = n[9], u;
224
226
  }
225
- function N(e) {
227
+ function P(e) {
226
228
  return e.files.size;
227
229
  }
228
- function P(n) {
229
- let r = S(8), { showProgress: i, maxSize: o } = n, s = g(I), u;
230
- r[0] !== s || r[1] !== i ? (u = /* @__PURE__ */ y(c, {
231
- sx: C.avatarDropzone,
232
- children: s ? /* @__PURE__ */ b(l, {
233
- value: s,
234
- sx: C.avatarItem,
230
+ function F(n) {
231
+ let r = T(9), { showProgress: i, maxSize: a, errorElem: s } = n, c = g(L), d;
232
+ r[0] !== c || r[1] !== i ? (d = /* @__PURE__ */ y(l, {
233
+ sx: E.avatarDropzone,
234
+ children: c ? /* @__PURE__ */ b(u, {
235
+ value: c,
236
+ sx: E.avatarItem,
235
237
  children: [
236
- /* @__PURE__ */ y(f, {
237
- sx: C.avatarPreview,
238
- render: F
238
+ /* @__PURE__ */ y(p, {
239
+ sx: E.avatarPreview,
240
+ render: I
239
241
  }),
240
242
  /* @__PURE__ */ b("div", {
241
243
  className: "x10l6tqk x10a8y8t x78zum5 xdt5ytf x6s0dn4 xl56j7k xvh977a xa44r0r xstwp1q xg01cxk x19991ni x13dflua x1o7uuvo",
242
244
  children: [/* @__PURE__ */ y(e.Camera, { size: 22 }), /* @__PURE__ */ y(t, {
243
245
  size: "xs",
244
246
  weight: "semibold",
245
- sx: C.whiteText,
247
+ sx: E.whiteText,
246
248
  children: "Change photo"
247
249
  })]
248
250
  }),
249
- i && /* @__PURE__ */ y(p, {
251
+ i && /* @__PURE__ */ y(m, {
250
252
  variant: "fill",
251
253
  style: { opacity: .5 }
252
254
  })
@@ -259,20 +261,24 @@ function P(n) {
259
261
  children: "Upload"
260
262
  })]
261
263
  })
262
- }), r[0] = s, r[1] = i, r[2] = u) : u = r[2];
263
- let d;
264
- r[3] === o ? d = r[4] : (d = o ? /* @__PURE__ */ b(t, {
264
+ }), r[0] = c, r[1] = i, r[2] = d) : d = r[2];
265
+ let f;
266
+ r[3] === a ? f = r[4] : (f = a ? /* @__PURE__ */ b(t, {
265
267
  size: "xs",
266
268
  type: "muted",
267
- children: ["Max ", a(o)]
268
- }) : null, r[3] = o, r[4] = d);
269
- let m;
270
- return r[5] !== u || r[6] !== d ? (m = /* @__PURE__ */ b("div", {
269
+ children: ["Max ", o(a)]
270
+ }) : null, r[3] = a, r[4] = f);
271
+ let h;
272
+ return r[5] !== s || r[6] !== d || r[7] !== f ? (h = /* @__PURE__ */ b("div", {
271
273
  className: "x78zum5 xdt5ytf x6s0dn4 x13z6uf9",
272
- children: [u, d]
273
- }), r[5] = u, r[6] = d, r[7] = m) : m = r[7], m;
274
+ children: [
275
+ d,
276
+ f,
277
+ s
278
+ ]
279
+ }), r[5] = s, r[6] = d, r[7] = f, r[8] = h) : h = r[8], h;
274
280
  }
275
- function F(n) {
281
+ function I(n) {
276
282
  let r = n.uploadedUrl || (n.type.startsWith("image/") && typeof URL < "u" && URL.createObjectURL ? URL.createObjectURL(n) : null);
277
283
  return r ? /* @__PURE__ */ y("img", {
278
284
  src: r,
@@ -287,26 +293,45 @@ function F(n) {
287
293
  })]
288
294
  });
289
295
  }
290
- function I(e) {
296
+ function L(e) {
291
297
  let t = e.files.values().next();
292
298
  return t.done ? null : t.value.file;
293
299
  }
294
- function L({ value: s, onChange: l, autoUpload: u = !1, uploadFile: d, apiConfig: f, uploadThingConfig: p, uploadHandler: m, maxFiles: g = 1, maxSize: _ = 5242880, accept: S = "image/*", multiple: T, disabled: E, className: D, sx: O, variant: k = "default", dropzoneTitle: N, dropzoneSubtitle: F, icon: I, showFileList: L = !0, showProgress: R = !0, showPreview: z = !0, showClear: B = !1 }) {
295
- let V = x.useRef(/* @__PURE__ */ new Map()), H = x.useMemo(() => (Array.isArray(s) ? s : s ? [s] : []).map((e) => {
300
+ function ie(e, t, n = []) {
301
+ if (e && e.length > 0) return e;
302
+ if (t) return [typeof t == "string" ? { message: t } : t];
303
+ if (n.length > 0) return n.map((e) => ({ message: e }));
304
+ }
305
+ function R({ value: c, onChange: u, autoUpload: d = !1, uploadFile: f, apiConfig: p, uploadThingConfig: m, uploadHandler: h, maxFiles: g = 1, maxSize: _ = 5242880, minSize: T, accept: D = "image/*", multiple: O, disabled: k, className: A, sx: j, variant: P = "default", dropzoneTitle: I, dropzoneSubtitle: L, icon: R, showFileList: z = !0, showProgress: B = !0, showPreview: V = !0, showClear: H = !1, error: U, errors: W, onFileReject: G, onAccept: K, hideError: ae = !1, invalid: oe, "aria-invalid": se }) {
306
+ let [q, J] = te([]), ce = x((e, t) => {
307
+ J((e) => e.includes(t) ? e : [...e, t]), G?.(e, t);
308
+ }, [G]), le = x((e) => {
309
+ J([]), K?.(e);
310
+ }, [K]), ue = x(() => {
311
+ J([]);
312
+ }, []);
313
+ S(() => {
314
+ J([]);
315
+ }, [c]);
316
+ let Y = C(() => ie(W, U, q), [
317
+ W,
318
+ U,
319
+ q
320
+ ]), X = !ae && Y && Y.length > 0 ? /* @__PURE__ */ y(r, { errors: Y }) : null, Z = w(/* @__PURE__ */ new Map()), de = C(() => (Array.isArray(c) ? c : c ? [c] : []).map((e) => {
296
321
  if (e instanceof File) return e;
297
322
  if (typeof e == "string") {
298
- let t = V.current.get(e);
299
- return t || (t = A(e, S), V.current.set(e, t)), t;
323
+ let t = Z.current.get(e);
324
+ return t || (t = re(e, D), Z.current.set(e, t)), t;
300
325
  }
301
326
  return e;
302
- }), [s, S]), U = x.useMemo(() => m || (p ? i(p) : f ? r(f) : null), [
327
+ }), [c, D]), Q = C(() => h || (m ? a(m) : p ? i(p) : null), [
328
+ h,
303
329
  m,
304
- p,
305
- f
306
- ]), W = async (e, t) => {
307
- if (!u) e.forEach((e) => t.onSuccess(e));
308
- else if (U) try {
309
- (await U(e, {
330
+ p
331
+ ]), fe = async (e, t) => {
332
+ if (!d) e.forEach((e) => t.onSuccess(e));
333
+ else if (Q) try {
334
+ (await Q(e, {
310
335
  onProgress: t.onProgress,
311
336
  onSuccess: (e, n) => {
312
337
  e.uploadedUrl = n.url, t.onSuccess(e);
@@ -319,104 +344,112 @@ function L({ value: s, onChange: l, autoUpload: u = !1, uploadFile: d, apiConfig
319
344
  r && (r.uploadedUrl = t.url);
320
345
  });
321
346
  } catch {}
322
- else d ? await Promise.all(e.map(async (e) => {
347
+ else f ? await Promise.all(e.map(async (e) => {
323
348
  let n = e;
324
349
  if (n.isUploadedUrl) t.onSuccess(e);
325
350
  else try {
326
- t.onProgress(e, 20), n.uploadedUrl = await d(e), t.onProgress(e, 100), t.onSuccess(e);
351
+ t.onProgress(e, 20), n.uploadedUrl = await f(e), t.onProgress(e, 100), t.onSuccess(e);
327
352
  } catch (n) {
328
353
  t.onError(e, n instanceof Error ? n : /* @__PURE__ */ Error("Upload failed"));
329
354
  }
330
355
  })) : (console.warn("FileUpload: autoUpload is true but no upload handler or config was provided."), e.forEach((e) => t.onError(e, /* @__PURE__ */ Error("Missing upload configuration"))));
331
- }, G = `${g > 1 ? `Up to ${g} files` : "1 file max"} ${_ ? `(Max ${a(_)})` : ""}`;
332
- return /* @__PURE__ */ b(o, {
333
- value: H,
334
- maxFiles: k === "avatar" ? 1 : g,
356
+ }, $ = `${g > 1 ? `Up to ${g} files` : "1 file max"} ${_ ? `(Max ${o(_)})` : ""}`;
357
+ return /* @__PURE__ */ b(s, {
358
+ value: de,
359
+ maxFiles: P === "avatar" ? 1 : g,
335
360
  maxSize: _,
336
- accept: S,
337
- multiple: k === "avatar" ? !1 : T ?? g > 1,
338
- disabled: E,
339
- onUpload: W,
340
- className: D,
341
- sx: O,
342
- children: [/* @__PURE__ */ y(w, {
343
- onChange: l,
344
- autoUpload: !!u,
345
- maxFiles: k === "avatar" ? 1 : g
346
- }), k === "avatar" ? /* @__PURE__ */ y(P, {
347
- showProgress: R,
348
- maxSize: _
349
- }) : k === "compact" ? /* @__PURE__ */ b(v, { children: [
350
- /* @__PURE__ */ b(c, {
351
- sx: C.compactDropzone,
361
+ minSize: T,
362
+ accept: D,
363
+ multiple: P === "avatar" ? !1 : O ?? g > 1,
364
+ disabled: k,
365
+ invalid: !!(oe || se || Y && Y.length > 0),
366
+ onUpload: fe,
367
+ onFileReject: ce,
368
+ onAccept: le,
369
+ className: A,
370
+ sx: j,
371
+ children: [/* @__PURE__ */ y(ne, {
372
+ onChange: u,
373
+ autoUpload: !!d,
374
+ maxFiles: P === "avatar" ? 1 : g,
375
+ onResetReject: ue
376
+ }), P === "avatar" ? /* @__PURE__ */ y(F, {
377
+ showProgress: B,
378
+ maxSize: _,
379
+ errorElem: X
380
+ }) : P === "compact" ? /* @__PURE__ */ b(v, { children: [
381
+ /* @__PURE__ */ b(l, {
382
+ sx: E.compactDropzone,
352
383
  children: [
353
384
  /* @__PURE__ */ y("div", {
354
385
  className: "x78zum5 x6s0dn4 xl56j7k xs5h3dt xettwda x9psvww xmkeg23 x1y0btm7 xb30jbz x1rexohn xw3nh4a x2lah0s",
355
- children: I || /* @__PURE__ */ y(e.CloudUpload, { size: 18 })
386
+ children: R || /* @__PURE__ */ y(e.CloudUpload, { size: 18 })
356
387
  }),
357
388
  /* @__PURE__ */ b("div", {
358
389
  className: "x78zum5 xdt5ytf x98rzlu xeuugli",
359
390
  children: [/* @__PURE__ */ y(t, {
360
391
  size: "sm",
361
392
  weight: "medium",
362
- children: N || "Choose or drop files to upload"
393
+ children: I || "Choose or drop files to upload"
363
394
  }), /* @__PURE__ */ y(t, {
364
395
  size: "xs",
365
396
  type: "muted",
366
- children: F || G
397
+ children: L || $
367
398
  })]
368
399
  }),
369
- /* @__PURE__ */ y(h, {
400
+ /* @__PURE__ */ y(ee, {
370
401
  asChild: !0,
371
402
  children: /* @__PURE__ */ y(n, {
372
403
  variant: "outline",
373
404
  size: "sm",
374
- disabled: E,
405
+ disabled: k,
375
406
  children: "Browse"
376
407
  })
377
408
  })
378
409
  ]
379
410
  }),
380
- B && /* @__PURE__ */ y(M, {
381
- clearBtnRowSx: C.clearBtnRow,
382
- clearBtnSx: C.clearBtn
411
+ H && /* @__PURE__ */ y(N, {
412
+ clearBtnRowSx: E.clearBtnRow,
413
+ clearBtnSx: E.clearBtn
383
414
  }),
384
- L && /* @__PURE__ */ y(j, {
385
- showPreview: z,
386
- showProgress: R,
415
+ z && /* @__PURE__ */ y(M, {
416
+ showPreview: V,
417
+ showProgress: B,
387
418
  orientation: "horizontal",
388
- avatarImgSx: C.avatarImg,
389
- deleteBtnSx: C.deleteBtn
390
- })
419
+ avatarImgSx: E.avatarImg,
420
+ deleteBtnSx: E.deleteBtn
421
+ }),
422
+ X
391
423
  ] }) : /* @__PURE__ */ b(v, { children: [
392
- /* @__PURE__ */ b(c, { children: [
424
+ /* @__PURE__ */ b(l, { children: [
393
425
  /* @__PURE__ */ y("div", {
394
426
  className: "x78zum5 x6s0dn4 xl56j7k xvm51jw xwaiz5r x9psvww xmkeg23 x1y0btm7 xb30jbz x1rexohn xw3nh4a x1hpqcdg",
395
- children: I || /* @__PURE__ */ y(e.CloudUpload, { size: 20 })
427
+ children: R || /* @__PURE__ */ y(e.CloudUpload, { size: 20 })
396
428
  }),
397
429
  /* @__PURE__ */ y(t, {
398
430
  size: "md",
399
431
  weight: "medium",
400
- children: N || "Drag & drop files here, or click to select"
432
+ children: I || "Drag & drop files here, or click to select"
401
433
  }),
402
434
  /* @__PURE__ */ y(t, {
403
435
  size: "xs",
404
436
  type: "muted",
405
- children: F || G
437
+ children: L || $
406
438
  })
407
439
  ] }),
408
- B && /* @__PURE__ */ y(M, {
409
- clearBtnRowSx: C.clearBtnRow,
410
- clearBtnSx: C.clearBtn
440
+ H && /* @__PURE__ */ y(N, {
441
+ clearBtnRowSx: E.clearBtnRow,
442
+ clearBtnSx: E.clearBtn
411
443
  }),
412
- L && /* @__PURE__ */ y(j, {
413
- showPreview: z,
414
- showProgress: R,
444
+ z && /* @__PURE__ */ y(M, {
445
+ showPreview: V,
446
+ showProgress: B,
415
447
  orientation: "vertical",
416
- avatarImgSx: C.avatarImg,
417
- deleteBtnSx: C.deleteBtn
418
- })
448
+ avatarImgSx: E.avatarImg,
449
+ deleteBtnSx: E.deleteBtn
450
+ }),
451
+ X
419
452
  ] })]
420
453
  });
421
454
  }
422
- export { L as FileUpload };
455
+ export { R as FileUpload };
@@ -1 +1 @@
1
- const e=require("../Form.cjs"),t=require("./FileUpload.cjs");let n=require("react/jsx-runtime"),r=require("react/compiler-runtime");var i=i=>{let a=(0,r.c)(13),o,s,c,l;if(a[0]!==i){let{control:e,name:t,rules:n,label:r,description:u,htmlType:d,width:f,className:p,sx:m,disabled:h,...g}=i;o=p,l=m,s=h,c=g,a[0]=i,a[1]=o,a[2]=s,a[3]=c,a[4]=l}else o=a[1],s=a[2],c=a[3],l=a[4];let u;a[5]!==o||a[6]!==s||a[7]!==c||a[8]!==l?(u=e=>{let{onChange:r,value:i,disabled:a}=e;return(0,n.jsx)(t.FileUpload,{...c,value:i,onChange:r,disabled:a||s,className:o,sx:l})},a[5]=o,a[6]=s,a[7]=c,a[8]=l,a[9]=u):u=a[9];let d;return a[10]!==i||a[11]!==u?(d=(0,n.jsx)(e.FormBase,{...i,children:u}),a[10]=i,a[11]=u,a[12]=d):d=a[12],d},a=i;exports.FileDropzone=t.FileUpload,exports.FormFileUpload=i,exports.default=i,exports.FormFileUploader=a;
1
+ const e=require("../../node_modules/.pnpm/react-hook-form@7.83.0_react@19.3.1/node_modules/react-hook-form/dist/index.esm.cjs"),t=require("../Form.cjs"),n=require("./FileUpload.cjs");let r=require("react/jsx-runtime");require("react");let i=require("react/compiler-runtime");function a(e){return typeof e!=`object`||!e?!1:`setError`in e&&`clearErrors`in e}function o(e,t,n,r){let i={type:`validate`,message:r};e?.setError?e.setError(n,i,{shouldFocus:!0}):a(t)&&t.setError(n,i,{shouldFocus:!0})}function s(e,t,n){e?.clearErrors?e.clearErrors(n):a(t)&&t.clearErrors(n)}var c=a=>{let c=(0,i.c)(32),l,u,d,f,p,m,h,g;if(c[0]!==a){let{control:e,name:t,rules:n,label:r,description:i,htmlType:o,width:s,className:_,sx:v,disabled:y,onFileReject:b,onAccept:x,...S}=a;u=e,d=t,l=_,m=v,f=y,g=b,h=x,p=S,c[0]=a,c[1]=l,c[2]=u,c[3]=d,c[4]=f,c[5]=p,c[6]=m,c[7]=h,c[8]=g}else l=c[1],u=c[2],d=c[3],f=c[4],p=c[5],m=c[6],h=c[7],g=c[8];let _=e.useFormContext(),v;c[9]!==u||c[10]!==_||c[11]!==d||c[12]!==g?(v=(e,t)=>{o(_,u,d,t),g?.(e,t)},c[9]=u,c[10]=_,c[11]=d,c[12]=g,c[13]=v):v=c[13];let y=v,b;c[14]!==u||c[15]!==_||c[16]!==d||c[17]!==h?(b=e=>{s(_,u,d),h?.(e)},c[14]=u,c[15]=_,c[16]=d,c[17]=h,c[18]=b):b=c[18];let x=b,S;c[19]!==l||c[20]!==u||c[21]!==_||c[22]!==x||c[23]!==y||c[24]!==d||c[25]!==f||c[26]!==p||c[27]!==m?(S=e=>{let{onChange:t,value:i,disabled:a,"aria-invalid":o}=e;return(0,r.jsx)(n.FileUpload,{...p,value:i,onChange:e=>{(!e||Array.isArray(e)&&e.length===0)&&s(_,u,d),t(e)},onFileReject:y,onAccept:x,hideError:!!o,disabled:a||f,className:l,sx:m})},c[19]=l,c[20]=u,c[21]=_,c[22]=x,c[23]=y,c[24]=d,c[25]=f,c[26]=p,c[27]=m,c[28]=S):S=c[28];let C;return c[29]!==a||c[30]!==S?(C=(0,r.jsx)(t.FormBase,{...a,children:S}),c[29]=a,c[30]=S,c[31]=C):C=c[31],C},l=c;exports.FileDropzone=n.FileUpload,exports.FormFileUpload=c,exports.default=c,exports.FormFileUploader=l;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Form/FormFileUpload/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EACL,UAAU,EACV,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC3B,MAAM,cAAc,CAAC;AAEtB,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,CAAC;AAEjG;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG,IAAI,CAAC,eAAe,EAAE,OAAO,GAAG,UAAU,CAAC,CAAC;AACnF,MAAM,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAE7D;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,EAAE,eAAe,CAAC,wBAAwB,CA6BpE,CAAC;AAEF,eAAO,MAAM,gBAAgB,2CAAiB,CAAC;eAChC,cAAc;AAC7B,OAAO,EAAE,UAAU,IAAI,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Form/FormFileUpload/index.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EACL,UAAU,EACV,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC3B,MAAM,cAAc,CAAC;AAEtB,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,CAAC;AAmEjG;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG,IAAI,CAAC,eAAe,EAAE,OAAO,GAAG,UAAU,CAAC,CAAC;AACnF,MAAM,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAE7D;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,EAAE,eAAe,CAAC,wBAAwB,CAyDpE,CAAC;AAEF,eAAO,MAAM,gBAAgB,2CAAiB,CAAC;eAChC,cAAc;AAC7B,OAAO,EAAE,UAAU,IAAI,YAAY,EAAE,CAAC"}
@@ -1,30 +1,58 @@
1
- import { FormBase as e } from "../Form.js";
2
- import { FileUpload as t } from "./FileUpload.js";
3
- import { jsx as n } from "react/jsx-runtime";
4
- import { c as r } from "react/compiler-runtime";
1
+ import { useFormContext as e } from "../../node_modules/.pnpm/react-hook-form@7.83.0_react@19.3.1/node_modules/react-hook-form/dist/index.esm.js";
2
+ import { FormBase as t } from "../Form.js";
3
+ import { FileUpload as n } from "./FileUpload.js";
4
+ import { jsx as r } from "react/jsx-runtime";
5
+ import "react";
6
+ import { c as i } from "react/compiler-runtime";
5
7
  // src/Form/FormFileUpload/index.tsx
6
- var i = (i) => {
7
- let a = r(13), o, s, c, l;
8
- if (a[0] !== i) {
9
- let { control: e, name: t, rules: n, label: r, description: u, htmlType: d, width: f, className: p, sx: m, disabled: h, ...g } = i;
10
- o = p, l = m, s = h, c = g, a[0] = i, a[1] = o, a[2] = s, a[3] = c, a[4] = l;
11
- } else o = a[1], s = a[2], c = a[3], l = a[4];
12
- let u;
13
- a[5] !== o || a[6] !== s || a[7] !== c || a[8] !== l ? (u = (e) => {
14
- let { onChange: r, value: i, disabled: a } = e;
15
- return /* @__PURE__ */ n(t, {
16
- ...c,
8
+ function a(e) {
9
+ return typeof e != "object" || !e ? !1 : "setError" in e && "clearErrors" in e;
10
+ }
11
+ function o(e, t, n, r) {
12
+ let i = {
13
+ type: "validate",
14
+ message: r
15
+ };
16
+ e?.setError ? e.setError(n, i, { shouldFocus: !0 }) : a(t) && t.setError(n, i, { shouldFocus: !0 });
17
+ }
18
+ function s(e, t, n) {
19
+ e?.clearErrors ? e.clearErrors(n) : a(t) && t.clearErrors(n);
20
+ }
21
+ var c = (a) => {
22
+ let c = i(32), l, u, d, f, p, m, h, g;
23
+ if (c[0] !== a) {
24
+ let { control: e, name: t, rules: n, label: r, description: i, htmlType: o, width: s, className: _, sx: v, disabled: y, onFileReject: b, onAccept: x, ...S } = a;
25
+ u = e, d = t, l = _, m = v, f = y, g = b, h = x, p = S, c[0] = a, c[1] = l, c[2] = u, c[3] = d, c[4] = f, c[5] = p, c[6] = m, c[7] = h, c[8] = g;
26
+ } else l = c[1], u = c[2], d = c[3], f = c[4], p = c[5], m = c[6], h = c[7], g = c[8];
27
+ let _ = e(), v;
28
+ c[9] !== u || c[10] !== _ || c[11] !== d || c[12] !== g ? (v = (e, t) => {
29
+ o(_, u, d, t), g?.(e, t);
30
+ }, c[9] = u, c[10] = _, c[11] = d, c[12] = g, c[13] = v) : v = c[13];
31
+ let y = v, b;
32
+ c[14] !== u || c[15] !== _ || c[16] !== d || c[17] !== h ? (b = (e) => {
33
+ s(_, u, d), h?.(e);
34
+ }, c[14] = u, c[15] = _, c[16] = d, c[17] = h, c[18] = b) : b = c[18];
35
+ let x = b, S;
36
+ c[19] !== l || c[20] !== u || c[21] !== _ || c[22] !== x || c[23] !== y || c[24] !== d || c[25] !== f || c[26] !== p || c[27] !== m ? (S = (e) => {
37
+ let { onChange: t, value: i, disabled: a, "aria-invalid": o } = e;
38
+ return /* @__PURE__ */ r(n, {
39
+ ...p,
17
40
  value: i,
18
- onChange: r,
19
- disabled: a || s,
20
- className: o,
21
- sx: l
41
+ onChange: (e) => {
42
+ (!e || Array.isArray(e) && e.length === 0) && s(_, u, d), t(e);
43
+ },
44
+ onFileReject: y,
45
+ onAccept: x,
46
+ hideError: !!o,
47
+ disabled: a || f,
48
+ className: l,
49
+ sx: m
22
50
  });
23
- }, a[5] = o, a[6] = s, a[7] = c, a[8] = l, a[9] = u) : u = a[9];
24
- let d;
25
- return a[10] !== i || a[11] !== u ? (d = /* @__PURE__ */ n(e, {
26
- ...i,
27
- children: u
28
- }), a[10] = i, a[11] = u, a[12] = d) : d = a[12], d;
29
- }, a = i;
30
- export { t as FileDropzone, i as FormFileUpload, i as default, a as FormFileUploader };
51
+ }, c[19] = l, c[20] = u, c[21] = _, c[22] = x, c[23] = y, c[24] = d, c[25] = f, c[26] = p, c[27] = m, c[28] = S) : S = c[28];
52
+ let C;
53
+ return c[29] !== a || c[30] !== S ? (C = /* @__PURE__ */ r(t, {
54
+ ...a,
55
+ children: S
56
+ }), c[29] = a, c[30] = S, c[31] = C) : C = c[31], C;
57
+ }, l = c;
58
+ export { n as FileDropzone, c as FormFileUpload, c as default, l as FormFileUploader };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vlrc-fe/components",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "Enterprise UI component library built on Meta's Astryx Design System, Meta StyleX, and Radix UI.",
5
5
  "keywords": [
6
6
  "accessible",