zy-react-library 2.2.15 → 2.2.16

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.
@@ -1 +1 @@
1
- import{Space as e,Button as i}from"antd";import{useState as r}from"react";import{getFileName as l}from"../../utils/index.js";import n from"../Excel/index.js";import m from"../Pdf/index.js";import o from"../PreviewImg/index.js";import t from"../Video/index.js";import a from"../Word/index.js";import{jsxs as d,Fragment as p,jsx as s}from"react/jsx-runtime";const c=c=>{const{files:u=[],nameKey:f="",urlKey:x="",name:v,url:g,componentProps:h={}}=c,[y,j]=r(null),w=u.length>0?u.map(e=>{const i=e.filePath||e.url||e[x];return{name:e.name||e.fileName||e[f]||l(i),url:i}}).filter(e=>e.url):v&&g?[{name:v,url:g}]:[],b=()=>{j(null)};return 0===w.length?null:d(p,{children:[s(e,{direction:"vertical",children:w.map(r=>{const l=(e=>{const i=e.url.split(/[?#]/)[0],r=i.slice(i.lastIndexOf(".")+1).toLowerCase();return["jpg","jpeg","png","gif","webp","bmp","svg"].includes(r)?"image":"pdf"===r?"pdf":"docx"===r?"word":"xlsx"===r?"excel":["mp4","webm","m3u8"].includes(r)?"video":void 0})(r),n=`${r.name}-${r.url}`;return"image"===l?s(e,{children:s(o,{...h.image,files:[r.url]})},n):d(e,{children:[s("span",{children:r.name}),l?s(i,{type:"primary",size:"small",onClick:()=>((e,i)=>{j({...e,type:i})})(r,l),children:"预览"}):s("span",{children:"暂不支持预览"})]},n)})}),"pdf"===y?.type&&s(m,{...h.pdf,visible:!0,file:y.url,name:y.name,onCancel:b}),"word"===y?.type&&s(a,{...h.word,visible:!0,file:y.url,name:y.name,onCancel:b}),"excel"===y?.type&&s(n,{...h.excel,visible:!0,file:y.url,name:y.name,onCancel:b}),"video"===y?.type&&s(t,{...h.video,visible:!0,source:y.url,title:y.name,onCancel:b})]})};c.displayName="FilePreview";export{c as default};
1
+ import{Space as e,Button as l}from"antd";import{useState as i}from"react";import r from"../../hooks/useDownloadFile/index.js";import{getFileName as n}from"../../utils/index.js";import o from"../Excel/index.js";import m from"../Pdf/index.js";import t from"../PreviewImg/index.js";import a from"../Video/index.js";import s from"../Word/index.js";import{jsxs as d,Fragment as p,jsx as c}from"react/jsx-runtime";const u=u=>{const{files:f=[],nameKey:x="",urlKey:v="",name:y,url:g,componentProps:h={}}=u,{downloadFile:j}=r(),[w,b]=i(null),C=f.length>0?f.map(e=>{const l=e.filePath||e.url||e[v];return{name:e.name||e.fileName||e[x]||n(l),url:l}}).filter(e=>e.url):y&&g?[{name:y,url:g}]:[],P=()=>{b(null)};return 0===C.length?null:d(p,{children:[c(e,{orientation:"vertical",children:C.map(i=>{const r=(e=>{const l=e.url.split(/[?#]/)[0],i=l.slice(l.lastIndexOf(".")+1).toLowerCase();return["jpg","jpeg","png","gif","webp","bmp","svg"].includes(i)?"image":"pdf"===i?"pdf":"docx"===i?"word":"xlsx"===i?"excel":["mp4","webm","m3u8"].includes(i)?"video":void 0})(i),n=`${i.name}-${i.url}`;return"image"===r?c(e,{children:c(t,{...h.image,files:[i.url]})},n):d(e,{children:[c("span",{children:i.name}),c(l,r?{type:"primary",size:"small",onClick:()=>((e,l)=>{b({...e,type:l})})(i,r),children:"预览"}:{type:"primary",size:"small",onClick:()=>j({url:i.url,name:i.name}),children:"下载"})]},n)})}),"pdf"===w?.type&&c(m,{...h.pdf,visible:!0,file:w.url,name:w.name,onCancel:P}),"word"===w?.type&&c(s,{...h.word,visible:!0,file:w.url,name:w.name,onCancel:P}),"excel"===w?.type&&c(o,{...h.excel,visible:!0,file:w.url,name:w.name,onCancel:P}),"video"===w?.type&&c(a,{...h.video,visible:!0,source:w.url,title:w.name,onCancel:P})]})};u.displayName="FilePreview";export{u as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zy-react-library",
3
3
  "private": false,
4
- "version": "2.2.15",
4
+ "version": "2.2.16",
5
5
  "type": "module",
6
6
  "description": "",
7
7
  "author": "LiuJiaNan",