@forcecalendar/interface 1.4.0 → 1.6.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/dist/force-calendar-interface.esm.js +219 -56
- package/dist/force-calendar-interface.esm.js.map +1 -1
- package/dist/force-calendar-interface.umd.js +17 -17
- package/dist/force-calendar-interface.umd.js.map +1 -1
- package/package.json +4 -4
- package/src/components/ForceCalendar.js +150 -9
- package/src/core/BaseComponent.js +4 -0
- package/src/core/StateManager.js +235 -0
- package/src/index.js +1 -0
- package/src/utils/StyleUtils.js +28 -0
- package/types/components/ForceCalendar.d.ts +56 -3
- package/types/core/StateManager.d.ts +164 -16
- package/types/index.d.ts +1 -0
- package/types/utils/DateUtils.d.ts +1 -1
- package/types/utils/StyleUtils.d.ts +26 -0
|
@@ -8,7 +8,7 @@ var n = class extends HTMLElement {
|
|
|
8
8
|
this._initialized ||= (this.initialize(), !0), this.mount();
|
|
9
9
|
}
|
|
10
10
|
disconnectedCallback() {
|
|
11
|
-
this.unmount(), this.cleanup(), this._styleEl = null, this._contentWrapper = null;
|
|
11
|
+
this.unmount(), this.cleanup(), this._styleEl && this._styleEl.remove(), this._contentWrapper && this._contentWrapper.remove(), this._styleEl = null, this._contentWrapper = null;
|
|
12
12
|
}
|
|
13
13
|
initialize() {}
|
|
14
14
|
mount() {
|
|
@@ -236,7 +236,7 @@ var n = class extends HTMLElement {
|
|
|
236
236
|
loading: !1,
|
|
237
237
|
error: null,
|
|
238
238
|
config: { ...t }
|
|
239
|
-
}, this.subscribers = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this), this.unsubscribe = this.unsubscribe.bind(this), this.setState = this.setState.bind(this), this._syncEventsFromCore({ silent: !0 });
|
|
239
|
+
}, this.subscribers = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this), this.unsubscribe = this.unsubscribe.bind(this), this.setState = this.setState.bind(this), this._syncEventsFromCore({ silent: !0 }), this._visibleRangeKey = this._rangeKey(this.getVisibleRange());
|
|
240
240
|
}
|
|
241
241
|
_syncEventsFromCore(e = {}) {
|
|
242
242
|
let { force: t = !1 } = e, n = this.calendar.getEvents() || [];
|
|
@@ -299,28 +299,28 @@ var n = class extends HTMLElement {
|
|
|
299
299
|
});
|
|
300
300
|
}
|
|
301
301
|
setView(e) {
|
|
302
|
-
this.calendar.setView(e), this.setState({ view: e }), this.eventBus.emit("view:changed", { view: e });
|
|
302
|
+
this.calendar.setView(e), this.setState({ view: e }), this.eventBus.emit("view:changed", { view: e }), this._syncVisibleRange();
|
|
303
303
|
}
|
|
304
304
|
getView() {
|
|
305
305
|
return this.state.view;
|
|
306
306
|
}
|
|
307
307
|
setDate(e) {
|
|
308
|
-
this.calendar.goToDate(e), this.setState({ currentDate: this.calendar.getCurrentDate() }), this.eventBus.emit("date:changed", { date: this.state.currentDate });
|
|
308
|
+
this.calendar.goToDate(e), this.setState({ currentDate: this.calendar.getCurrentDate() }), this.eventBus.emit("date:changed", { date: this.state.currentDate }), this._syncVisibleRange();
|
|
309
309
|
}
|
|
310
310
|
getCurrentDate() {
|
|
311
311
|
return this.state.currentDate;
|
|
312
312
|
}
|
|
313
313
|
next() {
|
|
314
|
-
this.calendar.next(), this.setState({ currentDate: this.calendar.getCurrentDate() }), this.eventBus.emit("navigation:next", { date: this.state.currentDate });
|
|
314
|
+
this.calendar.next(), this.setState({ currentDate: this.calendar.getCurrentDate() }), this.eventBus.emit("navigation:next", { date: this.state.currentDate }), this._syncVisibleRange();
|
|
315
315
|
}
|
|
316
316
|
previous() {
|
|
317
|
-
this.calendar.previous(), this.setState({ currentDate: this.calendar.getCurrentDate() }), this.eventBus.emit("navigation:previous", { date: this.state.currentDate });
|
|
317
|
+
this.calendar.previous(), this.setState({ currentDate: this.calendar.getCurrentDate() }), this.eventBus.emit("navigation:previous", { date: this.state.currentDate }), this._syncVisibleRange();
|
|
318
318
|
}
|
|
319
319
|
today() {
|
|
320
|
-
this.calendar.today(), this.setState({ currentDate: this.calendar.getCurrentDate() }), this.eventBus.emit("navigation:today", { date: this.state.currentDate });
|
|
320
|
+
this.calendar.today(), this.setState({ currentDate: this.calendar.getCurrentDate() }), this.eventBus.emit("navigation:today", { date: this.state.currentDate }), this._syncVisibleRange();
|
|
321
321
|
}
|
|
322
322
|
goToDate(e) {
|
|
323
|
-
this.calendar.goToDate(e), this.setState({ currentDate: this.calendar.getCurrentDate() }), this.eventBus.emit("navigation:goto", { date: this.state.currentDate });
|
|
323
|
+
this.calendar.goToDate(e), this.setState({ currentDate: this.calendar.getCurrentDate() }), this.eventBus.emit("navigation:goto", { date: this.state.currentDate }), this._syncVisibleRange();
|
|
324
324
|
}
|
|
325
325
|
addEvent(e) {
|
|
326
326
|
let t = this.calendar.addEvent(e);
|
|
@@ -350,6 +350,69 @@ var n = class extends HTMLElement {
|
|
|
350
350
|
getEvents() {
|
|
351
351
|
return this.calendar.getEvents() || [];
|
|
352
352
|
}
|
|
353
|
+
setEvents(e, t = {}) {
|
|
354
|
+
let { removeMissing: n = !0 } = t, r = e ? Array.from(e) : [], i;
|
|
355
|
+
try {
|
|
356
|
+
i = typeof this.calendar.reconcileEvents == "function" ? this.calendar.setEvents(r, {
|
|
357
|
+
reconcile: !0,
|
|
358
|
+
removeMissing: n
|
|
359
|
+
}) : this._reconcileFallback(r, n);
|
|
360
|
+
} catch (e) {
|
|
361
|
+
throw this.eventBus.emit("event:error", {
|
|
362
|
+
action: "set",
|
|
363
|
+
events: r,
|
|
364
|
+
error: e
|
|
365
|
+
}), e;
|
|
366
|
+
}
|
|
367
|
+
let { added: a, updated: o, removed: s, unchanged: c } = i, l = {
|
|
368
|
+
events: this.getEvents(),
|
|
369
|
+
added: a,
|
|
370
|
+
updated: o,
|
|
371
|
+
removed: s,
|
|
372
|
+
unchanged: c
|
|
373
|
+
};
|
|
374
|
+
return (a.length > 0 || o.length > 0 || s.length > 0) && this.setState({ events: [...l.events] }), this.eventBus.emit("events:set", l), l;
|
|
375
|
+
}
|
|
376
|
+
_reconcileFallback(e, t) {
|
|
377
|
+
let n = /* @__PURE__ */ new Map();
|
|
378
|
+
e.forEach((e) => {
|
|
379
|
+
let t = e && e.id;
|
|
380
|
+
if (t == null || t === "") throw Error("Every event in a snapshot must have an id");
|
|
381
|
+
if (n.has(t)) throw Error(`Duplicate event id in snapshot: ${t}`);
|
|
382
|
+
n.set(t, e);
|
|
383
|
+
});
|
|
384
|
+
let r = {
|
|
385
|
+
added: [],
|
|
386
|
+
updated: [],
|
|
387
|
+
removed: [],
|
|
388
|
+
unchanged: []
|
|
389
|
+
}, i = new Map(this.getEvents().map((e) => [e.id, e]));
|
|
390
|
+
return t && i.forEach((e, t) => {
|
|
391
|
+
!n.has(t) && this.calendar.removeEvent(t) && r.removed.push(e);
|
|
392
|
+
}), n.forEach((e, t) => {
|
|
393
|
+
let n = i.get(t), a = typeof e.toObject == "function" ? e.toObject() : e;
|
|
394
|
+
if (!n) {
|
|
395
|
+
let n = this.calendar.addEvent(e);
|
|
396
|
+
if (!n) throw Error(`Failed to add event: ${t}`);
|
|
397
|
+
r.added.push(n);
|
|
398
|
+
} else if (n === e || this._isEquivalentFallback(n, a)) r.unchanged.push(n);
|
|
399
|
+
else {
|
|
400
|
+
let e = this.calendar.updateEvent(t, a);
|
|
401
|
+
if (!e) throw Error(`Failed to update event: ${t}`);
|
|
402
|
+
r.updated.push({
|
|
403
|
+
event: e,
|
|
404
|
+
oldEvent: n
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
}), r;
|
|
408
|
+
}
|
|
409
|
+
_isEquivalentFallback(e, t) {
|
|
410
|
+
let n = (e) => e instanceof Date ? e.getTime() : e == null ? NaN : new Date(e).getTime();
|
|
411
|
+
return Object.keys(t).every((r) => {
|
|
412
|
+
let i = e[r], a = t[r];
|
|
413
|
+
return r === "start" || r === "end" ? n(i) === n(a) : i === a ? !0 : i == null || a == null ? !1 : JSON.stringify(i) === JSON.stringify(a);
|
|
414
|
+
});
|
|
415
|
+
}
|
|
353
416
|
syncEvents() {
|
|
354
417
|
return this._syncEventsFromCore();
|
|
355
418
|
}
|
|
@@ -388,6 +451,41 @@ var n = class extends HTMLElement {
|
|
|
388
451
|
}
|
|
389
452
|
return t;
|
|
390
453
|
}
|
|
454
|
+
getVisibleRange() {
|
|
455
|
+
let e = this.calendar.getView(), t = this.calendar.getCurrentDate();
|
|
456
|
+
if (e !== "day") {
|
|
457
|
+
let e = this.calendar.getViewData() || {};
|
|
458
|
+
if (e.startDate instanceof Date && e.endDate instanceof Date) {
|
|
459
|
+
let t = new Date(e.startDate), n = new Date(e.endDate);
|
|
460
|
+
return e.type === "list" && (n = /* @__PURE__ */ new Date(n.getTime() - 1)), {
|
|
461
|
+
start: t,
|
|
462
|
+
end: n
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
let n = new Date(t);
|
|
467
|
+
n.setHours(0, 0, 0, 0);
|
|
468
|
+
let r = new Date(n);
|
|
469
|
+
return r.setDate(r.getDate() + 1), r.setMilliseconds(-1), {
|
|
470
|
+
start: n,
|
|
471
|
+
end: r
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
_rangeKey(e) {
|
|
475
|
+
return `${e.start.getTime()}:${e.end.getTime()}`;
|
|
476
|
+
}
|
|
477
|
+
_syncVisibleRange() {
|
|
478
|
+
if (!this.calendar) return;
|
|
479
|
+
let e = this.getVisibleRange(), t = this._rangeKey(e);
|
|
480
|
+
if (t === this._visibleRangeKey) return;
|
|
481
|
+
this._visibleRangeKey = t;
|
|
482
|
+
let n = {
|
|
483
|
+
...e,
|
|
484
|
+
view: this.state.view,
|
|
485
|
+
date: this.state.currentDate
|
|
486
|
+
};
|
|
487
|
+
this.eventBus.emit("range:changed", n);
|
|
488
|
+
}
|
|
391
489
|
selectEvent(e) {
|
|
392
490
|
this.setState({ selectedEvent: e }), this.eventBus.emit("event:selected", { event: e });
|
|
393
491
|
}
|
|
@@ -428,7 +526,7 @@ var n = class extends HTMLElement {
|
|
|
428
526
|
this.setState({ config: {
|
|
429
527
|
...this.state.config,
|
|
430
528
|
...e
|
|
431
|
-
} }), e.weekStartsOn !== void 0 && this.calendar.setWeekStartsOn(e.weekStartsOn), e.locale !== void 0 && this.calendar.setLocale(e.locale), e.timeZone !== void 0 && this.calendar.setTimezone(e.timeZone);
|
|
529
|
+
} }), e.weekStartsOn !== void 0 && (this.calendar.setWeekStartsOn(e.weekStartsOn), this._syncVisibleRange()), e.locale !== void 0 && this.calendar.setLocale(e.locale), e.timeZone !== void 0 && this.calendar.setTimezone(e.timeZone);
|
|
432
530
|
}
|
|
433
531
|
destroy() {
|
|
434
532
|
this.subscribers.clear(), this._subscriberIds &&= (this._subscriberIds.clear(), null), this.eventBus &&= (this.eventBus.clear(), null), this.state = null, this.calendar = null;
|
|
@@ -677,7 +775,26 @@ var n = class extends HTMLElement {
|
|
|
677
775
|
};
|
|
678
776
|
return e.addEventListener("keydown", i), n?.focus(), () => e.removeEventListener("keydown", i);
|
|
679
777
|
}
|
|
680
|
-
}, c =
|
|
778
|
+
}, c = { slds: {
|
|
779
|
+
"--fc-primary-color": "#0176d3",
|
|
780
|
+
"--fc-primary-hover": "#014486",
|
|
781
|
+
"--fc-primary-light": "#eef4ff",
|
|
782
|
+
"--fc-accent-color": "#0b5cab",
|
|
783
|
+
"--fc-text-color": "#181818",
|
|
784
|
+
"--fc-text-secondary": "#706e6b",
|
|
785
|
+
"--fc-text-light": "#939393",
|
|
786
|
+
"--fc-border-color": "#e5e5e5",
|
|
787
|
+
"--fc-border-color-hover": "#c9c9c9",
|
|
788
|
+
"--fc-background": "#ffffff",
|
|
789
|
+
"--fc-background-alt": "#f3f3f3",
|
|
790
|
+
"--fc-background-hover": "#f3f3f3",
|
|
791
|
+
"--fc-background-active": "#d8e6fe",
|
|
792
|
+
"--fc-danger-color": "#ea001e",
|
|
793
|
+
"--fc-success-color": "#2e844a",
|
|
794
|
+
"--fc-border-radius": "0.25rem",
|
|
795
|
+
"--fc-border-radius-sm": "0.125rem",
|
|
796
|
+
"--fc-font-family": "'Salesforce Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"
|
|
797
|
+
} }, l = class {
|
|
681
798
|
static colors = {
|
|
682
799
|
primary: "#3B82F6",
|
|
683
800
|
secondary: "#64748B",
|
|
@@ -882,7 +999,7 @@ var n = class extends HTMLElement {
|
|
|
882
999
|
static getAnimations() {
|
|
883
1000
|
return "\n @keyframes fc-fade-in {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n\n @keyframes fc-slide-in-up {\n from {\n opacity: 0;\n transform: translateY(10px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n\n @keyframes fc-slide-in-down {\n from {\n opacity: 0;\n transform: translateY(-10px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n\n @keyframes fc-scale-in {\n from {\n opacity: 0;\n transform: scale(0.95);\n }\n to {\n opacity: 1;\n transform: scale(1);\n }\n }\n\n @keyframes fc-spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n }\n\n .fc-fade-in {\n animation: fc-fade-in var(--fc-transition);\n }\n\n .fc-slide-in-up {\n animation: fc-slide-in-up var(--fc-transition);\n }\n\n .fc-scale-in {\n animation: fc-scale-in var(--fc-transition);\n }\n ";
|
|
884
1001
|
}
|
|
885
|
-
},
|
|
1002
|
+
}, u = class {
|
|
886
1003
|
constructor(e, t) {
|
|
887
1004
|
this.container = e, this.stateManager = t, this._listeners = [], this._scrolled = !1, this._nowIndicatorTimer = null;
|
|
888
1005
|
}
|
|
@@ -921,7 +1038,7 @@ var n = class extends HTMLElement {
|
|
|
921
1038
|
return n === 0 ? `${i} ${r}` : `${i}:${n.toString().padStart(2, "0")} ${r}`;
|
|
922
1039
|
}
|
|
923
1040
|
getContrastingTextColor(e) {
|
|
924
|
-
return !e || typeof e != "string" || e.charAt(0) !== "#" ? "white" :
|
|
1041
|
+
return !e || typeof e != "string" || e.charAt(0) !== "#" ? "white" : l.getContrastColor(e);
|
|
925
1042
|
}
|
|
926
1043
|
renderNowIndicator() {
|
|
927
1044
|
let e = /* @__PURE__ */ new Date();
|
|
@@ -996,7 +1113,7 @@ var n = class extends HTMLElement {
|
|
|
996
1113
|
`;
|
|
997
1114
|
}
|
|
998
1115
|
getEventColor(e) {
|
|
999
|
-
return
|
|
1116
|
+
return l.sanitizeColor(e?.backgroundColor, "#2563eb");
|
|
1000
1117
|
}
|
|
1001
1118
|
attachCommonEventHandlers() {
|
|
1002
1119
|
this.addListener(this.container, "click", (e) => {
|
|
@@ -1099,18 +1216,18 @@ var n = class extends HTMLElement {
|
|
|
1099
1216
|
t && e.setAttribute("aria-label", `Event: ${t}`);
|
|
1100
1217
|
}
|
|
1101
1218
|
}
|
|
1102
|
-
},
|
|
1103
|
-
function
|
|
1219
|
+
}, d = 4, f = 15, p = 1;
|
|
1220
|
+
function m(e, t = f) {
|
|
1104
1221
|
return Math.round(e / t) * t;
|
|
1105
1222
|
}
|
|
1106
|
-
function
|
|
1223
|
+
function h(e, t) {
|
|
1107
1224
|
return Math.max(0, Math.min(e, 1440 - t));
|
|
1108
1225
|
}
|
|
1109
|
-
function
|
|
1226
|
+
function g(e, t) {
|
|
1110
1227
|
let n = new Date(e);
|
|
1111
1228
|
return n.setHours(t.getHours(), t.getMinutes(), t.getSeconds(), t.getMilliseconds()), n;
|
|
1112
1229
|
}
|
|
1113
|
-
var
|
|
1230
|
+
var _ = class {
|
|
1114
1231
|
constructor(e) {
|
|
1115
1232
|
this.renderer = e, this.container = e.container, this.stateManager = e.stateManager, this._active = null, this._docListeners = [];
|
|
1116
1233
|
}
|
|
@@ -1188,7 +1305,7 @@ var g = class {
|
|
|
1188
1305
|
let t = this._active;
|
|
1189
1306
|
if (t) {
|
|
1190
1307
|
if (!t.dragging) {
|
|
1191
|
-
if (Math.abs(e.clientX - t.startX) <
|
|
1308
|
+
if (Math.abs(e.clientX - t.startX) < d && Math.abs(e.clientY - t.startY) < d) return;
|
|
1192
1309
|
t.dragging = !0, t.eventEl && t.eventEl.classList.add("fc-dragging");
|
|
1193
1310
|
}
|
|
1194
1311
|
e.preventDefault(), t.onDragMove(e);
|
|
@@ -1239,7 +1356,7 @@ var g = class {
|
|
|
1239
1356
|
if (!t) return;
|
|
1240
1357
|
let n = this.stateManager.getEvents().find((t) => t.id === e.eventId);
|
|
1241
1358
|
if (!n) return;
|
|
1242
|
-
let r = new Date(n.start), i =
|
|
1359
|
+
let r = new Date(n.start), i = g(new Date(t.dataset.date), r), a = i.getTime() - r.getTime();
|
|
1243
1360
|
a !== 0 && this.stateManager.updateEvent(e.eventId, {
|
|
1244
1361
|
start: i,
|
|
1245
1362
|
end: new Date(new Date(n.end).getTime() + a)
|
|
@@ -1254,22 +1371,22 @@ var g = class {
|
|
|
1254
1371
|
}
|
|
1255
1372
|
_timeMoveDragMove(e) {
|
|
1256
1373
|
let t = this._active, n = this._columnAtPoint(e.clientX) || t.originColumn;
|
|
1257
|
-
t.dropColumn = n, t.deltaMinutes =
|
|
1374
|
+
t.dropColumn = n, t.deltaMinutes = m((e.clientY - t.startY) / p);
|
|
1258
1375
|
let r = t.originColumn.getBoundingClientRect(), i = n.getBoundingClientRect();
|
|
1259
|
-
t.eventEl.style.transform = `translate(${i.left - r.left}px, ${t.deltaMinutes *
|
|
1376
|
+
t.eventEl.style.transform = `translate(${i.left - r.left}px, ${t.deltaMinutes * p}px)`;
|
|
1260
1377
|
}
|
|
1261
1378
|
_timeMoveDrop() {
|
|
1262
1379
|
let e = this._active ?? {}, t = this.stateManager.getEvents().find((t) => t.id === e.eventId);
|
|
1263
1380
|
if (!t || !e.deltaMinutes && e.dropColumn === e.originColumn) return;
|
|
1264
|
-
let n = new Date(t.start), r = new Date(t.end).getTime() - n.getTime(), i =
|
|
1381
|
+
let n = new Date(t.start), r = new Date(t.end).getTime() - n.getTime(), i = g(e.dropColumn ? new Date(e.dropColumn.dataset.date) : n, n), a = h(i.getHours() * 60 + i.getMinutes() + (e.deltaMinutes || 0), Math.round(r / 6e4)), o = new Date(i);
|
|
1265
1382
|
o.setHours(Math.floor(a / 60), a % 60, 0, 0), o.getTime() !== n.getTime() && this.stateManager.updateEvent(e.eventId, {
|
|
1266
1383
|
start: o,
|
|
1267
1384
|
end: new Date(o.getTime() + r)
|
|
1268
1385
|
});
|
|
1269
1386
|
}
|
|
1270
1387
|
_resizeDragMove(e) {
|
|
1271
|
-
let t = this._active, n =
|
|
1272
|
-
t.newHeight = Math.max(
|
|
1388
|
+
let t = this._active, n = m((e.clientY - t.startY) / p);
|
|
1389
|
+
t.newHeight = Math.max(f, t.originHeight + n), t.newHeight = Math.min(t.newHeight, 1440 - t.originTop), t.eventEl.style.height = `${t.newHeight}px`;
|
|
1273
1390
|
}
|
|
1274
1391
|
_resizeDrop() {
|
|
1275
1392
|
let e = this._active ?? {};
|
|
@@ -1281,7 +1398,7 @@ var g = class {
|
|
|
1281
1398
|
}
|
|
1282
1399
|
_createDragMove(e) {
|
|
1283
1400
|
let t = this._active, n = t.column.getBoundingClientRect(), r = t.startY - n.top, i = e.clientY - n.top;
|
|
1284
|
-
t.fromMinutes =
|
|
1401
|
+
t.fromMinutes = m(Math.min(r, i) / p), t.toMinutes = m(Math.max(r, i) / p), t.fromMinutes = Math.max(0, t.fromMinutes), t.toMinutes = Math.min(1440, Math.max(t.toMinutes, t.fromMinutes + f)), this._selectionEl || (this._selectionEl = this.container.ownerDocument.createElement("div"), this._selectionEl.className = "fc-drag-selection", t.column.appendChild(this._selectionEl)), this._selectionEl.style.top = `${t.fromMinutes * p}px`, this._selectionEl.style.height = `${(t.toMinutes - t.fromMinutes) * p}px`;
|
|
1285
1402
|
}
|
|
1286
1403
|
_createDrop() {
|
|
1287
1404
|
let e = this._active ?? {};
|
|
@@ -1305,7 +1422,7 @@ var g = class {
|
|
|
1305
1422
|
t.className = "fc-resize-handle", t.setAttribute("aria-hidden", "true"), e.appendChild(t);
|
|
1306
1423
|
}
|
|
1307
1424
|
}
|
|
1308
|
-
},
|
|
1425
|
+
}, v = class extends u {
|
|
1309
1426
|
constructor(e, t) {
|
|
1310
1427
|
super(e, t), this.maxEventsToShow = 3;
|
|
1311
1428
|
}
|
|
@@ -1438,7 +1555,7 @@ var g = class {
|
|
|
1438
1555
|
let e = new Date(t.dataset.date);
|
|
1439
1556
|
e.setDate(e.getDate() + (i - r)), this._pendingFocusMs = e.getTime(), i < 0 ? this.stateManager.previous() : this.stateManager.next();
|
|
1440
1557
|
}
|
|
1441
|
-
}), this.attachCommonEventHandlers(), new
|
|
1558
|
+
}), this.attachCommonEventHandlers(), new _(this).enableMonthMove();
|
|
1442
1559
|
}
|
|
1443
1560
|
_applyRovingTabindex(e = null) {
|
|
1444
1561
|
let t = Array.from(this.container.querySelectorAll(".fc-month-day"));
|
|
@@ -1448,7 +1565,7 @@ var g = class {
|
|
|
1448
1565
|
for (let e of t) e.setAttribute("tabindex", e === n ? "0" : "-1");
|
|
1449
1566
|
return n;
|
|
1450
1567
|
}
|
|
1451
|
-
},
|
|
1568
|
+
}, y = class extends u {
|
|
1452
1569
|
constructor(e, t) {
|
|
1453
1570
|
super(e, t), this.hourHeight = 60, this.totalHeight = 24 * this.hourHeight;
|
|
1454
1571
|
}
|
|
@@ -1573,14 +1690,14 @@ var g = class {
|
|
|
1573
1690
|
day: "numeric",
|
|
1574
1691
|
year: "numeric"
|
|
1575
1692
|
}).format(n)}`;
|
|
1576
|
-
this._enhanceTimeGridAccessibility(".fc-week-day-column", r), new
|
|
1693
|
+
this._enhanceTimeGridAccessibility(".fc-week-day-column", r), new _(this).enableTimeGrid(".fc-week-day-column");
|
|
1577
1694
|
}
|
|
1578
1695
|
_scrollToCurrentTime() {
|
|
1579
1696
|
if (this._scrolled) return;
|
|
1580
1697
|
let e = this.container.querySelector("#week-scroll-container");
|
|
1581
1698
|
e && (e.scrollTop = 8 * this.hourHeight - 50, this._scrolled = !0);
|
|
1582
1699
|
}
|
|
1583
|
-
},
|
|
1700
|
+
}, b = class extends u {
|
|
1584
1701
|
constructor(e, t) {
|
|
1585
1702
|
super(e, t), this.hourHeight = 60, this.totalHeight = 24 * this.hourHeight;
|
|
1586
1703
|
}
|
|
@@ -1717,14 +1834,14 @@ var g = class {
|
|
|
1717
1834
|
day: "numeric",
|
|
1718
1835
|
year: "numeric"
|
|
1719
1836
|
}).format(t);
|
|
1720
|
-
this._enhanceTimeGridAccessibility(".fc-day-column", n), new
|
|
1837
|
+
this._enhanceTimeGridAccessibility(".fc-day-column", n), new _(this).enableTimeGrid(".fc-day-column");
|
|
1721
1838
|
}
|
|
1722
1839
|
_scrollToCurrentTime() {
|
|
1723
1840
|
if (this._scrolled) return;
|
|
1724
1841
|
let e = this.container.querySelector("#day-scroll-container");
|
|
1725
1842
|
e && (e.scrollTop = 8 * this.hourHeight - 50, this._scrolled = !0);
|
|
1726
1843
|
}
|
|
1727
|
-
},
|
|
1844
|
+
}, x = class extends n {
|
|
1728
1845
|
constructor() {
|
|
1729
1846
|
super(), this._isVisible = !1, this._cleanupFocusTrap = null, this.config = {
|
|
1730
1847
|
title: "New Event",
|
|
@@ -1771,8 +1888,8 @@ var g = class {
|
|
|
1771
1888
|
}
|
|
1772
1889
|
getStyles() {
|
|
1773
1890
|
return `
|
|
1774
|
-
${
|
|
1775
|
-
${
|
|
1891
|
+
${l.getBaseStyles()}
|
|
1892
|
+
${l.getButtonStyles()}
|
|
1776
1893
|
|
|
1777
1894
|
:host {
|
|
1778
1895
|
display: none;
|
|
@@ -1979,7 +2096,7 @@ var g = class {
|
|
|
1979
2096
|
${this.config.colors.map((e) => `
|
|
1980
2097
|
<button type="button"
|
|
1981
2098
|
class="color-btn ${e.color === this._formData.color ? "selected" : ""}"
|
|
1982
|
-
style="background-color: ${
|
|
2099
|
+
style="background-color: ${l.sanitizeColor(e.color)}"
|
|
1983
2100
|
data-color="${s.escapeHTML(e.color)}"
|
|
1984
2101
|
title="${s.escapeHTML(e.label)}"
|
|
1985
2102
|
aria-label="${s.escapeHTML(e.label)}"
|
|
@@ -2044,14 +2161,14 @@ var g = class {
|
|
|
2044
2161
|
this._cleanupFocusTrap && this._cleanupFocusTrap(), this._handleKeyDown && (window.removeEventListener("keydown", this._handleKeyDown), this._handleKeyDown = null, this._keydownListenerAdded = !1);
|
|
2045
2162
|
}
|
|
2046
2163
|
};
|
|
2047
|
-
customElements.get("forcecal-event-form") || customElements.define("forcecal-event-form",
|
|
2164
|
+
customElements.get("forcecal-event-form") || customElements.define("forcecal-event-form", x);
|
|
2048
2165
|
//#endregion
|
|
2049
2166
|
//#region src/components/ForceCalendar.js
|
|
2050
|
-
var
|
|
2167
|
+
var S = class e extends n {
|
|
2051
2168
|
static RENDERERS = {
|
|
2052
|
-
month:
|
|
2053
|
-
week:
|
|
2054
|
-
day:
|
|
2169
|
+
month: v,
|
|
2170
|
+
week: y,
|
|
2171
|
+
day: b
|
|
2055
2172
|
};
|
|
2056
2173
|
static get observedAttributes() {
|
|
2057
2174
|
return [
|
|
@@ -2060,11 +2177,12 @@ var x = class e extends n {
|
|
|
2060
2177
|
"locale",
|
|
2061
2178
|
"timezone",
|
|
2062
2179
|
"week-starts-on",
|
|
2063
|
-
"height"
|
|
2180
|
+
"height",
|
|
2181
|
+
"theme"
|
|
2064
2182
|
];
|
|
2065
2183
|
}
|
|
2066
2184
|
constructor() {
|
|
2067
|
-
super(), this.stateManager = null, this.currentView = null, this._hasRendered = !1, this._busUnsubscribers = [];
|
|
2185
|
+
super(), this.stateManager = null, this.currentView = null, this._hasRendered = !1, this._busUnsubscribers = [], this._pendingEvents = null;
|
|
2068
2186
|
}
|
|
2069
2187
|
propChanged(e, t, n) {
|
|
2070
2188
|
if (!(!this.stateManager || t === n)) switch (e) {
|
|
@@ -2097,7 +2215,16 @@ var x = class e extends n {
|
|
|
2097
2215
|
timeZone: this.getAttribute("timezone") || Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
2098
2216
|
weekStartsOn: parseInt(this.getAttribute("week-starts-on") || "0")
|
|
2099
2217
|
};
|
|
2100
|
-
this.stateManager = new a(e), this._stateUnsubscribe = this.stateManager.subscribe(this.handleStateChange.bind(this)), this.setupEventListeners()
|
|
2218
|
+
if (this.stateManager = new a(e), this._stateUnsubscribe = this.stateManager.subscribe(this.handleStateChange.bind(this)), this.setupEventListeners(), this._upgradeProperty("events"), this._pendingEvents) {
|
|
2219
|
+
let e = this._pendingEvents;
|
|
2220
|
+
this._pendingEvents = null, this.stateManager.setEvents(e.events, e.options);
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
2223
|
+
_upgradeProperty(e) {
|
|
2224
|
+
if (Object.prototype.hasOwnProperty.call(this, e)) {
|
|
2225
|
+
let t = this[e];
|
|
2226
|
+
delete this[e], this[e] = t;
|
|
2227
|
+
}
|
|
2101
2228
|
}
|
|
2102
2229
|
setupEventListeners() {
|
|
2103
2230
|
this._busUnsubscribers.forEach((e) => e()), this._busUnsubscribers = [];
|
|
@@ -2125,6 +2252,10 @@ var x = class e extends n {
|
|
|
2125
2252
|
this.emit("calendar-event-updated", e);
|
|
2126
2253
|
})), this._busUnsubscribers.push(e.on("event:deleted", (e) => {
|
|
2127
2254
|
this.emit("calendar-event-deleted", e);
|
|
2255
|
+
})), this._busUnsubscribers.push(e.on("events:set", (e) => {
|
|
2256
|
+
this.emit("calendar-events-set", e);
|
|
2257
|
+
})), this._busUnsubscribers.push(e.on("range:changed", (e) => {
|
|
2258
|
+
this.emit("calendar-range-change", e);
|
|
2128
2259
|
})), this._busUnsubscribers.push(e.on("date:selected", (e) => {
|
|
2129
2260
|
this.emit("calendar-date-select", e);
|
|
2130
2261
|
}));
|
|
@@ -2161,7 +2292,7 @@ var x = class e extends n {
|
|
|
2161
2292
|
if (t) {
|
|
2162
2293
|
this._currentViewInstance && this._currentViewInstance.cleanup && this._currentViewInstance.cleanup();
|
|
2163
2294
|
try {
|
|
2164
|
-
let n = new (e.RENDERERS[this.currentView] ||
|
|
2295
|
+
let n = new (e.RENDERERS[this.currentView] || v)(t, this.stateManager);
|
|
2165
2296
|
n._viewType = this.currentView, this._currentViewInstance = n, n.render();
|
|
2166
2297
|
} catch (e) {
|
|
2167
2298
|
console.error("[ForceCalendar] Error switching view:", e);
|
|
@@ -2176,7 +2307,7 @@ var x = class e extends n {
|
|
|
2176
2307
|
t && (t.style.display = e ? "flex" : "none"), n && (n.style.display = e ? "none" : "flex");
|
|
2177
2308
|
}
|
|
2178
2309
|
mount() {
|
|
2179
|
-
this.currentView = this.stateManager.getView(), super.mount();
|
|
2310
|
+
(!this.stateManager || !this.stateManager.state) && this.initialize(), this._stateUnsubscribe || (this._stateUnsubscribe = this.stateManager.subscribe(this.handleStateChange.bind(this)), this.setupEventListeners()), this.currentView = this.stateManager.getView(), super.mount();
|
|
2180
2311
|
}
|
|
2181
2312
|
loadView(e) {
|
|
2182
2313
|
!e || this.currentView === e || (this.currentView = e, this._switchView(), this._updateViewButtons(), this._updateTitle());
|
|
@@ -2184,10 +2315,10 @@ var x = class e extends n {
|
|
|
2184
2315
|
getStyles() {
|
|
2185
2316
|
let e = this.getAttribute("height") || "800px";
|
|
2186
2317
|
return `
|
|
2187
|
-
${
|
|
2188
|
-
${
|
|
2189
|
-
${
|
|
2190
|
-
${
|
|
2318
|
+
${l.getBaseStyles()}
|
|
2319
|
+
${l.getButtonStyles()}
|
|
2320
|
+
${l.getGridStyles()}
|
|
2321
|
+
${l.getAnimations()}
|
|
2191
2322
|
|
|
2192
2323
|
:host {
|
|
2193
2324
|
--calendar-height: ${e};
|
|
@@ -2682,13 +2813,18 @@ var x = class e extends n {
|
|
|
2682
2813
|
renderView() {
|
|
2683
2814
|
return "<div id=\"calendar-view-container\"></div>";
|
|
2684
2815
|
}
|
|
2816
|
+
_applyTheme(e) {
|
|
2817
|
+
let t = c[e];
|
|
2818
|
+
for (let e of Object.keys(c.slds)) t && t[e] ? this.style.setProperty(e, t[e]) : this.style.removeProperty(e);
|
|
2819
|
+
}
|
|
2685
2820
|
afterRender() {
|
|
2821
|
+
this._applyTheme(this.getAttribute("theme"));
|
|
2686
2822
|
let t = this.$("#calendar-view-container");
|
|
2687
2823
|
if (t && this.stateManager && this.currentView) {
|
|
2688
2824
|
if (this._currentViewInstance && this._currentViewInstance._viewType === this.currentView && t.children.length > 0) return;
|
|
2689
2825
|
this._currentViewInstance && (this._currentViewInstance.cleanup && this._currentViewInstance.cleanup(), this._viewUnsubscribe &&= (this._viewUnsubscribe(), null));
|
|
2690
2826
|
try {
|
|
2691
|
-
let n = new (e.RENDERERS[this.currentView] ||
|
|
2827
|
+
let n = new (e.RENDERERS[this.currentView] || v)(t, this.stateManager);
|
|
2692
2828
|
n._viewType = this.currentView, this._currentViewInstance = n, n.render();
|
|
2693
2829
|
} catch (e) {
|
|
2694
2830
|
console.error("[ForceCalendar] Error creating/rendering view:", e);
|
|
@@ -2712,7 +2848,16 @@ var x = class e extends n {
|
|
|
2712
2848
|
id: n,
|
|
2713
2849
|
...t
|
|
2714
2850
|
});
|
|
2715
|
-
})
|
|
2851
|
+
});
|
|
2852
|
+
let i = !this._hasRendered;
|
|
2853
|
+
if (this._hasRendered = !0, i && this.stateManager) {
|
|
2854
|
+
let e = this.stateManager.getState();
|
|
2855
|
+
this.emit("calendar-range-change", {
|
|
2856
|
+
...this.stateManager.getVisibleRange(),
|
|
2857
|
+
view: e.view,
|
|
2858
|
+
date: e.currentDate
|
|
2859
|
+
});
|
|
2860
|
+
}
|
|
2716
2861
|
}
|
|
2717
2862
|
handleNavigation(e) {
|
|
2718
2863
|
switch (e.currentTarget.dataset.action) {
|
|
@@ -2762,6 +2907,21 @@ var x = class e extends n {
|
|
|
2762
2907
|
getEvents() {
|
|
2763
2908
|
return this.stateManager.getEvents();
|
|
2764
2909
|
}
|
|
2910
|
+
setEvents(e, t = {}) {
|
|
2911
|
+
return this.stateManager ? this.stateManager.setEvents(e, t) : (this._pendingEvents = {
|
|
2912
|
+
events: e ? Array.from(e) : [],
|
|
2913
|
+
options: t
|
|
2914
|
+
}, null);
|
|
2915
|
+
}
|
|
2916
|
+
get events() {
|
|
2917
|
+
return this.stateManager ? this.stateManager.getEvents() : this._pendingEvents ? this._pendingEvents.events : [];
|
|
2918
|
+
}
|
|
2919
|
+
set events(e) {
|
|
2920
|
+
this.setEvents(e);
|
|
2921
|
+
}
|
|
2922
|
+
getVisibleRange() {
|
|
2923
|
+
return this.stateManager ? this.stateManager.getVisibleRange() : null;
|
|
2924
|
+
}
|
|
2765
2925
|
setView(e) {
|
|
2766
2926
|
this.stateManager.setView(e);
|
|
2767
2927
|
}
|
|
@@ -2778,14 +2938,17 @@ var x = class e extends n {
|
|
|
2778
2938
|
this.stateManager.today();
|
|
2779
2939
|
}
|
|
2780
2940
|
unmount() {
|
|
2781
|
-
this.
|
|
2941
|
+
this._releaseBindings();
|
|
2782
2942
|
}
|
|
2783
2943
|
destroy() {
|
|
2784
|
-
this.
|
|
2944
|
+
this._releaseBindings(), this.stateManager && this.stateManager.destroy();
|
|
2945
|
+
}
|
|
2946
|
+
_releaseBindings() {
|
|
2947
|
+
this._busUnsubscribers.forEach((e) => e()), this._busUnsubscribers = [], this._stateUnsubscribe &&= (this._stateUnsubscribe(), null), this._currentViewInstance && this._currentViewInstance.cleanup && this._currentViewInstance.cleanup(), this._currentViewInstance = null, this._hasRendered = !1, super.cleanup();
|
|
2785
2948
|
}
|
|
2786
2949
|
};
|
|
2787
|
-
customElements.get("forcecal-main") || customElements.define("forcecal-main",
|
|
2950
|
+
customElements.get("forcecal-main") || customElements.define("forcecal-main", S);
|
|
2788
2951
|
//#endregion
|
|
2789
|
-
export { n as BaseComponent,
|
|
2952
|
+
export { n as BaseComponent, u as BaseViewRenderer, s as DOMUtils, o as DateUtils, b as DayViewRenderer, r as EventBus, x as EventForm, S as ForceCalendar, v as MonthViewRenderer, a as StateManager, l as StyleUtils, y as WeekViewRenderer, i as eventBus };
|
|
2790
2953
|
|
|
2791
2954
|
//# sourceMappingURL=force-calendar-interface.esm.js.map
|