calkit 0.1.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 +734 -0
- package/dist/booking.es.js +1845 -0
- package/dist/booking.es.js.map +1 -0
- package/dist/booking.umd.js +888 -0
- package/dist/booking.umd.js.map +1 -0
- package/dist/calkit.es.js +5230 -0
- package/dist/calkit.es.js.map +1 -0
- package/dist/calkit.umd.js +2164 -0
- package/dist/calkit.umd.js.map +1 -0
- package/dist/datepicker.es.js +1619 -0
- package/dist/datepicker.es.js.map +1 -0
- package/dist/datepicker.umd.js +818 -0
- package/dist/datepicker.umd.js.map +1 -0
- package/dist/scheduler.es.js +3235 -0
- package/dist/scheduler.es.js.map +1 -0
- package/dist/scheduler.umd.js +1547 -0
- package/dist/scheduler.umd.js.map +1 -0
- package/dist/timepicker.es.js +962 -0
- package/dist/timepicker.es.js.map +1 -0
- package/dist/timepicker.umd.js +517 -0
- package/dist/timepicker.umd.js.map +1 -0
- package/llms.txt +594 -0
- package/package.json +58 -0
|
@@ -0,0 +1,2164 @@
|
|
|
1
|
+
(function(fe,be){typeof exports=="object"&&typeof module<"u"?be(exports):typeof define=="function"&&define.amd?define(["exports"],be):(fe=typeof globalThis<"u"?globalThis:fe||self,be(fe.CalKit={}))})(this,(function(fe){"use strict";class be 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(a=>{if(a instanceof CSSStyleSheet)return a;const t=new CSSStyleSheet;return t.replaceSync(a),t});else for(const a of e){const t=document.createElement("style");t.textContent=a instanceof CSSStyleSheet?"":a,this.shadowRoot.prepend(t)}}render(){}emit(e,a={}){this.dispatchEvent(new CustomEvent(e,{detail:a,bubbles:!0,composed:!0}))}showStatus(e,a,t={}){if(!this._store)return;const{autoDismiss:s,dismissible:i=!0}=t;clearTimeout(this._statusTimer),this._store.set({statusType:e,statusMessage:a,statusDismissible:i}),this.emit("cal:status",{type:e,message:a}),s&&s>0&&(this._statusTimer=setTimeout(()=>this.clearStatus(),s))}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 De(n){let e={...n};const a=new Set;return{get(t){return e[t]},set(t){const s=e;e={...e,...t};let i=!1;for(const l of Object.keys(t))if(s[l]!==e[l]){i=!0;break}if(i)for(const l of a)l(e,s)},getState(){return e},subscribe(t){return a.add(t),()=>a.delete(t)}}}const se=["January","February","March","April","May","June","July","August","September","October","November","December"],kt=["Su","Mo","Tu","We","Th","Fr","Sa"],wt=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Et=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function We(n,e="short"){const a=W(n);return a?e==="long"?wt[a.getDay()]:Et[a.getDay()]:""}function Xe(n=0){const e=[];for(let a=0;a<7;a++)e.push(kt[(n+a)%7]);return e}function Ge(n,e){return new Date(n,e+1,0).getDate()}function Lt(n,e){return new Date(n,e,1).getDay()}function Z(n){if(typeof n=="string")return n;const e=n instanceof Date?n:new Date(n.year,n.month,n.day),a=e.getFullYear(),t=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0");return`${a}-${t}-${s}`}function W(n){if(!n)return null;if(n instanceof Date)return n;if(typeof n=="string"){const[e,a,t]=n.split("-").map(Number);return!e||!a||!t?null:new Date(e,a-1,t)}return null}function re(n,e){if(!n||!e)return!1;const a=W(n),t=W(e);return!a||!t?!1:a.getFullYear()===t.getFullYear()&&a.getMonth()===t.getMonth()&&a.getDate()===t.getDate()}function Ct(n,e,a){if(!n||!e||!a)return!1;const t=W(n),s=W(e),i=W(a);if(!t||!s||!i)return!1;const l=t.getTime(),r=Math.min(s.getTime(),i.getTime()),o=Math.max(s.getTime(),i.getTime());return l>=r&&l<=o}function ue(){return Z(new Date)}function pe(n,e,a){const t=new Date(n,e+a,1);return{year:t.getFullYear(),month:t.getMonth()}}function ye(n,e){const a=W(n);return a?(a.setDate(a.getDate()+e),Z(a)):n}function Ke(n,e,a=0){const t=Ge(n,e),i=(Lt(n,e)-a+7)%7,l=[],r=ue(),o=pe(n,e,-1),h=Ge(o.year,o.month);for(let g=i-1;g>=0;g--){const u=h-g,p=Z({year:o.year,month:o.month,day:u});l.push({year:o.year,month:o.month,day:u,dateString:p,isCurrentMonth:!1,isToday:p===r})}for(let g=1;g<=t;g++){const u=Z({year:n,month:e,day:g});l.push({year:n,month:e,day:g,dateString:u,isCurrentMonth:!0,isToday:u===r})}const c=pe(n,e,1);let d=1;for(;l.length<42;){const g=Z({year:c.year,month:c.month,day:d});l.push({year:c.year,month:c.month,day:d,dateString:g,isCurrentMonth:!1,isToday:g===r}),d++}return l}const Se=`
|
|
2
|
+
:host {
|
|
3
|
+
/* Light theme (default) */
|
|
4
|
+
--cal-bg: 0 0% 100%;
|
|
5
|
+
--cal-bg-muted: 240 5% 96%;
|
|
6
|
+
--cal-fg: 240 6% 10%;
|
|
7
|
+
--cal-fg-muted: 240 4% 46%;
|
|
8
|
+
--cal-border: 240 6% 90%;
|
|
9
|
+
--cal-accent: 240 6% 10%;
|
|
10
|
+
--cal-accent-fg: 0 0% 100%;
|
|
11
|
+
--cal-accent-subtle: 240 5% 96%;
|
|
12
|
+
--cal-hover: 240 5% 93%;
|
|
13
|
+
--cal-ring: 240 6% 10%;
|
|
14
|
+
--cal-radius: 8px;
|
|
15
|
+
--cal-radius-sm: 6px;
|
|
16
|
+
--cal-cell-size: 36px;
|
|
17
|
+
--cal-transition: 150ms ease;
|
|
18
|
+
|
|
19
|
+
/* Booking color palette (softer / less saturated) */
|
|
20
|
+
--cal-booking-blue-bg: 217 55% 94%;
|
|
21
|
+
--cal-booking-blue-fg: 217 60% 35%;
|
|
22
|
+
--cal-booking-green-bg: 152 45% 93%;
|
|
23
|
+
--cal-booking-green-fg: 152 55% 28%;
|
|
24
|
+
--cal-booking-red-bg: 4 50% 94%;
|
|
25
|
+
--cal-booking-red-fg: 4 55% 40%;
|
|
26
|
+
--cal-booking-orange-bg: 30 55% 93%;
|
|
27
|
+
--cal-booking-orange-fg: 30 60% 35%;
|
|
28
|
+
--cal-booking-gray-bg: 240 8% 94%;
|
|
29
|
+
--cal-booking-gray-fg: 240 8% 38%;
|
|
30
|
+
|
|
31
|
+
/* Booking hover tokens */
|
|
32
|
+
--cal-booking-blue-hover: 217 55% 88%;
|
|
33
|
+
--cal-booking-green-hover: 152 45% 87%;
|
|
34
|
+
--cal-booking-red-hover: 4 50% 88%;
|
|
35
|
+
--cal-booking-orange-hover: 30 55% 87%;
|
|
36
|
+
--cal-booking-gray-hover: 240 8% 88%;
|
|
37
|
+
|
|
38
|
+
/* Scheduler tokens */
|
|
39
|
+
--cal-sched-grid-line: 240 6% 94%;
|
|
40
|
+
--cal-sched-now-line: 4 70% 55%;
|
|
41
|
+
--cal-sched-slot-hover: 240 5% 97%;
|
|
42
|
+
--cal-sched-header-bg: 240 5% 98%;
|
|
43
|
+
|
|
44
|
+
/* Status tokens */
|
|
45
|
+
--cal-status-error-bg: 4 50% 95%;
|
|
46
|
+
--cal-status-error-fg: 4 55% 40%;
|
|
47
|
+
--cal-status-error-border: 4 50% 85%;
|
|
48
|
+
--cal-status-warning-bg: 40 55% 95%;
|
|
49
|
+
--cal-status-warning-fg: 40 60% 35%;
|
|
50
|
+
--cal-status-warning-border: 40 50% 85%;
|
|
51
|
+
--cal-status-info-bg: 217 55% 95%;
|
|
52
|
+
--cal-status-info-fg: 217 60% 35%;
|
|
53
|
+
--cal-status-info-border: 217 50% 85%;
|
|
54
|
+
--cal-status-success-bg: 152 45% 95%;
|
|
55
|
+
--cal-status-success-fg: 152 55% 28%;
|
|
56
|
+
--cal-status-success-border: 152 45% 85%;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
:host([theme="dark"]) {
|
|
60
|
+
--cal-bg: 240 6% 10%;
|
|
61
|
+
--cal-bg-muted: 240 4% 16%;
|
|
62
|
+
--cal-fg: 0 0% 98%;
|
|
63
|
+
--cal-fg-muted: 240 4% 54%;
|
|
64
|
+
--cal-border: 240 4% 20%;
|
|
65
|
+
--cal-accent: 0 0% 98%;
|
|
66
|
+
--cal-accent-fg: 240 6% 10%;
|
|
67
|
+
--cal-accent-subtle: 240 4% 16%;
|
|
68
|
+
--cal-hover: 240 4% 20%;
|
|
69
|
+
--cal-ring: 0 0% 98%;
|
|
70
|
+
|
|
71
|
+
--cal-booking-blue-bg: 217 50% 25%;
|
|
72
|
+
--cal-booking-blue-fg: 217 80% 75%;
|
|
73
|
+
--cal-booking-green-bg: 142 40% 22%;
|
|
74
|
+
--cal-booking-green-fg: 142 70% 70%;
|
|
75
|
+
--cal-booking-red-bg: 4 45% 25%;
|
|
76
|
+
--cal-booking-red-fg: 4 70% 75%;
|
|
77
|
+
--cal-booking-orange-bg: 30 45% 25%;
|
|
78
|
+
--cal-booking-orange-fg: 30 80% 75%;
|
|
79
|
+
--cal-booking-gray-bg: 240 5% 22%;
|
|
80
|
+
--cal-booking-gray-fg: 240 5% 65%;
|
|
81
|
+
|
|
82
|
+
--cal-booking-blue-hover: 217 50% 30%;
|
|
83
|
+
--cal-booking-green-hover: 142 40% 27%;
|
|
84
|
+
--cal-booking-red-hover: 4 45% 30%;
|
|
85
|
+
--cal-booking-orange-hover: 30 45% 30%;
|
|
86
|
+
--cal-booking-gray-hover: 240 5% 27%;
|
|
87
|
+
|
|
88
|
+
--cal-sched-grid-line: 240 4% 18%;
|
|
89
|
+
--cal-sched-now-line: 4 55% 55%;
|
|
90
|
+
--cal-sched-slot-hover: 240 4% 14%;
|
|
91
|
+
--cal-sched-header-bg: 240 5% 12%;
|
|
92
|
+
|
|
93
|
+
--cal-status-error-bg: 4 45% 20%;
|
|
94
|
+
--cal-status-error-fg: 4 70% 75%;
|
|
95
|
+
--cal-status-error-border: 4 45% 30%;
|
|
96
|
+
--cal-status-warning-bg: 40 45% 20%;
|
|
97
|
+
--cal-status-warning-fg: 40 80% 75%;
|
|
98
|
+
--cal-status-warning-border: 40 45% 30%;
|
|
99
|
+
--cal-status-info-bg: 217 50% 20%;
|
|
100
|
+
--cal-status-info-fg: 217 80% 75%;
|
|
101
|
+
--cal-status-info-border: 217 50% 30%;
|
|
102
|
+
--cal-status-success-bg: 152 40% 18%;
|
|
103
|
+
--cal-status-success-fg: 152 70% 70%;
|
|
104
|
+
--cal-status-success-border: 152 40% 28%;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
:host([theme="auto"]) {
|
|
108
|
+
--cal-bg: 0 0% 100%;
|
|
109
|
+
--cal-bg-muted: 240 5% 96%;
|
|
110
|
+
--cal-fg: 240 6% 10%;
|
|
111
|
+
--cal-fg-muted: 240 4% 46%;
|
|
112
|
+
--cal-border: 240 6% 90%;
|
|
113
|
+
--cal-accent: 240 6% 10%;
|
|
114
|
+
--cal-accent-fg: 0 0% 100%;
|
|
115
|
+
--cal-accent-subtle: 240 5% 96%;
|
|
116
|
+
--cal-hover: 240 5% 93%;
|
|
117
|
+
--cal-ring: 240 6% 10%;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@media (prefers-color-scheme: dark) {
|
|
121
|
+
:host([theme="auto"]) {
|
|
122
|
+
--cal-bg: 240 6% 10%;
|
|
123
|
+
--cal-bg-muted: 240 4% 16%;
|
|
124
|
+
--cal-fg: 0 0% 98%;
|
|
125
|
+
--cal-fg-muted: 240 4% 54%;
|
|
126
|
+
--cal-border: 240 4% 20%;
|
|
127
|
+
--cal-accent: 0 0% 98%;
|
|
128
|
+
--cal-accent-fg: 240 6% 10%;
|
|
129
|
+
--cal-accent-subtle: 240 4% 16%;
|
|
130
|
+
--cal-hover: 240 4% 20%;
|
|
131
|
+
--cal-ring: 0 0% 98%;
|
|
132
|
+
|
|
133
|
+
--cal-booking-blue-bg: 217 50% 25%;
|
|
134
|
+
--cal-booking-blue-fg: 217 80% 75%;
|
|
135
|
+
--cal-booking-green-bg: 142 40% 22%;
|
|
136
|
+
--cal-booking-green-fg: 142 70% 70%;
|
|
137
|
+
--cal-booking-red-bg: 4 45% 25%;
|
|
138
|
+
--cal-booking-red-fg: 4 70% 75%;
|
|
139
|
+
--cal-booking-orange-bg: 30 45% 25%;
|
|
140
|
+
--cal-booking-orange-fg: 30 80% 75%;
|
|
141
|
+
--cal-booking-gray-bg: 240 5% 22%;
|
|
142
|
+
--cal-booking-gray-fg: 240 5% 65%;
|
|
143
|
+
|
|
144
|
+
--cal-booking-blue-hover: 217 50% 30%;
|
|
145
|
+
--cal-booking-green-hover: 142 40% 27%;
|
|
146
|
+
--cal-booking-red-hover: 4 45% 30%;
|
|
147
|
+
--cal-booking-orange-hover: 30 45% 30%;
|
|
148
|
+
--cal-booking-gray-hover: 240 5% 27%;
|
|
149
|
+
|
|
150
|
+
--cal-sched-grid-line: 240 4% 18%;
|
|
151
|
+
--cal-sched-now-line: 4 55% 55%;
|
|
152
|
+
--cal-sched-slot-hover: 240 4% 14%;
|
|
153
|
+
--cal-sched-header-bg: 240 5% 12%;
|
|
154
|
+
|
|
155
|
+
--cal-status-error-bg: 4 45% 20%;
|
|
156
|
+
--cal-status-error-fg: 4 70% 75%;
|
|
157
|
+
--cal-status-error-border: 4 45% 30%;
|
|
158
|
+
--cal-status-warning-bg: 40 45% 20%;
|
|
159
|
+
--cal-status-warning-fg: 40 80% 75%;
|
|
160
|
+
--cal-status-warning-border: 40 45% 30%;
|
|
161
|
+
--cal-status-info-bg: 217 50% 20%;
|
|
162
|
+
--cal-status-info-fg: 217 80% 75%;
|
|
163
|
+
--cal-status-info-border: 217 50% 30%;
|
|
164
|
+
--cal-status-success-bg: 152 40% 18%;
|
|
165
|
+
--cal-status-success-fg: 152 70% 70%;
|
|
166
|
+
--cal-status-success-border: 152 40% 28%;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
`,Te=`
|
|
170
|
+
:host {
|
|
171
|
+
display: inline-block;
|
|
172
|
+
font-family: inherit;
|
|
173
|
+
font-size: 14px;
|
|
174
|
+
line-height: 1.5;
|
|
175
|
+
color: hsl(var(--cal-fg));
|
|
176
|
+
-webkit-font-smoothing: antialiased;
|
|
177
|
+
-moz-osx-font-smoothing: grayscale;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
:host([display="inline"]) {
|
|
181
|
+
display: inline-block;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
*,
|
|
185
|
+
*::before,
|
|
186
|
+
*::after {
|
|
187
|
+
box-sizing: border-box;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
button {
|
|
191
|
+
font: inherit;
|
|
192
|
+
color: inherit;
|
|
193
|
+
background: none;
|
|
194
|
+
border: none;
|
|
195
|
+
padding: 0;
|
|
196
|
+
margin: 0;
|
|
197
|
+
cursor: pointer;
|
|
198
|
+
-webkit-tap-highlight-color: transparent;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
button:focus-visible {
|
|
202
|
+
outline: 2px solid hsl(var(--cal-ring));
|
|
203
|
+
outline-offset: 2px;
|
|
204
|
+
border-radius: var(--cal-radius-sm);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
[hidden] {
|
|
208
|
+
display: none !important;
|
|
209
|
+
}
|
|
210
|
+
`,Me=`
|
|
211
|
+
@keyframes cal-fade-in {
|
|
212
|
+
from { opacity: 0; }
|
|
213
|
+
to { opacity: 1; }
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
@keyframes cal-slide-up {
|
|
217
|
+
from {
|
|
218
|
+
opacity: 0;
|
|
219
|
+
transform: translateY(4px);
|
|
220
|
+
}
|
|
221
|
+
to {
|
|
222
|
+
opacity: 1;
|
|
223
|
+
transform: translateY(0);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
@keyframes cal-slide-left {
|
|
228
|
+
from {
|
|
229
|
+
opacity: 0;
|
|
230
|
+
transform: translateX(16px);
|
|
231
|
+
}
|
|
232
|
+
to {
|
|
233
|
+
opacity: 1;
|
|
234
|
+
transform: translateX(0);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
@keyframes cal-slide-right {
|
|
239
|
+
from {
|
|
240
|
+
opacity: 0;
|
|
241
|
+
transform: translateX(-16px);
|
|
242
|
+
}
|
|
243
|
+
to {
|
|
244
|
+
opacity: 1;
|
|
245
|
+
transform: translateX(0);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.cal-animate-fade { animation: cal-fade-in 150ms cubic-bezier(0.16, 1, 0.3, 1); }
|
|
250
|
+
.cal-animate-slide-up { animation: cal-slide-up 200ms cubic-bezier(0.16, 1, 0.3, 1); }
|
|
251
|
+
.cal-animate-slide-left { animation: cal-slide-left 200ms cubic-bezier(0.16, 1, 0.3, 1); }
|
|
252
|
+
.cal-animate-slide-right { animation: cal-slide-right 200ms cubic-bezier(0.16, 1, 0.3, 1); }
|
|
253
|
+
|
|
254
|
+
@keyframes cal-shimmer {
|
|
255
|
+
0% { background-position: -200% 0; }
|
|
256
|
+
100% { background-position: 200% 0; }
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.cal-skeleton {
|
|
260
|
+
background: linear-gradient(
|
|
261
|
+
90deg,
|
|
262
|
+
hsl(var(--cal-bg-muted)) 25%,
|
|
263
|
+
hsl(var(--cal-hover)) 50%,
|
|
264
|
+
hsl(var(--cal-bg-muted)) 75%
|
|
265
|
+
);
|
|
266
|
+
background-size: 200% 100%;
|
|
267
|
+
animation: cal-shimmer 1.5s infinite ease-in-out;
|
|
268
|
+
border-radius: 999px;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.cal-skeleton--rect {
|
|
272
|
+
border-radius: var(--cal-radius-sm);
|
|
273
|
+
}
|
|
274
|
+
`,Ue={blue:{bg:"var(--cal-booking-blue-bg)",fg:"var(--cal-booking-blue-fg)",hover:"var(--cal-booking-blue-hover)"},green:{bg:"var(--cal-booking-green-bg)",fg:"var(--cal-booking-green-fg)",hover:"var(--cal-booking-green-hover)"},red:{bg:"var(--cal-booking-red-bg)",fg:"var(--cal-booking-red-fg)",hover:"var(--cal-booking-red-hover)"},orange:{bg:"var(--cal-booking-orange-bg)",fg:"var(--cal-booking-orange-fg)",hover:"var(--cal-booking-orange-hover)"},gray:{bg:"var(--cal-booking-gray-bg)",fg:"var(--cal-booking-gray-fg)",hover:"var(--cal-booking-gray-hover)"}},xe="blue";function we(n){return Ue[n]||Ue[xe]}function Dt(n,e=[],a={},t=null){const s=e.find(p=>p.end===n),i=e.find(p=>p.start===n),l=e.find(p=>p.start<n&&p.end>n);let r="available",o=null,h=!1,c=null,d=null,g=null;s&&i?(r="half-day",h=!0,c=we(s.color||xe),d=we(i.color||xe)):l?(r="booked",g=we(l.color||xe)):i&&!s?(r="checkin-only",d=we(i.color||xe)):s&&!i&&(r="checkout-only",c=we(s.color||xe));const u=a[n];if(u&&(u.status&&(r=u.status),u.label!==void 0&&(o=u.label)),t){const p=t(n);p&&(p.status&&(r=p.status),p.label!==void 0&&(o=p.label))}return{status:r,label:o,checkoutBooking:s,checkinBooking:i,halfDay:h,colorOut:c,colorIn:d,colorFull:g}}function Ve(n,e,a=[]){if(!n||!e)return!0;const t=n<e?n:e,s=n<e?e:n;for(const i of a)if(t<i.end&&s>i.start)return!1;return!0}function St(n,e,a=[]){return!n||!e?!1:!Ve(n,e,a)}function Je(n){const{year:e,month:a,firstDay:t=0,selectedDates:s=[],rangeStart:i,rangeEnd:l,hoverDate:r,minDate:o,maxDate:h,disabledDates:c=[],mode:d="single",focusedDate:g,onSelect:u,onHover:p,bookings:_=null,dayData:m=null,labelFormula:v=null,showLabelsOnHover:C=!1}=n,k=_!==null,S=document.createElement("div");S.setAttribute("role","grid"),S.classList.add("cal-grid");const B=document.createElement("div");B.setAttribute("role","row"),B.classList.add("cal-weekdays");for(const M of Xe(t)){const x=document.createElement("div");x.setAttribute("role","columnheader"),x.setAttribute("aria-label",M),x.classList.add("cal-weekday"),x.textContent=M,B.appendChild(x)}S.appendChild(B);const V=Ke(e,a,t),O=d==="range"&&i&&!l&&r||k&&i&&!l&&r?r:l,N=k?St(i,r,_):!1;let I;return V.forEach((M,x)=>{x%7===0&&(I=document.createElement("div"),I.setAttribute("role","row"),I.classList.add("cal-row"),S.appendChild(I));const f=document.createElement("button");f.setAttribute("role","gridcell"),f.setAttribute("part","day"),f.classList.add("cal-day");const F=M.dateString;f.dataset.date=F;const R=new Date(M.year,M.month,M.day);f.setAttribute("aria-label",R.toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric"})),M.isCurrentMonth||f.classList.add("cal-day--outside"),M.isToday&&f.classList.add("cal-day--today");let L=null,y=!1;if(k){L=Dt(F,_,m||{},v);const{status:E,label:Y,halfDay:X,colorOut:$,colorIn:T,colorFull:z}=L;if(E==="booked"&&(f.classList.add("cal-day--booked"),z&&(f.style.setProperty("--booking-bg",`hsl(${z.bg})`),f.style.setProperty("--booking-fg",`hsl(${z.fg})`),f.style.setProperty("--booking-hover",`hsl(${z.hover})`)),y=!0),E==="blocked"&&(f.classList.add("cal-day--blocked"),y=!0),X&&(f.classList.add("cal-day--half-day"),$&&f.style.setProperty("--half-day-color-out",`hsl(${$.bg})`),T&&f.style.setProperty("--half-day-color-in",`hsl(${T.bg})`),y=!0),E==="checkout-only"&&(f.classList.add("cal-day--checkout-only"),$&&f.style.setProperty("--half-day-color-out",`hsl(${$.bg})`)),E==="checkin-only"&&(f.classList.add("cal-day--checkin-only"),T&&f.style.setProperty("--half-day-color-in",`hsl(${T.bg})`)),C){let q=null;if(X&&L.checkoutBooking&&L.checkinBooking)q=`${L.checkoutBooking.label||""} / ${L.checkinBooking.label||""}`;else if(E==="booked"){const Q=_.find(ke=>ke.start<=F&&ke.end>F);Q&&(q=Q.label)}else E==="checkout-only"&&L.checkoutBooking?q=L.checkoutBooking.label:E==="checkin-only"&&L.checkinBooking&&(q=L.checkinBooking.label);q&&f.setAttribute("data-booking-label",q)}if(N&&i&&!l&&r){const q=i<r?i:r,Q=i<r?r:i;F>=q&&F<=Q&&f.classList.add("cal-day--invalid-range")}}if(k?i&&l&&(re(F,i)||re(F,l))?(f.classList.add("cal-day--selected"),f.setAttribute("aria-selected","true")):f.setAttribute("aria-selected","false"):s.some(Y=>re(Y,F))?(f.classList.add("cal-day--selected"),f.setAttribute("aria-selected","true")):f.setAttribute("aria-selected","false"),(d==="range"||k)&&i&&O){const E=re(F,i),Y=re(F,O),X=Ct(F,i,O);E&&f.classList.add("cal-day--range-start"),Y&&f.classList.add("cal-day--range-end"),X&&!E&&!Y&&f.classList.add("cal-day--in-range")}const K=Tt(F,o,h,c)||y;if(K&&(f.classList.add("cal-day--disabled"),f.disabled=!0,f.setAttribute("aria-disabled","true")),g&&re(F,g)?f.setAttribute("tabindex","0"):f.setAttribute("tabindex","-1"),k&&L&&L.label!=null){f.classList.add("cal-day--with-label");const E=document.createElement("span");E.classList.add("cal-day__number"),E.textContent=M.day,f.appendChild(E);const Y=document.createElement("span");Y.classList.add("cal-day__label"),Y.textContent=L.label,f.appendChild(Y)}else f.textContent=M.day;K?k&&f.addEventListener("mouseenter",()=>p==null?void 0:p(F)):(f.addEventListener("click",()=>u==null?void 0:u(F)),f.addEventListener("mouseenter",()=>p==null?void 0:p(F))),I.appendChild(f)}),S.addEventListener("mouseleave",()=>p==null?void 0:p(null)),S}function Tt(n,e,a,t){return!!(t.includes(n)||e&&n<e||a&&n>a)}const Ze=`
|
|
275
|
+
.cal-grid {
|
|
276
|
+
display: flex;
|
|
277
|
+
flex-direction: column;
|
|
278
|
+
gap: 2px;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.cal-weekdays {
|
|
282
|
+
display: grid;
|
|
283
|
+
grid-template-columns: repeat(7, var(--cal-cell-size));
|
|
284
|
+
gap: 0;
|
|
285
|
+
margin-bottom: 4px;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.cal-weekday {
|
|
289
|
+
display: flex;
|
|
290
|
+
align-items: center;
|
|
291
|
+
justify-content: center;
|
|
292
|
+
height: var(--cal-cell-size);
|
|
293
|
+
font-size: 12px;
|
|
294
|
+
font-weight: 500;
|
|
295
|
+
color: hsl(var(--cal-fg-muted));
|
|
296
|
+
user-select: none;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
.cal-row {
|
|
300
|
+
display: grid;
|
|
301
|
+
grid-template-columns: repeat(7, var(--cal-cell-size));
|
|
302
|
+
gap: 0;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.cal-day {
|
|
306
|
+
display: flex;
|
|
307
|
+
align-items: center;
|
|
308
|
+
justify-content: center;
|
|
309
|
+
width: var(--cal-cell-size);
|
|
310
|
+
height: var(--cal-cell-size);
|
|
311
|
+
font-size: 14px;
|
|
312
|
+
border-radius: var(--cal-radius-sm);
|
|
313
|
+
transition: background var(--cal-transition), color var(--cal-transition);
|
|
314
|
+
position: relative;
|
|
315
|
+
user-select: none;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.cal-day:not(.cal-day--disabled):not(.cal-day--selected):not(.cal-day--booked):not(.cal-day--half-day):not(.cal-day--blocked):not(.cal-day--checkout-only):not(.cal-day--checkin-only):hover {
|
|
319
|
+
background: hsl(var(--cal-hover));
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.cal-day--outside {
|
|
323
|
+
color: hsl(var(--cal-fg-muted));
|
|
324
|
+
opacity: 0.4;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.cal-day--today:not(.cal-day--selected):not(.cal-day--booked):not(.cal-day--half-day):not(.cal-day--checkout-only):not(.cal-day--checkin-only) {
|
|
328
|
+
border: 1px solid hsl(var(--cal-border));
|
|
329
|
+
font-weight: 600;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
.cal-day--selected {
|
|
333
|
+
background: hsl(var(--cal-accent));
|
|
334
|
+
color: hsl(var(--cal-accent-fg));
|
|
335
|
+
font-weight: 600;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
.cal-day--range-start {
|
|
339
|
+
background: hsl(var(--cal-accent));
|
|
340
|
+
color: hsl(var(--cal-accent-fg));
|
|
341
|
+
font-weight: 600;
|
|
342
|
+
border-radius: var(--cal-radius-sm) 0 0 var(--cal-radius-sm);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
.cal-day--range-end {
|
|
346
|
+
background: hsl(var(--cal-accent));
|
|
347
|
+
color: hsl(var(--cal-accent-fg));
|
|
348
|
+
font-weight: 600;
|
|
349
|
+
border-radius: 0 var(--cal-radius-sm) var(--cal-radius-sm) 0;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
.cal-day--range-start.cal-day--range-end {
|
|
353
|
+
border-radius: var(--cal-radius-sm);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
.cal-day--in-range {
|
|
357
|
+
background: hsl(var(--cal-accent-subtle));
|
|
358
|
+
border-radius: 0;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
.cal-day--in-range:hover {
|
|
362
|
+
background: hsl(var(--cal-accent-subtle)) !important;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
.cal-day--disabled {
|
|
366
|
+
opacity: 0.3;
|
|
367
|
+
cursor: not-allowed;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/* ── Booking-specific styles ── */
|
|
371
|
+
|
|
372
|
+
/* Booked (fully occupied) */
|
|
373
|
+
.cal-day--booked {
|
|
374
|
+
background: var(--booking-bg, hsl(var(--cal-booking-blue-bg)));
|
|
375
|
+
color: var(--booking-fg, hsl(var(--cal-booking-blue-fg)));
|
|
376
|
+
cursor: not-allowed;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
.cal-day--booked:hover {
|
|
380
|
+
background: var(--booking-hover, hsl(var(--cal-booking-blue-hover)));
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/* Blocked */
|
|
384
|
+
.cal-day--blocked {
|
|
385
|
+
background: hsl(var(--cal-bg-muted));
|
|
386
|
+
opacity: 0.4;
|
|
387
|
+
cursor: not-allowed;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/* Half-day diagonal (checkout + checkin on same day) */
|
|
391
|
+
.cal-day--half-day {
|
|
392
|
+
background: linear-gradient(135deg,
|
|
393
|
+
var(--half-day-color-out, hsl(var(--cal-booking-blue-bg))) 49.5%,
|
|
394
|
+
hsl(var(--cal-bg)) 49.5%, hsl(var(--cal-bg)) 50.5%,
|
|
395
|
+
var(--half-day-color-in, hsl(var(--cal-booking-green-bg))) 50.5%);
|
|
396
|
+
cursor: not-allowed;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/* Checkout-only (last day of a booking — outgoing triangle) */
|
|
400
|
+
.cal-day--checkout-only {
|
|
401
|
+
background: linear-gradient(135deg,
|
|
402
|
+
var(--half-day-color-out, hsl(var(--cal-booking-blue-bg))) 49.5%,
|
|
403
|
+
hsl(var(--cal-bg)) 49.5%);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/* Checkin-only (first day of a booking — incoming triangle) */
|
|
407
|
+
.cal-day--checkin-only {
|
|
408
|
+
background: linear-gradient(135deg,
|
|
409
|
+
hsl(var(--cal-bg)) 50.5%,
|
|
410
|
+
var(--half-day-color-in, hsl(var(--cal-booking-blue-bg))) 50.5%);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/* Diagonal cells: standard text color for clean contrast */
|
|
414
|
+
.cal-day--half-day,
|
|
415
|
+
.cal-day--checkout-only,
|
|
416
|
+
.cal-day--checkin-only {
|
|
417
|
+
color: hsl(var(--cal-fg));
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/* ── Diagonal + selection compounds ── */
|
|
421
|
+
|
|
422
|
+
/* Checkout-only — range boundary: accent-subtle fill + refined ring */
|
|
423
|
+
.cal-day--checkout-only.cal-day--range-start,
|
|
424
|
+
.cal-day--checkout-only.cal-day--range-end,
|
|
425
|
+
.cal-day--checkout-only.cal-day--selected {
|
|
426
|
+
background: linear-gradient(135deg,
|
|
427
|
+
var(--half-day-color-out, hsl(var(--cal-booking-blue-bg))) 49.5%,
|
|
428
|
+
hsl(var(--cal-accent-subtle)) 50.5%);
|
|
429
|
+
color: hsl(var(--cal-fg));
|
|
430
|
+
box-shadow: inset 0 0 0 1.5px hsl(var(--cal-accent) / 0.3);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/* Checkout-only — in range: accent-subtle fill */
|
|
434
|
+
.cal-day--checkout-only.cal-day--in-range {
|
|
435
|
+
background: linear-gradient(135deg,
|
|
436
|
+
var(--half-day-color-out, hsl(var(--cal-booking-blue-bg))) 49.5%,
|
|
437
|
+
hsl(var(--cal-accent-subtle)) 50.5%);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/* Checkin-only — range boundary: accent-subtle fill + refined ring */
|
|
441
|
+
.cal-day--checkin-only.cal-day--range-start,
|
|
442
|
+
.cal-day--checkin-only.cal-day--range-end,
|
|
443
|
+
.cal-day--checkin-only.cal-day--selected {
|
|
444
|
+
background: linear-gradient(135deg,
|
|
445
|
+
hsl(var(--cal-accent-subtle)) 49.5%,
|
|
446
|
+
var(--half-day-color-in, hsl(var(--cal-booking-blue-bg))) 50.5%);
|
|
447
|
+
color: hsl(var(--cal-fg));
|
|
448
|
+
box-shadow: inset 0 0 0 1.5px hsl(var(--cal-accent) / 0.3);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/* Checkin-only — in range: accent-subtle fill */
|
|
452
|
+
.cal-day--checkin-only.cal-day--in-range {
|
|
453
|
+
background: linear-gradient(135deg,
|
|
454
|
+
hsl(var(--cal-accent-subtle)) 49.5%,
|
|
455
|
+
var(--half-day-color-in, hsl(var(--cal-booking-blue-bg))) 50.5%);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/* Half-day in range — accent-subtle stripe between booking triangles */
|
|
459
|
+
.cal-day--half-day.cal-day--in-range {
|
|
460
|
+
background: linear-gradient(135deg,
|
|
461
|
+
var(--half-day-color-out, hsl(var(--cal-booking-blue-bg))) 49.5%,
|
|
462
|
+
hsl(var(--cal-accent-subtle)) 49.5%, hsl(var(--cal-accent-subtle)) 50.5%,
|
|
463
|
+
var(--half-day-color-in, hsl(var(--cal-booking-green-bg))) 50.5%);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/* Invalid range preview (crosses a booking) */
|
|
467
|
+
.cal-day--invalid-range {
|
|
468
|
+
background: hsl(var(--cal-booking-red-bg));
|
|
469
|
+
border-radius: 0;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/* Booked/half-day/diagonal cells stay opaque even when disabled */
|
|
473
|
+
.cal-day--disabled.cal-day--booked,
|
|
474
|
+
.cal-day--disabled.cal-day--half-day,
|
|
475
|
+
.cal-day--disabled.cal-day--checkout-only,
|
|
476
|
+
.cal-day--disabled.cal-day--checkin-only {
|
|
477
|
+
opacity: 1;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/* Sublabel spans */
|
|
481
|
+
.cal-day__number {
|
|
482
|
+
font-size: 13px;
|
|
483
|
+
font-weight: 500;
|
|
484
|
+
line-height: 1;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
.cal-day__label {
|
|
488
|
+
font-size: 9px;
|
|
489
|
+
font-weight: 500;
|
|
490
|
+
line-height: 1;
|
|
491
|
+
opacity: 0.8;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
.cal-day--with-label {
|
|
495
|
+
flex-direction: column;
|
|
496
|
+
gap: 1px;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/* CSS Tooltip */
|
|
500
|
+
.cal-day[data-booking-label] {
|
|
501
|
+
overflow: visible;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
.cal-day[data-booking-label]:hover::after {
|
|
505
|
+
content: attr(data-booking-label);
|
|
506
|
+
position: absolute;
|
|
507
|
+
bottom: calc(100% + 6px);
|
|
508
|
+
left: 50%;
|
|
509
|
+
transform: translateX(-50%);
|
|
510
|
+
padding: 4px 8px;
|
|
511
|
+
font-size: 11px;
|
|
512
|
+
font-weight: 500;
|
|
513
|
+
white-space: nowrap;
|
|
514
|
+
color: hsl(var(--cal-accent-fg));
|
|
515
|
+
background: hsl(var(--cal-accent));
|
|
516
|
+
border-radius: 4px;
|
|
517
|
+
pointer-events: none;
|
|
518
|
+
z-index: 10;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
.cal-day[data-booking-label]:hover::before {
|
|
522
|
+
content: '';
|
|
523
|
+
position: absolute;
|
|
524
|
+
bottom: calc(100% + 2px);
|
|
525
|
+
left: 50%;
|
|
526
|
+
transform: translateX(-50%);
|
|
527
|
+
border: 4px solid transparent;
|
|
528
|
+
border-top-color: hsl(var(--cal-accent));
|
|
529
|
+
pointer-events: none;
|
|
530
|
+
z-index: 10;
|
|
531
|
+
}
|
|
532
|
+
`,Pe='<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>',He='<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 Ae({year:n,month:e,onPrev:a,onNext:t,onTitleClick:s}){const i=document.createElement("div");i.classList.add("cal-nav");const l=document.createElement("button");l.classList.add("cal-nav__btn","cal-nav__btn--prev"),l.innerHTML=Pe,l.setAttribute("aria-label","Previous month"),l.addEventListener("click",a);const r=s?"button":"div",o=document.createElement(r);o.classList.add("cal-nav__title"),s&&(o.classList.add("cal-nav__title--interactive"),o.setAttribute("aria-label",`Select month and year, currently ${se[e]} ${n}`),o.addEventListener("click",s)),o.setAttribute("aria-live","polite"),o.textContent=`${se[e]} ${n}`;const h=document.createElement("button");return h.classList.add("cal-nav__btn","cal-nav__btn--next"),h.innerHTML=He,h.setAttribute("aria-label","Next month"),h.addEventListener("click",t),i.appendChild(l),i.appendChild(o),i.appendChild(h),i}const Qe=`
|
|
533
|
+
.cal-nav {
|
|
534
|
+
display: flex;
|
|
535
|
+
align-items: center;
|
|
536
|
+
justify-content: space-between;
|
|
537
|
+
padding: 0 4px;
|
|
538
|
+
margin-bottom: 8px;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
.cal-nav__btn {
|
|
542
|
+
display: flex;
|
|
543
|
+
align-items: center;
|
|
544
|
+
justify-content: center;
|
|
545
|
+
width: 28px;
|
|
546
|
+
height: 28px;
|
|
547
|
+
border-radius: var(--cal-radius-sm);
|
|
548
|
+
color: hsl(var(--cal-fg));
|
|
549
|
+
transition: background var(--cal-transition);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
.cal-nav__btn:hover {
|
|
553
|
+
background: hsl(var(--cal-hover));
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
.cal-nav__title {
|
|
557
|
+
font-size: 14px;
|
|
558
|
+
font-weight: 600;
|
|
559
|
+
color: hsl(var(--cal-fg));
|
|
560
|
+
user-select: none;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
.cal-nav__title--interactive {
|
|
564
|
+
cursor: pointer;
|
|
565
|
+
padding: 2px 8px;
|
|
566
|
+
border-radius: var(--cal-radius-sm);
|
|
567
|
+
transition: background var(--cal-transition);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
.cal-nav__title--interactive:hover {
|
|
571
|
+
background: hsl(var(--cal-hover));
|
|
572
|
+
}
|
|
573
|
+
`,Mt=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function et({pickerYear:n,viewMonth:e,viewYear:a,onMonthSelect:t,onYearPrev:s,onYearNext:i,onClose:l}){const r=document.createElement("div");r.classList.add("cal-myp","cal-animate-fade");const o=document.createElement("div");o.classList.add("cal-myp__year-nav");const h=document.createElement("button");h.classList.add("cal-nav__btn"),h.innerHTML=Pe,h.setAttribute("aria-label","Previous year"),h.addEventListener("click",s);const c=document.createElement("div");c.classList.add("cal-myp__year-label"),c.textContent=n;const d=document.createElement("button");d.classList.add("cal-nav__btn"),d.innerHTML=He,d.setAttribute("aria-label","Next year"),d.addEventListener("click",i),o.appendChild(h),o.appendChild(c),o.appendChild(d),r.appendChild(o);const g=document.createElement("div");g.classList.add("cal-myp__grid");const u=new Date,p=u.getMonth(),_=u.getFullYear();for(let m=0;m<12;m++){const v=document.createElement("button");v.classList.add("cal-myp__cell"),v.textContent=Mt[m],m===e&&n===a&&v.classList.add("cal-myp__cell--active"),m===p&&n===_&&v.classList.add("cal-myp__cell--today"),v.addEventListener("click",()=>t(m,n)),g.appendChild(v)}return r.appendChild(g),r.addEventListener("keydown",m=>{m.key==="Escape"&&(m.stopPropagation(),l())}),r}const tt=`
|
|
574
|
+
.cal-myp {
|
|
575
|
+
width: calc(7 * var(--cal-cell-size));
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
.cal-myp__year-nav {
|
|
579
|
+
display: flex;
|
|
580
|
+
align-items: center;
|
|
581
|
+
justify-content: space-between;
|
|
582
|
+
padding: 0 4px;
|
|
583
|
+
margin-bottom: 8px;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
.cal-myp__year-label {
|
|
587
|
+
font-size: 14px;
|
|
588
|
+
font-weight: 600;
|
|
589
|
+
color: hsl(var(--cal-fg));
|
|
590
|
+
user-select: none;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
.cal-myp__grid {
|
|
594
|
+
display: grid;
|
|
595
|
+
grid-template-columns: repeat(3, 1fr);
|
|
596
|
+
gap: 4px;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
.cal-myp__cell {
|
|
600
|
+
display: flex;
|
|
601
|
+
align-items: center;
|
|
602
|
+
justify-content: center;
|
|
603
|
+
height: calc(var(--cal-cell-size) * 1.5);
|
|
604
|
+
font-size: 13px;
|
|
605
|
+
font-weight: 500;
|
|
606
|
+
color: hsl(var(--cal-fg));
|
|
607
|
+
border-radius: var(--cal-radius-sm);
|
|
608
|
+
cursor: pointer;
|
|
609
|
+
transition: background var(--cal-transition);
|
|
610
|
+
user-select: none;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
.cal-myp__cell:hover {
|
|
614
|
+
background: hsl(var(--cal-hover));
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
.cal-myp__cell--active {
|
|
618
|
+
background: hsl(var(--cal-accent));
|
|
619
|
+
color: hsl(var(--cal-accent-fg));
|
|
620
|
+
font-weight: 600;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
.cal-myp__cell--active:hover {
|
|
624
|
+
background: hsl(var(--cal-accent));
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
.cal-myp__cell--today:not(.cal-myp__cell--active) {
|
|
628
|
+
border: 1px solid hsl(var(--cal-border));
|
|
629
|
+
font-weight: 600;
|
|
630
|
+
}
|
|
631
|
+
`;function At(){return[{key:"today",label:"Today",resolve(){const n=ue();return{start:n,end:n}}},{key:"this-week",label:"This Week",resolve(){const n=new Date,e=n.getDay(),a=new Date(n);a.setDate(n.getDate()-e);const t=new Date(a);return t.setDate(a.getDate()+6),{start:Z(a),end:Z(t)}}},{key:"next-7",label:"Next 7 Days",resolve(){const n=new Date,e=new Date;return e.setDate(n.getDate()+6),{start:Z(n),end:Z(e)}}},{key:"next-30",label:"Next 30 Days",resolve(){const n=new Date,e=new Date;return e.setDate(n.getDate()+29),{start:Z(n),end:Z(e)}}}]}function $t({presetKeys:n,onSelect:e}){const a=document.createElement("div");a.classList.add("cal-presets");const t=At(),s=n.map(i=>t.find(l=>l.key===i)).filter(Boolean);for(const i of s){const l=document.createElement("button");l.classList.add("cal-preset"),l.textContent=i.label,l.addEventListener("click",()=>{e==null||e(i.resolve())}),a.appendChild(l)}return a}const zt=`
|
|
632
|
+
.cal-presets {
|
|
633
|
+
display: flex;
|
|
634
|
+
flex-wrap: wrap;
|
|
635
|
+
gap: 6px;
|
|
636
|
+
padding: 8px 4px;
|
|
637
|
+
border-top: 1px solid hsl(var(--cal-border));
|
|
638
|
+
margin-top: 8px;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
.cal-preset {
|
|
642
|
+
display: inline-flex;
|
|
643
|
+
align-items: center;
|
|
644
|
+
height: 28px;
|
|
645
|
+
padding: 0 10px;
|
|
646
|
+
font-size: 12px;
|
|
647
|
+
font-weight: 500;
|
|
648
|
+
border-radius: 999px;
|
|
649
|
+
background: hsl(var(--cal-bg-muted));
|
|
650
|
+
color: hsl(var(--cal-fg));
|
|
651
|
+
transition: background var(--cal-transition);
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
.cal-preset:hover {
|
|
655
|
+
background: hsl(var(--cal-hover));
|
|
656
|
+
}
|
|
657
|
+
`;function Be({trigger:n,content:e,onClose:a}){const t=document.createElement("div");t.classList.add("cal-popover"),t.setAttribute("role","dialog"),t.setAttribute("aria-modal","false"),t.style.display="none",t.appendChild(e);let s=!1;function i(){t.classList.remove("cal-popover--above");const d=n.getBoundingClientRect(),g=t.offsetHeight,u=window.innerHeight-d.bottom,p=d.top;u<g+8&&p>u?(t.classList.add("cal-popover--above"),t.style.top="auto",t.style.bottom="100%",t.style.marginBottom="4px",t.style.marginTop="0"):(t.style.top="100%",t.style.bottom="auto",t.style.marginTop="4px",t.style.marginBottom="0")}function l(){s||(s=!0,t.style.display="",t.classList.add("cal-animate-slide-up"),requestAnimationFrame(()=>i()),document.addEventListener("click",o,!0),document.addEventListener("keydown",h,!0))}function r(){s&&(s=!1,t.style.display="none",t.classList.remove("cal-animate-slide-up"),document.removeEventListener("click",o,!0),document.removeEventListener("keydown",h,!0),a==null||a())}function o(d){var u;const g=(u=n.getRootNode())==null?void 0:u.host;g&&!g.contains(d.target)&&d.target!==g&&r()}function h(d){d.key==="Escape"&&(d.stopPropagation(),r())}function c(){s&&(s=!1,t.style.display="none",t.classList.remove("cal-animate-slide-up")),document.removeEventListener("click",o,!0),document.removeEventListener("keydown",h,!0)}return{panel:t,open:l,close:r,destroy:c,get isOpen(){return s}}}const Oe=`
|
|
658
|
+
.cal-popover-wrapper {
|
|
659
|
+
position: relative;
|
|
660
|
+
display: inline-block;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
.cal-popover {
|
|
664
|
+
position: absolute;
|
|
665
|
+
left: 0;
|
|
666
|
+
z-index: 50;
|
|
667
|
+
background: hsl(var(--cal-bg));
|
|
668
|
+
border: 1px solid hsl(var(--cal-border));
|
|
669
|
+
border-radius: var(--cal-radius);
|
|
670
|
+
box-shadow: 0 4px 16px -2px rgba(0, 0, 0, 0.08), 0 2px 6px -2px rgba(0, 0, 0, 0.04);
|
|
671
|
+
padding: 12px;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
.cal-trigger {
|
|
675
|
+
display: inline-flex;
|
|
676
|
+
align-items: center;
|
|
677
|
+
gap: 8px;
|
|
678
|
+
height: 36px;
|
|
679
|
+
padding: 0 12px;
|
|
680
|
+
font-size: 14px;
|
|
681
|
+
border: 1px solid hsl(var(--cal-border));
|
|
682
|
+
border-radius: var(--cal-radius-sm);
|
|
683
|
+
background: hsl(var(--cal-bg));
|
|
684
|
+
color: hsl(var(--cal-fg));
|
|
685
|
+
cursor: pointer;
|
|
686
|
+
transition: border-color var(--cal-transition);
|
|
687
|
+
white-space: nowrap;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
.cal-trigger:hover {
|
|
691
|
+
border-color: hsl(var(--cal-fg-muted));
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
.cal-trigger--placeholder {
|
|
695
|
+
color: hsl(var(--cal-fg-muted));
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
.cal-trigger__icon {
|
|
699
|
+
display: flex;
|
|
700
|
+
color: hsl(var(--cal-fg-muted));
|
|
701
|
+
}
|
|
702
|
+
`;function at({columns:n=3,rows:e=4,durationLabels:a=!1}={}){const t=document.createElement("div");t.setAttribute("role","status"),t.setAttribute("aria-label","Loading..."),t.classList.add("cal-skeleton-time-grid"),a&&t.classList.add("cal-skeleton-time-grid--duration");const s=n*e;for(let i=0;i<s;i++){const l=document.createElement("div");l.classList.add("cal-skeleton"),t.appendChild(l)}return t}function st({rows:n=5}={}){const e=document.createElement("div");e.setAttribute("role","status"),e.setAttribute("aria-label","Loading..."),e.classList.add("cal-skeleton-calendar-grid");for(let t=0;t<7;t++){const s=document.createElement("div");s.classList.add("cal-skeleton","cal-skeleton-calendar-grid__header"),e.appendChild(s)}const a=7*n;for(let t=0;t<a;t++){const s=document.createElement("div");s.classList.add("cal-skeleton","cal-skeleton-calendar-grid__day"),e.appendChild(s)}return e}const Fe=`
|
|
703
|
+
.cal-skeleton-time-grid {
|
|
704
|
+
display: grid;
|
|
705
|
+
grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
|
|
706
|
+
gap: 6px;
|
|
707
|
+
padding: 4px;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
.cal-skeleton-time-grid--duration {
|
|
711
|
+
grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
.cal-skeleton-time-grid .cal-skeleton {
|
|
715
|
+
height: 40px;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
.cal-skeleton-calendar-grid {
|
|
719
|
+
display: grid;
|
|
720
|
+
grid-template-columns: repeat(7, 1fr);
|
|
721
|
+
gap: 2px;
|
|
722
|
+
padding: 4px;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
.cal-skeleton-calendar-grid__header {
|
|
726
|
+
height: 20px;
|
|
727
|
+
margin-bottom: 4px;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
.cal-skeleton-calendar-grid__day {
|
|
731
|
+
height: var(--cal-cell-size, 36px);
|
|
732
|
+
aspect-ratio: 1;
|
|
733
|
+
border-radius: var(--cal-radius-sm) !important;
|
|
734
|
+
}
|
|
735
|
+
`,nt={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 $e({type:n="info",message:e,dismissible:a=!0,onDismiss:t}){const s=document.createElement("div");s.classList.add("cal-status",`cal-status--${n}`,"cal-animate-slide-up"),s.setAttribute("role",n==="error"?"alert":"status"),s.setAttribute("aria-live",n==="error"?"assertive":"polite");const i=document.createElement("span");i.classList.add("cal-status__icon"),i.innerHTML=nt[n]||nt.info,s.appendChild(i);const l=document.createElement("span");if(l.classList.add("cal-status__text"),l.textContent=e,s.appendChild(l),a){const r=document.createElement("button");r.classList.add("cal-status__close"),r.setAttribute("aria-label","Dismiss"),r.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>',r.addEventListener("click",()=>t==null?void 0:t()),s.appendChild(r)}return s}const ze=`
|
|
736
|
+
.cal-status {
|
|
737
|
+
display: flex;
|
|
738
|
+
align-items: center;
|
|
739
|
+
gap: 8px;
|
|
740
|
+
padding: 8px 12px;
|
|
741
|
+
border-radius: var(--cal-radius-sm);
|
|
742
|
+
font-size: 12px;
|
|
743
|
+
line-height: 1.4;
|
|
744
|
+
margin-bottom: 8px;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
.cal-status__icon {
|
|
748
|
+
flex-shrink: 0;
|
|
749
|
+
display: flex;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
.cal-status__text {
|
|
753
|
+
flex: 1;
|
|
754
|
+
min-width: 0;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
.cal-status__close {
|
|
758
|
+
flex-shrink: 0;
|
|
759
|
+
display: flex;
|
|
760
|
+
align-items: center;
|
|
761
|
+
justify-content: center;
|
|
762
|
+
width: 20px;
|
|
763
|
+
height: 20px;
|
|
764
|
+
border-radius: 4px;
|
|
765
|
+
cursor: pointer;
|
|
766
|
+
opacity: 0.7;
|
|
767
|
+
transition: opacity var(--cal-transition);
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
.cal-status__close:hover {
|
|
771
|
+
opacity: 1;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
.cal-status--error {
|
|
775
|
+
background: hsl(var(--cal-status-error-bg));
|
|
776
|
+
color: hsl(var(--cal-status-error-fg));
|
|
777
|
+
border: 1px solid hsl(var(--cal-status-error-border));
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
.cal-status--warning {
|
|
781
|
+
background: hsl(var(--cal-status-warning-bg));
|
|
782
|
+
color: hsl(var(--cal-status-warning-fg));
|
|
783
|
+
border: 1px solid hsl(var(--cal-status-warning-border));
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
.cal-status--info {
|
|
787
|
+
background: hsl(var(--cal-status-info-bg));
|
|
788
|
+
color: hsl(var(--cal-status-info-fg));
|
|
789
|
+
border: 1px solid hsl(var(--cal-status-info-border));
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
.cal-status--success {
|
|
793
|
+
background: hsl(var(--cal-status-success-bg));
|
|
794
|
+
color: hsl(var(--cal-status-success-fg));
|
|
795
|
+
border: 1px solid hsl(var(--cal-status-success-border));
|
|
796
|
+
}
|
|
797
|
+
`,Yt='<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="3" width="12" height="11" rx="2"/><path d="M5 1v3M11 1v3M2 7h12"/></svg>',It=`
|
|
798
|
+
.cal-picker {
|
|
799
|
+
background: hsl(var(--cal-bg));
|
|
800
|
+
border-radius: var(--cal-radius);
|
|
801
|
+
user-select: none;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
:host([display="inline"]) .cal-picker {
|
|
805
|
+
border: 1px solid hsl(var(--cal-border));
|
|
806
|
+
padding: 12px;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
.cal-months {
|
|
810
|
+
display: flex;
|
|
811
|
+
gap: 16px;
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
.cal-month {
|
|
815
|
+
flex: 0 0 auto;
|
|
816
|
+
}
|
|
817
|
+
`;class it extends be{static get styles(){return[Se,Te,Me,Ze,Qe,tt,zt,Oe,Fe,ze,It]}static get observedAttributes(){return["mode","display","theme","value","min-date","max-date","disabled-dates","first-day","locale","presets","placeholder","loading"]}constructor(){super();const e=new Date;this._store=De({viewYear:e.getFullYear(),viewMonth:e.getMonth(),selectedDates:[],rangeStart:null,rangeEnd:null,hoverDate:null,isOpen:!1,focusedDate:ue(),navDirection:null,pickingMonth:!1,pickerYear:e.getFullYear(),statusType:null,statusMessage:null,statusDismissible:!0}),this._popover=null,this._unsubscribe=null,this._rendering=!1}get mode(){return this.getAttribute("mode")||"single"}get display(){return this.getAttribute("display")||"inline"}get placeholder(){return this.getAttribute("placeholder")||"Select date"}get firstDay(){return parseInt(this.getAttribute("first-day")||"0",10)}get minDate(){return this.getAttribute("min-date")||null}get maxDate(){return this.getAttribute("max-date")||null}get loading(){return this.hasAttribute("loading")}set loading(e){e?this.setAttribute("loading",""):this.removeAttribute("loading")}get disabledDates(){const e=this.getAttribute("disabled-dates");return e?e.split(",").map(a=>a.trim()):[]}get presetKeys(){const e=this.getAttribute("presets");return e?e.split(",").map(a=>a.trim()):[]}get value(){const e=this._store.getState();return this.mode==="range"?e.rangeStart&&e.rangeEnd?{start:e.rangeStart,end:e.rangeEnd}:null:this.mode==="multi"?[...e.selectedDates]:e.selectedDates[0]||null}set value(e){if(this.mode==="range"&&e&&typeof e=="object"){const a=typeof e.start=="string"?e.start:Z(e.start),t=typeof e.end=="string"?e.end:Z(e.end);this._store.set({rangeStart:a,rangeEnd:t,selectedDates:[a,t]}),this._navigateToDate(a)}else this.mode==="multi"&&Array.isArray(e)?(this._store.set({selectedDates:e}),e.length&&this._navigateToDate(e[0])):typeof e=="string"?(this._store.set({selectedDates:[e],rangeStart:null,rangeEnd:null}),this._navigateToDate(e)):this._store.set({selectedDates:[],rangeStart:null,rangeEnd:null})}_navigateToDate(e){const a=W(e);a&&this._store.set({viewYear:a.getFullYear(),viewMonth:a.getMonth()})}connectedCallback(){super.connectedCallback(),this._unsubscribe=this._store.subscribe((a,t)=>{if(this._rendering)return;a.hoverDate!==t.hoverDate&&a.viewYear===t.viewYear&&a.viewMonth===t.viewMonth&&a.selectedDates===t.selectedDates&&a.rangeStart===t.rangeStart&&a.rangeEnd===t.rangeEnd&&a.isOpen===t.isOpen&&a.navDirection===t.navDirection&&a.pickingMonth===t.pickingMonth&&a.pickerYear===t.pickerYear?this._updateGridHighlight(a):this.render()});const e=this.getAttribute("value");if(e)if(this.mode==="range"&&e.includes("/")){const[a,t]=e.split("/");this.value={start:a,end:t}}else this.mode==="multi"&&e.includes(",")?this.value=e.split(",").map(a=>a.trim()):this.value=e}disconnectedCallback(){var e,a;(e=this._unsubscribe)==null||e.call(this),(a=this._popover)==null||a.destroy(),clearTimeout(this._statusTimer)}attributeChangedCallback(e,a,t){if(a!==t){if(e==="value"&&this._initialized)if(this.mode==="range"&&t&&t.includes("/")){const[s,i]=t.split("/");this.value={start:s,end:i}}else this.mode==="multi"&&t&&t.includes(",")?this.value=t.split(",").map(s=>s.trim()):this.value=t;this._initialized&&this.render()}}_handleSelect(e){const a=this._store.getState();if(this.mode==="single")this._store.set({selectedDates:[e],focusedDate:e}),this.emit("cal:change",{value:e}),this.display==="popover"&&this.close();else if(this.mode==="range")if(!a.rangeStart||a.rangeEnd)this._store.set({rangeStart:e,rangeEnd:null,selectedDates:[e],focusedDate:e});else{let t=a.rangeStart,s=e;t>s&&([t,s]=[s,t]),this._store.set({rangeStart:t,rangeEnd:s,selectedDates:[t,s],hoverDate:null,focusedDate:s}),this.emit("cal:change",{value:{start:t,end:s}}),this.display==="popover"&&this.close()}else if(this.mode==="multi"){const t=[...a.selectedDates],s=t.findIndex(i=>re(i,e));s>=0?t.splice(s,1):t.push(e),t.sort(),this._store.set({selectedDates:t,focusedDate:e}),this.emit("cal:change",{value:t})}}_handleHover(e){this.mode==="range"&&this._store.set({hoverDate:e})}_handlePresetSelect({start:e,end:a}){this._store.set({rangeStart:e,rangeEnd:a,selectedDates:[e,a],hoverDate:null}),this._navigateToDate(e),this.emit("cal:change",{value:{start:e,end:a}}),this.display==="popover"&&this.close()}_prevMonth(){const{viewYear:e,viewMonth:a}=this._store.getState(),{year:t,month:s}=pe(e,a,-1);this._store.set({viewYear:t,viewMonth:s,navDirection:"prev"}),this.emit("cal:month-change",{year:t,month:s})}_nextMonth(){const{viewYear:e,viewMonth:a}=this._store.getState(),{year:t,month:s}=pe(e,a,1);this._store.set({viewYear:t,viewMonth:s,navDirection:"next"}),this.emit("cal:month-change",{year:t,month:s})}_toggleMonthPicker(){const e=this._store.getState();this._store.set({pickingMonth:!e.pickingMonth,pickerYear:e.viewYear})}_selectMonthFromPicker(e,a){this._store.set({viewYear:a,viewMonth:e,pickingMonth:!1}),this.emit("cal:month-change",{year:a,month:e})}_handleKeydown(e){if(e.key==="Escape"&&this._store.get("pickingMonth")){e.stopPropagation(),this._store.set({pickingMonth:!1});return}const a=this._store.getState(),t=W(a.focusedDate);if(!t)return;let s=null;switch(e.key){case"ArrowLeft":s=new Date(t),s.setDate(t.getDate()-1);break;case"ArrowRight":s=new Date(t),s.setDate(t.getDate()+1);break;case"ArrowUp":s=new Date(t),s.setDate(t.getDate()-7);break;case"ArrowDown":s=new Date(t),s.setDate(t.getDate()+7);break;case"Enter":case" ":e.preventDefault(),this._handleSelect(a.focusedDate);return;case"Escape":this.display==="popover"&&this.close();return;default:return}if(s){e.preventDefault();const i=Z(s);s.getMonth()!==a.viewMonth||s.getFullYear()!==a.viewYear?this._store.set({viewYear:s.getFullYear(),viewMonth:s.getMonth(),focusedDate:i,navDirection:s>t?"next":"prev"}):this._store.set({focusedDate:i}),requestAnimationFrame(()=>{const l=this.$(`[data-date="${i}"]`);l==null||l.focus()})}}_updateGridHighlight(e){const a=this.$$(".cal-day"),{rangeStart:t,hoverDate:s}=e,i=t&&!e.rangeEnd&&s?s:e.rangeEnd;for(const l of a){const r=l.dataset.date;if(!r||l.classList.contains("cal-day--disabled"))continue;const o=r===t,h=r===i;let c=!1;if(t&&i){const d=t<i?t:i,g=t<i?i:t;c=r>=d&&r<=g&&!o&&!h}l.classList.toggle("cal-day--range-start",o&&!!i),l.classList.toggle("cal-day--range-end",h&&!!i),l.classList.toggle("cal-day--in-range",c)}}open(){this._popover&&(this._popover.open(),this._store.set({isOpen:!0}),this.emit("cal:open"))}close(){this._popover&&(this._popover.close(),this._store.set({isOpen:!1}),this.emit("cal:close"))}goToMonth(e,a){this._store.set({viewYear:a,viewMonth:e})}_renderCalendarContent(){const e=this._store.getState(),a=document.createElement("div");if(a.classList.add("cal-picker"),e.statusType&&e.statusMessage&&a.appendChild($e({type:e.statusType,message:e.statusMessage,dismissible:e.statusDismissible,onDismiss:()=>this.clearStatus()})),this.loading){const l=document.createElement("div");l.classList.add("cal-months");const r=document.createElement("div");return r.classList.add("cal-month"),r.appendChild(st()),l.appendChild(r),a.appendChild(l),a.addEventListener("keydown",o=>this._handleKeydown(o)),a}const t=document.createElement("div");t.classList.add("cal-months");const s=this.mode==="range"&&this.hasAttribute("dual"),i=s?2:1;for(let l=0;l<i;l++){const{year:r,month:o}=l===0?{year:e.viewYear,month:e.viewMonth}:pe(e.viewYear,e.viewMonth,1),h=document.createElement("div");if(h.classList.add("cal-month"),l===0&&h.appendChild(Ae({year:r,month:o,onPrev:e.pickingMonth?()=>{}:()=>this._prevMonth(),onNext:e.pickingMonth?()=>{}:()=>{s||this._nextMonth()},onTitleClick:()=>this._toggleMonthPicker()})),l===1&&h.appendChild(Ae({year:r,month:o,onPrev:()=>{},onNext:()=>this._nextMonth()})),e.pickingMonth&&l===0){const c=et({pickerYear:e.pickerYear,viewMonth:e.viewMonth,viewYear:e.viewYear,onMonthSelect:(d,g)=>this._selectMonthFromPicker(d,g),onYearPrev:()=>this._store.set({pickerYear:e.pickerYear-1}),onYearNext:()=>this._store.set({pickerYear:e.pickerYear+1}),onClose:()=>this._store.set({pickingMonth:!1})});h.appendChild(c)}else{const c=e.navDirection==="next"?"cal-animate-slide-left":e.navDirection==="prev"?"cal-animate-slide-right":"",d=Je({year:r,month:o,firstDay:this.firstDay,selectedDates:e.selectedDates,rangeStart:e.rangeStart,rangeEnd:e.rangeEnd,hoverDate:e.hoverDate,minDate:this.minDate,maxDate:this.maxDate,disabledDates:this.disabledDates,mode:this.mode,focusedDate:e.focusedDate,onSelect:g=>this._handleSelect(g),onHover:g=>this._handleHover(g)});c&&d.classList.add(c),h.appendChild(d)}t.appendChild(h)}return a.appendChild(t),this.mode==="range"&&this.presetKeys.length&&a.appendChild($t({presetKeys:this.presetKeys,onSelect:l=>this._handlePresetSelect(l)})),a.addEventListener("keydown",l=>this._handleKeydown(l)),a}_formatTriggerText(){const e=this._store.getState();return this.mode==="range"&&e.rangeStart&&e.rangeEnd?`${this._formatShortDate(e.rangeStart)} – ${this._formatShortDate(e.rangeEnd)}`:e.selectedDates.length?this.mode==="multi"?`${e.selectedDates.length} dates selected`:this._formatShortDate(e.selectedDates[0]):null}_formatShortDate(e){const a=W(e);return a?`${se[a.getMonth()].slice(0,3)} ${a.getDate()}, ${a.getFullYear()}`:e}render(){var t;if(this._rendering)return;this._rendering=!0;const e=this.shadowRoot,a=[...e.childNodes];for(const s of a)s.nodeName!=="STYLE"&&!(s instanceof CSSStyleSheet)&&e.removeChild(s);if((t=this._popover)==null||t.destroy(),this._popover=null,this.display==="popover"){const s=document.createElement("div");s.classList.add("cal-popover-wrapper");const i=document.createElement("button");i.classList.add("cal-trigger");const l=document.createElement("span");l.classList.add("cal-trigger__icon"),l.innerHTML=Yt,i.appendChild(l);const r=this._formatTriggerText(),o=document.createElement("span");r?o.textContent=r:(o.textContent=this.placeholder,o.classList.add("cal-trigger--placeholder")),i.appendChild(o),s.appendChild(i);const h=this._renderCalendarContent(),c=Be({trigger:i,content:h,onClose:()=>{this._store.set({isOpen:!1}),this.emit("cal:close")}});s.appendChild(c.panel),e.appendChild(s),i.addEventListener("click",d=>{d.stopPropagation(),c.isOpen?this.close():this.open()}),this._popover=c,this._store.get("isOpen")&&c.open()}else e.appendChild(this._renderCalendarContent());this._store.set({navDirection:null}),this._rendering=!1}}function ie(n){if(!n||typeof n!="string")return null;const e=n.trim().toUpperCase(),a=e.match(/^(\d{1,2}):(\d{2})\s*(AM|PM)$/);if(a){let s=parseInt(a[1],10);const i=parseInt(a[2],10),l=a[3];return l==="AM"&&s===12&&(s=0),l==="PM"&&s!==12&&(s+=12),{hours:s,minutes:i}}const t=e.match(/^(\d{1,2}):(\d{2})$/);return t?{hours:parseInt(t[1],10),minutes:parseInt(t[2],10)}:null}function oe(n,e,a="24h"){const t=String(e).padStart(2,"0");if(a==="12h"){const s=n>=12?"PM":"AM";return`${n%12||12}:${t} ${s}`}return`${String(n).padStart(2,"0")}:${t}`}function b(n){const e=ie(n);return e?e.hours*60+e.minutes:0}function le(n){const e=Math.floor(n/60)%24,a=n%60;return`${String(e).padStart(2,"0")}:${String(a).padStart(2,"0")}`}function Ee(n,e,a){const t=[],s=b(n),i=b(e);for(let l=s;l<=i;l+=a)t.push(le(l));return t}function lt(n,e,a,t="24h"){const s=[],i=b(n),l=b(e);for(let r=i;r<=l;r+=a){const o=le(r),h=r+a,c=le(Math.min(h,l+a)),d=ie(o),g=ie(c),u=d?oe(d.hours,d.minutes,t):o,p=g?oe(g.hours,g.minutes,t):c;s.push({time:o,displayText:`${u}–${p}`})}return s}function rt(){const n=new Date;return`${String(n.getHours()).padStart(2,"0")}:${String(n.getMinutes()).padStart(2,"0")}`}function ot(n,e,a){const t=b(n),s=b(e),i=b(a),l=Math.min(s,i),r=Math.max(s,i);return t>=l&&t<=r}function ct(n){const{slots:e=[],mode:a="single",format:t="24h",selected:s,hoverTime:i,rangeStart:l,unavailableTimes:r=[],onSelect:o,onHover:h,durationLabels:c=!1}=n,d=document.createElement("div");d.classList.add("cal-time-grid"),c&&d.classList.add("cal-time-grid--duration"),d.setAttribute("role","listbox"),a==="multi"&&d.setAttribute("aria-multiselectable","true");for(const g of e){const u=document.createElement("button");u.classList.add("cal-time-slot"),u.setAttribute("role","option"),u.dataset.time=g.time;const p=ie(g.time),_=g.displayText?g.displayText:p?oe(p.hours,p.minutes,t):g.time,m=document.createElement("span");if(m.classList.add("cal-time-slot__time"),m.textContent=_,u.appendChild(m),g.label){const k=document.createElement("span");k.classList.add("cal-time-slot__label"),k.textContent=g.label,u.appendChild(k)}const v=g.available===!1||r.includes(g.time);if(v&&(u.classList.add("cal-time-slot--unavailable"),u.disabled=!0,u.setAttribute("aria-disabled","true")),Pt(g.time,s,a)?(u.classList.add("cal-time-slot--selected"),u.setAttribute("aria-selected","true")):u.setAttribute("aria-selected","false"),a==="range"&&l&&!Ht(s)&&i){const k=ot(g.time,l,i),S=g.time===l,B=g.time===i;k&&!S&&!B&&u.classList.add("cal-time-slot--in-range"),S&&u.classList.add("cal-time-slot--range-start"),B&&u.classList.add("cal-time-slot--range-end")}else if(a==="range"&&s&&typeof s=="object"&&s.start&&s.end){const k=ot(g.time,s.start,s.end),S=g.time===s.start,B=g.time===s.end;S&&u.classList.add("cal-time-slot--range-start","cal-time-slot--selected"),B&&u.classList.add("cal-time-slot--range-end","cal-time-slot--selected"),k&&!S&&!B&&u.classList.add("cal-time-slot--in-range")}v||(u.addEventListener("click",()=>o==null?void 0:o(g.time)),u.addEventListener("mouseenter",()=>h==null?void 0:h(g.time))),d.appendChild(u)}return d.addEventListener("mouseleave",()=>h==null?void 0:h(null)),d}function Pt(n,e,a){return e?a==="single"?e===n:a==="multi"?Array.isArray(e)&&e.includes(n):a==="range"&&typeof e=="object"&&e.start&&e.end?e.start===n||e.end===n:!1:!1}function Ht(n){return n&&typeof n=="object"&&n.start&&n.end}const dt=`
|
|
818
|
+
.cal-time-grid {
|
|
819
|
+
display: grid;
|
|
820
|
+
grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
|
|
821
|
+
gap: 6px;
|
|
822
|
+
max-height: 280px;
|
|
823
|
+
overflow-y: auto;
|
|
824
|
+
padding: 4px;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
.cal-time-grid::-webkit-scrollbar {
|
|
828
|
+
width: 6px;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
.cal-time-grid::-webkit-scrollbar-track {
|
|
832
|
+
background: transparent;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
.cal-time-grid::-webkit-scrollbar-thumb {
|
|
836
|
+
background: hsl(var(--cal-border));
|
|
837
|
+
border-radius: 3px;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
.cal-time-slot {
|
|
841
|
+
display: flex;
|
|
842
|
+
flex-direction: column;
|
|
843
|
+
align-items: center;
|
|
844
|
+
justify-content: center;
|
|
845
|
+
height: 40px;
|
|
846
|
+
padding: 0 8px;
|
|
847
|
+
border-radius: 999px;
|
|
848
|
+
font-size: 13px;
|
|
849
|
+
background: hsl(var(--cal-bg-muted));
|
|
850
|
+
color: hsl(var(--cal-fg));
|
|
851
|
+
transition: background var(--cal-transition), color var(--cal-transition);
|
|
852
|
+
gap: 1px;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
.cal-time-slot:not(.cal-time-slot--unavailable):not(.cal-time-slot--selected):hover {
|
|
856
|
+
background: hsl(var(--cal-hover));
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
.cal-time-slot__time {
|
|
860
|
+
font-weight: 500;
|
|
861
|
+
line-height: 1;
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
.cal-time-slot__label {
|
|
865
|
+
font-size: 9px;
|
|
866
|
+
opacity: 0.7;
|
|
867
|
+
line-height: 1;
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
.cal-time-slot--selected {
|
|
871
|
+
background: hsl(var(--cal-accent));
|
|
872
|
+
color: hsl(var(--cal-accent-fg));
|
|
873
|
+
font-weight: 600;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
.cal-time-slot--in-range {
|
|
877
|
+
background: hsl(var(--cal-accent-subtle));
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
.cal-time-slot--range-start,
|
|
881
|
+
.cal-time-slot--range-end {
|
|
882
|
+
background: hsl(var(--cal-accent));
|
|
883
|
+
color: hsl(var(--cal-accent-fg));
|
|
884
|
+
font-weight: 600;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
.cal-time-slot--unavailable {
|
|
888
|
+
opacity: 0.3;
|
|
889
|
+
cursor: not-allowed;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
.cal-time-grid--duration {
|
|
893
|
+
grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
.cal-time-grid--duration .cal-time-slot {
|
|
897
|
+
font-size: 12px;
|
|
898
|
+
}
|
|
899
|
+
`,Bt='<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="3" width="12" height="11" rx="2"/><path d="M5 1v3M11 1v3M2 7h12"/></svg>',Ot=`
|
|
900
|
+
.cal-picker {
|
|
901
|
+
background: hsl(var(--cal-bg));
|
|
902
|
+
border-radius: var(--cal-radius);
|
|
903
|
+
user-select: none;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
:host([display="inline"]) .cal-picker {
|
|
907
|
+
border: 1px solid hsl(var(--cal-border));
|
|
908
|
+
padding: 12px;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
.cal-months {
|
|
912
|
+
display: flex;
|
|
913
|
+
gap: 16px;
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
.cal-month {
|
|
917
|
+
flex: 0 0 auto;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
/* Time section */
|
|
921
|
+
.cal-booking-time-section {
|
|
922
|
+
margin-top: 12px;
|
|
923
|
+
padding-top: 12px;
|
|
924
|
+
border-top: 1px solid hsl(var(--cal-border));
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
.cal-booking-time-header {
|
|
928
|
+
font-size: 13px;
|
|
929
|
+
font-weight: 600;
|
|
930
|
+
color: hsl(var(--cal-fg));
|
|
931
|
+
margin-bottom: 8px;
|
|
932
|
+
}
|
|
933
|
+
`;class ht extends be{static get styles(){return[Se,Te,Me,Ze,dt,Qe,tt,Oe,Fe,ze,Ot]}static get observedAttributes(){return["theme","display","min-date","max-date","first-day","placeholder","dual","show-labels-on-hover","time-slots","time-start","time-end","time-interval","time-format","duration-labels","loading"]}constructor(){super();const e=new Date;this._store=De({viewYear:e.getFullYear(),viewMonth:e.getMonth(),rangeStart:null,rangeEnd:null,hoverDate:null,isOpen:!1,focusedDate:ue(),navDirection:null,pickingMonth:!1,pickerYear:e.getFullYear(),startTime:null,endTime:null,timeSelectPhase:null,statusType:null,statusMessage:null,statusDismissible:!0}),this._bookings=[],this._dayData={},this._labelFormula=null,this._timeSlots=null,this._popover=null,this._unsubscribe=null,this._rendering=!1}get display(){return this.getAttribute("display")||"inline"}get placeholder(){return this.getAttribute("placeholder")||"Select dates"}get firstDay(){return parseInt(this.getAttribute("first-day")||"0",10)}get minDate(){return this.getAttribute("min-date")||null}get maxDate(){return this.getAttribute("max-date")||null}get showLabelsOnHover(){return this.hasAttribute("show-labels-on-hover")}get timeSlotsEnabled(){return this.hasAttribute("time-slots")}get timeStartTime(){return this.getAttribute("time-start")||"09:00"}get timeEndTime(){return this.getAttribute("time-end")||"17:00"}get timeInterval(){return parseInt(this.getAttribute("time-interval")||"60",10)}get timeFormat(){return this.getAttribute("time-format")||"24h"}get durationLabels(){return this.hasAttribute("duration-labels")}get loading(){return this.hasAttribute("loading")}set loading(e){e?this.setAttribute("loading",""):this.removeAttribute("loading")}get bookings(){return this._bookings}set bookings(e){this._bookings=Array.isArray(e)?e:[],this._initialized&&this.render()}get dayData(){return this._dayData}set dayData(e){this._dayData=e&&typeof e=="object"?e:{},this._initialized&&this.render()}get labelFormula(){return this._labelFormula}set labelFormula(e){this._labelFormula=typeof e=="function"?e:null,this._initialized&&this.render()}get timeSlots(){return this._timeSlots}set timeSlots(e){this._timeSlots=Array.isArray(e)?e:null,this._initialized&&this.render()}get value(){const e=this._store.getState();if(!e.rangeStart||!e.rangeEnd)return null;const a={start:e.rangeStart,end:e.rangeEnd};return this.timeSlotsEnabled&&(e.startTime&&(a.startTime=e.startTime),e.endTime&&(a.endTime=e.endTime)),a}set value(e){if(e&&typeof e=="object"&&e.start&&e.end){const a=typeof e.start=="string"?e.start:Z(e.start),t=typeof e.end=="string"?e.end:Z(e.end),s={rangeStart:a,rangeEnd:t};e.startTime&&(s.startTime=e.startTime),e.endTime&&(s.endTime=e.endTime),this._store.set(s),this._navigateToDate(a)}else this._store.set({rangeStart:null,rangeEnd:null,startTime:null,endTime:null,timeSelectPhase:null})}_navigateToDate(e){const a=W(e);a&&this._store.set({viewYear:a.getFullYear(),viewMonth:a.getMonth()})}connectedCallback(){super.connectedCallback(),this._unsubscribe=this._store.subscribe((a,t)=>{if(this._rendering)return;a.hoverDate!==t.hoverDate&&a.viewYear===t.viewYear&&a.viewMonth===t.viewMonth&&a.rangeStart===t.rangeStart&&a.rangeEnd===t.rangeEnd&&a.isOpen===t.isOpen&&a.navDirection===t.navDirection&&a.pickingMonth===t.pickingMonth&&a.pickerYear===t.pickerYear&&a.timeSelectPhase===t.timeSelectPhase?this._updateGridHighlight(a):this.render()});const e=this.getAttribute("bookings");if(e&&!this._bookings.length)try{this._bookings=JSON.parse(e)}catch{}}disconnectedCallback(){var e,a;(e=this._unsubscribe)==null||e.call(this),(a=this._popover)==null||a.destroy(),clearTimeout(this._statusTimer)}attributeChangedCallback(e,a,t){a!==t&&this._initialized&&this.render()}_handleSelect(e){const a=this._store.getState();if(!a.rangeStart||a.rangeEnd)this._store.set({rangeStart:e,rangeEnd:null,hoverDate:null,focusedDate:e,startTime:null,endTime:null,timeSelectPhase:null});else{let t=a.rangeStart,s=e;if(t>s&&([t,s]=[s,t]),!Ve(t,s,this._bookings)){this.emit("cal:selection-invalid",{start:t,end:s}),this._store.set({rangeStart:null,rangeEnd:null,hoverDate:null,startTime:null,endTime:null,timeSelectPhase:null}),this.showStatus("error","Selection overlaps an existing booking",{autoDismiss:4e3});return}this.timeSlotsEnabled?this._store.set({rangeStart:t,rangeEnd:s,hoverDate:null,focusedDate:s,timeSelectPhase:"start"}):(this._store.set({rangeStart:t,rangeEnd:s,hoverDate:null,focusedDate:s}),this.emit("cal:change",{value:{start:t,end:s}}),this.display==="popover"&&this.close())}}_handleTimeSelect(e){const a=this._store.getState();if(a.timeSelectPhase==="start")this._store.set({startTime:e,timeSelectPhase:"end"});else if(a.timeSelectPhase==="end"){this._store.set({endTime:e,timeSelectPhase:null});const t={start:a.rangeStart,end:a.rangeEnd,startTime:a.startTime,endTime:e};this.emit("cal:change",{value:t}),this.display==="popover"&&this.close()}}_handleHover(e){this._store.set({hoverDate:e})}_updateGridHighlight(e){const a=this.$$(".cal-day"),{rangeStart:t,hoverDate:s}=e,i=t&&!e.rangeEnd&&s?s:e.rangeEnd;let l=!1;if(t&&!e.rangeEnd&&s){const r=t<s?t:s,o=t<s?s:t;for(const h of this._bookings)if(r<h.end&&o>h.start){l=!0;break}}for(const r of a){const o=r.dataset.date;if(!o)continue;const h=o===t&&!!i,c=o===i&&!!i;let d=!1;if(t&&i){const u=t<i?t:i,p=t<i?i:t;d=o>=u&&o<=p&&!h&&!c}const g=l&&t&&!e.rangeEnd&&s&&(()=>{const u=t<s?t:s,p=t<s?s:t;return o>=u&&o<=p})();r.classList.toggle("cal-day--range-start",h),r.classList.toggle("cal-day--range-end",c),r.classList.toggle("cal-day--in-range",d),r.classList.toggle("cal-day--invalid-range",!!g)}}_prevMonth(){const{viewYear:e,viewMonth:a}=this._store.getState(),{year:t,month:s}=pe(e,a,-1);this._store.set({viewYear:t,viewMonth:s,navDirection:"prev"}),this.emit("cal:month-change",{year:t,month:s})}_nextMonth(){const{viewYear:e,viewMonth:a}=this._store.getState(),{year:t,month:s}=pe(e,a,1);this._store.set({viewYear:t,viewMonth:s,navDirection:"next"}),this.emit("cal:month-change",{year:t,month:s})}_toggleMonthPicker(){const e=this._store.getState();this._store.set({pickingMonth:!e.pickingMonth,pickerYear:e.viewYear})}_selectMonthFromPicker(e,a){this._store.set({viewYear:a,viewMonth:e,pickingMonth:!1}),this.emit("cal:month-change",{year:a,month:e})}_handleKeydown(e){if(e.key==="Escape"&&this._store.get("pickingMonth")){e.stopPropagation(),this._store.set({pickingMonth:!1});return}const a=this._store.getState(),t=W(a.focusedDate);if(!t)return;let s=null;switch(e.key){case"ArrowLeft":s=new Date(t),s.setDate(t.getDate()-1);break;case"ArrowRight":s=new Date(t),s.setDate(t.getDate()+1);break;case"ArrowUp":s=new Date(t),s.setDate(t.getDate()-7);break;case"ArrowDown":s=new Date(t),s.setDate(t.getDate()+7);break;case"Enter":case" ":e.preventDefault(),this._handleSelect(a.focusedDate);return;case"Escape":this.display==="popover"&&this.close();return;default:return}if(s){e.preventDefault();const i=Z(s);s.getMonth()!==a.viewMonth||s.getFullYear()!==a.viewYear?this._store.set({viewYear:s.getFullYear(),viewMonth:s.getMonth(),focusedDate:i,navDirection:s>t?"next":"prev"}):this._store.set({focusedDate:i}),requestAnimationFrame(()=>{const l=this.$(`[data-date="${i}"]`);l==null||l.focus()})}}open(){this._popover&&(this._popover.open(),this._store.set({isOpen:!0}),this.emit("cal:open"))}close(){this._popover&&(this._popover.close(),this._store.set({isOpen:!1}),this.emit("cal:close"))}goToMonth(e,a){this._store.set({viewYear:a,viewMonth:e})}_getTimeSlotArray(){return this._timeSlots?this._timeSlots:this.durationLabels?lt(this.timeStartTime,this.timeEndTime,this.timeInterval,this.timeFormat).map(a=>({...a,available:!0})):Ee(this.timeStartTime,this.timeEndTime,this.timeInterval).map(a=>({time:a,available:!0}))}_renderCalendarContent(){const e=this._store.getState(),a=document.createElement("div");if(a.classList.add("cal-picker"),e.statusType&&e.statusMessage&&a.appendChild($e({type:e.statusType,message:e.statusMessage,dismissible:e.statusDismissible,onDismiss:()=>this.clearStatus()})),this.loading){const l=document.createElement("div");l.classList.add("cal-months");const r=document.createElement("div");if(r.classList.add("cal-month"),r.appendChild(st()),l.appendChild(r),a.appendChild(l),this.timeSlotsEnabled){const o=document.createElement("div");o.classList.add("cal-booking-time-section"),o.appendChild(at({durationLabels:this.durationLabels})),a.appendChild(o)}return a.addEventListener("keydown",o=>this._handleKeydown(o)),a}const t=document.createElement("div");t.classList.add("cal-months");const s=this.hasAttribute("dual"),i=s?2:1;for(let l=0;l<i;l++){const{year:r,month:o}=l===0?{year:e.viewYear,month:e.viewMonth}:pe(e.viewYear,e.viewMonth,1),h=document.createElement("div");if(h.classList.add("cal-month"),l===0&&h.appendChild(Ae({year:r,month:o,onPrev:e.pickingMonth?()=>{}:()=>this._prevMonth(),onNext:e.pickingMonth?()=>{}:()=>{s||this._nextMonth()},onTitleClick:()=>this._toggleMonthPicker()})),l===1&&h.appendChild(Ae({year:r,month:o,onPrev:()=>{},onNext:()=>this._nextMonth()})),e.pickingMonth&&l===0){const c=et({pickerYear:e.pickerYear,viewMonth:e.viewMonth,viewYear:e.viewYear,onMonthSelect:(d,g)=>this._selectMonthFromPicker(d,g),onYearPrev:()=>this._store.set({pickerYear:e.pickerYear-1}),onYearNext:()=>this._store.set({pickerYear:e.pickerYear+1}),onClose:()=>this._store.set({pickingMonth:!1})});h.appendChild(c)}else{const c=e.navDirection==="next"?"cal-animate-slide-left":e.navDirection==="prev"?"cal-animate-slide-right":"",d=Je({year:r,month:o,firstDay:this.firstDay,rangeStart:e.rangeStart,rangeEnd:e.rangeEnd,hoverDate:e.hoverDate,minDate:this.minDate,maxDate:this.maxDate,focusedDate:e.focusedDate,mode:"range",onSelect:g=>this._handleSelect(g),onHover:g=>this._handleHover(g),bookings:this._bookings,dayData:this._dayData,labelFormula:this._labelFormula,showLabelsOnHover:this.showLabelsOnHover});c&&d.classList.add(c),h.appendChild(d)}t.appendChild(h)}if(a.appendChild(t),this.timeSlotsEnabled&&e.timeSelectPhase&&!e.pickingMonth){const l=document.createElement("div");l.classList.add("cal-booking-time-section");const r=document.createElement("div");r.classList.add("cal-booking-time-header"),r.textContent=e.timeSelectPhase==="start"?"Select check-in time":"Select check-out time",l.appendChild(r);const o=this._getTimeSlotArray(),h=ct({slots:o,mode:"single",format:this.timeFormat,selected:e.timeSelectPhase==="end"?e.startTime:null,onSelect:c=>this._handleTimeSelect(c),onHover:()=>{},durationLabels:this.durationLabels});l.appendChild(h),a.appendChild(l)}return a.addEventListener("keydown",l=>this._handleKeydown(l)),a}_formatTriggerText(){const e=this._store.getState();if(e.rangeStart&&e.rangeEnd){let a=`${this._formatShortDate(e.rangeStart)} – ${this._formatShortDate(e.rangeEnd)}`;return e.startTime&&e.endTime&&(a+=` (${e.startTime} – ${e.endTime})`),a}return null}_formatShortDate(e){const a=W(e);return a?`${se[a.getMonth()].slice(0,3)} ${a.getDate()}, ${a.getFullYear()}`:e}render(){var t;if(this._rendering)return;this._rendering=!0;const e=this.shadowRoot,a=[...e.childNodes];for(const s of a)s.nodeName!=="STYLE"&&!(s instanceof CSSStyleSheet)&&e.removeChild(s);if((t=this._popover)==null||t.destroy(),this._popover=null,this.display==="popover"){const s=document.createElement("div");s.classList.add("cal-popover-wrapper");const i=document.createElement("button");i.classList.add("cal-trigger");const l=document.createElement("span");l.classList.add("cal-trigger__icon"),l.innerHTML=Bt,i.appendChild(l);const r=this._formatTriggerText(),o=document.createElement("span");r?o.textContent=r:(o.textContent=this.placeholder,o.classList.add("cal-trigger--placeholder")),i.appendChild(o),s.appendChild(i);const h=this._renderCalendarContent(),c=Be({trigger:i,content:h,onClose:()=>{this._store.set({isOpen:!1}),this.emit("cal:close")}});s.appendChild(c.panel),e.appendChild(s),i.addEventListener("click",d=>{d.stopPropagation(),c.isOpen?this.close():this.open()}),this._popover=c,this._store.get("isOpen")&&c.open()}else e.appendChild(this._renderCalendarContent());this._store.set({navDirection:null}),this._rendering=!1}}const Ft='<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="8" cy="8" r="6"/><path d="M8 4.5V8l2.5 1.5"/></svg>',Nt=`
|
|
934
|
+
.cal-timepicker {
|
|
935
|
+
background: hsl(var(--cal-bg));
|
|
936
|
+
border-radius: var(--cal-radius);
|
|
937
|
+
user-select: none;
|
|
938
|
+
min-width: 200px;
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
:host([display="inline"]) .cal-timepicker {
|
|
942
|
+
border: 1px solid hsl(var(--cal-border));
|
|
943
|
+
padding: 12px;
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
.cal-timepicker__header {
|
|
947
|
+
font-size: 14px;
|
|
948
|
+
font-weight: 600;
|
|
949
|
+
color: hsl(var(--cal-fg));
|
|
950
|
+
margin-bottom: 8px;
|
|
951
|
+
padding: 0 4px;
|
|
952
|
+
}
|
|
953
|
+
`;class ut extends be{static get styles(){return[Se,Te,Me,dt,Oe,Fe,ze,Nt]}static get observedAttributes(){return["mode","display","theme","start-time","end-time","interval","format","placeholder","value","duration-labels","loading"]}constructor(){super(),this._store=De({selected:null,rangeStart:null,hoverTime:null,isOpen:!1,statusType:null,statusMessage:null,statusDismissible:!0}),this._slots=null,this._unavailableTimes=[],this._popover=null,this._unsubscribe=null,this._rendering=!1}get mode(){return this.getAttribute("mode")||"single"}get display(){return this.getAttribute("display")||"inline"}get placeholder(){return this.getAttribute("placeholder")||"Select time"}get startTime(){return this.getAttribute("start-time")||"09:00"}get endTime(){return this.getAttribute("end-time")||"17:00"}get interval(){return parseInt(this.getAttribute("interval")||"30",10)}get format(){return this.getAttribute("format")||"24h"}get durationLabels(){return this.hasAttribute("duration-labels")}get loading(){return this.hasAttribute("loading")}set loading(e){e?this.setAttribute("loading",""):this.removeAttribute("loading")}get slots(){return this._slots}set slots(e){this._slots=Array.isArray(e)?e:null,this._initialized&&this.render()}get unavailableTimes(){return this._unavailableTimes}set unavailableTimes(e){this._unavailableTimes=Array.isArray(e)?e:[],this._initialized&&this.render()}get value(){return this._store.getState().selected}set value(e){this.mode==="single"&&typeof e=="string"?this._store.set({selected:e,rangeStart:null}):this.mode==="multi"&&Array.isArray(e)?this._store.set({selected:[...e].sort((a,t)=>b(a)-b(t)),rangeStart:null}):this.mode==="range"&&e&&typeof e=="object"?this._store.set({selected:{start:e.start,end:e.end},rangeStart:null}):this._store.set({selected:null,rangeStart:null})}_getEffectiveSlots(){return this._slots?this._slots:this.durationLabels?lt(this.startTime,this.endTime,this.interval,this.format).map(t=>({...t,available:!this._unavailableTimes.includes(t.time)})):Ee(this.startTime,this.endTime,this.interval).map(a=>({time:a,available:!this._unavailableTimes.includes(a)}))}connectedCallback(){super.connectedCallback(),this._unsubscribe=this._store.subscribe((a,t)=>{if(this._rendering)return;a.hoverTime!==t.hoverTime&&a.selected===t.selected&&a.rangeStart===t.rangeStart&&a.isOpen===t.isOpen?this._updateSlotHighlight(a):this.render()});const e=this.getAttribute("value");if(e)if(this.mode==="multi"&&e.includes(","))this.value=e.split(",").map(a=>a.trim());else if(this.mode==="range"&&e.includes("/")){const[a,t]=e.split("/");this.value={start:a.trim(),end:t.trim()}}else this.value=e}disconnectedCallback(){var e,a;(e=this._unsubscribe)==null||e.call(this),(a=this._popover)==null||a.destroy(),clearTimeout(this._statusTimer)}attributeChangedCallback(e,a,t){if(a!==t){if(e==="value"&&this._initialized)if(this.mode==="multi"&&t&&t.includes(","))this.value=t.split(",").map(s=>s.trim());else if(this.mode==="range"&&t&&t.includes("/")){const[s,i]=t.split("/");this.value={start:s.trim(),end:i.trim()}}else this.value=t;this._initialized&&this.render()}}_handleSelect(e){const a=this._store.getState();if(this.mode==="single")this._store.set({selected:e}),this.emit("cal:time-change",{value:e}),this.display==="popover"&&this.close();else if(this.mode==="multi"){const t=Array.isArray(a.selected)?[...a.selected]:[],s=t.indexOf(e);s>=0?t.splice(s,1):t.push(e),t.sort((i,l)=>b(i)-b(l)),this._store.set({selected:t}),this.emit("cal:time-change",{value:t})}else if(this.mode==="range")if(!a.rangeStart||a.selected&&typeof a.selected=="object"&&a.selected.start&&a.selected.end)this._store.set({rangeStart:e,selected:null,hoverTime:null});else{let t=a.rangeStart,s=e;b(t)>b(s)&&([t,s]=[s,t]);const i={start:t,end:s};this._store.set({selected:i,rangeStart:null,hoverTime:null}),this.emit("cal:time-change",{value:i}),this.display==="popover"&&this.close()}}_handleHover(e){this.mode==="range"&&this._store.set({hoverTime:e})}_updateSlotHighlight(e){const a=this.$$(".cal-time-slot"),{rangeStart:t,hoverTime:s,selected:i}=e,l=i&&typeof i=="object"&&i.start&&i.end;for(const r of a){const o=r.dataset.time;if(!(!o||r.disabled))if(t&&!l&&s){const h=b(t)<b(s)?t:s,c=b(t)<b(s)?s:t,d=b(o),g=d>b(h)&&d<b(c),u=o===t,p=o===s;r.classList.toggle("cal-time-slot--range-start",u),r.classList.toggle("cal-time-slot--range-end",p),r.classList.toggle("cal-time-slot--in-range",g)}else t||r.classList.remove("cal-time-slot--range-start","cal-time-slot--range-end","cal-time-slot--in-range")}}open(){this._popover&&(this._popover.open(),this._store.set({isOpen:!0}),this.emit("cal:open"))}close(){this._popover&&(this._popover.close(),this._store.set({isOpen:!1}),this.emit("cal:close"))}_renderTimepickerContent(){const e=this._store.getState(),a=document.createElement("div");a.classList.add("cal-timepicker"),e.statusType&&e.statusMessage&&a.appendChild($e({type:e.statusType,message:e.statusMessage,dismissible:e.statusDismissible,onDismiss:()=>this.clearStatus()}));const t=document.createElement("div");if(t.classList.add("cal-timepicker__header"),t.textContent="Select Time",a.appendChild(t),this.loading)a.appendChild(at({durationLabels:this.durationLabels}));else{const s=this._getEffectiveSlots(),i=ct({slots:s,mode:this.mode,format:this.format,selected:e.selected,hoverTime:e.hoverTime,rangeStart:e.rangeStart,unavailableTimes:this._unavailableTimes,onSelect:l=>this._handleSelect(l),onHover:l=>this._handleHover(l),durationLabels:this.durationLabels});a.appendChild(i)}return a}_formatTriggerText(){const e=this._store.getState();return e.selected?this.mode==="single"&&typeof e.selected=="string"?e.selected:this.mode==="multi"&&Array.isArray(e.selected)&&e.selected.length?`${e.selected.length} time${e.selected.length>1?"s":""} selected`:this.mode==="range"&&typeof e.selected=="object"&&e.selected.start?`${e.selected.start} – ${e.selected.end}`:null:null}render(){var t;if(this._rendering)return;this._rendering=!0;const e=this.shadowRoot,a=[...e.childNodes];for(const s of a)s.nodeName!=="STYLE"&&!(s instanceof CSSStyleSheet)&&e.removeChild(s);if((t=this._popover)==null||t.destroy(),this._popover=null,this.display==="popover"){const s=document.createElement("div");s.classList.add("cal-popover-wrapper");const i=document.createElement("button");i.classList.add("cal-trigger");const l=document.createElement("span");l.classList.add("cal-trigger__icon"),l.innerHTML=Ft,i.appendChild(l);const r=this._formatTriggerText(),o=document.createElement("span");r?o.textContent=r:(o.textContent=this.placeholder,o.classList.add("cal-trigger--placeholder")),i.appendChild(o),s.appendChild(i);const h=this._renderTimepickerContent(),c=Be({trigger:i,content:h,onClose:()=>{this._store.set({isOpen:!1}),this.emit("cal:close")}});s.appendChild(c.panel),e.appendChild(s),i.addEventListener("click",d=>{d.stopPropagation(),c.isOpen?this.close():this.open()}),this._popover=c,this._store.get("isOpen")&&c.open()}else e.appendChild(this._renderTimepickerContent());this._rendering=!1}}function Rt(n,e=0){const a=W(n);if(!a)return n;const s=(a.getDay()-e+7)%7;return a.setDate(a.getDate()-s),Z(a)}function Ne(n,e=0){const a=Rt(n,e),t=[];for(let s=0;s<7;s++)t.push(ye(a,s));return t}function jt(n,e,a){const t=W(e);if(!t)return"";if(n==="day")return`${se[t.getMonth()]} ${t.getDate()}, ${t.getFullYear()}`;if(n==="week"&&a&&a.length===7){const s=W(a[0]),i=W(a[6]);return!s||!i?"":s.getMonth()===i.getMonth()?`${se[s.getMonth()]} ${s.getDate()}–${i.getDate()}, ${s.getFullYear()}`:s.getFullYear()===i.getFullYear()?`${se[s.getMonth()].slice(0,3)} ${s.getDate()} – ${se[i.getMonth()].slice(0,3)} ${i.getDate()}, ${s.getFullYear()}`:`${se[s.getMonth()].slice(0,3)} ${s.getDate()}, ${s.getFullYear()} – ${se[i.getMonth()].slice(0,3)} ${i.getDate()}, ${i.getFullYear()}`}return n==="month"?`${se[t.getMonth()]} ${t.getFullYear()}`:""}function Le(n,e){return n.filter(a=>a.start?a.end&&a.end!==a.start?e>=a.start&&e<=a.end:a.start===e:!1)}function Ye(n){if(!n.length)return n;const e=[...n].sort((t,s)=>{const i=b(t.startTime||"00:00"),l=b(s.startTime||"00:00");if(i!==l)return i-l;const r=b(t.endTime||"23:59");return b(s.endTime||"23:59")-l-(r-i)}),a=[];for(const t of e){const s=b(t.startTime||"00:00"),i=b(t.endTime||"23:59");let l=!1;for(let r=0;r<a.length;r++)if(s>=a[r]){t._col=r,a[r]=i,l=!0;break}l||(t._col=a.length,a.push(i))}for(const t of e){const s=b(t.startTime||"00:00"),i=b(t.endTime||"23:59");let l=t._col;for(const r of e){const o=b(r.startTime||"00:00"),h=b(r.endTime||"23:59");o<i&&h>s&&(l=Math.max(l,r._col))}t._totalCols=l+1}return e}function ge(n,e,a,t){return(b(n)-b(e))/t*a}function pt(n,e,a,t){const s=n/a*t,i=b(e)+s;return le(Math.round(i))}function gt(n,e){const a=b(n),t=Math.round(a/e)*e;return le(t)}function qt(n,e,a){return Le(n,a).filter(t=>t.resourceId===e)}function mt(n,e,a,t,s){const i=qt(n,e,a),l=b(t),r=b(s);for(const o of i){if(!o.startTime||!o.endTime)continue;const h=b(o.startTime),c=b(o.endTime);if(l<c&&r>h)return!1}return!0}function Wt(n,e,a,t,s="08:00",i="18:00"){const{duration:l,resourceId:r,minCapacity:o}=n,h=n.date||ue(),c=14;let d=e;r&&(d=e.filter(p=>p.id===r)),o&&(d=d.filter(p=>p.capacity&&p.capacity>=o));const g=b(s),u=b(i);for(let p=0;p<c;p++){const _=ye(h,p);for(const m of d)for(let v=g;v+l<=u;v+=t){const C=le(v),k=le(v+l);if(mt(a,m.id,_,C,k))return{resourceId:m.id,date:_,startTime:C,endTime:k}}}return null}function Xt({title:n,view:e,onPrev:a,onNext:t,onToday:s,onViewChange:i}){const l=document.createElement("div");l.classList.add("cal-sched-nav");const r=document.createElement("div");r.classList.add("cal-sched-nav__left");const o=document.createElement("button");o.classList.add("cal-sched-nav__btn"),o.innerHTML=Pe,o.setAttribute("aria-label","Previous"),o.addEventListener("click",a);const h=document.createElement("button");h.classList.add("cal-sched-nav__btn"),h.innerHTML=He,h.setAttribute("aria-label","Next"),h.addEventListener("click",t);const c=document.createElement("button");c.classList.add("cal-sched-nav__today"),c.textContent="Today",c.addEventListener("click",s);const d=document.createElement("span");d.classList.add("cal-sched-nav__title"),d.setAttribute("aria-live","polite"),d.textContent=n,r.appendChild(o),r.appendChild(h),r.appendChild(c),r.appendChild(d);const g=document.createElement("div");g.classList.add("cal-sched-nav__tabs");for(const u of["day","week","month"]){const p=document.createElement("button");p.classList.add("cal-sched-nav__tab"),u===e&&p.classList.add("cal-sched-nav__tab--active"),p.textContent=u.charAt(0).toUpperCase()+u.slice(1),p.addEventListener("click",()=>i(u)),g.appendChild(p)}return l.appendChild(r),l.appendChild(g),l}const Gt=`
|
|
954
|
+
.cal-sched-nav {
|
|
955
|
+
display: flex;
|
|
956
|
+
align-items: center;
|
|
957
|
+
justify-content: space-between;
|
|
958
|
+
padding: 8px 0;
|
|
959
|
+
gap: 8px;
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
.cal-sched-nav__left {
|
|
963
|
+
display: flex;
|
|
964
|
+
align-items: center;
|
|
965
|
+
gap: 4px;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
.cal-sched-nav__btn {
|
|
969
|
+
display: flex;
|
|
970
|
+
align-items: center;
|
|
971
|
+
justify-content: center;
|
|
972
|
+
width: 28px;
|
|
973
|
+
height: 28px;
|
|
974
|
+
border-radius: var(--cal-radius-sm);
|
|
975
|
+
color: hsl(var(--cal-fg));
|
|
976
|
+
transition: background var(--cal-transition);
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
.cal-sched-nav__btn:hover {
|
|
980
|
+
background: hsl(var(--cal-hover));
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
.cal-sched-nav__today {
|
|
984
|
+
font-size: 13px;
|
|
985
|
+
font-weight: 500;
|
|
986
|
+
color: hsl(var(--cal-fg));
|
|
987
|
+
padding: 4px 12px;
|
|
988
|
+
border-radius: var(--cal-radius-sm);
|
|
989
|
+
border: 1px solid hsl(var(--cal-border));
|
|
990
|
+
margin-left: 4px;
|
|
991
|
+
margin-right: 8px;
|
|
992
|
+
transition: background var(--cal-transition);
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
.cal-sched-nav__today:hover {
|
|
996
|
+
background: hsl(var(--cal-hover));
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
.cal-sched-nav__title {
|
|
1000
|
+
font-size: 14px;
|
|
1001
|
+
font-weight: 600;
|
|
1002
|
+
color: hsl(var(--cal-fg));
|
|
1003
|
+
user-select: none;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
.cal-sched-nav__tabs {
|
|
1007
|
+
display: flex;
|
|
1008
|
+
gap: 0;
|
|
1009
|
+
border: 1px solid hsl(var(--cal-border));
|
|
1010
|
+
border-radius: var(--cal-radius-sm);
|
|
1011
|
+
overflow: hidden;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
.cal-sched-nav__tab {
|
|
1015
|
+
font-size: 13px;
|
|
1016
|
+
font-weight: 500;
|
|
1017
|
+
color: hsl(var(--cal-fg-muted));
|
|
1018
|
+
padding: 4px 12px;
|
|
1019
|
+
transition: all var(--cal-transition);
|
|
1020
|
+
border-right: 1px solid hsl(var(--cal-border));
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
.cal-sched-nav__tab:last-child {
|
|
1024
|
+
border-right: none;
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
.cal-sched-nav__tab:hover {
|
|
1028
|
+
background: hsl(var(--cal-hover));
|
|
1029
|
+
color: hsl(var(--cal-fg));
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
.cal-sched-nav__tab--active {
|
|
1033
|
+
background: hsl(var(--cal-accent));
|
|
1034
|
+
color: hsl(var(--cal-accent-fg));
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
.cal-sched-nav__tab--active:hover {
|
|
1038
|
+
background: hsl(var(--cal-accent));
|
|
1039
|
+
color: hsl(var(--cal-accent-fg));
|
|
1040
|
+
}
|
|
1041
|
+
`;function ft({startTime:n,endTime:e,interval:a,slotHeight:t,format:s}){const i=document.createElement("div");i.classList.add("cal-sched-time-axis");const l=Ee(n,e,a);for(let r=0;r<l.length;r++){const o=l[r],h=ie(o);if(!h)continue;const c=document.createElement("div");if(c.classList.add("cal-sched-time-axis__slot"),c.style.height=`${t}px`,h.minutes===0){const d=document.createElement("span");d.classList.add("cal-sched-time-axis__label"),d.textContent=oe(h.hours,h.minutes,s),c.appendChild(d)}i.appendChild(c)}return i}const Kt=`
|
|
1042
|
+
.cal-sched-time-axis {
|
|
1043
|
+
display: flex;
|
|
1044
|
+
flex-direction: column;
|
|
1045
|
+
flex-shrink: 0;
|
|
1046
|
+
width: 56px;
|
|
1047
|
+
border-right: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
.cal-sched-time-axis__slot {
|
|
1051
|
+
position: relative;
|
|
1052
|
+
display: flex;
|
|
1053
|
+
align-items: flex-start;
|
|
1054
|
+
justify-content: flex-end;
|
|
1055
|
+
padding-right: 8px;
|
|
1056
|
+
border-bottom: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
.cal-sched-time-axis__label {
|
|
1060
|
+
font-size: 11px;
|
|
1061
|
+
color: hsl(var(--cal-fg-muted));
|
|
1062
|
+
transform: translateY(-7px);
|
|
1063
|
+
white-space: nowrap;
|
|
1064
|
+
user-select: none;
|
|
1065
|
+
}
|
|
1066
|
+
`;function Ut({resource:n,width:e}){const a=document.createElement("div");a.classList.add("cal-sched-resource-header"),e&&(a.style.width=`${e}px`),a.style.flex=e?`0 0 ${e}px`:"1 1 0";const t=document.createElement("span");t.classList.add("cal-sched-resource-header__dot");const s=n.color||"blue";t.style.background=`hsl(var(--cal-booking-${s}-fg))`,a.appendChild(t);const i=document.createElement("span");if(i.classList.add("cal-sched-resource-header__name"),i.textContent=n.name,a.appendChild(i),n.capacity){const l=document.createElement("span");l.classList.add("cal-sched-resource-header__capacity"),l.textContent=n.capacity,l.setAttribute("title",`Capacity: ${n.capacity}`),a.appendChild(l)}return a}function Vt({resources:n}){const e=document.createElement("div");e.classList.add("cal-sched-resource-header-row");for(const a of n)e.appendChild(Ut({resource:a}));return e}const Jt=`
|
|
1067
|
+
.cal-sched-resource-header-row {
|
|
1068
|
+
display: flex;
|
|
1069
|
+
border-bottom: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1070
|
+
background: hsl(var(--cal-sched-header-bg));
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
.cal-sched-resource-header {
|
|
1074
|
+
display: flex;
|
|
1075
|
+
align-items: center;
|
|
1076
|
+
gap: 6px;
|
|
1077
|
+
padding: 8px 12px;
|
|
1078
|
+
min-width: 0;
|
|
1079
|
+
border-right: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
.cal-sched-resource-header:last-child {
|
|
1083
|
+
border-right: none;
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
.cal-sched-resource-header__dot {
|
|
1087
|
+
width: 8px;
|
|
1088
|
+
height: 8px;
|
|
1089
|
+
border-radius: 50%;
|
|
1090
|
+
flex-shrink: 0;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
.cal-sched-resource-header__name {
|
|
1094
|
+
font-size: 13px;
|
|
1095
|
+
font-weight: 500;
|
|
1096
|
+
color: hsl(var(--cal-fg));
|
|
1097
|
+
white-space: nowrap;
|
|
1098
|
+
overflow: hidden;
|
|
1099
|
+
text-overflow: ellipsis;
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
.cal-sched-resource-header__capacity {
|
|
1103
|
+
font-size: 11px;
|
|
1104
|
+
color: hsl(var(--cal-fg-muted));
|
|
1105
|
+
background: hsl(var(--cal-bg-muted));
|
|
1106
|
+
padding: 1px 6px;
|
|
1107
|
+
border-radius: 999px;
|
|
1108
|
+
flex-shrink: 0;
|
|
1109
|
+
}
|
|
1110
|
+
`;function Ie({event:n,gridStartTime:e,slotHeight:a,interval:t,format:s,onClick:i,eventContent:l,showTime:r=!0,resource:o,draggable:h}){const c=document.createElement("div");c.classList.add("cal-sched-event"),c.setAttribute("role","button"),c.setAttribute("tabindex","0"),c.dataset.eventId=n.id;const d=!!n.locked;h&&!d&&(c.dataset.draggable="true"),d&&c.classList.add("cal-sched-event--locked");const g=n.color||"blue";if(c.style.setProperty("--ev-bg",`var(--cal-booking-${g}-bg)`),c.style.setProperty("--ev-fg",`var(--cal-booking-${g}-fg)`),n.startTime&&n.endTime){const u=ge(n.startTime,e,a,t),p=ge(n.endTime,e,a,t),_=Math.max(p-u,a*.5);if(c.style.top=`${u}px`,c.style.height=`${_}px`,n._totalCols>1){const m=100/n._totalCols;c.style.left=`${n._col*m}%`,c.style.width=`${m}%`}}if(typeof l=="function"){const u=l(n,o),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=n.title||"",c.appendChild(u),r&&n.startTime&&n.endTime){const p=document.createElement("div");p.classList.add("cal-sched-event__time");const _=ie(n.startTime),m=ie(n.endTime);_&&m&&(p.textContent=`${oe(_.hours,_.minutes,s)}–${oe(m.hours,m.minutes,s)}`),c.appendChild(p)}}if(h&&!d){const u=document.createElement("div");u.classList.add("cal-sched-event__resize-handle"),c.appendChild(u)}return i&&(c.addEventListener("click",u=>{if(c.dataset.wasDragged){delete c.dataset.wasDragged;return}u.stopPropagation(),i(n)}),c.addEventListener("keydown",u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),u.stopPropagation(),i(n))})),c}function vt({event:n,onClick:e,eventContent:a,resource:t}){const s=document.createElement("div");s.classList.add("cal-sched-allday-chip"),s.dataset.eventId=n.id;const i=n.color||"blue";if(s.style.setProperty("--ev-bg",`var(--cal-booking-${i}-bg)`),s.style.setProperty("--ev-fg",`var(--cal-booking-${i}-fg)`),typeof a=="function"){const l=a(n,t);l instanceof HTMLElement?s.appendChild(l):l!=null&&(s.textContent=String(l))}else s.textContent=n.title||"";return e&&s.addEventListener("click",l=>{l.stopPropagation(),e(n)}),s}function Zt({event:n,format:e,onClick:a,eventContent:t,resource:s}){const i=document.createElement("div");i.classList.add("cal-sched-month-chip"),i.dataset.eventId=n.id;const l=n.color||"blue";if(i.style.setProperty("--ev-bg",`var(--cal-booking-${l}-bg)`),i.style.setProperty("--ev-fg",`var(--cal-booking-${l}-fg)`),typeof t=="function"){const r=t(n,s);r instanceof HTMLElement?i.appendChild(r):r!=null&&(i.textContent=String(r))}else{const r=document.createElement("span");r.classList.add("cal-sched-month-chip__dot"),r.style.background=`hsl(var(--cal-booking-${l}-fg))`,i.appendChild(r);const o=document.createElement("span");if(o.classList.add("cal-sched-month-chip__text"),n.startTime){const h=ie(n.startTime),c=h?oe(h.hours,h.minutes,e):n.startTime;o.textContent=`${c} ${n.title||""}`}else o.textContent=n.title||"";i.appendChild(o)}return a&&i.addEventListener("click",r=>{r.stopPropagation(),a(n)}),i}const Qt=`
|
|
1111
|
+
.cal-sched-event {
|
|
1112
|
+
position: absolute;
|
|
1113
|
+
left: 2px;
|
|
1114
|
+
right: 2px;
|
|
1115
|
+
background: hsl(var(--ev-bg));
|
|
1116
|
+
color: hsl(var(--ev-fg));
|
|
1117
|
+
border-left: 3px solid hsl(var(--ev-fg));
|
|
1118
|
+
border-radius: var(--cal-radius-sm);
|
|
1119
|
+
padding: 2px 6px;
|
|
1120
|
+
font-size: 12px;
|
|
1121
|
+
line-height: 1.3;
|
|
1122
|
+
overflow: hidden;
|
|
1123
|
+
cursor: pointer;
|
|
1124
|
+
transition: box-shadow var(--cal-transition);
|
|
1125
|
+
z-index: 1;
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
.cal-sched-event:hover {
|
|
1129
|
+
box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.1);
|
|
1130
|
+
z-index: 2;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
.cal-sched-event:focus-visible {
|
|
1134
|
+
outline: 2px solid hsl(var(--cal-ring));
|
|
1135
|
+
outline-offset: 1px;
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
.cal-sched-event__title {
|
|
1139
|
+
font-weight: 500;
|
|
1140
|
+
white-space: nowrap;
|
|
1141
|
+
overflow: hidden;
|
|
1142
|
+
text-overflow: ellipsis;
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
.cal-sched-event__time {
|
|
1146
|
+
font-size: 11px;
|
|
1147
|
+
opacity: 0.8;
|
|
1148
|
+
white-space: nowrap;
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
.cal-sched-event__custom {
|
|
1152
|
+
overflow: hidden;
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
.cal-sched-event--locked {
|
|
1156
|
+
cursor: default;
|
|
1157
|
+
opacity: 0.85;
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
.cal-sched-event--locked::after {
|
|
1161
|
+
content: '';
|
|
1162
|
+
position: absolute;
|
|
1163
|
+
top: 3px;
|
|
1164
|
+
right: 4px;
|
|
1165
|
+
width: 10px;
|
|
1166
|
+
height: 10px;
|
|
1167
|
+
background: currentColor;
|
|
1168
|
+
opacity: 0.25;
|
|
1169
|
+
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='currentColor'%3E%3Cpath d='M11 5V4a3 3 0 0 0-6 0v1H4v7h8V5h-1ZM6 4a2 2 0 1 1 4 0v1H6V4Z'/%3E%3C/svg%3E");
|
|
1170
|
+
mask-size: contain;
|
|
1171
|
+
mask-repeat: no-repeat;
|
|
1172
|
+
-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='currentColor'%3E%3Cpath d='M11 5V4a3 3 0 0 0-6 0v1H4v7h8V5h-1ZM6 4a2 2 0 1 1 4 0v1H6V4Z'/%3E%3C/svg%3E");
|
|
1173
|
+
-webkit-mask-size: contain;
|
|
1174
|
+
-webkit-mask-repeat: no-repeat;
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
.cal-sched-allday-chip {
|
|
1178
|
+
background: hsl(var(--ev-bg));
|
|
1179
|
+
color: hsl(var(--ev-fg));
|
|
1180
|
+
border-left: 3px solid hsl(var(--ev-fg));
|
|
1181
|
+
border-radius: var(--cal-radius-sm);
|
|
1182
|
+
padding: 2px 8px;
|
|
1183
|
+
font-size: 12px;
|
|
1184
|
+
font-weight: 500;
|
|
1185
|
+
white-space: nowrap;
|
|
1186
|
+
overflow: hidden;
|
|
1187
|
+
text-overflow: ellipsis;
|
|
1188
|
+
cursor: pointer;
|
|
1189
|
+
transition: box-shadow var(--cal-transition);
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
.cal-sched-allday-chip:hover {
|
|
1193
|
+
box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.1);
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
.cal-sched-month-chip {
|
|
1197
|
+
display: flex;
|
|
1198
|
+
align-items: center;
|
|
1199
|
+
gap: 4px;
|
|
1200
|
+
background: hsl(var(--ev-bg));
|
|
1201
|
+
color: hsl(var(--ev-fg));
|
|
1202
|
+
border-radius: var(--cal-radius-sm);
|
|
1203
|
+
padding: 1px 6px;
|
|
1204
|
+
font-size: 11px;
|
|
1205
|
+
cursor: pointer;
|
|
1206
|
+
overflow: hidden;
|
|
1207
|
+
transition: box-shadow var(--cal-transition);
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
.cal-sched-month-chip:hover {
|
|
1211
|
+
box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.1);
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
.cal-sched-month-chip__dot {
|
|
1215
|
+
width: 6px;
|
|
1216
|
+
height: 6px;
|
|
1217
|
+
border-radius: 50%;
|
|
1218
|
+
flex-shrink: 0;
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
.cal-sched-month-chip__text {
|
|
1222
|
+
white-space: nowrap;
|
|
1223
|
+
overflow: hidden;
|
|
1224
|
+
text-overflow: ellipsis;
|
|
1225
|
+
}
|
|
1226
|
+
`;function Ce({date:n,startTime:e,endTime:a,resourceName:t,format:s,onCreate:i}){const l=document.createElement("div");l.classList.add("cal-sched-slot-prompt","cal-animate-fade");const r=document.createElement("div");if(r.classList.add("cal-sched-slot-prompt__info"),e&&a){const h=ie(e),c=ie(a),d=document.createElement("div");d.classList.add("cal-sched-slot-prompt__time"),h&&c&&(d.textContent=`${oe(h.hours,h.minutes,s)}–${oe(c.hours,c.minutes,s)}`),r.appendChild(d)}else{const h=document.createElement("div");h.classList.add("cal-sched-slot-prompt__time"),h.textContent=n,r.appendChild(h)}if(t){const h=document.createElement("div");h.classList.add("cal-sched-slot-prompt__resource"),h.textContent=t,r.appendChild(h)}l.appendChild(r);const o=document.createElement("button");return o.classList.add("cal-sched-slot-prompt__btn"),o.setAttribute("aria-label","Create event"),o.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>',o.addEventListener("click",h=>{h.stopPropagation(),i==null||i()}),l.appendChild(o),l.addEventListener("click",h=>h.stopPropagation()),l}const ea=`
|
|
1227
|
+
.cal-sched-slot-prompt {
|
|
1228
|
+
position: absolute;
|
|
1229
|
+
z-index: 10;
|
|
1230
|
+
display: flex;
|
|
1231
|
+
align-items: center;
|
|
1232
|
+
gap: 8px;
|
|
1233
|
+
background: hsl(var(--cal-bg));
|
|
1234
|
+
border: 1px solid hsl(var(--cal-border));
|
|
1235
|
+
border-radius: var(--cal-radius);
|
|
1236
|
+
box-shadow: 0 4px 16px -2px rgba(0, 0, 0, 0.1), 0 1px 4px -1px rgba(0, 0, 0, 0.06);
|
|
1237
|
+
padding: 6px 8px 6px 12px;
|
|
1238
|
+
font-size: 12px;
|
|
1239
|
+
color: hsl(var(--cal-fg));
|
|
1240
|
+
white-space: nowrap;
|
|
1241
|
+
pointer-events: auto;
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
.cal-sched-slot-prompt__info {
|
|
1245
|
+
display: flex;
|
|
1246
|
+
flex-direction: column;
|
|
1247
|
+
gap: 1px;
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
.cal-sched-slot-prompt__time {
|
|
1251
|
+
font-weight: 600;
|
|
1252
|
+
font-size: 12px;
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
.cal-sched-slot-prompt__resource {
|
|
1256
|
+
font-size: 11px;
|
|
1257
|
+
color: hsl(var(--cal-fg-muted));
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
.cal-sched-slot-prompt__btn {
|
|
1261
|
+
display: flex;
|
|
1262
|
+
align-items: center;
|
|
1263
|
+
justify-content: center;
|
|
1264
|
+
width: 26px;
|
|
1265
|
+
height: 26px;
|
|
1266
|
+
border-radius: var(--cal-radius-sm);
|
|
1267
|
+
background: hsl(var(--cal-accent));
|
|
1268
|
+
color: hsl(var(--cal-accent-fg));
|
|
1269
|
+
flex-shrink: 0;
|
|
1270
|
+
transition: opacity var(--cal-transition);
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
.cal-sched-slot-prompt__btn:hover {
|
|
1274
|
+
opacity: 0.85;
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
/* Selected slot highlight */
|
|
1278
|
+
.cal-sched-week__slot--selected,
|
|
1279
|
+
.cal-sched-day__slot--selected {
|
|
1280
|
+
background: hsl(var(--cal-accent-subtle));
|
|
1281
|
+
box-shadow: inset 0 0 0 1.5px hsl(var(--cal-accent));
|
|
1282
|
+
z-index: 1;
|
|
1283
|
+
position: relative;
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
.cal-sched-month__cell--selected {
|
|
1287
|
+
background: hsl(var(--cal-accent-subtle));
|
|
1288
|
+
box-shadow: inset 0 0 0 1.5px hsl(var(--cal-accent));
|
|
1289
|
+
}
|
|
1290
|
+
`;function ta({date:n,resources:e,events:a,startTime:t,endTime:s,interval:i,slotHeight:l,format:r,layout:o,resourceMode:h,selectedSlot:c,eventContent:d,showTime:g=!0,draggable:u,onSlotClick:p,onEventClick:_,onSlotCreate:m}){const v=document.createElement("div");v.classList.add("cal-sched-day"),o==="horizontal"&&v.classList.add("cal-sched-day--horizontal");const C=h==="tabs",k=e.length>1&&!C,S=Le(a,n),B=S.filter(x=>!x.startTime||!x.endTime),V=S.filter(x=>x.startTime&&x.endTime),O=Ee(t,s,i);if(B.length>0){const x=document.createElement("div");x.classList.add("cal-sched-day__allday");const f=document.createElement("div");f.classList.add("cal-sched-day__allday-label"),f.textContent="All day",x.appendChild(f);const F=document.createElement("div");F.classList.add("cal-sched-day__allday-chips");for(const R of B){const L=e.find(y=>y.id===R.resourceId);F.appendChild(vt({event:R,onClick:y=>_==null?void 0:_(y,R.resourceId,L),eventContent:d,resource:L}))}x.appendChild(F),v.appendChild(x)}if(k){const x=document.createElement("div");x.classList.add("cal-sched-day__header");const f=document.createElement("div");f.classList.add("cal-sched-day__header-spacer"),x.appendChild(f),x.appendChild(Vt({resources:e})),v.appendChild(x)}const N=document.createElement("div");N.classList.add("cal-sched-day__grid-area"),N.appendChild(ft({startTime:t,endTime:s,interval:i,slotHeight:l,format:r}));const I=document.createElement("div");if(I.classList.add("cal-sched-day__lanes"),k)for(const x of e){const f=document.createElement("div");f.classList.add("cal-sched-day__lane"),f.style.flex="1 1 0",f.dataset.resourceId=x.id,f.dataset.date=n;for(let L=0;L<O.length;L++){const y=document.createElement("div");y.classList.add("cal-sched-day__slot"),y.style.height=`${l}px`,y.dataset.time=O[L],y.dataset.resourceId=x.id;const H=L<O.length-1?O[L+1]:s;c&&c.date===n&&c.startTime===O[L]&&c.resourceId===x.id&&(y.classList.add("cal-sched-day__slot--selected"),y.appendChild(Ce({date:n,startTime:O[L],endTime:H,resourceName:x.name,format:r,onCreate:()=>m==null?void 0:m(n,O[L],H,x.id,x)}))),y.addEventListener("click",()=>{p==null||p(n,O[L],H,x.id,x)}),f.appendChild(y)}const F=V.filter(L=>L.resourceId===x.id),R=Ye(F);for(const L of R)f.appendChild(Ie({event:L,gridStartTime:t,slotHeight:l,interval:i,format:r,onClick:y=>_==null?void 0:_(y,x.id,x),eventContent:d,showTime:g,resource:x,draggable:u}));I.appendChild(f)}else{const x=document.createElement("div");x.classList.add("cal-sched-day__lane"),x.style.flex="1 1 0",x.dataset.date=n;const f=e.length===1?e[0]:null;f&&(x.dataset.resourceId=f.id);for(let R=0;R<O.length;R++){const L=document.createElement("div");L.classList.add("cal-sched-day__slot"),L.style.height=`${l}px`,L.dataset.time=O[R];const y=R<O.length-1?O[R+1]:s,H=(f==null?void 0:f.id)||null;c&&c.date===n&&c.startTime===O[R]&&(c.resourceId===H||!c.resourceId&&!H)&&(L.classList.add("cal-sched-day__slot--selected"),L.appendChild(Ce({date:n,startTime:O[R],endTime:y,resourceName:(f==null?void 0:f.name)||null,format:r,onCreate:()=>m==null?void 0:m(n,O[R],y,H,f)}))),L.addEventListener("click",()=>{p==null||p(n,O[R],y,H,f)}),x.appendChild(L)}const F=Ye(V);for(const R of F){const L=e.find(y=>y.id===R.resourceId)||e[0];x.appendChild(Ie({event:R,gridStartTime:t,slotHeight:l,interval:i,format:r,onClick:y=>_==null?void 0:_(y,R.resourceId,L),eventContent:d,showTime:g,resource:L,draggable:u}))}I.appendChild(x)}N.appendChild(I);const M=ue();if(re(n,M)){const x=rt(),f=b(x),F=b(t),R=b(s);if(f>=F&&f<=R){const L=ge(x,t,l,i),y=document.createElement("div");y.classList.add("cal-sched-now-line"),y.style.top=`${L}px`;const H=document.createElement("div");H.classList.add("cal-sched-now-line__dot"),y.appendChild(H),I.appendChild(y)}}return v.appendChild(N),v}const aa=`
|
|
1291
|
+
.cal-sched-day {
|
|
1292
|
+
display: flex;
|
|
1293
|
+
flex-direction: column;
|
|
1294
|
+
border: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1295
|
+
border-radius: var(--cal-radius);
|
|
1296
|
+
overflow: hidden;
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
.cal-sched-day__allday {
|
|
1300
|
+
display: flex;
|
|
1301
|
+
align-items: center;
|
|
1302
|
+
gap: 8px;
|
|
1303
|
+
padding: 6px 12px;
|
|
1304
|
+
border-bottom: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1305
|
+
background: hsl(var(--cal-sched-header-bg));
|
|
1306
|
+
flex-wrap: wrap;
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
.cal-sched-day__allday-label {
|
|
1310
|
+
font-size: 11px;
|
|
1311
|
+
color: hsl(var(--cal-fg-muted));
|
|
1312
|
+
flex-shrink: 0;
|
|
1313
|
+
width: 48px;
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
.cal-sched-day__allday-chips {
|
|
1317
|
+
display: flex;
|
|
1318
|
+
gap: 4px;
|
|
1319
|
+
flex-wrap: wrap;
|
|
1320
|
+
flex: 1;
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
.cal-sched-day__header {
|
|
1324
|
+
display: flex;
|
|
1325
|
+
background: hsl(var(--cal-sched-header-bg));
|
|
1326
|
+
position: sticky;
|
|
1327
|
+
top: 0;
|
|
1328
|
+
z-index: 3;
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
.cal-sched-day__header-spacer {
|
|
1332
|
+
width: 56px;
|
|
1333
|
+
flex-shrink: 0;
|
|
1334
|
+
border-right: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
.cal-sched-day__grid-area {
|
|
1338
|
+
display: flex;
|
|
1339
|
+
overflow-y: auto;
|
|
1340
|
+
position: relative;
|
|
1341
|
+
padding-top: 8px;
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
.cal-sched-day__lanes {
|
|
1345
|
+
display: flex;
|
|
1346
|
+
flex: 1;
|
|
1347
|
+
position: relative;
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
.cal-sched-day__lane {
|
|
1351
|
+
position: relative;
|
|
1352
|
+
border-right: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
.cal-sched-day__lane:last-child {
|
|
1356
|
+
border-right: none;
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
.cal-sched-day__slot {
|
|
1360
|
+
border-bottom: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1361
|
+
cursor: pointer;
|
|
1362
|
+
transition: background var(--cal-transition);
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
.cal-sched-day__slot:hover {
|
|
1366
|
+
background: hsl(var(--cal-sched-slot-hover));
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
/* Now line */
|
|
1370
|
+
.cal-sched-now-line {
|
|
1371
|
+
position: absolute;
|
|
1372
|
+
left: 0;
|
|
1373
|
+
right: 0;
|
|
1374
|
+
height: 2px;
|
|
1375
|
+
background: hsl(var(--cal-sched-now-line));
|
|
1376
|
+
z-index: 5;
|
|
1377
|
+
pointer-events: none;
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
.cal-sched-now-line__dot {
|
|
1381
|
+
position: absolute;
|
|
1382
|
+
left: -4px;
|
|
1383
|
+
top: -3px;
|
|
1384
|
+
width: 8px;
|
|
1385
|
+
height: 8px;
|
|
1386
|
+
border-radius: 50%;
|
|
1387
|
+
background: hsl(var(--cal-sched-now-line));
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
/* Horizontal layout */
|
|
1391
|
+
.cal-sched-day--horizontal .cal-sched-day__grid-area {
|
|
1392
|
+
flex-direction: column;
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
.cal-sched-day--horizontal .cal-sched-day__lanes {
|
|
1396
|
+
flex-direction: column;
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
.cal-sched-day--horizontal .cal-sched-day__lane {
|
|
1400
|
+
display: flex;
|
|
1401
|
+
border-right: none;
|
|
1402
|
+
border-bottom: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
.cal-sched-day--horizontal .cal-sched-day__lane:last-child {
|
|
1406
|
+
border-bottom: none;
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
.cal-sched-day--horizontal .cal-sched-day__slot {
|
|
1410
|
+
border-bottom: none;
|
|
1411
|
+
border-right: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1412
|
+
flex: 0 0 auto;
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
.cal-sched-day--horizontal .cal-sched-time-axis {
|
|
1416
|
+
flex-direction: row;
|
|
1417
|
+
width: auto;
|
|
1418
|
+
border-right: none;
|
|
1419
|
+
border-bottom: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
.cal-sched-day--horizontal .cal-sched-time-axis__slot {
|
|
1423
|
+
border-bottom: none;
|
|
1424
|
+
border-right: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1425
|
+
align-items: center;
|
|
1426
|
+
justify-content: center;
|
|
1427
|
+
padding: 4px 0;
|
|
1428
|
+
}
|
|
1429
|
+
`,Re=3,je=5;function sa({date:n,firstDay:e,resources:a,events:t,startTime:s,endTime:i,interval:l,slotHeight:r,format:o,layout:h,resourceMode:c,selectedSlot:d,eventContent:g,showTime:u=!0,draggable:p,allDayCollapsed:_,onToggleAllDay:m,onSlotClick:v,onEventClick:C,onSlotCreate:k}){const S=document.createElement("div");S.classList.add("cal-sched-week"),h==="horizontal"&&S.classList.add("cal-sched-week--horizontal");const B=Ne(n,e),V=c==="tabs",O=a.length>1&&!V,N=Ee(s,i,l),I=ue(),M={};for(const y of B){const H=Le(t,y).filter(K=>!K.startTime||!K.endTime);H.length&&(M[y]=H)}if(Object.keys(M).length>0){const y=document.createElement("div");y.classList.add("cal-sched-week__allday"),_&&y.classList.add("cal-sched-week__allday--collapsed");const H=document.createElement("div");H.classList.add("cal-sched-week__allday-spacer");const K=document.createElement("span");K.textContent="All day",H.appendChild(K);const E=document.createElement("button");E.classList.add("cal-sched-week__allday-toggle"),E.setAttribute("aria-label",_?"Expand all-day events":"Collapse all-day events"),E.innerHTML=_?'<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>',E.addEventListener("click",Y=>{Y.stopPropagation(),m==null||m()}),H.appendChild(E),y.appendChild(H);for(const Y of B){const X=document.createElement("div");X.classList.add("cal-sched-week__allday-cell");const $=M[Y]||[];if(_){if($.length>0){const T=document.createElement("div");T.classList.add("cal-sched-week__allday-dots");const z=$.slice(0,je);for(const q of z){const Q=document.createElement("span");Q.classList.add("cal-sched-week__allday-dot");const ke=q.color||"blue";Q.style.background=`hsl(var(--cal-booking-${ke}-fg))`,T.appendChild(Q)}if($.length>je){const q=document.createElement("span");q.classList.add("cal-sched-week__allday-overflow"),q.textContent=`+${$.length-je}`,T.appendChild(q)}X.appendChild(T)}}else{const T=$.slice(0,Re);for(const z of T){const q=a.find(Q=>Q.id===z.resourceId);X.appendChild(vt({event:z,onClick:Q=>C==null?void 0:C(Q,z.resourceId,q),eventContent:g,resource:q}))}if($.length>Re){const z=document.createElement("span");z.classList.add("cal-sched-week__allday-overflow"),z.textContent=`+${$.length-Re}`,X.appendChild(z)}}y.appendChild(X)}S.appendChild(y)}const f=document.createElement("div");f.classList.add("cal-sched-week__header");const F=document.createElement("div");F.classList.add("cal-sched-week__header-spacer"),f.appendChild(F);for(const y of B){const H=W(y),K=document.createElement("div");K.classList.add("cal-sched-week__day-header"),re(y,I)&&K.classList.add("cal-sched-week__day-header--today");const E=document.createElement("span");E.classList.add("cal-sched-week__day-name"),E.textContent=We(y);const Y=document.createElement("span");if(Y.classList.add("cal-sched-week__day-num"),re(y,I)&&Y.classList.add("cal-sched-week__day-num--today"),Y.textContent=H?H.getDate():"",K.appendChild(E),K.appendChild(Y),O){const X=document.createElement("div");X.classList.add("cal-sched-week__res-row");for(const $ of a){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-${$.color||"blue"}-fg))`,T.appendChild(z),T.appendChild(document.createTextNode($.name)),X.appendChild(T)}K.appendChild(X)}f.appendChild(K)}S.appendChild(f);const R=document.createElement("div");R.classList.add("cal-sched-week__grid-area"),R.appendChild(ft({startTime:s,endTime:i,interval:l,slotHeight:r,format:o}));const L=document.createElement("div");L.classList.add("cal-sched-week__cols");for(const y of B){const H=document.createElement("div");H.classList.add("cal-sched-week__day-col"),H.dataset.date=y,re(y,I)&&H.classList.add("cal-sched-week__day-col--today");const K=Le(t,y).filter(E=>E.startTime&&E.endTime);if(O)for(const E of a){const Y=document.createElement("div");Y.classList.add("cal-sched-week__lane"),Y.dataset.resourceId=E.id;for(let T=0;T<N.length;T++){const z=document.createElement("div");z.classList.add("cal-sched-week__slot"),z.style.height=`${r}px`,z.dataset.time=N[T];const q=T<N.length-1?N[T+1]:i;d&&d.date===y&&d.startTime===N[T]&&d.resourceId===E.id&&(z.classList.add("cal-sched-week__slot--selected"),z.appendChild(Ce({date:y,startTime:N[T],endTime:q,resourceName:E.name,format:o,onCreate:()=>k==null?void 0:k(y,N[T],q,E.id,E)}))),z.addEventListener("click",()=>{v==null||v(y,N[T],q,E.id,E)}),Y.appendChild(z)}const X=K.filter(T=>T.resourceId===E.id),$=Ye(X);for(const T of $)Y.appendChild(Ie({event:T,gridStartTime:s,slotHeight:r,interval:l,format:o,onClick:z=>C==null?void 0:C(z,E.id,E),eventContent:g,showTime:u,resource:E,draggable:p}));H.appendChild(Y)}else{const E=document.createElement("div");E.classList.add("cal-sched-week__lane","cal-sched-week__lane--full");const Y=a.length===1?a[0]:null;Y&&(E.dataset.resourceId=Y.id);for(let $=0;$<N.length;$++){const T=document.createElement("div");T.classList.add("cal-sched-week__slot"),T.style.height=`${r}px`,T.dataset.time=N[$];const z=$<N.length-1?N[$+1]:i,q=(Y==null?void 0:Y.id)||null;d&&d.date===y&&d.startTime===N[$]&&(d.resourceId===q||!d.resourceId&&!q)&&(T.classList.add("cal-sched-week__slot--selected"),T.appendChild(Ce({date:y,startTime:N[$],endTime:z,resourceName:(Y==null?void 0:Y.name)||null,format:o,onCreate:()=>k==null?void 0:k(y,N[$],z,q,Y)}))),T.addEventListener("click",()=>{v==null||v(y,N[$],z,q,Y)}),E.appendChild(T)}const X=Ye(K);for(const $ of X){const T=a.find(z=>z.id===$.resourceId)||a[0];E.appendChild(Ie({event:$,gridStartTime:s,slotHeight:r,interval:l,format:o,onClick:z=>C==null?void 0:C(z,$.resourceId,T),eventContent:g,showTime:u,resource:T,draggable:p}))}H.appendChild(E)}L.appendChild(H)}if(B.includes(I)){const y=rt(),H=b(y),K=b(s),E=b(i);if(H>=K&&H<=E){const Y=B.indexOf(I),X=ge(y,s,r,l),$=document.createElement("div");$.classList.add("cal-sched-now-line","cal-sched-now-line--week"),$.style.top=`${X}px`;const T=100/7;$.style.left=`${Y*T}%`,$.style.width=`${T}%`;const z=document.createElement("div");z.classList.add("cal-sched-now-line__dot"),$.appendChild(z),L.appendChild($)}}return R.appendChild(L),S.appendChild(R),S}const na=`
|
|
1430
|
+
.cal-sched-week {
|
|
1431
|
+
display: flex;
|
|
1432
|
+
flex-direction: column;
|
|
1433
|
+
border: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1434
|
+
border-radius: var(--cal-radius);
|
|
1435
|
+
overflow: hidden;
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
.cal-sched-week__allday {
|
|
1439
|
+
display: flex;
|
|
1440
|
+
border-bottom: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1441
|
+
background: hsl(var(--cal-sched-header-bg));
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
.cal-sched-week__allday-spacer {
|
|
1445
|
+
width: 56px;
|
|
1446
|
+
flex-shrink: 0;
|
|
1447
|
+
font-size: 11px;
|
|
1448
|
+
color: hsl(var(--cal-fg-muted));
|
|
1449
|
+
display: flex;
|
|
1450
|
+
flex-direction: column;
|
|
1451
|
+
align-items: flex-end;
|
|
1452
|
+
justify-content: center;
|
|
1453
|
+
gap: 4px;
|
|
1454
|
+
padding-right: 8px;
|
|
1455
|
+
border-right: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
.cal-sched-week__allday-toggle {
|
|
1459
|
+
display: flex;
|
|
1460
|
+
align-items: center;
|
|
1461
|
+
justify-content: center;
|
|
1462
|
+
width: 18px;
|
|
1463
|
+
height: 18px;
|
|
1464
|
+
border-radius: var(--cal-radius-sm);
|
|
1465
|
+
background: transparent;
|
|
1466
|
+
color: hsl(var(--cal-fg-muted));
|
|
1467
|
+
cursor: pointer;
|
|
1468
|
+
transition: background var(--cal-transition), color var(--cal-transition);
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
.cal-sched-week__allday-toggle:hover {
|
|
1472
|
+
background: hsl(var(--cal-sched-slot-hover));
|
|
1473
|
+
color: hsl(var(--cal-fg));
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
.cal-sched-week__allday-cell {
|
|
1477
|
+
flex: 1;
|
|
1478
|
+
display: flex;
|
|
1479
|
+
gap: 2px;
|
|
1480
|
+
padding: 4px;
|
|
1481
|
+
flex-wrap: wrap;
|
|
1482
|
+
border-right: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1483
|
+
max-height: 80px;
|
|
1484
|
+
overflow: hidden;
|
|
1485
|
+
align-items: flex-start;
|
|
1486
|
+
align-content: flex-start;
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
.cal-sched-week__allday--collapsed .cal-sched-week__allday-cell {
|
|
1490
|
+
max-height: 28px;
|
|
1491
|
+
align-items: center;
|
|
1492
|
+
align-content: center;
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
.cal-sched-week__allday-cell:last-child {
|
|
1496
|
+
border-right: none;
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
.cal-sched-week__allday-overflow {
|
|
1500
|
+
font-size: 10px;
|
|
1501
|
+
color: hsl(var(--cal-fg-muted));
|
|
1502
|
+
padding: 1px 4px;
|
|
1503
|
+
white-space: nowrap;
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
.cal-sched-week__allday-dots {
|
|
1507
|
+
display: flex;
|
|
1508
|
+
align-items: center;
|
|
1509
|
+
gap: 3px;
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
.cal-sched-week__allday-dot {
|
|
1513
|
+
width: 7px;
|
|
1514
|
+
height: 7px;
|
|
1515
|
+
border-radius: 50%;
|
|
1516
|
+
flex-shrink: 0;
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
.cal-sched-week__header {
|
|
1520
|
+
display: flex;
|
|
1521
|
+
background: hsl(var(--cal-sched-header-bg));
|
|
1522
|
+
border-bottom: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1523
|
+
position: sticky;
|
|
1524
|
+
top: 0;
|
|
1525
|
+
z-index: 3;
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
.cal-sched-week__header-spacer {
|
|
1529
|
+
width: 56px;
|
|
1530
|
+
flex-shrink: 0;
|
|
1531
|
+
border-right: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
.cal-sched-week__day-header {
|
|
1535
|
+
flex: 1;
|
|
1536
|
+
text-align: center;
|
|
1537
|
+
padding: 8px 4px;
|
|
1538
|
+
border-right: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1539
|
+
}
|
|
1540
|
+
|
|
1541
|
+
.cal-sched-week__day-header:last-child {
|
|
1542
|
+
border-right: none;
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
.cal-sched-week__day-name {
|
|
1546
|
+
display: block;
|
|
1547
|
+
font-size: 11px;
|
|
1548
|
+
color: hsl(var(--cal-fg-muted));
|
|
1549
|
+
font-weight: 500;
|
|
1550
|
+
text-transform: uppercase;
|
|
1551
|
+
letter-spacing: 0.5px;
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
.cal-sched-week__day-num {
|
|
1555
|
+
display: inline-flex;
|
|
1556
|
+
align-items: center;
|
|
1557
|
+
justify-content: center;
|
|
1558
|
+
width: 28px;
|
|
1559
|
+
height: 28px;
|
|
1560
|
+
font-size: 14px;
|
|
1561
|
+
font-weight: 600;
|
|
1562
|
+
color: hsl(var(--cal-fg));
|
|
1563
|
+
border-radius: 50%;
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
.cal-sched-week__day-num--today {
|
|
1567
|
+
background: hsl(var(--cal-accent));
|
|
1568
|
+
color: hsl(var(--cal-accent-fg));
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
.cal-sched-week__res-row {
|
|
1572
|
+
display: flex;
|
|
1573
|
+
justify-content: center;
|
|
1574
|
+
gap: 8px;
|
|
1575
|
+
margin-top: 4px;
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
.cal-sched-week__res-label {
|
|
1579
|
+
display: flex;
|
|
1580
|
+
align-items: center;
|
|
1581
|
+
gap: 3px;
|
|
1582
|
+
font-size: 10px;
|
|
1583
|
+
color: hsl(var(--cal-fg-muted));
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
.cal-sched-week__res-dot {
|
|
1587
|
+
width: 6px;
|
|
1588
|
+
height: 6px;
|
|
1589
|
+
border-radius: 50%;
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1592
|
+
.cal-sched-week__grid-area {
|
|
1593
|
+
display: flex;
|
|
1594
|
+
overflow-y: auto;
|
|
1595
|
+
position: relative;
|
|
1596
|
+
padding-top: 8px;
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1599
|
+
.cal-sched-week__cols {
|
|
1600
|
+
display: flex;
|
|
1601
|
+
flex: 1;
|
|
1602
|
+
position: relative;
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1605
|
+
.cal-sched-week__day-col {
|
|
1606
|
+
flex: 1;
|
|
1607
|
+
display: flex;
|
|
1608
|
+
border-right: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1609
|
+
position: relative;
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
.cal-sched-week__day-col:last-child {
|
|
1613
|
+
border-right: none;
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
.cal-sched-week__lane {
|
|
1617
|
+
flex: 1;
|
|
1618
|
+
position: relative;
|
|
1619
|
+
border-right: 1px solid hsl(var(--cal-sched-grid-line) / 0.5);
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
.cal-sched-week__lane:last-child {
|
|
1623
|
+
border-right: none;
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
.cal-sched-week__lane--full {
|
|
1627
|
+
border-right: none;
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
.cal-sched-week__slot {
|
|
1631
|
+
border-bottom: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1632
|
+
cursor: pointer;
|
|
1633
|
+
transition: background var(--cal-transition);
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
.cal-sched-week__slot:hover {
|
|
1637
|
+
background: hsl(var(--cal-sched-slot-hover));
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
.cal-sched-now-line--week {
|
|
1641
|
+
position: absolute;
|
|
1642
|
+
height: 2px;
|
|
1643
|
+
background: hsl(var(--cal-sched-now-line));
|
|
1644
|
+
z-index: 5;
|
|
1645
|
+
pointer-events: none;
|
|
1646
|
+
}
|
|
1647
|
+
`,bt=3;function ia({date:n,firstDay:e,resources:a,events:t,format:s,selectedResourceId:i,selectedDate:l,eventContent:r,onSlotClick:o,onEventClick:h,onSlotCreate:c}){const d=document.createElement("div");d.classList.add("cal-sched-month");const g=W(n);if(!g)return d;const u=g.getFullYear(),p=g.getMonth();ue();const _=document.createElement("div");_.classList.add("cal-sched-month__weekdays");const m=Xe(e);for(const k of m){const S=document.createElement("div");S.classList.add("cal-sched-month__weekday"),S.textContent=k,_.appendChild(S)}d.appendChild(_);const v=document.createElement("div");v.classList.add("cal-sched-month__grid");const C=Ke(u,p,e);for(const k of C){const S=document.createElement("div");S.classList.add("cal-sched-month__cell"),k.isCurrentMonth||S.classList.add("cal-sched-month__cell--outside"),k.isToday&&S.classList.add("cal-sched-month__cell--today"),l&&k.dateString===l&&S.classList.add("cal-sched-month__cell--selected"),S.addEventListener("click",M=>{M.target.closest(".cal-sched-month-chip")||o==null||o(k.dateString)});const B=document.createElement("div");B.classList.add("cal-sched-month__day-num"),k.isToday&&B.classList.add("cal-sched-month__day-num--today"),B.textContent=k.day,S.appendChild(B);let V=Le(t,k.dateString);i&&(V=V.filter(M=>M.resourceId===i)),V.sort((M,x)=>M.startTime&&!x.startTime?-1:!M.startTime&&x.startTime?1:M.startTime&&x.startTime?M.startTime.localeCompare(x.startTime):0);const O=document.createElement("div");O.classList.add("cal-sched-month__events");const N=V.slice(0,bt),I=V.length-bt;for(const M of N){const x=a.find(f=>f.id===M.resourceId);O.appendChild(Zt({event:M,format:s,onClick:f=>h==null?void 0:h(f,M.resourceId,x),eventContent:r,resource:x}))}if(I>0){const M=document.createElement("div");M.classList.add("cal-sched-month__more"),M.textContent=`+${I} more`,O.appendChild(M)}S.appendChild(O),l&&k.dateString===l&&(S.style.position="relative",S.appendChild(Ce({date:k.dateString,startTime:null,endTime:null,resourceName:null,format:s,onCreate:()=>c==null?void 0:c(k.dateString)}))),v.appendChild(S)}return d.appendChild(v),d}const la=`
|
|
1648
|
+
.cal-sched-month {
|
|
1649
|
+
border: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1650
|
+
border-radius: var(--cal-radius);
|
|
1651
|
+
overflow: hidden;
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
.cal-sched-month__weekdays {
|
|
1655
|
+
display: grid;
|
|
1656
|
+
grid-template-columns: repeat(7, minmax(0, 1fr));
|
|
1657
|
+
border-bottom: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1658
|
+
background: hsl(var(--cal-sched-header-bg));
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
.cal-sched-month__weekday {
|
|
1662
|
+
font-size: 11px;
|
|
1663
|
+
font-weight: 500;
|
|
1664
|
+
color: hsl(var(--cal-fg-muted));
|
|
1665
|
+
text-align: center;
|
|
1666
|
+
padding: 8px 4px;
|
|
1667
|
+
text-transform: uppercase;
|
|
1668
|
+
letter-spacing: 0.5px;
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
.cal-sched-month__grid {
|
|
1672
|
+
display: grid;
|
|
1673
|
+
grid-template-columns: repeat(7, minmax(0, 1fr));
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
.cal-sched-month__cell {
|
|
1677
|
+
min-height: 100px;
|
|
1678
|
+
border-right: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1679
|
+
border-bottom: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1680
|
+
padding: 4px;
|
|
1681
|
+
cursor: pointer;
|
|
1682
|
+
transition: background var(--cal-transition);
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
.cal-sched-month__cell:nth-child(7n) {
|
|
1686
|
+
border-right: none;
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
.cal-sched-month__cell:hover {
|
|
1690
|
+
background: hsl(var(--cal-sched-slot-hover));
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
.cal-sched-month__cell--outside {
|
|
1694
|
+
opacity: 0.4;
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1697
|
+
.cal-sched-month__day-num {
|
|
1698
|
+
font-size: 13px;
|
|
1699
|
+
font-weight: 500;
|
|
1700
|
+
color: hsl(var(--cal-fg));
|
|
1701
|
+
margin-bottom: 4px;
|
|
1702
|
+
width: 24px;
|
|
1703
|
+
height: 24px;
|
|
1704
|
+
display: flex;
|
|
1705
|
+
align-items: center;
|
|
1706
|
+
justify-content: center;
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
.cal-sched-month__day-num--today {
|
|
1710
|
+
background: hsl(var(--cal-accent));
|
|
1711
|
+
color: hsl(var(--cal-accent-fg));
|
|
1712
|
+
border-radius: 50%;
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
.cal-sched-month__events {
|
|
1716
|
+
display: flex;
|
|
1717
|
+
flex-direction: column;
|
|
1718
|
+
gap: 2px;
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
.cal-sched-month__more {
|
|
1722
|
+
font-size: 11px;
|
|
1723
|
+
color: hsl(var(--cal-fg-muted));
|
|
1724
|
+
padding: 1px 6px;
|
|
1725
|
+
cursor: pointer;
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
.cal-sched-month__more:hover {
|
|
1729
|
+
color: hsl(var(--cal-fg));
|
|
1730
|
+
}
|
|
1731
|
+
`;function ra({columns:n=3,rows:e=10,slotHeight:a=48}={}){const t=document.createElement("div");t.setAttribute("role","status"),t.setAttribute("aria-label","Loading..."),t.classList.add("cal-sched-skeleton-grid");const s=document.createElement("div");s.classList.add("cal-sched-skeleton-grid__header");const i=document.createElement("div");i.classList.add("cal-sched-skeleton-grid__spacer"),s.appendChild(i);for(let r=0;r<n;r++){const o=document.createElement("div");o.classList.add("cal-skeleton","cal-sched-skeleton-grid__col-header"),s.appendChild(o)}t.appendChild(s);const l=document.createElement("div");l.classList.add("cal-sched-skeleton-grid__body");for(let r=0;r<e;r++){const o=document.createElement("div");o.classList.add("cal-sched-skeleton-grid__row"),o.style.height=`${a}px`;const h=document.createElement("div");h.classList.add("cal-skeleton","cal-sched-skeleton-grid__time"),o.appendChild(h);for(let c=0;c<n;c++){const d=document.createElement("div");if(d.classList.add("cal-sched-skeleton-grid__cell"),Math.random()<.15){const g=document.createElement("div");g.classList.add("cal-skeleton","cal-skeleton--rect","cal-sched-skeleton-grid__event"),g.style.height=`${a*(1+Math.floor(Math.random()*2))}px`,d.appendChild(g)}o.appendChild(d)}l.appendChild(o)}return t.appendChild(l),t}function oa(){const n=document.createElement("div");n.setAttribute("role","status"),n.setAttribute("aria-label","Loading..."),n.classList.add("cal-sched-skeleton-month");const e=document.createElement("div");e.classList.add("cal-sched-skeleton-month__weekdays");for(let t=0;t<7;t++){const s=document.createElement("div");s.classList.add("cal-skeleton","cal-sched-skeleton-month__weekday"),e.appendChild(s)}n.appendChild(e);const a=document.createElement("div");a.classList.add("cal-sched-skeleton-month__grid");for(let t=0;t<35;t++){const s=document.createElement("div");s.classList.add("cal-sched-skeleton-month__cell");const i=document.createElement("div");i.classList.add("cal-skeleton","cal-sched-skeleton-month__num"),s.appendChild(i);const l=Math.floor(Math.random()*3);for(let r=0;r<l;r++){const o=document.createElement("div");o.classList.add("cal-skeleton","cal-skeleton--rect","cal-sched-skeleton-month__chip"),s.appendChild(o)}a.appendChild(s)}return n.appendChild(a),n}const ca=`
|
|
1732
|
+
.cal-sched-skeleton-grid {
|
|
1733
|
+
border: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1734
|
+
border-radius: var(--cal-radius);
|
|
1735
|
+
overflow: hidden;
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1738
|
+
.cal-sched-skeleton-grid__header {
|
|
1739
|
+
display: flex;
|
|
1740
|
+
background: hsl(var(--cal-sched-header-bg));
|
|
1741
|
+
border-bottom: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1742
|
+
padding: 12px 0;
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1745
|
+
.cal-sched-skeleton-grid__spacer {
|
|
1746
|
+
width: 56px;
|
|
1747
|
+
flex-shrink: 0;
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
.cal-sched-skeleton-grid__col-header {
|
|
1751
|
+
flex: 1;
|
|
1752
|
+
height: 20px;
|
|
1753
|
+
margin: 0 12px;
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1756
|
+
.cal-sched-skeleton-grid__body {
|
|
1757
|
+
display: flex;
|
|
1758
|
+
flex-direction: column;
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
.cal-sched-skeleton-grid__row {
|
|
1762
|
+
display: flex;
|
|
1763
|
+
border-bottom: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
.cal-sched-skeleton-grid__time {
|
|
1767
|
+
width: 36px;
|
|
1768
|
+
height: 12px;
|
|
1769
|
+
margin: 4px 10px;
|
|
1770
|
+
flex-shrink: 0;
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1773
|
+
.cal-sched-skeleton-grid__cell {
|
|
1774
|
+
flex: 1;
|
|
1775
|
+
border-right: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1776
|
+
position: relative;
|
|
1777
|
+
padding: 2px;
|
|
1778
|
+
}
|
|
1779
|
+
|
|
1780
|
+
.cal-sched-skeleton-grid__cell:last-child {
|
|
1781
|
+
border-right: none;
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1784
|
+
.cal-sched-skeleton-grid__event {
|
|
1785
|
+
width: 80%;
|
|
1786
|
+
min-height: 24px;
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1789
|
+
.cal-sched-skeleton-month {
|
|
1790
|
+
border: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1791
|
+
border-radius: var(--cal-radius);
|
|
1792
|
+
overflow: hidden;
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1795
|
+
.cal-sched-skeleton-month__weekdays {
|
|
1796
|
+
display: grid;
|
|
1797
|
+
grid-template-columns: repeat(7, 1fr);
|
|
1798
|
+
gap: 8px;
|
|
1799
|
+
padding: 12px;
|
|
1800
|
+
background: hsl(var(--cal-sched-header-bg));
|
|
1801
|
+
border-bottom: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
.cal-sched-skeleton-month__weekday {
|
|
1805
|
+
height: 14px;
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
.cal-sched-skeleton-month__grid {
|
|
1809
|
+
display: grid;
|
|
1810
|
+
grid-template-columns: repeat(7, 1fr);
|
|
1811
|
+
}
|
|
1812
|
+
|
|
1813
|
+
.cal-sched-skeleton-month__cell {
|
|
1814
|
+
min-height: 80px;
|
|
1815
|
+
border-right: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1816
|
+
border-bottom: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1817
|
+
padding: 6px;
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
.cal-sched-skeleton-month__cell:nth-child(7n) {
|
|
1821
|
+
border-right: none;
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
.cal-sched-skeleton-month__num {
|
|
1825
|
+
width: 20px;
|
|
1826
|
+
height: 14px;
|
|
1827
|
+
margin-bottom: 6px;
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1830
|
+
.cal-sched-skeleton-month__chip {
|
|
1831
|
+
height: 16px;
|
|
1832
|
+
margin-bottom: 2px;
|
|
1833
|
+
width: 85%;
|
|
1834
|
+
}
|
|
1835
|
+
`;function da({event:n,resource:e,format:a,onClose:t,actions:s,onAction:i}){const l=document.createElement("div");l.classList.add("cal-sched-detail-backdrop"),l.addEventListener("click",t);const r=document.createElement("div");r.classList.add("cal-sched-detail","cal-animate-fade"),r.addEventListener("click",u=>u.stopPropagation());const o=document.createElement("button");o.classList.add("cal-sched-detail__close"),o.setAttribute("aria-label","Close"),o.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>',o.addEventListener("click",t),r.appendChild(o);const h=n.color||"blue",c=document.createElement("div");c.classList.add("cal-sched-detail__accent"),c.style.background=`hsl(var(--cal-booking-${h}-fg))`,r.appendChild(c);const d=document.createElement("div");if(d.classList.add("cal-sched-detail__title"),d.textContent=n.title||"Untitled",r.appendChild(d),n.startTime&&n.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 _=ie(n.startTime),m=ie(n.endTime),v=document.createElement("span");_&&m&&(v.textContent=`${oe(_.hours,_.minutes,a)}–${oe(m.hours,m.minutes,a)}`),u.appendChild(v),r.appendChild(u)}if(n.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 _=W(n.start),m=document.createElement("span");if(_){let v=`${We(n.start,"long")}, ${se[_.getMonth()]} ${_.getDate()}`;if(n.end&&n.end!==n.start){const C=W(n.end);C&&(v+=` – ${se[C.getMonth()]} ${C.getDate()}`)}m.textContent=v}u.appendChild(m),r.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 _=document.createElement("span");_.textContent=e.name,e.capacity&&(_.textContent+=` (capacity: ${e.capacity})`),u.appendChild(_),r.appendChild(u)}if(n.metadata&&typeof n.metadata=="object"){const u=Object.entries(n.metadata);if(u.length>0){const p=document.createElement("div");p.classList.add("cal-sched-detail__meta");for(const[_,m]of u){const v=document.createElement("div");v.classList.add("cal-sched-detail__meta-row");const C=document.createElement("span");C.classList.add("cal-sched-detail__meta-label"),C.textContent=_;const k=document.createElement("span");k.textContent=String(m),v.appendChild(C),v.appendChild(k),p.appendChild(v)}r.appendChild(p)}}if(s&&s.length>0){const u=document.createElement("div");u.classList.add("cal-sched-detail__actions");for(const p of s){const _=document.createElement("button");_.classList.add("cal-sched-detail__action"),p.type==="danger"&&_.classList.add("cal-sched-detail__action--danger"),_.textContent=p.label,_.addEventListener("click",()=>{i==null||i(p.label)}),u.appendChild(_)}r.appendChild(u)}l.appendChild(r);const g=u=>{u.key==="Escape"&&t()};return l.addEventListener("keydown",g),requestAnimationFrame(()=>o.focus()),l}const ha=`
|
|
1836
|
+
.cal-sched-detail-backdrop {
|
|
1837
|
+
position: absolute;
|
|
1838
|
+
inset: 0;
|
|
1839
|
+
z-index: 20;
|
|
1840
|
+
display: flex;
|
|
1841
|
+
align-items: flex-start;
|
|
1842
|
+
justify-content: center;
|
|
1843
|
+
padding-top: 80px;
|
|
1844
|
+
background: rgba(0, 0, 0, 0.06);
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
.cal-sched-detail {
|
|
1848
|
+
position: relative;
|
|
1849
|
+
background: hsl(var(--cal-bg));
|
|
1850
|
+
border: 1px solid hsl(var(--cal-border));
|
|
1851
|
+
border-radius: var(--cal-radius);
|
|
1852
|
+
box-shadow: 0 8px 30px -4px rgba(0, 0, 0, 0.12), 0 2px 8px -2px rgba(0, 0, 0, 0.06);
|
|
1853
|
+
padding: 16px 20px;
|
|
1854
|
+
min-width: 260px;
|
|
1855
|
+
max-width: 340px;
|
|
1856
|
+
font-size: 13px;
|
|
1857
|
+
color: hsl(var(--cal-fg));
|
|
1858
|
+
user-select: text;
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
.cal-sched-detail__close {
|
|
1862
|
+
position: absolute;
|
|
1863
|
+
top: 10px;
|
|
1864
|
+
right: 10px;
|
|
1865
|
+
display: flex;
|
|
1866
|
+
align-items: center;
|
|
1867
|
+
justify-content: center;
|
|
1868
|
+
width: 24px;
|
|
1869
|
+
height: 24px;
|
|
1870
|
+
border-radius: var(--cal-radius-sm);
|
|
1871
|
+
color: hsl(var(--cal-fg-muted));
|
|
1872
|
+
transition: background var(--cal-transition), color var(--cal-transition);
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
.cal-sched-detail__close:hover {
|
|
1876
|
+
background: hsl(var(--cal-hover));
|
|
1877
|
+
color: hsl(var(--cal-fg));
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1880
|
+
.cal-sched-detail__accent {
|
|
1881
|
+
width: 32px;
|
|
1882
|
+
height: 4px;
|
|
1883
|
+
border-radius: 2px;
|
|
1884
|
+
margin-bottom: 10px;
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1887
|
+
.cal-sched-detail__title {
|
|
1888
|
+
font-size: 15px;
|
|
1889
|
+
font-weight: 600;
|
|
1890
|
+
margin-bottom: 12px;
|
|
1891
|
+
padding-right: 24px;
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1894
|
+
.cal-sched-detail__row {
|
|
1895
|
+
display: flex;
|
|
1896
|
+
align-items: center;
|
|
1897
|
+
gap: 8px;
|
|
1898
|
+
padding: 4px 0;
|
|
1899
|
+
color: hsl(var(--cal-fg-muted));
|
|
1900
|
+
font-size: 13px;
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
.cal-sched-detail__icon {
|
|
1904
|
+
display: flex;
|
|
1905
|
+
flex-shrink: 0;
|
|
1906
|
+
color: hsl(var(--cal-fg-muted));
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1909
|
+
.cal-sched-detail__res-dot {
|
|
1910
|
+
width: 8px;
|
|
1911
|
+
height: 8px;
|
|
1912
|
+
border-radius: 50%;
|
|
1913
|
+
flex-shrink: 0;
|
|
1914
|
+
margin-left: 3px;
|
|
1915
|
+
margin-right: 3px;
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
.cal-sched-detail__meta {
|
|
1919
|
+
margin-top: 10px;
|
|
1920
|
+
padding-top: 10px;
|
|
1921
|
+
border-top: 1px solid hsl(var(--cal-border));
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
.cal-sched-detail__meta-row {
|
|
1925
|
+
display: flex;
|
|
1926
|
+
justify-content: space-between;
|
|
1927
|
+
padding: 2px 0;
|
|
1928
|
+
font-size: 12px;
|
|
1929
|
+
color: hsl(var(--cal-fg-muted));
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1932
|
+
.cal-sched-detail__meta-label {
|
|
1933
|
+
font-weight: 500;
|
|
1934
|
+
text-transform: capitalize;
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1937
|
+
.cal-sched-detail__actions {
|
|
1938
|
+
display: flex;
|
|
1939
|
+
gap: 6px;
|
|
1940
|
+
margin-top: 14px;
|
|
1941
|
+
padding-top: 12px;
|
|
1942
|
+
border-top: 1px solid hsl(var(--cal-border));
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
.cal-sched-detail__action {
|
|
1946
|
+
flex: 1;
|
|
1947
|
+
display: flex;
|
|
1948
|
+
align-items: center;
|
|
1949
|
+
justify-content: center;
|
|
1950
|
+
padding: 6px 12px;
|
|
1951
|
+
font-size: 12px;
|
|
1952
|
+
font-weight: 500;
|
|
1953
|
+
border-radius: var(--cal-radius-sm);
|
|
1954
|
+
border: 1px solid hsl(var(--cal-border));
|
|
1955
|
+
color: hsl(var(--cal-fg));
|
|
1956
|
+
background: hsl(var(--cal-bg));
|
|
1957
|
+
transition: background var(--cal-transition);
|
|
1958
|
+
cursor: pointer;
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
.cal-sched-detail__action:hover {
|
|
1962
|
+
background: hsl(var(--cal-hover));
|
|
1963
|
+
}
|
|
1964
|
+
|
|
1965
|
+
.cal-sched-detail__action--danger {
|
|
1966
|
+
color: hsl(var(--cal-status-error-fg));
|
|
1967
|
+
border-color: hsl(var(--cal-status-error-border));
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
.cal-sched-detail__action--danger:hover {
|
|
1971
|
+
background: hsl(var(--cal-status-error-bg));
|
|
1972
|
+
}
|
|
1973
|
+
`;function ua({resources:n,selectedResourceId:e,onResourceFilter:a}){const t=document.createElement("div");t.classList.add("cal-sched-res-tabs");const s=document.createElement("button");s.classList.add("cal-sched-res-tabs__tab"),e||s.classList.add("cal-sched-res-tabs__tab--active"),s.textContent="All",s.addEventListener("click",()=>a==null?void 0:a(null)),t.appendChild(s);for(const i of n){const l=document.createElement("button");l.classList.add("cal-sched-res-tabs__tab"),e===i.id&&l.classList.add("cal-sched-res-tabs__tab--active");const r=document.createElement("span");r.classList.add("cal-sched-res-tabs__dot"),r.style.background=`hsl(var(--cal-booking-${i.color||"blue"}-fg))`,l.appendChild(r),l.appendChild(document.createTextNode(i.name)),l.addEventListener("click",()=>a==null?void 0:a(i.id)),t.appendChild(l)}return t}const pa=`
|
|
1974
|
+
.cal-sched-res-tabs {
|
|
1975
|
+
display: flex;
|
|
1976
|
+
gap: 4px;
|
|
1977
|
+
padding: 8px 12px;
|
|
1978
|
+
border-bottom: 1px solid hsl(var(--cal-sched-grid-line));
|
|
1979
|
+
background: hsl(var(--cal-sched-header-bg));
|
|
1980
|
+
flex-wrap: wrap;
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1983
|
+
.cal-sched-res-tabs__tab {
|
|
1984
|
+
display: flex;
|
|
1985
|
+
align-items: center;
|
|
1986
|
+
gap: 4px;
|
|
1987
|
+
font-size: 12px;
|
|
1988
|
+
font-weight: 500;
|
|
1989
|
+
color: hsl(var(--cal-fg-muted));
|
|
1990
|
+
padding: 4px 10px;
|
|
1991
|
+
border-radius: var(--cal-radius-sm);
|
|
1992
|
+
border: 1px solid hsl(var(--cal-border));
|
|
1993
|
+
transition: all var(--cal-transition);
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1996
|
+
.cal-sched-res-tabs__tab:hover {
|
|
1997
|
+
background: hsl(var(--cal-hover));
|
|
1998
|
+
color: hsl(var(--cal-fg));
|
|
1999
|
+
}
|
|
2000
|
+
|
|
2001
|
+
.cal-sched-res-tabs__tab--active {
|
|
2002
|
+
background: hsl(var(--cal-accent));
|
|
2003
|
+
color: hsl(var(--cal-accent-fg));
|
|
2004
|
+
border-color: hsl(var(--cal-accent));
|
|
2005
|
+
}
|
|
2006
|
+
|
|
2007
|
+
.cal-sched-res-tabs__tab--active:hover {
|
|
2008
|
+
background: hsl(var(--cal-accent));
|
|
2009
|
+
color: hsl(var(--cal-accent-fg));
|
|
2010
|
+
}
|
|
2011
|
+
|
|
2012
|
+
.cal-sched-res-tabs__dot {
|
|
2013
|
+
width: 6px;
|
|
2014
|
+
height: 6px;
|
|
2015
|
+
border-radius: 50%;
|
|
2016
|
+
}
|
|
2017
|
+
`;function ga({onClick:n}){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",a=>{a.stopPropagation(),n==null||n()}),e}const ma=`
|
|
2018
|
+
.cal-sched-fab {
|
|
2019
|
+
position: absolute;
|
|
2020
|
+
bottom: 16px;
|
|
2021
|
+
right: 16px;
|
|
2022
|
+
width: 48px;
|
|
2023
|
+
height: 48px;
|
|
2024
|
+
border-radius: 50%;
|
|
2025
|
+
background: hsl(var(--cal-accent));
|
|
2026
|
+
color: hsl(var(--cal-accent-fg));
|
|
2027
|
+
display: flex;
|
|
2028
|
+
align-items: center;
|
|
2029
|
+
justify-content: center;
|
|
2030
|
+
box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
|
|
2031
|
+
cursor: pointer;
|
|
2032
|
+
z-index: 8;
|
|
2033
|
+
transition: transform var(--cal-transition), box-shadow var(--cal-transition);
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2036
|
+
.cal-sched-fab:hover {
|
|
2037
|
+
transform: scale(1.08);
|
|
2038
|
+
box-shadow: 0 6px 16px -2px rgba(0, 0, 0, 0.25), 0 3px 6px -1px rgba(0, 0, 0, 0.12);
|
|
2039
|
+
}
|
|
2040
|
+
|
|
2041
|
+
.cal-sched-fab:active {
|
|
2042
|
+
transform: scale(0.96);
|
|
2043
|
+
}
|
|
2044
|
+
|
|
2045
|
+
.cal-sched-fab:focus-visible {
|
|
2046
|
+
outline: 2px solid hsl(var(--cal-ring));
|
|
2047
|
+
outline-offset: 2px;
|
|
2048
|
+
}
|
|
2049
|
+
`,fa=4;function va({shadowRoot:n,getConfig:e,getViewInfo:a,getEvents:t,onMove:s,onResize:i,onCreate:l}){let r=!1,o=null,h=null,c=null,d=null,g=0,u=0,p=0,_=0,m=!1,v=null,C=null,k=null,S=null,B=null,V=null,O=null,N=null,I=null,M=null,x=null,f=null,F=0;function R(w){if(!r||w.button!==0)return;const A=w.target.closest(".cal-sched-event__resize-handle"),P=w.target.closest('.cal-sched-event[data-draggable="true"]');if(P){const U=P.dataset.eventId;if(h=t().find(j=>j.id===U),!h)return;w.preventDefault(),w.stopPropagation(),N=P,O=w.pointerId,P.setPointerCapture(w.pointerId),p=w.clientX,_=w.clientY,m=!1,C=h.startTime,v=h.endTime,k=h.start,S=h.resourceId,A?(o="resize",d=P,d.classList.add("cal-sched-event--resizing")):(o="move",d=P)}else{const U=w.target.closest("[data-time]");if(!U||w.target.closest(".cal-sched-slot-prompt"))return;const D=H(w.clientX,w.clientY);if(!D)return;w.preventDefault(),o="create",p=w.clientX,_=w.clientY,m=!1,M=D.date,x=D.resourceId,f=D.time;const j=n.querySelectorAll("[data-time]");j.length>0&&(F=j[0].getBoundingClientRect().top),N=U,O=w.pointerId,U.setPointerCapture(w.pointerId)}n.addEventListener("pointermove",L),n.addEventListener("pointerup",y)}function L(w){if(!o)return;const A=w.clientX-p,P=w.clientY-_,U=Math.sqrt(A*A+P*P);if(!(!m&&U<fa)){if(m=!0,o==="move"){if(!c&&d){const j=d.getBoundingClientRect();g=p-j.left,u=_-j.top,c=d.cloneNode(!0),c.classList.add("cal-sched-event--ghost"),c.style.cssText=`
|
|
2050
|
+
position: fixed;
|
|
2051
|
+
width: ${j.width}px;
|
|
2052
|
+
height: ${j.height}px;
|
|
2053
|
+
left: ${j.left}px;
|
|
2054
|
+
top: ${j.top}px;
|
|
2055
|
+
z-index: 1000;
|
|
2056
|
+
pointer-events: none;
|
|
2057
|
+
opacity: 0.85;
|
|
2058
|
+
box-shadow: 0 8px 24px -4px rgba(0,0,0,0.2);
|
|
2059
|
+
background: hsl(var(--ev-bg));
|
|
2060
|
+
color: hsl(var(--ev-fg));
|
|
2061
|
+
border-left: 3px solid hsl(var(--ev-fg));
|
|
2062
|
+
border-radius: var(--cal-radius-sm);
|
|
2063
|
+
padding: 2px 6px;
|
|
2064
|
+
font-size: 12px;
|
|
2065
|
+
line-height: 1.3;
|
|
2066
|
+
overflow: hidden;
|
|
2067
|
+
`,c.style.setProperty("--ev-bg",d.style.getPropertyValue("--ev-bg")),c.style.setProperty("--ev-fg",d.style.getPropertyValue("--ev-fg")),n.appendChild(c),d.classList.add("cal-sched-event--dragging")}c&&(c.style.left=`${w.clientX-g}px`,c.style.top=`${w.clientY-u}px`);const D=H(w.clientX,w.clientY);D?K(D):E()}else if(o==="resize"){const D=e(),j=D.snapInterval||D.interval,ae=D.slotHeight*(j/D.interval),ce=w.clientY-_,J=Math.round(ce/ae)*j,_e=b(v),me=b(C);let te=_e+J;const ne=D.minDuration||j,de=me+ne;if(te<de&&(te=de),D.maxDuration){const ve=me+D.maxDuration;te>ve&&(te=ve)}const G=b(D.endTime);te>G&&(te=G);const he=le(te);if(d){const ve=ge(C,D.startTime,D.slotHeight,D.interval),qe=ge(he,D.startTime,D.slotHeight,D.interval);d.style.height=`${Math.max(qe-ve,D.slotHeight*.5)}px`}X(w.clientX,w.clientY,he,D.format)}else if(o==="create"){const D=e(),j=D.snapInterval||D.interval,ae=w.clientY-F,ce=pt(Math.max(0,ae),D.startTime,D.slotHeight,D.interval),ee=gt(ce,j),J=b(ee),_e=b(f),me=b(D.endTime),te=D.minDuration||j;let ne=Math.max(J,_e+te);if(D.maxDuration){const G=_e+D.maxDuration;ne>G&&(ne=G)}ne>me&&(ne=me);const de=le(ne);if(!I){I=document.createElement("div"),I.classList.add("cal-sched-create-preview");let G=null;x&&(G=n.querySelector(`[data-resource-id="${x}"][data-date="${M}"]`),G||(G=n.querySelector(`[data-date="${M}"] [data-resource-id="${x}"]`))),G||(G=n.querySelector(`[data-date="${M}"] .cal-sched-week__lane`)||n.querySelector(`[data-date="${M}"] .cal-sched-day__lane`)||n.querySelector(`[data-date="${M}"]`)),G&&G.appendChild(I)}if(I){const G=e(),he=ge(f,G.startTime,G.slotHeight,G.interval),ve=ge(de,G.startTime,G.slotHeight,G.interval);I.style.top=`${he}px`,I.style.height=`${Math.max(ve-he,G.slotHeight*.5)}px`,I.dataset.endTime=de}X(w.clientX,w.clientY,de,D.format)}}}function y(w){if(o){if(n.removeEventListener("pointermove",L),n.removeEventListener("pointerup",y),N&&O!=null){try{N.releasePointerCapture(O)}catch{}N=null,O=null}if(o==="move"){if(E(),c&&(c.remove(),c=null),d&&d.classList.remove("cal-sched-event--dragging"),m){d&&(d.dataset.wasDragged="true");const A=H(w.clientX,w.clientY);if(A&&h){const P=e(),U=b(v)-b(C),D=A.time,j=b(D),ae=Math.min(j+U,b(P.endTime)),ce=le(ae),ee={date:k,startTime:C,endTime:v,resourceId:S},J={date:A.date,startTime:D,endTime:ce,resourceId:A.resourceId||S};(ee.date!==J.date||ee.startTime!==J.startTime||ee.resourceId!==J.resourceId)&&(s==null||s({event:h,from:ee,to:J}))}}}else if(o==="resize"){if(m){const A=e(),P=A.snapInterval||A.interval,U=A.slotHeight*(P/A.interval),D=w.clientY-_,ae=Math.round(D/U)*P,ce=b(v),ee=b(C);let J=ce+ae;const _e=A.minDuration||P,me=ee+_e;if(J<me&&(J=me),A.maxDuration){const de=ee+A.maxDuration;J>de&&(J=de)}const te=b(A.endTime);J>te&&(J=te);const ne=le(J);d&&(d.dataset.wasDragged="true"),ne!==v&&h&&(i==null||i({event:h,from:{endTime:v},to:{endTime:ne}}))}d&&d.classList.remove("cal-sched-event--resizing"),$()}else if(o==="create"){$();const A=(I==null?void 0:I.dataset.endTime)||null;I&&(I.remove(),I=null),m&&M&&f&&A&&(l==null||l({date:M,startTime:f,endTime:A,resourceId:x})),M=null,x=null,f=null,F=0}o=null,h=null,d=null,g=0,u=0,p=0,_=0,m=!1,v=null,C=null,k=null,S=null}}function H(w,A){const P=e(),U=n.querySelectorAll("[data-date]");let D=null,j=null;for(const he of U){const ve=he.getBoundingClientRect();if(w>=ve.left&&w<=ve.right){if(D=he.dataset.date,he.dataset.resourceId)j=he.dataset.resourceId;else{const qe=he.querySelectorAll("[data-resource-id]");for(const yt of qe){const xt=yt.getBoundingClientRect();if(w>=xt.left&&w<=xt.right){j=yt.dataset.resourceId;break}}}break}}if(!D)return null;const ae=n.querySelectorAll("[data-time]");if(ae.length===0)return null;const ee=ae[0].getBoundingClientRect().top,J=A-ee;if(J<0)return null;const _e=P.snapInterval||P.interval,me=pt(J,P.startTime,P.slotHeight,P.interval),te=gt(me,_e),ne=b(te),de=b(P.startTime),G=b(P.endTime);return ne<de||ne>=G?null:{date:D,time:te,resourceId:j}}function K(w){E();const A=e();let P=A.interval;h&&C&&v&&(P=b(v)-b(C));let D=b(w.time)+P;const j=b(A.endTime);D>j&&(D=j);const ae=le(D);let ce=Y(w.date,w.resourceId);if(!ce)return;V=document.createElement("div"),V.classList.add("cal-sched-drop-preview");const ee=ge(w.time,A.startTime,A.slotHeight,A.interval),J=ge(ae,A.startTime,A.slotHeight,A.interval);V.style.top=`${ee}px`,V.style.height=`${Math.max(J-ee,A.slotHeight*.5)}px`,ce.appendChild(V)}function E(){V&&(V.remove(),V=null)}function Y(w,A){if(A){let U=n.querySelector(`[data-resource-id="${A}"][data-date="${w}"]`);if(U||(U=n.querySelector(`[data-date="${w}"] [data-resource-id="${A}"]`)),U)return U}const P=n.querySelector(`[data-date="${w}"]`);return P?P.querySelector(".cal-sched-week__lane")||P.querySelector(".cal-sched-day__lane")||P:null}function X(w,A,P,U){B||(B=document.createElement("div"),B.classList.add("cal-sched-drag-time-label"),n.appendChild(B));const{hours:D,minutes:j}=T(P),ae=U==="12h"?z(D,j):P;B.textContent=ae,B.style.left=`${w+12}px`,B.style.top=`${A-8}px`}function $(){B&&(B.remove(),B=null)}function T(w){const[A,P]=w.split(":").map(Number);return{hours:A,minutes:P}}function z(w,A){const P=w>=12?"PM":"AM";return`${w%12||12}:${String(A).padStart(2,"0")} ${P}`}function q(){r||(r=!0,n.addEventListener("pointerdown",R))}function Q(){r=!1,n.removeEventListener("pointerdown",R),n.removeEventListener("pointermove",L),n.removeEventListener("pointerup",y),ke()}function ke(){c&&(c.remove(),c=null),I&&(I.remove(),I=null),d&&(d.classList.remove("cal-sched-event--dragging","cal-sched-event--resizing"),d=null),E(),$(),o=null,h=null,m=!1}function ya(){Q()}return{enable:q,disable:Q,destroy:ya}}const ba=`
|
|
2068
|
+
[data-draggable="true"] {
|
|
2069
|
+
cursor: grab;
|
|
2070
|
+
}
|
|
2071
|
+
|
|
2072
|
+
[data-draggable="true"]:active {
|
|
2073
|
+
cursor: grabbing;
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
.cal-sched-event--dragging {
|
|
2077
|
+
opacity: 0.3;
|
|
2078
|
+
pointer-events: none;
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
.cal-sched-event--ghost {
|
|
2082
|
+
pointer-events: none;
|
|
2083
|
+
}
|
|
2084
|
+
|
|
2085
|
+
.cal-sched-event--resizing {
|
|
2086
|
+
z-index: 10;
|
|
2087
|
+
}
|
|
2088
|
+
|
|
2089
|
+
.cal-sched-event__resize-handle {
|
|
2090
|
+
position: absolute;
|
|
2091
|
+
bottom: 0;
|
|
2092
|
+
left: 0;
|
|
2093
|
+
right: 0;
|
|
2094
|
+
height: 6px;
|
|
2095
|
+
cursor: ns-resize;
|
|
2096
|
+
border-radius: 0 0 var(--cal-radius-sm) var(--cal-radius-sm);
|
|
2097
|
+
display: flex;
|
|
2098
|
+
align-items: center;
|
|
2099
|
+
justify-content: center;
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
.cal-sched-event__resize-handle::after {
|
|
2103
|
+
content: '';
|
|
2104
|
+
width: 20px;
|
|
2105
|
+
height: 2px;
|
|
2106
|
+
border-radius: 1px;
|
|
2107
|
+
background: currentColor;
|
|
2108
|
+
opacity: 0.3;
|
|
2109
|
+
transition: opacity var(--cal-transition);
|
|
2110
|
+
}
|
|
2111
|
+
|
|
2112
|
+
.cal-sched-event__resize-handle:hover::after {
|
|
2113
|
+
opacity: 0.6;
|
|
2114
|
+
}
|
|
2115
|
+
|
|
2116
|
+
.cal-sched-drop-preview {
|
|
2117
|
+
position: absolute;
|
|
2118
|
+
left: 2px;
|
|
2119
|
+
right: 2px;
|
|
2120
|
+
background: hsl(var(--cal-accent) / 0.12);
|
|
2121
|
+
border: 1.5px solid hsl(var(--cal-accent) / 0.5);
|
|
2122
|
+
border-radius: var(--cal-radius-sm);
|
|
2123
|
+
z-index: 3;
|
|
2124
|
+
pointer-events: none;
|
|
2125
|
+
transition: top 0.05s ease, height 0.05s ease;
|
|
2126
|
+
}
|
|
2127
|
+
|
|
2128
|
+
.cal-sched-create-preview {
|
|
2129
|
+
position: absolute;
|
|
2130
|
+
left: 2px;
|
|
2131
|
+
right: 2px;
|
|
2132
|
+
background: hsl(var(--cal-accent) / 0.15);
|
|
2133
|
+
border: 1.5px dashed hsl(var(--cal-accent));
|
|
2134
|
+
border-radius: var(--cal-radius-sm);
|
|
2135
|
+
z-index: 4;
|
|
2136
|
+
pointer-events: none;
|
|
2137
|
+
transition: height 0.05s ease;
|
|
2138
|
+
}
|
|
2139
|
+
|
|
2140
|
+
.cal-sched-drag-time-label {
|
|
2141
|
+
position: fixed;
|
|
2142
|
+
background: hsl(var(--cal-fg));
|
|
2143
|
+
color: hsl(var(--cal-bg));
|
|
2144
|
+
font-size: 11px;
|
|
2145
|
+
font-weight: 500;
|
|
2146
|
+
padding: 2px 6px;
|
|
2147
|
+
border-radius: var(--cal-radius-sm);
|
|
2148
|
+
pointer-events: none;
|
|
2149
|
+
z-index: 1001;
|
|
2150
|
+
white-space: nowrap;
|
|
2151
|
+
}
|
|
2152
|
+
`,_a=`
|
|
2153
|
+
.cal-sched {
|
|
2154
|
+
background: hsl(var(--cal-bg));
|
|
2155
|
+
border-radius: var(--cal-radius);
|
|
2156
|
+
user-select: none;
|
|
2157
|
+
font-size: 14px;
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2160
|
+
.cal-sched__body {
|
|
2161
|
+
position: relative;
|
|
2162
|
+
}
|
|
2163
|
+
`;class _t extends be{static get styles(){return[Se,Te,Me,Gt,Kt,Jt,Qt,aa,na,la,ca,ze,ha,pa,ea,ma,ba,_a]}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=De({view:"week",anchorDate:ue(),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 a=this.getAttribute("view");a&&this._store.set({view:a});const t=this.getAttribute("layout");t&&this._store.set({layout:t}),super.connectedCallback(),this._unsubscribe=this._store.subscribe(()=>{this._rendering||this.render()}),this._nowTimer=setInterval(()=>{const s=this._store.get("view");(s==="day"||s==="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,a,t){if(a!==t){if(e==="date"&&t){this._store.set({anchorDate:t});return}if(e==="view"&&t){this._store.set({view:t});return}if(e==="layout"&&t){this._store.set({layout:t});return}e==="draggable-events"&&(t!==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(ue())}next(){const e=this._store.getState(),a=W(e.anchorDate);if(!a)return;let t;if(e.view==="day")t=ye(e.anchorDate,1);else if(e.view==="week")t=ye(e.anchorDate,7);else{const{year:s,month:i}=pe(a.getFullYear(),a.getMonth(),1);t=Z(new Date(s,i,1))}this._store.set({anchorDate:t}),this.emit("cal:date-change",{date:t,view:e.view})}prev(){const e=this._store.getState(),a=W(e.anchorDate);if(!a)return;let t;if(e.view==="day")t=ye(e.anchorDate,-1);else if(e.view==="week")t=ye(e.anchorDate,-7);else{const{year:s,month:i}=pe(a.getFullYear(),a.getMonth(),-1);t=Z(new Date(s,i,1))}this._store.set({anchorDate:t}),this.emit("cal:date-change",{date:t,view:e.view})}findAvailableSlot(e){return Wt(e,this._resources,this._events,this.interval,this.startTime,this.endTime)}isSlotAvailable(e,a,t,s){return mt(this._events,s,e,a,t)}_handleSlotClick(e,a,t,s,i){this._lastSlotValue={date:e,startTime:a,endTime:t,resourceId:s,resource:i},this._store.set({selectedSlot:{date:e,startTime:a,endTime:t,resourceId:s,resource:i}}),this.emit("cal:slot-select",{date:e,startTime:a,endTime:t,resourceId:s,resource:i})}_handleSlotCreate(e,a,t,s,i){this.emit("cal:slot-create",{date:e,startTime:a,endTime:t,resourceId:s,resource:i})}_dismissSlot(){this._store.set({selectedSlot:null})}_handleEventClick(e,a,t){this._dismissSlot(),this._store.set({detailEvent:e,detailResource:t||null}),this.emit("cal:event-click",{event:e,resourceId:a,resource:t})}_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 a=this._store.getState(),t=a.detailEvent,s=a.detailResource;this.emit("cal:event-action",{action:e,event:t,resourceId:t==null?void 0:t.resourceId,resource:s})}_initDrag(){this._dragManager||(this._dragManager=va({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:Ne(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 a=this._resources.find(t=>t.id===e.resourceId)||null;this.emit("cal:slot-create",{...e,resource:a})}}),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 _;if(this._rendering)return;this._rendering=!0;const e=this.shadowRoot,a=[...e.childNodes];for(const m of a)m.nodeName!=="STYLE"&&!(m instanceof CSSStyleSheet)&&e.removeChild(m);const t=this._store.getState(),s=document.createElement("div");s.classList.add("cal-sched"),t.statusType&&t.statusMessage&&s.appendChild($e({type:t.statusType,message:t.statusMessage,dismissible:t.statusDismissible,onDismiss:()=>this.clearStatus()}));const i=t.view,l=t.anchorDate,r=Ne(l,this.firstDay),o=jt(i,l,r),h=this.resourceMode;s.appendChild(Xt({title:o,view:i,onPrev:()=>this.prev(),onNext:()=>this.next(),onToday:()=>this.today(),onViewChange:m=>this._handleViewChange(m)}));const c=this._resources.length>0?this._resources:[{id:"__default",name:""}],d=h==="tabs"&&c.length>1&&c[0].id!=="__default";d&&!this.loading&&s.appendChild(ua({resources:c,selectedResourceId:t.selectedResourceId,onResourceFilter:m=>this._handleResourceFilter(m)}));let g=this._events;d&&t.selectedResourceId&&(g=this._events.filter(m=>m.resourceId===t.selectedResourceId));let u=c;if(d&&t.selectedResourceId){const m=c.find(v=>v.id===t.selectedResourceId);m&&(u=[m])}const p=document.createElement("div");if(p.classList.add("cal-sched__body"),this.loading)if(i==="month")p.appendChild(oa());else{const m=i==="week"?7:Math.max(this._resources.length,1);p.appendChild(ra({columns:m,rows:Math.ceil((b(this.endTime)-b(this.startTime))/this.interval),slotHeight:this.slotHeight}))}else i==="day"?p.appendChild(ta({date:l,resources:u,events:g,startTime:this.startTime,endTime:this.endTime,interval:this.interval,slotHeight:this.slotHeight,format:this.format,layout:t.layout,resourceMode:h,selectedSlot:t.selectedSlot,eventContent:this._eventContent,showTime:this.showEventTime,draggable:this.draggableEvents,onSlotClick:(m,v,C,k,S)=>this._handleSlotClick(m,v,C,k,S),onEventClick:(m,v,C)=>this._handleEventClick(m,v,C),onSlotCreate:(m,v,C,k,S)=>this._handleSlotCreate(m,v,C,k,S)})):i==="week"?p.appendChild(sa({date:l,firstDay:this.firstDay,resources:u,events:g,startTime:this.startTime,endTime:this.endTime,interval:this.interval,slotHeight:this.slotHeight,format:this.format,layout:t.layout,resourceMode:h,selectedSlot:t.selectedSlot,eventContent:this._eventContent,showTime:this.showEventTime,draggable:this.draggableEvents,allDayCollapsed:t.allDayCollapsed,onToggleAllDay:()=>this._store.set({allDayCollapsed:!t.allDayCollapsed}),onSlotClick:(m,v,C,k,S)=>this._handleSlotClick(m,v,C,k,S),onEventClick:(m,v,C)=>this._handleEventClick(m,v,C),onSlotCreate:(m,v,C,k,S)=>this._handleSlotCreate(m,v,C,k,S)})):i==="month"&&p.appendChild(ia({date:l,firstDay:this.firstDay,resources:u,events:g,format:this.format,selectedResourceId:t.selectedResourceId,selectedDate:((_=t.selectedSlot)==null?void 0:_.date)||null,eventContent:this._eventContent,onSlotClick:m=>this._handleSlotClick(m,null,null,null,null),onEventClick:(m,v,C)=>this._handleEventClick(m,v,C),onSlotCreate:m=>this._handleSlotCreate(m,null,null,null,null)}));s.appendChild(p),t.detailEvent&&p.appendChild(da({event:t.detailEvent,resource:t.detailResource,format:this.format,onClose:()=>this._closeDetail(),actions:this._eventActions,onAction:m=>this._handleEventAction(m)})),this.showFab&&!this.loading&&p.appendChild(ga({onClick:()=>this._handleFabClick()})),e.appendChild(s),this._escHandler||(this._escHandler=m=>{m.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-datepicker")||customElements.define("cal-datepicker",it),customElements.get("cal-booking")||customElements.define("cal-booking",ht),customElements.get("cal-timepicker")||customElements.define("cal-timepicker",ut),customElements.get("cal-scheduler")||customElements.define("cal-scheduler",_t),fe.CalBooking=ht,fe.CalDatepicker=it,fe.CalScheduler=_t,fe.CalTimepicker=ut,Object.defineProperty(fe,Symbol.toStringTag,{value:"Module"})}));
|
|
2164
|
+
//# sourceMappingURL=calkit.umd.js.map
|