calkit 0.1.0 → 0.2.0
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.
- package/README.md +1 -1
- package/dist/booking.es.js +421 -318
- package/dist/booking.es.js.map +1 -1
- package/dist/booking.umd.js +12 -12
- package/dist/booking.umd.js.map +1 -1
- package/dist/calkit.d.ts +453 -0
- package/dist/calkit.es.js +1101 -898
- package/dist/calkit.es.js.map +1 -1
- package/dist/calkit.umd.js +34 -34
- package/dist/calkit.umd.js.map +1 -1
- package/dist/datepicker.es.js +333 -241
- package/dist/datepicker.es.js.map +1 -1
- package/dist/datepicker.umd.js +12 -12
- package/dist/datepicker.umd.js.map +1 -1
- package/dist/scheduler.es.js +705 -638
- package/dist/scheduler.es.js.map +1 -1
- package/dist/scheduler.umd.js +20 -20
- package/dist/scheduler.umd.js.map +1 -1
- package/dist/timepicker.es.js +146 -116
- package/dist/timepicker.es.js.map +1 -1
- package/dist/timepicker.umd.js +6 -6
- package/dist/timepicker.umd.js.map +1 -1
- package/llms.txt +1 -1
- package/package.json +4 -2
package/dist/scheduler.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(me,ve){typeof exports=="object"&&typeof module<"u"?ve(exports):typeof define=="function"&&define.amd?define(["exports"],ve):(me=typeof globalThis<"u"?globalThis:me||self,ve(me.CalScheduler={}))})(this,(function(me){"use strict";class ve extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this._initialized=!1}static get styles(){return[]}connectedCallback(){this._initialized||(this._adoptStyles(),this._initialized=!0),this.render()}_adoptStyles(){const e=this.constructor.styles;if(e.length)if("adoptedStyleSheets"in this.shadowRoot)this.shadowRoot.adoptedStyleSheets=e.map(s=>{if(s instanceof CSSStyleSheet)return s;const a=new CSSStyleSheet;return a.replaceSync(s),a});else for(const s of e){const a=document.createElement("style");a.textContent=s instanceof CSSStyleSheet?"":s,this.shadowRoot.prepend(a)}}render(){}clear(){}emit(e,s={}){this.dispatchEvent(new CustomEvent(e,{detail:s,bubbles:!0,composed:!0}))}showStatus(e,s,a={}){if(!this._store)return;const{autoDismiss:n,dismissible:r=!0}=a;clearTimeout(this._statusTimer),this._store.set({statusType:e,statusMessage:s,statusDismissible:r}),this.emit("cal:status",{type:e,message:s}),n&&n>0&&(this._statusTimer=setTimeout(()=>this.clearStatus(),n))}clearStatus(){this._store&&(clearTimeout(this._statusTimer),this._store.set({statusType:null,statusMessage:null,statusDismissible:!0}),this.emit("cal:status",{type:null,message:null}))}$(e){return this.shadowRoot.querySelector(e)}$$(e){return this.shadowRoot.querySelectorAll(e)}}function Oe(t){let e={...t};const s=new Set;return{get(a){return e[a]},set(a){const n=e;e={...e,...a};let r=!1;for(const l of Object.keys(a))if(n[l]!==e[l]){r=!0;break}if(r)for(const l of s)l(e,n)},getState(){return e},subscribe(a){return s.add(a),()=>s.delete(a)}}}const xe=["January","February","March","April","May","June","July","August","September","October","November","December"],qe=["Su","Mo","Tu","We","Th","Fr","Sa"],Xe=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],We=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function Ue(t){if(!t)return xe;try{const e=new Intl.DateTimeFormat(t,{month:"long"});return Array.from({length:12},(s,a)=>{const n=e.format(new Date(2024,a,1));return n.charAt(0).toUpperCase()+n.slice(1)})}catch{return xe}}function $e(t,e="short",s){const a=Q(t);return a?e==="long"?Xe[a.getDay()]:We[a.getDay()]:""}function Ge(t=0,e){const s=[];for(let a=0;a<7;a++)s.push(qe[(t+a)%7]);return s}function Ae(t,e){return new Date(t,e+1,0).getDate()}function Ze(t,e){return new Date(t,e,1).getDay()}function he(t){if(typeof t=="string")return t;const e=t instanceof Date?t:new Date(t.year,t.month,t.day),s=e.getFullYear(),a=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${s}-${a}-${n}`}function Q(t){if(!t)return null;if(t instanceof Date)return t;if(typeof t=="string"){const[e,s,a]=t.split("-").map(Number);return!e||!s||!a?null:new Date(e,s-1,a)}return null}function ye(t,e){if(!t||!e)return!1;const s=Q(t),a=Q(e);return!s||!a?!1:s.getFullYear()===a.getFullYear()&&s.getMonth()===a.getMonth()&&s.getDate()===a.getDate()}function ge(){return he(new Date)}function we(t,e,s){const a=new Date(t,e+s,1);return{year:a.getFullYear(),month:a.getMonth()}}function fe(t,e){const s=Q(t);return s?(s.setDate(s.getDate()+e),he(s)):t}function Je(t,e,s=0){const a=Ae(t,e),r=(Ze(t,e)-s+7)%7,l=[],i=ge(),d=we(t,e,-1),g=Ae(d.year,d.month);for(let k=r-1;k>=0;k--){const u=g-k,p=he({year:d.year,month:d.month,day:u});l.push({year:d.year,month:d.month,day:u,dateString:p,isCurrentMonth:!1,isToday:p===i})}for(let k=1;k<=a;k++){const u=he({year:t,month:e,day:k});l.push({year:t,month:e,day:k,dateString:u,isCurrentMonth:!0,isToday:u===i})}const c=we(t,e,1);let h=1;for(;l.length<42;){const k=he({year:c.year,month:c.month,day:h});l.push({year:c.year,month:c.month,day:h,dateString:k,isCurrentMonth:!1,isToday:k===i}),h++}return l}function oe(t){if(!t||typeof t!="string")return null;const e=t.trim().toUpperCase(),s=e.match(/^(\d{1,2}):(\d{2})\s*(AM|PM)$/);if(s){let n=parseInt(s[1],10);const r=parseInt(s[2],10),l=s[3];return l==="AM"&&n===12&&(n=0),l==="PM"&&n!==12&&(n+=12),{hours:n,minutes:r}}const a=e.match(/^(\d{1,2}):(\d{2})$/);return a?{hours:parseInt(a[1],10),minutes:parseInt(a[2],10)}:null}function ue(t,e,s="24h"){const a=String(e).padStart(2,"0");if(s==="12h"){const n=t>=12?"PM":"AM";return`${t%12||12}:${a} ${n}`}return`${String(t).padStart(2,"0")}:${a}`}function w(t){const e=oe(t);return e?e.hours*60+e.minutes:0}function le(t){const e=Math.floor(t/60)%24,s=t%60;return`${String(e).padStart(2,"0")}:${String(s).padStart(2,"0")}`}function Le(t,e,s){const a=[],n=w(t);let r=w(e);r<=n&&(r+=1440);for(let l=n;l<=r;l+=s)a.push(le(l%1440));return a}function Ie(){const t=new Date;return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function Ke(t,e=0){const s=Q(t);if(!s)return t;const n=(s.getDay()-e+7)%7;return s.setDate(s.getDate()-n),he(s)}function Ce(t,e=0){const s=Ke(t,e),a=[];for(let n=0;n<7;n++)a.push(fe(s,n));return a}function Qe(t,e,s,a){const n=Q(e);if(!n)return"";const r=Ue(a);if(t==="day")return`${r[n.getMonth()]} ${n.getDate()}, ${n.getFullYear()}`;if(t==="week"&&s&&s.length===7){const l=Q(s[0]),i=Q(s[6]);return!l||!i?"":l.getMonth()===i.getMonth()?`${r[l.getMonth()]} ${l.getDate()}–${i.getDate()}, ${l.getFullYear()}`:l.getFullYear()===i.getFullYear()?`${r[l.getMonth()].slice(0,3)} ${l.getDate()} – ${r[i.getMonth()].slice(0,3)} ${i.getDate()}, ${l.getFullYear()}`:`${r[l.getMonth()].slice(0,3)} ${l.getDate()}, ${l.getFullYear()} – ${r[i.getMonth()].slice(0,3)} ${i.getDate()}, ${i.getFullYear()}`}return t==="month"?`${r[n.getMonth()]} ${n.getFullYear()}`:""}function be(t,e){return t.filter(s=>s.start?s.end&&s.end!==s.start?e>=s.start&&e<=s.end:s.start===e:!1)}function ke(t){if(!t.length)return t;const e=[...t].sort((a,n)=>{const r=w(a.startTime||"00:00"),l=w(n.startTime||"00:00");if(r!==l)return r-l;const i=w(a.endTime||"23:59");return w(n.endTime||"23:59")-l-(i-r)}),s=[];for(const a of e){const n=w(a.startTime||"00:00"),r=w(a.endTime||"23:59");let l=!1;for(let i=0;i<s.length;i++)if(n>=s[i]){a._col=i,s[i]=r,l=!0;break}l||(a._col=s.length,s.push(r))}for(const a of e){const n=w(a.startTime||"00:00"),r=w(a.endTime||"23:59");let l=a._col;for(const i of e){const d=w(i.startTime||"00:00"),g=w(i.endTime||"23:59");d<r&&g>n&&(l=Math.max(l,i._col))}a._totalCols=l+1}return e}function re(t,e,s,a){return(w(t)-w(e))/a*s}function ze(t,e,s,a){const n=t/s*a,r=w(e)+n;return le(Math.round(r))}function Pe(t,e){const s=w(t),a=Math.round(s/e)*e;return le(a)}function et(t,e,s){return be(t,s).filter(a=>a.resourceId===e)}function He(t,e,s,a,n){const r=et(t,e,s),l=w(a),i=w(n);for(const d of r){if(!d.startTime||!d.endTime)continue;const g=w(d.startTime),c=w(d.endTime);if(l<c&&i>g)return!1}return!0}function tt(t,e,s,a,n="08:00",r="18:00"){const{duration:l,resourceId:i,minCapacity:d}=t,g=t.date||ge(),c=14;let h=e;i&&(h=e.filter(p=>p.id===i)),d&&(h=h.filter(p=>p.capacity&&p.capacity>=d));const k=w(n),u=w(r);for(let p=0;p<c;p++){const f=fe(g,p);for(const o of h)for(let m=k;m+l<=u;m+=a){const _=le(m),C=le(m+l);if(He(s,o.id,f,_,C))return{resourceId:o.id,date:f,startTime:_,endTime:C}}}return null}function at(t){if(!Array.isArray(t)||!t.length)return null;const e={};for(const s of t)!s.name||!s.bg||!s.fg||(e[s.name]={bg:s.bg,fg:s.fg,hover:s.hover||s.bg});return Object.keys(e).length?e:null}const st=`
|
|
2
2
|
:host {
|
|
3
3
|
/* Light theme (default) */
|
|
4
4
|
--cal-bg: 0 0% 100%;
|
|
@@ -166,7 +166,7 @@
|
|
|
166
166
|
--cal-status-success-border: 152 40% 28%;
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
-
`,
|
|
169
|
+
`,nt=`
|
|
170
170
|
:host {
|
|
171
171
|
display: inline-block;
|
|
172
172
|
font-family: inherit;
|
|
@@ -207,7 +207,7 @@
|
|
|
207
207
|
[hidden] {
|
|
208
208
|
display: none !important;
|
|
209
209
|
}
|
|
210
|
-
`,
|
|
210
|
+
`,lt=`
|
|
211
211
|
@keyframes cal-fade-in {
|
|
212
212
|
from { opacity: 0; }
|
|
213
213
|
to { opacity: 1; }
|
|
@@ -271,7 +271,7 @@
|
|
|
271
271
|
.cal-skeleton--rect {
|
|
272
272
|
border-radius: var(--cal-radius-sm);
|
|
273
273
|
}
|
|
274
|
-
`,
|
|
274
|
+
`,rt='<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M10 12L6 8l4-4"/></svg>',it='<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M6 4l4 4-4 4"/></svg>';function ct({title:t,view:e,onPrev:s,onNext:a,onToday:n,onViewChange:r,locale:l}){const i=document.createElement("div");i.classList.add("cal-sched-nav");const d=document.createElement("div");d.classList.add("cal-sched-nav__left");const g=document.createElement("button");g.classList.add("cal-sched-nav__btn"),g.innerHTML=rt,g.setAttribute("aria-label","Previous"),g.addEventListener("click",s);const c=document.createElement("button");c.classList.add("cal-sched-nav__btn"),c.innerHTML=it,c.setAttribute("aria-label","Next"),c.addEventListener("click",a);let h="Today";if(l)try{const _=new Intl.RelativeTimeFormat(l,{numeric:"auto"}).formatToParts(0,"day").map(C=>C.value).join("");h=_.charAt(0).toUpperCase()+_.slice(1)}catch{}const k=document.createElement("button");k.classList.add("cal-sched-nav__today"),k.textContent=h,k.addEventListener("click",n);const u=document.createElement("span");u.classList.add("cal-sched-nav__title"),u.setAttribute("aria-live","polite"),u.textContent=t,d.appendChild(g),d.appendChild(c),d.appendChild(k),d.appendChild(u);const p=document.createElement("div");p.classList.add("cal-sched-nav__tabs");const f={day:"Day",week:"Week",month:"Month"};if(l)try{const o=new Intl.DisplayNames(l,{type:"dateTimeField"});for(const m of["day","week","month"]){const _=o.of(m);_&&(f[m]=_.charAt(0).toUpperCase()+_.slice(1))}}catch{}for(const o of["day","week","month"]){const m=document.createElement("button");m.classList.add("cal-sched-nav__tab"),o===e&&m.classList.add("cal-sched-nav__tab--active"),m.textContent=f[o],m.addEventListener("click",()=>r(o)),p.appendChild(m)}return i.appendChild(d),i.appendChild(p),i}const ot=`
|
|
275
275
|
.cal-sched-nav {
|
|
276
276
|
display: flex;
|
|
277
277
|
align-items: center;
|
|
@@ -359,7 +359,7 @@
|
|
|
359
359
|
background: hsl(var(--cal-accent));
|
|
360
360
|
color: hsl(var(--cal-accent-fg));
|
|
361
361
|
}
|
|
362
|
-
`;function Ye({startTime:t,endTime:e,interval:s,slotHeight:a,format:n}){const
|
|
362
|
+
`;function Ye({startTime:t,endTime:e,interval:s,slotHeight:a,format:n}){const r=document.createElement("div");r.classList.add("cal-sched-time-axis");const l=Le(t,e,s);for(let i=0;i<l.length;i++){const d=l[i],g=oe(d);if(!g)continue;const c=document.createElement("div");if(c.classList.add("cal-sched-time-axis__slot"),c.style.height=`${a}px`,g.minutes===0){const h=document.createElement("span");h.classList.add("cal-sched-time-axis__label"),h.textContent=ue(g.hours,g.minutes,n),c.appendChild(h)}r.appendChild(c)}return r}const dt=`
|
|
363
363
|
.cal-sched-time-axis {
|
|
364
364
|
display: flex;
|
|
365
365
|
flex-direction: column;
|
|
@@ -384,7 +384,7 @@
|
|
|
384
384
|
white-space: nowrap;
|
|
385
385
|
user-select: none;
|
|
386
386
|
}
|
|
387
|
-
`;function
|
|
387
|
+
`;function ht({resource:t,width:e}){const s=document.createElement("div");s.classList.add("cal-sched-resource-header"),e&&(s.style.width=`${e}px`),s.style.flex=e?`0 0 ${e}px`:"1 1 0";const a=document.createElement("span");a.classList.add("cal-sched-resource-header__dot");const n=t.color||"blue";a.style.background=`hsl(var(--cal-booking-${n}-fg))`,s.appendChild(a);const r=document.createElement("span");if(r.classList.add("cal-sched-resource-header__name"),r.textContent=t.name,s.appendChild(r),t.capacity){const l=document.createElement("span");l.classList.add("cal-sched-resource-header__capacity"),l.textContent=t.capacity,l.setAttribute("title",`Capacity: ${t.capacity}`),s.appendChild(l)}return s}function ut({resources:t}){const e=document.createElement("div");e.classList.add("cal-sched-resource-header-row");for(const s of t)e.appendChild(ht({resource:s}));return e}const pt=`
|
|
388
388
|
.cal-sched-resource-header-row {
|
|
389
389
|
display: flex;
|
|
390
390
|
border-bottom: 1px solid hsl(var(--cal-sched-grid-line));
|
|
@@ -428,7 +428,7 @@
|
|
|
428
428
|
border-radius: 999px;
|
|
429
429
|
flex-shrink: 0;
|
|
430
430
|
}
|
|
431
|
-
`;function Ee({event:t,gridStartTime:e,slotHeight:s,interval:a,format:n,onClick:
|
|
431
|
+
`;function Ee({event:t,gridStartTime:e,slotHeight:s,interval:a,format:n,onClick:r,eventContent:l,showTime:i=!0,resource:d,draggable:g}){const c=document.createElement("div");c.classList.add("cal-sched-event"),c.setAttribute("role","button"),c.setAttribute("tabindex","0"),c.dataset.eventId=t.id;const h=!!t.locked;g&&!h&&(c.dataset.draggable="true"),h&&c.classList.add("cal-sched-event--locked");const k=t.color||"blue";if(c.style.setProperty("--ev-bg",`var(--cal-booking-${k}-bg)`),c.style.setProperty("--ev-fg",`var(--cal-booking-${k}-fg)`),t.startTime&&t.endTime){const u=re(t.startTime,e,s,a),p=re(t.endTime,e,s,a),f=Math.max(p-u,s*.5);if(c.style.top=`${u}px`,c.style.height=`${f}px`,t._totalCols>1){const o=100/t._totalCols;c.style.left=`${t._col*o}%`,c.style.width=`${o}%`}}if(typeof l=="function"){const u=l(t,d),p=document.createElement("div");p.classList.add("cal-sched-event__custom"),u instanceof HTMLElement?p.appendChild(u):u!=null&&(p.textContent=String(u)),c.appendChild(p)}else{const u=document.createElement("div");if(u.classList.add("cal-sched-event__title"),u.textContent=t.title||"",c.appendChild(u),i&&t.startTime&&t.endTime){const p=document.createElement("div");p.classList.add("cal-sched-event__time");const f=oe(t.startTime),o=oe(t.endTime);f&&o&&(p.textContent=`${ue(f.hours,f.minutes,n)}–${ue(o.hours,o.minutes,n)}`),c.appendChild(p)}}if(g&&!h){const u=document.createElement("div");u.classList.add("cal-sched-event__resize-handle"),c.appendChild(u)}return r&&(c.addEventListener("click",u=>{if(c.dataset.wasDragged){delete c.dataset.wasDragged;return}u.stopPropagation(),r(t)}),c.addEventListener("keydown",u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),u.stopPropagation(),r(t))})),c}function Be({event:t,onClick:e,eventContent:s,resource:a}){const n=document.createElement("div");n.classList.add("cal-sched-allday-chip"),n.dataset.eventId=t.id;const r=t.color||"blue";if(n.style.setProperty("--ev-bg",`var(--cal-booking-${r}-bg)`),n.style.setProperty("--ev-fg",`var(--cal-booking-${r}-fg)`),typeof s=="function"){const l=s(t,a);l instanceof HTMLElement?n.appendChild(l):l!=null&&(n.textContent=String(l))}else n.textContent=t.title||"";return e&&n.addEventListener("click",l=>{l.stopPropagation(),e(t)}),n}function gt({event:t,format:e,onClick:s,eventContent:a,resource:n}){const r=document.createElement("div");r.classList.add("cal-sched-month-chip"),r.dataset.eventId=t.id;const l=t.color||"blue";if(r.style.setProperty("--ev-bg",`var(--cal-booking-${l}-bg)`),r.style.setProperty("--ev-fg",`var(--cal-booking-${l}-fg)`),typeof a=="function"){const i=a(t,n);i instanceof HTMLElement?r.appendChild(i):i!=null&&(r.textContent=String(i))}else{const i=document.createElement("span");i.classList.add("cal-sched-month-chip__dot"),i.style.background=`hsl(var(--cal-booking-${l}-fg))`,r.appendChild(i);const d=document.createElement("span");if(d.classList.add("cal-sched-month-chip__text"),t.startTime){const g=oe(t.startTime),c=g?ue(g.hours,g.minutes,e):t.startTime;d.textContent=`${c} ${t.title||""}`}else d.textContent=t.title||"";r.appendChild(d)}return s&&r.addEventListener("click",i=>{i.stopPropagation(),s(t)}),r}const mt=`
|
|
432
432
|
.cal-sched-event {
|
|
433
433
|
position: absolute;
|
|
434
434
|
left: 2px;
|
|
@@ -544,7 +544,7 @@
|
|
|
544
544
|
overflow: hidden;
|
|
545
545
|
text-overflow: ellipsis;
|
|
546
546
|
}
|
|
547
|
-
`;function
|
|
547
|
+
`;function _e({date:t,startTime:e,endTime:s,resourceName:a,format:n,onCreate:r}){const l=document.createElement("div");l.classList.add("cal-sched-slot-prompt","cal-animate-fade");const i=document.createElement("div");if(i.classList.add("cal-sched-slot-prompt__info"),e&&s){const g=oe(e),c=oe(s),h=document.createElement("div");h.classList.add("cal-sched-slot-prompt__time"),g&&c&&(h.textContent=`${ue(g.hours,g.minutes,n)}–${ue(c.hours,c.minutes,n)}`),i.appendChild(h)}else{const g=document.createElement("div");g.classList.add("cal-sched-slot-prompt__time"),g.textContent=t,i.appendChild(g)}if(a){const g=document.createElement("div");g.classList.add("cal-sched-slot-prompt__resource"),g.textContent=a,i.appendChild(g)}l.appendChild(i);const d=document.createElement("button");return d.classList.add("cal-sched-slot-prompt__btn"),d.setAttribute("aria-label","Create event"),d.innerHTML='<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M7 3v8M3 7h8"/></svg>',d.addEventListener("click",g=>{g.stopPropagation(),r==null||r()}),l.appendChild(d),l.addEventListener("click",g=>g.stopPropagation()),l}const ft=`
|
|
548
548
|
.cal-sched-slot-prompt {
|
|
549
549
|
position: absolute;
|
|
550
550
|
z-index: 10;
|
|
@@ -608,7 +608,7 @@
|
|
|
608
608
|
background: hsl(var(--cal-accent-subtle));
|
|
609
609
|
box-shadow: inset 0 0 0 1.5px hsl(var(--cal-accent));
|
|
610
610
|
}
|
|
611
|
-
`;function
|
|
611
|
+
`;function vt({date:t,resources:e,events:s,startTime:a,endTime:n,interval:r,slotHeight:l,format:i,layout:d,resourceMode:g,selectedSlot:c,eventContent:h,showTime:k=!0,draggable:u,onSlotClick:p,onEventClick:f,onSlotCreate:o}){const m=document.createElement("div");m.classList.add("cal-sched-day"),d==="horizontal"&&m.classList.add("cal-sched-day--horizontal");const _=g==="tabs",C=e.length>1&&!_,D=be(s,t),F=D.filter(x=>!x.startTime||!x.endTime),X=D.filter(x=>x.startTime&&x.endTime),Y=Le(a,n,r);if(F.length>0){const x=document.createElement("div");x.classList.add("cal-sched-day__allday");const E=document.createElement("div");E.classList.add("cal-sched-day__allday-label"),E.textContent="All day",x.appendChild(E);const Z=document.createElement("div");Z.classList.add("cal-sched-day__allday-chips");for(const N of F){const M=e.find(v=>v.id===N.resourceId);Z.appendChild(Be({event:N,onClick:v=>f==null?void 0:f(v,N.resourceId,M),eventContent:h,resource:M}))}x.appendChild(Z),m.appendChild(x)}if(C){const x=document.createElement("div");x.classList.add("cal-sched-day__header");const E=document.createElement("div");E.classList.add("cal-sched-day__header-spacer"),x.appendChild(E),x.appendChild(ut({resources:e})),m.appendChild(x)}const j=document.createElement("div");j.classList.add("cal-sched-day__grid-area"),j.appendChild(Ye({startTime:a,endTime:n,interval:r,slotHeight:l,format:i}));const P=document.createElement("div");if(P.classList.add("cal-sched-day__lanes"),C)for(const x of e){const E=document.createElement("div");E.classList.add("cal-sched-day__lane"),E.style.flex="1 1 0",E.dataset.resourceId=x.id,E.dataset.date=t;for(let M=0;M<Y.length;M++){const v=document.createElement("div");v.classList.add("cal-sched-day__slot"),v.style.height=`${l}px`,v.dataset.time=Y[M],v.dataset.resourceId=x.id;const I=M<Y.length-1?Y[M+1]:n;c&&c.date===t&&c.startTime===Y[M]&&c.resourceId===x.id&&(v.classList.add("cal-sched-day__slot--selected"),v.appendChild(_e({date:t,startTime:Y[M],endTime:I,resourceName:x.name,format:i,onCreate:()=>o==null?void 0:o(t,Y[M],I,x.id,x)}))),v.addEventListener("click",()=>{p==null||p(t,Y[M],I,x.id,x)}),E.appendChild(v)}const Z=X.filter(M=>M.resourceId===x.id),N=ke(Z);for(const M of N)E.appendChild(Ee({event:M,gridStartTime:a,slotHeight:l,interval:r,format:i,onClick:v=>f==null?void 0:f(v,x.id,x),eventContent:h,showTime:k,resource:x,draggable:u}));P.appendChild(E)}else{const x=document.createElement("div");x.classList.add("cal-sched-day__lane"),x.style.flex="1 1 0",x.dataset.date=t;const E=e.length===1?e[0]:null;E&&(x.dataset.resourceId=E.id);for(let N=0;N<Y.length;N++){const M=document.createElement("div");M.classList.add("cal-sched-day__slot"),M.style.height=`${l}px`,M.dataset.time=Y[N];const v=N<Y.length-1?Y[N+1]:n,I=(E==null?void 0:E.id)||null;c&&c.date===t&&c.startTime===Y[N]&&(c.resourceId===I||!c.resourceId&&!I)&&(M.classList.add("cal-sched-day__slot--selected"),M.appendChild(_e({date:t,startTime:Y[N],endTime:v,resourceName:(E==null?void 0:E.name)||null,format:i,onCreate:()=>o==null?void 0:o(t,Y[N],v,I,E)}))),M.addEventListener("click",()=>{p==null||p(t,Y[N],v,I,E)}),x.appendChild(M)}const Z=ke(X);for(const N of Z){const M=e.find(v=>v.id===N.resourceId)||e[0];x.appendChild(Ee({event:N,gridStartTime:a,slotHeight:l,interval:r,format:i,onClick:v=>f==null?void 0:f(v,N.resourceId,M),eventContent:h,showTime:k,resource:M,draggable:u}))}P.appendChild(x)}j.appendChild(P);const H=ge();if(ye(t,H)){const x=Ie(),E=w(x),Z=w(a),N=w(n);if(E>=Z&&E<=N){const M=re(x,a,l,r),v=document.createElement("div");v.classList.add("cal-sched-now-line"),v.style.top=`${M}px`;const I=document.createElement("div");I.classList.add("cal-sched-now-line__dot"),v.appendChild(I),P.appendChild(v)}}return m.appendChild(j),m}const bt=`
|
|
612
612
|
.cal-sched-day {
|
|
613
613
|
display: flex;
|
|
614
614
|
flex-direction: column;
|
|
@@ -747,7 +747,7 @@
|
|
|
747
747
|
justify-content: center;
|
|
748
748
|
padding: 4px 0;
|
|
749
749
|
}
|
|
750
|
-
`,Te=3,Me=5;function
|
|
750
|
+
`,Te=3,Me=5;function _t({date:t,firstDay:e,resources:s,events:a,startTime:n,endTime:r,interval:l,slotHeight:i,format:d,layout:g,resourceMode:c,selectedSlot:h,eventContent:k,showTime:u=!0,draggable:p,allDayCollapsed:f,onToggleAllDay:o,onSlotClick:m,onEventClick:_,onSlotCreate:C}){const D=document.createElement("div");D.classList.add("cal-sched-week"),g==="horizontal"&&D.classList.add("cal-sched-week--horizontal");const F=Ce(t,e),X=c==="tabs",Y=s.length>1&&!X,j=Le(n,r,l),P=ge(),H={};for(const v of F){const I=be(a,v).filter(W=>!W.startTime||!W.endTime);I.length&&(H[v]=I)}if(Object.keys(H).length>0){const v=document.createElement("div");v.classList.add("cal-sched-week__allday"),f&&v.classList.add("cal-sched-week__allday--collapsed");const I=document.createElement("div");I.classList.add("cal-sched-week__allday-spacer");const W=document.createElement("span");W.textContent="All day",I.appendChild(W);const $=document.createElement("button");$.classList.add("cal-sched-week__allday-toggle"),$.setAttribute("aria-label",f?"Expand all-day events":"Collapse all-day events"),$.innerHTML=f?'<svg width="12" height="12" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M3 5l3 3 3-3"/></svg>':'<svg width="12" height="12" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M3 7l3-3 3 3"/></svg>',$.addEventListener("click",R=>{R.stopPropagation(),o==null||o()}),I.appendChild($),v.appendChild(I);for(const R of F){const G=document.createElement("div");G.classList.add("cal-sched-week__allday-cell");const A=H[R]||[];if(f){if(A.length>0){const T=document.createElement("div");T.classList.add("cal-sched-week__allday-dots");const z=A.slice(0,Me);for(const U of z){const ie=document.createElement("span");ie.classList.add("cal-sched-week__allday-dot");const Se=U.color||"blue";ie.style.background=`hsl(var(--cal-booking-${Se}-fg))`,T.appendChild(ie)}if(A.length>Me){const U=document.createElement("span");U.classList.add("cal-sched-week__allday-overflow"),U.textContent=`+${A.length-Me}`,T.appendChild(U)}G.appendChild(T)}}else{const T=A.slice(0,Te);for(const z of T){const U=s.find(ie=>ie.id===z.resourceId);G.appendChild(Be({event:z,onClick:ie=>_==null?void 0:_(ie,z.resourceId,U),eventContent:k,resource:U}))}if(A.length>Te){const z=document.createElement("span");z.classList.add("cal-sched-week__allday-overflow"),z.textContent=`+${A.length-Te}`,G.appendChild(z)}}v.appendChild(G)}D.appendChild(v)}const E=document.createElement("div");E.classList.add("cal-sched-week__header");const Z=document.createElement("div");Z.classList.add("cal-sched-week__header-spacer"),E.appendChild(Z);for(const v of F){const I=Q(v),W=document.createElement("div");W.classList.add("cal-sched-week__day-header"),ye(v,P)&&W.classList.add("cal-sched-week__day-header--today");const $=document.createElement("span");$.classList.add("cal-sched-week__day-name"),$.textContent=$e(v);const R=document.createElement("span");if(R.classList.add("cal-sched-week__day-num"),ye(v,P)&&R.classList.add("cal-sched-week__day-num--today"),R.textContent=I?I.getDate():"",W.appendChild($),W.appendChild(R),Y){const G=document.createElement("div");G.classList.add("cal-sched-week__res-row");for(const A of s){const T=document.createElement("span");T.classList.add("cal-sched-week__res-label");const z=document.createElement("span");z.classList.add("cal-sched-week__res-dot"),z.style.background=`hsl(var(--cal-booking-${A.color||"blue"}-fg))`,T.appendChild(z),T.appendChild(document.createTextNode(A.name)),G.appendChild(T)}W.appendChild(G)}E.appendChild(W)}D.appendChild(E);const N=document.createElement("div");N.classList.add("cal-sched-week__grid-area"),N.appendChild(Ye({startTime:n,endTime:r,interval:l,slotHeight:i,format:d}));const M=document.createElement("div");M.classList.add("cal-sched-week__cols");for(const v of F){const I=document.createElement("div");I.classList.add("cal-sched-week__day-col"),I.dataset.date=v,ye(v,P)&&I.classList.add("cal-sched-week__day-col--today");const W=be(a,v).filter($=>$.startTime&&$.endTime);if(Y)for(const $ of s){const R=document.createElement("div");R.classList.add("cal-sched-week__lane"),R.dataset.resourceId=$.id;for(let T=0;T<j.length;T++){const z=document.createElement("div");z.classList.add("cal-sched-week__slot"),z.style.height=`${i}px`,z.dataset.time=j[T];const U=T<j.length-1?j[T+1]:r;h&&h.date===v&&h.startTime===j[T]&&h.resourceId===$.id&&(z.classList.add("cal-sched-week__slot--selected"),z.appendChild(_e({date:v,startTime:j[T],endTime:U,resourceName:$.name,format:d,onCreate:()=>C==null?void 0:C(v,j[T],U,$.id,$)}))),z.addEventListener("click",()=>{m==null||m(v,j[T],U,$.id,$)}),R.appendChild(z)}const G=W.filter(T=>T.resourceId===$.id),A=ke(G);for(const T of A)R.appendChild(Ee({event:T,gridStartTime:n,slotHeight:i,interval:l,format:d,onClick:z=>_==null?void 0:_(z,$.id,$),eventContent:k,showTime:u,resource:$,draggable:p}));I.appendChild(R)}else{const $=document.createElement("div");$.classList.add("cal-sched-week__lane","cal-sched-week__lane--full");const R=s.length===1?s[0]:null;R&&($.dataset.resourceId=R.id);for(let A=0;A<j.length;A++){const T=document.createElement("div");T.classList.add("cal-sched-week__slot"),T.style.height=`${i}px`,T.dataset.time=j[A];const z=A<j.length-1?j[A+1]:r,U=(R==null?void 0:R.id)||null;h&&h.date===v&&h.startTime===j[A]&&(h.resourceId===U||!h.resourceId&&!U)&&(T.classList.add("cal-sched-week__slot--selected"),T.appendChild(_e({date:v,startTime:j[A],endTime:z,resourceName:(R==null?void 0:R.name)||null,format:d,onCreate:()=>C==null?void 0:C(v,j[A],z,U,R)}))),T.addEventListener("click",()=>{m==null||m(v,j[A],z,U,R)}),$.appendChild(T)}const G=ke(W);for(const A of G){const T=s.find(z=>z.id===A.resourceId)||s[0];$.appendChild(Ee({event:A,gridStartTime:n,slotHeight:i,interval:l,format:d,onClick:z=>_==null?void 0:_(z,A.resourceId,T),eventContent:k,showTime:u,resource:T,draggable:p}))}I.appendChild($)}M.appendChild(I)}if(F.includes(P)){const v=Ie(),I=w(v),W=w(n),$=w(r);if(I>=W&&I<=$){const R=F.indexOf(P),G=re(v,n,i,l),A=document.createElement("div");A.classList.add("cal-sched-now-line","cal-sched-now-line--week"),A.style.top=`${G}px`;const T=100/7;A.style.left=`${R*T}%`,A.style.width=`${T}%`;const z=document.createElement("div");z.classList.add("cal-sched-now-line__dot"),A.appendChild(z),M.appendChild(A)}}return N.appendChild(M),D.appendChild(N),D}const xt=`
|
|
751
751
|
.cal-sched-week {
|
|
752
752
|
display: flex;
|
|
753
753
|
flex-direction: column;
|
|
@@ -965,7 +965,7 @@
|
|
|
965
965
|
z-index: 5;
|
|
966
966
|
pointer-events: none;
|
|
967
967
|
}
|
|
968
|
-
`,je=3;function
|
|
968
|
+
`,je=3;function yt({date:t,firstDay:e,resources:s,events:a,format:n,selectedResourceId:r,selectedDate:l,eventContent:i,onSlotClick:d,onEventClick:g,onSlotCreate:c}){const h=document.createElement("div");h.classList.add("cal-sched-month");const k=Q(t);if(!k)return h;const u=k.getFullYear(),p=k.getMonth();ge();const f=document.createElement("div");f.classList.add("cal-sched-month__weekdays");const o=Ge(e);for(const C of o){const D=document.createElement("div");D.classList.add("cal-sched-month__weekday"),D.textContent=C,f.appendChild(D)}h.appendChild(f);const m=document.createElement("div");m.classList.add("cal-sched-month__grid");const _=Je(u,p,e);for(const C of _){const D=document.createElement("div");D.classList.add("cal-sched-month__cell"),C.isCurrentMonth||D.classList.add("cal-sched-month__cell--outside"),C.isToday&&D.classList.add("cal-sched-month__cell--today"),l&&C.dateString===l&&D.classList.add("cal-sched-month__cell--selected"),D.addEventListener("click",H=>{H.target.closest(".cal-sched-month-chip")||d==null||d(C.dateString)});const F=document.createElement("div");F.classList.add("cal-sched-month__day-num"),C.isToday&&F.classList.add("cal-sched-month__day-num--today"),F.textContent=C.day,D.appendChild(F);let X=be(a,C.dateString);r&&(X=X.filter(H=>H.resourceId===r)),X.sort((H,x)=>H.startTime&&!x.startTime?-1:!H.startTime&&x.startTime?1:H.startTime&&x.startTime?H.startTime.localeCompare(x.startTime):0);const Y=document.createElement("div");Y.classList.add("cal-sched-month__events");const j=X.slice(0,je),P=X.length-je;for(const H of j){const x=s.find(E=>E.id===H.resourceId);Y.appendChild(gt({event:H,format:n,onClick:E=>g==null?void 0:g(E,H.resourceId,x),eventContent:i,resource:x}))}if(P>0){const H=document.createElement("div");H.classList.add("cal-sched-month__more"),H.textContent=`+${P} more`,Y.appendChild(H)}D.appendChild(Y),l&&C.dateString===l&&(D.style.position="relative",D.appendChild(_e({date:C.dateString,startTime:null,endTime:null,resourceName:null,format:n,onCreate:()=>c==null?void 0:c(C.dateString)}))),m.appendChild(D)}return h.appendChild(m),h}const wt=`
|
|
969
969
|
.cal-sched-month {
|
|
970
970
|
border: 1px solid hsl(var(--cal-sched-grid-line));
|
|
971
971
|
border-radius: var(--cal-radius);
|
|
@@ -1049,7 +1049,7 @@
|
|
|
1049
1049
|
.cal-sched-month__more:hover {
|
|
1050
1050
|
color: hsl(var(--cal-fg));
|
|
1051
1051
|
}
|
|
1052
|
-
`;function
|
|
1052
|
+
`;function kt({columns:t=3,rows:e=10,slotHeight:s=48}={}){const a=document.createElement("div");a.setAttribute("role","status"),a.setAttribute("aria-label","Loading..."),a.classList.add("cal-sched-skeleton-grid");const n=document.createElement("div");n.classList.add("cal-sched-skeleton-grid__header");const r=document.createElement("div");r.classList.add("cal-sched-skeleton-grid__spacer"),n.appendChild(r);for(let i=0;i<t;i++){const d=document.createElement("div");d.classList.add("cal-skeleton","cal-sched-skeleton-grid__col-header"),n.appendChild(d)}a.appendChild(n);const l=document.createElement("div");l.classList.add("cal-sched-skeleton-grid__body");for(let i=0;i<e;i++){const d=document.createElement("div");d.classList.add("cal-sched-skeleton-grid__row"),d.style.height=`${s}px`;const g=document.createElement("div");g.classList.add("cal-skeleton","cal-sched-skeleton-grid__time"),d.appendChild(g);for(let c=0;c<t;c++){const h=document.createElement("div");if(h.classList.add("cal-sched-skeleton-grid__cell"),Math.random()<.15){const k=document.createElement("div");k.classList.add("cal-skeleton","cal-skeleton--rect","cal-sched-skeleton-grid__event"),k.style.height=`${s*(1+Math.floor(Math.random()*2))}px`,h.appendChild(k)}d.appendChild(h)}l.appendChild(d)}return a.appendChild(l),a}function Et(){const t=document.createElement("div");t.setAttribute("role","status"),t.setAttribute("aria-label","Loading..."),t.classList.add("cal-sched-skeleton-month");const e=document.createElement("div");e.classList.add("cal-sched-skeleton-month__weekdays");for(let a=0;a<7;a++){const n=document.createElement("div");n.classList.add("cal-skeleton","cal-sched-skeleton-month__weekday"),e.appendChild(n)}t.appendChild(e);const s=document.createElement("div");s.classList.add("cal-sched-skeleton-month__grid");for(let a=0;a<35;a++){const n=document.createElement("div");n.classList.add("cal-sched-skeleton-month__cell");const r=document.createElement("div");r.classList.add("cal-skeleton","cal-sched-skeleton-month__num"),n.appendChild(r);const l=Math.floor(Math.random()*3);for(let i=0;i<l;i++){const d=document.createElement("div");d.classList.add("cal-skeleton","cal-skeleton--rect","cal-sched-skeleton-month__chip"),n.appendChild(d)}s.appendChild(n)}return t.appendChild(s),t}const Lt=`
|
|
1053
1053
|
.cal-sched-skeleton-grid {
|
|
1054
1054
|
border: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1055
1055
|
border-radius: var(--cal-radius);
|
|
@@ -1153,7 +1153,7 @@
|
|
|
1153
1153
|
margin-bottom: 2px;
|
|
1154
1154
|
width: 85%;
|
|
1155
1155
|
}
|
|
1156
|
-
`,Ne={error:'<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><circle cx="7" cy="7" r="6"/><path d="M7 4v3M7 9.5v.01"/></svg>',warning:'<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><path d="M7 1.5L1 12.5h12L7 1.5zM7 6v2.5M7 10.5v.01"/></svg>',info:'<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><circle cx="7" cy="7" r="6"/><path d="M7 6.5V10M7 4.5v.01"/></svg>',success:'<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><circle cx="7" cy="7" r="6"/><path d="M4.5 7l2 2L9.5 5"/></svg>'};function
|
|
1156
|
+
`,Ne={error:'<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><circle cx="7" cy="7" r="6"/><path d="M7 4v3M7 9.5v.01"/></svg>',warning:'<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><path d="M7 1.5L1 12.5h12L7 1.5zM7 6v2.5M7 10.5v.01"/></svg>',info:'<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><circle cx="7" cy="7" r="6"/><path d="M7 6.5V10M7 4.5v.01"/></svg>',success:'<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><circle cx="7" cy="7" r="6"/><path d="M4.5 7l2 2L9.5 5"/></svg>'};function Ct({type:t="info",message:e,dismissible:s=!0,onDismiss:a}){const n=document.createElement("div");n.classList.add("cal-status",`cal-status--${t}`,"cal-animate-slide-up"),n.setAttribute("role",t==="error"?"alert":"status"),n.setAttribute("aria-live",t==="error"?"assertive":"polite");const r=document.createElement("span");r.classList.add("cal-status__icon"),r.innerHTML=Ne[t]||Ne.info,n.appendChild(r);const l=document.createElement("span");if(l.classList.add("cal-status__text"),l.textContent=e,n.appendChild(l),s){const i=document.createElement("button");i.classList.add("cal-status__close"),i.setAttribute("aria-label","Dismiss"),i.innerHTML='<svg width="12" height="12" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><path d="M3 3l6 6M9 3l-6 6"/></svg>',i.addEventListener("click",()=>a==null?void 0:a()),n.appendChild(i)}return n}const Tt=`
|
|
1157
1157
|
.cal-status {
|
|
1158
1158
|
display: flex;
|
|
1159
1159
|
align-items: center;
|
|
@@ -1215,7 +1215,7 @@
|
|
|
1215
1215
|
color: hsl(var(--cal-status-success-fg));
|
|
1216
1216
|
border: 1px solid hsl(var(--cal-status-success-border));
|
|
1217
1217
|
}
|
|
1218
|
-
`;function
|
|
1218
|
+
`;function Mt({event:t,resource:e,format:s,onClose:a,actions:n,onAction:r}){const l=document.createElement("div");l.classList.add("cal-sched-detail-backdrop"),l.addEventListener("click",a);const i=document.createElement("div");i.classList.add("cal-sched-detail","cal-animate-fade"),i.addEventListener("click",u=>u.stopPropagation());const d=document.createElement("button");d.classList.add("cal-sched-detail__close"),d.setAttribute("aria-label","Close"),d.innerHTML='<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><path d="M4 4l6 6M10 4l-6 6"/></svg>',d.addEventListener("click",a),i.appendChild(d);const g=t.color||"blue",c=document.createElement("div");c.classList.add("cal-sched-detail__accent"),c.style.background=`hsl(var(--cal-booking-${g}-fg))`,i.appendChild(c);const h=document.createElement("div");if(h.classList.add("cal-sched-detail__title"),h.textContent=t.title||"Untitled",i.appendChild(h),t.startTime&&t.endTime){const u=document.createElement("div");u.classList.add("cal-sched-detail__row");const p=document.createElement("span");p.classList.add("cal-sched-detail__icon"),p.innerHTML='<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><circle cx="7" cy="7" r="5.5"/><path d="M7 4v3.5l2.5 1.5"/></svg>',u.appendChild(p);const f=oe(t.startTime),o=oe(t.endTime),m=document.createElement("span");f&&o&&(m.textContent=`${ue(f.hours,f.minutes,s)}–${ue(o.hours,o.minutes,s)}`),u.appendChild(m),i.appendChild(u)}if(t.start){const u=document.createElement("div");u.classList.add("cal-sched-detail__row");const p=document.createElement("span");p.classList.add("cal-sched-detail__icon"),p.innerHTML='<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><rect x="1.5" y="2.5" width="11" height="9.5" rx="1.5"/><path d="M4.5 1v2.5M9.5 1v2.5M1.5 5.5h11"/></svg>',u.appendChild(p);const f=Q(t.start),o=document.createElement("span");if(f){let m=`${$e(t.start,"long")}, ${xe[f.getMonth()]} ${f.getDate()}`;if(t.end&&t.end!==t.start){const _=Q(t.end);_&&(m+=` – ${xe[_.getMonth()]} ${_.getDate()}`)}o.textContent=m}u.appendChild(o),i.appendChild(u)}if(e&&e.name){const u=document.createElement("div");u.classList.add("cal-sched-detail__row");const p=document.createElement("span");p.classList.add("cal-sched-detail__res-dot"),p.style.background=`hsl(var(--cal-booking-${e.color||"blue"}-fg))`,u.appendChild(p);const f=document.createElement("span");f.textContent=e.name,e.capacity&&(f.textContent+=` (capacity: ${e.capacity})`),u.appendChild(f),i.appendChild(u)}if(t.metadata&&typeof t.metadata=="object"){const u=Object.entries(t.metadata);if(u.length>0){const p=document.createElement("div");p.classList.add("cal-sched-detail__meta");for(const[f,o]of u){const m=document.createElement("div");m.classList.add("cal-sched-detail__meta-row");const _=document.createElement("span");_.classList.add("cal-sched-detail__meta-label"),_.textContent=f;const C=document.createElement("span");C.textContent=String(o),m.appendChild(_),m.appendChild(C),p.appendChild(m)}i.appendChild(p)}}if(n&&n.length>0){const u=document.createElement("div");u.classList.add("cal-sched-detail__actions");for(const p of n){const f=document.createElement("button");f.classList.add("cal-sched-detail__action"),p.type==="danger"&&f.classList.add("cal-sched-detail__action--danger"),f.textContent=p.label,f.addEventListener("click",()=>{r==null||r(p.label)}),u.appendChild(f)}i.appendChild(u)}l.appendChild(i);const k=u=>{u.key==="Escape"&&a()};return l.addEventListener("keydown",k),requestAnimationFrame(()=>d.focus()),l}const St=`
|
|
1219
1219
|
.cal-sched-detail-backdrop {
|
|
1220
1220
|
position: absolute;
|
|
1221
1221
|
inset: 0;
|
|
@@ -1353,7 +1353,7 @@
|
|
|
1353
1353
|
.cal-sched-detail__action--danger:hover {
|
|
1354
1354
|
background: hsl(var(--cal-status-error-bg));
|
|
1355
1355
|
}
|
|
1356
|
-
`;function
|
|
1356
|
+
`;function Dt({resources:t,selectedResourceId:e,onResourceFilter:s}){const a=document.createElement("div");a.classList.add("cal-sched-res-tabs");const n=document.createElement("button");n.classList.add("cal-sched-res-tabs__tab"),e||n.classList.add("cal-sched-res-tabs__tab--active"),n.textContent="All",n.addEventListener("click",()=>s==null?void 0:s(null)),a.appendChild(n);for(const r of t){const l=document.createElement("button");l.classList.add("cal-sched-res-tabs__tab"),e===r.id&&l.classList.add("cal-sched-res-tabs__tab--active");const i=document.createElement("span");i.classList.add("cal-sched-res-tabs__dot"),i.style.background=`hsl(var(--cal-booking-${r.color||"blue"}-fg))`,l.appendChild(i),l.appendChild(document.createTextNode(r.name)),l.addEventListener("click",()=>s==null?void 0:s(r.id)),a.appendChild(l)}return a}const $t=`
|
|
1357
1357
|
.cal-sched-res-tabs {
|
|
1358
1358
|
display: flex;
|
|
1359
1359
|
gap: 4px;
|
|
@@ -1397,7 +1397,7 @@
|
|
|
1397
1397
|
height: 6px;
|
|
1398
1398
|
border-radius: 50%;
|
|
1399
1399
|
}
|
|
1400
|
-
`;function
|
|
1400
|
+
`;function At({onClick:t}){const e=document.createElement("button");return e.classList.add("cal-sched-fab"),e.setAttribute("aria-label","Create event"),e.innerHTML='<svg width="20" height="20" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M10 4v12M4 10h12"/></svg>',e.addEventListener("click",s=>{s.stopPropagation(),t==null||t()}),e}const It=`
|
|
1401
1401
|
.cal-sched-fab {
|
|
1402
1402
|
position: absolute;
|
|
1403
1403
|
bottom: 16px;
|
|
@@ -1429,7 +1429,7 @@
|
|
|
1429
1429
|
outline: 2px solid hsl(var(--cal-ring));
|
|
1430
1430
|
outline-offset: 2px;
|
|
1431
1431
|
}
|
|
1432
|
-
`,
|
|
1432
|
+
`,zt=4;function Pt({shadowRoot:t,getConfig:e,getViewInfo:s,getEvents:a,onMove:n,onResize:r,onCreate:l}){let i=!1,d=null,g=null,c=null,h=null,k=0,u=0,p=0,f=0,o=!1,m=null,_=null,C=null,D=null,F=null,X=null,Y=null,j=null,P=null,H=null,x=null,E=null,Z=0;function N(b){if(!i||b.button!==0)return;const L=b.target.closest(".cal-sched-event__resize-handle"),S=b.target.closest('.cal-sched-event[data-draggable="true"]');if(S){const O=S.dataset.eventId;if(g=a().find(B=>B.id===O),!g)return;b.preventDefault(),b.stopPropagation(),j=S,Y=b.pointerId,S.setPointerCapture(b.pointerId),p=b.clientX,f=b.clientY,o=!1,_=g.startTime,m=g.endTime,C=g.start,D=g.resourceId,L?(d="resize",h=S,h.classList.add("cal-sched-event--resizing")):(d="move",h=S)}else{const O=b.target.closest("[data-time]");if(!O||b.target.closest(".cal-sched-slot-prompt"))return;const y=I(b.clientX,b.clientY);if(!y)return;b.preventDefault(),d="create",p=b.clientX,f=b.clientY,o=!1,H=y.date,x=y.resourceId,E=y.time;const B=t.querySelectorAll("[data-time]");B.length>0&&(Z=B[0].getBoundingClientRect().top),j=O,Y=b.pointerId,O.setPointerCapture(b.pointerId)}t.addEventListener("pointermove",M),t.addEventListener("pointerup",v)}function M(b){if(!d)return;const L=b.clientX-p,S=b.clientY-f,O=Math.sqrt(L*L+S*S);if(!(!o&&O<zt)){if(o=!0,d==="move"){if(!c&&h){const B=h.getBoundingClientRect();k=p-B.left,u=f-B.top,c=h.cloneNode(!0),c.classList.add("cal-sched-event--ghost"),c.style.cssText=`
|
|
1433
1433
|
position: fixed;
|
|
1434
1434
|
width: ${B.width}px;
|
|
1435
1435
|
height: ${B.height}px;
|
|
@@ -1447,7 +1447,7 @@
|
|
|
1447
1447
|
font-size: 12px;
|
|
1448
1448
|
line-height: 1.3;
|
|
1449
1449
|
overflow: hidden;
|
|
1450
|
-
`,c.style.setProperty("--ev-bg",
|
|
1450
|
+
`,c.style.setProperty("--ev-bg",h.style.getPropertyValue("--ev-bg")),c.style.setProperty("--ev-fg",h.style.getPropertyValue("--ev-fg")),t.appendChild(c),h.classList.add("cal-sched-event--dragging")}c&&(c.style.left=`${b.clientX-k}px`,c.style.top=`${b.clientY-u}px`);const y=I(b.clientX,b.clientY);y?W(y):$()}else if(d==="resize"){const y=e(),B=y.snapInterval||y.interval,ee=y.slotHeight*(B/y.interval),ae=b.clientY-f,q=Math.round(ae/ee)*B,pe=w(m),ce=w(_);let K=pe+q;const te=y.minDuration||B,se=ce+te;if(K<se&&(K=se),y.maxDuration){const de=ce+y.maxDuration;K>de&&(K=de)}const V=w(y.endTime);K>V&&(K=V);const ne=le(K);if(h){const de=re(_,y.startTime,y.slotHeight,y.interval),De=re(ne,y.startTime,y.slotHeight,y.interval);h.style.height=`${Math.max(De-de,y.slotHeight*.5)}px`}G(b.clientX,b.clientY,ne,y.format)}else if(d==="create"){const y=e(),B=y.snapInterval||y.interval,ee=b.clientY-Z,ae=ze(Math.max(0,ee),y.startTime,y.slotHeight,y.interval),J=Pe(ae,B),q=w(J),pe=w(E),ce=w(y.endTime),K=y.minDuration||B;let te=Math.max(q,pe+K);if(y.maxDuration){const V=pe+y.maxDuration;te>V&&(te=V)}te>ce&&(te=ce);const se=le(te);if(!P){P=document.createElement("div"),P.classList.add("cal-sched-create-preview");let V=null;x&&(V=t.querySelector(`[data-resource-id="${x}"][data-date="${H}"]`),V||(V=t.querySelector(`[data-date="${H}"] [data-resource-id="${x}"]`))),V||(V=t.querySelector(`[data-date="${H}"] .cal-sched-week__lane`)||t.querySelector(`[data-date="${H}"] .cal-sched-day__lane`)||t.querySelector(`[data-date="${H}"]`)),V&&V.appendChild(P)}if(P){const V=e(),ne=re(E,V.startTime,V.slotHeight,V.interval),de=re(se,V.startTime,V.slotHeight,V.interval);P.style.top=`${ne}px`,P.style.height=`${Math.max(de-ne,V.slotHeight*.5)}px`,P.dataset.endTime=se}G(b.clientX,b.clientY,se,y.format)}}}function v(b){if(d){if(t.removeEventListener("pointermove",M),t.removeEventListener("pointerup",v),j&&Y!=null){try{j.releasePointerCapture(Y)}catch{}j=null,Y=null}if(d==="move"){if($(),c&&(c.remove(),c=null),h&&h.classList.remove("cal-sched-event--dragging"),o){h&&(h.dataset.wasDragged="true");const L=I(b.clientX,b.clientY);if(L&&g){const S=e(),O=w(m)-w(_),y=L.time,B=w(y),ee=Math.min(B+O,w(S.endTime)),ae=le(ee),J={date:C,startTime:_,endTime:m,resourceId:D},q={date:L.date,startTime:y,endTime:ae,resourceId:L.resourceId||D};(J.date!==q.date||J.startTime!==q.startTime||J.resourceId!==q.resourceId)&&(n==null||n({event:g,from:J,to:q}))}}}else if(d==="resize"){if(o){const L=e(),S=L.snapInterval||L.interval,O=L.slotHeight*(S/L.interval),y=b.clientY-f,ee=Math.round(y/O)*S,ae=w(m),J=w(_);let q=ae+ee;const pe=L.minDuration||S,ce=J+pe;if(q<ce&&(q=ce),L.maxDuration){const se=J+L.maxDuration;q>se&&(q=se)}const K=w(L.endTime);q>K&&(q=K);const te=le(q);h&&(h.dataset.wasDragged="true"),te!==m&&g&&(r==null||r({event:g,from:{endTime:m},to:{endTime:te}}))}h&&h.classList.remove("cal-sched-event--resizing"),A()}else if(d==="create"){A();const L=(P==null?void 0:P.dataset.endTime)||null;P&&(P.remove(),P=null),o&&H&&E&&L&&(l==null||l({date:H,startTime:E,endTime:L,resourceId:x})),H=null,x=null,E=null,Z=0}d=null,g=null,h=null,k=0,u=0,p=0,f=0,o=!1,m=null,_=null,C=null,D=null}}function I(b,L){const S=e(),O=t.querySelectorAll("[data-date]");let y=null,B=null;for(const ne of O){const de=ne.getBoundingClientRect();if(b>=de.left&&b<=de.right){if(y=ne.dataset.date,ne.dataset.resourceId)B=ne.dataset.resourceId;else{const De=ne.querySelectorAll("[data-resource-id]");for(const Fe of De){const Ve=Fe.getBoundingClientRect();if(b>=Ve.left&&b<=Ve.right){B=Fe.dataset.resourceId;break}}}break}}if(!y)return null;const ee=t.querySelectorAll("[data-time]");if(ee.length===0)return null;const J=ee[0].getBoundingClientRect().top,q=L-J;if(q<0)return null;const pe=S.snapInterval||S.interval,ce=ze(q,S.startTime,S.slotHeight,S.interval),K=Pe(ce,pe),te=w(K),se=w(S.startTime),V=w(S.endTime);return te<se||te>=V?null:{date:y,time:K,resourceId:B}}function W(b){$();const L=e();let S=L.interval;g&&_&&m&&(S=w(m)-w(_));let y=w(b.time)+S;const B=w(L.endTime);y>B&&(y=B);const ee=le(y);let ae=R(b.date,b.resourceId);if(!ae)return;X=document.createElement("div"),X.classList.add("cal-sched-drop-preview");const J=re(b.time,L.startTime,L.slotHeight,L.interval),q=re(ee,L.startTime,L.slotHeight,L.interval);X.style.top=`${J}px`,X.style.height=`${Math.max(q-J,L.slotHeight*.5)}px`,ae.appendChild(X)}function $(){X&&(X.remove(),X=null)}function R(b,L){if(L){let O=t.querySelector(`[data-resource-id="${L}"][data-date="${b}"]`);if(O||(O=t.querySelector(`[data-date="${b}"] [data-resource-id="${L}"]`)),O)return O}const S=t.querySelector(`[data-date="${b}"]`);return S?S.querySelector(".cal-sched-week__lane")||S.querySelector(".cal-sched-day__lane")||S:null}function G(b,L,S,O){F||(F=document.createElement("div"),F.classList.add("cal-sched-drag-time-label"),t.appendChild(F));const{hours:y,minutes:B}=T(S),ee=O==="12h"?z(y,B):S;F.textContent=ee,F.style.left=`${b+12}px`,F.style.top=`${L-8}px`}function A(){F&&(F.remove(),F=null)}function T(b){const[L,S]=b.split(":").map(Number);return{hours:L,minutes:S}}function z(b,L){const S=b>=12?"PM":"AM";return`${b%12||12}:${String(L).padStart(2,"0")} ${S}`}function U(){i||(i=!0,t.addEventListener("pointerdown",N))}function ie(){i=!1,t.removeEventListener("pointerdown",N),t.removeEventListener("pointermove",M),t.removeEventListener("pointerup",v),Se()}function Se(){c&&(c.remove(),c=null),P&&(P.remove(),P=null),h&&(h.classList.remove("cal-sched-event--dragging","cal-sched-event--resizing"),h=null),$(),A(),d=null,g=null,o=!1}function Bt(){ie()}return{enable:U,disable:ie,destroy:Bt}}const Ht=`
|
|
1451
1451
|
[data-draggable="true"] {
|
|
1452
1452
|
cursor: grab;
|
|
1453
1453
|
}
|
|
@@ -1532,7 +1532,7 @@
|
|
|
1532
1532
|
z-index: 1001;
|
|
1533
1533
|
white-space: nowrap;
|
|
1534
1534
|
}
|
|
1535
|
-
`,
|
|
1535
|
+
`,Yt=`
|
|
1536
1536
|
.cal-sched {
|
|
1537
1537
|
background: hsl(var(--cal-bg));
|
|
1538
1538
|
border-radius: var(--cal-radius);
|
|
@@ -1543,5 +1543,5 @@
|
|
|
1543
1543
|
.cal-sched__body {
|
|
1544
1544
|
position: relative;
|
|
1545
1545
|
}
|
|
1546
|
-
`;class Re extends be{static get styles(){return[tt,at,st,it,ct,ht,pt,ft,bt,xt,kt,Lt,Tt,St,gt,$t,At,Pt]}static get observedAttributes(){return["theme","view","layout","date","start-time","end-time","interval","format","first-day","loading","slot-height","resource-mode","show-event-time","show-fab","draggable-events","snap-interval","min-duration","max-duration"]}constructor(){super(),this._store=qe({view:"week",anchorDate:me(),layout:"vertical",selectedResourceId:null,selectedSlot:null,detailEvent:null,detailResource:null,statusType:null,statusMessage:null,statusDismissible:!0,allDayCollapsed:!1}),this._resources=[],this._events=[],this._eventActions=[],this._eventContent=null,this._unsubscribe=null,this._rendering=!1,this._nowTimer=null,this._dragManager=null}get view(){return this.getAttribute("view")||this._store.get("view")}get layout(){return this.getAttribute("layout")||this._store.get("layout")}get startTime(){return this.getAttribute("start-time")||"08:00"}get endTime(){return this.getAttribute("end-time")||"18:00"}get interval(){return parseInt(this.getAttribute("interval")||"30",10)}get format(){return this.getAttribute("format")||"24h"}get firstDay(){return parseInt(this.getAttribute("first-day")||"0",10)}get slotHeight(){return parseInt(this.getAttribute("slot-height")||"48",10)}get resourceMode(){return this.getAttribute("resource-mode")||"tabs"}get loading(){return this.hasAttribute("loading")}set loading(e){e?this.setAttribute("loading",""):this.removeAttribute("loading")}get showEventTime(){return this.getAttribute("show-event-time")!=="false"}get showFab(){return this.hasAttribute("show-fab")}get draggableEvents(){return this.hasAttribute("draggable-events")}get snapInterval(){const e=this.getAttribute("snap-interval");return e?parseInt(e,10):null}get minDuration(){const e=this.getAttribute("min-duration");return e?parseInt(e,10):null}get maxDuration(){const e=this.getAttribute("max-duration");return e?parseInt(e,10):null}get resources(){return this._resources}set resources(e){this._resources=Array.isArray(e)?e:[],this._initialized&&this.render()}get events(){return this._events}set events(e){this._events=Array.isArray(e)?e:[],this._initialized&&this.render()}get eventActions(){return this._eventActions}set eventActions(e){this._eventActions=Array.isArray(e)?e:[],this._initialized&&this.render()}get eventContent(){return this._eventContent}set eventContent(e){this._eventContent=typeof e=="function"?e:null,this._initialized&&this.render()}get value(){return this._lastSlotValue||null}connectedCallback(){const e=this.getAttribute("date");e&&this._store.set({anchorDate:e});const s=this.getAttribute("view");s&&this._store.set({view:s});const a=this.getAttribute("layout");a&&this._store.set({layout:a}),super.connectedCallback(),this._unsubscribe=this._store.subscribe(()=>{this._rendering||this.render()}),this._nowTimer=setInterval(()=>{const n=this._store.get("view");(n==="day"||n==="week")&&this.render()},6e4),this.draggableEvents&&this._initDrag()}disconnectedCallback(){var e;(e=this._unsubscribe)==null||e.call(this),clearInterval(this._nowTimer),clearTimeout(this._statusTimer),this._destroyDrag(),this._escHandler&&(document.removeEventListener("keydown",this._escHandler),this._escHandler=null)}attributeChangedCallback(e,s,a){if(s!==a){if(e==="date"&&a){this._store.set({anchorDate:a});return}if(e==="view"&&a){this._store.set({view:a});return}if(e==="layout"&&a){this._store.set({layout:a});return}e==="draggable-events"&&(a!==null?this._initDrag():this._destroyDrag()),this._initialized&&this.render()}}goToDate(e){this._store.set({anchorDate:e}),this.emit("cal:date-change",{date:e,view:this._store.get("view")})}setView(e){["day","week","month"].includes(e)&&(this._store.set({view:e}),this.emit("cal:view-change",{view:e,date:this._store.get("anchorDate")}))}today(){this.goToDate(me())}next(){const e=this._store.getState(),s=Q(e.anchorDate);if(!s)return;let a;if(e.view==="day")a=ve(e.anchorDate,1);else if(e.view==="week")a=ve(e.anchorDate,7);else{const{year:n,month:l}=we(s.getFullYear(),s.getMonth(),1);a=ue(new Date(n,l,1))}this._store.set({anchorDate:a}),this.emit("cal:date-change",{date:a,view:e.view})}prev(){const e=this._store.getState(),s=Q(e.anchorDate);if(!s)return;let a;if(e.view==="day")a=ve(e.anchorDate,-1);else if(e.view==="week")a=ve(e.anchorDate,-7);else{const{year:n,month:l}=we(s.getFullYear(),s.getMonth(),-1);a=ue(new Date(n,l,1))}this._store.set({anchorDate:a}),this.emit("cal:date-change",{date:a,view:e.view})}findAvailableSlot(e){return et(e,this._resources,this._events,this.interval,this.startTime,this.endTime)}isSlotAvailable(e,s,a,n){return He(this._events,n,e,s,a)}_handleSlotClick(e,s,a,n,l){this._lastSlotValue={date:e,startTime:s,endTime:a,resourceId:n,resource:l},this._store.set({selectedSlot:{date:e,startTime:s,endTime:a,resourceId:n,resource:l}}),this.emit("cal:slot-select",{date:e,startTime:s,endTime:a,resourceId:n,resource:l})}_handleSlotCreate(e,s,a,n,l){this.emit("cal:slot-create",{date:e,startTime:s,endTime:a,resourceId:n,resource:l})}_dismissSlot(){this._store.set({selectedSlot:null})}_handleEventClick(e,s,a){this._dismissSlot(),this._store.set({detailEvent:e,detailResource:a||null}),this.emit("cal:event-click",{event:e,resourceId:s,resource:a})}_closeDetail(){this._store.set({detailEvent:null,detailResource:null})}_handleViewChange(e){this._dismissSlot(),this.setView(e)}_handleResourceFilter(e){this._dismissSlot(),this._store.set({selectedResourceId:e})}_handleEventAction(e){const s=this._store.getState(),a=s.detailEvent,n=s.detailResource;this.emit("cal:event-action",{action:e,event:a,resourceId:a==null?void 0:a.resourceId,resource:n})}_initDrag(){this._dragManager||(this._dragManager=zt({shadowRoot:this.shadowRoot,getConfig:()=>({slotHeight:this.slotHeight,interval:this.interval,startTime:this.startTime,endTime:this.endTime,format:this.format,snapInterval:this.snapInterval,minDuration:this.minDuration,maxDuration:this.maxDuration}),getViewInfo:()=>{const e=this._store.getState();return{view:e.view,anchorDate:e.anchorDate,weekDates:Ce(e.anchorDate,this.firstDay),resources:this._resources.length>0?this._resources:[{id:"__default",name:""}],resourceMode:this.resourceMode,selectedResourceId:e.selectedResourceId}},getEvents:()=>this._events,onMove:e=>{this.emit("cal:event-move",e)},onResize:e=>{this.emit("cal:event-resize",e)},onCreate:e=>{const s=this._resources.find(a=>a.id===e.resourceId)||null;this.emit("cal:slot-create",{...e,resource:s})}}),this._dragManager.enable())}_destroyDrag(){this._dragManager&&(this._dragManager.destroy(),this._dragManager=null)}_handleFabClick(){const e=this._store.getState();this.emit("cal:fab-create",{date:e.anchorDate,view:e.view})}render(){var v;if(this._rendering)return;this._rendering=!0;const e=this.shadowRoot,s=[...e.childNodes];for(const h of s)h.nodeName!=="STYLE"&&!(h instanceof CSSStyleSheet)&&e.removeChild(h);const a=this._store.getState(),n=document.createElement("div");n.classList.add("cal-sched"),a.statusType&&a.statusMessage&&n.appendChild(Et({type:a.statusType,message:a.statusMessage,dismissible:a.statusDismissible,onDismiss:()=>this.clearStatus()}));const l=a.view,r=a.anchorDate,i=Ce(r,this.firstDay),d=Ke(l,r,i),g=this.resourceMode;n.appendChild(rt({title:d,view:l,onPrev:()=>this.prev(),onNext:()=>this.next(),onToday:()=>this.today(),onViewChange:h=>this._handleViewChange(h)}));const c=this._resources.length>0?this._resources:[{id:"__default",name:""}],o=g==="tabs"&&c.length>1&&c[0].id!=="__default";o&&!this.loading&&n.appendChild(Mt({resources:c,selectedResourceId:a.selectedResourceId,onResourceFilter:h=>this._handleResourceFilter(h)}));let k=this._events;o&&a.selectedResourceId&&(k=this._events.filter(h=>h.resourceId===a.selectedResourceId));let u=c;if(o&&a.selectedResourceId){const h=c.find(m=>m.id===a.selectedResourceId);h&&(u=[h])}const p=document.createElement("div");if(p.classList.add("cal-sched__body"),this.loading)if(l==="month")p.appendChild(wt());else{const h=l==="week"?7:Math.max(this._resources.length,1);p.appendChild(yt({columns:h,rows:Math.ceil((y(this.endTime)-y(this.startTime))/this.interval),slotHeight:this.slotHeight}))}else l==="day"?p.appendChild(mt({date:r,resources:u,events:k,startTime:this.startTime,endTime:this.endTime,interval:this.interval,slotHeight:this.slotHeight,format:this.format,layout:a.layout,resourceMode:g,selectedSlot:a.selectedSlot,eventContent:this._eventContent,showTime:this.showEventTime,draggable:this.draggableEvents,onSlotClick:(h,m,w,T,D)=>this._handleSlotClick(h,m,w,T,D),onEventClick:(h,m,w)=>this._handleEventClick(h,m,w),onSlotCreate:(h,m,w,T,D)=>this._handleSlotCreate(h,m,w,T,D)})):l==="week"?p.appendChild(vt({date:r,firstDay:this.firstDay,resources:u,events:k,startTime:this.startTime,endTime:this.endTime,interval:this.interval,slotHeight:this.slotHeight,format:this.format,layout:a.layout,resourceMode:g,selectedSlot:a.selectedSlot,eventContent:this._eventContent,showTime:this.showEventTime,draggable:this.draggableEvents,allDayCollapsed:a.allDayCollapsed,onToggleAllDay:()=>this._store.set({allDayCollapsed:!a.allDayCollapsed}),onSlotClick:(h,m,w,T,D)=>this._handleSlotClick(h,m,w,T,D),onEventClick:(h,m,w)=>this._handleEventClick(h,m,w),onSlotCreate:(h,m,w,T,D)=>this._handleSlotCreate(h,m,w,T,D)})):l==="month"&&p.appendChild(_t({date:r,firstDay:this.firstDay,resources:u,events:k,format:this.format,selectedResourceId:a.selectedResourceId,selectedDate:((v=a.selectedSlot)==null?void 0:v.date)||null,eventContent:this._eventContent,onSlotClick:h=>this._handleSlotClick(h,null,null,null,null),onEventClick:(h,m,w)=>this._handleEventClick(h,m,w),onSlotCreate:h=>this._handleSlotCreate(h,null,null,null,null)}));n.appendChild(p),a.detailEvent&&p.appendChild(Ct({event:a.detailEvent,resource:a.detailResource,format:this.format,onClose:()=>this._closeDetail(),actions:this._eventActions,onAction:h=>this._handleEventAction(h)})),this.showFab&&!this.loading&&p.appendChild(Dt({onClick:()=>this._handleFabClick()})),e.appendChild(n),this._escHandler||(this._escHandler=h=>{h.key==="Escape"&&this._store.get("selectedSlot")&&this._dismissSlot()},this.shadowRoot.addEventListener("keydown",this._escHandler),document.addEventListener("keydown",this._escHandler)),this._rendering=!1}}customElements.get("cal-scheduler")||customElements.define("cal-scheduler",Re),fe.CalScheduler=Re,Object.defineProperty(fe,Symbol.toStringTag,{value:"Module"})}));
|
|
1546
|
+
`;class Re extends ve{static get styles(){return[st,nt,lt,ot,dt,pt,mt,bt,xt,wt,Lt,Tt,St,$t,ft,It,Ht,Yt]}static get observedAttributes(){return["theme","view","layout","date","start-time","end-time","interval","format","first-day","loading","slot-height","resource-mode","show-event-time","show-fab","draggable-events","snap-interval","min-duration","max-duration","locale"]}constructor(){super(),this._store=Oe({view:"week",anchorDate:ge(),layout:"vertical",selectedResourceId:null,selectedSlot:null,detailEvent:null,detailResource:null,statusType:null,statusMessage:null,statusDismissible:!0,allDayCollapsed:!1}),this._resources=[],this._events=[],this._eventActions=[],this._eventContent=null,this._colors=null,this._customColorMap=null,this._unsubscribe=null,this._rendering=!1,this._nowTimer=null,this._dragManager=null}get view(){return this.getAttribute("view")||this._store.get("view")}get layout(){return this.getAttribute("layout")||this._store.get("layout")}get startTime(){return this.getAttribute("start-time")||"08:00"}get endTime(){return this.getAttribute("end-time")||"18:00"}get interval(){return parseInt(this.getAttribute("interval")||"30",10)}get format(){return this.getAttribute("format")||"24h"}get firstDay(){return parseInt(this.getAttribute("first-day")||"0",10)}get slotHeight(){return parseInt(this.getAttribute("slot-height")||"48",10)}get resourceMode(){return this.getAttribute("resource-mode")||"tabs"}get loading(){return this.hasAttribute("loading")}set loading(e){e?this.setAttribute("loading",""):this.removeAttribute("loading")}get showEventTime(){return this.getAttribute("show-event-time")!=="false"}get showFab(){return this.hasAttribute("show-fab")}get draggableEvents(){return this.hasAttribute("draggable-events")}get snapInterval(){const e=this.getAttribute("snap-interval");return e?parseInt(e,10):null}get minDuration(){const e=this.getAttribute("min-duration");return e?parseInt(e,10):null}get maxDuration(){const e=this.getAttribute("max-duration");return e?parseInt(e,10):null}get locale(){return this.getAttribute("locale")||void 0}get resources(){return this._resources}set resources(e){this._resources=Array.isArray(e)?e:[],this._initialized&&this.render()}get events(){return this._events}set events(e){this._events=Array.isArray(e)?e:[],this._initialized&&this.render()}get eventActions(){return this._eventActions}set eventActions(e){this._eventActions=Array.isArray(e)?e:[],this._initialized&&this.render()}get eventContent(){return this._eventContent}set eventContent(e){this._eventContent=typeof e=="function"?e:null,this._initialized&&this.render()}get colors(){return this._colors}set colors(e){if(this._colors=Array.isArray(e)?e:null,this._customColorMap=at(this._colors),this._customColorMap)for(const[s,a]of Object.entries(this._customColorMap))this.style.setProperty(`--cal-booking-${s}-bg`,a.bg),this.style.setProperty(`--cal-booking-${s}-fg`,a.fg),this.style.setProperty(`--cal-booking-${s}-hover`,a.hover);this._initialized&&this.render()}get value(){return this._lastSlotValue||null}connectedCallback(){const e=this.getAttribute("date");e&&this._store.set({anchorDate:e});const s=this.getAttribute("view");s&&this._store.set({view:s});const a=this.getAttribute("layout");a&&this._store.set({layout:a}),super.connectedCallback(),this._unsubscribe=this._store.subscribe(()=>{this._rendering||this.render()}),this._nowTimer=setInterval(()=>{const n=this._store.get("view");(n==="day"||n==="week")&&this.render()},6e4),this.draggableEvents&&this._initDrag()}disconnectedCallback(){var e;(e=this._unsubscribe)==null||e.call(this),clearInterval(this._nowTimer),clearTimeout(this._statusTimer),this._destroyDrag(),this._escHandler&&(document.removeEventListener("keydown",this._escHandler),this._escHandler=null)}attributeChangedCallback(e,s,a){if(s!==a){if(e==="date"&&a){this._store.set({anchorDate:a});return}if(e==="view"&&a){this._store.set({view:a});return}if(e==="layout"&&a){this._store.set({layout:a});return}e==="draggable-events"&&(a!==null?this._initDrag():this._destroyDrag()),this._initialized&&this.render()}}goToDate(e){this._store.set({anchorDate:e}),this.emit("cal:date-change",{date:e,view:this._store.get("view")})}setView(e){["day","week","month"].includes(e)&&(this._store.set({view:e}),this.emit("cal:view-change",{view:e,date:this._store.get("anchorDate")}))}today(){this.goToDate(ge())}next(){const e=this._store.getState(),s=Q(e.anchorDate);if(!s)return;let a;if(e.view==="day")a=fe(e.anchorDate,1);else if(e.view==="week")a=fe(e.anchorDate,7);else{const{year:n,month:r}=we(s.getFullYear(),s.getMonth(),1);a=he(new Date(n,r,1))}this._store.set({anchorDate:a}),this.emit("cal:date-change",{date:a,view:e.view})}prev(){const e=this._store.getState(),s=Q(e.anchorDate);if(!s)return;let a;if(e.view==="day")a=fe(e.anchorDate,-1);else if(e.view==="week")a=fe(e.anchorDate,-7);else{const{year:n,month:r}=we(s.getFullYear(),s.getMonth(),-1);a=he(new Date(n,r,1))}this._store.set({anchorDate:a}),this.emit("cal:date-change",{date:a,view:e.view})}findAvailableSlot(e){return tt(e,this._resources,this._events,this.interval,this.startTime,this.endTime)}isSlotAvailable(e,s,a,n){return He(this._events,n,e,s,a)}clear(){this._store.set({selectedSlot:null,detailEvent:null,detailResource:null}),this._lastSlotValue=null}_handleSlotClick(e,s,a,n,r){this._lastSlotValue={date:e,startTime:s,endTime:a,resourceId:n,resource:r},this._store.set({selectedSlot:{date:e,startTime:s,endTime:a,resourceId:n,resource:r}}),this.emit("cal:slot-select",{date:e,startTime:s,endTime:a,resourceId:n,resource:r})}_handleSlotCreate(e,s,a,n,r){this.emit("cal:slot-create",{date:e,startTime:s,endTime:a,resourceId:n,resource:r})}_dismissSlot(){this._store.set({selectedSlot:null})}_handleEventClick(e,s,a){this._dismissSlot(),this._store.set({detailEvent:e,detailResource:a||null}),this.emit("cal:event-click",{event:e,resourceId:s,resource:a})}_closeDetail(){this._store.set({detailEvent:null,detailResource:null})}_handleViewChange(e){this._dismissSlot(),this.setView(e)}_handleResourceFilter(e){this._dismissSlot(),this._store.set({selectedResourceId:e})}_handleEventAction(e){const s=this._store.getState(),a=s.detailEvent,n=s.detailResource;this.emit("cal:event-action",{action:e,event:a,resourceId:a==null?void 0:a.resourceId,resource:n})}_initDrag(){this._dragManager||(this._dragManager=Pt({shadowRoot:this.shadowRoot,getConfig:()=>({slotHeight:this.slotHeight,interval:this.interval,startTime:this.startTime,endTime:this.endTime,format:this.format,snapInterval:this.snapInterval,minDuration:this.minDuration,maxDuration:this.maxDuration}),getViewInfo:()=>{const e=this._store.getState();return{view:e.view,anchorDate:e.anchorDate,weekDates:Ce(e.anchorDate,this.firstDay),resources:this._resources.length>0?this._resources:[{id:"__default",name:""}],resourceMode:this.resourceMode,selectedResourceId:e.selectedResourceId}},getEvents:()=>this._events,onMove:e=>{this.emit("cal:event-move",e)},onResize:e=>{this.emit("cal:event-resize",e)},onCreate:e=>{const s=this._resources.find(a=>a.id===e.resourceId)||null;this.emit("cal:slot-create",{...e,resource:s})}}),this._dragManager.enable())}_destroyDrag(){this._dragManager&&(this._dragManager.destroy(),this._dragManager=null)}_handleFabClick(){const e=this._store.getState();this.emit("cal:fab-create",{date:e.anchorDate,view:e.view})}render(){var f;if(this._rendering)return;this._rendering=!0;const e=this.shadowRoot,s=[...e.childNodes];for(const o of s)o.nodeName!=="STYLE"&&!(o instanceof CSSStyleSheet)&&e.removeChild(o);const a=this._store.getState(),n=document.createElement("div");n.classList.add("cal-sched"),a.statusType&&a.statusMessage&&n.appendChild(Ct({type:a.statusType,message:a.statusMessage,dismissible:a.statusDismissible,onDismiss:()=>this.clearStatus()}));const r=a.view,l=a.anchorDate,i=Ce(l,this.firstDay),d=Qe(r,l,i,this.locale),g=this.resourceMode;n.appendChild(ct({title:d,view:r,onPrev:()=>this.prev(),onNext:()=>this.next(),onToday:()=>this.today(),onViewChange:o=>this._handleViewChange(o),locale:this.locale}));const c=this._resources.length>0?this._resources:[{id:"__default",name:""}],h=g==="tabs"&&c.length>1&&c[0].id!=="__default";h&&!this.loading&&n.appendChild(Dt({resources:c,selectedResourceId:a.selectedResourceId,onResourceFilter:o=>this._handleResourceFilter(o)}));let k=this._events;h&&a.selectedResourceId&&(k=this._events.filter(o=>o.resourceId===a.selectedResourceId));let u=c;if(h&&a.selectedResourceId){const o=c.find(m=>m.id===a.selectedResourceId);o&&(u=[o])}const p=document.createElement("div");if(p.classList.add("cal-sched__body"),this.loading)if(r==="month")p.appendChild(Et());else{const o=r==="week"?7:Math.max(this._resources.length,1);p.appendChild(kt({columns:o,rows:Math.ceil((w(this.endTime)-w(this.startTime))/this.interval),slotHeight:this.slotHeight}))}else r==="day"?p.appendChild(vt({date:l,resources:u,events:k,startTime:this.startTime,endTime:this.endTime,interval:this.interval,slotHeight:this.slotHeight,format:this.format,layout:a.layout,resourceMode:g,selectedSlot:a.selectedSlot,eventContent:this._eventContent,showTime:this.showEventTime,draggable:this.draggableEvents,onSlotClick:(o,m,_,C,D)=>this._handleSlotClick(o,m,_,C,D),onEventClick:(o,m,_)=>this._handleEventClick(o,m,_),onSlotCreate:(o,m,_,C,D)=>this._handleSlotCreate(o,m,_,C,D)})):r==="week"?p.appendChild(_t({date:l,firstDay:this.firstDay,resources:u,events:k,startTime:this.startTime,endTime:this.endTime,interval:this.interval,slotHeight:this.slotHeight,format:this.format,layout:a.layout,resourceMode:g,selectedSlot:a.selectedSlot,eventContent:this._eventContent,showTime:this.showEventTime,draggable:this.draggableEvents,allDayCollapsed:a.allDayCollapsed,onToggleAllDay:()=>this._store.set({allDayCollapsed:!a.allDayCollapsed}),onSlotClick:(o,m,_,C,D)=>this._handleSlotClick(o,m,_,C,D),onEventClick:(o,m,_)=>this._handleEventClick(o,m,_),onSlotCreate:(o,m,_,C,D)=>this._handleSlotCreate(o,m,_,C,D)})):r==="month"&&p.appendChild(yt({date:l,firstDay:this.firstDay,resources:u,events:k,format:this.format,selectedResourceId:a.selectedResourceId,selectedDate:((f=a.selectedSlot)==null?void 0:f.date)||null,eventContent:this._eventContent,onSlotClick:o=>this._handleSlotClick(o,null,null,null,null),onEventClick:(o,m,_)=>this._handleEventClick(o,m,_),onSlotCreate:o=>this._handleSlotCreate(o,null,null,null,null)}));n.appendChild(p),a.detailEvent&&p.appendChild(Mt({event:a.detailEvent,resource:a.detailResource,format:this.format,onClose:()=>this._closeDetail(),actions:this._eventActions,onAction:o=>this._handleEventAction(o)})),this.showFab&&!this.loading&&p.appendChild(At({onClick:()=>this._handleFabClick()})),e.appendChild(n),this._escHandler||(this._escHandler=o=>{o.key==="Escape"&&this._store.get("selectedSlot")&&this._dismissSlot()},this.shadowRoot.addEventListener("keydown",this._escHandler),document.addEventListener("keydown",this._escHandler)),this._rendering=!1}}customElements.get("cal-scheduler")||customElements.define("cal-scheduler",Re),me.CalScheduler=Re,Object.defineProperty(me,Symbol.toStringTag,{value:"Module"})}));
|
|
1547
1547
|
//# sourceMappingURL=scheduler.umd.js.map
|