UNPKG

gantt-schedule-timeline-calendar

Version:

Gantt, Schedule, Timeline, Calendar components all in one. [gantt, timeline, schedule, scheduler, calendar, booking, gantt chart, reservation, javascript gantt, javascript timeline, javascript schedule, javascript scheduler, javascript calendar, javascrip

127 lines 8.85 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ItemTypes={})}(this,(function(t){"use strict"; /** * ItemTypes plugin * * @copyright NEURONET - Rafal Pospiech * @author Rafal Pospiech <neuronet.io@gmail.com> * @module gantt-schedule-timeline-calendar * @link https://github.com/neuronetio/gantt-schedule-timeline-calendar * @link https://gantt-schedule-timeline-calendar.neuronet.io * @version 3.40.7 * @released 2025-05-27 * @license SEE LICENSE IN LICENSE FILE */const e="config.plugin.ItemTypes",i="config.templates.chart-timeline-items-row-item",s={task({className:t,labelClassName:e,cache:i,shouldDetach:s,actions:a,styleMap:l,slots:n,cutterLeft:o,cutterRight:c,getContent:p,vido:$,props:h}){const r=s||!h.item,{itemData:g,item:d}=h,u=g.position.left!==g.position.actualLeft,m=g.position.right!==g.position.actualRight,f=g.actualWidth,y=g.actualHeight,L=Math.min(8,y/2);let _=[`M ${L} ${y}`,`Q 0 ${y} 0 ${y-L}`,`L 0 ${L}`,`Q 0 0 ${L} 0`,`L ${f-L} 0`,`Q ${f} 0 ${f} ${L}`,`L ${f} ${y-L}`,`Q ${f} ${y} ${f-L} ${y}`,`L ${L} ${y}`].join(" ");u&&!m?_=["M 0 0",`L ${f-L} 0`,`Q ${f} 0 ${f} ${L}`,`L ${f} ${y-L}`,`Q ${f} ${y} ${f-L} ${y}`,`L 0 ${y}`].join(" "):u&&m?_=["M 0 0",`L ${f} 0`,`L ${f} ${y}`,`L 0 ${y}`].join(" "):!u&&m&&(_=[`M ${L} ${y}`,`Q 0 ${y} 0 ${y-L}`,`L 0 ${L}`,`Q 0 0 ${L} 0`,`L ${f} 0`,`L ${f} ${y}`,`L ${L} ${y}`].join(" "));const w=`gstc__clip-path-${d.id}`,v=`gstc__pattern-${d.id}`,j=void 0===d.progress?100:d.progress,b=g.width-g.width/100*j;let x=g.width-b;u&&(x+=g.position.left),x<0&&(x=0);const M=[`M ${x} 0`,`L ${f} 0`,`L ${f} ${y}`,`L ${x} ${y}`].join(" "),H=d.fill?d.fill:"#e74c3c",T=`gstc__item-type gstc__item-type--${d.type} `;return i(r?null:n.html("outer",$.html` <div class=${T+t} data-gstcid=${h.item.id} data-actions=${a()} style=${l.directive()}> ${f>=0?$.svg`<svg width=${f} height=${g.actualHeight} xmlns="http://www.w3.org/2000/svg"> <defs> <clipPath id=${w}> <path d=${_}></path> </clipPath> <pattern id=${v} width="20" height="20" patternTransform="rotate(45 0 0)" patternUnits="userSpaceOnUse" > <line class="gstc__item-type-progress-line" x1="0" y1="0" x2="0" y2="20" /> </pattern> </defs> <path class="gstc__item-type-item" d=${_} fill=${H} /> <path class="gstc__item-type-progress" clip-path="url(#${w})" d=${M} style="fill: url('#${v}');" /> <g clip-path="url(#${w})"> <foreignObject x="0" y="0" width="100%" height="100%"> <div class="gstc__item-type-content" xmlns="http://www.w3.org/1999/xhtml"> ${n.html("inner",$.html`<div class=${T+e}>${n.html("content",p())}</div>`)} </div> </foreignObject> </g> </svg>`:null} </div> `))},milestone({className:t,labelClassName:e,cache:i,actions:s,styleMap:a,shouldDetach:l,slots:n,cutterLeft:o,cutterRight:c,getContent:p,vido:$,props:h}){const r=l||!h.item,{itemData:g,item:d}=h,u=16,m=g.actualWidth,f=g.actualHeight,y=g.position.left!==g.position.actualLeft,L=g.position.right!==g.position.actualRight;let _=["M 0 "+g.actualHeight/2,`L ${m>=32?u:m/2} 0`,`L ${m>=32?m-u:m/2} 0`,`L ${m} ${g.actualHeight/2}`,`L ${m>=32?m-u:m/2} ${g.actualHeight}`,`L ${m>=32?u:m/2} ${g.actualHeight}`,"L 0 "+g.actualHeight/2].join(" ");y&&!L?_=["M 0 0",`L ${m>=32?m-u:m/2} 0`,`L ${m} ${g.actualHeight/2}`,`L ${m>=32?m-u:m/2} ${g.actualHeight}`,`L 0 ${f}`].join(" "):y&&L?_=["M 0 0",`L ${m} 0`,`L ${m} ${f}`,`L 0 ${f}`].join(" "):!y&&L&&(_=["M 0 "+g.actualHeight/2,`L ${m>=32?u:m/2} 0`,`L ${m} 0`,`L ${m} ${f}`,`L ${m>=32?u:m/2} ${g.actualHeight}`,"L 0 "+g.actualHeight/2].join(" "));const w=`gstc__clip-path-${d.id}`,v=`gstc__pattern-${d.id}`,j=void 0===d.progress?100:d.progress,b=g.width-g.width/100*j;let x=g.width-b;y&&(x+=g.position.left),x<0&&(x=0);const M=[`M ${m} 0`,`L ${m} ${f}`,`L ${x} ${f}`,`L ${x} 0`].join(" "),H=d.fill?d.fill:"#e74c3c",T=`gstc__item-type gstc__item-type--${d.type} `;return i(r?null:n.html("outer",$.html` <div class=${T+t} data-gstcid=${h.item.id} data-actions=${s()} style=${a.directive()}> ${m>=0?$.svg`<svg width=${m} height=${g.actualHeight} xmlns="http://www.w3.org/2000/svg"> <defs> <clipPath id=${w}> <path d=${_}></path> </clipPath> <pattern id=${v} width="20" height="20" patternTransform="rotate(45 0 0)" patternUnits="userSpaceOnUse" > <line class="gstc__item-type-progress-line" x1="0" y1="0" x2="0" y2="20" /> </pattern> </defs> <path class="gstc__item-type-item" d=${_} stroke="none" fill=${H} /> <path class="gstc__item-type-progress" clip-path="url(#${w})" d=${M} style="fill: url('#${v}');" /> <g clip-path="url(#${w})"> <foreignObject x="0" y="0" width="100%" height="100%"> <div class="gstc__item-type-content" xmlns="http://www.w3.org/1999/xhtml"> ${n.html("inner",$.html`<div class=${T+e}>${n.html("content",p())}</div>`)} </div> </foreignObject> </g> </svg>`:null} </div> `))},project({className:t,labelClassName:e,cache:i,shouldDetach:s,actions:a,styleMap:l,slots:n,cutterLeft:o,cutterRight:c,getContent:p,vido:$,props:h}){const r=s||!h.item,{itemData:g,item:d}=h,u=g.actualWidth,m=g.actualHeight,f=g.position.left!==g.position.actualLeft,y=["M 0 0",`L ${u} 0`,`L ${u} ${m}`,`L 0 ${m}`].join(" "),L=`gstc__clip-path-${d.id}`,_=`gstc__pattern-${d.id}`,w=void 0===d.progress?100:d.progress,v=g.width-g.width/100*w;let j=g.width-v;f&&(j+=g.position.left),j<0&&(j=0);const b=[`M ${u} 0`,`L ${u} ${m}`,`L ${j} ${m}`,`L ${j} 0`].join(" "),x=d.fill?d.fill:"#e74c3c",M=`gstc__item-type gstc__item-type--${d.type} `;return i(r?null:n.html("outer",$.html` <div class=${M+t} data-gstcid=${h.item.id} data-actions=${a()} style=${l.directive()}> ${u>=0?$.svg`<svg width=${u} height=${g.actualHeight} xmlns="http://www.w3.org/2000/svg"> <defs> <clipPath id=${L}> <path d=${y}></path> </clipPath> <pattern id=${_} width="20" height="20" patternTransform="rotate(45 0 0)" patternUnits="userSpaceOnUse" > <line class="gstc__item-type-progress-line" x1="0" y1="0" x2="0" y2="20" /> </pattern> </defs> <path class="gstc__item-type-item" d=${y} fill=${x} /> <path class="gstc__item-type-progress" clip-path="url(#${L})" d=${b} style="fill: url('#${_}');" /> <g clip-path="url(#${L})"> <foreignObject x="0" y="0" width="100%" height="100%"> <div class="gstc__item-type-content" xmlns="http://www.w3.org/1999/xhtml"> ${n.html("inner",$.html`<div class=${M+e}>${n.html("content",p())}</div>`)} </div> </foreignObject> </g> </svg>`:null} </div> `))}};class a{constructor(t,a){this.unsub=[],this.options=function(t){return Object.assign(Object.assign({},s),t)}(t),this.vido=a,this.state=a.state,this.api=a.api,this.componentTemplate=this.componentTemplate.bind(this),this.destroy=this.destroy.bind(this),this.state.update(e,this.options),this.state.update(i,(()=>this.componentTemplate)),this.unsub.push(this.state.subscribe(e,(t=>this.options=t))),this.api.pluginInitialized("ItemTypes")}destroy(){this.unsub.forEach((t=>t())),this.state.update(i,null),this.vido.api.pluginDestroyed("ItemTypes")}componentTemplate(t){const e=t.props.item;if(!e)return null;const i=e.type;if(!i)throw new Error(`Item (${e.id}) must have a 'type' {string} property 'task', 'milestone' or 'project'.`);return this.options[i](t)}}t.Plugin=function(t={}){return function(i){const s=i.state.get(e);s&&(t=i.api.mergeDeep({},t,s));return new a(t,i).destroy}},t.pluginPath=e,t.templatePath=i,Object.defineProperty(t,"__esModule",{value:!0})}));