@tachybase/plugin-block-gantt 1.3.16 → 1.3.18

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.
@@ -234,11 +234,11 @@
234
234
  pointerEvents: none,
235
235
  },
236
236
  }
237
- }`})),Zr=e=>{const{styles:t}=Jr(),{task:r,arrowIndent:o,isDelete:n,taskHeight:a,isSelected:i,rtl:s,onEventStart:l}=O({},e),u=f.useRef(null),[p,x]=f.useState(c.jsx("div",{})),[F,S]=f.useState(!0),y=r.typeInternal==="project";f.useEffect(()=>{switch(r.typeInternal){case"milestone":x(c.jsx(Wr,O({},e)));break;case"project":x(c.jsx(Kr,O({},e)));break;case"smalltask":x(c.jsx(jr,O({},e)));break;default:x(c.jsx(Yr,O({},e)));break}},[r,i]),f.useEffect(()=>{u.current&&S(u.current.getBBox().width<r.x2-r.x1)},[u,r]);const B=()=>{const g=r.x2-r.x1,v=r.barChildren.length>0;return F?r.x1+g*.5:s&&u.current?r.x1-u.current.getBBox().width-o*+v-o*.2:r.x1+g+o*+v+o*.2};return c.jsxs("g",{className:d.cx(t.nbganttTaskitem),onKeyDown:g=>{switch(g.key){case"Delete":{n&&l("delete",r,g);break}}g.stopPropagation()},onMouseEnter:g=>{l("mouseenter",r,g)},onMouseLeave:g=>{l("mouseleave",r,g)},onDoubleClick:g=>{l("dblclick",r,g)},onClick:g=>{l("click",r,g)},onFocus:()=>{l("select",r)},children:[p,c.jsx("text",{x:y?r.x1:B(),y:y?r.y-8:F?r.y+a*.5:r.y+a*.65,className:y?d.cx("projectLabel"):F?d.cx("barLabel"):d.cx("barLabelOutside"),ref:u,children:y&&Se(r.start)&&Se(r.end)?`${r.name}: ${Se(r.start)} ~ ${Se(r.end)}`:r.name})]})};let rt=null,Fe=null;const Rr=({tasks:e,dates:t,ganttEvent:r,selectedTask:o,rowHeight:n,columnWidth:a,timeStep:i,svg:s,taskHeight:l,arrowColor:u,arrowIndent:p,fontFamily:x,fontSize:F,rtl:S,setGanttEvent:y,setFailedTask:B,setSelectedTask:g,onDateChange:v,onProgressChange:C,onDoubleClick:T,onClick:M,onDelete:b})=>{var R;const h=(R=s==null?void 0:s.current)==null?void 0:R.createSVGPoint(),[m,N]=f.useState(0),[V,W]=f.useState(0),[ne,fe]=f.useState(!1);f.useEffect(()=>{var G,j,X,q;const P=((G=t[1])==null?void 0:G.getTime())-((j=t[0])==null?void 0:j.getTime())-((X=t[1])==null?void 0:X.getTimezoneOffset())*60*1e3+((q=t[0])==null?void 0:q.getTimezoneOffset())*60*1e3,H=i*a/P;N(H)},[a,t,i]),f.useEffect(()=>{const P=G=>re(this,null,function*(){var he;if(!r.changedTask||!h||!(s!=null&&s.current))return;G.preventDefault(),h.x=G.clientX;const j=h.matrixTransform((he=s==null?void 0:s.current.getScreenCTM())==null?void 0:he.inverse()),{isChanged:X,changedTask:q}=gt(j.x,r.action,r.changedTask,m,i,V,S);X&&y({action:r.action,changedTask:q})}),H=G=>re(this,null,function*(){var $e;const{action:j,originalSelectedTask:X,changedTask:q}=r;if(!q||!h||!(s!=null&&s.current)||!X)return;G.preventDefault(),h.x=G.clientX;const he=h.matrixTransform(($e=s==null?void 0:s.current.getScreenCTM())==null?void 0:$e.inverse()),{changedTask:Q}=gt(he.x,j,q,m,i,V,S),Te=X.start!==Q.start||X.end!==Q.end||X.progress!==Q.progress;s.current.removeEventListener("mousemove",P),s.current.removeEventListener("mouseup",H),y({action:""}),fe(!1);let ye=!0;if((j==="move"||j==="end"||j==="start")&&v&&Te)try{const ae=yield v(Q,Q.barChildren);ae!==void 0&&(ye=ae)}catch(ae){ye=!1}else if(C&&Te)try{const ae=yield C(Q,Q.barChildren);ae!==void 0&&(ye=ae)}catch(ae){ye=!1}ye||B(X)});!ne&&(r.action==="move"||r.action==="end"||r.action==="start"||r.action==="progress")&&(s!=null&&s.current)&&(s.current.addEventListener("mousemove",P),s.current.addEventListener("mouseup",H),fe(!0))},[r,m,V,C,i,v,s,ne,h,S,B,y]);const Ce=(P,H,G)=>re(this,null,function*(){var j;if(!G)P==="select"&&g(H.id);else if(hr(G)){if(P==="delete"&&b)try{const X=yield b(H);X!==void 0&&X&&y({action:P,changedTask:H})}catch(X){console.error("Error on Delete. "+X)}}else if(P==="mouseenter")r.action||y({action:P,changedTask:H,originalSelectedTask:H});else if(P==="mouseleave")r.action==="mouseenter"&&setTimeout(()=>{y({action:""})},300);else if(P==="dblclick")T&&T(H);else if(P==="click")M&&M(H);else if(P==="move"){if(!(s!=null&&s.current)||!h)return;h.x=G.clientX;const X=h.matrixTransform((j=s.current.getScreenCTM())==null?void 0:j.inverse());W(X.x-H.x1),y({action:P,changedTask:H,originalSelectedTask:H})}else y({action:P,changedTask:H,originalSelectedTask:H})}),ot=(P,H,G)=>{["click"].includes(P)?(!["start","end","progress"].includes(rt)&&(!Fe||Fe===H.start)&&Ce(P,H,G),rt=null,Fe=null):["move","select"].includes(P)?(Fe=H.start,Ce(P,H,G)):(Fe=H.start,rt=P,Ce(P,H,G))};return c.jsxs("g",{className:"content",children:[c.jsx("g",{className:"arrows",fill:u,stroke:u,children:e.map(P=>P.barChildren.map(H=>c.jsx(Or,{taskFrom:P,taskTo:e[H.index],rowHeight:n,taskHeight:l,arrowIndent:p,rtl:S},`Arrow from ${P.id} to ${e[H.index].id}`)))}),c.jsx("g",{className:"bar",fontFamily:x,fontSize:F,children:e.map(P=>c.jsx(Zr,{task:P,arrowIndent:p,taskHeight:l,isProgressChangeable:!!C&&!P.isDisabled,isDateChangeable:!!v&&!P.isDisabled,isDelete:!P.isDisabled,onEventStart:ot,isSelected:!!o&&P.id===o.id,rtl:S},P.id))})]})},At=f.forwardRef(({gridProps:e,calendarProps:t,barProps:r,ganttHeight:o,scrollY:n,scrollX:a},i)=>{const s=f.useRef(null),l=f.useRef(null),u=ce(O({},r),{svg:s}),{styles:p}=St();return f.useEffect(()=>{l.current&&(l.current.scrollTop=n)},[n]),f.useEffect(()=>{i.current&&(i.current.scrollLeft=a)},[a]),c.jsxs("div",{className:p.ganttverticalcontainer,ref:i,dir:"ltr",children:[c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e.svgWidth,height:t.headerHeight,fontFamily:r.fontFamily,className:"ganttHeader",children:c.jsx(Lr,O({},t))}),c.jsx("div",{ref:l,className:p.horizontalcontainer,style:o?{maxHeight:o,width:e.svgWidth}:{width:e.svgWidth},children:c.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:e.svgWidth,height:r.rowHeight*(r.tasks.length||3),fontFamily:r.fontFamily,ref:s,className:"ganttBody",children:[c.jsx(kr,O({},e)),c.jsx(Rr,O({},u))]})})]})});At.displayName="TaskGantt";const eo=(e,t)=>t/e>50?Math.floor(t/e)+20:50,to=f.createContext({close:()=>{}}),ro=e=>{const{visible:t,setVisible:r,record:o}=e,n=d.useCollectionParentRecordData(),i=I.useFieldSchema().properties.detail,s=f.useCallback(()=>{r(!1)},[]);return i&&c.jsx(to.Provider,{value:{close:s},children:c.jsx(d.ActionContextProvider,{value:{visible:t,setVisible:r},children:c.jsx(d.RecordProvider,{record:o,parent:n,children:c.jsx(I.RecursionField,{schema:i,name:i.name})})})})},oo=ke.debounce((e,t,r,o,n)=>re(this,null,function*(){yield t.update({filterByTk:e.id,values:{[r.start]:e.start,[r.end]:e.end}}),Ie.message.success(n("Saved successfully")),yield o==null?void 0:o.refresh()}),300),no=ke.debounce((e,t,r,o,n)=>re(this,null,function*(){yield t.update({filterByTk:e.id,values:{[r.progress]:e.progress/100}}),Ie.message.success(n("Saved successfully")),yield o==null?void 0:o.refresh()}),300),we=d.withDynamicSchemaProps(e=>{var qt,Ut,Wt;const{styles:t}=St(),{token:r}=d.useToken(),a=d.useAPIClient().auth.getOption("theme")==="compact"?45:55.56,{headerHeight:i=((qt=document.querySelector(".ant-table-thead"))==null?void 0:qt.clientHeight)||0,listCellWidth:s="155px",rowHeight:l=a,ganttHeight:u=0,preStepsCount:p=1,barFill:x=60,barCornerRadius:F=r.borderRadiusXS,barProgressColor:S=r.colorPrimary,barProgressSelectedColor:y=r.colorPrimary,barBackgroundColor:B=r.colorPrimary,barBackgroundSelectedColor:g=r.colorPrimary,projectProgressColor:v=r.colorPrimary,projectProgressSelectedColor:C=r.colorPrimary,projectBackgroundColor:T=r.colorPrimary,projectBackgroundSelectedColor:M=r.colorPrimary,milestoneBackgroundColor:b="#f1c453",milestoneBackgroundSelectedColor:h="#f29e4c",rtl:m=!1,handleWidth:N=8,timeStep:V=3e5,arrowColor:W="grey",fontFamily:ne="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'",fontSize:fe=r.fontSize,arrowIndent:Ce=20,todayColor:ot="rgba(252, 248, 227, 0.5)",viewDate:R,TooltipContent:P=xr,onDoubleClick:H,onDelete:G,onSelect:j,onExpanderClick:X,tasks:q,expandAndCollapseAll:he,fieldNames:Q}=d.useProps(e),Te=de(),ye=d.useCurrentAppInfo(),{t:$e}=ge.useTranslation(),ae=(Ut=ye.data)==null?void 0:Ut.lang,nt=d.useTableBlockContext(),{resource:Lt,service:Ve}=d.useBlockRequestContext(),Ht=I.useFieldSchema(),ee=Q.range||"day",ve=f.useRef(null),at=f.useRef(null),Et=f.useRef(null),[se,uo]=f.useState(()=>{const[w,$]=mt(q,ee,p);return{viewMode:ee,dates:xt(w,$,ee)}}),[fo,It]=f.useState(!1),[ho,po]=f.useState({}),[Le,kt]=f.useState(void 0),[qe,Ot]=f.useState(0),[go,bo]=f.useState(0),[mo,Xt]=f.useState(u),[te,Ue]=f.useState([]),[He,Gt]=f.useState({action:""}),st=f.useMemo(()=>l*x/100,[l,x]),[it,xo]=f.useState(),[We,zt]=f.useState(null),[pe,lt]=f.useState(0),[ie,Ee]=f.useState(-1),[Yt,Me]=f.useState(!1),Z=eo(se.dates.length,(Wt=Et.current)==null?void 0:Wt.clientWidth),le=se.dates.length*Z,De=te.length*l,{expandFlag:jt}=nt,[yo,vo]=f.useState([]);f.useEffect(()=>{nt.field.onExpandClick=Mo,nt.field.onRowSelect=Do},[]),f.useEffect(()=>{he==null||he(!jt)},[jt]),f.useEffect(()=>{let w;X?w=pr(q):w=q,w=w.sort(gr);const[$,D]=mt(w,ee,p);let A=xt($,D,ee);m&&(A=A.reverse(),ie===-1&&Ee(A.length*Z)),uo({dates:A,viewMode:ee}),Ue(tr(w,A,Z,l,st,F,N,m,S,y,B,g,v,C,T,M,b,h))},[q,ee,p,l,F,Z,st,N,S,y,B,g,v,C,T,M,b,h,m,ie]),f.useEffect(()=>{if(ee===se.viewMode&&(R&&!Le||R&&(Le==null?void 0:Le.valueOf())!==R.valueOf())){const w=se.dates,$=w.findIndex((D,A)=>R.valueOf()>=D.valueOf()&&A+1!==w.length&&R.valueOf()<w[A+1].valueOf());if($===-1)return;kt(R),Ee(Z*$)}},[R,Z,se.dates,se.viewMode,ee,Le,kt]),f.useEffect(()=>{const{changedTask:w,action:$}=He;if(w){if($==="delete")Gt({action:""}),Ue(te.filter(D=>D.id!==w.id));else if($==="move"||$==="end"||$==="start"||$==="progress"){const D=te.find(A=>A.id===w.id);if(D&&D.start&&D.end&&(D.start.getTime()!==w.start.getTime()||D.end.getTime()!==w.end.getTime()||D.progress!==w.progress)){const A=te.map(_=>_.id===w.id?w:_);Ue(A)}}}},[He,te]),f.useEffect(()=>{We&&(Ue(te.map(w=>w.id!==We.id?w:We)),zt(null))},[We,te]),f.useEffect(()=>{s||Ot(0),at.current&&Ot(at.current.offsetWidth)},[at,s]),f.useEffect(()=>{ve.current&&bo(ve.current.offsetWidth-qe)},[ve,qe]),f.useEffect(()=>{Xt(u?u+i:q.length*l+i)},[u,q,i,l]),f.useEffect(()=>{var $;const w=D=>{if(D.shiftKey||D.deltaX){const A=D.deltaX?D.deltaX:D.deltaY;let _=ie+A;_<0?_=0:_>le&&(_=le),Ee(_),D.preventDefault()}else if(u){let A=pe+D.deltaY;A<0?A=0:A>De-u&&(A=De-u),A!==pe&&(lt(A),D.preventDefault())}Me(!0)};return($=ve.current)==null||$.addEventListener("wheel",w,{passive:!1}),()=>{var D;(D=ve.current)==null||D.removeEventListener("wheel",w)}},[ve,pe,ie,u,le,m,De]);const So=w=>{pe!==w.currentTarget.scrollTop&&!Yt?(lt(w.currentTarget.scrollTop),Me(!0)):Me(!1)},wo=w=>{ie!==w.currentTarget.scrollLeft&&!Yt?(Ee(w.currentTarget.scrollLeft),Me(!0)):Me(!1)},Co=w=>{w.preventDefault();let $=pe,D=ie,A=!0;switch(w.key){case"Down":case"ArrowDown":$+=l,A=!1;break;case"Up":case"ArrowUp":$-=l,A=!1;break;case"Left":case"ArrowLeft":D-=Z;break;case"Right":case"ArrowRight":D+=Z;break}A?(D<0?D=0:D>le&&(D=le),Ee(D)):($<0?$=0:$>De-u&&($=De-u),lt($)),Me(!0)},To=w=>{const $=te.find(A=>A.id===w),D=te.find(A=>!!it&&A.id===it.id);j&&(D&&j(D,!1),$&&j($,!0)),xo($)},Mo=(w,$)=>{var A;const D=(A=Te==null?void 0:Te.field)==null?void 0:A.data.find(_=>_.id===$.id+"");X&&$.children.length&&X(ce(O({},D),{hideChildren:!w}))},Do=w=>{vo(w)},Bo=w=>re(this,null,function*(){no(w,Lt,Q,Ve,$e)}),No=w=>re(this,null,function*(){oo(w,Lt,Q,Ve,$e)}),Po=w=>{var _;const $=ct=>ct.reduce((_t,_e)=>_e.children?_t.concat([_e,...$(_e.children)]):_t.concat(_e),[]),D=$((_=Ve==null?void 0:Ve.data)==null?void 0:_.data),A=D==null?void 0:D.find(ct=>ct.id===+w.id);A&&(po(A),It(!0))},Fo={columnWidth:Z,svgWidth:le,tasks:q,rowHeight:l,dates:se.dates,todayColor:ot,rtl:m,selectedRowKeys:yo},Ao={dateSetup:se,locale:ae,viewMode:ee,headerHeight:i,columnWidth:Z,fontFamily:ne,fontSize:fe,rtl:m},$o={tasks:te,dates:se.dates,ganttEvent:He,selectedTask:it,rowHeight:l,taskHeight:st,columnWidth:Z,arrowColor:W,timeStep:V,fontFamily:ne,fontSize:fe,arrowIndent:Ce,svgWidth:le,rtl:m,setGanttEvent:Gt,setFailedTask:zt,setSelectedTask:To,onDateChange:No,onProgressChange:Q.progress&&Bo,onDoubleClick:H,onClick:Po,onDelete:G};return c.jsxs("div",{className:d.cx(d.css`
237
+ }`})),Zr=e=>{const{styles:t}=Jr(),{task:r,arrowIndent:o,isDelete:n,taskHeight:a,isSelected:i,rtl:s,onEventStart:l}=O({},e),u=f.useRef(null),[p,x]=f.useState(c.jsx("div",{})),[F,S]=f.useState(!0),y=r.typeInternal==="project";f.useEffect(()=>{switch(r.typeInternal){case"milestone":x(c.jsx(Wr,O({},e)));break;case"project":x(c.jsx(Kr,O({},e)));break;case"smalltask":x(c.jsx(jr,O({},e)));break;default:x(c.jsx(Yr,O({},e)));break}},[r,i]),f.useEffect(()=>{u.current&&S(u.current.getBBox().width<r.x2-r.x1)},[u,r]);const B=()=>{const g=r.x2-r.x1,v=r.barChildren.length>0;return F?r.x1+g*.5:s&&u.current?r.x1-u.current.getBBox().width-o*+v-o*.2:r.x1+g+o*+v+o*.2};return c.jsxs("g",{className:d.cx(t.nbganttTaskitem),onKeyDown:g=>{switch(g.key){case"Delete":{n&&l("delete",r,g);break}}g.stopPropagation()},onMouseEnter:g=>{l("mouseenter",r,g)},onMouseLeave:g=>{l("mouseleave",r,g)},onDoubleClick:g=>{l("dblclick",r,g)},onClick:g=>{l("click",r,g)},onFocus:()=>{l("select",r)},children:[p,c.jsx("text",{x:y?r.x1:B(),y:y?r.y-8:F?r.y+a*.5:r.y+a*.65,className:y?d.cx("projectLabel"):F?d.cx("barLabel"):d.cx("barLabelOutside"),ref:u,children:y&&Se(r.start)&&Se(r.end)?`${r.name}: ${Se(r.start)} ~ ${Se(r.end)}`:r.name})]})};let rt=null,Fe=null;const Rr=({tasks:e,dates:t,ganttEvent:r,selectedTask:o,rowHeight:n,columnWidth:a,timeStep:i,svg:s,taskHeight:l,arrowColor:u,arrowIndent:p,fontFamily:x,fontSize:F,rtl:S,setGanttEvent:y,setFailedTask:B,setSelectedTask:g,onDateChange:v,onProgressChange:C,onDoubleClick:T,onClick:M,onDelete:b})=>{var R;const h=(R=s==null?void 0:s.current)==null?void 0:R.createSVGPoint(),[m,N]=f.useState(0),[V,W]=f.useState(0),[ne,fe]=f.useState(!1);f.useEffect(()=>{var G,j,X,q;const P=((G=t[1])==null?void 0:G.getTime())-((j=t[0])==null?void 0:j.getTime())-((X=t[1])==null?void 0:X.getTimezoneOffset())*60*1e3+((q=t[0])==null?void 0:q.getTimezoneOffset())*60*1e3,H=i*a/P;N(H)},[a,t,i]),f.useEffect(()=>{const P=G=>re(null,null,function*(){var he;if(!r.changedTask||!h||!(s!=null&&s.current))return;G.preventDefault(),h.x=G.clientX;const j=h.matrixTransform((he=s==null?void 0:s.current.getScreenCTM())==null?void 0:he.inverse()),{isChanged:X,changedTask:q}=gt(j.x,r.action,r.changedTask,m,i,V,S);X&&y({action:r.action,changedTask:q})}),H=G=>re(null,null,function*(){var $e;const{action:j,originalSelectedTask:X,changedTask:q}=r;if(!q||!h||!(s!=null&&s.current)||!X)return;G.preventDefault(),h.x=G.clientX;const he=h.matrixTransform(($e=s==null?void 0:s.current.getScreenCTM())==null?void 0:$e.inverse()),{changedTask:Q}=gt(he.x,j,q,m,i,V,S),Te=X.start!==Q.start||X.end!==Q.end||X.progress!==Q.progress;s.current.removeEventListener("mousemove",P),s.current.removeEventListener("mouseup",H),y({action:""}),fe(!1);let ye=!0;if((j==="move"||j==="end"||j==="start")&&v&&Te)try{const ae=yield v(Q,Q.barChildren);ae!==void 0&&(ye=ae)}catch(ae){ye=!1}else if(C&&Te)try{const ae=yield C(Q,Q.barChildren);ae!==void 0&&(ye=ae)}catch(ae){ye=!1}ye||B(X)});!ne&&(r.action==="move"||r.action==="end"||r.action==="start"||r.action==="progress")&&(s!=null&&s.current)&&(s.current.addEventListener("mousemove",P),s.current.addEventListener("mouseup",H),fe(!0))},[r,m,V,C,i,v,s,ne,h,S,B,y]);const Ce=(P,H,G)=>re(null,null,function*(){var j;if(!G)P==="select"&&g(H.id);else if(hr(G)){if(P==="delete"&&b)try{const X=yield b(H);X!==void 0&&X&&y({action:P,changedTask:H})}catch(X){console.error("Error on Delete. "+X)}}else if(P==="mouseenter")r.action||y({action:P,changedTask:H,originalSelectedTask:H});else if(P==="mouseleave")r.action==="mouseenter"&&setTimeout(()=>{y({action:""})},300);else if(P==="dblclick")T&&T(H);else if(P==="click")M&&M(H);else if(P==="move"){if(!(s!=null&&s.current)||!h)return;h.x=G.clientX;const X=h.matrixTransform((j=s.current.getScreenCTM())==null?void 0:j.inverse());W(X.x-H.x1),y({action:P,changedTask:H,originalSelectedTask:H})}else y({action:P,changedTask:H,originalSelectedTask:H})}),ot=(P,H,G)=>{["click"].includes(P)?(!["start","end","progress"].includes(rt)&&(!Fe||Fe===H.start)&&Ce(P,H,G),rt=null,Fe=null):["move","select"].includes(P)?(Fe=H.start,Ce(P,H,G)):(Fe=H.start,rt=P,Ce(P,H,G))};return c.jsxs("g",{className:"content",children:[c.jsx("g",{className:"arrows",fill:u,stroke:u,children:e.map(P=>P.barChildren.map(H=>c.jsx(Or,{taskFrom:P,taskTo:e[H.index],rowHeight:n,taskHeight:l,arrowIndent:p,rtl:S},`Arrow from ${P.id} to ${e[H.index].id}`)))}),c.jsx("g",{className:"bar",fontFamily:x,fontSize:F,children:e.map(P=>c.jsx(Zr,{task:P,arrowIndent:p,taskHeight:l,isProgressChangeable:!!C&&!P.isDisabled,isDateChangeable:!!v&&!P.isDisabled,isDelete:!P.isDisabled,onEventStart:ot,isSelected:!!o&&P.id===o.id,rtl:S},P.id))})]})},At=f.forwardRef(({gridProps:e,calendarProps:t,barProps:r,ganttHeight:o,scrollY:n,scrollX:a},i)=>{const s=f.useRef(null),l=f.useRef(null),u=ce(O({},r),{svg:s}),{styles:p}=St();return f.useEffect(()=>{l.current&&(l.current.scrollTop=n)},[n]),f.useEffect(()=>{i.current&&(i.current.scrollLeft=a)},[a]),c.jsxs("div",{className:p.ganttverticalcontainer,ref:i,dir:"ltr",children:[c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e.svgWidth,height:t.headerHeight,fontFamily:r.fontFamily,className:"ganttHeader",children:c.jsx(Lr,O({},t))}),c.jsx("div",{ref:l,className:p.horizontalcontainer,style:o?{maxHeight:o,width:e.svgWidth}:{width:e.svgWidth},children:c.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:e.svgWidth,height:r.rowHeight*(r.tasks.length||3),fontFamily:r.fontFamily,ref:s,className:"ganttBody",children:[c.jsx(kr,O({},e)),c.jsx(Rr,O({},u))]})})]})});At.displayName="TaskGantt";const eo=(e,t)=>t/e>50?Math.floor(t/e)+20:50,to=f.createContext({close:()=>{}}),ro=e=>{const{visible:t,setVisible:r,record:o}=e,n=d.useCollectionParentRecordData(),i=I.useFieldSchema().properties.detail,s=f.useCallback(()=>{r(!1)},[]);return i&&c.jsx(to.Provider,{value:{close:s},children:c.jsx(d.ActionContextProvider,{value:{visible:t,setVisible:r},children:c.jsx(d.RecordProvider,{record:o,parent:n,children:c.jsx(I.RecursionField,{schema:i,name:i.name})})})})},oo=ke.debounce((e,t,r,o,n)=>re(null,null,function*(){yield t.update({filterByTk:e.id,values:{[r.start]:e.start,[r.end]:e.end}}),Ie.message.success(n("Saved successfully")),yield o==null?void 0:o.refresh()}),300),no=ke.debounce((e,t,r,o,n)=>re(null,null,function*(){yield t.update({filterByTk:e.id,values:{[r.progress]:e.progress/100}}),Ie.message.success(n("Saved successfully")),yield o==null?void 0:o.refresh()}),300),we=d.withDynamicSchemaProps(e=>{var qt,Ut,Wt;const{styles:t}=St(),{token:r}=d.useToken(),a=d.useAPIClient().auth.getOption("theme")==="compact"?45:55.56,{headerHeight:i=((qt=document.querySelector(".ant-table-thead"))==null?void 0:qt.clientHeight)||0,listCellWidth:s="155px",rowHeight:l=a,ganttHeight:u=0,preStepsCount:p=1,barFill:x=60,barCornerRadius:F=r.borderRadiusXS,barProgressColor:S=r.colorPrimary,barProgressSelectedColor:y=r.colorPrimary,barBackgroundColor:B=r.colorPrimary,barBackgroundSelectedColor:g=r.colorPrimary,projectProgressColor:v=r.colorPrimary,projectProgressSelectedColor:C=r.colorPrimary,projectBackgroundColor:T=r.colorPrimary,projectBackgroundSelectedColor:M=r.colorPrimary,milestoneBackgroundColor:b="#f1c453",milestoneBackgroundSelectedColor:h="#f29e4c",rtl:m=!1,handleWidth:N=8,timeStep:V=3e5,arrowColor:W="grey",fontFamily:ne="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'",fontSize:fe=r.fontSize,arrowIndent:Ce=20,todayColor:ot="rgba(252, 248, 227, 0.5)",viewDate:R,TooltipContent:P=xr,onDoubleClick:H,onDelete:G,onSelect:j,onExpanderClick:X,tasks:q,expandAndCollapseAll:he,fieldNames:Q}=d.useProps(e),Te=de(),ye=d.useCurrentAppInfo(),{t:$e}=ge.useTranslation(),ae=(Ut=ye.data)==null?void 0:Ut.lang,nt=d.useTableBlockContext(),{resource:Lt,service:Ve}=d.useBlockRequestContext(),Ht=I.useFieldSchema(),ee=Q.range||"day",ve=f.useRef(null),at=f.useRef(null),Et=f.useRef(null),[se,uo]=f.useState(()=>{const[w,$]=mt(q,ee,p);return{viewMode:ee,dates:xt(w,$,ee)}}),[fo,It]=f.useState(!1),[ho,po]=f.useState({}),[Le,kt]=f.useState(void 0),[qe,Ot]=f.useState(0),[go,bo]=f.useState(0),[mo,Xt]=f.useState(u),[te,Ue]=f.useState([]),[He,Gt]=f.useState({action:""}),st=f.useMemo(()=>l*x/100,[l,x]),[it,xo]=f.useState(),[We,zt]=f.useState(null),[pe,lt]=f.useState(0),[ie,Ee]=f.useState(-1),[Yt,Me]=f.useState(!1),Z=eo(se.dates.length,(Wt=Et.current)==null?void 0:Wt.clientWidth),le=se.dates.length*Z,De=te.length*l,{expandFlag:jt}=nt,[yo,vo]=f.useState([]);f.useEffect(()=>{nt.field.onExpandClick=Mo,nt.field.onRowSelect=Do},[]),f.useEffect(()=>{he==null||he(!jt)},[jt]),f.useEffect(()=>{let w;X?w=pr(q):w=q,w=w.sort(gr);const[$,D]=mt(w,ee,p);let A=xt($,D,ee);m&&(A=A.reverse(),ie===-1&&Ee(A.length*Z)),uo({dates:A,viewMode:ee}),Ue(tr(w,A,Z,l,st,F,N,m,S,y,B,g,v,C,T,M,b,h))},[q,ee,p,l,F,Z,st,N,S,y,B,g,v,C,T,M,b,h,m,ie]),f.useEffect(()=>{if(ee===se.viewMode&&(R&&!Le||R&&(Le==null?void 0:Le.valueOf())!==R.valueOf())){const w=se.dates,$=w.findIndex((D,A)=>R.valueOf()>=D.valueOf()&&A+1!==w.length&&R.valueOf()<w[A+1].valueOf());if($===-1)return;kt(R),Ee(Z*$)}},[R,Z,se.dates,se.viewMode,ee,Le,kt]),f.useEffect(()=>{const{changedTask:w,action:$}=He;if(w){if($==="delete")Gt({action:""}),Ue(te.filter(D=>D.id!==w.id));else if($==="move"||$==="end"||$==="start"||$==="progress"){const D=te.find(A=>A.id===w.id);if(D&&D.start&&D.end&&(D.start.getTime()!==w.start.getTime()||D.end.getTime()!==w.end.getTime()||D.progress!==w.progress)){const A=te.map(_=>_.id===w.id?w:_);Ue(A)}}}},[He,te]),f.useEffect(()=>{We&&(Ue(te.map(w=>w.id!==We.id?w:We)),zt(null))},[We,te]),f.useEffect(()=>{s||Ot(0),at.current&&Ot(at.current.offsetWidth)},[at,s]),f.useEffect(()=>{ve.current&&bo(ve.current.offsetWidth-qe)},[ve,qe]),f.useEffect(()=>{Xt(u?u+i:q.length*l+i)},[u,q,i,l]),f.useEffect(()=>{var $;const w=D=>{if(D.shiftKey||D.deltaX){const A=D.deltaX?D.deltaX:D.deltaY;let _=ie+A;_<0?_=0:_>le&&(_=le),Ee(_),D.preventDefault()}else if(u){let A=pe+D.deltaY;A<0?A=0:A>De-u&&(A=De-u),A!==pe&&(lt(A),D.preventDefault())}Me(!0)};return($=ve.current)==null||$.addEventListener("wheel",w,{passive:!1}),()=>{var D;(D=ve.current)==null||D.removeEventListener("wheel",w)}},[ve,pe,ie,u,le,m,De]);const So=w=>{pe!==w.currentTarget.scrollTop&&!Yt?(lt(w.currentTarget.scrollTop),Me(!0)):Me(!1)},wo=w=>{ie!==w.currentTarget.scrollLeft&&!Yt?(Ee(w.currentTarget.scrollLeft),Me(!0)):Me(!1)},Co=w=>{w.preventDefault();let $=pe,D=ie,A=!0;switch(w.key){case"Down":case"ArrowDown":$+=l,A=!1;break;case"Up":case"ArrowUp":$-=l,A=!1;break;case"Left":case"ArrowLeft":D-=Z;break;case"Right":case"ArrowRight":D+=Z;break}A?(D<0?D=0:D>le&&(D=le),Ee(D)):($<0?$=0:$>De-u&&($=De-u),lt($)),Me(!0)},To=w=>{const $=te.find(A=>A.id===w),D=te.find(A=>!!it&&A.id===it.id);j&&(D&&j(D,!1),$&&j($,!0)),xo($)},Mo=(w,$)=>{var A;const D=(A=Te==null?void 0:Te.field)==null?void 0:A.data.find(_=>_.id===$.id+"");X&&$.children.length&&X(ce(O({},D),{hideChildren:!w}))},Do=w=>{vo(w)},Bo=w=>re(null,null,function*(){no(w,Lt,Q,Ve,$e)}),No=w=>re(null,null,function*(){oo(w,Lt,Q,Ve,$e)}),Po=w=>{var _;const $=ct=>ct.reduce((_t,_e)=>_e.children?_t.concat([_e,...$(_e.children)]):_t.concat(_e),[]),D=$((_=Ve==null?void 0:Ve.data)==null?void 0:_.data),A=D==null?void 0:D.find(ct=>ct.id===+w.id);A&&(po(A),It(!0))},Fo={columnWidth:Z,svgWidth:le,tasks:q,rowHeight:l,dates:se.dates,todayColor:ot,rtl:m,selectedRowKeys:yo},Ao={dateSetup:se,locale:ae,viewMode:ee,headerHeight:i,columnWidth:Z,fontFamily:ne,fontSize:fe,rtl:m},$o={tasks:te,dates:se.dates,ganttEvent:He,selectedTask:it,rowHeight:l,taskHeight:st,columnWidth:Z,arrowColor:W,timeStep:V,fontFamily:ne,fontSize:fe,arrowIndent:Ce,svgWidth:le,rtl:m,setGanttEvent:Gt,setFailedTask:zt,setSelectedTask:To,onDateChange:No,onProgressChange:Q.progress&&Bo,onDoubleClick:H,onClick:Po,onDelete:G};return c.jsxs("div",{className:d.cx(d.css`
238
238
  .ant-table-container::after {
239
239
  box-shadow: none !important;
240
240
  }
