@forcecalendar/interface 1.0.50 → 1.0.51

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.
@@ -111,7 +111,7 @@ class M extends HTMLElement {
111
111
  this.setProp(t, r), this._initialized && this.render();
112
112
  }
113
113
  }
114
- class T {
114
+ class S {
115
115
  constructor() {
116
116
  this.events = /* @__PURE__ */ new Map(), this.wildcardHandlers = /* @__PURE__ */ new Set();
117
117
  }
@@ -249,10 +249,10 @@ class T {
249
249
  return t;
250
250
  }
251
251
  }
252
- const U = new T();
252
+ const U = new S();
253
253
  class I {
254
254
  constructor(t = {}) {
255
- this.eventBus = new T(), this.calendar = new L({
255
+ this.eventBus = new S(), this.calendar = new L({
256
256
  view: t.view || "month",
257
257
  date: t.date || /* @__PURE__ */ new Date(),
258
258
  weekStartsOn: t.weekStartsOn ?? 0,
@@ -486,7 +486,7 @@ class I {
486
486
  this.subscribers.clear(), this._subscriberIds && (this._subscriberIds.clear(), this._subscriberIds = null), this.eventBus && (this.eventBus.clear(), this.eventBus = null), this.state = null, this.calendar = null;
487
487
  }
488
488
  }
489
- class p extends V {
489
+ class u extends V {
490
490
  /**
491
491
  * Format date for display
492
492
  */
@@ -548,8 +548,8 @@ class p extends V {
548
548
  * Get relative time string (e.g., "2 hours ago", "in 3 days")
549
549
  */
550
550
  static getRelativeTime(t, e = /* @__PURE__ */ new Date(), r = "en-US") {
551
- const i = new Intl.RelativeTimeFormat(r, { numeric: "auto" }), s = t - e, n = Math.floor(s / 1e3), a = Math.floor(n / 60), o = Math.floor(a / 60), c = Math.floor(o / 24), d = Math.floor(c / 7), l = Math.floor(c / 30), f = Math.floor(c / 365);
552
- return Math.abs(n) < 60 ? i.format(n, "second") : Math.abs(a) < 60 ? i.format(a, "minute") : Math.abs(o) < 24 ? i.format(o, "hour") : Math.abs(c) < 7 ? i.format(c, "day") : Math.abs(d) < 4 ? i.format(d, "week") : Math.abs(l) < 12 ? i.format(l, "month") : i.format(f, "year");
551
+ const i = new Intl.RelativeTimeFormat(r, { numeric: "auto" }), s = t - e, n = Math.floor(s / 1e3), a = Math.floor(n / 60), o = Math.floor(a / 60), c = Math.floor(o / 24), l = Math.floor(c / 7), d = Math.floor(c / 30), p = Math.floor(c / 365);
552
+ return Math.abs(n) < 60 ? i.format(n, "second") : Math.abs(a) < 60 ? i.format(a, "minute") : Math.abs(o) < 24 ? i.format(o, "hour") : Math.abs(c) < 7 ? i.format(c, "day") : Math.abs(l) < 4 ? i.format(l, "week") : Math.abs(d) < 12 ? i.format(d, "month") : i.format(p, "year");
553
553
  }
554
554
  /**
555
555
  * Check if date is today
@@ -584,6 +584,13 @@ class p extends V {
584
584
  const r = new Date(2024, 0, 7 + t);
585
585
  return new Intl.DateTimeFormat(e, { weekday: "short" }).format(r);
586
586
  }
587
+ /**
588
+ * Get full day name
589
+ */
590
+ static getDayName(t, e = "en-US") {
591
+ const r = new Date(2024, 0, 7 + t);
592
+ return new Intl.DateTimeFormat(e, { weekday: "long" }).format(r);
593
+ }
587
594
  /**
588
595
  * Get month name
589
596
  */
@@ -600,7 +607,7 @@ class p extends V {
600
607
  return s && (s.toLowerCase() === "pm" && n < 12 ? o = n + 12 : s.toLowerCase() === "am" && n === 12 && (o = 0)), r.setHours(o, a || 0, 0, 0), r;
601
608
  }
602
609
  }
603
- class D {
610
+ class k {
604
611
  /**
605
612
  * Create element with attributes and children
606
613
  */
@@ -795,7 +802,7 @@ class D {
795
802
  return t.addEventListener("keydown", s), r == null || r.focus(), () => t.removeEventListener("keydown", s);
796
803
  }
797
804
  }
798
- class u {
805
+ class f {
799
806
  /**
800
807
  * Get CSS variable value
801
808
  */
@@ -1132,7 +1139,7 @@ class u {
1132
1139
  /**
1133
1140
  * Default theme colors
1134
1141
  */
1135
- v(u, "colors", {
1142
+ v(f, "colors", {
1136
1143
  primary: "#3B82F6",
1137
1144
  // Modern Blue
1138
1145
  secondary: "#64748B",
@@ -1165,7 +1172,7 @@ v(u, "colors", {
1165
1172
  }), /**
1166
1173
  * Common CSS variables
1167
1174
  */
1168
- v(u, "cssVariables", {
1175
+ v(f, "cssVariables", {
1169
1176
  // "Pro" Palette - Functional & Sharp
1170
1177
  "--fc-primary-color": "#2563EB",
1171
1178
  // International Blue (Focus)
@@ -1233,7 +1240,7 @@ v(u, "cssVariables", {
1233
1240
  }), /**
1234
1241
  * Get responsive breakpoints
1235
1242
  */
1236
- v(u, "breakpoints", {
1243
+ v(f, "breakpoints", {
1237
1244
  xs: "320px",
1238
1245
  sm: "576px",
1239
1246
  md: "768px",
@@ -1280,7 +1287,7 @@ class E {
1280
1287
  * @returns {string}
1281
1288
  */
1282
1289
  escapeHTML(t) {
1283
- return t == null ? "" : D.escapeHTML(String(t));
1290
+ return t == null ? "" : k.escapeHTML(String(t));
1284
1291
  }
1285
1292
  /**
1286
1293
  * Check if a date is today
@@ -1325,7 +1332,7 @@ class E {
1325
1332
  * @returns {string} '#000000' or '#FFFFFF'
1326
1333
  */
1327
1334
  getContrastingTextColor(t) {
1328
- return !t || typeof t != "string" || t.charAt(0) !== "#" ? "white" : u.getContrastColor(t);
1335
+ return !t || typeof t != "string" || t.charAt(0) !== "#" ? "white" : f.getContrastColor(t);
1329
1336
  }
1330
1337
  /**
1331
1338
  * Render the "now" indicator line for time-based views
@@ -1345,16 +1352,16 @@ class E {
1345
1352
  computeOverlapLayout(t) {
1346
1353
  if (!t || t.length === 0) return /* @__PURE__ */ new Map();
1347
1354
  const e = t.map((o) => {
1348
- const c = new Date(o.start), d = new Date(o.end), l = c.getHours() * 60 + c.getMinutes(), f = Math.max(l + 1, d.getHours() * 60 + d.getMinutes());
1349
- return { id: o.id, startMin: l, endMin: f };
1355
+ const c = new Date(o.start), l = new Date(o.end), d = c.getHours() * 60 + c.getMinutes(), p = Math.max(d + 1, l.getHours() * 60 + l.getMinutes());
1356
+ return { id: o.id, startMin: d, endMin: p };
1350
1357
  });
1351
1358
  e.sort((o, c) => o.startMin - c.startMin || c.endMin - c.startMin - (o.endMin - o.startMin));
1352
1359
  const r = [], i = /* @__PURE__ */ new Map();
1353
1360
  for (const o of e) {
1354
1361
  let c = !1;
1355
- for (let d = 0; d < r.length; d++)
1356
- if (r[d] <= o.startMin) {
1357
- r[d] = o.endMin, i.set(o.id, { column: d, totalColumns: 0 }), c = !0;
1362
+ for (let l = 0; l < r.length; l++)
1363
+ if (r[l] <= o.startMin) {
1364
+ r[l] = o.endMin, i.set(o.id, { column: l, totalColumns: 0 }), c = !0;
1358
1365
  break;
1359
1366
  }
1360
1367
  c || (i.set(o.id, { column: r.length, totalColumns: 0 }), r.push(o.endMin));
@@ -1365,9 +1372,9 @@ class E {
1365
1372
  n.length === 0 || o.startMin < a ? (n.push(o), a = Math.max(a, o.endMin)) : (s.push(n), n = [o], a = o.endMin);
1366
1373
  n.length > 0 && s.push(n);
1367
1374
  for (const o of s) {
1368
- const c = Math.max(...o.map((d) => i.get(d.id).column)) + 1;
1369
- for (const d of o)
1370
- i.get(d.id).totalColumns = c;
1375
+ const c = Math.max(...o.map((l) => i.get(l.id).column)) + 1;
1376
+ for (const l of o)
1377
+ i.get(l.id).totalColumns = c;
1371
1378
  }
1372
1379
  return i;
1373
1380
  }
@@ -1380,20 +1387,20 @@ class E {
1380
1387
  * @returns {string} HTML string
1381
1388
  */
1382
1389
  renderTimedEvent(t, e = {}) {
1383
- const { compact: r = !0, overlapLayout: i = null } = e, s = new Date(t.start), n = new Date(t.end), a = s.getHours() * 60 + s.getMinutes(), o = Math.max((n - s) / (1e3 * 60), r ? 20 : 30), c = this.getEventColor(t), d = this.getContrastingTextColor(c), l = r ? "4px 8px" : "8px 12px", f = r ? "11px" : "13px", g = r ? 2 : 12, b = r ? 2 : 24, C = r ? "4px" : "6px";
1390
+ const { compact: r = !0, overlapLayout: i = null } = e, s = new Date(t.start), n = new Date(t.end), a = s.getHours() * 60 + s.getMinutes(), o = Math.max((n - s) / (1e3 * 60), r ? 20 : 30), c = this.getEventColor(t), l = this.getContrastingTextColor(c), d = r ? "4px 8px" : "8px 12px", p = r ? "11px" : "13px", g = r ? 2 : 12, b = r ? 2 : 24, T = r ? "4px" : "6px";
1384
1391
  let y, x;
1385
1392
  if (i && i.has(t.id)) {
1386
- const { column: S, totalColumns: _ } = i.get(t.id), $ = `(100% - ${g + b}px)`;
1387
- y = `calc(${g}px + ${S} * ${$} / ${_})`, x = `calc(${$} / ${_})`;
1393
+ const { column: C, totalColumns: _ } = i.get(t.id), $ = `(100% - ${g + b}px)`;
1394
+ y = `calc(${g}px + ${C} * ${$} / ${_})`, x = `calc(${$} / ${_})`;
1388
1395
  } else
1389
1396
  y = `${g}px`, x = `calc(100% - ${g + b}px)`;
1390
1397
  return `
1391
1398
  <div class="fc-event fc-timed-event" data-event-id="${this.escapeHTML(t.id)}"
1392
1399
  style="position: absolute; top: ${a}px; height: ${o}px;
1393
1400
  left: ${y}; width: ${x};
1394
- background-color: ${c}; border-radius: ${C};
1395
- padding: ${l}; font-size: ${f};
1396
- font-weight: 500; color: ${d}; overflow: hidden;
1401
+ background-color: ${c}; border-radius: ${T};
1402
+ padding: ${d}; font-size: ${p};
1403
+ font-weight: 500; color: ${l}; overflow: hidden;
1397
1404
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
1398
1405
  cursor: pointer; z-index: 5;">
1399
1406
  <div style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
@@ -1411,7 +1418,7 @@ class E {
1411
1418
  * @returns {string}
1412
1419
  */
1413
1420
  getEventColor(t) {
1414
- return u.sanitizeColor(t == null ? void 0 : t.backgroundColor, "#2563eb");
1421
+ return f.sanitizeColor(t == null ? void 0 : t.backgroundColor, "#2563eb");
1415
1422
  }
1416
1423
  /**
1417
1424
  * Attach common event handlers for day/event clicks
@@ -1455,10 +1462,10 @@ class w extends E {
1455
1462
  }), s += "</div></div>", s;
1456
1463
  }
1457
1464
  _getDayNames(t) {
1458
- const e = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], r = [];
1465
+ const e = this.stateManager.getState().config.locale || "en-US", r = [];
1459
1466
  for (let i = 0; i < 7; i++) {
1460
1467
  const s = (t + i) % 7;
1461
- r.push(e[s]);
1468
+ r.push(u.getDayAbbreviation(s, e));
1462
1469
  }
1463
1470
  return r;
1464
1471
  }
@@ -1477,7 +1484,7 @@ class w extends E {
1477
1484
  ${t.dayOfMonth}
1478
1485
  </div>
1479
1486
  <div class="fc-day-events" style="display: flex; flex-direction: column; gap: 2px; flex: 1; overflow: hidden;">
1480
- ${o.map((d) => this._renderEvent(d)).join("")}
1487
+ ${o.map((l) => this._renderEvent(l)).join("")}
1481
1488
  ${c > 0 ? `<div class="fc-more-events" style="font-size: 10px; color: var(--fc-text-light); padding: 2px 4px; font-weight: 500;">+${c} more</div>` : ""}
1482
1489
  </div>
1483
1490
  </div>
@@ -1517,16 +1524,16 @@ class z extends E {
1517
1524
  this.container.innerHTML = r, this._attachEventHandlers(), this._scrollToCurrentTime();
1518
1525
  }
1519
1526
  _renderWeekView(t, e) {
1520
- const r = t.days, i = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], s = Array.from({ length: 24 }, (a, o) => o), n = r.map((a) => {
1527
+ const r = t.days, i = this.stateManager.getState().config.locale || "en-US", s = Array.from({ length: 24 }, (a, o) => o), n = r.map((a) => {
1521
1528
  const o = new Date(a.date), c = a.events || [];
1522
1529
  return {
1523
1530
  ...a,
1524
1531
  date: o,
1525
- dayName: i[o.getDay()],
1532
+ dayName: u.getDayAbbreviation(o.getDay(), i),
1526
1533
  dayOfMonth: o.getDate(),
1527
1534
  isToday: this.isToday(o),
1528
- timedEvents: c.filter((d) => !d.allDay),
1529
- allDayEvents: c.filter((d) => d.allDay)
1535
+ timedEvents: c.filter((l) => !l.allDay),
1536
+ allDayEvents: c.filter((l) => l.allDay)
1530
1537
  };
1531
1538
  });
1532
1539
  return `
@@ -1654,37 +1661,37 @@ class B extends E {
1654
1661
  this.container.innerHTML = r, this._attachEventHandlers(), this._scrollToCurrentTime();
1655
1662
  }
1656
1663
  _renderDayView(t, e) {
1657
- var l, f;
1658
- const r = ((f = (l = this.stateManager) == null ? void 0 : l.getState()) == null ? void 0 : f.currentDate) || /* @__PURE__ */ new Date(), i = this._extractDayData(t, r);
1664
+ var d, p;
1665
+ const r = ((p = (d = this.stateManager) == null ? void 0 : d.getState()) == null ? void 0 : p.currentDate) || /* @__PURE__ */ new Date(), i = this._extractDayData(t, r);
1659
1666
  if (!i)
1660
1667
  return '<div style="padding: 20px; text-align: center; color: var(--fc-text-secondary);">No data available for day view.</div>';
1661
- const { dayDate: s, dayName: n, isToday: a, allDayEvents: o, timedEvents: c } = i, d = Array.from({ length: 24 }, (g, b) => b);
1668
+ const { dayDate: s, dayName: n, isToday: a, allDayEvents: o, timedEvents: c } = i, l = Array.from({ length: 24 }, (g, b) => b);
1662
1669
  return `
1663
1670
  <div class="fc-day-view" style="display: flex; flex-direction: column; height: 100%; background: var(--fc-background); overflow: hidden;">
1664
1671
  ${this._renderHeader(s, n, a)}
1665
1672
  ${this._renderAllDayRow(o, s)}
1666
- ${this._renderTimeGrid(c, a, s, d)}
1673
+ ${this._renderTimeGrid(c, a, s, l)}
1667
1674
  </div>
1668
1675
  `;
1669
1676
  }
1670
1677
  _extractDayData(t, e) {
1671
1678
  let r, i, s, n, a;
1672
- const o = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
1679
+ const o = this.stateManager.getState().config.locale || "en-US";
1673
1680
  if (t.type === "day" && t.date)
1674
- if (r = new Date(t.date), i = t.dayName || o[r.getDay()], s = t.isToday !== void 0 ? t.isToday : this.isToday(r), n = t.allDayEvents || [], t.hours && Array.isArray(t.hours)) {
1681
+ if (r = new Date(t.date), i = t.dayName || u.getDayName(r.getDay(), o), s = t.isToday !== void 0 ? t.isToday : this.isToday(r), n = t.allDayEvents || [], t.hours && Array.isArray(t.hours)) {
1675
1682
  const c = /* @__PURE__ */ new Map();
1676
- t.hours.forEach((d) => {
1677
- (d.events || []).forEach((l) => {
1678
- c.has(l.id) || c.set(l.id, l);
1683
+ t.hours.forEach((l) => {
1684
+ (l.events || []).forEach((d) => {
1685
+ c.has(d.id) || c.set(d.id, d);
1679
1686
  });
1680
1687
  }), a = Array.from(c.values());
1681
1688
  } else
1682
1689
  a = [];
1683
1690
  else if (t.days && t.days.length > 0) {
1684
- const c = t.days.find((l) => this.isSameDay(new Date(l.date), e)) || t.days[0];
1685
- r = new Date(c.date), i = o[r.getDay()], s = this.isToday(r);
1686
- const d = c.events || [];
1687
- n = d.filter((l) => l.allDay), a = d.filter((l) => !l.allDay);
1691
+ const c = t.days.find((d) => this.isSameDay(new Date(d.date), e)) || t.days[0];
1692
+ r = new Date(c.date), i = u.getDayName(r.getDay(), o), s = this.isToday(r);
1693
+ const l = c.events || [];
1694
+ n = l.filter((d) => d.allDay), a = l.filter((d) => !d.allDay);
1688
1695
  } else
1689
1696
  return null;
1690
1697
  return { dayDate: r, dayName: i, isToday: s, allDayEvents: n, timedEvents: a };
@@ -1812,8 +1819,8 @@ class A extends M {
1812
1819
  }
1813
1820
  getStyles() {
1814
1821
  return `
1815
- ${u.getBaseStyles()}
1816
- ${u.getButtonStyles()}
1822
+ ${f.getBaseStyles()}
1823
+ ${f.getButtonStyles()}
1817
1824
 
1818
1825
  :host {
1819
1826
  display: none;
@@ -2058,7 +2065,7 @@ class A extends M {
2058
2065
  });
2059
2066
  }
2060
2067
  open(t = /* @__PURE__ */ new Date()) {
2061
- this.hasAttribute("open") || this.setAttribute("open", ""), this.titleGroup.classList.remove("has-error"), this.endGroup.classList.remove("has-error"), this._formData.start = t, this._formData.end = new Date(t.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 = D.trapFocus(this.modalContent));
2068
+ this.hasAttribute("open") || this.setAttribute("open", ""), this.titleGroup.classList.remove("has-error"), this.endGroup.classList.remove("has-error"), this._formData.start = t, this._formData.end = new Date(t.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));
2062
2069
  }
2063
2070
  close() {
2064
2071
  this.removeAttribute("open"), this._cleanupFocusTrap && (this._cleanupFocusTrap(), this._cleanupFocusTrap = null);
@@ -2222,10 +2229,10 @@ const m = class m extends M {
2222
2229
  getStyles() {
2223
2230
  const t = this.getAttribute("height") || "800px";
2224
2231
  return `
2225
- ${u.getBaseStyles()}
2226
- ${u.getButtonStyles()}
2227
- ${u.getGridStyles()}
2228
- ${u.getAnimations()}
2232
+ ${f.getBaseStyles()}
2233
+ ${f.getButtonStyles()}
2234
+ ${f.getGridStyles()}
2235
+ ${f.getAnimations()}
2229
2236
 
2230
2237
  :host {
2231
2238
  --calendar-height: ${t};
@@ -2614,7 +2621,7 @@ const m = class m extends M {
2614
2621
  return `
2615
2622
  <div class="force-calendar">
2616
2623
  <div class="fc-error">
2617
- <p><strong>Error:</strong> ${D.escapeHTML(s.message || "An error occurred")}</p>
2624
+ <p><strong>Error:</strong> ${k.escapeHTML(s.message || "An error occurred")}</p>
2618
2625
  </div>
2619
2626
  </div>
2620
2627
  `;
@@ -2722,15 +2729,15 @@ const m = class m extends M {
2722
2729
  const r = this.stateManager.getState().config.locale;
2723
2730
  switch (e) {
2724
2731
  case "month":
2725
- return p.formatDate(t, "month", r);
2732
+ return u.formatDate(t, "month", r);
2726
2733
  case "week": {
2727
- const i = p.startOfWeek(t), s = p.endOfWeek(t);
2728
- return p.formatDateRange(i, s, r);
2734
+ const i = u.startOfWeek(t), s = u.endOfWeek(t);
2735
+ return u.formatDateRange(i, s, r);
2729
2736
  }
2730
2737
  case "day":
2731
- return p.formatDate(t, "long", r);
2738
+ return u.formatDate(t, "long", r);
2732
2739
  default:
2733
- return p.formatDate(t, "month", r);
2740
+ return u.formatDate(t, "month", r);
2734
2741
  }
2735
2742
  }
2736
2743
  getIcon(t) {
@@ -2792,19 +2799,19 @@ v(m, "RENDERERS", {
2792
2799
  week: z,
2793
2800
  day: B
2794
2801
  });
2795
- let k = m;
2796
- customElements.get("forcecal-main") || customElements.define("forcecal-main", k);
2802
+ let D = m;
2803
+ customElements.get("forcecal-main") || customElements.define("forcecal-main", D);
2797
2804
  export {
2798
2805
  M as BaseComponent,
2799
2806
  E as BaseViewRenderer,
2800
- D as DOMUtils,
2801
- p as DateUtils,
2807
+ k as DOMUtils,
2808
+ u as DateUtils,
2802
2809
  B as DayViewRenderer,
2803
- T as EventBus,
2804
- k as ForceCalendar,
2810
+ S as EventBus,
2811
+ D as ForceCalendar,
2805
2812
  w as MonthViewRenderer,
2806
2813
  I as StateManager,
2807
- u as StyleUtils,
2814
+ f as StyleUtils,
2808
2815
  z as WeekViewRenderer,
2809
2816
  U as eventBus
2810
2817
  };