@forcecalendar/interface 1.0.41 → 1.0.42
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/dist/force-calendar-interface.esm.js +296 -294
- package/dist/force-calendar-interface.esm.js.map +1 -1
- package/dist/force-calendar-interface.umd.js +43 -43
- package/dist/force-calendar-interface.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ForceCalendar.js +11 -10
- package/src/core/StateManager.js +27 -23
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var S = Object.defineProperty;
|
|
2
|
-
var F = (
|
|
3
|
-
var v = (
|
|
2
|
+
var F = (h, e, t) => e in h ? S(h, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[e] = t;
|
|
3
|
+
var v = (h, e, t) => F(h, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { Calendar as H, DateUtils as L } from "@forcecalendar/core";
|
|
5
|
-
class
|
|
5
|
+
class M extends HTMLElement {
|
|
6
6
|
constructor() {
|
|
7
7
|
super(), this.attachShadow({ mode: "open" }), this._listeners = [], this._state = null, this._props = /* @__PURE__ */ new Map(), this._initialized = !1;
|
|
8
8
|
}
|
|
@@ -52,8 +52,8 @@ class T extends HTMLElement {
|
|
|
52
52
|
console.warn("addListener called with invalid parameters", { element: e, event: t, handler: r });
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
|
-
const
|
|
56
|
-
e.addEventListener(t,
|
|
55
|
+
const s = r.bind(this);
|
|
56
|
+
e.addEventListener(t, s), this._listeners.push({ element: e, event: t, handler: s });
|
|
57
57
|
}
|
|
58
58
|
emit(e, t = {}) {
|
|
59
59
|
this.dispatchEvent(
|
|
@@ -111,7 +111,7 @@ class T extends HTMLElement {
|
|
|
111
111
|
this.setProp(e, r), this._initialized && this.render();
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
class
|
|
114
|
+
class T {
|
|
115
115
|
constructor() {
|
|
116
116
|
this.events = /* @__PURE__ */ new Map(), this.wildcardHandlers = /* @__PURE__ */ new Set();
|
|
117
117
|
}
|
|
@@ -123,13 +123,13 @@ class V {
|
|
|
123
123
|
* @returns {Function} Unsubscribe function
|
|
124
124
|
*/
|
|
125
125
|
on(e, t, r = {}) {
|
|
126
|
-
const { once:
|
|
126
|
+
const { once: s = !1, priority: i = 0 } = r;
|
|
127
127
|
if (e.includes("*")) {
|
|
128
|
-
const a = { pattern: e, handler: t, once:
|
|
128
|
+
const a = { pattern: e, handler: t, once: s, priority: i };
|
|
129
129
|
return this.wildcardHandlers.add(a), () => this.wildcardHandlers.delete(a);
|
|
130
130
|
}
|
|
131
131
|
this.events.has(e) || this.events.set(e, []);
|
|
132
|
-
const n = { handler: t, once:
|
|
132
|
+
const n = { handler: t, once: s, priority: i }, o = this.events.get(e);
|
|
133
133
|
return o.push(n), o.sort((a, c) => c.priority - a.priority), () => {
|
|
134
134
|
const a = o.indexOf(n);
|
|
135
135
|
a > -1 && o.splice(a, 1);
|
|
@@ -146,16 +146,16 @@ class V {
|
|
|
146
146
|
*/
|
|
147
147
|
off(e, t) {
|
|
148
148
|
if (e.includes("*")) {
|
|
149
|
-
for (const
|
|
150
|
-
if (
|
|
151
|
-
this.wildcardHandlers.delete(
|
|
149
|
+
for (const i of this.wildcardHandlers)
|
|
150
|
+
if (i.pattern === e && i.handler === t) {
|
|
151
|
+
this.wildcardHandlers.delete(i);
|
|
152
152
|
return;
|
|
153
153
|
}
|
|
154
154
|
return;
|
|
155
155
|
}
|
|
156
156
|
if (!this.events.has(e)) return;
|
|
157
|
-
const r = this.events.get(e),
|
|
158
|
-
|
|
157
|
+
const r = this.events.get(e), s = r.findIndex((i) => i.handler === t);
|
|
158
|
+
s > -1 && r.splice(s, 1), r.length === 0 && this.events.delete(e);
|
|
159
159
|
}
|
|
160
160
|
/**
|
|
161
161
|
* Remove all wildcard handlers matching a pattern
|
|
@@ -172,8 +172,8 @@ class V {
|
|
|
172
172
|
*/
|
|
173
173
|
offAll(e) {
|
|
174
174
|
for (const [t, r] of this.events) {
|
|
175
|
-
const
|
|
176
|
-
|
|
175
|
+
const s = r.findIndex((i) => i.handler === e);
|
|
176
|
+
s > -1 && r.splice(s, 1), r.length === 0 && this.events.delete(t);
|
|
177
177
|
}
|
|
178
178
|
for (const t of [...this.wildcardHandlers])
|
|
179
179
|
t.handler === e && this.wildcardHandlers.delete(t);
|
|
@@ -187,8 +187,8 @@ class V {
|
|
|
187
187
|
async emit(e, t) {
|
|
188
188
|
const r = [];
|
|
189
189
|
if (this.events.has(e)) {
|
|
190
|
-
const
|
|
191
|
-
for (const n of
|
|
190
|
+
const i = [...this.events.get(e)];
|
|
191
|
+
for (const n of i) {
|
|
192
192
|
const { handler: o, once: a } = n;
|
|
193
193
|
a && this.off(e, o);
|
|
194
194
|
try {
|
|
@@ -199,11 +199,11 @@ class V {
|
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
|
-
const
|
|
203
|
-
for (const
|
|
204
|
-
if (this.matchesPattern(e,
|
|
205
|
-
const { handler: n, once: o } =
|
|
206
|
-
o &&
|
|
202
|
+
const s = [];
|
|
203
|
+
for (const i of [...this.wildcardHandlers])
|
|
204
|
+
if (this.matchesPattern(e, i.pattern)) {
|
|
205
|
+
const { handler: n, once: o } = i;
|
|
206
|
+
o && s.push(i);
|
|
207
207
|
try {
|
|
208
208
|
const a = n(t, e);
|
|
209
209
|
a instanceof Promise && r.push(a);
|
|
@@ -211,7 +211,7 @@ class V {
|
|
|
211
211
|
console.error(`Error in wildcard handler for ${e}:`, a);
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
|
-
return
|
|
214
|
+
return s.forEach((i) => this.wildcardHandlers.delete(i)), Promise.all(r);
|
|
215
215
|
}
|
|
216
216
|
/**
|
|
217
217
|
* Check if event name matches a pattern
|
|
@@ -253,10 +253,10 @@ class V {
|
|
|
253
253
|
return e;
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
|
-
const
|
|
257
|
-
class
|
|
256
|
+
const R = new T();
|
|
257
|
+
class V {
|
|
258
258
|
constructor(e = {}) {
|
|
259
|
-
this.calendar = new H({
|
|
259
|
+
this.eventBus = new T(), this.calendar = new H({
|
|
260
260
|
view: e.view || "month",
|
|
261
261
|
date: e.date || /* @__PURE__ */ new Date(),
|
|
262
262
|
weekStartsOn: e.weekStartsOn ?? 0,
|
|
@@ -295,8 +295,8 @@ class I {
|
|
|
295
295
|
*/
|
|
296
296
|
_eventsMatch(e, t) {
|
|
297
297
|
if (e.length !== t.length) return !1;
|
|
298
|
-
const r = new Set(e.map((
|
|
299
|
-
return t.every((
|
|
298
|
+
const r = new Set(e.map((s) => s.id));
|
|
299
|
+
return t.every((s) => r.has(s.id));
|
|
300
300
|
}
|
|
301
301
|
// State management
|
|
302
302
|
getState() {
|
|
@@ -307,8 +307,8 @@ class I {
|
|
|
307
307
|
};
|
|
308
308
|
}
|
|
309
309
|
setState(e, t = {}) {
|
|
310
|
-
const { silent: r = !1 } = t,
|
|
311
|
-
return this.state = { ...this.state, ...e }, r || (this.notifySubscribers(
|
|
310
|
+
const { silent: r = !1 } = t, s = { ...this.state };
|
|
311
|
+
return this.state = { ...this.state, ...e }, r || (this.notifySubscribers(s, this.state), this.emitStateChange(s, this.state)), this.state;
|
|
312
312
|
}
|
|
313
313
|
subscribe(e, t = null) {
|
|
314
314
|
return this.subscribers.add(e), t && (this._subscriberIds || (this._subscriberIds = /* @__PURE__ */ new Map()), this._subscriberIds.set(t, e)), () => this.unsubscribe(e, t);
|
|
@@ -335,56 +335,56 @@ class I {
|
|
|
335
335
|
this.subscribers.forEach((r) => {
|
|
336
336
|
try {
|
|
337
337
|
r(t, e);
|
|
338
|
-
} catch (
|
|
339
|
-
console.error("Error in state subscriber:",
|
|
338
|
+
} catch (s) {
|
|
339
|
+
console.error("Error in state subscriber:", s);
|
|
340
340
|
}
|
|
341
341
|
});
|
|
342
342
|
}
|
|
343
343
|
emitStateChange(e, t) {
|
|
344
|
-
const r = Object.keys(t).filter((
|
|
345
|
-
r.forEach((
|
|
346
|
-
|
|
347
|
-
oldValue: e[
|
|
348
|
-
newValue: t[
|
|
344
|
+
const r = Object.keys(t).filter((s) => e[s] !== t[s]);
|
|
345
|
+
r.forEach((s) => {
|
|
346
|
+
this.eventBus.emit(`state:${s}:changed`, {
|
|
347
|
+
oldValue: e[s],
|
|
348
|
+
newValue: t[s],
|
|
349
349
|
state: t
|
|
350
350
|
});
|
|
351
|
-
}), r.length > 0 &&
|
|
351
|
+
}), r.length > 0 && this.eventBus.emit("state:changed", { oldState: e, newState: t, changedKeys: r });
|
|
352
352
|
}
|
|
353
353
|
// Calendar operations
|
|
354
354
|
setView(e) {
|
|
355
|
-
this.calendar.setView(e), this.setState({ view: e }),
|
|
355
|
+
this.calendar.setView(e), this.setState({ view: e }), this.eventBus.emit("view:changed", { view: e });
|
|
356
356
|
}
|
|
357
357
|
getView() {
|
|
358
358
|
return this.state.view;
|
|
359
359
|
}
|
|
360
360
|
setDate(e) {
|
|
361
|
-
this.calendar.goToDate(e), this.setState({ currentDate: this.calendar.getCurrentDate() }),
|
|
361
|
+
this.calendar.goToDate(e), this.setState({ currentDate: this.calendar.getCurrentDate() }), this.eventBus.emit("date:changed", { date: this.state.currentDate });
|
|
362
362
|
}
|
|
363
363
|
getCurrentDate() {
|
|
364
364
|
return this.state.currentDate;
|
|
365
365
|
}
|
|
366
366
|
// Navigation
|
|
367
367
|
next() {
|
|
368
|
-
this.calendar.next(), this.setState({ currentDate: this.calendar.getCurrentDate() }),
|
|
368
|
+
this.calendar.next(), this.setState({ currentDate: this.calendar.getCurrentDate() }), this.eventBus.emit("navigation:next", { date: this.state.currentDate });
|
|
369
369
|
}
|
|
370
370
|
previous() {
|
|
371
|
-
this.calendar.previous(), this.setState({ currentDate: this.calendar.getCurrentDate() }),
|
|
371
|
+
this.calendar.previous(), this.setState({ currentDate: this.calendar.getCurrentDate() }), this.eventBus.emit("navigation:previous", { date: this.state.currentDate });
|
|
372
372
|
}
|
|
373
373
|
today() {
|
|
374
|
-
this.calendar.today(), this.setState({ currentDate: this.calendar.getCurrentDate() }),
|
|
374
|
+
this.calendar.today(), this.setState({ currentDate: this.calendar.getCurrentDate() }), this.eventBus.emit("navigation:today", { date: this.state.currentDate });
|
|
375
375
|
}
|
|
376
376
|
goToDate(e) {
|
|
377
|
-
this.calendar.goToDate(e), this.setState({ currentDate: this.calendar.getCurrentDate() }),
|
|
377
|
+
this.calendar.goToDate(e), this.setState({ currentDate: this.calendar.getCurrentDate() }), this.eventBus.emit("navigation:goto", { date: this.state.currentDate });
|
|
378
378
|
}
|
|
379
379
|
// Event management
|
|
380
380
|
addEvent(e) {
|
|
381
381
|
const t = this.calendar.addEvent(e);
|
|
382
|
-
return t ? (this._syncEventsFromCore(),
|
|
382
|
+
return t ? (this._syncEventsFromCore(), this.eventBus.emit("event:add", { event: t }), this.eventBus.emit("event:added", { event: t }), t) : (console.error("Failed to add event to calendar"), this.eventBus.emit("event:error", { action: "add", event: e, error: "Failed to add event" }), null);
|
|
383
383
|
}
|
|
384
384
|
updateEvent(e, t) {
|
|
385
385
|
this._syncEventsFromCore({ silent: !0 });
|
|
386
386
|
const r = this.calendar.updateEvent(e, t);
|
|
387
|
-
return r ? (this._syncEventsFromCore({ force: !0 }),
|
|
387
|
+
return r ? (this._syncEventsFromCore({ force: !0 }), this.eventBus.emit("event:update", { event: r }), this.eventBus.emit("event:updated", { event: r }), r) : (console.error(`Failed to update event: ${e}`), this.eventBus.emit("event:error", {
|
|
388
388
|
action: "update",
|
|
389
389
|
eventId: e,
|
|
390
390
|
updates: t,
|
|
@@ -392,7 +392,7 @@ class I {
|
|
|
392
392
|
}), null);
|
|
393
393
|
}
|
|
394
394
|
deleteEvent(e) {
|
|
395
|
-
return this._syncEventsFromCore({ silent: !0 }), this.calendar.removeEvent(e) ? (this._syncEventsFromCore(),
|
|
395
|
+
return this._syncEventsFromCore({ silent: !0 }), this.calendar.removeEvent(e) ? (this._syncEventsFromCore(), this.eventBus.emit("event:remove", { eventId: e }), this.eventBus.emit("event:deleted", { eventId: e }), !0) : (console.error(`Failed to delete event: ${e}`), this.eventBus.emit("event:error", { action: "delete", eventId: e, error: "Event not found" }), !1);
|
|
396
396
|
}
|
|
397
397
|
getEvents() {
|
|
398
398
|
return this.calendar.getEvents() || [];
|
|
@@ -416,11 +416,11 @@ class I {
|
|
|
416
416
|
return this.enrichViewData(e);
|
|
417
417
|
}
|
|
418
418
|
enrichViewData(e) {
|
|
419
|
-
var
|
|
420
|
-
const t = { ...e }, r = (
|
|
421
|
-
if (t.weeks && (t.weeks = t.weeks.map((
|
|
422
|
-
...
|
|
423
|
-
days:
|
|
419
|
+
var s;
|
|
420
|
+
const t = { ...e }, r = (s = this.state.selectedDate) == null ? void 0 : s.toDateString();
|
|
421
|
+
if (t.weeks && (t.weeks = t.weeks.map((i) => ({
|
|
422
|
+
...i,
|
|
423
|
+
days: i.days.map((n) => {
|
|
424
424
|
const o = new Date(n.date);
|
|
425
425
|
return {
|
|
426
426
|
...n,
|
|
@@ -428,35 +428,35 @@ class I {
|
|
|
428
428
|
events: n.events || this.getEventsForDate(o)
|
|
429
429
|
};
|
|
430
430
|
})
|
|
431
|
-
}))), t.days && (t.days = t.days.map((
|
|
432
|
-
const n = new Date(
|
|
431
|
+
}))), t.days && (t.days = t.days.map((i) => {
|
|
432
|
+
const n = new Date(i.date);
|
|
433
433
|
return {
|
|
434
|
-
...
|
|
434
|
+
...i,
|
|
435
435
|
isSelected: n.toDateString() === r,
|
|
436
|
-
events:
|
|
436
|
+
events: i.events || this.getEventsForDate(n)
|
|
437
437
|
};
|
|
438
438
|
})), t.date && !t.days && !t.weeks) {
|
|
439
|
-
const
|
|
440
|
-
t.isSelected =
|
|
439
|
+
const i = new Date(t.date);
|
|
440
|
+
t.isSelected = i.toDateString() === r, t.events = t.events || this.getEventsForDate(i);
|
|
441
441
|
}
|
|
442
442
|
return t;
|
|
443
443
|
}
|
|
444
444
|
// Selection management
|
|
445
445
|
selectEvent(e) {
|
|
446
|
-
this.setState({ selectedEvent: e }),
|
|
446
|
+
this.setState({ selectedEvent: e }), this.eventBus.emit("event:selected", { event: e });
|
|
447
447
|
}
|
|
448
448
|
selectEventById(e) {
|
|
449
449
|
const t = this.state.events.find((r) => r.id === e);
|
|
450
450
|
t && this.selectEvent(t);
|
|
451
451
|
}
|
|
452
452
|
deselectEvent() {
|
|
453
|
-
this.setState({ selectedEvent: null }),
|
|
453
|
+
this.setState({ selectedEvent: null }), this.eventBus.emit("event:deselected", {});
|
|
454
454
|
}
|
|
455
455
|
selectDate(e) {
|
|
456
|
-
this.setState({ selectedDate: e }),
|
|
456
|
+
this.setState({ selectedDate: e }), this.eventBus.emit("date:selected", { date: e });
|
|
457
457
|
}
|
|
458
458
|
deselectDate() {
|
|
459
|
-
this.setState({ selectedDate: null }),
|
|
459
|
+
this.setState({ selectedDate: null }), this.eventBus.emit("date:deselected", {});
|
|
460
460
|
}
|
|
461
461
|
// Utility methods
|
|
462
462
|
isToday(e) {
|
|
@@ -476,7 +476,7 @@ class I {
|
|
|
476
476
|
}
|
|
477
477
|
// Error handling
|
|
478
478
|
setError(e) {
|
|
479
|
-
this.setState({ error: e }), e &&
|
|
479
|
+
this.setState({ error: e }), e && this.eventBus.emit("error", { error: e });
|
|
480
480
|
}
|
|
481
481
|
clearError() {
|
|
482
482
|
this.setState({ error: null });
|
|
@@ -490,13 +490,13 @@ class I {
|
|
|
490
490
|
this.subscribers.clear(), this._subscriberIds && (this._subscriberIds.clear(), this._subscriberIds = null), this.state = null, this.calendar = null;
|
|
491
491
|
}
|
|
492
492
|
}
|
|
493
|
-
class
|
|
493
|
+
class p extends L {
|
|
494
494
|
/**
|
|
495
495
|
* Format date for display
|
|
496
496
|
*/
|
|
497
497
|
static formatDate(e, t = "default", r = "en-US") {
|
|
498
498
|
if (!e) return "";
|
|
499
|
-
const
|
|
499
|
+
const s = {
|
|
500
500
|
default: { year: "numeric", month: "long", day: "numeric" },
|
|
501
501
|
short: { year: "numeric", month: "short", day: "numeric" },
|
|
502
502
|
long: { weekday: "long", year: "numeric", month: "long", day: "numeric" },
|
|
@@ -513,20 +513,20 @@ class g extends L {
|
|
|
513
513
|
hour: "numeric",
|
|
514
514
|
minute: "2-digit"
|
|
515
515
|
}
|
|
516
|
-
},
|
|
517
|
-
return new Intl.DateTimeFormat(r,
|
|
516
|
+
}, i = s[t] || s.default;
|
|
517
|
+
return new Intl.DateTimeFormat(r, i).format(e);
|
|
518
518
|
}
|
|
519
519
|
/**
|
|
520
520
|
* Format time for display
|
|
521
521
|
*/
|
|
522
|
-
static formatTime(e, t = !0, r = !1,
|
|
522
|
+
static formatTime(e, t = !0, r = !1, s = "en-US") {
|
|
523
523
|
if (!e) return "";
|
|
524
|
-
const
|
|
524
|
+
const i = {
|
|
525
525
|
hour: "numeric",
|
|
526
526
|
minute: t ? "2-digit" : void 0,
|
|
527
527
|
hour12: !r
|
|
528
528
|
};
|
|
529
|
-
return new Intl.DateTimeFormat(
|
|
529
|
+
return new Intl.DateTimeFormat(s, i).format(e);
|
|
530
530
|
}
|
|
531
531
|
/**
|
|
532
532
|
* Format date range for display
|
|
@@ -535,25 +535,25 @@ class g extends L {
|
|
|
535
535
|
if (!e) return "";
|
|
536
536
|
if (!t || this.isSameDay(e, t))
|
|
537
537
|
return this.formatDate(e, "default", r);
|
|
538
|
-
const
|
|
539
|
-
return `${this.formatDate(e,
|
|
538
|
+
const s = this.isSameYear(e, t) ? "short" : "default";
|
|
539
|
+
return `${this.formatDate(e, s, r)} - ${this.formatDate(t, "default", r)}`;
|
|
540
540
|
}
|
|
541
541
|
/**
|
|
542
542
|
* Format time range for display
|
|
543
543
|
*/
|
|
544
544
|
static formatTimeRange(e, t, r = "en-US") {
|
|
545
545
|
if (!e) return "";
|
|
546
|
-
const
|
|
547
|
-
if (!t) return
|
|
548
|
-
const
|
|
549
|
-
return `${
|
|
546
|
+
const s = this.formatTime(e, !0, !1, r);
|
|
547
|
+
if (!t) return s;
|
|
548
|
+
const i = this.formatTime(t, !0, !1, r);
|
|
549
|
+
return `${s} - ${i}`;
|
|
550
550
|
}
|
|
551
551
|
/**
|
|
552
552
|
* Get relative time string (e.g., "2 hours ago", "in 3 days")
|
|
553
553
|
*/
|
|
554
554
|
static getRelativeTime(e, t = /* @__PURE__ */ new Date(), r = "en-US") {
|
|
555
|
-
const
|
|
556
|
-
return Math.abs(n) < 60 ?
|
|
555
|
+
const s = new Intl.RelativeTimeFormat(r, { numeric: "auto" }), i = e - t, n = Math.floor(i / 1e3), o = Math.floor(n / 60), a = Math.floor(o / 60), c = Math.floor(a / 24), d = Math.floor(c / 7), l = Math.floor(c / 30), f = Math.floor(c / 365);
|
|
556
|
+
return Math.abs(n) < 60 ? s.format(n, "second") : Math.abs(o) < 60 ? s.format(o, "minute") : Math.abs(a) < 24 ? s.format(a, "hour") : Math.abs(c) < 7 ? s.format(c, "day") : Math.abs(d) < 4 ? s.format(d, "week") : Math.abs(l) < 12 ? s.format(l, "month") : s.format(f, "year");
|
|
557
557
|
}
|
|
558
558
|
/**
|
|
559
559
|
* Check if date is today
|
|
@@ -592,61 +592,61 @@ class g extends L {
|
|
|
592
592
|
* Get month name
|
|
593
593
|
*/
|
|
594
594
|
static getMonthName(e, t = "long", r = "en-US") {
|
|
595
|
-
const
|
|
596
|
-
return new Intl.DateTimeFormat(r, { month: t }).format(
|
|
595
|
+
const s = new Date(2024, e, 1);
|
|
596
|
+
return new Intl.DateTimeFormat(r, { month: t }).format(s);
|
|
597
597
|
}
|
|
598
598
|
/**
|
|
599
599
|
* Parse time string (e.g., "14:30" or "2:30 PM")
|
|
600
600
|
*/
|
|
601
601
|
static parseTimeString(e, t = /* @__PURE__ */ new Date()) {
|
|
602
|
-
const r = new Date(t), [
|
|
602
|
+
const r = new Date(t), [s, i] = e.split(/\s+/), [n, o] = s.split(":").map(Number);
|
|
603
603
|
let a = n;
|
|
604
|
-
return
|
|
604
|
+
return i && (i.toLowerCase() === "pm" && n < 12 ? a = n + 12 : i.toLowerCase() === "am" && n === 12 && (a = 0)), r.setHours(a, o || 0, 0, 0), r;
|
|
605
605
|
}
|
|
606
606
|
}
|
|
607
|
-
class
|
|
607
|
+
class k {
|
|
608
608
|
/**
|
|
609
609
|
* Create element with attributes and children
|
|
610
610
|
*/
|
|
611
611
|
static createElement(e, t = {}, r = []) {
|
|
612
|
-
const
|
|
613
|
-
return Object.entries(t).forEach(([
|
|
614
|
-
if (
|
|
615
|
-
|
|
616
|
-
else if (
|
|
617
|
-
Object.assign(
|
|
618
|
-
else if (
|
|
619
|
-
|
|
620
|
-
else if (
|
|
621
|
-
const o =
|
|
622
|
-
|
|
612
|
+
const s = document.createElement(e);
|
|
613
|
+
return Object.entries(t).forEach(([i, n]) => {
|
|
614
|
+
if (i === "className")
|
|
615
|
+
s.className = n;
|
|
616
|
+
else if (i === "style" && typeof n == "object")
|
|
617
|
+
Object.assign(s.style, n);
|
|
618
|
+
else if (i.startsWith("data-"))
|
|
619
|
+
s.setAttribute(i, n);
|
|
620
|
+
else if (i.startsWith("on") && typeof n == "function") {
|
|
621
|
+
const o = i.slice(2).toLowerCase();
|
|
622
|
+
s.addEventListener(o, n);
|
|
623
623
|
} else
|
|
624
|
-
i
|
|
625
|
-
}), r.forEach((
|
|
626
|
-
typeof
|
|
627
|
-
}),
|
|
624
|
+
s[i] = n;
|
|
625
|
+
}), r.forEach((i) => {
|
|
626
|
+
typeof i == "string" ? s.appendChild(document.createTextNode(i)) : i instanceof Node && s.appendChild(i);
|
|
627
|
+
}), s;
|
|
628
628
|
}
|
|
629
629
|
/**
|
|
630
630
|
* Add multiple event listeners
|
|
631
631
|
*/
|
|
632
632
|
static addEventListeners(e, t) {
|
|
633
|
-
return Object.entries(t).forEach(([r,
|
|
634
|
-
e.addEventListener(r,
|
|
633
|
+
return Object.entries(t).forEach(([r, s]) => {
|
|
634
|
+
e.addEventListener(r, s);
|
|
635
635
|
}), () => {
|
|
636
|
-
Object.entries(t).forEach(([r,
|
|
637
|
-
e.removeEventListener(r,
|
|
636
|
+
Object.entries(t).forEach(([r, s]) => {
|
|
637
|
+
e.removeEventListener(r, s);
|
|
638
638
|
});
|
|
639
639
|
};
|
|
640
640
|
}
|
|
641
641
|
/**
|
|
642
642
|
* Delegate event handling
|
|
643
643
|
*/
|
|
644
|
-
static delegate(e, t, r,
|
|
645
|
-
const
|
|
644
|
+
static delegate(e, t, r, s) {
|
|
645
|
+
const i = (n) => {
|
|
646
646
|
const o = n.target.closest(t);
|
|
647
|
-
o && e.contains(o) &&
|
|
647
|
+
o && e.contains(o) && s.call(o, n);
|
|
648
648
|
};
|
|
649
|
-
return e.addEventListener(r,
|
|
649
|
+
return e.addEventListener(r, i), () => e.removeEventListener(r, i);
|
|
650
650
|
}
|
|
651
651
|
/**
|
|
652
652
|
* Get element position relative to viewport
|
|
@@ -673,8 +673,8 @@ class E {
|
|
|
673
673
|
* Smooth scroll to element
|
|
674
674
|
*/
|
|
675
675
|
static scrollToElement(e, t = {}) {
|
|
676
|
-
const { behavior: r = "smooth", block:
|
|
677
|
-
e.scrollIntoView({ behavior: r, block:
|
|
676
|
+
const { behavior: r = "smooth", block: s = "start", inline: i = "nearest" } = t;
|
|
677
|
+
e.scrollIntoView({ behavior: r, block: s, inline: i });
|
|
678
678
|
}
|
|
679
679
|
/**
|
|
680
680
|
* Get computed style value
|
|
@@ -699,10 +699,10 @@ class E {
|
|
|
699
699
|
*/
|
|
700
700
|
static waitForAnimation(e, t = "animationend") {
|
|
701
701
|
return new Promise((r) => {
|
|
702
|
-
const
|
|
703
|
-
e.removeEventListener(t,
|
|
702
|
+
const s = () => {
|
|
703
|
+
e.removeEventListener(t, s), r();
|
|
704
704
|
};
|
|
705
|
-
e.addEventListener(t,
|
|
705
|
+
e.addEventListener(t, s);
|
|
706
706
|
});
|
|
707
707
|
}
|
|
708
708
|
/**
|
|
@@ -730,9 +730,9 @@ class E {
|
|
|
730
730
|
*/
|
|
731
731
|
static debounce(e, t = 250) {
|
|
732
732
|
let r;
|
|
733
|
-
return function(...
|
|
733
|
+
return function(...i) {
|
|
734
734
|
const n = () => {
|
|
735
|
-
clearTimeout(r), e(...
|
|
735
|
+
clearTimeout(r), e(...i);
|
|
736
736
|
};
|
|
737
737
|
clearTimeout(r), r = setTimeout(n, t);
|
|
738
738
|
};
|
|
@@ -742,8 +742,8 @@ class E {
|
|
|
742
742
|
*/
|
|
743
743
|
static throttle(e, t = 250) {
|
|
744
744
|
let r;
|
|
745
|
-
return function(...
|
|
746
|
-
r || (e.apply(this,
|
|
745
|
+
return function(...s) {
|
|
746
|
+
r || (e.apply(this, s), r = !0, setTimeout(() => r = !1, t));
|
|
747
747
|
};
|
|
748
748
|
}
|
|
749
749
|
/**
|
|
@@ -757,9 +757,9 @@ class E {
|
|
|
757
757
|
*/
|
|
758
758
|
static parents(e, t) {
|
|
759
759
|
const r = [];
|
|
760
|
-
let
|
|
761
|
-
for (;
|
|
762
|
-
|
|
760
|
+
let s = e.parentElement;
|
|
761
|
+
for (; s; )
|
|
762
|
+
s.matches(t) && r.push(s), s = s.parentElement;
|
|
763
763
|
return r;
|
|
764
764
|
}
|
|
765
765
|
/**
|
|
@@ -793,13 +793,13 @@ class E {
|
|
|
793
793
|
);
|
|
794
794
|
if (t.length === 0)
|
|
795
795
|
return e.setAttribute("tabindex", "-1"), e.focus(), () => e.removeAttribute("tabindex");
|
|
796
|
-
const r = t[0],
|
|
797
|
-
n.key === "Tab" && (n.shiftKey ? document.activeElement === r && (
|
|
796
|
+
const r = t[0], s = t[t.length - 1], i = (n) => {
|
|
797
|
+
n.key === "Tab" && (n.shiftKey ? document.activeElement === r && (s == null || s.focus(), n.preventDefault()) : document.activeElement === s && (r == null || r.focus(), n.preventDefault()));
|
|
798
798
|
};
|
|
799
|
-
return e.addEventListener("keydown",
|
|
799
|
+
return e.addEventListener("keydown", i), r == null || r.focus(), () => e.removeEventListener("keydown", i);
|
|
800
800
|
}
|
|
801
801
|
}
|
|
802
|
-
class
|
|
802
|
+
class u {
|
|
803
803
|
/**
|
|
804
804
|
* Get CSS variable value
|
|
805
805
|
*/
|
|
@@ -810,8 +810,8 @@ class p {
|
|
|
810
810
|
* Set CSS variables
|
|
811
811
|
*/
|
|
812
812
|
static setCSSVariables(e, t = document.documentElement) {
|
|
813
|
-
Object.entries(e).forEach(([r,
|
|
814
|
-
t.style.setProperty(r,
|
|
813
|
+
Object.entries(e).forEach(([r, s]) => {
|
|
814
|
+
t.style.setProperty(r, s);
|
|
815
815
|
});
|
|
816
816
|
}
|
|
817
817
|
/**
|
|
@@ -967,22 +967,22 @@ class p {
|
|
|
967
967
|
* Darken color by percentage
|
|
968
968
|
*/
|
|
969
969
|
static darken(e, t) {
|
|
970
|
-
const r = parseInt(e.replace("#", ""), 16),
|
|
971
|
-
return "#" + (16777216 + (
|
|
970
|
+
const r = parseInt(e.replace("#", ""), 16), s = Math.round(2.55 * t), i = (r >> 16) - s, n = (r >> 8 & 255) - s, o = (r & 255) - s;
|
|
971
|
+
return "#" + (16777216 + (i < 255 ? i < 1 ? 0 : i : 255) * 65536 + (n < 255 ? n < 1 ? 0 : n : 255) * 256 + (o < 255 ? o < 1 ? 0 : o : 255)).toString(16).slice(1);
|
|
972
972
|
}
|
|
973
973
|
/**
|
|
974
974
|
* Lighten color by percentage
|
|
975
975
|
*/
|
|
976
976
|
static lighten(e, t) {
|
|
977
|
-
const r = parseInt(e.replace("#", ""), 16),
|
|
978
|
-
return "#" + (16777216 + (
|
|
977
|
+
const r = parseInt(e.replace("#", ""), 16), s = Math.round(2.55 * t), i = (r >> 16) + s, n = (r >> 8 & 255) + s, o = (r & 255) + s;
|
|
978
|
+
return "#" + (16777216 + (i < 255 ? i < 1 ? 0 : i : 255) * 65536 + (n < 255 ? n < 1 ? 0 : n : 255) * 256 + (o < 255 ? o < 1 ? 0 : o : 255)).toString(16).slice(1);
|
|
979
979
|
}
|
|
980
980
|
/**
|
|
981
981
|
* Get contrast color (black or white) for background
|
|
982
982
|
*/
|
|
983
983
|
static getContrastColor(e) {
|
|
984
|
-
const t = e.replace("#", ""), r = parseInt(t.substr(0, 2), 16),
|
|
985
|
-
return (r * 299 +
|
|
984
|
+
const t = e.replace("#", ""), r = parseInt(t.substr(0, 2), 16), s = parseInt(t.substr(2, 2), 16), i = parseInt(t.substr(4, 2), 16);
|
|
985
|
+
return (r * 299 + s * 587 + i * 114) / 1e3 >= 128 ? "#000000" : "#FFFFFF";
|
|
986
986
|
}
|
|
987
987
|
/**
|
|
988
988
|
* Sanitize color value to prevent CSS injection
|
|
@@ -1024,8 +1024,8 @@ class p {
|
|
|
1024
1024
|
* Convert hex to rgba
|
|
1025
1025
|
*/
|
|
1026
1026
|
static hexToRgba(e, t = 1) {
|
|
1027
|
-
const r = e.replace("#", ""),
|
|
1028
|
-
return `rgba(${
|
|
1027
|
+
const r = e.replace("#", ""), s = parseInt(r.substr(0, 2), 16), i = parseInt(r.substr(2, 2), 16), n = parseInt(r.substr(4, 2), 16);
|
|
1028
|
+
return `rgba(${s}, ${i}, ${n}, ${t})`;
|
|
1029
1029
|
}
|
|
1030
1030
|
/**
|
|
1031
1031
|
* Generate grid styles
|
|
@@ -1136,7 +1136,7 @@ class p {
|
|
|
1136
1136
|
/**
|
|
1137
1137
|
* Default theme colors
|
|
1138
1138
|
*/
|
|
1139
|
-
v(
|
|
1139
|
+
v(u, "colors", {
|
|
1140
1140
|
primary: "#3B82F6",
|
|
1141
1141
|
// Modern Blue
|
|
1142
1142
|
secondary: "#64748B",
|
|
@@ -1169,7 +1169,7 @@ v(p, "colors", {
|
|
|
1169
1169
|
}), /**
|
|
1170
1170
|
* Common CSS variables
|
|
1171
1171
|
*/
|
|
1172
|
-
v(
|
|
1172
|
+
v(u, "cssVariables", {
|
|
1173
1173
|
// "Pro" Palette - Functional & Sharp
|
|
1174
1174
|
"--fc-primary-color": "#2563EB",
|
|
1175
1175
|
// International Blue (Focus)
|
|
@@ -1237,7 +1237,7 @@ v(p, "cssVariables", {
|
|
|
1237
1237
|
}), /**
|
|
1238
1238
|
* Get responsive breakpoints
|
|
1239
1239
|
*/
|
|
1240
|
-
v(
|
|
1240
|
+
v(u, "breakpoints", {
|
|
1241
1241
|
xs: "320px",
|
|
1242
1242
|
sm: "576px",
|
|
1243
1243
|
md: "768px",
|
|
@@ -1245,7 +1245,7 @@ v(p, "breakpoints", {
|
|
|
1245
1245
|
xl: "1200px",
|
|
1246
1246
|
"2xl": "1400px"
|
|
1247
1247
|
});
|
|
1248
|
-
class
|
|
1248
|
+
class E {
|
|
1249
1249
|
/**
|
|
1250
1250
|
* @param {HTMLElement} container - The DOM element to render into
|
|
1251
1251
|
* @param {StateManager} stateManager - The state manager instance
|
|
@@ -1275,8 +1275,8 @@ class _ {
|
|
|
1275
1275
|
* @param {Function} handler
|
|
1276
1276
|
*/
|
|
1277
1277
|
addListener(e, t, r) {
|
|
1278
|
-
const
|
|
1279
|
-
e.addEventListener(t,
|
|
1278
|
+
const s = r.bind(this);
|
|
1279
|
+
e.addEventListener(t, s), this._listeners.push({ element: e, event: t, handler: s });
|
|
1280
1280
|
}
|
|
1281
1281
|
/**
|
|
1282
1282
|
* Escape HTML to prevent XSS
|
|
@@ -1284,7 +1284,7 @@ class _ {
|
|
|
1284
1284
|
* @returns {string}
|
|
1285
1285
|
*/
|
|
1286
1286
|
escapeHTML(e) {
|
|
1287
|
-
return e == null ? "" :
|
|
1287
|
+
return e == null ? "" : k.escapeHTML(String(e));
|
|
1288
1288
|
}
|
|
1289
1289
|
/**
|
|
1290
1290
|
* Check if a date is today
|
|
@@ -1319,8 +1319,8 @@ class _ {
|
|
|
1319
1319
|
* @returns {string}
|
|
1320
1320
|
*/
|
|
1321
1321
|
formatTime(e) {
|
|
1322
|
-
const t = e.getHours(), r = e.getMinutes(),
|
|
1323
|
-
return r === 0 ? `${
|
|
1322
|
+
const t = e.getHours(), r = e.getMinutes(), s = t >= 12 ? "PM" : "AM", i = t % 12 || 12;
|
|
1323
|
+
return r === 0 ? `${i} ${s}` : `${i}:${r.toString().padStart(2, "0")} ${s}`;
|
|
1324
1324
|
}
|
|
1325
1325
|
/**
|
|
1326
1326
|
* Get contrasting text color for a background color
|
|
@@ -1333,10 +1333,10 @@ class _ {
|
|
|
1333
1333
|
const t = e.charAt(0) === "#" ? e.substring(1) : e;
|
|
1334
1334
|
if (!/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(t))
|
|
1335
1335
|
return "white";
|
|
1336
|
-
const r = t.length === 3 ? t[0] + t[0] + t[1] + t[1] + t[2] + t[2] : t,
|
|
1337
|
-
if (isNaN(
|
|
1336
|
+
const r = t.length === 3 ? t[0] + t[0] + t[1] + t[1] + t[2] + t[2] : t, s = parseInt(r.substring(0, 2), 16), i = parseInt(r.substring(2, 4), 16), n = parseInt(r.substring(4, 6), 16);
|
|
1337
|
+
if (isNaN(s) || isNaN(i) || isNaN(n))
|
|
1338
1338
|
return "white";
|
|
1339
|
-
const a = [
|
|
1339
|
+
const a = [s / 255, i / 255, n / 255].map((d) => d <= 0.03928 ? d / 12.92 : Math.pow((d + 0.055) / 1.055, 2.4));
|
|
1340
1340
|
return 0.2126 * a[0] + 0.7152 * a[1] + 0.0722 * a[2] > 0.179 ? "black" : "white";
|
|
1341
1341
|
}
|
|
1342
1342
|
/**
|
|
@@ -1357,31 +1357,31 @@ class _ {
|
|
|
1357
1357
|
computeOverlapLayout(e) {
|
|
1358
1358
|
if (!e || e.length === 0) return /* @__PURE__ */ new Map();
|
|
1359
1359
|
const t = e.map((a) => {
|
|
1360
|
-
const c = new Date(a.start), d = new Date(a.end),
|
|
1361
|
-
return { id: a.id, startMin:
|
|
1360
|
+
const c = new Date(a.start), d = new Date(a.end), l = c.getHours() * 60 + c.getMinutes(), f = Math.max(l + 1, d.getHours() * 60 + d.getMinutes());
|
|
1361
|
+
return { id: a.id, startMin: l, endMin: f };
|
|
1362
1362
|
});
|
|
1363
1363
|
t.sort((a, c) => a.startMin - c.startMin || c.endMin - c.startMin - (a.endMin - a.startMin));
|
|
1364
|
-
const r = [],
|
|
1364
|
+
const r = [], s = /* @__PURE__ */ new Map();
|
|
1365
1365
|
for (const a of t) {
|
|
1366
1366
|
let c = !1;
|
|
1367
1367
|
for (let d = 0; d < r.length; d++)
|
|
1368
1368
|
if (r[d] <= a.startMin) {
|
|
1369
|
-
r[d] = a.endMin,
|
|
1369
|
+
r[d] = a.endMin, s.set(a.id, { column: d, totalColumns: 0 }), c = !0;
|
|
1370
1370
|
break;
|
|
1371
1371
|
}
|
|
1372
|
-
c || (
|
|
1372
|
+
c || (s.set(a.id, { column: r.length, totalColumns: 0 }), r.push(a.endMin));
|
|
1373
1373
|
}
|
|
1374
|
-
const
|
|
1374
|
+
const i = [];
|
|
1375
1375
|
let n = [], o = 0;
|
|
1376
1376
|
for (const a of t)
|
|
1377
|
-
n.length === 0 || a.startMin < o ? (n.push(a), o = Math.max(o, a.endMin)) : (
|
|
1378
|
-
n.length > 0 &&
|
|
1379
|
-
for (const a of
|
|
1380
|
-
const c = Math.max(...a.map((d) =>
|
|
1377
|
+
n.length === 0 || a.startMin < o ? (n.push(a), o = Math.max(o, a.endMin)) : (i.push(n), n = [a], o = a.endMin);
|
|
1378
|
+
n.length > 0 && i.push(n);
|
|
1379
|
+
for (const a of i) {
|
|
1380
|
+
const c = Math.max(...a.map((d) => s.get(d.id).column)) + 1;
|
|
1381
1381
|
for (const d of a)
|
|
1382
|
-
|
|
1382
|
+
s.get(d.id).totalColumns = c;
|
|
1383
1383
|
}
|
|
1384
|
-
return
|
|
1384
|
+
return s;
|
|
1385
1385
|
}
|
|
1386
1386
|
/**
|
|
1387
1387
|
* Render a timed event block
|
|
@@ -1392,19 +1392,19 @@ class _ {
|
|
|
1392
1392
|
* @returns {string} HTML string
|
|
1393
1393
|
*/
|
|
1394
1394
|
renderTimedEvent(e, t = {}) {
|
|
1395
|
-
const { compact: r = !0, overlapLayout:
|
|
1396
|
-
let
|
|
1397
|
-
if (
|
|
1398
|
-
const { column: C, totalColumns:
|
|
1399
|
-
|
|
1395
|
+
const { compact: r = !0, overlapLayout: s = null } = t, i = new Date(e.start), n = new Date(e.end), o = i.getHours() * 60 + i.getMinutes(), a = Math.max((n - i) / (1e3 * 60), r ? 20 : 30), c = this.getEventColor(e), d = r ? "4px 8px" : "8px 12px", l = r ? "11px" : "13px", f = r ? 2 : 12, m = r ? 2 : 24, b = r ? "4px" : "6px";
|
|
1396
|
+
let y, x;
|
|
1397
|
+
if (s && s.has(e.id)) {
|
|
1398
|
+
const { column: C, totalColumns: _ } = s.get(e.id), $ = `(100% - ${f + m}px)`;
|
|
1399
|
+
y = `calc(${f}px + ${C} * ${$} / ${_})`, x = `calc(${$} / ${_})`;
|
|
1400
1400
|
} else
|
|
1401
|
-
|
|
1401
|
+
y = `${f}px`, x = `calc(100% - ${f + m}px)`;
|
|
1402
1402
|
return `
|
|
1403
1403
|
<div class="fc-event fc-timed-event" data-event-id="${this.escapeHTML(e.id)}"
|
|
1404
1404
|
style="position: absolute; top: ${o}px; height: ${a}px;
|
|
1405
|
-
left: ${
|
|
1406
|
-
background-color: ${c}; border-radius: ${
|
|
1407
|
-
padding: ${d}; font-size: ${
|
|
1405
|
+
left: ${y}; width: ${x};
|
|
1406
|
+
background-color: ${c}; border-radius: ${b};
|
|
1407
|
+
padding: ${d}; font-size: ${l};
|
|
1408
1408
|
font-weight: 500; color: white; overflow: hidden;
|
|
1409
1409
|
box-shadow: 0 1px 2px rgba(0,0,0,0.1);
|
|
1410
1410
|
cursor: pointer; z-index: 5;">
|
|
@@ -1412,7 +1412,7 @@ class _ {
|
|
|
1412
1412
|
${this.escapeHTML(e.title)}
|
|
1413
1413
|
</div>
|
|
1414
1414
|
<div style="font-size: ${r ? "10px" : "11px"}; opacity: 0.9;">
|
|
1415
|
-
${this.formatTime(
|
|
1415
|
+
${this.formatTime(i)}${r ? "" : " - " + this.formatTime(n)}
|
|
1416
1416
|
</div>
|
|
1417
1417
|
</div>
|
|
1418
1418
|
`;
|
|
@@ -1423,7 +1423,7 @@ class _ {
|
|
|
1423
1423
|
* @returns {string}
|
|
1424
1424
|
*/
|
|
1425
1425
|
getEventColor(e) {
|
|
1426
|
-
return
|
|
1426
|
+
return u.sanitizeColor(e == null ? void 0 : e.backgroundColor, "#2563eb");
|
|
1427
1427
|
}
|
|
1428
1428
|
/**
|
|
1429
1429
|
* Attach common event handlers for day/event clicks
|
|
@@ -1433,12 +1433,12 @@ class _ {
|
|
|
1433
1433
|
const t = e.target.closest(".fc-event");
|
|
1434
1434
|
if (!t || !this.container.contains(t)) return;
|
|
1435
1435
|
e.stopPropagation();
|
|
1436
|
-
const r = t.dataset.eventId,
|
|
1437
|
-
|
|
1436
|
+
const r = t.dataset.eventId, s = this.stateManager.getEvents().find((i) => i.id === r);
|
|
1437
|
+
s && this.stateManager.selectEvent(s);
|
|
1438
1438
|
});
|
|
1439
1439
|
}
|
|
1440
1440
|
}
|
|
1441
|
-
class
|
|
1441
|
+
class g extends E {
|
|
1442
1442
|
constructor(e, t) {
|
|
1443
1443
|
super(e, t), this.maxEventsToShow = 3;
|
|
1444
1444
|
}
|
|
@@ -1455,7 +1455,7 @@ class m extends _ {
|
|
|
1455
1455
|
}
|
|
1456
1456
|
_renderMonthView(e, t) {
|
|
1457
1457
|
const r = t.weekStartsOn || 0;
|
|
1458
|
-
let
|
|
1458
|
+
let i = `
|
|
1459
1459
|
<div class="fc-month-view" style="display: flex; flex-direction: column; height: 100%; min-height: 400px; background: #fff; border: 1px solid #e5e7eb;">
|
|
1460
1460
|
<div class="fc-month-header" style="display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid #e5e7eb; background: #f9fafb;">
|
|
1461
1461
|
${this._getDayNames(r).map((n) => `<div class="fc-month-header-cell" style="padding: 12px 8px; text-align: center; font-size: 11px; font-weight: 600; color: #6b7280; text-transform: uppercase;">${n}</div>`).join("")}
|
|
@@ -1463,14 +1463,14 @@ class m extends _ {
|
|
|
1463
1463
|
<div class="fc-month-body" style="display: flex; flex-direction: column; flex: 1;">
|
|
1464
1464
|
`;
|
|
1465
1465
|
return e.weeks.forEach((n) => {
|
|
1466
|
-
|
|
1467
|
-
}),
|
|
1466
|
+
i += this._renderWeek(n);
|
|
1467
|
+
}), i += "</div></div>", i;
|
|
1468
1468
|
}
|
|
1469
1469
|
_getDayNames(e) {
|
|
1470
1470
|
const t = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], r = [];
|
|
1471
|
-
for (let
|
|
1472
|
-
const
|
|
1473
|
-
r.push(t[
|
|
1471
|
+
for (let s = 0; s < 7; s++) {
|
|
1472
|
+
const i = (e + s) % 7;
|
|
1473
|
+
r.push(t[i]);
|
|
1474
1474
|
}
|
|
1475
1475
|
return r;
|
|
1476
1476
|
}
|
|
@@ -1481,11 +1481,11 @@ class m extends _ {
|
|
|
1481
1481
|
}), t += "</div>", t;
|
|
1482
1482
|
}
|
|
1483
1483
|
_renderDay(e) {
|
|
1484
|
-
const t = !e.isCurrentMonth, r = e.isToday,
|
|
1484
|
+
const t = !e.isCurrentMonth, r = e.isToday, s = t ? "#f3f4f6" : "#fff", i = t ? "#9ca3af" : "#111827", n = r ? "background: #2563eb; color: white; border-radius: 50%; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;" : "", o = e.events || [], a = o.slice(0, this.maxEventsToShow), c = o.length - this.maxEventsToShow;
|
|
1485
1485
|
return `
|
|
1486
1486
|
<div class="fc-month-day" data-date="${e.date}"
|
|
1487
|
-
style="background: ${
|
|
1488
|
-
<div class="fc-day-number" style="font-size: 13px; font-weight: 500; color: ${
|
|
1487
|
+
style="background: ${s}; border-right: 1px solid #e5e7eb; border-bottom: 1px solid #e5e7eb; padding: 4px; min-height: 80px; cursor: pointer; display: flex; flex-direction: column;">
|
|
1488
|
+
<div class="fc-day-number" style="font-size: 13px; font-weight: 500; color: ${i}; padding: 2px 4px; margin-bottom: 4px; ${n}">
|
|
1489
1489
|
${e.dayOfMonth}
|
|
1490
1490
|
</div>
|
|
1491
1491
|
<div class="fc-day-events" style="display: flex; flex-direction: column; gap: 2px; flex: 1; overflow: hidden;">
|
|
@@ -1513,7 +1513,7 @@ class m extends _ {
|
|
|
1513
1513
|
}), this.attachCommonEventHandlers();
|
|
1514
1514
|
}
|
|
1515
1515
|
}
|
|
1516
|
-
class
|
|
1516
|
+
class w extends E {
|
|
1517
1517
|
constructor(e, t) {
|
|
1518
1518
|
super(e, t), this.hourHeight = 60, this.totalHeight = 24 * this.hourHeight;
|
|
1519
1519
|
}
|
|
@@ -1529,12 +1529,12 @@ class D extends _ {
|
|
|
1529
1529
|
this.container.innerHTML = r, this._attachEventHandlers(), this._scrollToCurrentTime();
|
|
1530
1530
|
}
|
|
1531
1531
|
_renderWeekView(e, t) {
|
|
1532
|
-
const r = e.days,
|
|
1532
|
+
const r = e.days, s = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], i = Array.from({ length: 24 }, (o, a) => a), n = r.map((o) => {
|
|
1533
1533
|
const a = new Date(o.date), c = o.events || [];
|
|
1534
1534
|
return {
|
|
1535
1535
|
...o,
|
|
1536
1536
|
date: a,
|
|
1537
|
-
dayName:
|
|
1537
|
+
dayName: s[a.getDay()],
|
|
1538
1538
|
dayOfMonth: a.getDate(),
|
|
1539
1539
|
isToday: this.isToday(a),
|
|
1540
1540
|
timedEvents: c.filter((d) => !d.allDay),
|
|
@@ -1545,7 +1545,7 @@ class D extends _ {
|
|
|
1545
1545
|
<div class="fc-week-view" style="display: flex; flex-direction: column; height: 100%; background: #fff; overflow: hidden;">
|
|
1546
1546
|
${this._renderHeader(n)}
|
|
1547
1547
|
${this._renderAllDayRow(n)}
|
|
1548
|
-
${this._renderTimeGrid(n,
|
|
1548
|
+
${this._renderTimeGrid(n, i)}
|
|
1549
1549
|
</div>
|
|
1550
1550
|
`;
|
|
1551
1551
|
}
|
|
@@ -1626,7 +1626,7 @@ class D extends _ {
|
|
|
1626
1626
|
<!-- Timed events -->
|
|
1627
1627
|
${(() => {
|
|
1628
1628
|
const r = this.computeOverlapLayout(e.timedEvents);
|
|
1629
|
-
return e.timedEvents.map((
|
|
1629
|
+
return e.timedEvents.map((s) => this.renderTimedEvent(s, { compact: !0, overlapLayout: r })).join("");
|
|
1630
1630
|
})()}
|
|
1631
1631
|
</div>
|
|
1632
1632
|
`;
|
|
@@ -1635,7 +1635,7 @@ class D extends _ {
|
|
|
1635
1635
|
this.addListener(this.container, "click", (e) => {
|
|
1636
1636
|
const t = e.target.closest(".fc-week-day-column");
|
|
1637
1637
|
if (!t || !this.container.contains(t) || e.target.closest(".fc-event")) return;
|
|
1638
|
-
const r = new Date(t.dataset.date),
|
|
1638
|
+
const r = new Date(t.dataset.date), s = this.container.querySelector("#week-scroll-container"), i = t.offsetTop, n = e.clientY - t.getBoundingClientRect().top + (s ? s.scrollTop : 0) - i, o = Math.max(0, Math.min(n + i, this.totalHeight));
|
|
1639
1639
|
r.setHours(
|
|
1640
1640
|
Math.floor(o / this.hourHeight),
|
|
1641
1641
|
Math.floor(o % this.hourHeight / (this.hourHeight / 60)),
|
|
@@ -1650,7 +1650,7 @@ class D extends _ {
|
|
|
1650
1650
|
e && (e.scrollTop = 8 * this.hourHeight - 50, this._scrolled = !0);
|
|
1651
1651
|
}
|
|
1652
1652
|
}
|
|
1653
|
-
class
|
|
1653
|
+
class D extends E {
|
|
1654
1654
|
constructor(e, t) {
|
|
1655
1655
|
super(e, t), this.hourHeight = 60, this.totalHeight = 24 * this.hourHeight;
|
|
1656
1656
|
}
|
|
@@ -1666,40 +1666,40 @@ class k extends _ {
|
|
|
1666
1666
|
this.container.innerHTML = r, this._attachEventHandlers(), this._scrollToCurrentTime();
|
|
1667
1667
|
}
|
|
1668
1668
|
_renderDayView(e, t) {
|
|
1669
|
-
var
|
|
1670
|
-
const r = ((
|
|
1671
|
-
if (!
|
|
1669
|
+
var l, f;
|
|
1670
|
+
const r = ((f = (l = this.stateManager) == null ? void 0 : l.getState()) == null ? void 0 : f.currentDate) || /* @__PURE__ */ new Date(), s = this._extractDayData(e, r);
|
|
1671
|
+
if (!s)
|
|
1672
1672
|
return '<div style="padding: 20px; text-align: center; color: #666;">No data available for day view.</div>';
|
|
1673
|
-
const { dayDate:
|
|
1673
|
+
const { dayDate: i, dayName: n, isToday: o, allDayEvents: a, timedEvents: c } = s, d = Array.from({ length: 24 }, (m, b) => b);
|
|
1674
1674
|
return `
|
|
1675
1675
|
<div class="fc-day-view" style="display: flex; flex-direction: column; height: 100%; background: #fff; overflow: hidden;">
|
|
1676
|
-
${this._renderHeader(
|
|
1677
|
-
${this._renderAllDayRow(a,
|
|
1678
|
-
${this._renderTimeGrid(c, o,
|
|
1676
|
+
${this._renderHeader(i, n, o)}
|
|
1677
|
+
${this._renderAllDayRow(a, i)}
|
|
1678
|
+
${this._renderTimeGrid(c, o, i, d)}
|
|
1679
1679
|
</div>
|
|
1680
1680
|
`;
|
|
1681
1681
|
}
|
|
1682
1682
|
_extractDayData(e, t) {
|
|
1683
|
-
let r,
|
|
1683
|
+
let r, s, i, n, o;
|
|
1684
1684
|
const a = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
|
|
1685
1685
|
if (e.type === "day" && e.date)
|
|
1686
|
-
if (r = new Date(e.date),
|
|
1686
|
+
if (r = new Date(e.date), s = e.dayName || a[r.getDay()], i = e.isToday !== void 0 ? e.isToday : this.isToday(r), n = e.allDayEvents || [], e.hours && Array.isArray(e.hours)) {
|
|
1687
1687
|
const c = /* @__PURE__ */ new Map();
|
|
1688
1688
|
e.hours.forEach((d) => {
|
|
1689
|
-
(d.events || []).forEach((
|
|
1690
|
-
c.has(
|
|
1689
|
+
(d.events || []).forEach((l) => {
|
|
1690
|
+
c.has(l.id) || c.set(l.id, l);
|
|
1691
1691
|
});
|
|
1692
1692
|
}), o = Array.from(c.values());
|
|
1693
1693
|
} else
|
|
1694
1694
|
o = [];
|
|
1695
1695
|
else if (e.days && e.days.length > 0) {
|
|
1696
|
-
const c = e.days.find((
|
|
1697
|
-
r = new Date(c.date),
|
|
1696
|
+
const c = e.days.find((l) => this.isSameDay(new Date(l.date), t)) || e.days[0];
|
|
1697
|
+
r = new Date(c.date), s = a[r.getDay()], i = this.isToday(r);
|
|
1698
1698
|
const d = c.events || [];
|
|
1699
|
-
n = d.filter((
|
|
1699
|
+
n = d.filter((l) => l.allDay), o = d.filter((l) => !l.allDay);
|
|
1700
1700
|
} else
|
|
1701
1701
|
return null;
|
|
1702
|
-
return { dayDate: r, dayName:
|
|
1702
|
+
return { dayDate: r, dayName: s, isToday: i, allDayEvents: n, timedEvents: o };
|
|
1703
1703
|
}
|
|
1704
1704
|
_renderHeader(e, t, r) {
|
|
1705
1705
|
return `
|
|
@@ -1735,12 +1735,12 @@ class k extends _ {
|
|
|
1735
1735
|
</div>
|
|
1736
1736
|
`;
|
|
1737
1737
|
}
|
|
1738
|
-
_renderTimeGrid(e, t, r,
|
|
1738
|
+
_renderTimeGrid(e, t, r, s) {
|
|
1739
1739
|
return `
|
|
1740
1740
|
<div id="day-scroll-container" class="fc-time-grid-container" style="flex: 1; overflow-y: auto; overflow-x: hidden; position: relative;">
|
|
1741
1741
|
<div class="fc-time-grid" style="display: grid; grid-template-columns: 60px 1fr; position: relative; height: ${this.totalHeight}px;">
|
|
1742
|
-
${this._renderTimeGutter(
|
|
1743
|
-
${this._renderDayColumn(e, t, r,
|
|
1742
|
+
${this._renderTimeGutter(s)}
|
|
1743
|
+
${this._renderDayColumn(e, t, r, s)}
|
|
1744
1744
|
</div>
|
|
1745
1745
|
</div>
|
|
1746
1746
|
`;
|
|
@@ -1758,19 +1758,19 @@ class k extends _ {
|
|
|
1758
1758
|
</div>
|
|
1759
1759
|
`;
|
|
1760
1760
|
}
|
|
1761
|
-
_renderDayColumn(e, t, r,
|
|
1761
|
+
_renderDayColumn(e, t, r, s) {
|
|
1762
1762
|
return `
|
|
1763
1763
|
<div class="fc-day-column" data-date="${r.toISOString()}" style="position: relative; cursor: pointer;">
|
|
1764
1764
|
<!-- Hour grid lines -->
|
|
1765
|
-
${
|
|
1765
|
+
${s.map(() => `<div style="height: ${this.hourHeight}px; border-bottom: 1px solid #f3f4f6;"></div>`).join("")}
|
|
1766
1766
|
|
|
1767
1767
|
<!-- Now indicator for today -->
|
|
1768
1768
|
${t ? this.renderNowIndicator() : ""}
|
|
1769
1769
|
|
|
1770
1770
|
<!-- Timed events -->
|
|
1771
1771
|
${(() => {
|
|
1772
|
-
const
|
|
1773
|
-
return e.map((n) => this.renderTimedEvent(n, { compact: !1, overlapLayout:
|
|
1772
|
+
const i = this.computeOverlapLayout(e);
|
|
1773
|
+
return e.map((n) => this.renderTimedEvent(n, { compact: !1, overlapLayout: i })).join("");
|
|
1774
1774
|
})()}
|
|
1775
1775
|
</div>
|
|
1776
1776
|
`;
|
|
@@ -1779,7 +1779,7 @@ class k extends _ {
|
|
|
1779
1779
|
this.addListener(this.container, "click", (e) => {
|
|
1780
1780
|
const t = e.target.closest(".fc-day-column");
|
|
1781
1781
|
if (!t || !this.container.contains(t) || e.target.closest(".fc-event")) return;
|
|
1782
|
-
const r = new Date(t.dataset.date),
|
|
1782
|
+
const r = new Date(t.dataset.date), s = this.container.querySelector("#day-scroll-container"), i = t.offsetTop, n = e.clientY - t.getBoundingClientRect().top + (s ? s.scrollTop : 0) - i, o = Math.max(0, Math.min(n + i, this.totalHeight));
|
|
1783
1783
|
r.setHours(
|
|
1784
1784
|
Math.floor(o / this.hourHeight),
|
|
1785
1785
|
Math.floor(o % this.hourHeight / (this.hourHeight / 60)),
|
|
@@ -1794,7 +1794,7 @@ class k extends _ {
|
|
|
1794
1794
|
e && (e.scrollTop = 8 * this.hourHeight - 50, this._scrolled = !0);
|
|
1795
1795
|
}
|
|
1796
1796
|
}
|
|
1797
|
-
class
|
|
1797
|
+
class I extends M {
|
|
1798
1798
|
constructor() {
|
|
1799
1799
|
super(), this._isVisible = !1, this._cleanupFocusTrap = null, this.config = {
|
|
1800
1800
|
title: "New Event",
|
|
@@ -1824,8 +1824,8 @@ class z extends T {
|
|
|
1824
1824
|
}
|
|
1825
1825
|
getStyles() {
|
|
1826
1826
|
return `
|
|
1827
|
-
${
|
|
1828
|
-
${
|
|
1827
|
+
${u.getBaseStyles()}
|
|
1828
|
+
${u.getButtonStyles()}
|
|
1829
1829
|
|
|
1830
1830
|
:host {
|
|
1831
1831
|
display: none;
|
|
@@ -2070,7 +2070,7 @@ class z extends T {
|
|
|
2070
2070
|
});
|
|
2071
2071
|
}
|
|
2072
2072
|
open(e = /* @__PURE__ */ new Date()) {
|
|
2073
|
-
this.hasAttribute("open") || this.setAttribute("open", ""), this.titleGroup.classList.remove("has-error"), this.endGroup.classList.remove("has-error"), this._formData.start = e, this._formData.end = new Date(e.getTime() + this.config.defaultDuration * 60 * 1e3), this._formData.title = "", this._formData.color = this.config.colors[0].color, this.startInput && (this.titleInput.value = "", this.startInput.value = this.formatDateForInput(this._formData.start), this.endInput.value = this.formatDateForInput(this._formData.end), this.updateColorSelection(), this._cleanupFocusTrap && this._cleanupFocusTrap(), this._cleanupFocusTrap =
|
|
2073
|
+
this.hasAttribute("open") || this.setAttribute("open", ""), this.titleGroup.classList.remove("has-error"), this.endGroup.classList.remove("has-error"), this._formData.start = e, this._formData.end = new Date(e.getTime() + this.config.defaultDuration * 60 * 1e3), this._formData.title = "", this._formData.color = this.config.colors[0].color, this.startInput && (this.titleInput.value = "", this.startInput.value = this.formatDateForInput(this._formData.start), this.endInput.value = this.formatDateForInput(this._formData.end), this.updateColorSelection(), this._cleanupFocusTrap && this._cleanupFocusTrap(), this._cleanupFocusTrap = k.trapFocus(this.modalContent));
|
|
2074
2074
|
}
|
|
2075
2075
|
close() {
|
|
2076
2076
|
this.removeAttribute("open"), this._cleanupFocusTrap && (this._cleanupFocusTrap(), this._cleanupFocusTrap = null);
|
|
@@ -2092,15 +2092,15 @@ class z extends T {
|
|
|
2092
2092
|
this.emit("save", e), this.close();
|
|
2093
2093
|
}
|
|
2094
2094
|
formatDateForInput(e) {
|
|
2095
|
-
const t = (a) => String(a).padStart(2, "0"), r = e.getFullYear(),
|
|
2096
|
-
return `${r}-${
|
|
2095
|
+
const t = (a) => String(a).padStart(2, "0"), r = e.getFullYear(), s = t(e.getMonth() + 1), i = t(e.getDate()), n = t(e.getHours()), o = t(e.getMinutes());
|
|
2096
|
+
return `${r}-${s}-${i}T${n}:${o}`;
|
|
2097
2097
|
}
|
|
2098
2098
|
unmount() {
|
|
2099
2099
|
this._cleanupFocusTrap && this._cleanupFocusTrap(), this._handleKeyDown && (window.removeEventListener("keydown", this._handleKeyDown), this._handleKeyDown = null, this._keydownListenerAdded = !1);
|
|
2100
2100
|
}
|
|
2101
2101
|
}
|
|
2102
|
-
customElements.get("forcecal-event-form") || customElements.define("forcecal-event-form",
|
|
2103
|
-
class
|
|
2102
|
+
customElements.get("forcecal-event-form") || customElements.define("forcecal-event-form", I);
|
|
2103
|
+
class z extends M {
|
|
2104
2104
|
static get observedAttributes() {
|
|
2105
2105
|
return ["view", "date", "locale", "timezone", "week-starts-on", "height"];
|
|
2106
2106
|
}
|
|
@@ -2115,48 +2115,50 @@ class A extends T {
|
|
|
2115
2115
|
timeZone: this.getAttribute("timezone") || Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
2116
2116
|
weekStartsOn: parseInt(this.getAttribute("week-starts-on") || "0")
|
|
2117
2117
|
};
|
|
2118
|
-
this.stateManager = new
|
|
2118
|
+
this.stateManager = new V(e), this.stateManager.subscribe(this.handleStateChange.bind(this)), this.setupEventListeners();
|
|
2119
2119
|
}
|
|
2120
2120
|
setupEventListeners() {
|
|
2121
|
-
this._busUnsubscribers.forEach((
|
|
2122
|
-
|
|
2123
|
-
|
|
2121
|
+
this._busUnsubscribers.forEach((r) => r()), this._busUnsubscribers = [];
|
|
2122
|
+
const e = this.stateManager.eventBus;
|
|
2123
|
+
this._busUnsubscribers.push(
|
|
2124
|
+
e.on("navigation:*", (r, s) => {
|
|
2125
|
+
this.emit("calendar-navigate", { action: s.split(":")[1], ...r });
|
|
2124
2126
|
})
|
|
2125
2127
|
), this._busUnsubscribers.push(
|
|
2126
|
-
|
|
2127
|
-
this.emit("calendar-view-change",
|
|
2128
|
+
e.on("view:changed", (r) => {
|
|
2129
|
+
this.emit("calendar-view-change", r);
|
|
2128
2130
|
})
|
|
2129
2131
|
);
|
|
2130
|
-
const
|
|
2131
|
-
this.emit(`calendar-event-${
|
|
2132
|
+
const t = (r, s) => {
|
|
2133
|
+
this.emit(`calendar-event-${r}`, s);
|
|
2132
2134
|
};
|
|
2133
2135
|
this._busUnsubscribers.push(
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
+
e.on("event:add", (r) => {
|
|
2137
|
+
t("add", r);
|
|
2136
2138
|
})
|
|
2137
2139
|
), this._busUnsubscribers.push(
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
+
e.on("event:update", (r) => {
|
|
2141
|
+
t("update", r);
|
|
2140
2142
|
})
|
|
2141
2143
|
), this._busUnsubscribers.push(
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
+
e.on("event:remove", (r) => {
|
|
2145
|
+
t("remove", r);
|
|
2144
2146
|
})
|
|
2145
2147
|
), this._busUnsubscribers.push(
|
|
2146
|
-
|
|
2147
|
-
this.emit("calendar-event-added",
|
|
2148
|
+
e.on("event:added", (r) => {
|
|
2149
|
+
this.emit("calendar-event-added", r);
|
|
2148
2150
|
})
|
|
2149
2151
|
), this._busUnsubscribers.push(
|
|
2150
|
-
|
|
2151
|
-
this.emit("calendar-event-updated",
|
|
2152
|
+
e.on("event:updated", (r) => {
|
|
2153
|
+
this.emit("calendar-event-updated", r);
|
|
2152
2154
|
})
|
|
2153
2155
|
), this._busUnsubscribers.push(
|
|
2154
|
-
|
|
2155
|
-
this.emit("calendar-event-deleted",
|
|
2156
|
+
e.on("event:deleted", (r) => {
|
|
2157
|
+
this.emit("calendar-event-deleted", r);
|
|
2156
2158
|
})
|
|
2157
2159
|
), this._busUnsubscribers.push(
|
|
2158
|
-
|
|
2159
|
-
this.emit("calendar-date-select",
|
|
2160
|
+
e.on("date:selected", (r) => {
|
|
2161
|
+
this.emit("calendar-date-select", r);
|
|
2160
2162
|
})
|
|
2161
2163
|
);
|
|
2162
2164
|
}
|
|
@@ -2164,7 +2166,7 @@ class A extends T {
|
|
|
2164
2166
|
var a, c;
|
|
2165
2167
|
if (!this._hasRendered)
|
|
2166
2168
|
return;
|
|
2167
|
-
const r = e.view !== (t == null ? void 0 : t.view),
|
|
2169
|
+
const r = e.view !== (t == null ? void 0 : t.view), s = ((a = e.currentDate) == null ? void 0 : a.getTime()) !== ((c = t == null ? void 0 : t.currentDate) == null ? void 0 : c.getTime()), i = e.events !== (t == null ? void 0 : t.events), n = e.loading !== (t == null ? void 0 : t.loading);
|
|
2168
2170
|
if (e.error !== (t == null ? void 0 : t.error)) {
|
|
2169
2171
|
this.render();
|
|
2170
2172
|
return;
|
|
@@ -2173,7 +2175,7 @@ class A extends T {
|
|
|
2173
2175
|
this._updateLoadingState(e.loading);
|
|
2174
2176
|
return;
|
|
2175
2177
|
}
|
|
2176
|
-
r && (this.currentView = e.view), r ? (this._updateTitle(), this._updateViewButtons(), this._switchView()) :
|
|
2178
|
+
r && (this.currentView = e.view), r ? (this._updateTitle(), this._updateViewButtons(), this._switchView()) : s ? (this._updateTitle(), this._updateViewContent()) : i && this._updateViewContent();
|
|
2177
2179
|
}
|
|
2178
2180
|
/**
|
|
2179
2181
|
* Update only the title text (no DOM recreation)
|
|
@@ -2204,11 +2206,11 @@ class A extends T {
|
|
|
2204
2206
|
this._currentViewInstance && this._currentViewInstance.cleanup && this._currentViewInstance.cleanup();
|
|
2205
2207
|
try {
|
|
2206
2208
|
const r = {
|
|
2207
|
-
month:
|
|
2208
|
-
week:
|
|
2209
|
-
day:
|
|
2210
|
-
}[this.currentView] ||
|
|
2211
|
-
|
|
2209
|
+
month: g,
|
|
2210
|
+
week: w,
|
|
2211
|
+
day: D
|
|
2212
|
+
}[this.currentView] || g, s = new r(e, this.stateManager);
|
|
2213
|
+
s._viewType = this.currentView, this._currentViewInstance = s, s.render();
|
|
2212
2214
|
} catch (t) {
|
|
2213
2215
|
console.error("[ForceCalendar] Error switching view:", t);
|
|
2214
2216
|
}
|
|
@@ -2236,10 +2238,10 @@ class A extends T {
|
|
|
2236
2238
|
getStyles() {
|
|
2237
2239
|
const e = this.getAttribute("height") || "800px";
|
|
2238
2240
|
return `
|
|
2239
|
-
${
|
|
2240
|
-
${
|
|
2241
|
-
${
|
|
2242
|
-
${
|
|
2241
|
+
${u.getBaseStyles()}
|
|
2242
|
+
${u.getButtonStyles()}
|
|
2243
|
+
${u.getGridStyles()}
|
|
2244
|
+
${u.getAnimations()}
|
|
2243
2245
|
|
|
2244
2246
|
:host {
|
|
2245
2247
|
--calendar-height: ${e};
|
|
@@ -2623,12 +2625,12 @@ class A extends T {
|
|
|
2623
2625
|
`;
|
|
2624
2626
|
}
|
|
2625
2627
|
template() {
|
|
2626
|
-
const e = this.stateManager.getState(), { currentDate: t, view: r, loading:
|
|
2627
|
-
if (
|
|
2628
|
+
const e = this.stateManager.getState(), { currentDate: t, view: r, loading: s, error: i } = e;
|
|
2629
|
+
if (i)
|
|
2628
2630
|
return `
|
|
2629
2631
|
<div class="force-calendar">
|
|
2630
2632
|
<div class="fc-error">
|
|
2631
|
-
<p><strong>Error:</strong> ${
|
|
2633
|
+
<p><strong>Error:</strong> ${k.escapeHTML(i.message || "An error occurred")}</p>
|
|
2632
2634
|
</div>
|
|
2633
2635
|
</div>
|
|
2634
2636
|
`;
|
|
@@ -2668,11 +2670,11 @@ class A extends T {
|
|
|
2668
2670
|
</header>
|
|
2669
2671
|
|
|
2670
2672
|
<div class="fc-body">
|
|
2671
|
-
<div class="fc-loading" style="display: ${
|
|
2673
|
+
<div class="fc-loading" style="display: ${s ? "flex" : "none"};">
|
|
2672
2674
|
<div class="fc-spinner"></div>
|
|
2673
2675
|
<span>Loading...</span>
|
|
2674
2676
|
</div>
|
|
2675
|
-
<div class="fc-view-container" style="display: ${
|
|
2677
|
+
<div class="fc-view-container" style="display: ${s ? "none" : "flex"};">
|
|
2676
2678
|
${this.renderView()}
|
|
2677
2679
|
</div>
|
|
2678
2680
|
</div>
|
|
@@ -2691,31 +2693,31 @@ class A extends T {
|
|
|
2691
2693
|
return;
|
|
2692
2694
|
this._currentViewInstance && (this._currentViewInstance.cleanup && this._currentViewInstance.cleanup(), this._viewUnsubscribe && (this._viewUnsubscribe(), this._viewUnsubscribe = null));
|
|
2693
2695
|
try {
|
|
2694
|
-
const
|
|
2695
|
-
month:
|
|
2696
|
-
week:
|
|
2697
|
-
day:
|
|
2698
|
-
}[this.currentView] ||
|
|
2696
|
+
const i = {
|
|
2697
|
+
month: g,
|
|
2698
|
+
week: w,
|
|
2699
|
+
day: D
|
|
2700
|
+
}[this.currentView] || g, n = new i(e, this.stateManager);
|
|
2699
2701
|
n._viewType = this.currentView, this._currentViewInstance = n, n.render();
|
|
2700
|
-
} catch (
|
|
2701
|
-
console.error("[ForceCalendar] Error creating/rendering view:",
|
|
2702
|
+
} catch (s) {
|
|
2703
|
+
console.error("[ForceCalendar] Error creating/rendering view:", s);
|
|
2702
2704
|
}
|
|
2703
2705
|
}
|
|
2704
|
-
this.$$("[data-action]").forEach((
|
|
2705
|
-
this.addListener(
|
|
2706
|
-
}), this.$$("[data-view]").forEach((
|
|
2707
|
-
this.addListener(
|
|
2706
|
+
this.$$("[data-action]").forEach((s) => {
|
|
2707
|
+
this.addListener(s, "click", this.handleNavigation);
|
|
2708
|
+
}), this.$$("[data-view]").forEach((s) => {
|
|
2709
|
+
this.addListener(s, "click", this.handleViewChange);
|
|
2708
2710
|
});
|
|
2709
2711
|
const t = this.$("#event-modal"), r = this.$("#create-event-btn");
|
|
2710
2712
|
r && t && this.addListener(r, "click", () => {
|
|
2711
2713
|
t.open(/* @__PURE__ */ new Date());
|
|
2712
|
-
}), this.addListener(this.shadowRoot, "day-click", (
|
|
2713
|
-
t && t.open(
|
|
2714
|
-
}), t && this.addListener(t, "save", (
|
|
2715
|
-
const
|
|
2714
|
+
}), this.addListener(this.shadowRoot, "day-click", (s) => {
|
|
2715
|
+
t && t.open(s.detail.date);
|
|
2716
|
+
}), t && this.addListener(t, "save", (s) => {
|
|
2717
|
+
const i = s.detail, n = window.crypto && typeof window.crypto.randomUUID == "function" ? window.crypto.randomUUID() : Math.random().toString(36).substring(2, 15);
|
|
2716
2718
|
this.stateManager.addEvent({
|
|
2717
2719
|
id: n,
|
|
2718
|
-
...
|
|
2720
|
+
...i
|
|
2719
2721
|
});
|
|
2720
2722
|
}), this._hasRendered = !0;
|
|
2721
2723
|
}
|
|
@@ -2727,10 +2729,10 @@ class A extends T {
|
|
|
2727
2729
|
*/
|
|
2728
2730
|
_createViewRenderer(e) {
|
|
2729
2731
|
const r = {
|
|
2730
|
-
month:
|
|
2731
|
-
week:
|
|
2732
|
-
day:
|
|
2733
|
-
}[e] ||
|
|
2732
|
+
month: g,
|
|
2733
|
+
week: w,
|
|
2734
|
+
day: D
|
|
2735
|
+
}[e] || g;
|
|
2734
2736
|
return new r(null, null);
|
|
2735
2737
|
}
|
|
2736
2738
|
handleNavigation(e) {
|
|
@@ -2754,15 +2756,15 @@ class A extends T {
|
|
|
2754
2756
|
const r = this.stateManager.state.config.locale;
|
|
2755
2757
|
switch (t) {
|
|
2756
2758
|
case "month":
|
|
2757
|
-
return
|
|
2759
|
+
return p.formatDate(e, "month", r);
|
|
2758
2760
|
case "week": {
|
|
2759
|
-
const
|
|
2760
|
-
return
|
|
2761
|
+
const s = p.startOfWeek(e), i = p.endOfWeek(e);
|
|
2762
|
+
return p.formatDateRange(s, i, r);
|
|
2761
2763
|
}
|
|
2762
2764
|
case "day":
|
|
2763
|
-
return
|
|
2765
|
+
return p.formatDate(e, "long", r);
|
|
2764
2766
|
default:
|
|
2765
|
-
return
|
|
2767
|
+
return p.formatDate(e, "month", r);
|
|
2766
2768
|
}
|
|
2767
2769
|
}
|
|
2768
2770
|
getIcon(e) {
|
|
@@ -2816,19 +2818,19 @@ class A extends T {
|
|
|
2816
2818
|
this._busUnsubscribers.forEach((e) => e()), this._busUnsubscribers = [], this.stateManager && this.stateManager.destroy(), super.cleanup();
|
|
2817
2819
|
}
|
|
2818
2820
|
}
|
|
2819
|
-
customElements.get("forcecal-main") || customElements.define("forcecal-main",
|
|
2821
|
+
customElements.get("forcecal-main") || customElements.define("forcecal-main", z);
|
|
2820
2822
|
export {
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2823
|
+
M as BaseComponent,
|
|
2824
|
+
E as BaseViewRenderer,
|
|
2825
|
+
k as DOMUtils,
|
|
2826
|
+
p as DateUtils,
|
|
2827
|
+
D as DayViewRenderer,
|
|
2828
|
+
T as EventBus,
|
|
2829
|
+
z as ForceCalendar,
|
|
2830
|
+
g as MonthViewRenderer,
|
|
2831
|
+
V as StateManager,
|
|
2832
|
+
u as StyleUtils,
|
|
2833
|
+
w as WeekViewRenderer,
|
|
2834
|
+
R as eventBus
|
|
2833
2835
|
};
|
|
2834
2836
|
//# sourceMappingURL=force-calendar-interface.esm.js.map
|