@bixi-design/excel-parser
Advanced tools
Comparing version 2.2.4-test.18 to 2.2.4-test.19
@@ -1,1 +0,1 @@ | ||
import{useMemoizedFn,useUnmount}from"ahooks";import{useRef}from"react";import{Subject}from"rxjs";import{map,filter,takeUntil}from"rxjs/operators";import{BixiExcel}from"./excel.js";import{isWindow}from"./utils.js";const useExcel=(s,e)=>{const o=isWindow()?luckysheet:{},{onProgressChange:l=[],create:n={}}=null!=e?e:{},x=useRef(new Subject);var e=useMemoizedFn(()=>{o.create(Object.assign({container:s,showinfobar:!1,allowEdit:!1},n))}),t=useMemoizedFn(e=>{o.setSheetActive(e)}),r=useMemoizedFn((e,t)=>{o.scroll({targetRow:e,targetCol:t})}),i=useMemoizedFn((t,d,e)=>{const{style:h={},scrollToFirst:g=!1}=null!=e?e:{};return new Promise(m=>{const u=`image-container-r-${t.fromRow}-c-`+t.fromCol;x.current.next(),x.current.complete(),x.current=new Subject,o.imageLoaded$.pipe(map(e=>[...e.values()].map(e=>null==e?void 0:e.item)),map(e=>e.find(e=>e.fromRow===t.fromRow&&e.fromCol===t.fromCol)),filter(e=>!!e),takeUntil(x.current)).subscribe(()=>{const l=document.querySelector(`[data-from=${u}]`),n=null===l||void 0===l?void 0:l.querySelector("img"),c=[];if(n){const a=new Image;a.src=n.src,a.onload=()=>{var{naturalWidth:e,naturalHeight:t}=a,{width:o,height:r}=n.getBoundingClientRect();const i=e/o,s=t/r;document.querySelectorAll(".bixi-excel-image-highlight").forEach(e=>e.remove()),d.forEach((e,t)=>{const o=document.createElement("div");o.id=`__BIXI_EXCEL_IMAGE_HIGHLIGHT-${u}-`+t,o.style.position="absolute",o.style.left=e.left/i+"px",o.style.top=e.top/s+"px",o.style.width=e.width/i+"px",o.style.height=e.height/s+"px",o.style.border="2px solid red",o.style.animation="",o.classList.add("bixi-excel-image-highlight"),o.setAttribute("data-bixi-excel-highlight","image"),c.push(o.id),Object.keys(h).forEach(e=>{o.style[e]=h[e]}),null!==l&&void 0!==l&&l.appendChild(o)}),g&&0<c.length&&null!=(e=document.getElementById(c[0]))&&e.scrollIntoView({block:"center"}),x.current.next(),x.current.complete(),m({labelDivIds:c})}}})})}),c=useMemoizedFn(()=>{const e=document.getElementById(s);if(e){const t=e.querySelectorAll("[data-bixi-excel-highlight=image]");t.forEach(e=>{e.remove()})}}),a=useMemoizedFn(e=>{BixiExcel.transformExcelToLucky(e).then(({files:e})=>{o.destroy(),o.create(Object.assign({container:s,showinfobar:!1,data:e.sheets,plugins:["chart"]},n))}),0<l.length&&BixiExcel.progress.subscribe(l)}),m=useMemoizedFn((e,t)=>{var{name:t=""}=null!=t?t:{};BixiExcel.transformExcelToLuckyByUrl(e,t).then(({files:e})=>{BixiExcel.sheet.destroy(),BixiExcel.sheet.create(Object.assign({container:s,showinfobar:!1,data:e.sheets,plugins:["chart"]},n))}),0<l.length&&BixiExcel.progress.subscribe(l)}),u=useMemoizedFn((e,t)=>{var{imageLazyLoadFolderPath:t="",enableImageLazyLoad:o=!1}=null!=t?t:{};if(o){o=e;var r=t;const{sheets:i=[]}=o;i.forEach(e=>{const{images:t={}}=e;Object.keys(t).forEach(e=>{t[e].lazyLoadSrc=r.replace(/\{\{REMOTE_SRC\}\}/g,""+t[e].remoteSrc),t[e].lazyLoad=!0})})}BixiExcel.sheet.destroy(),BixiExcel.sheet.create(Object.assign({container:s,showinfobar:!1,data:e.sheets,plugins:["chart"]},n)),0<l.length&&BixiExcel.progress.subscribe(l)});return useUnmount(()=>{BixiExcel.progress.destroy(),null!==o&&void 0!==o&&o.destroy(),x.current.next(),x.current.complete()}),{sheet:o,init:e,upload:a,loadFromUrl:m,scrollToSheet:t,scrollToCell:r,setImageLabels:i,clearImageLabels:c,loadFromJson:u}};export{useExcel}; | ||
import{useMemoizedFn,useUnmount}from"ahooks";import{useRef}from"react";import{Subject}from"rxjs";import{map,filter,takeUntil}from"rxjs/operators";import{BixiExcel}from"./excel.js";import{isWindow}from"./utils.js";const useExcel=(p,e)=>{const o=isWindow()?luckysheet:{},{onProgressChange:i=[],create:s={}}=null!=e?e:{},y=useRef(new Subject);var e=useMemoizedFn(()=>{o.create(Object.assign({container:p,showinfobar:!1,allowEdit:!1},s))}),t=useMemoizedFn(e=>{o.setSheetActive(e)}),l=useMemoizedFn((e,t)=>{o.scroll({targetRow:e,targetCol:t})}),r=useMemoizedFn((t,g,e)=>{const{style:x={},scrollToFirst:f=!1}=null!=e?e:{};return new Promise(d=>{const h=`image-container-r-${t.fromRow}-c-`+t.fromCol;y.current.next(),y.current.complete(),y.current=new Subject,o.imageLoaded$.pipe(map(e=>[...e.values()].map(e=>null==e?void 0:e.item)),map(e=>e.find(e=>e.fromRow===t.fromRow&&e.fromCol===t.fromCol)),filter(e=>!!e),takeUntil(y.current)).subscribe(()=>{const c=document.querySelector(`[data-from=${h}]`),a=null===c||void 0===c?void 0:c.querySelector("img"),u=[];if(a){const m=new Image;m.src=a.src,m.onload=()=>{var{naturalWidth:e,naturalHeight:t}=m,{width:o,height:l}=a.getBoundingClientRect();const r=e/o,i=t/l;if(document.querySelectorAll(".bixi-excel-image-highlight").forEach(e=>e.remove()),g.forEach((e,t)=>{const o=document.createElement("div");o.id=`__BIXI_EXCEL_IMAGE_HIGHLIGHT-${h}-`+t,o.style.position="absolute",o.style.left=e.left/r+"px",o.style.top=e.top/i+"px",o.style.width=e.width/r+"px",o.style.height=e.height/i+"px",o.style.border="2px solid red",o.style.animation="",o.classList.add("bixi-excel-image-highlight"),o.setAttribute("data-bixi-excel-highlight","image"),u.push(o.id),Object.keys(x).forEach(e=>{o.style[e]=x[e]}),null!==c&&void 0!==c&&c.appendChild(o)}),f&&0<u.length){const s=document.getElementById(u[0]),n=document.getElementById(p);s&&n&&(e=s.getBoundingClientRect(),o=n.getBoundingClientRect(),t=null!=(l=null==(t=document.getElementById("luckysheet-scrollbar-x"))?void 0:t.scrollLeft)?l:0,l=null!=(l=null==(l=document.getElementById("luckysheet-scrollbar-y"))?void 0:l.scrollTop)?l:0,luckysheet.scroll({scrollLeft:t+(e.x-o.x)-o.width/2,scrollTop:l+(e.y-o.y)-o.height/2}))}y.current.next(),y.current.complete(),d({labelDivIds:u})}}})})}),n=useMemoizedFn(()=>{const e=document.getElementById(p);if(e){const t=e.querySelectorAll("[data-bixi-excel-highlight=image]");t.forEach(e=>{e.remove()})}}),c=useMemoizedFn(e=>{BixiExcel.transformExcelToLucky(e).then(({files:e})=>{o.destroy(),o.create(Object.assign({container:p,showinfobar:!1,data:e.sheets,plugins:["chart"]},s))}),0<i.length&&BixiExcel.progress.subscribe(i)}),a=useMemoizedFn((e,t)=>{var{name:t=""}=null!=t?t:{};BixiExcel.transformExcelToLuckyByUrl(e,t).then(({files:e})=>{BixiExcel.sheet.destroy(),BixiExcel.sheet.create(Object.assign({container:p,showinfobar:!1,data:e.sheets,plugins:["chart"]},s))}),0<i.length&&BixiExcel.progress.subscribe(i)}),u=useMemoizedFn((e,t)=>{var{imageLazyLoadFolderPath:t="",enableImageLazyLoad:o=!1}=null!=t?t:{};if(o){o=e;var l=t;const{sheets:r=[]}=o;r.forEach(e=>{const{images:t={}}=e;Object.keys(t).forEach(e=>{t[e].lazyLoadSrc=l.replace(/\{\{REMOTE_SRC\}\}/g,""+t[e].remoteSrc),t[e].lazyLoad=!0})})}BixiExcel.sheet.destroy(),BixiExcel.sheet.create(Object.assign({container:p,showinfobar:!1,data:e.sheets,plugins:["chart"]},s)),0<i.length&&BixiExcel.progress.subscribe(i)});return useUnmount(()=>{BixiExcel.progress.destroy(),null!==o&&void 0!==o&&o.destroy(),y.current.next(),y.current.complete()}),{sheet:o,init:e,upload:c,loadFromUrl:a,scrollToSheet:t,scrollToCell:l,setImageLabels:r,clearImageLabels:n,loadFromJson:u}};export{useExcel}; |
{ | ||
"name": "@bixi-design/excel-parser", | ||
"version": "2.2.4-test.18", | ||
"version": "2.2.4-test.19", | ||
"description": "React Excel Parser", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
235775
2852