WokerTask/public/admin/assets/vue-simple-calendar.f45a5eb...

2 lines
15 KiB
JavaScript

import{d as le,$ as Le,b as D,w as Te,o as y,c as b,J as w,u as d,a as f,T as ie,F as L,a9 as T,K as O,V as k,a4 as P,L as oe,U as se}from"./@vue.f8dfc830.js";var Ye=Object.defineProperty,Ae=(e,r,t)=>r in e?Ye(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,H=(e,r,t)=>(Ae(e,typeof r!="symbol"?r+"":r,t),t);const A=()=>B(new Date),$e=(e,r,t)=>{switch(r){case"year":return new Date(e.getFullYear(),0);case"month":return new Date(e.getFullYear(),e.getMonth());case"week":return _(e,t);default:return e}},xe=e=>[...Array(7)].map((r,t)=>S(e,t)),S=(e,r)=>new Date(e.getFullYear(),e.getMonth(),e.getDate()+r,e.getHours(),e.getMinutes(),e.getSeconds()),_=(e,r)=>S(e,(r-e.getDay()-7)%-7),We=(e,r)=>S(_(e,r),7),Y=e=>new Date(e.getFullYear(),e.getMonth()),He=e=>Math.ceil(e.getDate()/7),Be=(e,r,t)=>new Date(e.getFullYear()+(r=="year"?t:0),e.getMonth()+(r=="month"?t:0),e.getDate()+(r=="week"?t*7:0)),q=e=>("0"+String(e.getMonth()+1)).slice(-2),G=e=>("0"+String(e.getDate())).slice(-2),de=e=>e.getFullYear()+"-"+q(e),Ne=e=>de(e)+"-"+G(e),Ee=e=>q(e)+"-"+G(e),Ue=(e,r,t)=>{if(e.getHours()===0&&e.getMinutes()===0&&e.getSeconds()===0)return"";if(!N()){var l=new Date().getTimezoneOffset()*6e4;return new Date(e.getTime()-l).toISOString().slice(11,16)}return e.toLocaleTimeString(r,t)},Re=(e,r,t,l)=>{const g=e.getFullYear()===r.getFullYear(),h=ge(e,r),c=t!=="year"&&t!=="month";let m=[];return m.push(l[e.getMonth()]),c&&(m.push(" "),m.push(e.getDate())),g||(m.push(c?", ":" "),m.push(e.getFullYear())),!h||!g?(m.push(" \u2013 "),h||m.push(l[r.getMonth()]),c&&m.push(" ")):c&&m.push(" \u2013 "),c?(m.push(r.getDate()),m.push(", ")):m.push(" "),m.push(r.getFullYear()),m.join("")},ue=(e,r)=>{const t=Date.UTC(r.getFullYear(),r.getMonth(),r.getDate()),l=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate());return(t-l)/864e5},Ve=(e,r)=>!!e&&!!r&&ue(e,r)===0,ze=(e,r)=>!!e&&!!r&&e.getTime()===r.getTime(),ge=(e,r)=>!!e&&!!r&&e.getFullYear()===r.getFullYear()&&e.getMonth()===r.getMonth(),je=e=>Y(e)<Y(A()),_e=e=>Y(e)>Y(A()),qe=e=>B(e)>A(),Ge=e=>B(e)<A(),Je=e=>e.getMonth()!==S(e,7).getMonth(),Ke=e=>e.getMonth()!==S(e,1).getMonth(),ce=e=>{let r=[...Array(7)].map(t=>0);return e.split(/\D/,7).forEach((t,l)=>r[l]=Number(t)),r[1]--,new Date(r[0],r[1],r[2],r[3],r[4],r[5],r[6])},j=e=>typeof e=="string"?ce(e):new Date(e),B=e=>{const r=new Date(e);return r.setHours(0,0,0,0),r},Qe=e=>e.substring(0,2),N=()=>typeof Intl<"u",Xe=(e,r)=>{if(!N())return[...Array(12)].map(l=>"");const t=new Intl.DateTimeFormat(e,{month:r});return[...Array(12)].map((l,g)=>t.format(new Date(2017,g,1)))},Ze=(e,r,t)=>{if(!N())return[...Array(7)].map(g=>"");const l=new Intl.DateTimeFormat(e,{weekday:r});return[...Array(7)].map((g,h)=>l.format(new Date(2017,0,(h+1+t)%7)))},et=()=>typeof navigator>"u"?"unk":(navigator.languages&&navigator.languages.length?navigator.languages[0]:navigator.language).toLowerCase(),tt=(e,r)=>{var l;const t=e.classes?[...e.classes]:[];return r&&t.push("isHovered"),{originalItem:e,startDate:j(e.startDate),endDate:j(e.endDate||e.startDate),classes:t,title:e.title||"Untitled",id:e.id,url:e.url,tooltip:(l=e.tooltip)!=null?l:e.title}},n={addDays:S,beginningOfMonth:Y,beginningOfPeriod:$e,beginningOfWeek:_,dateOnly:B,dayDiff:ue,daysOfWeek:xe,endOfWeek:We,formattedPeriod:Re,formattedTime:Ue,fromIsoStringToLocalDate:ce,getDefaultBrowserLocale:et,getFormattedMonthNames:Xe,getFormattedWeekdayNames:Ze,incrementPeriod:Be,instanceOfMonth:He,isFutureMonth:_e,isInFuture:qe,isInPast:Ge,isLastDayOfMonth:Ke,isLastInstanceOfMonth:Je,isoMonthDay:Ee,isoYearMonth:de,isoYearMonthDay:Ne,isPastMonth:je,isSameDate:Ve,isSameDateTime:ze,isSameMonth:ge,languageCode:Qe,normalizeItem:tt,paddedDay:G,paddedMonth:q,supportsIntl:N,today:A,toLocalDate:j};class at{constructor(){H(this,"currentDragItem"),H(this,"dateSelectionOrigin"),H(this,"currentHoveredItemId",""),H(this,"CalendarMath",n)}}const rt={class:"cv-header-days"},nt={key:0,class:"cv-weeknumber"},it=["aria-multiselectable"],ot={key:0,class:"cv-weeknumber"},lt={class:"cv-weekdays"},st=["draggable","aria-grabbed","aria-label","aria-selected","aria-dropeffect","onClick","onDragstart","onDrop","onDragover","onDragenter","onDragleave"],dt={class:"cv-day-number"},ut=["draggable","aria-grabbed","title","onDragstart","onMouseenter","onMouseleave","onClick","innerHTML"],gt=["draggable","aria-grabbed","title","onDragstart","onMouseenter","onMouseleave","onClick"],ft=le({__name:"CalendarView",props:{showDate:{default:void 0},displayPeriodUom:{default:"month"},displayPeriodCount:{default:1},displayWeekNumbers:{type:Boolean,default:!1},locale:{default:void 0},monthNameFormat:{default:"long"},weekdayNameFormat:{default:"short"},showTimes:{type:Boolean,default:!1},timeFormatOptions:{default:()=>({})},disablePast:{type:Boolean,default:!1},disableFuture:{type:Boolean,default:!1},enableDateSelection:{type:Boolean,default:!1},selectionStart:{default:void 0},selectionEnd:{default:void 0},enableDragDrop:{type:Boolean,default:!1},startingDayOfWeek:{default:0},items:{default:()=>[]},dateClasses:{default:()=>({})},itemTop:{default:"1.4em"},itemContentHeight:{default:"1.4em"},itemBorderHeight:{default:"2px"},periodChangedCallback:{type:Function,default:void 0},currentPeriodLabel:{default:""},currentPeriodLabelIcons:{default:"\u21E4-\u21E5"},doEmitItemMouseEvents:{type:Boolean,default:!1},enableHtmlTitles:{type:Boolean,default:!0}},emits:["period-changed","click-date","click-item","item-mouseenter","item-mouseleave","drag-start","drag-over-date","drag-enter-date","drag-leave-date","drop-on-date","date-selection","date-selection-start","date-selection-finish"],setup(e,{emit:r}){const t=e,l=Le(new at),g=D(()=>t.locale||n.getDefaultBrowserLocale()),h=D(()=>t.showDate?n.dateOnly(t.showDate):n.today()),c=D(()=>n.beginningOfPeriod(h.value,t.displayPeriodUom,t.startingDayOfWeek)),m=D(()=>n.addDays(n.incrementPeriod(c.value,t.displayPeriodUom,t.displayPeriodCount),-1)),J=D(()=>{const a=n.beginningOfWeek(n.beginningOfPeriod(c.value,"year",0),t.startingDayOfWeek),o=n.beginningOfWeek(c.value,t.startingDayOfWeek);return 1+Math.floor(n.dayDiff(a,o)/7)}),$=D(()=>n.beginningOfWeek(c.value,t.startingDayOfWeek)),E=D(()=>n.endOfWeek(m.value,t.startingDayOfWeek)),me=D(()=>{const a=Math.floor((n.dayDiff($.value,E.value)+1)/7);return[...Array(a)].map((o,u)=>n.addDays($.value,u*7))}),U=D(()=>n.getFormattedMonthNames(g.value,t.monthNameFormat)),pe=D(()=>n.getFormattedWeekdayNames(g.value,t.weekdayNameFormat,t.startingDayOfWeek)),R=D(()=>t.items?t.items.map(a=>n.normalizeItem(a,a.id===l.currentHoveredItemId)):[]),V=D(()=>n.beginningOfPeriod(n.today(),t.displayPeriodUom,t.startingDayOfWeek)),De=D(()=>n.addDays(n.incrementPeriod(V.value,t.displayPeriodUom,t.displayPeriodCount),-1)),ve=D(()=>n.formattedPeriod(c.value,m.value,t.displayPeriodUom,U.value)),ye=D(()=>{const a=V.value,o=c.value;return t.currentPeriodLabel?t.currentPeriodLabel==="icons"?t.currentPeriodLabelIcons[Math.sign(a.getTime()-o.getTime())+1]:t.currentPeriodLabel:n.formattedPeriod(a,De.value,t.displayPeriodUom,U.value)}),be=D(()=>({previousYear:I(-12),previousPeriod:I(-1),nextPeriod:I(1),previousFullPeriod:I(-t.displayPeriodCount),nextFullPeriod:I(t.displayPeriodCount),nextYear:I(12),currentPeriod:V.value,currentPeriodLabel:ye.value,periodStart:c.value,periodEnd:m.value,displayLocale:g.value,displayFirstDate:$.value,displayLastDate:E.value,monthNames:U.value,fixedItems:R.value,periodLabel:ve.value})),he=D(()=>({periodStart:c,periodEnd:m,displayFirstDate:$,displayLastDate:E}));Te(()=>he,a=>{t.periodChangedCallback&&(r("period-changed"),t.periodChangedCallback(a,"watch"))},{immediate:!0,deep:!0});const fe=(a,o)=>{t.disablePast&&n.isInPast(a)||t.disableFuture&&n.isInFuture(a)||r("click-date",a,ee(a,a),o)},K=(a,o)=>r("click-item",a,o),C=a=>"dow"+(a+t.startingDayOfWeek)%7,I=a=>{const o=n.incrementPeriod(c.value,t.displayPeriodUom,a),u=n.incrementPeriod(o,t.displayPeriodUom,t.displayPeriodCount);return t.disablePast&&u<=n.today()||t.disableFuture&&o>n.today()?null:o},Q=(a,o)=>{l.currentHoveredItemId=a.id,t.doEmitItemMouseEvents&&r("item-mouseenter",a,o)},X=(a,o)=>{l.currentHoveredItemId="",t.doEmitItemMouseEvents&&r("item-mouseleave",a,o)},Pe=(a,o)=>{var u,p;if(!t.enableDateSelection)return!1;(u=o.dataTransfer)==null||u.setData("text",a.toString());let i=new Image;return i.src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",(p=o.dataTransfer)==null||p.setDragImage(i,10,10),l.dateSelectionOrigin=a,r("date-selection-start",z(a),o),!0},Z=(a,o)=>{var u;return t.enableDragDrop?((u=o.dataTransfer)==null||u.setData("text",a.id),l.currentDragItem=a,l.dateSelectionOrigin=void 0,r("drag-start",a,o),!0):!1},z=a=>a<=l.dateSelectionOrigin?[a,l.dateSelectionOrigin]:[l.dateSelectionOrigin,a],ke=(a,o)=>{t.enableDragDrop&&r("drag-over-date",l.currentDragItem,a,o)},Me=(a,o)=>{t.enableDateSelection&&l.dateSelectionOrigin&&r("date-selection",z(a),o),t.enableDragDrop&&(r("drag-enter-date",l.currentDragItem,a,o),o.target.classList.add("draghover"))},we=(a,o)=>{t.enableDateSelection&&t.selectionStart||!t.enableDragDrop||(r("drag-leave-date",l.currentDragItem,a,o),o.target.classList.remove("draghover"))},Ie=(a,o)=>{if(t.enableDateSelection&&l.dateSelectionOrigin){r("date-selection-finish",z(a),o);return}!t.enableDragDrop||(r("drop-on-date",l.currentDragItem,a,o),o.target.classList.remove("draghover"))},Oe=(a,o)=>a.startDate<o.startDate?-1:o.startDate<a.startDate?1:a.endDate>o.endDate?-1:o.endDate>a.endDate?1:a.id<o.id?-1:1,Se=a=>ee(a,n.addDays(a,6)),ee=(a,o)=>R.value.filter(u=>u.endDate>=a&&n.dateOnly(u.startDate)<=o,this).sort(Oe),Ce=a=>!!R.value.find(o=>o.endDate>=a&&n.dateOnly(o.startDate)<=a),te=a=>!(!t.selectionStart||!t.selectionEnd||a<n.dateOnly(t.selectionStart)||a>n.dateOnly(t.selectionEnd)),ae=a=>{const o=Se(a),u=[],p=[[],[],[],[],[],[],[]];if(!o)return u;for(let i=0;i<o.length;i++){const s=Object.assign({},o[i],{classes:[...o[i].classes],itemRow:0}),v=s.startDate<a,F=v?0:n.dayDiff(a,s.startDate),ne=Math.min(7-F,n.dayDiff(n.addDays(a,F),s.endDate)+1);v&&s.classes.push("continued"),n.dayDiff(a,s.endDate)>6&&s.classes.push("toBeContinued"),n.isInPast(s.endDate)&&s.classes.push("past"),s.originalItem.url&&s.classes.push("hasUrl");for(let M=0;M<7;M++)if(M===F){let W=0;for(;p[M][W];)W++;s.itemRow=W,p[M][W]=!0}else M<F+ne&&(p[M][s.itemRow]=!0);s.classes.push(`offset${F}`),s.classes.push(`span${ne}`),u.push(s)}return u},Fe=a=>{const o='<span class="startTime">'+n.formattedTime(a.startDate,g.value,t.timeFormatOptions)+"</span>";let u="";return n.isSameDateTime(a.startDate,a.endDate)||(u='<span class="endTime">'+n.formattedTime(a.endDate,g.value,t.timeFormatOptions)+"</span>"),o+u},re=a=>t.showTimes?Fe(a)+" "+a.title:a.title,x=a=>{const o=a.itemRow,u=t.itemContentHeight,p=t.itemBorderHeight;return`calc(${t.itemTop} + ${o}*${u} + ${o}*${p})`};return(a,o)=>(y(),b("div",{"aria-label":"Calendar",class:O(["cv-wrapper",`locale-${d(n).languageCode(d(g))}`,`locale-${d(g)}`,`y${d(c).getFullYear()}`,`m${d(n).paddedMonth(d(c))}`,`period-${e.displayPeriodUom}`,`periodCount-${e.displayPeriodCount}`,{past:d(n).isPastMonth(d(c)),future:d(n).isFutureMonth(d(c)),noIntl:!d(n).supportsIntl}])},[w(a.$slots,"header",{headerProps:d(be)}),f("div",rt,[e.displayWeekNumbers?(y(),b("div",nt)):ie("",!0),(y(!0),b(L,null,T(d(pe),(u,p)=>w(a.$slots,"dayHeader",{index:C(p),label:u},()=>[(y(),b("div",{key:C(p),class:O([C(p),"cv-header-day"])},k(u),3))])),256))]),f("div",{"aria-multiselectable":e.enableDateSelection,class:"cv-weeks"},[(y(!0),b(L,null,T(d(me),(u,p)=>(y(),b("div",{key:`${p}-week`,class:O(["cv-week",`week${p+1}`,`ws${d(n).isoYearMonthDay(u)}`])},[e.displayWeekNumbers?(y(),b("div",ot,[w(a.$slots,"weekNumber",{date:u,numberInYear:d(J)+p,numberInPeriod:p+1},()=>[f("span",null,k(d(J)+p),1)])])):ie("",!0),f("div",lt,[(y(!0),b(L,null,T(d(n).daysOfWeek(u),(i,s)=>(y(),b("div",{key:C(s),draggable:e.enableDateSelection,class:O(["cv-day",C(s),`d${d(n).isoYearMonthDay(i)}`,`d${d(n).isoMonthDay(i)}`,`d${d(n).paddedDay(i)}`,`instance${d(n).instanceOfMonth(i)}`,{today:d(n).isSameDate(i,d(n).today()),outsideOfMonth:!d(n).isSameMonth(i,d(h)),past:d(n).isInPast(i),future:d(n).isInFuture(i),last:d(n).isLastDayOfMonth(i),lastInstance:d(n).isLastInstanceOfMonth(i),hasItems:Ce(i),selectionStart:d(n).isSameDate(i,e.selectionStart),selectionEnd:d(n).isSameDate(i,e.selectionEnd)},...e.dateClasses&&e.dateClasses[d(n).isoYearMonthDay(i)]||[]]),"aria-grabbed":e.enableDateSelection?te(i):void 0,"aria-label":i.getDate().toString(),"aria-selected":te(i),"aria-dropeffect":e.enableDragDrop&&l.currentDragItem?"move":e.enableDateSelection&&l.dateSelectionOrigin?"execute":"none",onClick:v=>fe(i,v),onDragstart:v=>Pe(i,v),onDrop:P(v=>Ie(i,v),["prevent"]),onDragover:P(v=>ke(i,v),["prevent"]),onDragenter:P(v=>Me(i,v),["prevent"]),onDragleave:P(v=>we(i,v),["prevent"])},[f("div",dt,k(i.getDate()),1),w(a.$slots,"dayContent",{day:i})],42,st))),128)),t.enableHtmlTitles?(y(!0),b(L,{key:0},T(ae(u),i=>w(a.$slots,"item",{value:i,weekStartDate:u,top:x(i)},()=>[(y(),b("div",{key:i.id,draggable:e.enableDragDrop,"aria-grabbed":e.enableDragDrop?i==l.currentDragItem:void 0,class:O([i.classes,"cv-item"]),title:i.tooltip||i.title,style:oe(`top:${x(i)};${i.originalItem.style}`),onDragstart:s=>Z(i,s),onMouseenter:s=>Q(i,s),onMouseleave:s=>X(i,s),onClick:P(s=>K(i,s),["stop"]),innerHTML:re(i)},null,46,ut))])),256)):(y(!0),b(L,{key:1},T(ae(u),i=>w(a.$slots,"item",{value:i,weekStartDate:u,top:x(i)},()=>[(y(),b("div",{key:i.id,draggable:e.enableDragDrop,"aria-grabbed":e.enableDragDrop?i==l.currentDragItem:void 0,class:O([i.classes,"cv-item"]),title:i.tooltip||i.title,style:oe(`top:${x(i)};${i.originalItem.style}`),onDragstart:s=>Z(i,s),onMouseenter:s=>Q(i,s),onMouseleave:s=>X(i,s),onClick:P(s=>K(i,s),["stop"])},k(re(i)),47,gt)),se(" div> ")])),256))])],2))),128))],8,it)],2))}}),ct={class:"cv-header"},mt={class:"cv-header-nav"},pt=["disabled"],Dt=["disabled","innerHTML"],vt=["disabled"],yt=["disabled"],bt={class:"periodLabel"},Pt=le({__name:"CalendarViewHeader",props:{headerProps:{type:Object,required:!0},previousYearLabel:{type:String,default:"<<"},previousPeriodLabel:{type:String,default:"<"},nextPeriodLabel:{type:String,default:">"},nextYearLabel:{type:String,default:">>"}},emits:["input"],setup(e,{emit:r}){const t=l=>r("input",l);return(l,g)=>(y(),b("div",ct,[f("div",mt,[f("button",{disabled:!e.headerProps.previousYear,class:"previousYear","aria-label":"Previous Year",onClick:g[0]||(g[0]=P(h=>t(e.headerProps.previousYear),["prevent"]))},k(e.previousYearLabel),9,pt),f("button",{disabled:!e.headerProps.previousPeriod,class:"previousPeriod","aria-label":"Previous Period",onClick:g[1]||(g[1]=P(h=>t(e.headerProps.previousPeriod),["prevent"])),innerHTML:e.previousPeriodLabel},null,8,Dt),f("button",{class:"currentPeriod","aria-label":"Current Period",onClick:g[2]||(g[2]=P(h=>t(e.headerProps.currentPeriod),["prevent"]))},k(e.headerProps.currentPeriodLabel),1),f("button",{disabled:!e.headerProps.nextPeriod,class:"nextPeriod","aria-label":"Next Period",onClick:g[3]||(g[3]=P(h=>t(e.headerProps.nextPeriod),["prevent"]))},k(e.nextPeriodLabel),9,vt),f("button",{disabled:!e.headerProps.nextYear,class:"nextYear","aria-label":"Next Year",onClick:g[4]||(g[4]=P(h=>t(e.headerProps.nextYear),["prevent"]))},k(e.nextYearLabel),9,yt)]),f("div",bt,[w(l.$slots,"label",{},()=>[se(k(e.headerProps.periodLabel),1)])])]))}});export{Pt as M,ft as P};