@forcecalendar/interface 1.4.0 → 1.5.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.
@@ -677,7 +677,26 @@ var n = class extends HTMLElement {
677
677
  };
678
678
  return e.addEventListener("keydown", i), n?.focus(), () => e.removeEventListener("keydown", i);
679
679
  }
680
- }, c = class {
680
+ }, c = { slds: {
681
+ "--fc-primary-color": "#0176d3",
682
+ "--fc-primary-hover": "#014486",
683
+ "--fc-primary-light": "#eef4ff",
684
+ "--fc-accent-color": "#0b5cab",
685
+ "--fc-text-color": "#181818",
686
+ "--fc-text-secondary": "#706e6b",
687
+ "--fc-text-light": "#939393",
688
+ "--fc-border-color": "#e5e5e5",
689
+ "--fc-border-color-hover": "#c9c9c9",
690
+ "--fc-background": "#ffffff",
691
+ "--fc-background-alt": "#f3f3f3",
692
+ "--fc-background-hover": "#f3f3f3",
693
+ "--fc-background-active": "#d8e6fe",
694
+ "--fc-danger-color": "#ea001e",
695
+ "--fc-success-color": "#2e844a",
696
+ "--fc-border-radius": "0.25rem",
697
+ "--fc-border-radius-sm": "0.125rem",
698
+ "--fc-font-family": "'Salesforce Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"
699
+ } }, l = class {
681
700
  static colors = {
682
701
  primary: "#3B82F6",
683
702
  secondary: "#64748B",
@@ -882,7 +901,7 @@ var n = class extends HTMLElement {
882
901
  static getAnimations() {
883
902
  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
903
  }
885
- }, l = class {
904
+ }, u = class {
886
905
  constructor(e, t) {
887
906
  this.container = e, this.stateManager = t, this._listeners = [], this._scrolled = !1, this._nowIndicatorTimer = null;
888
907
  }
@@ -921,7 +940,7 @@ var n = class extends HTMLElement {
921
940
  return n === 0 ? `${i} ${r}` : `${i}:${n.toString().padStart(2, "0")} ${r}`;
922
941
  }
923
942
  getContrastingTextColor(e) {
924
- return !e || typeof e != "string" || e.charAt(0) !== "#" ? "white" : c.getContrastColor(e);
943
+ return !e || typeof e != "string" || e.charAt(0) !== "#" ? "white" : l.getContrastColor(e);
925
944
  }
926
945
  renderNowIndicator() {
927
946
  let e = /* @__PURE__ */ new Date();
@@ -996,7 +1015,7 @@ var n = class extends HTMLElement {
996
1015
  `;
997
1016
  }
998
1017
  getEventColor(e) {
999
- return c.sanitizeColor(e?.backgroundColor, "#2563eb");
1018
+ return l.sanitizeColor(e?.backgroundColor, "#2563eb");
1000
1019
  }
1001
1020
  attachCommonEventHandlers() {
1002
1021
  this.addListener(this.container, "click", (e) => {
@@ -1099,18 +1118,18 @@ var n = class extends HTMLElement {
1099
1118
  t && e.setAttribute("aria-label", `Event: ${t}`);
1100
1119
  }
1101
1120
  }
1102
- }, u = 4, d = 15, f = 1;
1103
- function p(e, t = d) {
1121
+ }, d = 4, f = 15, p = 1;
1122
+ function m(e, t = f) {
1104
1123
  return Math.round(e / t) * t;
1105
1124
  }
1106
- function m(e, t) {
1125
+ function h(e, t) {
1107
1126
  return Math.max(0, Math.min(e, 1440 - t));
1108
1127
  }
1109
- function h(e, t) {
1128
+ function g(e, t) {
1110
1129
  let n = new Date(e);
1111
1130
  return n.setHours(t.getHours(), t.getMinutes(), t.getSeconds(), t.getMilliseconds()), n;
1112
1131
  }
1113
- var g = class {
1132
+ var _ = class {
1114
1133
  constructor(e) {
1115
1134
  this.renderer = e, this.container = e.container, this.stateManager = e.stateManager, this._active = null, this._docListeners = [];
1116
1135
  }
@@ -1188,7 +1207,7 @@ var g = class {
1188
1207
  let t = this._active;
1189
1208
  if (t) {
1190
1209
  if (!t.dragging) {
1191
- if (Math.abs(e.clientX - t.startX) < u && Math.abs(e.clientY - t.startY) < u) return;
1210
+ if (Math.abs(e.clientX - t.startX) < d && Math.abs(e.clientY - t.startY) < d) return;
1192
1211
  t.dragging = !0, t.eventEl && t.eventEl.classList.add("fc-dragging");
1193
1212
  }
1194
1213
  e.preventDefault(), t.onDragMove(e);
@@ -1239,7 +1258,7 @@ var g = class {
1239
1258
  if (!t) return;
1240
1259
  let n = this.stateManager.getEvents().find((t) => t.id === e.eventId);
1241
1260
  if (!n) return;
1242
- let r = new Date(n.start), i = h(new Date(t.dataset.date), r), a = i.getTime() - r.getTime();
1261
+ let r = new Date(n.start), i = g(new Date(t.dataset.date), r), a = i.getTime() - r.getTime();
1243
1262
  a !== 0 && this.stateManager.updateEvent(e.eventId, {
1244
1263
  start: i,
1245
1264
  end: new Date(new Date(n.end).getTime() + a)
@@ -1254,22 +1273,22 @@ var g = class {
1254
1273
  }
1255
1274
  _timeMoveDragMove(e) {
1256
1275
  let t = this._active, n = this._columnAtPoint(e.clientX) || t.originColumn;
1257
- t.dropColumn = n, t.deltaMinutes = p((e.clientY - t.startY) / f);
1276
+ t.dropColumn = n, t.deltaMinutes = m((e.clientY - t.startY) / p);
1258
1277
  let r = t.originColumn.getBoundingClientRect(), i = n.getBoundingClientRect();
1259
- t.eventEl.style.transform = `translate(${i.left - r.left}px, ${t.deltaMinutes * f}px)`;
1278
+ t.eventEl.style.transform = `translate(${i.left - r.left}px, ${t.deltaMinutes * p}px)`;
1260
1279
  }
1261
1280
  _timeMoveDrop() {
1262
1281
  let e = this._active ?? {}, t = this.stateManager.getEvents().find((t) => t.id === e.eventId);
1263
1282
  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 = h(e.dropColumn ? new Date(e.dropColumn.dataset.date) : n, n), a = m(i.getHours() * 60 + i.getMinutes() + (e.deltaMinutes || 0), Math.round(r / 6e4)), o = new Date(i);
1283
+ 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
1284
  o.setHours(Math.floor(a / 60), a % 60, 0, 0), o.getTime() !== n.getTime() && this.stateManager.updateEvent(e.eventId, {
1266
1285
  start: o,
1267
1286
  end: new Date(o.getTime() + r)
1268
1287
  });
1269
1288
  }
1270
1289
  _resizeDragMove(e) {
1271
- let t = this._active, n = p((e.clientY - t.startY) / f);
1272
- t.newHeight = Math.max(d, t.originHeight + n), t.newHeight = Math.min(t.newHeight, 1440 - t.originTop), t.eventEl.style.height = `${t.newHeight}px`;
1290
+ let t = this._active, n = m((e.clientY - t.startY) / p);
1291
+ 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
1292
  }
1274
1293
  _resizeDrop() {
1275
1294
  let e = this._active ?? {};
@@ -1281,7 +1300,7 @@ var g = class {
1281
1300
  }
1282
1301
  _createDragMove(e) {
1283
1302
  let t = this._active, n = t.column.getBoundingClientRect(), r = t.startY - n.top, i = e.clientY - n.top;
1284
- t.fromMinutes = p(Math.min(r, i) / f), t.toMinutes = p(Math.max(r, i) / f), t.fromMinutes = Math.max(0, t.fromMinutes), t.toMinutes = Math.min(1440, Math.max(t.toMinutes, t.fromMinutes + d)), 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 * f}px`, this._selectionEl.style.height = `${(t.toMinutes - t.fromMinutes) * f}px`;
1303
+ 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
1304
  }
1286
1305
  _createDrop() {
1287
1306
  let e = this._active ?? {};
@@ -1305,7 +1324,7 @@ var g = class {
1305
1324
  t.className = "fc-resize-handle", t.setAttribute("aria-hidden", "true"), e.appendChild(t);
1306
1325
  }
1307
1326
  }
1308
- }, _ = class extends l {
1327
+ }, v = class extends u {
1309
1328
  constructor(e, t) {
1310
1329
  super(e, t), this.maxEventsToShow = 3;
1311
1330
  }
@@ -1438,7 +1457,7 @@ var g = class {
1438
1457
  let e = new Date(t.dataset.date);
1439
1458
  e.setDate(e.getDate() + (i - r)), this._pendingFocusMs = e.getTime(), i < 0 ? this.stateManager.previous() : this.stateManager.next();
1440
1459
  }
1441
- }), this.attachCommonEventHandlers(), new g(this).enableMonthMove();
1460
+ }), this.attachCommonEventHandlers(), new _(this).enableMonthMove();
1442
1461
  }