241
241
  .ant-table-row {
242
242
  height: ${a}px;
243
243
  }
244
- `),children:[c.jsx(ro,{visible:fo,setVisible:It,record:ho}),c.jsx(I.RecursionField,{name:"anctionBar",schema:Ht.properties.toolBar}),c.jsx(I.RecursionField,{name:"table",schema:Ht.properties.table}),c.jsxs("div",{className:t.wrapper,onKeyDown:Co,tabIndex:0,ref:ve,children:[c.jsx(At,{gridProps:Fo,calendarProps:Ao,barProps:$o,ganttHeight:u,scrollY:pe,scrollX:ie,ref:Et}),He.changedTask&&c.jsx(mr,{arrowIndent:Ce,rowHeight:l,svgContainerHeight:mo,svgContainerWidth:go,fontFamily:ne,fontSize:fe,scrollX:ie,scrollY:pe,task:He.changedTask,headerHeight:i,taskListWidth:qe,TooltipContent:P,rtl:m,svgWidth:le}),c.jsx(yr,{ganttFullHeight:De,ganttHeight:u,headerHeight:i,scroll:pe,onScroll:So,rtl:m}),c.jsx(br,{svgWidth:le,taskListWidth:qe,scroll:ie,rtl:m,onScroll:wo})]})]})}),ao=()=>{const{name:e,title:t}=d.useCollection_deprecated(),r=d.useSchemaTemplate();return c.jsx(d.GeneralSchemaDesigner,{schemaSettings:"blockSettings:gantt",template:r,title:t||e})},Ae=()=>ge.useTranslation("gantt"),je=(e="string")=>{var n;const t=d.useCompile(),{fields:r}=d.useCollection_deprecated();return(n=r==null?void 0:r.filter(a=>a.type===e))==null?void 0:n.map(a=>{var i;return{value:a.name,label:t((i=a==null?void 0:a.uiSchema)==null?void 0:i.title)}})},so=new d.SchemaSettings({name:"blockSettings:gantt",items:[{name:"title",Component:d.SchemaSettingsBlockTitleItem},{name:"titleField",Component:d.SchemaSettingsSelectItem,useComponentProps(){var i;const{t:e}=Ae(),t=I.useFieldSchema(),r=((i=t==null?void 0:t["x-decorator-props"])==null?void 0:i.fieldNames)||{},{service:o}=de(),n=I.useField(),{dn:a}=d.useDesignable();return{title:e("Title field"),value:r.title,options:je("string"),onChange:s=>{const l=n.decoratorProps.fieldNames||{};l.title=s,n.decoratorProps.params=l,t["x-decorator-props"].params=l,t["x-decorator-props"].fieldNames=l,o.refresh(),a.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":n.decoratorProps}}),a.refresh()}}}},{name:"timeScale",Component:d.SchemaSettingsSelectItem,useComponentProps(){var s;const{t:e}=Ae(),t=I.useFieldSchema(),r=((s=t==null?void 0:t["x-decorator-props"])==null?void 0:s.fieldNames)||{},o=I.useField(),{service:n}=de(),{dn:a}=d.useDesignable(),i=d.useCompile();return{title:e("Time scale"),value:r.range||"day",options:[{label:i('{{t("Hour")}}'),value:"hour",color:"orange"},{label:i('{{t("Quarter of day")}}'),value:"quarterDay",color:"default"},{label:i('{{t("Half of day")}}'),value:"halfDay",color:"blue"},{label:i('{{t("Day")}}'),value:"day",color:"yellow"},{label:i('{{t("Week")}}'),value:"week",color:"pule"},{label:i('{{t("Month")}}'),value:"month",color:"green"},{label:i('{{t("QuarterYear")}}'),value:"quarterYear",color:"red"},{label:i('{{t("Year")}}'),value:"year",color:"green"}],onChange:l=>{const u=o.decoratorProps.fieldNames||{};u.range=l,o.decoratorProps.params=u,t["x-decorator-props"].params=u,t["x-decorator-props"].fieldNames=u,n.refresh(),a.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":o.decoratorProps}}),a.refresh()}}}},{name:"startDateField",Component:d.SchemaSettingsSelectItem,useComponentProps(){var i;const{t:e}=Ae(),t=I.useFieldSchema(),r=((i=t==null?void 0:t["x-decorator-props"])==null?void 0:i.fieldNames)||{},o=I.useField(),{dn:n}=d.useDesignable(),{service:a}=de();return{title:e("Start date field"),value:r.start,options:je("date"),onChange:s=>{const l=o.decoratorProps.fieldNames||{};l.start=s,o.decoratorProps.fieldNames=l,t["x-decorator-props"].fieldNames=l,a.refresh(),n.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":o.decoratorProps}}),n.refresh()}}}},{name:"setDataLoadingMode",Component:d.SetDataLoadingMode},{name:"endDateField",Component:d.SchemaSettingsSelectItem,useComponentProps(){var i;const{t:e}=Ae(),t=I.useFieldSchema(),r=I.useField(),{service:o}=de(),{dn:n}=d.useDesignable(),a=((i=t==null?void 0:t["x-decorator-props"])==null?void 0:i.fieldNames)||{};return{title:e("End date field"),value:a.end,options:je("date"),onChange:s=>{const l=r.decoratorProps.fieldNames||{};l.end=s,r.decoratorProps.fieldNames=l,t["x-decorator-props"].fieldNames=l,o.refresh(),n.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":r.decoratorProps}}),n.refresh()}}}},{name:"processField",Component:d.SchemaSettingsSelectItem,useComponentProps(){var i;const{t:e}=Ae(),t=I.useFieldSchema(),r=((i=t==null?void 0:t["x-decorator-props"])==null?void 0:i.fieldNames)||{},{service:o}=de(),{dn:n}=d.useDesignable(),a=I.useField();return{title:e("Progress field"),value:r.progress,options:je("float"),onChange:s=>{const l=a.decoratorProps.fieldNames||{};l.progress=s,a.decoratorProps.fieldNames=l,t["x-decorator-props"].fieldNames=l,o.refresh(),n.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":a.decoratorProps}}),n.refresh()}}}},{name:"dataScope",Component:d.SchemaSettingsDataScope,useComponentProps(){var s,l;const{name:e}=d.useCollection(),t=I.useFieldSchema(),{form:r}=d.useFormBlockContext(),o=I.useField(),{service:n}=de(),{dn:a}=d.useDesignable(),i=d.useDataLoadingMode();return{collectionName:e,defaultFilter:((l=(s=t==null?void 0:t["x-decorator-props"])==null?void 0:s.params)==null?void 0:l.filter)||{},form:r,onSubmit:({filter:u})=>{var x;u=d.removeNullCondition(u);const p=o.decoratorProps.params||{};p.filter=u,o.decoratorProps.params=p,t["x-decorator-props"].params=p,i==="auto"&&n.run(ce(O({},(x=n.params)==null?void 0:x[0]),{filter:u})),a.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":t["x-decorator-props"]}})}}}},{name:"divider",type:"divider"},{name:"template",Component:d.SchemaSettingsTemplate,useComponentProps(){const{name:e}=d.useCollection();return{componentName:"Gantt",collectionName:e}}},{name:"divider2",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]}),io=new d.SchemaInitializer({name:"gantt:configureActions",title:"{{t('Configure actions')}}",icon:"SettingOutlined",style:{marginLeft:8},items:[{type:"itemGroup",name:"enableActions",title:"{{t('Enable actions')}}",children:[{type:"item",name:"filter",title:"{{t('Filter')}}",Component:"FilterActionInitializer",schema:{"x-align":"left"}},{type:"item",title:"{{t('Add new')}}",name:"addNew",Component:"CreateActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}},useVisible(){const e=d.useCollection_deprecated();return!["view","file","sql"].includes(e.template)||(e==null?void 0:e.writableView)}},{type:"item",title:"{{t('Delete')}}",name:"delete",Component:"BulkDestroyActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider"},useVisible(){const e=d.useCollection_deprecated();return!["view","sql"].includes(e.template)||(e==null?void 0:e.writableView)}},{type:"item",title:"{{t('Refresh')}}",name:"refresh",Component:"RefreshActionInitializer",schema:{"x-align":"right"}},{name:"toggle",title:"{{t('Expand/Collapse')}}",Component:"ExpandableActionInitializer",schema:{"x-align":"right"},useVisible(){var o;const e=I.useFieldSchema(),t=d.useCollection_deprecated(),{treeTable:r}=((o=e==null?void 0:e.parent)==null?void 0:o["x-decorator-props"])||{};return t.tree&&r!==!1}}]},{name:"divider",type:"divider",useVisible(){const e=d.useCollection_deprecated();return!["view","sql"].includes(e.template)||(e==null?void 0:e.writableView)}},{type:"subMenu",name:"customize",title:'{{t("Customize")}}',children:[{type:"item",title:'{{t("Add record")}}',name:"addRecord",Component:"CustomizeAddRecordActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action":"create","x-acl-action-props":{skipScopeCheck:!0}}}],useVisible(){const e=d.useCollection_deprecated();return!["view","sql"].includes(e.template)||(e==null?void 0:e.writableView)}}]}),lo=e=>{const{collectionName:t,fieldNames:r,dataSource:o}=e;return{type:"void","x-acl-action":`${t}:list`,"x-decorator":"GanttBlockProvider","x-decorator-props":{collection:t,dataSource:o,action:"list",fieldNames:r,params:{paginate:!1}},"x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:gantt","x-component":"CardItem",properties:{[I.uid()]:{type:"void","x-component":"Gantt","x-use-component-props":"useGanttBlockProps",properties:{toolBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},"x-initializer":"gantt:configureActions",properties:{}},table:{type:"array","x-decorator":"div","x-decorator-props":{style:{float:"left",maxWidth:"35%"}},"x-initializer":"table:configureColumns","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},pagination:!1},properties:{actions:{type:"void",title:'{{ t("Actions") }}',"x-action-column":"actions","x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column","x-designer":"TableV2.ActionColumnDesigner","x-initializer":"table:configureItemActions",properties:{actions:{type:"void","x-decorator":"DndContext","x-component":"Space","x-component-props":{split:"|"}}}}}},detail:{type:"void","x-component":"Gantt.Event",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-component-props":{className:"tb-action-popup"},title:'{{ t("View record") }}',properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab",properties:{tab1:{type:"void",title:'{{t("Details")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:common:addBlock"}}}}}}}}}}}}}},co=()=>{const{insert:e}=d.useSchemaInitializer(),{t}=ge.useTranslation(),{getCollectionFields:r}=d.useCollectionManager_deprecated(),o=f.useContext(I.SchemaOptionsContext),{theme:n}=d.useGlobalTheme(),a=d.useSchemaInitializerItem();return c.jsx(d.DataBlockInitializer,ce(O({},a),{componentType:"Gantt",icon:c.jsx(Jt.FormOutlined,{}),onCreateBlockSchema:s=>re(this,[s],function*({item:i}){var S,y,B;const l=r(i.name,i.dataSource),u=(S=l==null?void 0:l.filter(g=>g.type==="string"))==null?void 0:S.map(g=>{var v;return{label:(v=g==null?void 0:g.uiSchema)==null?void 0:v.title,value:g.name}}),p=(y=l==null?void 0:l.filter(g=>g.type==="date"))==null?void 0:y.map(g=>{var v;return{label:(v=g==null?void 0:g.uiSchema)==null?void 0:v.title,value:g.name}}),x=(B=l==null?void 0:l.filter(g=>g.type==="float"))==null?void 0:B.map(g=>{var v;return{label:(v=g==null?void 0:g.uiSchema)==null?void 0:v.title,value:g.name}}),F=yield d.FormDialog(t("Create gantt block"),()=>c.jsx(d.SchemaComponentOptions,{scope:o.scope,components:O({},o.components),children:c.jsx(Be.FormLayout,{layout:"vertical",children:c.jsx(d.SchemaComponent,{schema:{properties:{title:{title:t("Title field"),enum:u,required:!0,"x-component":"Select","x-decorator":"FormItem"},start:{title:t("Start date field"),enum:p,required:!0,default:"createdAt","x-component":"Select","x-decorator":"FormItem"},end:{title:t("End date field"),enum:p,required:!0,"x-component":"Select","x-decorator":"FormItem"},progress:{title:t("Progress field"),enum:x,"x-component":"Select","x-decorator":"FormItem"},range:{title:t("Time scale"),enum:[{label:'{{t("Hour")}}',value:"hour",color:"orange"},{label:'{{t("Quarter of day")}}',value:"quarterDay",color:"default"},{label:'{{t("Half of day")}}',value:"halfDay",color:"blue"},{label:'{{t("Day")}}',value:"day",color:"yellow"},{label:'{{t("Week")}}',value:"week",color:"pule"},{label:'{{t("Month")}}',value:"month",color:"green"},{label:'{{t("Year")}}',value:"year",color:"green"},{label:'{{t("QuarterYear")}}',value:"quarterYear",color:"red"}],default:"day","x-component":"Select","x-decorator":"FormItem"}}}})})}),n).open({initialValues:{}});e(lo({collectionName:i.name,dataSource:i.dataSource,fieldNames:O({},F)}))})}))};we.ActionBar=d.ActionBar,we.ViewMode=E,we.Designer=ao,we.Event=Zt;const $t=f.memo(e=>c.jsx(d.SchemaComponentOptions,{components:{Gantt:we,GanttBlockInitializer:co,GanttBlockProvider:er},scope:{useGanttBlockProps:dt},children:e.children}));$t.displayName="GanttProvider";class Vt extends d.Plugin{load(){return re(this,null,function*(){this.app.use($t),this.app.schemaSettingsManager.add(so),this.app.schemaInitializerManager.add(io);const t=this.app.schemaInitializerManager.get("page:addBlock");t==null||t.add("dataBlocks.gantt",{title:"{{t('Gantt')}}",Component:"GanttBlockInitializer"}),this.app.addScopes({useGanttBlockProps:dt})})}}L.Gantt=we,L.GanttPlugin=Vt,L.default=Vt,Object.defineProperties(L,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
244
+ `),children:[c.jsx(ro,{visible:fo,setVisible:It,record:ho}),c.jsx(I.RecursionField,{name:"anctionBar",schema:Ht.properties.toolBar}),c.jsx(I.RecursionField,{name:"table",schema:Ht.properties.table}),c.jsxs("div",{className:t.wrapper,onKeyDown:Co,tabIndex:0,ref:ve,children:[c.jsx(At,{gridProps:Fo,calendarProps:Ao,barProps:$o,ganttHeight:u,scrollY:pe,scrollX:ie,ref:Et}),He.changedTask&&c.jsx(mr,{arrowIndent:Ce,rowHeight:l,svgContainerHeight:mo,svgContainerWidth:go,fontFamily:ne,fontSize:fe,scrollX:ie,scrollY:pe,task:He.changedTask,headerHeight:i,taskListWidth:qe,TooltipContent:P,rtl:m,svgWidth:le}),c.jsx(yr,{ganttFullHeight:De,ganttHeight:u,headerHeight:i,scroll:pe,onScroll:So,rtl:m}),c.jsx(br,{svgWidth:le,taskListWidth:qe,scroll:ie,rtl:m,onScroll:wo})]})]})}),ao=()=>{const{name:e,title:t}=d.useCollection_deprecated(),r=d.useSchemaTemplate();return c.jsx(d.GeneralSchemaDesigner,{schemaSettings:"blockSettings:gantt",template:r,title:t||e})},Ae=()=>ge.useTranslation("gantt"),je=(e="string")=>{var n;const t=d.useCompile(),{fields:r}=d.useCollection_deprecated();return(n=r==null?void 0:r.filter(a=>a.type===e))==null?void 0:n.map(a=>{var i;return{value:a.name,label:t((i=a==null?void 0:a.uiSchema)==null?void 0:i.title)}})},so=new d.SchemaSettings({name:"blockSettings:gantt",items:[{name:"title",Component:d.SchemaSettingsBlockTitleItem},{name:"titleField",Component:d.SchemaSettingsSelectItem,useComponentProps(){var i;const{t:e}=Ae(),t=I.useFieldSchema(),r=((i=t==null?void 0:t["x-decorator-props"])==null?void 0:i.fieldNames)||{},{service:o}=de(),n=I.useField(),{dn:a}=d.useDesignable();return{title:e("Title field"),value:r.title,options:je("string"),onChange:s=>{const l=n.decoratorProps.fieldNames||{};l.title=s,n.decoratorProps.params=l,t["x-decorator-props"].params=l,t["x-decorator-props"].fieldNames=l,o.refresh(),a.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":n.decoratorProps}}),a.refresh()}}}},{name:"timeScale",Component:d.SchemaSettingsSelectItem,useComponentProps(){var s;const{t:e}=Ae(),t=I.useFieldSchema(),r=((s=t==null?void 0:t["x-decorator-props"])==null?void 0:s.fieldNames)||{},o=I.useField(),{service:n}=de(),{dn:a}=d.useDesignable(),i=d.useCompile();return{title:e("Time scale"),value:r.range||"day",options:[{label:i('{{t("Hour")}}'),value:"hour",color:"orange"},{label:i('{{t("Quarter of day")}}'),value:"quarterDay",color:"default"},{label:i('{{t("Half of day")}}'),value:"halfDay",color:"blue"},{label:i('{{t("Day")}}'),value:"day",color:"yellow"},{label:i('{{t("Week")}}'),value:"week",color:"pule"},{label:i('{{t("Month")}}'),value:"month",color:"green"},{label:i('{{t("QuarterYear")}}'),value:"quarterYear",color:"red"},{label:i('{{t("Year")}}'),value:"year",color:"green"}],onChange:l=>{const u=o.decoratorProps.fieldNames||{};u.range=l,o.decoratorProps.params=u,t["x-decorator-props"].params=u,t["x-decorator-props"].fieldNames=u,n.refresh(),a.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":o.decoratorProps}}),a.refresh()}}}},{name:"startDateField",Component:d.SchemaSettingsSelectItem,useComponentProps(){var i;const{t:e}=Ae(),t=I.useFieldSchema(),r=((i=t==null?void 0:t["x-decorator-props"])==null?void 0:i.fieldNames)||{},o=I.useField(),{dn:n}=d.useDesignable(),{service:a}=de();return{title:e("Start date field"),value:r.start,options:je("date"),onChange:s=>{const l=o.decoratorProps.fieldNames||{};l.start=s,o.decoratorProps.fieldNames=l,t["x-decorator-props"].fieldNames=l,a.refresh(),n.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":o.decoratorProps}}),n.refresh()}}}},{name:"setDataLoadingMode",Component:d.SetDataLoadingMode},{name:"endDateField",Component:d.SchemaSettingsSelectItem,useComponentProps(){var i;const{t:e}=Ae(),t=I.useFieldSchema(),r=I.useField(),{service:o}=de(),{dn:n}=d.useDesignable(),a=((i=t==null?void 0:t["x-decorator-props"])==null?void 0:i.fieldNames)||{};return{title:e("End date field"),value:a.end,options:je("date"),onChange:s=>{const l=r.decoratorProps.fieldNames||{};l.end=s,r.decoratorProps.fieldNames=l,t["x-decorator-props"].fieldNames=l,o.refresh(),n.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":r.decoratorProps}}),n.refresh()}}}},{name:"processField",Component:d.SchemaSettingsSelectItem,useComponentProps(){var i;const{t:e}=Ae(),t=I.useFieldSchema(),r=((i=t==null?void 0:t["x-decorator-props"])==null?void 0:i.fieldNames)||{},{service:o}=de(),{dn:n}=d.useDesignable(),a=I.useField();return{title:e("Progress field"),value:r.progress,options:je("float"),onChange:s=>{const l=a.decoratorProps.fieldNames||{};l.progress=s,a.decoratorProps.fieldNames=l,t["x-decorator-props"].fieldNames=l,o.refresh(),n.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":a.decoratorProps}}),n.refresh()}}}},{name:"dataScope",Component:d.SchemaSettingsDataScope,useComponentProps(){var s,l;const{name:e}=d.useCollection(),t=I.useFieldSchema(),{form:r}=d.useFormBlockContext(),o=I.useField(),{service:n}=de(),{dn:a}=d.useDesignable(),i=d.useDataLoadingMode();return{collectionName:e,defaultFilter:((l=(s=t==null?void 0:t["x-decorator-props"])==null?void 0:s.params)==null?void 0:l.filter)||{},form:r,onSubmit:({filter:u})=>{var x;u=d.removeNullCondition(u);const p=o.decoratorProps.params||{};p.filter=u,o.decoratorProps.params=p,t["x-decorator-props"].params=p,i==="auto"&&n.run(ce(O({},(x=n.params)==null?void 0:x[0]),{filter:u})),a.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":t["x-decorator-props"]}})}}}},{name:"divider",type:"divider"},{name:"template",Component:d.SchemaSettingsTemplate,useComponentProps(){const{name:e}=d.useCollection();return{componentName:"Gantt",collectionName:e}}},{name:"divider2",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]}),io=new d.SchemaInitializer({name:"gantt:configureActions",title:"{{t('Configure actions')}}",icon:"SettingOutlined",style:{marginLeft:8},items:[{type:"itemGroup",name:"enableActions",title:"{{t('Enable actions')}}",children:[{type:"item",name:"filter",title:"{{t('Filter')}}",Component:"FilterActionInitializer",schema:{"x-align":"left"}},{type:"item",title:"{{t('Add new')}}",name:"addNew",Component:"CreateActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}},useVisible(){const e=d.useCollection_deprecated();return!["view","file","sql"].includes(e.template)||(e==null?void 0:e.writableView)}},{type:"item",title:"{{t('Delete')}}",name:"delete",Component:"BulkDestroyActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider"},useVisible(){const e=d.useCollection_deprecated();return!["view","sql"].includes(e.template)||(e==null?void 0:e.writableView)}},{type:"item",title:"{{t('Refresh')}}",name:"refresh",Component:"RefreshActionInitializer",schema:{"x-align":"right"}},{name:"toggle",title:"{{t('Expand/Collapse')}}",Component:"ExpandableActionInitializer",schema:{"x-align":"right"},useVisible(){var o;const e=I.useFieldSchema(),t=d.useCollection_deprecated(),{treeTable:r}=((o=e==null?void 0:e.parent)==null?void 0:o["x-decorator-props"])||{};return t.tree&&r!==!1}}]},{name:"divider",type:"divider",useVisible(){const e=d.useCollection_deprecated();return!["view","sql"].includes(e.template)||(e==null?void 0:e.writableView)}},{type:"subMenu",name:"customize",title:'{{t("Customize")}}',children:[{type:"item",title:'{{t("Add record")}}',name:"addRecord",Component:"CustomizeAddRecordActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action":"create","x-acl-action-props":{skipScopeCheck:!0}}}],useVisible(){const e=d.useCollection_deprecated();return!["view","sql"].includes(e.template)||(e==null?void 0:e.writableView)}}]}),lo=e=>{const{collectionName:t,fieldNames:r,dataSource:o}=e;return{type:"void","x-acl-action":`${t}:list`,"x-decorator":"GanttBlockProvider","x-decorator-props":{collection:t,dataSource:o,action:"list",fieldNames:r,params:{paginate:!1}},"x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:gantt","x-component":"CardItem",properties:{[I.uid()]:{type:"void","x-component":"Gantt","x-use-component-props":"useGanttBlockProps",properties:{toolBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},"x-initializer":"gantt:configureActions",properties:{}},table:{type:"array","x-decorator":"div","x-decorator-props":{style:{float:"left",maxWidth:"35%"}},"x-initializer":"table:configureColumns","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},pagination:!1},properties:{actions:{type:"void",title:'{{ t("Actions") }}',"x-action-column":"actions","x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column","x-designer":"TableV2.ActionColumnDesigner","x-initializer":"table:configureItemActions",properties:{actions:{type:"void","x-decorator":"DndContext","x-component":"Space","x-component-props":{split:"|"}}}}}},detail:{type:"void","x-component":"Gantt.Event",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-component-props":{className:"tb-action-popup"},title:'{{ t("View record") }}',properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab",properties:{tab1:{type:"void",title:'{{t("Details")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:common:addBlock"}}}}}}}}}}}}}},co=()=>{const{insert:e}=d.useSchemaInitializer(),{t}=ge.useTranslation(),{getCollectionFields:r}=d.useCollectionManager_deprecated(),o=f.useContext(I.SchemaOptionsContext),{theme:n}=d.useGlobalTheme(),a=d.useSchemaInitializerItem();return c.jsx(d.DataBlockInitializer,ce(O({},a),{componentType:"Gantt",icon:c.jsx(Jt.FormOutlined,{}),onCreateBlockSchema:s=>re(null,[s],function*({item:i}){var S,y,B;const l=r(i.name,i.dataSource),u=(S=l==null?void 0:l.filter(g=>g.type==="string"))==null?void 0:S.map(g=>{var v;return{label:(v=g==null?void 0:g.uiSchema)==null?void 0:v.title,value:g.name}}),p=(y=l==null?void 0:l.filter(g=>g.type==="date"))==null?void 0:y.map(g=>{var v;return{label:(v=g==null?void 0:g.uiSchema)==null?void 0:v.title,value:g.name}}),x=(B=l==null?void 0:l.filter(g=>g.type==="float"))==null?void 0:B.map(g=>{var v;return{label:(v=g==null?void 0:g.uiSchema)==null?void 0:v.title,value:g.name}}),F=yield d.FormDialog(t("Create gantt block"),()=>c.jsx(d.SchemaComponentOptions,{scope:o.scope,components:O({},o.components),children:c.jsx(Be.FormLayout,{layout:"vertical",children:c.jsx(d.SchemaComponent,{schema:{properties:{title:{title:t("Title field"),enum:u,required:!0,"x-component":"Select","x-decorator":"FormItem"},start:{title:t("Start date field"),enum:p,required:!0,default:"createdAt","x-component":"Select","x-decorator":"FormItem"},end:{title:t("End date field"),enum:p,required:!0,"x-component":"Select","x-decorator":"FormItem"},progress:{title:t("Progress field"),enum:x,"x-component":"Select","x-decorator":"FormItem"},range:{title:t("Time scale"),enum:[{label:'{{t("Hour")}}',value:"hour",color:"orange"},{label:'{{t("Quarter of day")}}',value:"quarterDay",color:"default"},{label:'{{t("Half of day")}}',value:"halfDay",color:"blue"},{label:'{{t("Day")}}',value:"day",color:"yellow"},{label:'{{t("Week")}}',value:"week",color:"pule"},{label:'{{t("Month")}}',value:"month",color:"green"},{label:'{{t("Year")}}',value:"year",color:"green"},{label:'{{t("QuarterYear")}}',value:"quarterYear",color:"red"}],default:"day","x-component":"Select","x-decorator":"FormItem"}}}})})}),n).open({initialValues:{}});e(lo({collectionName:i.name,dataSource:i.dataSource,fieldNames:O({},F)}))})}))};we.ActionBar=d.ActionBar,we.ViewMode=E,we.Designer=ao,we.Event=Zt;const $t=f.memo(e=>c.jsx(d.SchemaComponentOptions,{components:{Gantt:we,GanttBlockInitializer:co,GanttBlockProvider:er},scope:{useGanttBlockProps:dt},children:e.children}));$t.displayName="GanttProvider";class Vt extends d.Plugin{load(){return re(this,null,function*(){this.app.use($t),this.app.schemaSettingsManager.add(so),this.app.schemaInitializerManager.add(io);const t=this.app.schemaInitializerManager.get("page:addBlock");t==null||t.add("dataBlocks.gantt",{title:"{{t('Gantt')}}",Component:"GanttBlockInitializer"}),this.app.addScopes({useGanttBlockProps:dt})})}}L.Gantt=we,L.GanttPlugin=Vt,L.default=Vt,Object.defineProperties(L,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,13 +1,13 @@
1
1
  module.exports = {
2
2
  "react": "18.3.1",
3
- "@tachybase/client": "1.3.16",
4
- "@tachybase/schema": "1.3.16",
5
- "@tachybase/components": "1.3.16",
3
+ "@tachybase/client": "1.3.18",
4
+ "@tachybase/schema": "1.3.18",
5
+ "@tachybase/components": "1.3.18",
6
6
  "@ant-design/icons": "5.5.2",
7
7
  "react-i18next": "15.2.0",
8
- "@tachybase/server": "1.3.16",
9
- "@tachybase/test": "1.3.16",
8
+ "@tachybase/server": "1.3.18",
9
+ "@tachybase/test": "1.3.18",
10
10
  "antd": "5.22.5",
11
11
  "lodash": "4.17.21",
12
- "@tachybase/utils": "1.3.16"
12
+ "@tachybase/utils": "1.3.18"
13
13
  };
package/dist/index.js CHANGED
@@ -26,12 +26,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var src_exports = {};
30
- __export(src_exports, {
29
+ var index_exports = {};
30
+ __export(index_exports, {
31
31
  default: () => import_server.default
32
32
  });
33
- module.exports = __toCommonJS(src_exports);
34
- __reExport(src_exports, require("./server"), module.exports);
33
+ module.exports = __toCommonJS(index_exports);
34
+ __reExport(index_exports, require("./server"), module.exports);
35
35
  var import_server = __toESM(require("./server"));
36
36
  // Annotate the CommonJS export names for ESM import in node:
37
37
  0 && (module.exports = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tachybase/plugin-block-gantt",
3
3
  "displayName": "Block: Gantt",
4
- "version": "1.3.16",
4
+ "version": "1.3.18",
5
5
  "description": "Provides Gantt block.",
6
6
  "keywords": [
7
7
  "Blocks"
@@ -15,14 +15,14 @@
15
15
  "antd": "5.22.5",
16
16
  "lodash": "4.17.21",
17
17
  "react-i18next": "^15.2.0",
18
- "@tachybase/components": "1.3.16",
19
- "@tachybase/schema": "1.3.16"
18
+ "@tachybase/components": "1.3.18",
19
+ "@tachybase/schema": "1.3.18"
20
20
  },
21
21
  "peerDependencies": {
22
- "@tachybase/client": "1.3.16",
23
- "@tachybase/test": "1.3.16",
24
- "@tachybase/utils": "1.3.16",
25
- "@tachybase/server": "1.3.16"
22
+ "@tachybase/client": "1.3.18",
23
+ "@tachybase/server": "1.3.18",
24
+ "@tachybase/utils": "1.3.18",
25
+ "@tachybase/test": "1.3.18"
26
26
  },
27
27
  "description.zh-CN": "提供甘特图卡片。",
28
28
  "displayName.zh-CN": "卡片:甘特图",