@vlrc-fe/components 3.0.1 → 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 +23 -0
- package/dist/Form/FormFileUpload/FileUpload.cjs +1 -1
- package/dist/Form/FormFileUpload/FileUpload.d.ts +41 -3
- package/dist/Form/FormFileUpload/FileUpload.d.ts.map +1 -1
- package/dist/Form/FormFileUpload/FileUpload.js +156 -123
- package/dist/Form/FormFileUpload/index.cjs +1 -1
- package/dist/Form/FormFileUpload/index.d.ts.map +1 -1
- package/dist/Form/FormFileUpload/index.js +55 -27
- package/dist/Typography/Paragraph.cjs +1 -1
- package/dist/Typography/Paragraph.js +1 -1
- package/dist/Typography/Text.cjs +1 -1
- package/dist/Typography/Text.js +3 -3
- package/dist/Typography/Title.cjs +1 -1
- package/dist/Typography/Title.d.ts.map +1 -1
- package/dist/Typography/Title.js +2 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Changelog
|
|
2
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
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- **Typography Color Inheritance**:
|
|
18
|
+
- `Text`, `Paragraph`, and `Title` now default to `color: inherit` instead of forcing `color: colors.foreground`.
|
|
19
|
+
- Semantic `type` prop on `Text` now applies explicit semantic color only when specified, allowing Typography primitives to naturally inherit colors inside colored containers, buttons, and badges.
|
|
20
|
+
- **Storybook Reorganization**:
|
|
21
|
+
- Reorganized all component stories into cohesive hierarchies (`Foundations/`, `Actions/`, `Feedback/`, `Forms/`, `Layout/`, `Navigation/`).
|
|
22
|
+
- Added theme switching support in Storybook preview.
|
|
23
|
+
|
|
24
|
+
## [3.0.1] - 2026-11-14
|
|
25
|
+
|
|
3
26
|
## [2.8.0] - 2026-11-10
|
|
4
27
|
|
|
5
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
|
|
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?:
|
|
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):
|
|
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;
|
|
1
|
+
{"version":3,"file":"FileUpload.d.ts","sourceRoot":"","sources":["../../../src/Form/FormFileUpload/FileUpload.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAeL,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,KAAK,aAAa,EACnB,MAAM,sBAAsB,CAAC;AA0L9B;;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;;OAEG;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,SAAS,CAAC;IACjB;;;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;IACpB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC7C;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC,CAAC;IACjD;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACrD;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;IACnC;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;CAC7C,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;AAgRlG;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,QAAQ,EACR,UAAkB,EAClB,UAAU,EACV,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,QAAY,EACZ,OAAyB,EACzB,OAAO,EACP,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,EACjB,KAAK,EACL,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,SAAiB,EACjB,OAAO,EACP,cAAc,EAAE,WAAW,GAC5B,EAAE,eAAe,GAAG,YAAY,CA0OhC"}
|
|
@@ -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 {
|
|
5
|
-
import {
|
|
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
|
|
9
|
-
import { c as
|
|
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
|
|
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
|
|
121
|
-
let t =
|
|
122
|
-
return t[0] !== r || t[1] !== i || t[2] !== n || t[3] !== a ? (
|
|
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(
|
|
125
|
-
if (
|
|
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(
|
|
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(
|
|
132
|
+
let t = e.map(D);
|
|
132
133
|
return i === 1 ? t.length > 0 ? t[t.length - 1] : null : t;
|
|
133
|
-
})(),
|
|
134
|
-
(r ? JSON.stringify(
|
|
135
|
-
},
|
|
136
|
-
|
|
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
|
-
|
|
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
|
|
144
|
+
function D(e) {
|
|
143
145
|
return e.file;
|
|
144
146
|
}
|
|
145
|
-
function
|
|
147
|
+
function O(e) {
|
|
146
148
|
return !!e;
|
|
147
149
|
}
|
|
148
|
-
function
|
|
150
|
+
function k(e) {
|
|
149
151
|
return e.file.uploadedUrl;
|
|
150
152
|
}
|
|
151
|
-
function
|
|
153
|
+
function A(e) {
|
|
152
154
|
return e.status === "success";
|
|
153
155
|
}
|
|
154
|
-
function
|
|
156
|
+
function j(e) {
|
|
155
157
|
return e;
|
|
156
158
|
}
|
|
157
|
-
function
|
|
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
|
|
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(
|
|
174
|
+
return s.length === 0 ? null : /* @__PURE__ */ y(h, {
|
|
173
175
|
orientation: i,
|
|
174
|
-
children: s.map((s, c) => /* @__PURE__ */ b(
|
|
176
|
+
children: s.map((s, c) => /* @__PURE__ */ b(u, {
|
|
175
177
|
value: s,
|
|
176
178
|
children: [
|
|
177
|
-
t && /* @__PURE__ */ y(
|
|
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(
|
|
186
|
-
r && /* @__PURE__ */ y(
|
|
187
|
-
/* @__PURE__ */ y(
|
|
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
|
|
202
|
-
let n =
|
|
203
|
-
if (g(
|
|
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
|
|
209
|
-
n[4] === Symbol.for("react.memo_cache_sentinel") ? (
|
|
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(
|
|
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: [
|
|
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
|
|
227
|
+
function P(e) {
|
|
226
228
|
return e.files.size;
|
|
227
229
|
}
|
|
228
|
-
function
|
|
229
|
-
let r =
|
|
230
|
-
r[0] !==
|
|
231
|
-
sx:
|
|
232
|
-
children:
|
|
233
|
-
value:
|
|
234
|
-
sx:
|
|
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(
|
|
237
|
-
sx:
|
|
238
|
-
render:
|
|
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:
|
|
247
|
+
sx: E.whiteText,
|
|
246
248
|
children: "Change photo"
|
|
247
249
|
})]
|
|
248
250
|
}),
|
|
249
|
-
i && /* @__PURE__ */ y(
|
|
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] =
|
|
263
|
-
let
|
|
264
|
-
r[3] ===
|
|
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
|
|
268
|
-
}) : null, r[3] =
|
|
269
|
-
let
|
|
270
|
-
return r[5] !==
|
|
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: [
|
|
273
|
-
|
|
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
|
|
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
|
|
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
|
|
295
|
-
|
|
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 =
|
|
299
|
-
return 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
|
-
}), [
|
|
327
|
+
}), [c, D]), Q = C(() => h || (m ? a(m) : p ? i(p) : null), [
|
|
328
|
+
h,
|
|
303
329
|
m,
|
|
304
|
-
p
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
if (
|
|
308
|
-
|
|
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
|
|
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
|
|
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
|
-
},
|
|
332
|
-
return /* @__PURE__ */ b(
|
|
333
|
-
value:
|
|
334
|
-
maxFiles:
|
|
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
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
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:
|
|
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:
|
|
393
|
+
children: I || "Choose or drop files to upload"
|
|
363
394
|
}), /* @__PURE__ */ y(t, {
|
|
364
395
|
size: "xs",
|
|
365
396
|
type: "muted",
|
|
366
|
-
children:
|
|
397
|
+
children: L || $
|
|
367
398
|
})]
|
|
368
399
|
}),
|
|
369
|
-
/* @__PURE__ */ y(
|
|
400
|
+
/* @__PURE__ */ y(ee, {
|
|
370
401
|
asChild: !0,
|
|
371
402
|
children: /* @__PURE__ */ y(n, {
|
|
372
403
|
variant: "outline",
|
|
373
404
|
size: "sm",
|
|
374
|
-
disabled:
|
|
405
|
+
disabled: k,
|
|
375
406
|
children: "Browse"
|
|
376
407
|
})
|
|
377
408
|
})
|
|
378
409
|
]
|
|
379
410
|
}),
|
|
380
|
-
|
|
381
|
-
clearBtnRowSx:
|
|
382
|
-
clearBtnSx:
|
|
411
|
+
H && /* @__PURE__ */ y(N, {
|
|
412
|
+
clearBtnRowSx: E.clearBtnRow,
|
|
413
|
+
clearBtnSx: E.clearBtn
|
|
383
414
|
}),
|
|
384
|
-
|
|
385
|
-
showPreview:
|
|
386
|
-
showProgress:
|
|
415
|
+
z && /* @__PURE__ */ y(M, {
|
|
416
|
+
showPreview: V,
|
|
417
|
+
showProgress: B,
|
|
387
418
|
orientation: "horizontal",
|
|
388
|
-
avatarImgSx:
|
|
389
|
-
deleteBtnSx:
|
|
390
|
-
})
|
|
419
|
+
avatarImgSx: E.avatarImg,
|
|
420
|
+
deleteBtnSx: E.deleteBtn
|
|
421
|
+
}),
|
|
422
|
+
X
|
|
391
423
|
] }) : /* @__PURE__ */ b(v, { children: [
|
|
392
|
-
/* @__PURE__ */ b(
|
|
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:
|
|
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:
|
|
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:
|
|
437
|
+
children: L || $
|
|
406
438
|
})
|
|
407
439
|
] }),
|
|
408
|
-
|
|
409
|
-
clearBtnRowSx:
|
|
410
|
-
clearBtnSx:
|
|
440
|
+
H && /* @__PURE__ */ y(N, {
|
|
441
|
+
clearBtnRowSx: E.clearBtnRow,
|
|
442
|
+
clearBtnSx: E.clearBtn
|
|
411
443
|
}),
|
|
412
|
-
|
|
413
|
-
showPreview:
|
|
414
|
-
showProgress:
|
|
444
|
+
z && /* @__PURE__ */ y(M, {
|
|
445
|
+
showPreview: V,
|
|
446
|
+
showProgress: B,
|
|
415
447
|
orientation: "vertical",
|
|
416
|
-
avatarImgSx:
|
|
417
|
-
deleteBtnSx:
|
|
418
|
-
})
|
|
448
|
+
avatarImgSx: E.avatarImg,
|
|
449
|
+
deleteBtnSx: E.deleteBtn
|
|
450
|
+
}),
|
|
451
|
+
X
|
|
419
452
|
] })]
|
|
420
453
|
});
|
|
421
454
|
}
|
|
422
|
-
export {
|
|
455
|
+
export { R as FileUpload };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("../Form.cjs"),
|
|
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":"
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
},
|
|
24
|
-
let
|
|
25
|
-
return
|
|
26
|
-
...
|
|
27
|
-
children:
|
|
28
|
-
}),
|
|
29
|
-
},
|
|
30
|
-
export {
|
|
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 };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("./utils.cjs"),n=require("./tooltip.cjs"),r=require("./weightStyles.cjs");let i=require("@stylexjs/stylex");i=e.__toESM(i,1);let a=require("react/jsx-runtime"),o=require("react"),s=e.__toESM(o,1);o=e.__toESM(o);var c={base:{kogj98:`x1ghz6dp`,kMwMTN:`
|
|
1
|
+
const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("./utils.cjs"),n=require("./tooltip.cjs"),r=require("./weightStyles.cjs");let i=require("@stylexjs/stylex");i=e.__toESM(i,1);let a=require("react/jsx-runtime"),o=require("react"),s=e.__toESM(o,1);o=e.__toESM(o);var c={base:{kogj98:`x1ghz6dp`,kMwMTN:`x1heor9g`,kLWn49:`x1ksxc8v`,$$css:!0},sizeXxs:{kGuDYH:`x6phcfz`,kLWn49:`x37zpob`,$$css:!0},sizeXs:{kGuDYH:`x2ohwh0`,kLWn49:`xfrs9s4`,$$css:!0},sizeSm:{kGuDYH:`xboafo0`,kLWn49:`x1evy7pa`,$$css:!0},sizeMd:{kGuDYH:`xkpwil5`,kLWn49:`x1dbl2gt`,$$css:!0},sizeLg:{kGuDYH:`x1jchvi3`,kLWn49:`x1ksxc8v`,$$css:!0},sizeXl:{kGuDYH:`x1603h9y`,kLWn49:`x1dbl2gt`,$$css:!0},sizeXxl:{kGuDYH:`xngnso2`,kLWn49:`x1jjo3f5`,$$css:!0},defaultVariant:{$$css:!0},leadVariant:{kGuDYH:`x1603h9y`,kLWn49:`x1dbl2gt`,kMwMTN:`xw3nh4a`,k63SB2:`xo1l8bm`,$$css:!0},typeDefault:{kMwMTN:`x84br7x`,$$css:!0},typeSecondary:{kMwMTN:`xw3nh4a`,$$css:!0},typeMuted:{kMwMTN:`xw3nh4a`,$$css:!0},typeSuccess:{kMwMTN:`x1spsc8`,$$css:!0},typeWarning:{kMwMTN:`x7evrrw`,$$css:!0},typeDanger:{kMwMTN:`xuuroe4`,$$css:!0},typeInfo:{kMwMTN:`xb343pj`,$$css:!0},typeInherit:{kMwMTN:`x1heor9g`,$$css:!0},spacingNone:{k1K539:`xat24cr`,$$css:!0},spacingSm:{k1K539:`xhbfen4`,$$css:!0},spacingMd:{k1K539:`xyi6m4r`,$$css:!0},spacingLg:{k1K539:`x1nhhxel`,$$css:!0},alignLeft:{k9WMMc:`xdpxx8g`,$$css:!0},alignCenter:{k9WMMc:`x2b8uid`,$$css:!0},alignRight:{k9WMMc:`x1hr2gdg`,$$css:!0},alignJustify:{k9WMMc:`xmw9mke`,$$css:!0},ellipsisSingle:{kVQacm:`xb3r6kr`,kg5iWk:`xlyipyv`,khDVqt:`xuxw1ft`,k1xSpc:`x1lliihq`,ks0D6T:`x193iq5w`,k7Eaqz:`xeuugli`,$$css:!0}},ee={xxs:c.sizeXxs,xs:c.sizeXs,sm:c.sizeSm,md:c.sizeMd,lg:c.sizeLg,xl:c.sizeXl,xxl:c.sizeXxl},l={default:c.defaultVariant,lead:c.leadVariant},u={none:c.spacingNone,sm:c.spacingSm,md:c.spacingMd,lg:c.spacingLg},d={left:c.alignLeft,center:c.alignCenter,right:c.alignRight,justify:c.alignJustify},f={default:c.typeDefault,secondary:c.typeSecondary,muted:c.typeMuted,success:c.typeSuccess,warning:c.typeWarning,danger:c.typeDanger,info:c.typeInfo,inherit:c.typeInherit},p=s.forwardRef(function({size:e=`md`,variant:o=`default`,type:s,spacing:p=`none`,align:m=`left`,weight:h,required:g,customSize:_,lines:v,rows:y,lineHeight:b,ellipsis:x,tooltip:S,textDecoration:C,textDecorationLine:w,textDecorationStyle:T,textDecorationColor:E,textDecorationThickness:D,textUnderlineOffset:O,color:k,margin:A,m:j,marginTop:M,mt:N,marginBottom:P,mb:te,marginLeft:F,ml:I,marginRight:L,mr:R,marginInline:z,mx:B,marginBlock:V,my:H,letterSpacing:U,as:W=`p`,className:G,children:K,sx:q,...J},Y){let X=v??y??(typeof x==`object`?x?.rows:void 0),Z=(x===!0||typeof x==`object`&&!!x&&!x.rows)&&!X,Q=ee[e]??c.sizeMd,ne=t.resolveCustomTypographyStyle({customSize:_,color:k,lines:v,rows:y,lineHeight:b,ellipsis:x,textDecoration:C,textDecorationLine:w,textDecorationStyle:T,textDecorationColor:E,textDecorationThickness:D,textUnderlineOffset:O,margin:A,m:j,marginTop:M,mt:N,marginBottom:P,mb:te,marginLeft:F,ml:I,marginRight:L,mr:R,marginInline:z,mx:B,marginBlock:V,my:H,letterSpacing:U}),$=i.props(c.base,Q,l[o],s&&f[s],u[p],d[m],h&&r.typographyWeightStyles[h],Z&&c.ellipsisSingle,q),re=n.resolveTooltipContent(S,x,K),ie=(0,a.jsxs)(W,{ref:Y,"data-slot":`typography-paragraph`,"data-variant":o,"data-size":e,"data-weight":h,...$,style:{...$.style,...ne},className:G?`${$.className||``} ${G}`.trim():$.className,...J,children:[K,g&&(0,a.jsx)(`span`,{"aria-hidden":`true`,className:`xuuroe4 x4aigyd x1rg5ohu xo5v014 x1s688f x87ps6o`,children:`*`})]});return n.renderWithTooltip(ie,re)});p.displayName=`Typography.Paragraph`,exports.Paragraph=p;
|
package/dist/Typography/Text.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("../Icons/Icons.cjs"),ee=require("./utils.cjs"),n=require("./tooltip.cjs"),r=require("./weightStyles.cjs");let i=require("@stylexjs/stylex");i=e.__toESM(i,1);let a=require("react/jsx-runtime"),o=require("react"),s=e.__toESM(o,1);o=e.__toESM(o);var c={base:{kMwMTN:`
|
|
1
|
+
const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("../Icons/Icons.cjs"),ee=require("./utils.cjs"),n=require("./tooltip.cjs"),r=require("./weightStyles.cjs");let i=require("@stylexjs/stylex");i=e.__toESM(i,1);let a=require("react/jsx-runtime"),o=require("react"),s=e.__toESM(o,1);o=e.__toESM(o);var c={base:{kMwMTN:`x1heor9g`,kLWn49:`x1evy7pa`,$$css:!0},sizeXxs:{kGuDYH:`x6phcfz`,kLWn49:`x1xfvgam`,$$css:!0},sizeXs:{kGuDYH:`x2ohwh0`,kLWn49:`x37zpob`,$$css:!0},sizeSm:{kGuDYH:`xboafo0`,kLWn49:`xfrs9s4`,$$css:!0},sizeMd:{kGuDYH:`xkpwil5`,kLWn49:`x1evy7pa`,$$css:!0},sizeLg:{kGuDYH:`x1jchvi3`,kLWn49:`x1evy7pa`,$$css:!0},sizeXl:{kGuDYH:`x1603h9y`,kLWn49:`xfrs9s4`,$$css:!0},sizeXxl:{kGuDYH:`xngnso2`,kLWn49:`x37zpob`,$$css:!0},typeDefault:{kMwMTN:`x84br7x`,$$css:!0},typeSecondary:{kMwMTN:`xw3nh4a`,$$css:!0},typeMuted:{kMwMTN:`xw3nh4a`,$$css:!0},typeSuccess:{kMwMTN:`x1spsc8`,$$css:!0},typeWarning:{kMwMTN:`x7evrrw`,$$css:!0},typeDanger:{kMwMTN:`xuuroe4`,$$css:!0},typeInfo:{kMwMTN:`xb343pj`,$$css:!0},typeInherit:{kMwMTN:`x1heor9g`,$$css:!0},strong:{k63SB2:`x1xlr1w8`,$$css:!0},italic:{kKX8nH:`x1k4tb9n`,$$css:!0},underline:{kybGjl:`x1bvjpef`,$$css:!0},delete:{kybGjl:`xmqliwb`,$$css:!0},keyboard:{kMv6JI:`x17yh6e0`,kGuDYH:`x1dcheo9`,kaIpWk:`xqfady0`,kMzoRj:`xmkeg23`,ksu8eU:`x1y0btm7`,kVAM5u:`xb30jbz`,kWkggS:`x1qry0bl`,kg3NbH:`x18a9hih`,k8WAf4:`x1dus959`,kGVxlE:`xfk7h2l`,$$css:!0},ellipsisSingle:{k1xSpc:`x1rg5ohu`,ks0D6T:`x193iq5w`,k7Eaqz:`xeuugli`,kVQacm:`xb3r6kr`,kg5iWk:`xlyipyv`,khDVqt:`xuxw1ft`,kXLuUW:`x3ajldb`,$$css:!0}},l={xxs:c.sizeXxs,xs:c.sizeXs,sm:c.sizeSm,md:c.sizeMd,lg:c.sizeLg,xl:c.sizeXl,xxl:c.sizeXxl},u={default:c.typeDefault,secondary:c.typeSecondary,muted:c.typeMuted,success:c.typeSuccess,warning:c.typeWarning,danger:c.typeDanger,info:c.typeInfo,inherit:c.typeInherit},d=s.forwardRef(function({type:e,size:o=`md`,weight:d=`regular`,required:te,strong:f,italic:p,underline:m,delete:h,keyboard:g,customSize:_,lines:v,rows:y,lineHeight:ne,ellipsis:b,tooltip:re,textDecoration:x,textDecorationLine:S,textDecorationStyle:C,textDecorationColor:w,textDecorationThickness:T,textUnderlineOffset:E,color:D,margin:O,m:k,marginTop:A,mt:j,marginBottom:M,mb:N,marginLeft:P,ml:F,marginRight:I,mr:L,marginInline:R,mx:z,marginBlock:B,my:ie,letterSpacing:V,copyable:H,as:U,className:W,children:G,sx:K,...q},J){let[Y,X]=s.useState(!1),Z=`span`;g?Z=`kbd`:f?Z=`strong`:p?Z=`em`:h&&(Z=`del`);let Q=U||Z,ae=v??y??(typeof b==`object`?b?.rows:void 0),oe=(b===!0||typeof b==`object`&&!!b&&!b.rows)&&!ae,se=l[o]??c.sizeMd,ce=ee.resolveCustomTypographyStyle({customSize:_,color:D,lines:v,rows:y,lineHeight:ne,ellipsis:b,textDecoration:x,textDecorationLine:S,textDecorationStyle:C,textDecorationColor:w,textDecorationThickness:T,textUnderlineOffset:E,margin:O,m:k,marginTop:A,mt:j,marginBottom:M,mb:N,marginLeft:P,ml:F,marginRight:I,mr:L,marginInline:R,mx:z,marginBlock:B,my:ie,letterSpacing:V}),le=async()=>{if(typeof G==`string`)try{await navigator.clipboard.writeText(G),X(!0),setTimeout(()=>X(!1),2e3)}catch{}},$=i.props(c.base,se,e&&u[e],d&&r.typographyWeightStyles[d],f&&c.strong,p&&c.italic,m&&!x&&!S&&c.underline,h&&!x&&!S&&c.delete,g&&c.keyboard,oe&&c.ellipsisSingle,K),ue=n.resolveTooltipContent(re,b,G),de=(0,a.jsxs)(Q,{ref:J,"data-slot":`typography-text`,"data-type":e,"data-size":o,"data-weight":d,...$,style:{...$.style,...ce},className:W?`${$.className||``} ${W}`.trim():$.className,...q,children:[G,te&&(0,a.jsx)(`span`,{"aria-hidden":`true`,className:`xuuroe4 x4aigyd x1rg5ohu xo5v014 x1s688f x87ps6o`,children:`*`}),H&&(0,a.jsx)(`button`,{type:`button`,onClick:le,className:`xjyslct xc342km xjbqb8w xw3nh4a x1ypdohk xo8u9x4 x4aigyd xqfady0 x3nfvp2 x6s0dn4 xl56j7k xxymvpz x1a2a7pz x1gbuem2 xx6bhzk x8aud5w x9p52ec`,"aria-label":Y?`Copied`:`Copy text`,children:Y?(0,a.jsx)(t.Icons.Check,{className:`x1xvt488 xf08kfj`}):(0,a.jsx)(t.Icons.Copy,{className:`x1xvt488 xf08kfj`})})]});return n.renderWithTooltip(de,ue)});d.displayName=`Typography.Text`,exports.Text=d;
|
package/dist/Typography/Text.js
CHANGED
|
@@ -8,7 +8,7 @@ import * as o from "react";
|
|
|
8
8
|
// src/Typography/Text.tsx
|
|
9
9
|
var s = {
|
|
10
10
|
base: {
|
|
11
|
-
kMwMTN: "
|
|
11
|
+
kMwMTN: "x1heor9g",
|
|
12
12
|
kLWn49: "x1evy7pa",
|
|
13
13
|
$$css: !0
|
|
14
14
|
},
|
|
@@ -135,7 +135,7 @@ var s = {
|
|
|
135
135
|
danger: s.typeDanger,
|
|
136
136
|
info: s.typeInfo,
|
|
137
137
|
inherit: s.typeInherit
|
|
138
|
-
}, l = o.forwardRef(function({ type: l
|
|
138
|
+
}, l = o.forwardRef(function({ type: l, size: u = "md", weight: d = "regular", required: f, strong: p, italic: m, underline: h, delete: g, keyboard: _, customSize: re, lines: v, rows: y, lineHeight: b, ellipsis: x, tooltip: S, textDecoration: C, textDecorationLine: w, textDecorationStyle: T, textDecorationColor: E, textDecorationThickness: D, textUnderlineOffset: O, color: k, margin: A, m: j, marginTop: M, mt: N, marginBottom: P, mb: F, marginLeft: I, ml: L, marginRight: R, mr: ie, marginInline: z, mx: B, marginBlock: V, my: H, letterSpacing: U, copyable: W, as: G, className: K, children: q, sx: J, ...Y }, ae) {
|
|
139
139
|
let [X, Z] = o.useState(!1), Q = "span";
|
|
140
140
|
_ ? Q = "kbd" : p ? Q = "strong" : m ? Q = "em" : g && (Q = "del");
|
|
141
141
|
let oe = G || Q, se = v ?? y ?? (typeof x == "object" ? x?.rows : void 0), ce = (x === !0 || typeof x == "object" && !!x && !x.rows) && !se, le = c[u] ?? s.sizeMd, ue = t({
|
|
@@ -170,7 +170,7 @@ var s = {
|
|
|
170
170
|
if (typeof q == "string") try {
|
|
171
171
|
await navigator.clipboard.writeText(q), Z(!0), setTimeout(() => Z(!1), 2e3);
|
|
172
172
|
} catch {}
|
|
173
|
-
}, $ = te.props(s.base, le, ne[l], d && r[d], p && s.strong, m && s.italic, h && !C && !w && s.underline, g && !C && !w && s.delete, _ && s.keyboard, ce && s.ellipsisSingle, J), fe = n(S, x, q), pe = /* @__PURE__ */ a(oe, {
|
|
173
|
+
}, $ = te.props(s.base, le, l && ne[l], d && r[d], p && s.strong, m && s.italic, h && !C && !w && s.underline, g && !C && !w && s.delete, _ && s.keyboard, ce && s.ellipsisSingle, J), fe = n(S, x, q), pe = /* @__PURE__ */ a(oe, {
|
|
174
174
|
ref: ae,
|
|
175
175
|
"data-slot": "typography-text",
|
|
176
176
|
"data-type": l,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("../Icons/Icons.cjs"),ee=require("./utils.cjs"),n=require("./tooltip.cjs"),r=require("./weightStyles.cjs");let i=require("@stylexjs/stylex");i=e.__toESM(i,1);let a=require("react/jsx-runtime"),o=require("react"),s=e.__toESM(o,1);o=e.__toESM(o);var c={base:{kogj98:`x1ghz6dp`,k63SB2:`x1xlr1w8`,kMwMTN:`
|
|
1
|
+
const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("../Icons/Icons.cjs"),ee=require("./utils.cjs"),n=require("./tooltip.cjs"),r=require("./weightStyles.cjs");let i=require("@stylexjs/stylex");i=e.__toESM(i,1);let a=require("react/jsx-runtime"),o=require("react"),s=e.__toESM(o,1);o=e.__toESM(o);var c={base:{kogj98:`x1ghz6dp`,k63SB2:`x1xlr1w8`,kMwMTN:`x1heor9g`,kLWn49:`x132q4wb`,k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kOIVth:`x13z6uf9`,$$css:!0},sizeXxs:{kGuDYH:`x2ohwh0`,kLWn49:`xwn7fz2`,$$css:!0},sizeXs:{kGuDYH:`xboafo0`,kLWn49:`xwn7fz2`,$$css:!0},sizeSm:{kGuDYH:`xkpwil5`,kLWn49:`x1xfvgam`,$$css:!0},sizeMd:{kGuDYH:`x1jchvi3`,kLWn49:`x1xfvgam`,$$css:!0},sizeLg:{kGuDYH:`x1603h9y`,kLWn49:`xwn7fz2`,$$css:!0},sizeXl:{kGuDYH:`xngnso2`,kLWn49:`x132q4wb`,$$css:!0},sizeXxl:{kGuDYH:`x579bpy`,kLWn49:`x1u7k74`,kb6lSQ:`x72az59`,$$css:!0},defaultVariant:{$$css:!0},gradientVariant:{kKwaWg:`x1t3prov`,kBahZS:`x1t23j8t`,kUisrP:`xg7jpbn`,$$css:!0},monoVariant:{kMv6JI:`x17yh6e0`,k63SB2:`x1s688f`,$$css:!0},tight:{kb6lSQ:`xrq0m5f`,$$css:!0},normal:{kb6lSQ:`x1i21sxh`,$$css:!0},wide:{kb6lSQ:`x2ujxvm`,$$css:!0},ellipsisSingle:{kVQacm:`xb3r6kr`,kg5iWk:`xlyipyv`,khDVqt:`xuxw1ft`,k1xSpc:`x1lliihq`,ks0D6T:`x193iq5w`,k7Eaqz:`xeuugli`,$$css:!0}},te={1:`xxl`,2:`xl`,3:`lg`,4:`md`,5:`sm`,6:`xs`},ne={xxs:c.sizeXxs,xs:c.sizeXs,sm:c.sizeSm,md:c.sizeMd,lg:c.sizeLg,xl:c.sizeXl,xxl:c.sizeXxl},re={default:c.defaultVariant,gradient:c.gradientVariant,mono:c.monoVariant},l={tight:c.tight,normal:c.normal,wide:c.wide},u=s.forwardRef(function({level:e=1,size:o,variant:u=`default`,tracking:ie=`normal`,weight:d,customSize:ae,lines:f,rows:p,lineHeight:oe,ellipsis:m,tooltip:se,textDecoration:ce,textDecorationLine:h,textDecorationStyle:g,textDecorationColor:_,textDecorationThickness:v,textUnderlineOffset:y,color:b,margin:x,m:S,marginTop:C,mt:w,marginBottom:T,mb:E,marginLeft:D,ml:O,marginRight:k,mr:A,marginInline:j,mx:M,marginBlock:N,my:P,letterSpacing:F,editable:I,copyable:L,onEdit:R,required:le,as:z,className:B,children:V,sx:H,...U},W){let ue=z||`h${e}`,[G,K]=s.useState(!1),[q,J]=s.useState(!1),[Y,de]=s.useState(typeof V==`string`?V:``),X=o??te[e]??`xxl`,fe=ne[X]??c.sizeXxl,pe=f??p??(typeof m==`object`?m?.rows:void 0),me=(m===!0||typeof m==`object`&&!!m&&!m.rows)&&!pe,he=ee.resolveCustomTypographyStyle({customSize:ae,color:b,lines:f,rows:p,lineHeight:oe,ellipsis:m,textDecoration:ce,textDecorationLine:h,textDecorationStyle:g,textDecorationColor:_,textDecorationThickness:v,textUnderlineOffset:y,margin:x,m:S,marginTop:C,mt:w,marginBottom:T,mb:E,marginLeft:D,ml:O,marginRight:k,mr:A,marginInline:j,mx:M,marginBlock:N,my:P,letterSpacing:F}),Z=async()=>{let e=typeof V==`string`?V:Y;try{await navigator.clipboard.writeText(e),K(!0),setTimeout(()=>K(!1),2e3)}catch{}},Q=()=>{J(!1),R?.(Y)},$=i.props(c.base,fe,re[u],l[ie],d&&r.typographyWeightStyles[d],me&&c.ellipsisSingle,H),ge=n.resolveTooltipContent(se,m,V),_e=(0,a.jsxs)(ue,{ref:W,"data-slot":`typography-title`,"data-level":e,"data-size":X,"data-variant":u,"data-weight":d,...$,style:{...$.style,...he},className:B?`${$.className||``} ${B}`.trim():$.className,...U,children:[q?(0,a.jsx)(`input`,{autoFocus:!0,value:Y,onChange:e=>de(e.target.value),onBlur:Q,onKeyDown:e=>{e.key===`Enter`&&Q(),e.key===`Escape`&&J(!1)},className:`x1qlqyl8 x1pd3egz xjb2p0i x84br7x x1mlyrtw xmkeg23 x1y0btm7 x1puiyjm xqfady0 x97vtpp x1o5vn8x x1a2a7pz`}):(0,a.jsxs)(`span`,{children:[V,le&&(0,a.jsx)(`span`,{"aria-hidden":`true`,className:`xuuroe4 x4aigyd x1rg5ohu xo5v014 x1s688f x87ps6o`,children:`*`})]}),I&&!q&&(0,a.jsx)(`button`,{type:`button`,onClick:()=>J(!0),className:`xjyslct xc342km xjbqb8w xw3nh4a x1ypdohk x78pyy4 xqfady0 x3nfvp2 x6s0dn4 xl56j7k x1a2a7pz x1gbuem2 xx6bhzk x8aud5w x9p52ec`,"aria-label":`Edit title`,children:(0,a.jsx)(t.Icons.Pencil,{className:`xcdlrvm x1l36t39`})}),L&&(0,a.jsx)(`button`,{type:`button`,onClick:Z,className:`xjyslct xc342km xjbqb8w xw3nh4a x1ypdohk x78pyy4 xqfady0 x3nfvp2 x6s0dn4 xl56j7k x1a2a7pz x1gbuem2 xx6bhzk x8aud5w x9p52ec`,"aria-label":G?`Copied`:`Copy title`,children:G?(0,a.jsx)(t.Icons.Check,{className:`xcdlrvm x1l36t39`}):(0,a.jsx)(t.Icons.Copy,{className:`xcdlrvm x1l36t39`})})]});return n.renderWithTooltip(_e,ge)});u.displayName=`Typography.Title`,exports.Title=u;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Title.d.ts","sourceRoot":"","sources":["../../src/Typography/Title.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,KAAK,EAAc,UAAU,EAA+B,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Title.d.ts","sourceRoot":"","sources":["../../src/Typography/Title.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,KAAK,EAAc,UAAU,EAA+B,MAAM,SAAS,CAAC;AA6JnF,eAAO,MAAM,KAAK,gFAuLhB,CAAC"}
|
package/dist/Typography/Title.js
CHANGED
|
@@ -10,7 +10,7 @@ var a = {
|
|
|
10
10
|
base: {
|
|
11
11
|
kogj98: "x1ghz6dp",
|
|
12
12
|
k63SB2: "x1xlr1w8",
|
|
13
|
-
kMwMTN: "
|
|
13
|
+
kMwMTN: "x1heor9g",
|
|
14
14
|
kLWn49: "x132q4wb",
|
|
15
15
|
k1xSpc: "x78zum5",
|
|
16
16
|
kGNEyG: "x6s0dn4",
|
|
@@ -53,10 +53,7 @@ var a = {
|
|
|
53
53
|
kb6lSQ: "x72az59",
|
|
54
54
|
$$css: !0
|
|
55
55
|
},
|
|
56
|
-
defaultVariant: {
|
|
57
|
-
kMwMTN: "x84br7x",
|
|
58
|
-
$$css: !0
|
|
59
|
-
},
|
|
56
|
+
defaultVariant: { $$css: !0 },
|
|
60
57
|
gradientVariant: {
|
|
61
58
|
kKwaWg: "x1t3prov",
|
|
62
59
|
kBahZS: "x1t23j8t",
|