@forcecalendar/interface 1.0.27 → 1.0.29
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 +9 -0
- package/dist/force-calendar-interface.esm.js +102 -55
- package/dist/force-calendar-interface.esm.js.map +1 -1
- package/dist/force-calendar-interface.umd.js.map +1 -1
- package/package.json +3 -1
- package/src/components/EventForm.js +180 -176
- package/src/components/ForceCalendar.js +416 -394
- package/src/core/BaseComponent.js +146 -144
- package/src/core/EventBus.js +197 -197
- package/src/core/StateManager.js +405 -399
- package/src/index.js +3 -3
- package/src/renderers/BaseViewRenderer.js +195 -193
- package/src/renderers/DayViewRenderer.js +133 -118
- package/src/renderers/MonthViewRenderer.js +74 -72
- package/src/renderers/WeekViewRenderer.js +118 -96
- package/src/utils/DOMUtils.js +277 -277
- package/src/utils/DateUtils.js +164 -164
- package/src/utils/StyleUtils.js +286 -249
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# @forcecalendar/interface
|
|
2
|
+
|
|
3
|
+
[](https://github.com/forceCalendar/interface/actions/workflows/test.yml)
|
|
4
|
+
[](https://github.com/forceCalendar/interface/actions/workflows/code-quality.yml)
|
|
5
|
+
[](https://www.npmjs.com/package/@forcecalendar/interface)
|
|
6
|
+
[](https://www.npmjs.com/package/@forcecalendar/interface)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
|
|
9
|
+
Official interface layer for forceCalendar Core — enterprise calendar components for Salesforce and the web.
|
|
@@ -55,11 +55,13 @@ class O extends HTMLElement {
|
|
|
55
55
|
e.addEventListener(t, i), this._listeners.push({ element: e, event: t, handler: i });
|
|
56
56
|
}
|
|
57
57
|
emit(e, t = {}) {
|
|
58
|
-
this.dispatchEvent(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
this.dispatchEvent(
|
|
59
|
+
new CustomEvent(e, {
|
|
60
|
+
detail: t,
|
|
61
|
+
bubbles: !0,
|
|
62
|
+
composed: !0
|
|
63
|
+
})
|
|
64
|
+
);
|
|
63
65
|
}
|
|
64
66
|
// Style management
|
|
65
67
|
getStyles() {
|
|
@@ -5227,9 +5229,7 @@ class ie {
|
|
|
5227
5229
|
});
|
|
5228
5230
|
}
|
|
5229
5231
|
emitStateChange(e, t) {
|
|
5230
|
-
const s = Object.keys(t).filter(
|
|
5231
|
-
(i) => e[i] !== t[i]
|
|
5232
|
-
);
|
|
5232
|
+
const s = Object.keys(t).filter((i) => e[i] !== t[i]);
|
|
5233
5233
|
s.forEach((i) => {
|
|
5234
5234
|
u.emit(`state:${i}:changed`, {
|
|
5235
5235
|
oldValue: e[i],
|
|
@@ -5272,7 +5272,12 @@ class ie {
|
|
|
5272
5272
|
updateEvent(e, t) {
|
|
5273
5273
|
this._syncEventsFromCore({ silent: !0 });
|
|
5274
5274
|
const s = this.calendar.updateEvent(e, t);
|
|
5275
|
-
return s ? (this._syncEventsFromCore(), u.emit("event:update", { event: s }), u.emit("event:updated", { event: s }), s) : (console.error(`Failed to update event: ${e}`), u.emit("event:error", {
|
|
5275
|
+
return s ? (this._syncEventsFromCore(), u.emit("event:update", { event: s }), u.emit("event:updated", { event: s }), s) : (console.error(`Failed to update event: ${e}`), u.emit("event:error", {
|
|
5276
|
+
action: "update",
|
|
5277
|
+
eventId: e,
|
|
5278
|
+
updates: t,
|
|
5279
|
+
error: "Event not found in calendar"
|
|
5280
|
+
}), null);
|
|
5276
5281
|
}
|
|
5277
5282
|
deleteEvent(e) {
|
|
5278
5283
|
return this._syncEventsFromCore({ silent: !0 }), this.calendar.removeEvent(e) ? (this._syncEventsFromCore(), u.emit("event:remove", { eventId: e }), u.emit("event:deleted", { eventId: e }), !0) : (console.error(`Failed to delete event: ${e}`), u.emit("event:error", { action: "delete", eventId: e, error: "Event not found" }), !1);
|
|
@@ -5487,7 +5492,7 @@ class E extends f {
|
|
|
5487
5492
|
return r && (r.toLowerCase() === "pm" && n < 12 ? o = n + 12 : r.toLowerCase() === "am" && n === 12 && (o = 0)), s.setHours(o, a || 0, 0, 0), s;
|
|
5488
5493
|
}
|
|
5489
5494
|
}
|
|
5490
|
-
class
|
|
5495
|
+
class H {
|
|
5491
5496
|
/**
|
|
5492
5497
|
* Create element with attributes and children
|
|
5493
5498
|
*/
|
|
@@ -6128,7 +6133,7 @@ I(D, "breakpoints", {
|
|
|
6128
6133
|
xl: "1200px",
|
|
6129
6134
|
"2xl": "1400px"
|
|
6130
6135
|
});
|
|
6131
|
-
class
|
|
6136
|
+
class F {
|
|
6132
6137
|
/**
|
|
6133
6138
|
* @param {HTMLElement} container - The DOM element to render into
|
|
6134
6139
|
* @param {StateManager} stateManager - The state manager instance
|
|
@@ -6167,7 +6172,7 @@ class H {
|
|
|
6167
6172
|
* @returns {string}
|
|
6168
6173
|
*/
|
|
6169
6174
|
escapeHTML(e) {
|
|
6170
|
-
return e == null ? "" :
|
|
6175
|
+
return e == null ? "" : H.escapeHTML(String(e));
|
|
6171
6176
|
}
|
|
6172
6177
|
/**
|
|
6173
6178
|
* Check if a date is today
|
|
@@ -6277,7 +6282,7 @@ class H {
|
|
|
6277
6282
|
});
|
|
6278
6283
|
}
|
|
6279
6284
|
}
|
|
6280
|
-
class S extends
|
|
6285
|
+
class S extends F {
|
|
6281
6286
|
constructor(e, t) {
|
|
6282
6287
|
super(e, t), this.maxEventsToShow = 3;
|
|
6283
6288
|
}
|
|
@@ -6352,7 +6357,7 @@ class S extends H {
|
|
|
6352
6357
|
}), this.attachCommonEventHandlers();
|
|
6353
6358
|
}
|
|
6354
6359
|
}
|
|
6355
|
-
class z extends
|
|
6360
|
+
class z extends F {
|
|
6356
6361
|
constructor(e, t) {
|
|
6357
6362
|
super(e, t), this.hourHeight = 60, this.totalHeight = 24 * this.hourHeight;
|
|
6358
6363
|
}
|
|
@@ -6392,7 +6397,8 @@ class z extends H {
|
|
|
6392
6397
|
return `
|
|
6393
6398
|
<div class="fc-week-header" style="display: grid; grid-template-columns: 60px repeat(7, 1fr); border-bottom: 1px solid #e5e7eb; background: #f9fafb; flex-shrink: 0;">
|
|
6394
6399
|
<div style="border-right: 1px solid #e5e7eb;"></div>
|
|
6395
|
-
${e.map(
|
|
6400
|
+
${e.map(
|
|
6401
|
+
(t) => `
|
|
6396
6402
|
<div style="padding: 12px 8px; text-align: center; border-right: 1px solid #e5e7eb;">
|
|
6397
6403
|
<div style="font-size: 10px; font-weight: 700; color: #6b7280; text-transform: uppercase; letter-spacing: 0.1em;">
|
|
6398
6404
|
${t.dayName}
|
|
@@ -6401,7 +6407,8 @@ class z extends H {
|
|
|
6401
6407
|
${t.dayOfMonth}
|
|
6402
6408
|
</div>
|
|
6403
6409
|
</div>
|
|
6404
|
-
`
|
|
6410
|
+
`
|
|
6411
|
+
).join("")}
|
|
6405
6412
|
</div>
|
|
6406
6413
|
`;
|
|
6407
6414
|
}
|
|
@@ -6411,16 +6418,20 @@ class z extends H {
|
|
|
6411
6418
|
<div style="font-size: 9px; color: #6b7280; display: flex; align-items: center; justify-content: center; border-right: 1px solid #e5e7eb; text-transform: uppercase; font-weight: 700;">
|
|
6412
6419
|
All day
|
|
6413
6420
|
</div>
|
|
6414
|
-
${e.map(
|
|
6421
|
+
${e.map(
|
|
6422
|
+
(t) => `
|
|
6415
6423
|
<div class="fc-all-day-cell" data-date="${t.date.toISOString()}" style="border-right: 1px solid #e5e7eb; padding: 4px; display: flex; flex-direction: column; gap: 2px;">
|
|
6416
|
-
${t.allDayEvents.map(
|
|
6424
|
+
${t.allDayEvents.map(
|
|
6425
|
+
(s) => `
|
|
6417
6426
|
<div class="fc-event fc-all-day-event" data-event-id="${this.escapeHTML(s.id)}"
|
|
6418
6427
|
style="background-color: ${this.getEventColor(s)}; font-size: 10px; padding: 2px 4px; border-radius: 2px; color: white; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
|
|
6419
6428
|
${this.escapeHTML(s.title)}
|
|
6420
6429
|
</div>
|
|
6421
|
-
`
|
|
6430
|
+
`
|
|
6431
|
+
).join("")}
|
|
6422
6432
|
</div>
|
|
6423
|
-
`
|
|
6433
|
+
`
|
|
6434
|
+
).join("")}
|
|
6424
6435
|
</div>
|
|
6425
6436
|
`;
|
|
6426
6437
|
}
|
|
@@ -6437,11 +6448,13 @@ class z extends H {
|
|
|
6437
6448
|
_renderTimeGutter(e) {
|
|
6438
6449
|
return `
|
|
6439
6450
|
<div class="fc-time-gutter" style="border-right: 1px solid #e5e7eb; background: #fafafa;">
|
|
6440
|
-
${e.map(
|
|
6451
|
+
${e.map(
|
|
6452
|
+
(t) => `
|
|
6441
6453
|
<div style="height: ${this.hourHeight}px; font-size: 10px; color: #6b7280; text-align: right; padding-right: 8px; font-weight: 500;">
|
|
6442
6454
|
${t === 0 ? "" : this.formatHour(t)}
|
|
6443
6455
|
</div>
|
|
6444
|
-
`
|
|
6456
|
+
`
|
|
6457
|
+
).join("")}
|
|
6445
6458
|
</div>
|
|
6446
6459
|
`;
|
|
6447
6460
|
}
|
|
@@ -6464,7 +6477,12 @@ class z extends H {
|
|
|
6464
6477
|
const t = e.target.closest(".fc-week-day-column");
|
|
6465
6478
|
if (!t || !this.container.contains(t) || e.target.closest(".fc-event")) return;
|
|
6466
6479
|
const s = new Date(t.dataset.date), i = t.getBoundingClientRect(), r = this.container.querySelector("#week-scroll-container"), n = e.clientY - i.top + (r ? r.scrollTop : 0);
|
|
6467
|
-
s.setHours(
|
|
6480
|
+
s.setHours(
|
|
6481
|
+
Math.floor(n / this.hourHeight),
|
|
6482
|
+
Math.floor(n % this.hourHeight / (this.hourHeight / 60)),
|
|
6483
|
+
0,
|
|
6484
|
+
0
|
|
6485
|
+
), this.stateManager.selectDate(s);
|
|
6468
6486
|
}), this.attachCommonEventHandlers();
|
|
6469
6487
|
}
|
|
6470
6488
|
_scrollToCurrentTime() {
|
|
@@ -6473,7 +6491,7 @@ class z extends H {
|
|
|
6473
6491
|
e && (e.scrollTop = 8 * this.hourHeight - 50, this._scrolled = !0);
|
|
6474
6492
|
}
|
|
6475
6493
|
}
|
|
6476
|
-
class L extends
|
|
6494
|
+
class L extends F {
|
|
6477
6495
|
constructor(e, t) {
|
|
6478
6496
|
super(e, t), this.hourHeight = 60, this.totalHeight = 24 * this.hourHeight;
|
|
6479
6497
|
}
|
|
@@ -6546,12 +6564,14 @@ class L extends H {
|
|
|
6546
6564
|
All day
|
|
6547
6565
|
</div>
|
|
6548
6566
|
<div class="fc-all-day-cell" data-date="${t.toISOString()}" style="padding: 6px 12px; display: flex; flex-wrap: wrap; gap: 4px;">
|
|
6549
|
-
${e.map(
|
|
6567
|
+
${e.map(
|
|
6568
|
+
(s) => `
|
|
6550
6569
|
<div class="fc-event fc-all-day-event" data-event-id="${this.escapeHTML(s.id)}"
|
|
6551
6570
|
style="background-color: ${this.getEventColor(s)}; font-size: 12px; padding: 4px 8px; border-radius: 4px; color: white; cursor: pointer; font-weight: 500;">
|
|
6552
6571
|
${this.escapeHTML(s.title)}
|
|
6553
6572
|
</div>
|
|
6554
|
-
`
|
|
6573
|
+
`
|
|
6574
|
+
).join("")}
|
|
6555
6575
|
</div>
|
|
6556
6576
|
</div>
|
|
6557
6577
|
`;
|
|
@@ -6569,11 +6589,13 @@ class L extends H {
|
|
|
6569
6589
|
_renderTimeGutter(e) {
|
|
6570
6590
|
return `
|
|
6571
6591
|
<div class="fc-time-gutter" style="border-right: 1px solid #e5e7eb; background: #fafafa;">
|
|
6572
|
-
${e.map(
|
|
6592
|
+
${e.map(
|
|
6593
|
+
(t) => `
|
|
6573
6594
|
<div style="height: ${this.hourHeight}px; font-size: 11px; color: #6b7280; text-align: right; padding-right: 12px; font-weight: 500;">
|
|
6574
6595
|
${t === 0 ? "" : this.formatHour(t)}
|
|
6575
6596
|
</div>
|
|
6576
|
-
`
|
|
6597
|
+
`
|
|
6598
|
+
).join("")}
|
|
6577
6599
|
</div>
|
|
6578
6600
|
`;
|
|
6579
6601
|
}
|
|
@@ -6596,7 +6618,12 @@ class L extends H {
|
|
|
6596
6618
|
const t = e.target.closest(".fc-day-column");
|
|
6597
6619
|
if (!t || !this.container.contains(t) || e.target.closest(".fc-event")) return;
|
|
6598
6620
|
const s = new Date(t.dataset.date), i = t.getBoundingClientRect(), r = this.container.querySelector("#day-scroll-container"), n = e.clientY - i.top + (r ? r.scrollTop : 0);
|
|
6599
|
-
s.setHours(
|
|
6621
|
+
s.setHours(
|
|
6622
|
+
Math.floor(n / this.hourHeight),
|
|
6623
|
+
Math.floor(n % this.hourHeight / (this.hourHeight / 60)),
|
|
6624
|
+
0,
|
|
6625
|
+
0
|
|
6626
|
+
), this.stateManager.selectDate(s);
|
|
6600
6627
|
}), this.attachCommonEventHandlers();
|
|
6601
6628
|
}
|
|
6602
6629
|
_scrollToCurrentTime() {
|
|
@@ -6840,7 +6867,8 @@ class re extends O {
|
|
|
6840
6867
|
<div class="form-group">
|
|
6841
6868
|
<label id="color-label">Color</label>
|
|
6842
6869
|
<div class="color-options" id="color-picker" role="radiogroup" aria-labelledby="color-label">
|
|
6843
|
-
${this.config.colors.map(
|
|
6870
|
+
${this.config.colors.map(
|
|
6871
|
+
(e) => `
|
|
6844
6872
|
<button type="button"
|
|
6845
6873
|
class="color-btn ${e.color === this._formData.color ? "selected" : ""}"
|
|
6846
6874
|
style="background-color: ${e.color}"
|
|
@@ -6849,7 +6877,8 @@ class re extends O {
|
|
|
6849
6877
|
aria-label="${e.label}"
|
|
6850
6878
|
aria-checked="${e.color === this._formData.color ? "true" : "false"}"
|
|
6851
6879
|
role="radio"></button>
|
|
6852
|
-
`
|
|
6880
|
+
`
|
|
6881
|
+
).join("")}
|
|
6853
6882
|
</div>
|
|
6854
6883
|
</div>
|
|
6855
6884
|
</div>
|
|
@@ -6879,7 +6908,7 @@ class re extends O {
|
|
|
6879
6908
|
});
|
|
6880
6909
|
}
|
|
6881
6910
|
open(e = /* @__PURE__ */ new Date()) {
|
|
6882
|
-
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 =
|
|
6911
|
+
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 = H.trapFocus(this.modalContent));
|
|
6883
6912
|
}
|
|
6884
6913
|
close() {
|
|
6885
6914
|
this.removeAttribute("open"), this._cleanupFocusTrap && (this._cleanupFocusTrap(), this._cleanupFocusTrap = null);
|
|
@@ -6927,29 +6956,47 @@ class ne extends O {
|
|
|
6927
6956
|
this.stateManager = new ie(e), this.stateManager.subscribe(this.handleStateChange.bind(this)), this.setupEventListeners();
|
|
6928
6957
|
}
|
|
6929
6958
|
setupEventListeners() {
|
|
6930
|
-
this._busUnsubscribers.forEach((t) => t()), this._busUnsubscribers = [], this._busUnsubscribers.push(
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
6934
|
-
|
|
6959
|
+
this._busUnsubscribers.forEach((t) => t()), this._busUnsubscribers = [], this._busUnsubscribers.push(
|
|
6960
|
+
u.on("navigation:*", (t, s) => {
|
|
6961
|
+
this.emit("calendar-navigate", { action: s.split(":")[1], ...t });
|
|
6962
|
+
})
|
|
6963
|
+
), this._busUnsubscribers.push(
|
|
6964
|
+
u.on("view:changed", (t) => {
|
|
6965
|
+
this.emit("calendar-view-change", t);
|
|
6966
|
+
})
|
|
6967
|
+
);
|
|
6935
6968
|
const e = (t, s) => {
|
|
6936
6969
|
this.emit(`calendar-event-${t}`, s);
|
|
6937
6970
|
};
|
|
6938
|
-
this._busUnsubscribers.push(
|
|
6939
|
-
|
|
6940
|
-
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
|
|
6946
|
-
|
|
6947
|
-
|
|
6948
|
-
|
|
6949
|
-
|
|
6950
|
-
|
|
6951
|
-
|
|
6952
|
-
|
|
6971
|
+
this._busUnsubscribers.push(
|
|
6972
|
+
u.on("event:add", (t) => {
|
|
6973
|
+
e("add", t);
|
|
6974
|
+
})
|
|
6975
|
+
), this._busUnsubscribers.push(
|
|
6976
|
+
u.on("event:update", (t) => {
|
|
6977
|
+
e("update", t);
|
|
6978
|
+
})
|
|
6979
|
+
), this._busUnsubscribers.push(
|
|
6980
|
+
u.on("event:remove", (t) => {
|
|
6981
|
+
e("remove", t);
|
|
6982
|
+
})
|
|
6983
|
+
), this._busUnsubscribers.push(
|
|
6984
|
+
u.on("event:added", (t) => {
|
|
6985
|
+
e("add", t), this.emit("calendar-event-added", t);
|
|
6986
|
+
})
|
|
6987
|
+
), this._busUnsubscribers.push(
|
|
6988
|
+
u.on("event:updated", (t) => {
|
|
6989
|
+
e("update", t), this.emit("calendar-event-updated", t);
|
|
6990
|
+
})
|
|
6991
|
+
), this._busUnsubscribers.push(
|
|
6992
|
+
u.on("event:deleted", (t) => {
|
|
6993
|
+
e("remove", t), this.emit("calendar-event-deleted", t);
|
|
6994
|
+
})
|
|
6995
|
+
), this._busUnsubscribers.push(
|
|
6996
|
+
u.on("date:selected", (t) => {
|
|
6997
|
+
this.emit("calendar-date-select", t);
|
|
6998
|
+
})
|
|
6999
|
+
);
|
|
6953
7000
|
}
|
|
6954
7001
|
handleStateChange(e, t) {
|
|
6955
7002
|
var o, c;
|
|
@@ -7419,7 +7466,7 @@ class ne extends O {
|
|
|
7419
7466
|
return `
|
|
7420
7467
|
<div class="force-calendar">
|
|
7421
7468
|
<div class="fc-error">
|
|
7422
|
-
<p><strong>Error:</strong> ${
|
|
7469
|
+
<p><strong>Error:</strong> ${H.escapeHTML(r.message || "An error occurred")}</p>
|
|
7423
7470
|
</div>
|
|
7424
7471
|
</div>
|
|
7425
7472
|
`;
|
|
@@ -7610,8 +7657,8 @@ customElements.get("forcecal-main") || customElements.define("forcecal-main", ne
|
|
|
7610
7657
|
typeof window < "u" && typeof customElements < "u" && console.log("Force Calendar Interface loading...");
|
|
7611
7658
|
export {
|
|
7612
7659
|
O as BaseComponent,
|
|
7613
|
-
|
|
7614
|
-
|
|
7660
|
+
F as BaseViewRenderer,
|
|
7661
|
+
H as DOMUtils,
|
|
7615
7662
|
E as DateUtils,
|
|
7616
7663
|
L as DayViewRenderer,
|
|
7617
7664
|
se as EventBus,
|