@aggbond/my-file-preview-mobile 1.0.1
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.
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* myPopup Component v1.0.1
|
|
3
|
+
* GitHub: https://github.com/aGG-Bond/ReadFilePopupMobile#readme
|
|
4
|
+
* (c) 2025 aGG-Bond
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/
|
|
7
|
+
import e from"@aggbond/my-popup";const t=new e;class i{Configns;constructor(e){this.Configns=Object.assign({basePath:"/assets/pdfs/",modalId:"filePreviewModal",contentId:"filePreviewContent",closeBtnId:"filePreviewCloseBtn",fileTypes:{pdf:"application/pdf",txt:"text/plain",html:"text/html",1:"richTextFile",2:"choosePdfFile",3:"quotePdfFile"},fileKeyNameConfign:{fileTitle:"name",fileType:"doc_type",filePdfUrl:"pdf_url",fileRichContent:"content_text",fileArr:"com_terms"},isConfignFileKeyName:!1,isDrawFileList:!1,listObj:{listId:"",fileList:[{name:"默认标题",file_type:3,pdf_url:"",content_text:"",com_terms:[{name:"默认标题",pdf_url:"clause_pdf: https://showFile.com/address.pdf",content_text:"disclaimer<p><strong>默认文件</strong></p>"}],styleStr:{color:"red","font-weight":"bold"}}],fileStyle:{color:"red","font-weight":"bold"},isCheckButton:!1,isCoerceReadPopup:!0,checkCallBack:e=>{},listText:"更多详情请阅读",checkButtonID:"ReadFileCheckBox"},coerceReadList:{titleText:"请阅读并同意以下文件",fileList:[{name:"默认标题",file_type:3,pdf_url:"",content_text:"",com_terms:[{name:"默认标题",pdf_url:"clause_pdf: https://showFile.com/address.pdf",content_text:"disclaimer<p><strong>默认文件</strong></p>"}],styleStr:{color:"red","font-weight":"bold"}}],fileStyle:{color:"red","font-weight":"bold"},btnArr:["确认已阅读并同意","拒绝"],btnStyle:[{color:"red"},{color:"gray"}],btnBoxStyle:{},showProgressInButton:!1,coerceCallBack:[(e,t)=>{},(e,t)=>{}]},isBindFileClick:!1},e),this.initModal()}initModal(){const{isDrawFileList:e,listObj:t,isBindFileClick:i,isConfignFileKeyName:o,coerceReadList:n}=this.Configns;o&&t.fileList&&t.fileList.length>0&&(this.Configns.listObj.fileList=this.dataChange(t.fileList)),n.fileList&&n.fileList.length>0&&(this.Configns.coerceReadList.fileList=this.dataChange(n.fileList)),e&&this.drawReadFileList(t),i&&this.bindFileClick(t.listId,void 0)}dataChange(e){if(!this.Configns.fileKeyNameConfign)throw new Error("请传入文件keyNameConfign");const{fileTitle:t,filePdfUrl:i,fileRichContent:o,fileArr:n,fileType:l}=this.Configns.fileKeyNameConfign;if(!(t&&i&&o&&n))throw new Error("请传入文件keyNameConfign的参数");return e.forEach(e=>{e.name=e[t],e.file_type=e[l],e.pdf_url=e[i],e.content_text=e[o],e.com_terms=e[n]}),e}drawReadFileList(e){const{listId:t,fileList:i,isCheckButton:o,isCoerceReadPopup:n,checkCallBack:l,listText:s,checkButtonID:r,fileStyle:c}=e;if(!t)throw new Error("请传入需要添加的dom ID");if(i.length<1)throw new Error("请传入需要渲染的文件数据");let a=`${o?`<input type="checkbox" id="${r}" />`:""}${s}`;for(let f=0,h=i.length;f<h;f++){const{name:e,pdf_url:t,file_type:o,styleStr:n}=i[f];a+=`<span class="pdfsee item-contract" data-pdf="${2==o?t:""}" data-title="${e}" data-index="${f}" data-type="${o||this.judgeFileType({type:"",file:i[f],index:f})}" style="${this.objToStr(n||(c||{}))}">${e}</span>`}const d=document.querySelector(t);if(!d)throw new Error("未找到元素"+t);if(d.insertAdjacentHTML("beforeend",a),o&&r){const e=document.getElementById(r);e&&e.addEventListener("click",e=>{const t=e.target.checked;l&&l(t),t&&n&&this.openCoerceReadPopup()})}}objToStr(e){return Object.entries(e).reduce((e,[t,i])=>`${e}${t}:${i};`,"")}judgeFileType(e){const{type:t,file:i,index:o,fromChooseList:n=!1,isCoerce:l=!1}=e;if(!i)throw new Error("未找到对应文件信息 file is not defined");let s;switch(t){case"1":case 1:s=this.richTextFile({file:i,fromChooseList:n,isCoerce:l});break;case"2":case 2:s=this.quotePdfFile({file:i,fromChooseList:n,isCoerce:l});break;case"3":case 3:s=this.choosePdfFile({file:i,index:o,fromChooseList:n,isCoerce:l});break;default:const{com_terms:e,content_text:t,pdf_url:r}=i;if(e&&e.length>0)return 3;if(t)return 1;if(r)return 2}if(l)return s}richTextFile(i){const{file:o,fromChooseList:n=!1,isCoerce:l=!1}=i,{name:s,content_text:r}=o,c=n?new e:t;if(l)return r;c.showBottomPopup({title:s,content:r,contentStyle:{},titleStyle:{fontWeight:"bold"},callbacks:[function(){}]})}choosePdfFile(i){const{file:o,index:n,fromChooseList:l=!1,isCoerce:s=!1}=i,{com_terms:r=[],name:c}=o,a=l?new e:t;let d="<dl class='ChoosePdfFileList' style='margin:0;padding:0;'>";for(let e=0;e<r.length;e++){const{pdf_url:t,name:i,file_type:o}=r[e];d+=`<dd class="cl" data-pdf="${t}" data-title="${i}" data-index="${e}" style="margin:0">\n <span class="pdfsee item-contract" data-pdf="${t}" data-title="${i}" data-index="${e}" data-type="${o||this.judgeFileType({type:"",file:r[e],index:e})}">${i}</span>\n </dd>`}if(d+="</dl>",s)return d;a.showBottomPopup({title:c,content:d,contentStyle:{},titleStyle:{fontWeight:"bold"},callbacks:[function(){}]}),this.bindFileClick(".ChoosePdfFileList",r)}quotePdfFile(i){const{file:o,fromChooseList:n=!1,isControl:l=!1,isCoerce:s=!1}=i,{pdf_url:r,name:c,divType:a="iframe"}=o,d=n?new e:t,f=l?r:`${r}#toolbar=0&navpanes=0&scrollbar=0`,h="iframe"===a?`<iframe src="${f}" width="100%" height="800" style="border:none;"></iframe>`:"object"===a?`<object data="${f}" type="application/pdf" width="100%" height="800">\n <p>您的浏览器不支持PDF查看。请<a href="${f}">下载文件</a>。</p></object>`:`<embed src="${f}" type="application/pdf" width="100%" height="800" />`;if(s)return h;d.showBottomPopup({title:c,content:h,contentStyle:{padding:"0"},contentBoxStyle:{maxHeight:"100vh"},titleStyle:{fontWeight:"bold"},callbacks:[function(){}]})}bindFileClick(e,t){const i=document.querySelector(e);if(!i)throw new Error("容器未找到:"+e);i.addEventListener("click",e=>{const i=e.target;if("span"===i.tagName.toLowerCase()){const e=i.dataset,o=e.type,n=e.index?parseInt(e.index):void 0;if(void 0!==n){const e=t?.[n]||this.Configns?.listObj?.fileList?.[n];void 0!==o&&e&&this.judgeFileType({type:o,file:e,index:n,fromChooseList:!!t})}}})}openCoerceReadPopup(){const{fileList:e,btnArr:i=["同意并继续"],btnStyle:o,btnBoxStyle:n,coerceCallBack:l,titleText:s,showProgressInButton:r}=this.Configns.coerceReadList;if(0===e.length)throw new Error("fileList不能为空");let c=0,a=null,d=[0];const f=h=>{if(c>=e.length)return;const p=e[c],u=c===e.length-1;p.file_type||(p.file_type=this.judgeFileType({type:"",file:p,isCoerce:!0}));const g=this.judgeFileType({type:p.file_type,file:p,isCoerce:!0}),m={next:()=>{a=null,c++,d.includes(c)||d.push(c),f()},prev:()=>{a=null,c>0&&(c--,f())},close:()=>{t.close()},getCurrentIndex:()=>c,getFileList:()=>[...e],isLastFile:()=>u,setButtonTitles:e=>{Array.isArray(e)&&(a=e)},getVisitedIndices:()=>[...d],goTo:t=>{t>=0&&t<e.length&&(a=null,c=t,d.includes(c)||d.push(c),f())},setCheckboxChecked:e=>{const t=this.Configns.listObj?.checkButtonID;if(t){const i=document.getElementById(t);if(i){i.checked=e;const t=new Event("change");i.dispatchEvent(t)}}},isCheckboxChecked:()=>{const e=this.Configns.listObj?.checkButtonID;if(e){const t=document.getElementById(e);return!!t&&t.checked}return!1}},y=[];if(i&&i.length>0)for(let e=0;e<i.length;e++)y.push(
|
|
8
|
+
/* @__PURE__ */(e=>()=>"function"==typeof l?l(m,e):Array.isArray(l)&&"function"==typeof l[e]?l[e](m):void 0)(e));let C=a||i;if(!1!==r&&!a&&i&&i.length>0){const t=c+1,o=e.length;if(C=[...i],"number"==typeof r){const e=r;e>=0&&e<C.length&&(C[e]=`${i[e]}(${t}/${o})`)}else!0===r&&(C[0]=`${i[0]}(${t}/${o})`)}const w={title:p.name||`${s||"文件"} (${c+1}/${e.length})`,content:g,btnBoxStyle:n||{display:"flex",justifyContent:"space-around",alignItems:"center",padding:"0 2.4vw"},btns:C,btnStyle:o||[{display:"inline-block",width:"91vw",height:"10.667vw",color:"#fff",backgroundColor:"#29AEEF",borderRadius:"8.533vw",textAlign:"center",lineHeight:"10.667vw",cursor:"pointer",margin:"5.33vw auto"},{display:"inline-block",width:"91vw",height:"10.667vw",color:"#fff",backgroundColor:"#29AEEF",borderRadius:"8.533vw",textAlign:"center",lineHeight:"10.667vw",cursor:"pointer",margin:"5.33vw auto"}],callbacks:y};m.setCheckboxChecked(!1),t.showBottomPopup(w),3===p.file_type&&p.com_terms&&this.bindFileClick(".ChoosePdfFileList",p.com_terms)};f()}loadFile(e){const i=e.split(".").pop()?.toLowerCase();if(!i)return;const o=this.Configns.fileTypes[i];if(!o)return;const n=e.split("/").pop()||"文件";"application/pdf"===o?t.showBottomPopup({title:n,content:`<iframe src="${e}" width="100%" height="600px" style="border:none;"></iframe>`,contentStyle:{},titleStyle:{fontWeight:"bold"},callbacks:[function(){}]}):fetch(e).then(e=>{if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);return e.text()}).then(e=>{let o;o="html"===i||"htm"===i?`<div style="max-height: 70vh; overflow-y: auto;">${e}</div>`:`<pre style="white-space: pre-wrap; word-wrap: break-word; max-height: 70vh; overflow-y: auto;">${e}</pre>`,t.showBottomPopup({title:n,content:o,contentStyle:{maxHeight:"70vh",overflow:"auto"},titleStyle:{fontWeight:"bold"},callbacks:[function(){}]})}).catch(i=>{t.showBottomPopup({title:"文件加载失败",content:`<p style="color: red;">无法加载文件: ${e}</p><p>错误详情: ${i.message}</p>`,callbacks:[function(){}]})})}}export{i as default};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* myPopup Component v1.0.1
|
|
3
|
+
* GitHub: https://github.com/aGG-Bond/ReadFilePopupMobile#readme
|
|
4
|
+
* (c) 2025 aGG-Bond
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/
|
|
7
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@aggbond/my-popup")):"function"==typeof define&&define.amd?define(["@aggbond/my-popup"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).FilePreview=t(e.Popup)}(this,function(e){"use strict";const t=new e;return class{Configns;constructor(e){this.Configns=Object.assign({basePath:"/assets/pdfs/",modalId:"filePreviewModal",contentId:"filePreviewContent",closeBtnId:"filePreviewCloseBtn",fileTypes:{pdf:"application/pdf",txt:"text/plain",html:"text/html",1:"richTextFile",2:"choosePdfFile",3:"quotePdfFile"},fileKeyNameConfign:{fileTitle:"name",fileType:"doc_type",filePdfUrl:"pdf_url",fileRichContent:"content_text",fileArr:"com_terms"},isConfignFileKeyName:!1,isDrawFileList:!1,listObj:{listId:"",fileList:[{name:"默认标题",file_type:3,pdf_url:"",content_text:"",com_terms:[{name:"默认标题",pdf_url:"clause_pdf: https://showFile.com/address.pdf",content_text:"disclaimer<p><strong>默认文件</strong></p>"}],styleStr:{color:"red","font-weight":"bold"}}],fileStyle:{color:"red","font-weight":"bold"},isCheckButton:!1,isCoerceReadPopup:!0,checkCallBack:e=>{},listText:"更多详情请阅读",checkButtonID:"ReadFileCheckBox"},coerceReadList:{titleText:"请阅读并同意以下文件",fileList:[{name:"默认标题",file_type:3,pdf_url:"",content_text:"",com_terms:[{name:"默认标题",pdf_url:"clause_pdf: https://showFile.com/address.pdf",content_text:"disclaimer<p><strong>默认文件</strong></p>"}],styleStr:{color:"red","font-weight":"bold"}}],fileStyle:{color:"red","font-weight":"bold"},btnArr:["确认已阅读并同意","拒绝"],btnStyle:[{color:"red"},{color:"gray"}],btnBoxStyle:{},showProgressInButton:!1,coerceCallBack:[(e,t)=>{},(e,t)=>{}]},isBindFileClick:!1},e),this.initModal()}initModal(){const{isDrawFileList:e,listObj:t,isBindFileClick:i,isConfignFileKeyName:o,coerceReadList:n}=this.Configns;o&&t.fileList&&t.fileList.length>0&&(this.Configns.listObj.fileList=this.dataChange(t.fileList)),n.fileList&&n.fileList.length>0&&(this.Configns.coerceReadList.fileList=this.dataChange(n.fileList)),e&&this.drawReadFileList(t),i&&this.bindFileClick(t.listId,void 0)}dataChange(e){if(!this.Configns.fileKeyNameConfign)throw new Error("请传入文件keyNameConfign");const{fileTitle:t,filePdfUrl:i,fileRichContent:o,fileArr:n,fileType:l}=this.Configns.fileKeyNameConfign;if(!(t&&i&&o&&n))throw new Error("请传入文件keyNameConfign的参数");return e.forEach(e=>{e.name=e[t],e.file_type=e[l],e.pdf_url=e[i],e.content_text=e[o],e.com_terms=e[n]}),e}drawReadFileList(e){const{listId:t,fileList:i,isCheckButton:o,isCoerceReadPopup:n,checkCallBack:l,listText:s,checkButtonID:r,fileStyle:c}=e;if(!t)throw new Error("请传入需要添加的dom ID");if(i.length<1)throw new Error("请传入需要渲染的文件数据");let a=`${o?`<input type="checkbox" id="${r}" />`:""}${s}`;for(let d=0,h=i.length;d<h;d++){const{name:e,pdf_url:t,file_type:o,styleStr:n}=i[d];a+=`<span class="pdfsee item-contract" data-pdf="${2==o?t:""}" data-title="${e}" data-index="${d}" data-type="${o||this.judgeFileType({type:"",file:i[d],index:d})}" style="${this.objToStr(n||(c||{}))}">${e}</span>`}const f=document.querySelector(t);if(!f)throw new Error("未找到元素"+t);if(f.insertAdjacentHTML("beforeend",a),o&&r){const e=document.getElementById(r);e&&e.addEventListener("click",e=>{const t=e.target.checked;l&&l(t),t&&n&&this.openCoerceReadPopup()})}}objToStr(e){return Object.entries(e).reduce((e,[t,i])=>`${e}${t}:${i};`,"")}judgeFileType(e){const{type:t,file:i,index:o,fromChooseList:n=!1,isCoerce:l=!1}=e;if(!i)throw new Error("未找到对应文件信息 file is not defined");let s;switch(t){case"1":case 1:s=this.richTextFile({file:i,fromChooseList:n,isCoerce:l});break;case"2":case 2:s=this.quotePdfFile({file:i,fromChooseList:n,isCoerce:l});break;case"3":case 3:s=this.choosePdfFile({file:i,index:o,fromChooseList:n,isCoerce:l});break;default:const{com_terms:e,content_text:t,pdf_url:r}=i;if(e&&e.length>0)return 3;if(t)return 1;if(r)return 2}if(l)return s}richTextFile(i){const{file:o,fromChooseList:n=!1,isCoerce:l=!1}=i,{name:s,content_text:r}=o,c=n?new e:t;if(l)return r;c.showBottomPopup({title:s,content:r,contentStyle:{},titleStyle:{fontWeight:"bold"},callbacks:[function(){}]})}choosePdfFile(i){const{file:o,index:n,fromChooseList:l=!1,isCoerce:s=!1}=i,{com_terms:r=[],name:c}=o,a=l?new e:t;let f="<dl class='ChoosePdfFileList' style='margin:0;padding:0;'>";for(let e=0;e<r.length;e++){const{pdf_url:t,name:i,file_type:o}=r[e];f+=`<dd class="cl" data-pdf="${t}" data-title="${i}" data-index="${e}" style="margin:0">\n <span class="pdfsee item-contract" data-pdf="${t}" data-title="${i}" data-index="${e}" data-type="${o||this.judgeFileType({type:"",file:r[e],index:e})}">${i}</span>\n </dd>`}if(f+="</dl>",s)return f;a.showBottomPopup({title:c,content:f,contentStyle:{},titleStyle:{fontWeight:"bold"},callbacks:[function(){}]}),this.bindFileClick(".ChoosePdfFileList",r)}quotePdfFile(i){const{file:o,fromChooseList:n=!1,isControl:l=!1,isCoerce:s=!1}=i,{pdf_url:r,name:c,divType:a="iframe"}=o,f=n?new e:t,d=l?r:`${r}#toolbar=0&navpanes=0&scrollbar=0`,h="iframe"===a?`<iframe src="${d}" width="100%" height="800" style="border:none;"></iframe>`:"object"===a?`<object data="${d}" type="application/pdf" width="100%" height="800">\n <p>您的浏览器不支持PDF查看。请<a href="${d}">下载文件</a>。</p></object>`:`<embed src="${d}" type="application/pdf" width="100%" height="800" />`;if(s)return h;f.showBottomPopup({title:c,content:h,contentStyle:{padding:"0"},contentBoxStyle:{maxHeight:"100vh"},titleStyle:{fontWeight:"bold"},callbacks:[function(){}]})}bindFileClick(e,t){const i=document.querySelector(e);if(!i)throw new Error("容器未找到:"+e);i.addEventListener("click",e=>{const i=e.target;if("span"===i.tagName.toLowerCase()){const e=i.dataset,o=e.type,n=e.index?parseInt(e.index):void 0;if(void 0!==n){const e=t?.[n]||this.Configns?.listObj?.fileList?.[n];void 0!==o&&e&&this.judgeFileType({type:o,file:e,index:n,fromChooseList:!!t})}}})}openCoerceReadPopup(){const{fileList:e,btnArr:i=["同意并继续"],btnStyle:o,btnBoxStyle:n,coerceCallBack:l,titleText:s,showProgressInButton:r}=this.Configns.coerceReadList;if(0===e.length)throw new Error("fileList不能为空");let c=0,a=null,f=[0];const d=h=>{if(c>=e.length)return;const p=e[c],u=c===e.length-1;p.file_type||(p.file_type=this.judgeFileType({type:"",file:p,isCoerce:!0}));const g=this.judgeFileType({type:p.file_type,file:p,isCoerce:!0}),y={next:()=>{a=null,c++,f.includes(c)||f.push(c),d()},prev:()=>{a=null,c>0&&(c--,d())},close:()=>{t.close()},getCurrentIndex:()=>c,getFileList:()=>[...e],isLastFile:()=>u,setButtonTitles:e=>{Array.isArray(e)&&(a=e)},getVisitedIndices:()=>[...f],goTo:t=>{t>=0&&t<e.length&&(a=null,c=t,f.includes(c)||f.push(c),d())},setCheckboxChecked:e=>{const t=this.Configns.listObj?.checkButtonID;if(t){const i=document.getElementById(t);if(i){i.checked=e;const t=new Event("change");i.dispatchEvent(t)}}},isCheckboxChecked:()=>{const e=this.Configns.listObj?.checkButtonID;if(e){const t=document.getElementById(e);return!!t&&t.checked}return!1}},m=[];if(i&&i.length>0)for(let e=0;e<i.length;e++)m.push((e=>()=>"function"==typeof l?l(y,e):Array.isArray(l)&&"function"==typeof l[e]?l[e](y):void 0)(e));let C=a||i;if(!1!==r&&!a&&i&&i.length>0){const t=c+1,o=e.length;if(C=[...i],"number"==typeof r){const e=r;e>=0&&e<C.length&&(C[e]=`${i[e]}(${t}/${o})`)}else!0===r&&(C[0]=`${i[0]}(${t}/${o})`)}const w={title:p.name||`${s||"文件"} (${c+1}/${e.length})`,content:g,btnBoxStyle:n||{display:"flex",justifyContent:"space-around",alignItems:"center",padding:"0 2.4vw"},btns:C,btnStyle:o||[{display:"inline-block",width:"91vw",height:"10.667vw",color:"#fff",backgroundColor:"#29AEEF",borderRadius:"8.533vw",textAlign:"center",lineHeight:"10.667vw",cursor:"pointer",margin:"5.33vw auto"},{display:"inline-block",width:"91vw",height:"10.667vw",color:"#fff",backgroundColor:"#29AEEF",borderRadius:"8.533vw",textAlign:"center",lineHeight:"10.667vw",cursor:"pointer",margin:"5.33vw auto"}],callbacks:m};y.setCheckboxChecked(!1),t.showBottomPopup(w),3===p.file_type&&p.com_terms&&this.bindFileClick(".ChoosePdfFileList",p.com_terms)};d()}loadFile(e){const i=e.split(".").pop()?.toLowerCase();if(!i)return;const o=this.Configns.fileTypes[i];if(!o)return;const n=e.split("/").pop()||"文件";"application/pdf"===o?t.showBottomPopup({title:n,content:`<iframe src="${e}" width="100%" height="600px" style="border:none;"></iframe>`,contentStyle:{},titleStyle:{fontWeight:"bold"},callbacks:[function(){}]}):fetch(e).then(e=>{if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);return e.text()}).then(e=>{let o;o="html"===i||"htm"===i?`<div style="max-height: 70vh; overflow-y: auto;">${e}</div>`:`<pre style="white-space: pre-wrap; word-wrap: break-word; max-height: 70vh; overflow-y: auto;">${e}</pre>`,t.showBottomPopup({title:n,content:o,contentStyle:{maxHeight:"70vh",overflow:"auto"},titleStyle:{fontWeight:"bold"},callbacks:[function(){}]})}).catch(i=>{t.showBottomPopup({title:"文件加载失败",content:`<p style="color: red;">无法加载文件: ${e}</p><p>错误详情: ${i.message}</p>`,callbacks:[function(){}]})})}}});
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
interface FileObject {
|
|
2
|
+
name: string;
|
|
3
|
+
file_type: number;
|
|
4
|
+
pdf_url: string;
|
|
5
|
+
content_text: string;
|
|
6
|
+
com_terms?: FileObject[];
|
|
7
|
+
styleStr?: Record<string, string>;
|
|
8
|
+
divType?: string;
|
|
9
|
+
}
|
|
10
|
+
interface ListObject {
|
|
11
|
+
listId: string;
|
|
12
|
+
fileList: FileObject[];
|
|
13
|
+
fileStyle?: Record<string, string>;
|
|
14
|
+
isCheckButton?: boolean;
|
|
15
|
+
isCoerceReadPopup?: boolean;
|
|
16
|
+
checkCallBack?: (isChecked: boolean) => void;
|
|
17
|
+
listText?: string;
|
|
18
|
+
checkButtonID?: string;
|
|
19
|
+
}
|
|
20
|
+
interface CoerceReadList {
|
|
21
|
+
titleText?: string;
|
|
22
|
+
fileList: FileObject[];
|
|
23
|
+
fileStyle?: Record<string, string>;
|
|
24
|
+
btnArr?: string[];
|
|
25
|
+
btnStyle?: Record<string, string>[];
|
|
26
|
+
btnBoxStyle?: Record<string, string>;
|
|
27
|
+
showProgressInButton?: boolean | number;
|
|
28
|
+
coerceCallBack?: ((control: ControlObject, buttonIndex: number) => void) | ((control: ControlObject) => void)[];
|
|
29
|
+
}
|
|
30
|
+
interface ConfigOptions {
|
|
31
|
+
basePath?: string;
|
|
32
|
+
modalId?: string;
|
|
33
|
+
contentId?: string;
|
|
34
|
+
closeBtnId?: string;
|
|
35
|
+
fileTypes?: Record<string, string>;
|
|
36
|
+
fileKeyNameConfign?: {
|
|
37
|
+
fileTitle: string;
|
|
38
|
+
fileType: string;
|
|
39
|
+
filePdfUrl: string;
|
|
40
|
+
fileRichContent: string;
|
|
41
|
+
fileArr: string;
|
|
42
|
+
};
|
|
43
|
+
isConfignFileKeyName?: boolean;
|
|
44
|
+
isDrawFileList?: boolean;
|
|
45
|
+
listObj?: ListObject;
|
|
46
|
+
coerceReadList?: CoerceReadList;
|
|
47
|
+
isBindFileClick?: boolean;
|
|
48
|
+
}
|
|
49
|
+
interface ControlObject {
|
|
50
|
+
next: () => void;
|
|
51
|
+
prev: () => void;
|
|
52
|
+
close: () => void;
|
|
53
|
+
getCurrentIndex: () => number;
|
|
54
|
+
getFileList: () => FileObject[];
|
|
55
|
+
isLastFile: () => boolean;
|
|
56
|
+
setButtonTitles: (titles: string[]) => void;
|
|
57
|
+
getVisitedIndices: () => number[];
|
|
58
|
+
goTo: (index: number) => void;
|
|
59
|
+
setCheckboxChecked: (isChecked: boolean) => void;
|
|
60
|
+
isCheckboxChecked: () => boolean;
|
|
61
|
+
}
|
|
62
|
+
declare class FilePreview {
|
|
63
|
+
Configns: Required<ConfigOptions> & {
|
|
64
|
+
listObj: Required<ListObject>;
|
|
65
|
+
coerceReadList: Required<CoerceReadList>;
|
|
66
|
+
fileKeyNameConfign: NonNullable<ConfigOptions['fileKeyNameConfign']>;
|
|
67
|
+
};
|
|
68
|
+
constructor(options: ConfigOptions);
|
|
69
|
+
initModal(): void;
|
|
70
|
+
dataChange(data: any[]): FileObject[];
|
|
71
|
+
drawReadFileList(listObj: ListObject): void;
|
|
72
|
+
objToStr(obj: Record<string, string>): string;
|
|
73
|
+
judgeFileType(params: {
|
|
74
|
+
type: string | number;
|
|
75
|
+
file?: FileObject;
|
|
76
|
+
index?: number;
|
|
77
|
+
fromChooseList?: boolean;
|
|
78
|
+
isCoerce?: boolean;
|
|
79
|
+
}): number | string | void;
|
|
80
|
+
richTextFile(params: {
|
|
81
|
+
file: FileObject;
|
|
82
|
+
fromChooseList?: boolean;
|
|
83
|
+
isCoerce?: boolean;
|
|
84
|
+
}): string | void;
|
|
85
|
+
choosePdfFile(params: {
|
|
86
|
+
file: FileObject;
|
|
87
|
+
index?: number;
|
|
88
|
+
fromChooseList?: boolean;
|
|
89
|
+
isCoerce?: boolean;
|
|
90
|
+
}): string | void;
|
|
91
|
+
quotePdfFile(params: {
|
|
92
|
+
file: FileObject;
|
|
93
|
+
fromChooseList?: boolean;
|
|
94
|
+
isControl?: boolean;
|
|
95
|
+
isCoerce?: boolean;
|
|
96
|
+
}): string | void;
|
|
97
|
+
bindFileClick(containerSelector: string, fileArr?: FileObject[]): void;
|
|
98
|
+
openCoerceReadPopup(): void;
|
|
99
|
+
loadFile(filePath: string): void;
|
|
100
|
+
}
|
|
101
|
+
export default FilePreview;
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aggbond/my-file-preview-mobile",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"provenance": false,
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"description": "A file preview plugin supporting PDF, text, HTML and rich text files",
|
|
9
|
+
"main": "dist/ReadFilePopupMobile.umd.js",
|
|
10
|
+
"module": "dist/ReadFilePopupMobile.esm.js",
|
|
11
|
+
"types": "dist/types/ReadFilePopupMobile.d.ts",
|
|
12
|
+
"unpkg": "dist/ReadFilePopupMobile.umd.min.js",
|
|
13
|
+
"jsdelivr": "dist/ReadFilePopupMobile.umd.min.js",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/types/ReadFilePopupMobile.d.ts",
|
|
17
|
+
"import": "./dist/ReadFilePopupMobile.es.js",
|
|
18
|
+
"require": "./dist/ReadFilePopupMobile.umd.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"src",
|
|
24
|
+
"README.md",
|
|
25
|
+
"LICENSE"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"dev": "vite",
|
|
29
|
+
"build": "vite build",
|
|
30
|
+
"preview": "vite preview",
|
|
31
|
+
"test": "jest",
|
|
32
|
+
"prepublishOnly": "npm run build",
|
|
33
|
+
"docs": "typedoc --out docs/api src/"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"files-preview",
|
|
37
|
+
"pdf",
|
|
38
|
+
"text",
|
|
39
|
+
"html",
|
|
40
|
+
"popup",
|
|
41
|
+
"mobile"
|
|
42
|
+
],
|
|
43
|
+
"author": "aGG-Bond",
|
|
44
|
+
"license": "MIT",
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "https://github.com/aGG-Bond/ReadFilePopupMobile.git"
|
|
48
|
+
},
|
|
49
|
+
"bugs": {
|
|
50
|
+
"url": "https://github.com/aGG-Bond/ReadFilePopupMobile/issues"
|
|
51
|
+
},
|
|
52
|
+
"homepage": "https://github.com/aGG-Bond/ReadFilePopupMobile#readme",
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@types/node": "^25.0.3",
|
|
55
|
+
"terser": "^5.44.1",
|
|
56
|
+
"typescript": "~5.9.3",
|
|
57
|
+
"vite": "^7.2.4",
|
|
58
|
+
"vite-plugin-dts": "^4.5.4"
|
|
59
|
+
},
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"@aggbond/my-popup": "^1.0.7"
|
|
62
|
+
}
|
|
63
|
+
}
|