xiaodao-spreader 0.1.2
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/LICENSE +21 -0
- package/README.md +91 -0
- package/dist/style.css +1 -0
- package/dist/types/components/spreader/constants.d.ts +15 -0
- package/dist/types/components/spreader/formula.d.ts +36 -0
- package/dist/types/components/spreader/spreader.vue.d.ts +28 -0
- package/dist/types/components/spreader/theme.d.ts +4 -0
- package/dist/types/components/spreader/types.d.ts +115 -0
- package/dist/types/components/spreader/utils.d.ts +26 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/xiaodao-spreader.es.js +1632 -0
- package/dist/xiaodao-spreader.umd.js +4 -0
- package/package.json +52 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
(function(le,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],a):(le=typeof globalThis<"u"?globalThis:le||self,a(le.XiaoDaoSpreader={},le.Vue))})(this,function(le,a){"use strict";const al={"zh-CN":{insert:"插入",delete:"删除",rename:"重命名",moveLeft:"左移",moveRight:"右移",cut:"剪切",copy:"复制",paste:"粘贴",addSheet:"新建工作表",moveSheetLeft:"左移",moveSheetRight:"右移",scrollUp:"向上滚动",scrollDown:"向下滚动",scrollLeft:"向左滚动",scrollRight:"向右滚动",calculate:"计算",sum:"求和"},"en-US":{insert:"Insert",delete:"Delete",rename:"Rename",moveLeft:"Move Left",moveRight:"Move Right",cut:"Cut",copy:"Copy",paste:"Paste",addSheet:"Add new sheet",moveSheetLeft:"Move Left",moveSheetRight:"Move Right",scrollUp:"Scroll up",scrollDown:"Scroll down",scrollLeft:"Scroll left",scrollRight:"Scroll right",calculate:"Calculate",sum:"Sum"}};function B(s,d){var i;return((i=al[s])==null?void 0:i[d])??d}const rl={bg:"#f4f4f4",gridBg:"#ffffff",headerBg:"#e8e8e8",headerBorder:"#c8c8c8",headerText:"#444",headerSep:"#b0b0b0",cornerBg:"#e0e0e0",gridLine:"#e0e0e0",selectionBg:"rgba(0, 120, 215, 0.12)",activeCellBorder:"#0078d7",cellText:"#1a1a1a",scrollTrack:"rgba(0,0,0,0.08)",scrollThumb:"rgba(0,0,0,0.25)",formulaBarBg:"#f0f0f0",formulaBarBorder:"#c8c8c8",formulaBarLabelText:"#333",formulaBarLabelBg:"#fff",formulaBarLabelBorder:"#c0c0c0",formulaBarInputBg:"#fff",formulaBarInputBorder:"#c0c0c0",formulaBarInputText:"#1a1a1a",formulaBarInputFocusBorder:"#0078d7",formulaBarInputFocusShadow:"rgba(0, 120, 215, 0.3)",wrapperBg:"#e8e8e8",cellEditorBorder:"#0078d7",cellEditorText:"#1a1a1a",cellEditorBg:"#fff",cellEditorShadow:"#0078d7",tabBarBg:"#e8e8e8",tabBarBorder:"#c0c0c0",tabActiveBg:"#ffffff",tabActiveText:"#1a1a1a",tabActiveBorder:"#0078d7",tabInactiveBg:"#dfdfdf",tabInactiveText:"#666",tabInactiveBorder:"transparent",tabHoverBg:"#e0e0e0",tabAddBtnColor:"#555",tabAddBtnHoverBg:"#d0d0d0",tabScrollBtnColor:"#888",tabScrollBtnHoverBg:"#d0d0d0",scrollbarThumb:"rgba(0,0,0,0.25)",scrollbarThumbHover:"rgba(0,0,0,0.4)",scrollBtnBg:"#e8e8e8",scrollBtnColor:"#666",scrollBtnHoverBg:"#d0d0d0",scrollBtnActiveBg:"#c0c0c0",scrollTrackBg:"rgba(0,0,0,0.06)"},cl={bg:"#1e1e1e",gridBg:"#252526",headerBg:"#252525",headerBorder:"#3e3e3e",headerText:"#999",headerSep:"#3e3e3e",cornerBg:"#2a2a2a",gridLine:"#3e3e3e",selectionBg:"rgba(0, 120, 215, 0.25)",activeCellBorder:"#0078d7",cellText:"#d4d4d4",scrollTrack:"rgba(255,255,255,0.06)",scrollThumb:"rgba(255,255,255,0.2)",formulaBarBg:"#2d2d2d",formulaBarBorder:"#3e3e3e",formulaBarLabelText:"#ccc",formulaBarLabelBg:"#3c3c3c",formulaBarLabelBorder:"#555",formulaBarInputBg:"#3c3c3c",formulaBarInputBorder:"#555",formulaBarInputText:"#d4d4d4",formulaBarInputFocusBorder:"#0078d7",formulaBarInputFocusShadow:"rgba(0, 120, 215, 0.4)",wrapperBg:"#1e1e1e",cellEditorBorder:"#0078d7",cellEditorText:"#d4d4d4",cellEditorBg:"#3c3c3c",cellEditorShadow:"#0078d7",tabBarBg:"#2a2a2a",tabBarBorder:"#3e3e3e",tabActiveBg:"#1e1e1e",tabActiveText:"#e0e0e0",tabActiveBorder:"#0078d7",tabInactiveBg:"#333333",tabInactiveText:"#888",tabInactiveBorder:"transparent",tabHoverBg:"#3a3a3a",tabAddBtnColor:"#999",tabAddBtnHoverBg:"#3a3a3a",tabScrollBtnColor:"#777",tabScrollBtnHoverBg:"#3a3a3a",scrollbarThumb:"rgba(255,255,255,0.2)",scrollbarThumbHover:"rgba(255,255,255,0.35)",scrollBtnBg:"#2d2d2d",scrollBtnColor:"#999",scrollBtnHoverBg:"#3d3d3d",scrollBtnActiveBg:"#4d4d4d",scrollTrackBg:"rgba(255,255,255,0.05)"};function Y(s){let d="",i=s;do d=String.fromCharCode(65+i%26)+d,i=Math.floor(i/26)-1;while(i>=0);return d}function Qe(s){let d=0;for(let i=0;i<s.length;i++)d=d*26+(s.toUpperCase().charCodeAt(i)-64);return d-1}function ae(s){if(s==null)return null;if(typeof s=="number")return s;if(typeof s=="string"){const d=parseFloat(s);return s.endsWith("%")||isNaN(d)?null:d}return null}function et(s){navigator.clipboard.writeText(s).catch(()=>{const d=document.createElement("textarea");d.value=s,d.style.position="fixed",d.style.opacity="0",document.body.appendChild(d),d.select(),document.execCommand("copy"),document.body.removeChild(d)})}function me(s,d){return`${s},${d}`}function $e(s,d,i){const u=s.match(/^\$?([A-Z]+)\$?(\d+)$/i);if(!u)return null;const c=Qe(u[1]),E=parseInt(u[2],10)-1;return c<0||c>=d||E<0||E>=i?null:{col:c,row:E}}function re(s,d){if(!d)return{x:0,y:0};const i=d.getBoundingClientRect();return{x:s.clientX-i.left,y:s.clientY-i.top}}function sl(s,d,i){const u=s.split(":");if(u.length!==2)return null;const c=$e(u[0],d,i),E=$e(u[1],d,i);return!c||!E?null:{sc:Math.min(c.col,E.col),sr:Math.min(c.row,E.row),ec:Math.max(c.col,E.col),er:Math.max(c.row,E.row)}}function il(s,d,i,u,c){const E=i[me(s,d)];if(!E)return 0;const T=E.value;if(T.startsWith("="))return _t(me(s,d),i,u,c)??0;const b=parseFloat(T);return isNaN(b)?0:b}const be=new Map;function kt(){be.clear()}function _t(s,d,i,u){return ul(s,d,i,u)}function ul(s,d,i,u,c){if(be.has(s))return NaN;be.set(s,NaN);const E=d[s];if(!E)return NaN;const T=E.value;if(!T.startsWith("=")){const g=parseFloat(T),p=isNaN(g)?0:g;return be.set(s,p),p}const b=T.slice(1).trim();if(b.toUpperCase().startsWith("SUM(")&&b.endsWith(")")){const g=b.slice(4,-1).trim(),p=sl(g,i,u);if(p){let D=0;for(let N=p.sc;N<=p.ec;N++)for(let _=p.sr;_<=p.er;_++)D+=il(N,_,d,i,u);return isNaN(D)?NaN:(be.set(s,D),D)}return NaN}return NaN}function St(s,d,i){const u=[],c=/(\$?[A-Z]+\$?\d+)(?::(\$?[A-Z]+\$?\d+))?/gi;let E;for(;(E=c.exec(s))!==null;){const T=$e(E[1],d,i);if(T)if(E[2]){const b=$e(E[2],d,i);if(!b)continue;for(let L=Math.min(T.col,b.col);L<=Math.max(T.col,b.col);L++)for(let g=Math.min(T.row,b.row);g<=Math.max(T.row,b.row);g++)u.push(me(L,g))}else u.push(me(T.col,T.row))}return u}function fl(s,d,i,u,c){const E=i[me(s,d)];if(!E)return"";const T=E.value;if(!T.startsWith("="))return T;const b=_t(me(s,d),i,u,c);return isNaN(b)?"#ERROR":String(b)}function dl(s,d,i,u,c,E){return d===0&&i===0?s:s.replace(/(\$?)([A-Z]+)(\$?)(\d+)/gi,(T,b,L,g,p)=>{const D=b?Qe(L):Qe(L)+d,N=g?parseInt(p,10)-1:parseInt(p,10)-1+i;let _;D<0?_="A":D>=u?_=E(u-1):_=E(D);let C;return N<0?C="1":N>=c?C=String(c):C=String(N+1),(b||"")+_+(g||"")+C})}class vl{constructor(){this.deps=new Map,this.rev=new Map,this.dirty=new Set}clear(d){var u;const i=this.deps.get(d);if(i){for(const c of i)(u=this.rev.get(c))==null||u.delete(d);this.deps.delete(d)}}set(d,i){if(this.clear(d),i.length!==0){this.deps.set(d,i);for(const u of i)this.rev.has(u)||this.rev.set(u,new Set),this.rev.get(u).add(d)}}markDirty(d){const i=[d];for(;i.length>0;){const u=i.pop(),c=this.rev.get(u);if(c)for(const E of c)this.dirty.has(E)||(this.dirty.add(E),i.push(E))}}getDirtyAndClear(){const d=this.dirty;return this.dirty=new Set,d}rebuild(d,i,u){this.deps.clear(),this.rev.clear(),this.dirty.clear(),be.clear();for(const[c,E]of Object.entries(d))if(E.value.startsWith("=")){const T=St(E.value.slice(1),i,u);this.set(c,T)}}}function hl(s,d,i,u){const c={},E=u(d),T=u(i);return E!=null&&(c.width=`${E}px`),T!=null&&(c.height=`${T}px`),c["--sp-formula-bar-bg"]=s.formulaBarBg,c["--sp-formula-bar-border"]=s.formulaBarBorder,c["--sp-formula-bar-label-color"]=s.formulaBarLabelText,c["--sp-formula-bar-label-bg"]=s.formulaBarLabelBg,c["--sp-formula-bar-label-border"]=s.formulaBarLabelBorder,c["--sp-formula-bar-input-bg"]=s.formulaBarInputBg,c["--sp-formula-bar-input-border"]=s.formulaBarInputBorder,c["--sp-formula-bar-input-color"]=s.formulaBarInputText,c["--sp-formula-bar-input-focus-border"]=s.formulaBarInputFocusBorder,c["--sp-formula-bar-input-focus-shadow"]=s.formulaBarInputFocusShadow,c["--sp-wrapper-bg"]=s.wrapperBg,c["--sp-cell-editor-border"]=s.cellEditorBorder,c["--sp-cell-editor-color"]=s.cellEditorText,c["--sp-cell-editor-bg"]=s.cellEditorBg,c["--sp-cell-editor-shadow"]=s.cellEditorShadow,c["--sp-tab-bar-bg"]=s.tabBarBg,c["--sp-tab-bar-border"]=s.tabBarBorder,c["--sp-tab-active-bg"]=s.tabActiveBg,c["--sp-tab-active-color"]=s.tabActiveText,c["--sp-tab-active-border"]=s.tabActiveBorder,c["--sp-tab-inactive-bg"]=s.tabInactiveBg,c["--sp-tab-inactive-color"]=s.tabInactiveText,c["--sp-tab-inactive-border"]=s.tabInactiveBorder,c["--sp-tab-hover-bg"]=s.tabHoverBg,c["--sp-tab-add-btn-color"]=s.tabAddBtnColor,c["--sp-tab-add-btn-hover-bg"]=s.tabAddBtnHoverBg,c["--sp-tab-scroll-btn-color"]=s.tabScrollBtnColor,c["--sp-tab-scroll-btn-hover-bg"]=s.tabScrollBtnHoverBg,c["--sp-scroll-thumb"]=s.scrollbarThumb,c["--sp-scroll-thumb-hover"]=s.scrollbarThumbHover,c["--sp-scroll-btn-bg"]=s.scrollBtnBg,c["--sp-scroll-btn-color"]=s.scrollBtnColor,c["--sp-scroll-btn-hover-bg"]=s.scrollBtnHoverBg,c["--sp-scroll-btn-active-bg"]=s.scrollBtnActiveBg,c["--sp-scroll-track-bg"]=s.scrollTrackBg,c}const pl={class:"tab-list"},ml=["onClick","onDblclick","onContextmenu"],bl=["value"],El={key:1,class:"tab-item__name"},gl=["title"],Hl={class:"formula-bar"},wl={class:"formula-bar__cell-label"},Bl=["value"],yl=["value"],Tl=["title"],Dl=["title"],Rl=["title"],xl=["title"],kl={key:2,class:"sb-corner"},_l=["onClick","onMouseenter"],Sl={class:"context-menu__label"},Cl={key:0,class:"context-menu__arrow"},Il=["onClick"],Ct=((s,d)=>{const i=s.__vccOpts||s;for(const[u,c]of d)i[u]=c;return i})(a.defineComponent({__name:"spreader",props:a.mergeModels({rowCount:{default:200},colCount:{default:26},width:{},height:{},theme:{default:"light"},locale:{default:"zh-CN"}},{data:{default:()=>[]},dataModifiers:{}}),emits:["update:data"],setup(s){const d=s,i=a.computed(()=>d.locale==="zh-CN"?"zh-CN":"en-US"),u=d.colCount,c=d.rowCount,E=a.useModel(s,"data");let T="";const b=a.reactive({}),L=new vl,g=a.ref(null),p=a.ref({col:0,row:0}),D=a.ref(null),N=a.ref(""),_=a.ref(new Array(u).fill(100)),C=a.ref(new Array(c).fill(24)),R=a.ref(0),x=a.ref(0),ce=a.computed(()=>{const e=[0];for(let t=0;t<u;t++)e.push(e[t]+_.value[t]);return e}),se=a.computed(()=>{const e=[0];for(let t=0;t<c;t++)e.push(e[t]+C.value[t]);return e}),tt=a.computed(()=>ce.value[u]),lt=a.computed(()=>se.value[c]);function j(e,t){p.value={col:e,row:t},g.value={startCol:e,startRow:t,endCol:e,endRow:t}}function K(e,t,n,l){p.value={col:e,row:t},g.value={startCol:Math.min(e,n),startRow:Math.min(t,l),endCol:Math.max(e,n),endRow:Math.max(t,l)}}function nt(){K(0,0,u-1,c-1)}function It(e,t){const n=g.value;return n?e>=n.startCol&&e<=n.endCol&&t>=n.startRow&&t<=n.endRow:!1}function M(e,t){return`${e},${t}`}function $(e){Reflect.deleteProperty(b,e)}function Ee(e,t){var n;return((n=b[M(e,t)])==null?void 0:n.value)??""}function Al(e,t){return kt(),fl(e,t,b,u,c)}function ge(e,t,n){var h;const l=M(e,t);if(kt(),n===""||n==null){L.clear(l),$(l),L.markDirty(l);return}const o=String(n),r=((h=b[l])==null?void 0:h.style)??null;b[l]={value:o,style:r},o.startsWith("=")?L.set(l,St(o.slice(1),u,c)):L.clear(l),L.markDirty(l)}function At(e,t,n,l){for(let o=e;o<=t;o++)for(let r=n;r<=l;r++){const h=M(o,r);L.clear(h),$(h),L.markDirty(h)}}function ne(e){D.value||(D.value={...p.value},N.value=e??Ee(p.value.col,p.value.row))}function ie(){D.value&&(ge(D.value.col,D.value.row,N.value),D.value=null,N.value="")}function ue(){D.value=null,N.value=""}function ee(e,t){j(Math.max(0,Math.min(u-1,p.value.col+e)),Math.max(0,Math.min(c-1,p.value.row+t)))}function I(e,t){const n=Math.max(0,G.w-52-11),l=Math.max(0,G.h-24-11),o=ce.value[e],r=se.value[t],h=_.value[e],m=C.value[t];let H=R.value,y=x.value;o<H?H=o:o+h>H+n&&(H=o+h-n),r<y?y=r:r+m>y+l&&(y=r+m-l),V(H,y)}function P(e){const t=ce.value;if(e<0||e>=t[u])return-1;let n=0,l=u-1;for(;n<l;){const o=n+l+1>>1;t[o]<=e?n=o:l=o-1}return n}function Z(e){const t=se.value;if(e<0||e>=t[c])return-1;let n=0,l=c-1;for(;n<l;){const o=n+l+1>>1;t[o]<=e?n=o:l=o-1}return n}const oe=a.ref([]),Le=a.ref([]);function ot(){const e={};for(const[t,n]of Object.entries(b))e[t]={value:n.value,style:n.style};return{cells:e,colWidths:[..._.value],rowHeights:[...C.value]}}function Mt(e){Object.keys(b).forEach(t=>$(t)),Object.assign(b,e.cells),_.value=e.colWidths,C.value=e.rowHeights,L.rebuild(b,u,c)}function F(){const e=ot(),t=oe.value[oe.value.length-1];t&&JSON.stringify(t)===JSON.stringify(e)||(oe.value.push(e),Le.value=[],oe.value.length>50&&oe.value.shift())}function Ml(){oe.value.length&&(Le.value.push(ot()),Mt(oe.value.pop()),g.value=null,v())}function Wl(){Le.value.length&&(oe.value.push(ot()),Mt(Le.value.pop()),g.value=null,v())}let Wt=null;function Ge(){const e=g.value;if(!e)return;Wt={...e};const t=[];for(let n=e.startRow;n<=e.endRow;n++){const l=[];for(let o=e.startCol;o<=e.endCol;o++)l.push(Ee(o,n));t.push(l.join(" "))}et(t.join(`
|
|
2
|
+
`))}function Fe(){const e=g.value;if(e){if(e.startCol===0&&e.endCol===u-1){const t=[];for(let n=e.startRow;n<=e.endRow;n++){const l=[];for(let o=0;o<u;o++)l.push(Ee(o,n));t.push(l.join(" "))}et(t.join(`
|
|
3
|
+
`))}else if(e.startRow===0&&e.endRow===c-1){const t=[];for(let n=0;n<c;n++){const l=[];for(let o=e.startCol;o<=e.endCol;o++)l.push(Ee(o,n));t.push(l.join(" "))}et(t.join(`
|
|
4
|
+
`))}}}async function Ce(){let e="";try{e=await navigator.clipboard.readText()}catch{return}if(!e&&e!=="")return;const t=e.split(/\r?\n/),n=p.value,l=Wt;for(let o=0;o<t.length;o++){const r=t[o].split(" ");for(let h=0;h<r.length;h++){const m=n.col+h,H=n.row+o;if(m<u&&H<c){let y=r[h];y.startsWith("=")&&l&&(y=dl(y,m-(l.startCol+h),H-(l.startRow+o),u,c,Y)),ge(m,H,y)}}}}function at(){if(Ge(),g.value){const e=g.value;At(e.startCol,e.endCol,e.startRow,e.endRow),v()}}function rt(){if(g.value){const e=g.value;At(e.startCol,e.endCol,e.startRow,e.endRow),v()}}function Nl(){const e=g.value;if(!e)return;F();const t=e.startCol,n=e.startRow,l=e.endCol,o=e.endRow;if(n===o)if(l+1<u){const r=`${Y(t)}${n+1}:${Y(l)}${n+1}`;ge(l+1,n,`=SUM(${r})`)}else{const r=`${Y(t)}${n+1}:${Y(l-1)}${n+1}`;ge(l,n,`=SUM(${r})`)}else for(let r=t;r<=l;r++)if(o+1<c){const h=`${Y(r)}${n+1}:${Y(r)}${o+1}`;ge(r,o+1,`=SUM(${h})`)}else{const h=`${Y(r)}${n+1}:${Y(r)}${o}`;ge(r,o,`=SUM(${h})`)}v(),A()}function $l(e,t){const n=t-e+1;for(let l=e;l<=t;l++)for(let o=0;o<u;o++)$(M(o,l));for(let l=e;l<c-n;l++){for(let o=0;o<u;o++){const r=M(o,l+n),h=M(o,l);b[r]?(b[h]=b[r],$(r)):$(h)}C.value[l]=C.value[l+n]}for(let l=c-n;l<c;l++){for(let o=0;o<u;o++)$(M(o,l));C.value[l]=24}}function Ll(e,t){const n=t-e+1;if(!(t>=c-1)){for(let l=c-1;l>t;l--){for(let o=0;o<u;o++){const r=M(o,l-n),h=M(o,l);b[r]?b[h]=b[r]:$(h)}C.value[l]=C.value[l-n]}for(let l=t+1;l<=t+n;l++){for(let o=0;o<u;o++)$(M(o,l));C.value[l]=24}}}function Gl(e,t){const n=t-e+1;if(!(t>=u-1)){for(let l=u-1;l>t;l--){for(let o=0;o<c;o++){const r=M(l-n,o),h=M(l,o);b[r]?b[h]=b[r]:$(h)}_.value[l]=_.value[l-n]}for(let l=t+1;l<=t+n;l++){for(let o=0;o<c;o++)$(M(l,o));_.value[l]=100}}}function Fl(e,t){const n=t-e+1;for(let l=e;l<=t;l++)for(let o=0;o<c;o++)$(M(l,o));for(let l=e;l<u-n;l++){for(let o=0;o<c;o++){const r=M(l+n,o),h=M(l,o);b[r]?(b[h]=b[r],$(r)):$(h)}_.value[l]=_.value[l+n]}for(let l=u-n;l<u;l++){for(let o=0;o<c;o++)$(M(l,o));_.value[l]=100}}let Nt=0;function $t(){return Nt++,`s_${Nt}`}function Ve(e){return{id:$t(),name:e,cells:{},selection:{startCol:0,startRow:0,endCol:0,endRow:0},activeCell:{col:0,row:0},scrollX:0,scrollY:0,colWidths:new Array(u).fill(100),rowHeights:new Array(c).fill(24)}}const k=a.ref([Ve("Sheet1")]),U=a.ref(0);function Ie(){const e=k.value[U.value];e&&(e.cells={...b},e.selection=g.value?{...g.value}:null,e.activeCell={...p.value},e.scrollX=R.value,e.scrollY=x.value,e.colWidths=[..._.value],e.rowHeights=[...C.value])}function fe(e){const t=k.value[e];t&&(Object.keys(b).forEach(n=>$(n)),Object.assign(b,t.cells),g.value=t.selection?{...t.selection}:null,p.value={...t.activeCell},R.value=t.scrollX,x.value=t.scrollY,_.value=[...t.colWidths],C.value=[...t.rowHeights],U.value=e)}function Vl(e){e===U.value||e<0||e>=k.value.length||(ue(),Ie(),fe(e))}function ct(e){return ue(),Ie(),k.value.push(Ve(`Sheet${k.value.length+1}`)),fe(k.value.length-1),k.value.length-1}function Ol(e){return k.value.length<=1||(ue(),k.value.splice(e,1),fe(Math.min(e,k.value.length-1))),U.value}function Ul(e,t){k.value[e]&&t.trim()&&(k.value[e].name=t.trim())}function Xl(e){ue(),Ie();const t=k.value[e];if(!t)return e;let n=t.name;const l=n.match(/^(.*?)\s*\((\d+)\)$/);let o=l?parseInt(l[2],10)+1:2;l&&(n=l[1]);let r=`${n} (${o})`;const h=new Set(k.value.map(H=>H.name));for(;h.has(r);)o++,r=`${n} (${o})`;const m={id:$t(),name:r,cells:{...t.cells},selection:t.selection?{...t.selection}:null,activeCell:t.activeCell?{...t.activeCell}:{col:0,row:0},scrollX:t.scrollX,scrollY:t.scrollY,colWidths:[...t.colWidths],rowHeights:[...t.rowHeights]};return k.value.splice(e+1,0,m),fe(e+1),e+1}function Lt(e,t){const n=e+t;if(n<0||n>=k.value.length)return;const l=U.value,o=k.value.splice(e,1)[0];k.value.splice(n,0,o),l===e?U.value=n:e<l&&n>=l?U.value=l-1:e>l&&n<=l&&(U.value=l+1),v()}const zl=a.computed(()=>k.value.length);function A(){Ie();const e=k.value.map(n=>{const l={};for(const[m,H]of Object.entries(n.cells))l[m]={value:H.value},H.style&&(l[m].style=H.style);const o={name:n.name,cells:l},r={};for(let m=0;m<n.colWidths.length;m++)n.colWidths[m]!==100&&(r[m]=n.colWidths[m]);Object.keys(r).length&&(o.colWidths=r);const h={};for(let m=0;m<n.rowHeights.length;m++)n.rowHeights[m]!==24&&(h[m]=n.rowHeights[m]);return Object.keys(h).length&&(o.rowHeights=h),o}),t=JSON.stringify(e);t!==T&&(T=t,E.value=e)}let st=!1;function Gt(){st||(st=!0,Promise.resolve().then(()=>{st=!1,A()}))}const Ft=a.computed(()=>d.theme==="dark"?cl:rl),Yl=a.computed(()=>hl(Ft.value,d.width,d.height,ae)),de=a.ref(null),J=a.ref(null),it=a.ref(null),ut=a.ref(null),G=a.reactive({w:800,h:600}),He=a.computed(()=>Math.max(0,tt.value-Math.max(0,G.w-52-11))),we=a.computed(()=>Math.max(0,lt.value-Math.max(0,G.h-24-11)));function V(e,t){const n=Math.max(0,G.w-52-11),l=Math.max(0,G.h-24-11);R.value=Math.max(0,Math.min(e??R.value,Math.max(0,tt.value-n))),x.value=Math.max(0,Math.min(t??x.value,Math.max(0,lt.value-l)))}function jl(){var e;return typeof window>"u"?!1:!((e=window.matchMedia)!=null&&e.call(window,"(hover: none) and (pointer: coarse)").matches)}function O(e=!1){a.nextTick(()=>{const t=it.value;if(t){if(!D.value&&!jl()){document.activeElement===t&&t.blur();return}t.focus(),e&&t.select()}})}function Kl(){O()}let ft=!1,f=null,Ae=1;function v(){ft||(ft=!0,requestAnimationFrame(()=>{ft=!1,Pl()}))}function Pl(){const e=J.value;if(!e)return;const t=de.value;if(!t||(f=e.getContext("2d"),!f))return;Ae=window.devicePixelRatio||1;const n=t.getBoundingClientRect(),l=n.width,o=n.height;G.w=l,G.h=o,e.width=l*Ae,e.height=o*Ae,e.style.width=l+"px",e.style.height=o+"px",f.setTransform(Ae,0,0,Ae,0,0);const r=R.value,h=x.value,m=52,H=24,y=Ft.value,Dt=ce.value,Rt=se.value,qt=_.value,Qt=C.value,Je=Math.max(0,P(r));let el=Je;for(let w=Je;w<u&&!(m+Dt[w]-r>=l);w++)el=w;const tl=el,qe=Math.max(0,Z(h));let ll=qe;for(let w=qe;w<c&&!(H+Rt[w]-h>=o);w++)ll=w;const nl=ll;f.fillStyle=y.bg,f.fillRect(0,0,l,o),f.fillStyle=y.gridBg,f.fillRect(m,H,l-m,o-H),f.save(),f.beginPath(),f.rect(m+.5,H+.5,l-m-1,o-H-1),f.clip();const z=g.value,xt=D.value;for(let w=qe;w<=nl;w++)for(let S=Je;S<=tl;S++){const W=m+Dt[S]-r,pe=H+Rt[w]-h,Ne=qt[S],Se=Qt[w];if(!(W+Ne<m||pe+Se<H||W>l||pe>o)&&(It(S,w)&&(f.fillStyle=y.selectionBg,f.fillRect(W,pe,Ne,Se)),p.value.col===S&&p.value.row===w&&(f.strokeStyle=y.activeCellBorder,f.lineWidth=2,f.strokeRect(W+1,pe+1,Ne-2,Se-2)),f.strokeStyle=y.gridLine,f.lineWidth=.5,f.strokeRect(W+.25,pe+.25,Ne-.5,Se-.5),!(xt&&xt.col===S&&xt.row===w))){const ol=Al(S,w);ol&&(f.fillStyle=y.cellText,f.font='13px -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif',f.textBaseline="middle",f.save(),f.beginPath(),f.rect(W+5,pe+1,Ne-10,Se-2),f.clip(),f.fillText(ol,W+5,pe+Se/2+.5),f.restore())}}f.restore(),f.fillStyle=y.headerBg,f.fillRect(m,0,l-m,H);for(let w=Je;w<=tl;w++){const S=m+Dt[w]-r,W=qt[w];S+W<m||S>l||(z&&w>=z.startCol&&w<=z.endCol&&(f.fillStyle=y.selectionBg,f.fillRect(S,0,W,H)),f.strokeStyle=y.headerBorder,f.lineWidth=.5,f.strokeRect(S+.25,.25,W-.5,H-.5),z&&w>=z.startCol&&w<=z.endCol&&(f.strokeStyle=y.activeCellBorder,f.lineWidth=2,f.beginPath(),f.moveTo(S,H-1),f.lineTo(S+W,H-1),f.stroke()),f.fillStyle=y.headerText,f.font='11px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',f.textAlign="center",f.textBaseline="middle",f.fillText(Y(w),S+W/2,H/2))}f.strokeStyle=y.headerSep,f.lineWidth=1,f.beginPath(),f.moveTo(m,H+.5),f.lineTo(l,H+.5),f.stroke(),f.fillStyle=y.headerBg,f.fillRect(0,H,m,o-H);for(let w=qe;w<=nl;w++){const S=H+Rt[w]-h,W=Qt[w];S+W<H||S>o||(z&&w>=z.startRow&&w<=z.endRow&&(f.fillStyle=y.selectionBg,f.fillRect(0,S,m,W)),f.strokeStyle=y.headerBorder,f.lineWidth=.5,f.strokeRect(.25,S+.25,m-.5,W-.5),z&&w>=z.startRow&&w<=z.endRow&&(f.strokeStyle=y.activeCellBorder,f.lineWidth=2,f.beginPath(),f.moveTo(m-1,S),f.lineTo(m-1,S+W),f.stroke()),f.fillStyle=y.headerText,f.font='11px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',f.textAlign="center",f.textBaseline="middle",f.fillText(String(w+1),m/2,S+W/2+.5))}f.strokeStyle=y.headerSep,f.lineWidth=1,f.beginPath(),f.moveTo(m+.5,H),f.lineTo(m+.5,o),f.stroke(),f.fillStyle=y.headerBg,f.fillRect(0,0,m,H),f.strokeStyle=y.headerSep,f.lineWidth=1,f.strokeRect(.5,.5,m-.5,H-.5)}const Zl=a.computed(()=>Y(p.value.col)+String(p.value.row+1)),Jl=a.computed(()=>D.value?N.value:Ee(p.value.col,p.value.row));function ql(){D.value||(I(p.value.col,p.value.row),N.value=Ee(p.value.col,p.value.row),ne(),v())}function Ql(e){N.value=e.target.value}function en(e){var t,n;e.key==="Enter"?(e.preventDefault(),ie(),ee(0,1),I(p.value.col,p.value.row),(t=ut.value)==null||t.blur(),v(),O()):e.key==="Escape"&&(e.preventDefault(),ue(),(n=ut.value)==null||n.blur(),v(),O())}function tn(){setTimeout(()=>{D.value&&(ie(),v())},0)}const ve=a.ref(null),Be=a.ref("");function ln(e){ve.value===null&&(Vl(e),v())}function Vt(e){e!==U.value&&(Ie(),fe(e),v()),ve.value=e,Be.value=k.value[e].name,a.nextTick(()=>{const t=document.querySelector(".tab-rename-input");t==null||t.focus(),t==null||t.select()})}function Ot(){ve.value!==null&&(Ul(ve.value,Be.value),a.nextTick(A)),ve.value=null,Be.value=""}function nn(){ve.value=null,Be.value=""}function on(e){e.key==="Enter"?(e.preventDefault(),Ot()):e.key==="Escape"&&(e.preventDefault(),nn())}const te=a.ref(null);let Me=null;function Ut(){Me&&(document.removeEventListener("click",Me),Me=null)}function ye(e,t,n){Ut();const l=140,o=n.length*28+8,r=window.innerWidth,h=window.innerHeight;e+l>r&&(e-=l),t+o>h&&(t-=o),te.value={x:e,y:t,items:n},Me=()=>{te.value=null,Ut()},setTimeout(()=>document.addEventListener("click",Me,{once:!0}),0)}const Oe=a.ref(!1);function an(e,t){if(!t.children){Oe.value=!1;return}const l=e.currentTarget.querySelector(".context-submenu");if(!l){Oe.value=!1;return}const o=l.getBoundingClientRect();Oe.value=o.right>window.innerWidth}function rn(e,t){e.preventDefault(),e.stopPropagation(),ye(e.clientX,e.clientY,[{label:B(i.value,"insert"),action:()=>{ct(),v()}},{label:B(i.value,"copy"),action:()=>{Xl(t)}},{label:B(i.value,"rename"),action:()=>{Vt(t)}},{label:B(i.value,"delete"),action:()=>{Ol(t),v()},disabled:zl.value<=1},{label:B(i.value,"moveSheetLeft"),action:()=>{Lt(t,-1)},disabled:t===0},{label:B(i.value,"moveSheetRight"),action:()=>{Lt(t,1)},disabled:t===k.value.length-1}])}function cn(e){e.preventDefault(),!(e.target.closest(".tab-item")||e.target.closest(".tab-bar__add-btn"))&&ye(e.clientX,e.clientY,[{label:B(i.value,"insert"),action:()=>{ct(),v()}}])}function sn(e){e.preventDefault(),nt(),v(),ye(e.clientX,e.clientY,[{label:B(i.value,"cut"),action:()=>{at(),A()}},{label:B(i.value,"copy"),action:()=>Ge()},{label:B(i.value,"paste"),action:()=>{F(),Ce().then(()=>{v(),a.nextTick(A)})}},{label:B(i.value,"delete"),action:()=>{F(),rt();for(let t=0;t<u;t++)_.value[t]=100;for(let t=0;t<c;t++)C.value[t]=24;v(),A()}}])}function un(e,t){e.preventDefault();const n=g.value;n&&n.startCol===0&&n.endCol===u-1&&t>=n.startRow&&t<=n.endRow||(K(0,t,u-1,t),v());const l=g.value;ye(e.clientX,e.clientY,[{label:B(i.value,"insert"),action:()=>{F(),Ll(l.startRow,l.endRow),v(),A()},disabled:l.endRow>=c-1},{label:B(i.value,"cut"),action:()=>{F(),Fe();for(let o=l.startRow;o<=l.endRow;o++)for(let r=0;r<u;r++)$(M(r,o));v(),A()}},{label:B(i.value,"copy"),action:()=>Fe()},{label:B(i.value,"paste"),action:()=>{F(),Ce().then(()=>{v(),a.nextTick(A)})}},{label:B(i.value,"delete"),action:()=>{F(),$l(l.startRow,l.endRow),v(),A()}}])}function fn(e,t){e.preventDefault();const n=g.value;n&&n.startRow===0&&n.endRow===c-1&&t>=n.startCol&&t<=n.endCol||(K(t,0,t,c-1),v());const l=g.value;ye(e.clientX,e.clientY,[{label:B(i.value,"insert"),action:()=>{F(),Gl(l.startCol,l.endCol),v(),A()},disabled:l.endCol>=u-1},{label:B(i.value,"cut"),action:()=>{F(),Fe();for(let o=l.startCol;o<=l.endCol;o++)for(let r=0;r<c;r++)$(M(o,r));v(),A()}},{label:B(i.value,"copy"),action:()=>Fe()},{label:B(i.value,"paste"),action:()=>{F(),Ce().then(()=>{v(),a.nextTick(A)})}},{label:B(i.value,"delete"),action:()=>{F(),Fl(l.startCol,l.endCol),v(),A()}}])}function dn(e,t,n){e.preventDefault(),It(t,n)||(j(t,n),v());const l=g.value,o=!!(l&&l.startCol===l.endCol&&l.startRow===l.endRow);ye(e.clientX,e.clientY,[{label:B(i.value,"cut"),action:()=>{at(),A()}},{label:B(i.value,"copy"),action:()=>Ge()},{label:B(i.value,"paste"),action:()=>{F(),Ce().then(()=>{v(),a.nextTick(A)})}},{label:B(i.value,"delete"),action:()=>{F(),rt(),v(),A()}},{label:B(i.value,"calculate"),children:[{label:B(i.value,"sum"),action:Nl,disabled:o}]}])}const vn=a.computed(()=>{const e=!D.value,t=D.value??p.value,n=t.col,l=t.row;return{left:`${52+ce.value[n]-R.value}px`,top:`${24+se.value[l]-x.value}px`,width:`${_.value[n]}px`,height:`${C.value[l]}px`,opacity:e?0:1,pointerEvents:e?"none":"auto",color:e?"transparent":void 0,caretColor:e?"transparent":void 0,borderColor:e?"transparent":void 0,background:e?"transparent":void 0,boxShadow:e?"none":void 0}}),hn=a.computed(()=>Math.max(0,G.w-52-11)),pn=a.computed(()=>Math.max(0,G.h-24-11)),Ue=a.computed(()=>Math.max(0,hn.value-11*2)),Xe=a.computed(()=>Math.max(0,pn.value-11*2));function dt(){return Math.max(0,G.w-52-11)}function vt(){return Math.max(0,G.h-24-11)}const ze=a.computed(()=>He.value<=0?Ue.value:Math.max(24,dt()/tt.value*Ue.value)),ht=a.computed(()=>He.value<=0?0:R.value/He.value*(Ue.value-ze.value)),Ye=a.computed(()=>we.value<=0?Xe.value:Math.max(24,vt()/lt.value*Xe.value)),pt=a.computed(()=>we.value<=0?0:x.value/we.value*(Xe.value-Ye.value));let he=null,je=0,Ke=0;function mn(e){e.preventDefault(),he="v",je=e.clientY,Ke=x.value,document.addEventListener("mousemove",mt),document.addEventListener("mouseup",bt)}function bn(e){e.preventDefault(),he="h",je=e.clientX,Ke=R.value,document.addEventListener("mousemove",mt),document.addEventListener("mouseup",bt)}function mt(e){if(he==="v"){const n=(e.clientY-je)/(Xe.value-Ye.value);V(null,Ke+n*we.value),v()}else if(he==="h"){const n=(e.clientX-je)/(Ue.value-ze.value);V(Ke+n*He.value,null),v()}}function bt(){he=null,document.removeEventListener("mousemove",mt),document.removeEventListener("mouseup",bt)}function En(e){if(he)return;const t=e.currentTarget.getBoundingClientRect(),n=e.clientY-t.top;n<pt.value?V(null,x.value-vt()):n>pt.value+Ye.value&&V(null,x.value+vt()),v()}function gn(e){if(he)return;const t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left;n<ht.value?V(R.value-dt(),null):n>ht.value+ze.value&&V(R.value+dt(),null),v()}let Te=!1,q=0,Q=0,De=!1,Re=!1,Xt=0,zt=0,xe=0,Pe=0,Et=0,gt=0,Yt=0,jt=0,We=!1,Ht=!1,ke=0,_e=0,wt=0,Kt=-1,Pt=-1;function Hn(e){if(e.button!==0)return;e.preventDefault(),te.value=null;const t=re(e,J.value);if(t.y<24&&t.x>=52){const o=t.x-52+R.value,r=P(o);if(r>=0&&Math.abs(t.x-(52+ce.value[r+1]-R.value))<=4){De=!0,Xt=r,xe=_.value[r],Pe=o,v();return}}if(t.x<52&&t.y>=24){const o=t.y-24+x.value,r=Z(o);if(r>=0&&Math.abs(t.y-(24+se.value[r+1]-x.value))<=4){Re=!0,zt=r,xe=C.value[r],Pe=o,v();return}}if(t.x<52||t.y<24){if(t.y<24&&t.x>=52){const o=P(t.x-52+R.value);o>=0&&(K(o,0,o,c-1),Te=!0,q=o,Q=0)}else if(t.x<52&&t.y>=24){const o=Z(t.y-24+x.value);o>=0&&(K(0,o,u-1,o),Te=!0,q=0,Q=o)}else t.x<52&&t.y<24&&nt();v();return}const n=P(t.x-52+R.value),l=Z(t.y-24+x.value);if(!(n<0||l<0)){if(ie(),e.shiftKey&&g.value){const o=g.value;K(o.startCol,o.startRow,n,l)}else j(n,l);Te=!0,q=n,Q=l,O(),v()}}function wn(e){if(De){const r=re(e,J.value).x-52+R.value-Pe;xe+r>=30&&(_.value[Xt]=xe+r),v();return}if(Re){const r=re(e,J.value).y-24+x.value-Pe;xe+r>=24&&(C.value[zt]=xe+r),v();return}if(!Te){const o=J.value;if(!o)return;const r=re(e,o);if(r.y<24&&r.x>=52){const h=P(r.x-52+R.value);if(h>=0&&Math.abs(r.x-(52+ce.value[h+1]-R.value))<=4){o.style.cursor="col-resize";return}}if(r.x<52&&r.y>=24){const h=Z(r.y-24+x.value);if(h>=0&&Math.abs(r.y-(24+se.value[h+1]-x.value))<=4){o.style.cursor="row-resize";return}}o.style.cursor="cell";return}const t=re(e,J.value);if(q<0||Q<0)return;if(t.x<52||t.y<24){if(t.y<24&&t.x>=52){const o=P(t.x-52+R.value);o>=0&&K(Math.min(q,o),0,Math.max(q,o),c-1)}else if(t.x<52&&t.y>=24){const o=Z(t.y-24+x.value);o>=0&&K(0,Math.min(Q,o),u-1,Math.max(Q,o))}v();return}const n=P(t.x-52+R.value),l=Z(t.y-24+x.value);n<0||l<0||(Q===0&&q>=0&&g.value&&g.value.startRow===0&&g.value.endRow===c-1?K(Math.min(q,n),0,Math.max(q,n),c-1):q===0&&Q>=0&&g.value&&g.value.startCol===0&&g.value.endCol===u-1?K(0,Math.min(Q,l),u-1,Math.max(Q,l)):K(q,Q,n,l),v())}function Bn(){const e=De||Re;Te=!1,De=!1,Re=!1,e&&Gt()}function yn(){const e=De||Re;Te=!1,De=!1,Re=!1,e&&Gt()}function Tn(e){e.preventDefault();const t=re(e,J.value);if(t.x<52&&t.y<24){sn(e);return}if(t.y<24&&t.x>=52){const n=P(t.x-52+R.value);n>=0&&fn(e,n);return}if(t.x<52&&t.y>=24){const n=Z(t.y-24+x.value);n>=0&&un(e,n);return}if(t.x>=52&&t.y>=24){const n=P(t.x-52+R.value),l=Z(t.y-24+x.value);n>=0&&l>=0&&dn(e,n,l)}}function Dn(e){const t=re(e,J.value);if(t.x<52||t.y<24)return;const n=P(t.x-52+R.value),l=Z(t.y-24+x.value);n<0||l<0||(j(n,l),I(n,l),ne(),v(),O())}function Rn(e){V(R.value+e.deltaX,x.value+e.deltaY),v()}function xn(e){if(e.touches.length!==1){We=!1;return}const t=e.touches[0],n=J.value;if(!n)return;const l=n.getBoundingClientRect(),o=t.clientX-l.left,r=t.clientY-l.top;o>=52&&r>=24&&(e.preventDefault(),We=!0,Ht=!1,Et=o,gt=r,Yt=R.value,jt=x.value,ke=P(o-52+R.value),_e=Z(r-24+x.value))}function kn(e){if(!We||e.touches.length!==1)return;const t=e.touches[0],n=J.value;if(!n)return;const l=n.getBoundingClientRect(),o=t.clientX-l.left,r=t.clientY-l.top;(Math.abs(o-Et)>8||Math.abs(r-gt)>8)&&(Ht=!0,e.preventDefault(),V(Yt+(Et-o),jt+(gt-r)),v())}function _n(){if(We&&(We=!1,!Ht&&ke>=0&&_e>=0)){const e=Date.now();ke===Kt&&_e===Pt&&e-wt<300?(j(ke,_e),ne(),v(),O(),wt=0):(ie(),j(ke,_e),v(),wt=e),Kt=ke,Pt=_e,O()}}function Bt(e){return e.isComposing||e.key==="Process"||e.keyCode===229}function Zt(e){return e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey}function Jt(e){if(D.value)return;const t=e.ctrlKey||e.metaKey,n=e.shiftKey;switch(!0){case(t&&(e.key==="c"||e.key==="C")):e.preventDefault(),Ge();return;case(t&&(e.key==="x"||e.key==="X")):e.preventDefault(),at();return;case(t&&(e.key==="z"||e.key==="Z")):e.preventDefault(),Ml();return;case(t&&(e.key==="y"||e.key==="Y")):e.preventDefault(),Wl();return;case(t&&(e.key==="v"||e.key==="V")):e.preventDefault(),F(),Ce().then(()=>{v(),a.nextTick(A)});return;case(t&&(e.key==="a"||e.key==="A")):e.preventDefault(),nt(),v();return;case(t&&e.key==="Home"):e.preventDefault(),j(0,0),I(0,0),v();return;case(t&&e.key==="End"):e.preventDefault(),j(u-1,c-1),I(u-1,c-1),v();return;case e.key==="Home":e.preventDefault(),j(0,p.value.row),I(0,p.value.row),v();return;case e.key==="End":e.preventDefault(),j(u-1,p.value.row),I(u-1,p.value.row),v();return;case e.key==="ArrowUp":e.preventDefault(),ee(0,-1),I(p.value.col,p.value.row),v();return;case e.key==="ArrowDown":e.preventDefault(),ee(0,1),I(p.value.col,p.value.row),v();return;case e.key==="ArrowLeft":e.preventDefault(),ee(-1,0),I(p.value.col,p.value.row),v();return;case e.key==="ArrowRight":e.preventDefault(),ee(1,0),I(p.value.col,p.value.row),v();return;case e.key==="Tab":e.preventDefault(),ee(n?-1:1,0),I(p.value.col,p.value.row),v();return;case e.key==="Enter":e.preventDefault(),ee(0,n?-1:1),I(p.value.col,p.value.row),v();return;case e.key==="F2":e.preventDefault(),I(p.value.col,p.value.row),ne(),v(),O();return;case e.key==="Delete":case e.key==="Backspace":e.preventDefault(),F(),rt(),v();return;case e.key==="Escape":e.preventDefault(),ue(),v();return;case Zt(e):if(Bt(e)){I(p.value.col,p.value.row),ne(""),v(),O();return}e.preventDefault(),I(p.value.col,p.value.row),ne(e.key),v(),a.nextTick(()=>{const l=it.value;l&&(l.focus(),l.setSelectionRange(1,1))});return}}let yt=!1,Tt=!1;function Sn(e){const t=e.target.value;if(!D.value){I(p.value.col,p.value.row),ne(t),v();return}N.value=t}function Cn(){yt=!0,D.value||(I(p.value.col,p.value.row),ne(""),v())}function In(e){yt=!1,Tt=!0,setTimeout(()=>{Tt=!1},0),N.value=e.target.value}function An(e){if(!D.value){if(Zt(e)||Bt(e))return;Jt(e);return}yt||Bt(e)||Tt&&(e.key==="Enter"||e.key==="Escape")||(e.key==="Enter"?(e.preventDefault(),ie(),ee(0,1),I(p.value.col,p.value.row),v(),O()):e.key==="Tab"?(e.preventDefault(),ie(),ee(e.shiftKey?-1:1,0),I(p.value.col,p.value.row),v(),O()):e.key==="Escape"&&(e.preventDefault(),ue(),v(),O()))}function Mn(){setTimeout(()=>{D.value&&(ie(),v())},0)}function Ze(){var t;const e=(t=de.value)==null?void 0:t.getBoundingClientRect();if(e){const n=ae(d.width),l=ae(d.height);n!=null?G.w=n:G.w=e.width,l!=null?G.h=l:G.h=e.height}V(null,null),v()}let X=null;return a.onMounted(()=>{const e=ae(d.width),t=ae(d.height);(e==null||t==null)&&(X=new ResizeObserver(()=>Ze()),de.value&&X.observe(de.value)),a.nextTick(()=>{Ze(),O()}),j(0,0),E.value&&E.value.length>0&&(T=JSON.stringify(E.value),k.value=E.value.map(n=>{const l=Ve(n.name);for(const[o,r]of Object.entries(n.cells))l.cells[o]={value:r.value,style:r.style??null};if(n.colWidths)for(const[o,r]of Object.entries(n.colWidths)){const h=Number(o);h>=0&&h<u&&r>=30&&(l.colWidths[h]=r)}if(n.rowHeights)for(const[o,r]of Object.entries(n.rowHeights)){const h=Number(o);h>=0&&h<c&&r>=24&&(l.rowHeights[h]=r)}return l}),k.value.length>0&&fe(0))}),a.watch(()=>[d.width,d.height],()=>{const e=ae(d.width),t=ae(d.height);e!=null&&t!=null?(X==null||X.disconnect(),X=null):!X&&de.value&&(X=new ResizeObserver(()=>Ze()),X.observe(de.value)),a.nextTick(()=>Ze())}),a.watch(()=>d.theme,()=>v()),a.watch(()=>({...b}),()=>a.nextTick(A),{deep:!1}),a.watch(U,()=>a.nextTick(A)),a.watch(()=>E.value,e=>{if(!e||e.length===0)return;const t=JSON.stringify(e);t!==T&&(T=t,k.value=e.map(n=>{const l=Ve(n.name);for(const[o,r]of Object.entries(n.cells))l.cells[o]={value:r.value,style:r.style??null};if(n.colWidths)for(const[o,r]of Object.entries(n.colWidths)){const h=Number(o);h>=0&&h<u&&r>=30&&(l.colWidths[h]=r)}if(n.rowHeights)for(const[o,r]of Object.entries(n.rowHeights)){const h=Number(o);h>=0&&h<c&&r>=24&&(l.rowHeights[h]=r)}return l}),k.value.length>0&&fe(0),v())},{deep:!0}),a.onBeforeUnmount(()=>{X==null||X.disconnect()}),(e,t)=>(a.openBlock(),a.createElementBlock("div",{class:"spreadsheet-outer",style:a.normalizeStyle(Yl.value)},[a.createElementVNode("div",{class:"tab-bar",onContextmenu:cn},[a.createElementVNode("div",pl,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(k.value,(n,l)=>(a.openBlock(),a.createElementBlock("div",{key:n.id,class:a.normalizeClass(["tab-item",{"tab-item--active":l===U.value}]),onClick:o=>ln(l),onDblclick:a.withModifiers(o=>Vt(l),["prevent"]),onContextmenu:o=>rn(o,l)},[ve.value===l?(a.openBlock(),a.createElementBlock("input",{key:0,class:"tab-rename-input",value:Be.value,onInput:t[0]||(t[0]=o=>Be.value=o.target.value),onKeydown:on,onBlur:Ot,onClick:t[1]||(t[1]=a.withModifiers(()=>{},["stop"]))},null,40,bl)):(a.openBlock(),a.createElementBlock("span",El,a.toDisplayString(n.name),1))],42,ml))),128))]),a.createElementVNode("button",{class:"tab-bar__add-btn",title:a.unref(B)(i.value,"addSheet"),onClick:t[2]||(t[2]=n=>{ct(),v()})}," + ",8,gl)],32),a.createElementVNode("div",Hl,[a.createElementVNode("div",wl,a.toDisplayString(Zl.value),1),a.createElementVNode("input",{ref_key:"formulaBarRef",ref:ut,class:"formula-bar__input",value:Jl.value,onFocus:ql,onInput:Ql,onKeydown:en,onBlur:tn},null,40,Bl)]),a.createElementVNode("div",{ref_key:"wrapperRef",ref:de,class:"spreadsheet-wrapper"},[a.createElementVNode("canvas",{ref_key:"canvasRef",ref:J,class:"grid-canvas",tabindex:"0",onMousedown:Hn,onMousemove:wn,onMouseup:Bn,onMouseleave:yn,onDblclick:Dn,onWheel:a.withModifiers(Rn,["prevent"]),onFocus:Kl,onKeydown:Jt,onContextmenu:Tn,onTouchstart:a.withModifiers(xn,["prevent"]),onTouchmove:a.withModifiers(kn,["prevent"]),onTouchend:_n},null,544),a.createElementVNode("input",{ref_key:"editInputRef",ref:it,class:"cell-editor",value:N.value,style:a.normalizeStyle(vn.value),onInput:Sn,onKeydown:An,onCompositionstart:Cn,onCompositionend:In,onBlur:Mn},null,44,yl),we.value>0?(a.openBlock(),a.createElementBlock("div",{key:0,class:"v-scrollbar",style:a.normalizeStyle({top:a.unref(24)+"px",height:`calc(100% - ${a.unref(24)+a.unref(11)}px)`})},[a.createElementVNode("button",{class:"sb-btn sb-btn--up",title:a.unref(B)(i.value,"scrollUp"),onMousedown:t[3]||(t[3]=a.withModifiers(n=>{V(null,x.value-50),v()},["prevent"]))},[...t[8]||(t[8]=[a.createElementVNode("span",{class:"sb-arrow sb-arrow--up"},null,-1)])],40,Tl),a.createElementVNode("div",{class:"sb-track sb-track--v",onMousedown:En},[a.createElementVNode("div",{class:"sb-thumb sb-thumb--v",style:a.normalizeStyle({top:pt.value+"px",height:Ye.value+"px"}),onMousedown:mn},null,36)],32),a.createElementVNode("button",{class:"sb-btn sb-btn--down",title:a.unref(B)(i.value,"scrollDown"),onMousedown:t[4]||(t[4]=a.withModifiers(n=>{V(null,x.value+50),v()},["prevent"]))},[...t[9]||(t[9]=[a.createElementVNode("span",{class:"sb-arrow sb-arrow--down"},null,-1)])],40,Dl)],4)):a.createCommentVNode("",!0),He.value>0?(a.openBlock(),a.createElementBlock("div",{key:1,class:"h-scrollbar",style:a.normalizeStyle({left:a.unref(52)+"px",width:`calc(100% - ${a.unref(52)+a.unref(11)}px)`})},[a.createElementVNode("button",{class:"sb-btn sb-btn--left",title:a.unref(B)(i.value,"scrollLeft"),onMousedown:t[5]||(t[5]=a.withModifiers(n=>{V(R.value-50,null),v()},["prevent"]))},[...t[10]||(t[10]=[a.createElementVNode("span",{class:"sb-arrow sb-arrow--left"},null,-1)])],40,Rl),a.createElementVNode("div",{class:"sb-track sb-track--h",onMousedown:gn},[a.createElementVNode("div",{class:"sb-thumb sb-thumb--h",style:a.normalizeStyle({left:ht.value+"px",width:ze.value+"px"}),onMousedown:bn},null,36)],32),a.createElementVNode("button",{class:"sb-btn sb-btn--right",title:a.unref(B)(i.value,"scrollRight"),onMousedown:t[6]||(t[6]=a.withModifiers(n=>{V(R.value+50,null),v()},["prevent"]))},[...t[11]||(t[11]=[a.createElementVNode("span",{class:"sb-arrow sb-arrow--right"},null,-1)])],40,xl)],4)):a.createCommentVNode("",!0),He.value>0&&we.value>0?(a.openBlock(),a.createElementBlock("div",kl)):a.createCommentVNode("",!0)],512),(a.openBlock(),a.createBlock(a.Teleport,{to:"body"},[te.value?(a.openBlock(),a.createElementBlock("div",{key:0,class:"context-menu",style:a.normalizeStyle({left:te.value.x+"px",top:te.value.y+"px"}),onClick:t[7]||(t[7]=a.withModifiers(()=>{},["stop"]))},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(te.value.items,(n,l)=>(a.openBlock(),a.createElementBlock("div",{key:l,class:a.normalizeClass(["context-menu__item",{"context-menu__item--disabled":n.disabled}]),onClick:o=>!n.disabled&&n.action&&(n.action(),te.value=null),onMouseenter:o=>an(o,n)},[a.createElementVNode("span",Sl,a.toDisplayString(n.label),1),n.children?(a.openBlock(),a.createElementBlock("span",Cl)):a.createCommentVNode("",!0),n.children?(a.openBlock(),a.createElementBlock("div",{key:1,class:a.normalizeClass(["context-submenu",{"context-submenu--left":Oe.value}])},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(n.children,(o,r)=>(a.openBlock(),a.createElementBlock("div",{key:r,class:a.normalizeClass(["context-menu__item",{"context-menu__item--disabled":o.disabled}]),onClick:a.withModifiers(h=>!o.disabled&&o.action&&(o.action(),te.value=null),["stop"])},a.toDisplayString(o.label),11,Il))),128))],2)):a.createCommentVNode("",!0)],42,_l))),128))],4)):a.createCommentVNode("",!0)]))],4))}}),[["__scopeId","data-v-5100e6d6"]]);le.Spreader=Ct,le.default=Ct,Object.defineProperties(le,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "xiaodao-spreader",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "A Vue 3 component for spreading sheets",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"vue",
|
|
9
|
+
"canvas",
|
|
10
|
+
"spreader",
|
|
11
|
+
"sheet"
|
|
12
|
+
],
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"main": "./dist/xiaodao-spreader.umd.js",
|
|
17
|
+
"module": "./dist/xiaodao-spreader.es.js",
|
|
18
|
+
"types": "./dist/types/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/types/index.d.ts",
|
|
22
|
+
"import": "./dist/xiaodao-spreader.es.js",
|
|
23
|
+
"require": "./dist/xiaodao-spreader.umd.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"vue": "^3.4.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@vitejs/plugin-vue": "^5.0.0",
|
|
32
|
+
"@types/node": "^20.0.0",
|
|
33
|
+
"typescript": "~5.4.0",
|
|
34
|
+
"vite": "^5.0.0",
|
|
35
|
+
"vue": "^3.4.0",
|
|
36
|
+
"vue-tsc": "^2.2.0"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public",
|
|
40
|
+
"registry": "https://registry.npmjs.org/"
|
|
41
|
+
},
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "git+https://github.com/xiaodaozhi/xiaodao-spreader.git"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"dev": "vite",
|
|
48
|
+
"build": "vue-tsc --noEmit && vite build && vue-tsc -p tsconfig.build.json",
|
|
49
|
+
"preview": "vite preview",
|
|
50
|
+
"type-check": "vue-tsc --noEmit"
|
|
51
|
+
}
|
|
52
|
+
}
|