1443
1462
  _applyRovingTabindex(e = null) {
1444
1463
  let t = Array.from(this.container.querySelectorAll(".fc-month-day"));
@@ -1448,7 +1467,7 @@ var g = class {
1448
1467
  for (let e of t) e.setAttribute("tabindex", e === n ? "0" : "-1");
1449
1468
  return n;
1450
1469
  }
1451
- }, v = class extends l {
1470
+ }, y = class extends u {
1452
1471
  constructor(e, t) {
1453
1472
  super(e, t), this.hourHeight = 60, this.totalHeight = 24 * this.hourHeight;
1454
1473
  }
@@ -1573,14 +1592,14 @@ var g = class {
1573
1592
  day: "numeric",
1574
1593
  year: "numeric"
1575
1594
  }).format(n)}`;
1576
- this._enhanceTimeGridAccessibility(".fc-week-day-column", r), new g(this).enableTimeGrid(".fc-week-day-column");
1595
+ this._enhanceTimeGridAccessibility(".fc-week-day-column", r), new _(this).enableTimeGrid(".fc-week-day-column");
1577
1596
  }
1578
1597
  _scrollToCurrentTime() {
1579
1598
  if (this._scrolled) return;
1580
1599
  let e = this.container.querySelector("#week-scroll-container");
1581
1600
  e && (e.scrollTop = 8 * this.hourHeight - 50, this._scrolled = !0);
1582
1601
  }
1583
- }, y = class extends l {
1602
+ }, b = class extends u {
1584
1603
  constructor(e, t) {
1585
1604
  super(e, t), this.hourHeight = 60, this.totalHeight = 24 * this.hourHeight;
1586
1605
  }
@@ -1717,14 +1736,14 @@ var g = class {
1717
1736
  day: "numeric",
1718
1737
  year: "numeric"
1719
1738
  }).format(t);
1720
- this._enhanceTimeGridAccessibility(".fc-day-column", n), new g(this).enableTimeGrid(".fc-day-column");
1739
+ this._enhanceTimeGridAccessibility(".fc-day-column", n), new _(this).enableTimeGrid(".fc-day-column");
1721
1740
  }
1722
1741
  _scrollToCurrentTime() {
1723
1742
  if (this._scrolled) return;
1724
1743
  let e = this.container.querySelector("#day-scroll-container");
1725
1744
  e && (e.scrollTop = 8 * this.hourHeight - 50, this._scrolled = !0);
1726
1745
  }
1727
- }, b = class extends n {
1746
+ }, x = class extends n {
1728
1747
  constructor() {
1729
1748
  super(), this._isVisible = !1, this._cleanupFocusTrap = null, this.config = {
1730
1749
  title: "New Event",
@@ -1771,8 +1790,8 @@ var g = class {
1771
1790
  }
1772
1791
  getStyles() {
1773
1792
  return `
