var ce=Object.defineProperty;var X=Object.getOwnPropertySymbols;var re=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable;var Y=(p,m,a)=>m in p?ce(p,m,{enumerable:!0,configurable:!0,writable:!0,value:a}):p[m]=a,N=(p,m)=>{for(var a in m||(m={}))re.call(m,a)&&Y(p,a,m[a]);if(X)for(var a of X(m))ue.call(m,a)&&Y(p,a,m[a]);return p};import{d as me,w as pe,r as de,ah as w,ar as C,as as _,au as M,ag as q,k as f,aF as x,e as S,G as y,F as z,aD as I,A as T,at as fe,aB as ve}from"./vue-vendor-C7Zq48Yl.js";import{d as Ce}from"./index-BI6CMai0.js";import"./antd-vue-vendor-BPnV8VqP.js";import"./vxe-table-vendor-B88kchpX.js";const _e={class:"header-config-editor"},xe={class:"toolbar"},ge={class:"grid-table"},we=["rowspan","colspan","onMousedown","onMousemove","onContextmenu"],Me=me({__name:"TableHeaderConfigEditor",props:{rowCount:{},colCount:{},columnTitles:{},value:{}},emits:["update:value"],setup(p,{emit:m}){const a=p,B=m,o=de({cells:[],selecting:!1,selection:{r1:0,c1:0,r2:0,c2:0},contextMenu:{visible:!1,x:0,y:0}}),h=S(()=>Math.max(1,Number(a.colCount||1))),g=S(()=>Math.max(1,Number(a.rowCount||1)));function V(t){var n;const e=(n=a.columnTitles)==null?void 0:n[t];return String(e||`列${t+1}`)}function U(t,e){const n=[];for(let l=0;lN({},l))}pe(()=>[a.rowCount,a.colCount,a.value],()=>{o.cells=J(g.value,h.value,a.value)},{immediate:!0,deep:!0});function $(){B("update:value",{rowCount:g.value,colCount:h.value,cells:o.cells.map(t=>N({},t))})}function v(t,e){return o.cells.find(n=>n.row===t&&n.col===e)}function k(t,e){return o.cells.find(n=>t>=n.row&&t=n.col&&e=n&&t<=l&&e>=i&&e<=r}function P(t,e){var l;const n=v(t,e);return{selected:E(t,e),focused:(n==null?void 0:n.id)===((l=k(o.selection.r2,o.selection.c2))==null?void 0:l.id)}}function Q(t,e){o.selecting=!0,o.selection={r1:t,c1:e,r2:t,c2:e},R()}function W(t,e){o.selecting&&(o.selection.r2=t,o.selection.c2=e)}function Z(){o.selecting=!1}function ee(t,e,n){const l=v(t,e);l&&(l.title=String(n||""),$())}function F(){return{minR:Math.min(o.selection.r1,o.selection.r2),maxR:Math.max(o.selection.r1,o.selection.r2),minC:Math.min(o.selection.c1,o.selection.c2),maxC:Math.max(o.selection.c1,o.selection.c2)}}function te(){const{minR:t,maxR:e,minC:n,maxC:l}=F(),i=o.cells.filter(s=>s.row>=t&&s.row<=e&&s.col>=n&&s.col<=l),r=(e-t+1)*(l-n+1);return i.length===r&&i.every(s=>s.rowspan===1&&s.colspan===1)}function D(){if(!te())return;const{minR:t,maxR:e,minC:n,maxC:l}=F(),i=Array.from({length:l-n+1}).map((s,d)=>{const c=n+d,u=k(g.value-1,c);return String((u==null?void 0:u.title)||V(c))}),r=v(t,n);r&&(r.rowspan=e-t+1,r.colspan=l-n+1,e===g.value-1&&(r.title=n===l?i[0]:i.join(" / ")),o.cells=o.cells.filter(s=>s===r||s.rowe||s.coll),$())}function H(){const t=k(o.selection.r2,o.selection.c2);if(!t||t.rowspan===1&&t.colspan===1)return;const{row:e,col:n,rowspan:l,colspan:i,title:r}=t;o.cells=o.cells.filter(s=>s.id!==t.id);for(let s=e;sN({},n))})}function oe(t,e,n){E(e,n)||(o.selection={r1:e,c1:n,r2:e,c2:n}),o.contextMenu={visible:!0,x:t.clientX,y:t.clientY}}function R(){o.contextMenu.visible=!1}function le(){D(),R()}function se(){H(),R()}const A=S(()=>o.contextMenu),j=S(()=>k(o.selection.r2,o.selection.c2)),ae=S(()=>{var t;return String(((t=j.value)==null?void 0:t.align)||"center")});function ie(t){const e=j.value;e&&(e.align=String(t||"center"),$())}return(t,e)=>{const n=w("a-input-number"),l=w("a-select-option"),i=w("a-select"),r=w("a-button"),s=w("a-space"),d=w("a-input");return _(),C("div",_e,[M("div",xe,[f(s,null,{default:x(()=>[f(n,{value:g.value,min:1,max:6,"addon-before":"表头行数","onUpdate:value":e[0]||(e[0]=c=>ne(Number(c||1)))},null,8,["value"]),f(i,{value:ae.value,style:{width:"120px"},"onUpdate:value":e[1]||(e[1]=c=>ie(c))},{default:x(()=>[f(l,{value:"left"},{default:x(()=>[...e[2]||(e[2]=[y("左对齐",-1)])]),_:1}),f(l,{value:"center"},{default:x(()=>[...e[3]||(e[3]=[y("居中",-1)])]),_:1}),f(l,{value:"right"},{default:x(()=>[...e[4]||(e[4]=[y("右对齐",-1)])]),_:1})]),_:1},8,["value"]),f(r,{size:"small",onClick:D},{default:x(()=>[...e[5]||(e[5]=[y("合并选中",-1)])]),_:1}),f(r,{size:"small",onClick:H},{default:x(()=>[...e[6]||(e[6]=[y("拆分当前",-1)])]),_:1})]),_:1})]),M("div",{class:"grid-wrap",onClick:R},[M("table",ge,[M("tbody",null,[(_(!0),C(z,null,I(g.value,c=>(_(),C("tr",{key:`row_${c-1}`},[(_(!0),C(z,null,I(h.value,u=>{var G,L,O;return _(),C(z,{key:`slot_${c-1}_${u-1}`},[K(c-1,u-1)?(_(),C("td",{key:0,rowspan:((G=v(c-1,u-1))==null?void 0:G.rowspan)||1,colspan:((L=v(c-1,u-1))==null?void 0:L.colspan)||1,class:fe(P(c-1,u-1)),onMousedown:T(b=>Q(c-1,u-1),["prevent"]),onMousemove:T(b=>W(c-1,u-1),["prevent"]),onMouseup:T(Z,["prevent"]),onContextmenu:T(b=>oe(b,c-1,u-1),["prevent"])},[f(d,{size:"small",value:((O=v(c-1,u-1))==null?void 0:O.title)||"","onUpdate:value":b=>ee(c-1,u-1,b)},null,8,["value","onUpdate:value"])],42,we)):q("",!0)],64)}),128))]))),128))])])]),A.value.visible?(_(),C("div",{key:0,class:"context-menu",style:ve({left:`${A.value.x}px`,top:`${A.value.y}px`})},[M("div",{class:"menu-item",onClick:le},"合并"),M("div",{class:"menu-item",onClick:se},"拆分")],4)):q("",!0)])}}}),ke=Ce(Me,[["__scopeId","data-v-d18c037e"]]);export{ke as default};