-
Notifications
You must be signed in to change notification settings - Fork 1
/
browser.js
1 lines (1 loc) · 4.34 KB
/
browser.js
1
var MyPackage=function(e,t){"use strict";function i(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var r=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,Object.freeze(t)}var r=i(t);const a=(e,t)=>e.start.getTime()-t.start.getTime(),s=(e,{startTime:t,ratio:i})=>{const r=e.start.getTime()-t,a=e.end.getTime()-t,s=Math.round(r*i);return{width:Math.round(a*i)-s,left:s}},{useRef:n,useEffect:l}=r,{format:o,isToday:c,isPast:d,addDays:m,startOfDay:u}=require("date-fns"),h=({evt:e})=>r.createElement("div",{key:e.id,className:"react-scrollable-timeline-event"},e.title?e.title:e.id),p=({group:e,maxHeight:t,resourceNode:i})=>r.createElement("div",{style:{position:"relative",height:t+36}},r.createElement("div",{className:"resource-header",style:{height:t+36}},i({group:e}))),g=({childs:e,maxHeight:t,viewSize:{width:i}})=>r.createElement("div",{className:"timeline-separator",style:{height:t+36,overflow:"hidden",width:i}},e),f=({group:{title:e}})=>r.createElement("div",null,e),v=e=>r.createElement("div",null,o(e.start,"yyyy-MM-dd")),y=(e,t)=>e&&t&&e&&t[e]?t[e]:{title:e||""},w=({dates:e,lineItem:t,viewSize:i})=>r.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},e.map((e=>t({date:e,viewSize:i})))),b=({date:e,viewSize:t})=>{const{width:i,left:a}=s(e,t);return r.createElement("div",{key:`line-${e.start.getTime()}`,style:{width:`${i}px`,display:"inline-flex",position:"absolute",left:`${a}px`,height:"100%",borderLeft:"1px solid #DDD",top:0}})};return e.Timeline=({groups:e,events:t,startDate:i=u(new Date),endDate:o=m(u(new Date),40),width:x=5e3,interval:E=864e5,resourceHeaderWidth:k=200,groupKey:D,getGroupData:T=y,resourceNode:O=f,itemNode:j=h,dateNode:N=v,onEventClick:H=(e=>e)})=>{const $=i.getTime(),M=o.getTime()-$,z={startDate:i,startTime:$,endDate:o,totalTicks:M,ratio:x/M,width:x},S=n(null),P=n(null),_=e=>s(e,z),C=(G=e=>D?e[D]:"single",t.reduce(((e,t)=>{const i=G(t);return Object.assign(Object.assign({},e),{[i]:[...e[i]||[],t]})}),{}));var G;const W=(({start:e,end:t,interval:i})=>{const r=[],a=e.getTime(),s=t.getTime(),n=Math.ceil((s-a)/i);for(let e=0;e<n;e++)r.push({start:new Date(a+i*e),end:new Date(a+i*(e+1))});return r})({start:i,end:o,interval:E}),F=W.map((e=>((e,t,i)=>{const{width:a,left:s}=i(t);let n="is-future";switch(!0){default:n="is-future";break;case c(t.start):n="is-today";break;case d(t.start):n="is-past"}return r.createElement("div",{key:`datenode-${t.start.getTime()}`,style:{width:`${a}px`,position:"absolute",left:`${s}px`,top:0},className:"react-scrollable-timeline-date "+n},e(t))})(N,e,_))),I=((e,t)=>{const i=[];return Object.keys(e).map((r=>{i.push(Object.assign(Object.assign({},t(e[r],r)),{key:r}))})),i})(C,(e=>e.sort(a).reduce(((e,t,i)=>({rendered:a=[],maxHeight:s=0,elements:n=[]},l)=>{const o=((e,t)=>t.filter((t=>t.id!=e.id)).filter((t=>{return r=e,!((i=t).end<=r.start||i.start>=r.end);var i,r})))(l,a);let c=o.length;for(let e=0;e<a.length+1;e++)if(!o.some((t=>t.positionFromTop==e))){c=e;break}const d=36*c;return{elements:[...n,r.createElement("div",{key:l.id,className:"timeline-event-wrapper "+(i?"pointer":""),style:Object.assign(Object.assign({},t(l)),{height:36,top:d}),onClick:()=>i(l)},r.createElement(e,{evt:l}))],maxHeight:Math.max(s||0,d),rendered:[...a,Object.assign(Object.assign({},l),{positionFromTop:c})]}})(j,_,H),{}))),R=I.map((({maxHeight:t,key:i})=>r.createElement(p,{key:`resource-${i}`,group:T(i,e),resourceNode:O,maxHeight:t}))),q=I.map((({elements:e,maxHeight:t,key:i})=>r.createElement(g,{key:`group-${i}`,maxHeight:t,childs:e,viewSize:z})));return l((()=>{if(S&&S.current){const e=S.current.children[0].clientHeight;S.current.style.height=`${e}px`,P&&P.current&&(P.current.style.marginTop=e-1+"px")}}),[]),r.createElement("div",{className:"react-scrollable-timeline",style:{maxWidth:"100%",position:"relative",display:"flex",flexDirection:"row",border:"1px solid #DDD"}},D&&r.createElement("div",{ref:P,style:{width:`${k}px`,position:"relative",flexGrow:0,flexShrink:0}},R),r.createElement("div",{style:{overflowX:"scroll",maxWidth:"100%",position:"relative",flexGrow:1}},r.createElement(w,{dates:W,lineItem:b,viewSize:z}),r.createElement("div",{ref:S,style:{width:z.width,position:"relative",height:"5rem"}},F),q))},Object.defineProperty(e,"__esModule",{value:!0}),e}({},React);