1774
- ${c.getBaseStyles()}
1775
- ${c.getButtonStyles()}
1793
+ ${l.getBaseStyles()}
1794
+ ${l.getButtonStyles()}
1776
1795
 
1777
1796
  :host {
1778
1797
  display: none;
@@ -1979,7 +1998,7 @@ var g = class {
1979
1998
  ${this.config.colors.map((e) => `
1980
1999
  <button type="button"
1981
2000
  class="color-btn ${e.color === this._formData.color ? "selected" : ""}"
1982
- style="background-color: ${c.sanitizeColor(e.color)}"
2001
+ style="background-color: ${l.sanitizeColor(e.color)}"
1983
2002
  data-color="${s.escapeHTML(e.color)}"
1984
2003
  title="${s.escapeHTML(e.label)}"
1985
2004
  aria-label="${s.escapeHTML(e.label)}"
@@ -2044,14 +2063,14 @@ var g = class {
2044
2063
  this._cleanupFocusTrap && this._cleanupFocusTrap(), this._handleKeyDown && (window.removeEventListener("keydown", this._handleKeyDown), this._handleKeyDown = null, this._keydownListenerAdded = !1);
2045
2064
  }
2046
2065
  };
2047
- customElements.get("forcecal-event-form") || customElements.define("forcecal-event-form", b);
2066
+ customElements.get("forcecal-event-form") || customElements.define("forcecal-event-form", x);
2048
2067
  //#endregion
2049
2068
  //#region src/components/ForceCalendar.js
2050
- var x = class e extends n {
2069
+ var S = class e extends n {
2051
2070
  static RENDERERS = {
2052
- month: _,
2053
- week: v,
2054
- day: y
2071
+ month: v,
2072
+ week: y,
2073
+ day: b
2055
2074
  };
2056
2075
  static get observedAttributes() {
2057
2076
  return [
@@ -2060,7 +2079,8 @@ var x = class e extends n {
2060
2079
  "locale",
2061
2080
  "timezone",
2062
2081
  "week-starts-on",
2063
- "height"
2082
+ "height",
2083
+ "theme"
2064
2084
  ];
2065
2085
  }
2066
2086
  constructor() {
@@ -2161,7 +2181,7 @@ var x = class e extends n {
2161
2181
  if (t) {
2162
2182
  this._currentViewInstance && this._currentViewInstance.cleanup && this._currentViewInstance.cleanup();
2163
2183
  try {
2164
- let n = new (e.RENDERERS[this.currentView] || _)(t, this.stateManager);
2184
+ let n = new (e.RENDERERS[this.currentView] || v)(t, this.stateManager);
2165
2185
  n._viewType = this.currentView, this._currentViewInstance = n, n.render();
2166
2186
  } catch (e) {
2167
2187
  console.error("[ForceCalendar] Error switching view:", e);
@@ -2184,10 +2204,10 @@ var x = class e extends n {
2184
2204
  getStyles() {
2185
2205
  let e = this.getAttribute("height") || "800px";
2186
2206
  return `
2187
- ${c.getBaseStyles()}
2188
- ${c.getButtonStyles()}
2189
- ${c.getGridStyles()}
2190
- ${c.getAnimations()}
2207
+ ${l.getBaseStyles()}
2208
+ ${l.getButtonStyles()}
2209
+ ${l.getGridStyles()}
2210
+ ${l.getAnimations()}
2191
2211
 
2192
2212
  :host {
2193
2213
  --calendar-height: ${e};
@@ -2682,13 +2702,18 @@ var x = class e extends n {
2682
2702
  renderView() {
2683
2703
  return "<div id=\"calendar-view-container\"></div>";
2684
2704
  }
2705
+ _applyTheme(e) {
2706
+ let t = c[e];
2707
+ for (let e of Object.keys(c.slds)) t && t[e] ? this.style.setProperty(e, t[e]) : this.style.removeProperty(e);
2708
+ }
2685
2709
  afterRender() {
2710
+ this._applyTheme(this.getAttribute("theme"));
2686
2711
  let t = this.$("#calendar-view-container");
2687
2712
  if (t && this.stateManager && this.currentView) {
2688
2713
  if (this._currentViewInstance && this._currentViewInstance._viewType === this.currentView && t.children.length > 0) return;
2689
2714
  this._currentViewInstance && (this._currentViewInstance.cleanup && this._currentViewInstance.cleanup(), this._viewUnsubscribe &&= (this._viewUnsubscribe(), null));
2690
2715
  try {
2691
- let n = new (e.RENDERERS[this.currentView] || _)(t, this.stateManager);
2716
+ let n = new (e.RENDERERS[this.currentView] || v)(t, this.stateManager);
2692
2717
  n._viewType = this.currentView, this._currentViewInstance = n, n.render();
2693
2718
  } catch (e) {
2694
2719
  console.error("[ForceCalendar] Error creating/rendering view:", e);
@@ -2784,8 +2809,8 @@ var x = class e extends n {
2784
2809
  this._busUnsubscribers.forEach((e) => e()), this._busUnsubscribers = [], this._stateUnsubscribe &&= (this._stateUnsubscribe(), null), this._currentViewInstance && this._currentViewInstance.cleanup && (this._currentViewInstance.cleanup(), this._currentViewInstance = null), this.stateManager && this.stateManager.destroy(), super.cleanup();
2785
2810
  }
2786
2811
  };
2787
- customElements.get("forcecal-main") || customElements.define("forcecal-main", x);
2812
+ customElements.get("forcecal-main") || customElements.define("forcecal-main", S);
2788
2813
  //#endregion
2789
- export { n as BaseComponent, l as BaseViewRenderer, s as DOMUtils, o as DateUtils, y as DayViewRenderer, r as EventBus, x as ForceCalendar, _ as MonthViewRenderer, a as StateManager, c as StyleUtils, v as WeekViewRenderer, i as eventBus };
2814
+ export { n as BaseComponent, u as BaseViewRenderer, s as DOMUtils, o as DateUtils, b as DayViewRenderer, r as EventBus, S as ForceCalendar, v as MonthViewRenderer, a as StateManager, l as StyleUtils, y as WeekViewRenderer, i as eventBus };
2790
2815
 
2791
2816
  //# sourceMappingURL=force-calendar-interface.esm.js.map