zy-react-library 1.1.24 → 1.1.25

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.
@@ -11,7 +11,7 @@ export interface UploadProps extends Omit<AntUploadProps, "fileList"> {
11
11
  ratio?: `${number}*${number}`;
12
12
  /** 是否显示提示,默认 true */
13
13
  showTip?: boolean;
14
- /** 文件大小限制(单位:MB */
14
+ /** 文件大小限制(单位:MB),默认 10 */
15
15
  size?: number;
16
16
  /** 自定义提示内容 */
17
17
  tipContent?: ReactNode;
@@ -1 +1 @@
1
- import{PlusOutlined as e,VideoCameraAddOutlined as t,UploadOutlined as i}from"@ant-design/icons";import{Upload as n,Modal as o,Button as l,message as r}from"antd";import{useState as s}from"react";import{jsxs as a,Fragment as d,jsx as c}from"react/jsx-runtime";const p=p=>{const{value:m=[],onChange:u,onPreview:f,onRemove:g,onGetRemoveFile:h,beforeUpload:v,maxCount:w,listType:y,accept:x,ratio:$="",showTip:j=!0,multiple:b=!0,size:C,tipContent:T,uploadButtonText:U,fileType:R,...F}=p,[z,L]=s(!1),[B,I]=s(""),M=".jpg,.jpeg,.png",O=".pdf,.doc,.docx",P=".mp4",A=R||(()=>{if(x){if("*"===x)return"document";const e=x.split(",");return e.some(e=>P.split(",").includes(e))?"video":e.some(e=>O.split(",").includes(e))?"document":e.some(e=>M.split(",").includes(e))?"image":"document"}return"image"})(),D="image"===A,G="video"===A,N="document"===A,S=y||("*"===x?"text":"image"===A?"picture-card":"text"),W=x?"*"===x?"":x:D?M:G?P:N?O:M,k=w||(G?1:D||N?4:1),q=C||(G?100:0),E=U||(G?"上传视频":"上传附件"),H=W.replace(/\./g,"").split(",").join("、"),J=()=>T||`${[`最多上传${k}个文件`,W?`并且只能上传${H}格式的文件`:"可以上传任意格式的文件",q?`文件大小不能超过${q}M`:"",$?`只能上传${$}分辨率的图片`:""].filter(Boolean).join(",")}。`,K=D?c("div",{children:c(e,{style:{fontSize:32}})}):c(l,{type:"primary",icon:c(G?t:i,{}),children:E});return a(d,{children:[c(n,{fileList:m,multiple:b,maxCount:k,listType:S,accept:W,onChange:({file:e,fileList:t})=>{const i=W?W.split(","):[],n=$?$.split("*"):[],o=e.name.substring(e.name.lastIndexOf("."),e.name.length),l=1024*q*1024;if(i.length>0&&!i.includes(o))r.warning(`只能上传${H}格式的文件`);else if(l&&e.size>l)r.warning(`文件大小不能超过${q}M`);else if(2===n.length&&e.type?.startsWith("image/")){const i=i=>{const o=new Image;o.onload=()=>{if(o.width!==+n[0]||o.height!==+n[1]){r.warning(`只能上传${$}分辨率的图片`);const i=t.filter(t=>t.uid!==e.uid);return void u?.(i)}u?.(t)},o.src=i};if(e.url)i(e.url);else{const t=new FileReader;t.onload=e=>{i(e.target.result)},t.readAsDataURL(e)}}else u?.(t)},onPreview:e=>{D&&(I(e.url||e.thumbUrl),L(!0)),f?.(e)},onRemove:e=>(e.originFileObj||h?.(e),g?.(e)),beforeUpload:(e,t)=>!!v&&v(e,t),...F,children:m.length>=k?null:K}),j?J()&&c("div",{style:{marginTop:10,color:"#ff4d4f"},children:J()}):null,c(o,{open:z,title:"查看图片",footer:null,onCancel:()=>{L(!1)},children:c("img",{alt:"preview",style:{width:"100%",objectFit:"scale-down"},src:B})})]})};p.displayName="Upload";export{p as default};
1
+ import{PlusOutlined as e,VideoCameraAddOutlined as t,UploadOutlined as i}from"@ant-design/icons";import{Upload as n,Modal as o,Button as l,message as r}from"antd";import{useState as s}from"react";import{jsxs as a,Fragment as d,jsx as c}from"react/jsx-runtime";const p=p=>{const{value:m=[],onChange:u,onPreview:f,onRemove:g,onGetRemoveFile:h,beforeUpload:v,maxCount:w,listType:y,accept:x,ratio:$="",showTip:j=!0,multiple:b=!0,size:C,tipContent:T,uploadButtonText:U,fileType:R,...F}=p,[z,L]=s(!1),[B,I]=s(""),M=".jpg,.jpeg,.png",O=".pdf,.doc,.docx",P=".mp4",A=R||(()=>{if(x){if("*"===x)return"document";const e=x.split(",");return e.some(e=>P.split(",").includes(e))?"video":e.some(e=>O.split(",").includes(e))?"document":e.some(e=>M.split(",").includes(e))?"image":"document"}return"image"})(),D="image"===A,G="video"===A,N="document"===A,S=y||("*"===x?"text":"image"===A?"picture-card":"text"),W=x?"*"===x?"":x:D?M:G?P:N?O:M,k=w||(G?1:D||N?4:1),q=C||(G?100:10),E=U||(G?"上传视频":"上传附件"),H=W.replace(/\./g,"").split(",").join("、"),J=()=>T||`${[`最多上传${k}个文件`,W?`并且只能上传${H}格式的文件`:"可以上传任意格式的文件",q?`文件大小不能超过${q}M`:"",$?`只能上传${$}分辨率的图片`:""].filter(Boolean).join(",")}。`,K=D?c("div",{children:c(e,{style:{fontSize:32}})}):c(l,{type:"primary",icon:c(G?t:i,{}),children:E});return a(d,{children:[c(n,{fileList:m,multiple:b,maxCount:k,listType:S,accept:W,onChange:({file:e,fileList:t})=>{const i=W?W.split(","):[],n=$?$.split("*"):[],o=e.name.substring(e.name.lastIndexOf("."),e.name.length),l=1024*q*1024;if(i.length>0&&!i.includes(o))r.warning(`只能上传${H}格式的文件`);else if(l&&e.size>l)r.warning(`文件大小不能超过${q}M`);else if(2===n.length&&e.type?.startsWith("image/")){const i=i=>{const o=new Image;o.onload=()=>{if(o.width!==+n[0]||o.height!==+n[1]){r.warning(`只能上传${$}分辨率的图片`);const i=t.filter(t=>t.uid!==e.uid);return void u?.(i)}u?.(t)},o.src=i};if(e.url)i(e.url);else{const t=new FileReader;t.onload=e=>{i(e.target.result)},t.readAsDataURL(e)}}else u?.(t)},onPreview:e=>{D&&(I(e.url||e.thumbUrl),L(!0)),f?.(e)},onRemove:e=>(e.originFileObj||h?.(e),g?.(e)),beforeUpload:(e,t)=>!!v&&v(e,t),...F,children:m.length>=k?null:K}),j?J()&&c("div",{style:{marginTop:10,color:"#ff4d4f"},children:J()}):null,c(o,{open:z,title:"查看图片",footer:null,onCancel:()=>{L(!1)},children:c("img",{alt:"preview",style:{width:"100%",objectFit:"scale-down"},src:B})})]})};p.displayName="Upload";export{p as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zy-react-library",
3
3
  "private": false,
4
- "version": "1.1.24",
4
+ "version": "1.1.25",
5
5
  "type": "module",
6
6
  "description": "",
7
7
  "author": "LiuJiaNan",