snowy-designer
Version:
基于Epic-Designer-Pro版本的设计器,可视化开发页面表单
2 lines (1 loc) • 7.57 kB
JavaScript
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("vue");;/* empty css */require("radix-vue");require("clsx");require("tailwind-merge");require("lucide-vue-next");require("../../../ui-kit/base-ui/src/shadch-ui/button/index.cjs");require("@vueuse/core");require("../../../ui-kit/base-ui/src/shadch-ui/toast/index.cjs");require("vuedraggable");const g=require("../../../utils/src/common/data.cjs"),k=require("../../../utils/src/common/string.cjs");require("../../../hooks/src/store/index.cjs");require("lodash");require("../../../utils/src/manager/pluginManager.cjs");require("monaco-editor");require("../../../utils/src/request/index.cjs");function B(s,l){const n=g.getMatchedById(s,l);return n[n.length-3]}function z(s,l){var w,p,d,P;const n=B(l.schemas,s.id??""),m=s.id??"",o=V(m,n);if(!o)return;const r=o.colIndex+(((w=o.cell.componentProps)==null?void 0:w.colspan)??1);for(let a=0;a<(((p=n.children)==null?void 0:p.length)||0);a++){const h=(d=n.children)==null?void 0:d[a];if(!h||!h.children)return;h.children.splice(r,0,{id:`td_${k.getUUID()}`,label:"单元格",type:"td",children:[]})}const i=[];(P=n.children)==null||P.forEach((a,h)=>{var c;if(!a.children)return;const e=((c=a.children[o.colIndex].componentProps)==null?void 0:c.colspan)??1;(e===0||e>1)&&i.push(h)}),i.forEach(a=>{var t,f,u,I,x;let h=0;if(!n.children)return;let e;for(let C=o.colIndex;C>=0;C--){const R=(t=n.children[a].children)==null?void 0:t[C],q=((f=R==null?void 0:R.componentProps)==null?void 0:f.colspan)??1;q>1&&!e&&(e=R),h+=q}const c=((u=e==null?void 0:e.componentProps)==null?void 0:u.rowspan)??1;for(let C=0;C<c;C++){const y=(x=(I=n.children[a+C])==null?void 0:I.children)==null?void 0:x[r];h>r&&y&&(g.setValueByPath(y,"componentProps.colspan",0),g.setValueByPath(y,"status.invalid",!0))}h>r&&e&&e.children&&e.componentProps.colspan++})}function F(s,l){var a,h;const n=B(l.schemas,s.id??""),m=s.id??"",o=V(m,n);if(!o||!n.children)return;const r=o.rowIndex+(((a=o.cell.componentProps)==null?void 0:a.rowspan)??1),i=n.children[o.rowIndex];if(!i.children)return;const w=[],p=g.deepClone({...i,id:`tr_${k.getUUID()}`,children:i.children.map((e,c)=>{var f;const t=((f=e.componentProps)==null?void 0:f.rowspan)??1;return(t===0||t>1)&&w.push(c),{...e,id:`td_${k.getUUID()}`,componentProps:{...e.componentProps,colspan:1,rowspan:1},status:{},children:[]}})}),d=[],P=n.children[r];if(P){let e=0;(h=P.children)==null||h.forEach((c,t)=>{var f,u;((f=c.componentProps)==null?void 0:f.colspan)>1&&(e=t+(c.componentProps.colspan??1)),(u=c.status)!=null&&u.invalid&&e<=t&&d.push(t)})}n.children.splice(r,0,p),w.forEach(e=>{var u,I,x,C;let c=0;if(!n.children)return;let t=null;for(let y=o.rowIndex;y>=0;y--){const R=n.children[y],q=(u=R.children)==null?void 0:u[e],S=((I=q==null?void 0:q.componentProps)==null?void 0:I.rowspan)??1;S>1&&!t&&(t=R),c+=S}const f=(C=(x=n.children[r])==null?void 0:x.children)==null?void 0:C[e];c>r&&f&&(f.componentProps.rowspan=0,f.status={invalid:!0},t&&t.children&&(t.children[e].componentProps.rowspan+=1))}),d.forEach(e=>{var t,f,u;const c=(u=(f=(t=n.children)==null?void 0:t[r])==null?void 0:f.children)==null?void 0:u[e];c&&(c.componentProps.rowspan=0,c.status={invalid:!0})})}function G(s,l){const n=B(l.schemas,s.id??""),m=s.id??"",o=V(m,n);if(!o||!n.children)return;const r=o.rowIndex,i=n.children[r];if(!i.children)return;const w=[];i.children.forEach((p,d)=>{var a;const P=((a=p.componentProps)==null?void 0:a.rowspan)??1;(P===0||P>1)&&w.push(d)}),w.forEach(p=>{var P,a,h,e,c,t,f;if(!n.children)return;let d=null;for(let u=r-1;u>=0;u--){const I=n.children[u],x=(P=I.children)==null?void 0:P[p];if((((a=x==null?void 0:x.componentProps)==null?void 0:a.rowspan)??1)>1&&!d){d=I;break}}if(d)g.setValueByPath(d,`children.${p}.componentProps.rowspan`,((h=d.children)==null?void 0:h[p].componentProps.rowspan)-1);else{const u=(c=(e=n.children[r])==null?void 0:e.children)==null?void 0:c[p],I=(f=(t=n.children[r+1])==null?void 0:t.children)==null?void 0:f[p];I&&u&&(g.setValueByPath(I,"componentProps.rowspan",u.componentProps.rowspan-1),g.setValueByPath(I,"componentProps.colspan",u.componentProps.colspan),g.setValueByPath(I,"status.invalid",!1))}}),n.children.splice(r,1)}function H(s,l){const n=B(l.schemas,s.id??""),m=s.id??"",o=V(m,n);if(!o||!n.children)return;const r=o.colIndex;n.children.forEach(i=>{var d;if(!i.children)return;const p=((d=i.children[r].componentProps)==null?void 0:d.colspan)??1;p>1?(g.setValueByPath(i,`children.${r}.componentProps.colspan`,p-1),i.children.splice(r+1,1)):i.children.splice(r,1),i.children.forEach((P,a)=>{var e;const h=((e=P.componentProps)==null?void 0:e.colspan)??1;h>1&&h+a>r&&g.setValueByPath(i,`children.${a}.componentProps.colspan`,h-1)})})}function J(s,l){var P,a,h,e;const n=B(l.schemas,s.id??""),m=s.id??"",o=V(m,n);if(!o||!n.children)return;const r=o.rowIndex,i=o.colIndex,w=(P=n.children[r].children)==null?void 0:P[i];if(!w)return;const p=((a=w.componentProps)==null?void 0:a.rowspan)??1,d=((h=w.componentProps)==null?void 0:h.colspan)??1;for(let c=0;c<p;c++)for(let t=0;t<d;t++){if(c===0&&t===0)continue;const f=r+c,u=i+t,I=(e=n.children[f].children)==null?void 0:e[u];if(!I)return;g.setValueByPath(I,"componentProps.rowspan",1),g.setValueByPath(I,"componentProps.colspan",1),g.setValueByPath(I,"status.invalid",!1)}w.componentProps.rowspan=1,w.componentProps.colspan=1}function T(s,l,n){var u,I,x,C,y,R,q,S,b,A,D,U,M,_,j;const m=V(s,l);if(!m||!l.children)return;const o=n==="down",r=m.rowIndex,i=m.colIndex,w=(I=(u=l.children[r])==null?void 0:u.children)==null?void 0:I[i];if(!w)return;const p=o?"rowspan":"colspan",d=(o?r:i)+(((x=w.componentProps)==null?void 0:x[p])??1);if(!((y=(C=l.children[o?d:r])==null?void 0:C.children)!=null&&y[o?i:d])){console.error(`最后一个元素,无法向${o?"下":"右"}合并`);return}const P=(q=(R=l.children[o?d:r])==null?void 0:R.children)==null?void 0:q[o?i:d];if(!P)return;const a=((S=w.componentProps)==null?void 0:S[p])??1,h=((b=P.componentProps)==null?void 0:b[p])??1,e=o?"colspan":"rowspan",c=((A=w.componentProps)==null?void 0:A[e])??1;let t=((D=P.componentProps)==null?void 0:D[e])??1;const f=[];if(t===0){console.error(`单元格的 ${e} 不相等,无法合并`);return}if(c>1&&c!==t){let v=null;for(let E=0;E<c;E++){const $=(M=(U=l.children[o?d:r+E])==null?void 0:U.children)==null?void 0:M[o?i+E:d],O=((_=$==null?void 0:$.componentProps)==null?void 0:_[p])??1;if(E===0)v=O;else{if(!$||v!==O){console.error(`下一行单元格的 ${p} 不相等,无法合并`);return}t+=((j=$.componentProps)==null?void 0:j[e])??1,f.push($)}}}if(c!==t){console.error(`单元格的 ${e} 不相等,无法合并`);return}g.setValueByPath(w,`componentProps.${p}`,a+h),g.setValueByPath(P,`componentProps.${p}`,0),g.setValueByPath(P,"status.invalid",!0),f.forEach(v=>{g.setValueByPath(v,`componentProps.${p}`,0),g.setValueByPath(v,"status.invalid",!0)})}function K(s,l){const n=B(l.schemas,s.id??""),m=s.id??"";T(m,n,"down")}function L(s,l){const n=B(l.schemas,s.id??""),m=s.id??"";T(m,n,"right")}function V(s,l){if(!l.children)return null;for(let n=0;n<l.children.length;n++){const m=l.children[n];if(m.children)for(let o=0;o<m.children.length;o++){const r=m.children[o];if(r.id===s)return{cell:r,colIndex:o,rowIndex:n}}}return null}exports.addColumnAfterRightClick=z;exports.addRowAfterRightClick=F;exports.deleteColumnAfterRightClick=H;exports.deleteRowAfterRightClick=G;exports.findCellInfo=V;exports.getTableSchema=B;exports.mergeCells=T;exports.mergeDown=K;exports.mergeRight=L;exports.splitCell=J;