@forcecalendar/interface 1.0.47 → 1.0.49
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { Calendar as
|
|
1
|
+
var F = Object.defineProperty;
|
|
2
|
+
var H = (h, t, e) => t in h ? F(h, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[t] = e;
|
|
3
|
+
var v = (h, t, e) => H(h, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { Calendar as L, DateUtils as V } from "@forcecalendar/core";
|
|
5
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;
|
|
@@ -125,14 +125,14 @@ class T {
|
|
|
125
125
|
on(t, e, r = {}) {
|
|
126
126
|
const { once: s = !1, priority: i = 0 } = r;
|
|
127
127
|
if (t.includes("*")) {
|
|
128
|
-
const
|
|
129
|
-
return this.wildcardHandlers.add(
|
|
128
|
+
const o = { pattern: t, handler: e, once: s, priority: i };
|
|
129
|
+
return this.wildcardHandlers.add(o), () => this.wildcardHandlers.delete(o);
|
|
130
130
|
}
|
|
131
131
|
this.events.has(t) || this.events.set(t, []);
|
|
132
|
-
const n = { handler: e, once: s, priority: i },
|
|
133
|
-
return
|
|
134
|
-
const
|
|
135
|
-
|
|
132
|
+
const n = { handler: e, once: s, priority: i }, a = this.events.get(t);
|
|
133
|
+
return a.push(n), a.sort((o, c) => c.priority - o.priority), () => {
|
|
134
|
+
const o = a.indexOf(n);
|
|
135
|
+
o > -1 && a.splice(o, 1);
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
@@ -187,12 +187,12 @@ class T {
|
|
|
187
187
|
if (this.events.has(t)) {
|
|
188
188
|
const s = [...this.events.get(t)];
|
|
189
189
|
for (const i of s) {
|
|
190
|
-
const { handler: n, once:
|
|
191
|
-
|
|
190
|
+
const { handler: n, once: a } = i;
|
|
191
|
+
a && this.off(t, n);
|
|
192
192
|
try {
|
|
193
193
|
n(e, t);
|
|
194
|
-
} catch (
|
|
195
|
-
console.error(`Error in event handler for ${t}:`,
|
|
194
|
+
} catch (o) {
|
|
195
|
+
console.error(`Error in event handler for ${t}:`, o);
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
}
|
|
@@ -203,8 +203,8 @@ class T {
|
|
|
203
203
|
n && r.push(s);
|
|
204
204
|
try {
|
|
205
205
|
i(e, t);
|
|
206
|
-
} catch (
|
|
207
|
-
console.error(`Error in wildcard handler for ${t}:`,
|
|
206
|
+
} catch (a) {
|
|
207
|
+
console.error(`Error in wildcard handler for ${t}:`, a);
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
210
|
r.forEach((s) => this.wildcardHandlers.delete(s));
|
|
@@ -249,10 +249,10 @@ class T {
|
|
|
249
249
|
return t;
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
|
-
const
|
|
253
|
-
class
|
|
252
|
+
const U = new T();
|
|
253
|
+
class I {
|
|
254
254
|
constructor(t = {}) {
|
|
255
|
-
this.eventBus = new T(), this.calendar = new
|
|
255
|
+
this.eventBus = new T(), this.calendar = new L({
|
|
256
256
|
view: t.view || "month",
|
|
257
257
|
date: t.date || /* @__PURE__ */ new Date(),
|
|
258
258
|
weekStartsOn: t.weekStartsOn ?? 0,
|
|
@@ -417,11 +417,11 @@ class V {
|
|
|
417
417
|
if (e.weeks && (e.weeks = e.weeks.map((i) => ({
|
|
418
418
|
...i,
|
|
419
419
|
days: i.days.map((n) => {
|
|
420
|
-
const
|
|
420
|
+
const a = new Date(n.date);
|
|
421
421
|
return {
|
|
422
422
|
...n,
|
|
423
|
-
isSelected:
|
|
424
|
-
events: n.events || this.getEventsForDate(
|
|
423
|
+
isSelected: a.toDateString() === r,
|
|
424
|
+
events: n.events || this.getEventsForDate(a)
|
|
425
425
|
};
|
|
426
426
|
})
|
|
427
427
|
}))), e.days && (e.days = e.days.map((i) => {
|
|
@@ -486,7 +486,7 @@ class V {
|
|
|
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
|
|
489
|
+
class p extends V {
|
|
490
490
|
/**
|
|
491
491
|
* Format date for display
|
|
492
492
|
*/
|
|
@@ -548,8 +548,8 @@ class p extends L {
|
|
|
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 s = new Intl.RelativeTimeFormat(r, { numeric: "auto" }), i = t - e, n = Math.floor(i / 1e3),
|
|
552
|
-
return Math.abs(n) < 60 ? s.format(n, "second") : Math.abs(
|
|
551
|
+
const s = new Intl.RelativeTimeFormat(r, { numeric: "auto" }), i = t - e, n = Math.floor(i / 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 ? s.format(n, "second") : Math.abs(a) < 60 ? s.format(a, "minute") : Math.abs(o) < 24 ? s.format(o, "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");
|
|
553
553
|
}
|
|
554
554
|
/**
|
|
555
555
|
* Check if date is today
|
|
@@ -595,9 +595,9 @@ class p extends L {
|
|
|
595
595
|
* Parse time string (e.g., "14:30" or "2:30 PM")
|
|
596
596
|
*/
|
|
597
597
|
static parseTimeString(t, e = /* @__PURE__ */ new Date()) {
|
|
598
|
-
const r = new Date(e), [s, i] = t.split(/\s+/), [n,
|
|
599
|
-
let
|
|
600
|
-
return i && (i.toLowerCase() === "pm" && n < 12 ?
|
|
598
|
+
const r = new Date(e), [s, i] = t.split(/\s+/), [n, a] = s.split(":").map(Number);
|
|
599
|
+
let o = n;
|
|
600
|
+
return i && (i.toLowerCase() === "pm" && n < 12 ? o = n + 12 : i.toLowerCase() === "am" && n === 12 && (o = 0)), r.setHours(o, a || 0, 0, 0), r;
|
|
601
601
|
}
|
|
602
602
|
}
|
|
603
603
|
class D {
|
|
@@ -614,8 +614,8 @@ class D {
|
|
|
614
614
|
else if (i.startsWith("data-"))
|
|
615
615
|
s.setAttribute(i, n);
|
|
616
616
|
else if (i.startsWith("on") && typeof n == "function") {
|
|
617
|
-
const
|
|
618
|
-
s.addEventListener(
|
|
617
|
+
const a = i.slice(2).toLowerCase();
|
|
618
|
+
s.addEventListener(a, n);
|
|
619
619
|
} else
|
|
620
620
|
s[i] = n;
|
|
621
621
|
}), r.forEach((i) => {
|
|
@@ -639,8 +639,8 @@ class D {
|
|
|
639
639
|
*/
|
|
640
640
|
static delegate(t, e, r, s) {
|
|
641
641
|
const i = (n) => {
|
|
642
|
-
const
|
|
643
|
-
|
|
642
|
+
const a = n.target.closest(e);
|
|
643
|
+
a && t.contains(a) && s.call(a, n);
|
|
644
644
|
};
|
|
645
645
|
return t.addEventListener(r, i), () => t.removeEventListener(r, i);
|
|
646
646
|
}
|
|
@@ -795,7 +795,7 @@ class D {
|
|
|
795
795
|
return t.addEventListener("keydown", i), r == null || r.focus(), () => t.removeEventListener("keydown", i);
|
|
796
796
|
}
|
|
797
797
|
}
|
|
798
|
-
class
|
|
798
|
+
class u {
|
|
799
799
|
/**
|
|
800
800
|
* Get CSS variable value
|
|
801
801
|
*/
|
|
@@ -963,15 +963,15 @@ class f {
|
|
|
963
963
|
* Darken color by percentage
|
|
964
964
|
*/
|
|
965
965
|
static darken(t, e) {
|
|
966
|
-
const r = parseInt(t.replace("#", ""), 16), s = Math.round(2.55 * e), i = (r >> 16) - s, n = (r >> 8 & 255) - s,
|
|
967
|
-
return "#" + (16777216 + (i < 255 ? i < 1 ? 0 : i : 255) * 65536 + (n < 255 ? n < 1 ? 0 : n : 255) * 256 + (
|
|
966
|
+
const r = parseInt(t.replace("#", ""), 16), s = Math.round(2.55 * e), i = (r >> 16) - s, n = (r >> 8 & 255) - s, a = (r & 255) - s;
|
|
967
|
+
return "#" + (16777216 + (i < 255 ? i < 1 ? 0 : i : 255) * 65536 + (n < 255 ? n < 1 ? 0 : n : 255) * 256 + (a < 255 ? a < 1 ? 0 : a : 255)).toString(16).slice(1);
|
|
968
968
|
}
|
|
969
969
|
/**
|
|
970
970
|
* Lighten color by percentage
|
|
971
971
|
*/
|
|
972
972
|
static lighten(t, e) {
|
|
973
|
-
const r = parseInt(t.replace("#", ""), 16), s = Math.round(2.55 * e), i = (r >> 16) + s, n = (r >> 8 & 255) + s,
|
|
974
|
-
return "#" + (16777216 + (i < 255 ? i < 1 ? 0 : i : 255) * 65536 + (n < 255 ? n < 1 ? 0 : n : 255) * 256 + (
|
|
973
|
+
const r = parseInt(t.replace("#", ""), 16), s = Math.round(2.55 * e), i = (r >> 16) + s, n = (r >> 8 & 255) + s, a = (r & 255) + s;
|
|
974
|
+
return "#" + (16777216 + (i < 255 ? i < 1 ? 0 : i : 255) * 65536 + (n < 255 ? n < 1 ? 0 : n : 255) * 256 + (a < 255 ? a < 1 ? 0 : a : 255)).toString(16).slice(1);
|
|
975
975
|
}
|
|
976
976
|
/**
|
|
977
977
|
* Get contrast color (black or white) for background
|
|
@@ -1132,7 +1132,7 @@ class f {
|
|
|
1132
1132
|
/**
|
|
1133
1133
|
* Default theme colors
|
|
1134
1134
|
*/
|
|
1135
|
-
|
|
1135
|
+
v(u, "colors", {
|
|
1136
1136
|
primary: "#3B82F6",
|
|
1137
1137
|
// Modern Blue
|
|
1138
1138
|
secondary: "#64748B",
|
|
@@ -1165,7 +1165,7 @@ g(f, "colors", {
|
|
|
1165
1165
|
}), /**
|
|
1166
1166
|
* Common CSS variables
|
|
1167
1167
|
*/
|
|
1168
|
-
|
|
1168
|
+
v(u, "cssVariables", {
|
|
1169
1169
|
// "Pro" Palette - Functional & Sharp
|
|
1170
1170
|
"--fc-primary-color": "#2563EB",
|
|
1171
1171
|
// International Blue (Focus)
|
|
@@ -1233,7 +1233,7 @@ g(f, "cssVariables", {
|
|
|
1233
1233
|
}), /**
|
|
1234
1234
|
* Get responsive breakpoints
|
|
1235
1235
|
*/
|
|
1236
|
-
|
|
1236
|
+
v(u, "breakpoints", {
|
|
1237
1237
|
xs: "320px",
|
|
1238
1238
|
sm: "576px",
|
|
1239
1239
|
md: "768px",
|
|
@@ -1319,21 +1319,13 @@ class E {
|
|
|
1319
1319
|
return r === 0 ? `${i} ${s}` : `${i}:${r.toString().padStart(2, "0")} ${s}`;
|
|
1320
1320
|
}
|
|
1321
1321
|
/**
|
|
1322
|
-
* Get contrasting text color for a background color
|
|
1323
|
-
*
|
|
1322
|
+
* Get contrasting text color for a background color.
|
|
1323
|
+
* Delegates to StyleUtils.getContrastColor() as the single implementation.
|
|
1324
1324
|
* @param {string} bgColor - Hex color string
|
|
1325
|
-
* @returns {string} '
|
|
1325
|
+
* @returns {string} '#000000' or '#FFFFFF'
|
|
1326
1326
|
*/
|
|
1327
1327
|
getContrastingTextColor(t) {
|
|
1328
|
-
|
|
1329
|
-
const e = t.charAt(0) === "#" ? t.substring(1) : t;
|
|
1330
|
-
if (!/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(e))
|
|
1331
|
-
return "white";
|
|
1332
|
-
const r = e.length === 3 ? e[0] + e[0] + e[1] + e[1] + e[2] + e[2] : e, s = parseInt(r.substring(0, 2), 16), i = parseInt(r.substring(2, 4), 16), n = parseInt(r.substring(4, 6), 16);
|
|
1333
|
-
if (isNaN(s) || isNaN(i) || isNaN(n))
|
|
1334
|
-
return "white";
|
|
1335
|
-
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));
|
|
1336
|
-
return 0.2126 * a[0] + 0.7152 * a[1] + 0.0722 * a[2] > 0.179 ? "black" : "white";
|
|
1328
|
+
return !t || typeof t != "string" || t.charAt(0) !== "#" ? "white" : u.getContrastColor(t);
|
|
1337
1329
|
}
|
|
1338
1330
|
/**
|
|
1339
1331
|
* Render the "now" indicator line for time-based views
|
|
@@ -1352,29 +1344,29 @@ class E {
|
|
|
1352
1344
|
*/
|
|
1353
1345
|
computeOverlapLayout(t) {
|
|
1354
1346
|
if (!t || t.length === 0) return /* @__PURE__ */ new Map();
|
|
1355
|
-
const e = t.map((
|
|
1356
|
-
const c = new Date(
|
|
1357
|
-
return { id:
|
|
1347
|
+
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 };
|
|
1358
1350
|
});
|
|
1359
|
-
e.sort((
|
|
1351
|
+
e.sort((o, c) => o.startMin - c.startMin || c.endMin - c.startMin - (o.endMin - o.startMin));
|
|
1360
1352
|
const r = [], s = /* @__PURE__ */ new Map();
|
|
1361
|
-
for (const
|
|
1353
|
+
for (const o of e) {
|
|
1362
1354
|
let c = !1;
|
|
1363
1355
|
for (let d = 0; d < r.length; d++)
|
|
1364
|
-
if (r[d] <=
|
|
1365
|
-
r[d] =
|
|
1356
|
+
if (r[d] <= o.startMin) {
|
|
1357
|
+
r[d] = o.endMin, s.set(o.id, { column: d, totalColumns: 0 }), c = !0;
|
|
1366
1358
|
break;
|
|
1367
1359
|
}
|
|
1368
|
-
c || (s.set(
|
|
1360
|
+
c || (s.set(o.id, { column: r.length, totalColumns: 0 }), r.push(o.endMin));
|
|
1369
1361
|
}
|
|
1370
1362
|
const i = [];
|
|
1371
|
-
let n = [],
|
|
1372
|
-
for (const
|
|
1373
|
-
n.length === 0 ||
|
|
1363
|
+
let n = [], a = 0;
|
|
1364
|
+
for (const o of e)
|
|
1365
|
+
n.length === 0 || o.startMin < a ? (n.push(o), a = Math.max(a, o.endMin)) : (i.push(n), n = [o], a = o.endMin);
|
|
1374
1366
|
n.length > 0 && i.push(n);
|
|
1375
|
-
for (const
|
|
1376
|
-
const c = Math.max(...
|
|
1377
|
-
for (const d of
|
|
1367
|
+
for (const o of i) {
|
|
1368
|
+
const c = Math.max(...o.map((d) => s.get(d.id).column)) + 1;
|
|
1369
|
+
for (const d of o)
|
|
1378
1370
|
s.get(d.id).totalColumns = c;
|
|
1379
1371
|
}
|
|
1380
1372
|
return s;
|
|
@@ -1388,20 +1380,20 @@ class E {
|
|
|
1388
1380
|
* @returns {string} HTML string
|
|
1389
1381
|
*/
|
|
1390
1382
|
renderTimedEvent(t, e = {}) {
|
|
1391
|
-
const { compact: r = !0, overlapLayout: s = null } = e, i = new Date(t.start), n = new Date(t.end),
|
|
1383
|
+
const { compact: r = !0, overlapLayout: s = null } = e, i = new Date(t.start), n = new Date(t.end), a = i.getHours() * 60 + i.getMinutes(), o = Math.max((n - i) / (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, S = r ? "4px" : "6px";
|
|
1392
1384
|
let y, x;
|
|
1393
1385
|
if (s && s.has(t.id)) {
|
|
1394
|
-
const { column:
|
|
1395
|
-
y = `calc(${
|
|
1386
|
+
const { column: C, totalColumns: _ } = s.get(t.id), $ = `(100% - ${g + b}px)`;
|
|
1387
|
+
y = `calc(${g}px + ${C} * ${$} / ${_})`, x = `calc(${$} / ${_})`;
|
|
1396
1388
|
} else
|
|
1397
|
-
y = `${
|
|
1389
|
+
y = `${g}px`, x = `calc(100% - ${g + b}px)`;
|
|
1398
1390
|
return `
|
|
1399
1391
|
<div class="fc-event fc-timed-event" data-event-id="${this.escapeHTML(t.id)}"
|
|
1400
|
-
style="position: absolute; top: ${
|
|
1392
|
+
style="position: absolute; top: ${a}px; height: ${o}px;
|
|
1401
1393
|
left: ${y}; width: ${x};
|
|
1402
|
-
background-color: ${c}; border-radius: ${
|
|
1403
|
-
padding: ${
|
|
1404
|
-
font-weight: 500; color:
|
|
1394
|
+
background-color: ${c}; border-radius: ${S};
|
|
1395
|
+
padding: ${l}; font-size: ${f};
|
|
1396
|
+
font-weight: 500; color: ${d}; overflow: hidden;
|
|
1405
1397
|
box-shadow: 0 1px 2px rgba(0,0,0,0.1);
|
|
1406
1398
|
cursor: pointer; z-index: 5;">
|
|
1407
1399
|
<div style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
|
|
@@ -1419,7 +1411,7 @@ class E {
|
|
|
1419
1411
|
* @returns {string}
|
|
1420
1412
|
*/
|
|
1421
1413
|
getEventColor(t) {
|
|
1422
|
-
return
|
|
1414
|
+
return u.sanitizeColor(t == null ? void 0 : t.backgroundColor, "#2563eb");
|
|
1423
1415
|
}
|
|
1424
1416
|
/**
|
|
1425
1417
|
* Attach common event handlers for day/event clicks
|
|
@@ -1477,7 +1469,7 @@ class w extends E {
|
|
|
1477
1469
|
}), e += "</div>", e;
|
|
1478
1470
|
}
|
|
1479
1471
|
_renderDay(t) {
|
|
1480
|
-
const e = !t.isCurrentMonth, r = t.isToday, s = e ? "var(--fc-background-hover)" : "var(--fc-background)", i = e ? "var(--fc-text-light)" : "var(--fc-text-color)", n = r ? "background: var(--fc-primary-color); color: white; border-radius: 50%; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;" : "",
|
|
1472
|
+
const e = !t.isCurrentMonth, r = t.isToday, s = e ? "var(--fc-background-hover)" : "var(--fc-background)", i = e ? "var(--fc-text-light)" : "var(--fc-text-color)", n = r ? "background: var(--fc-primary-color); color: white; border-radius: 50%; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;" : "", a = t.events || [], o = a.slice(0, this.maxEventsToShow), c = a.length - this.maxEventsToShow;
|
|
1481
1473
|
return `
|
|
1482
1474
|
<div class="fc-month-day" data-date="${t.date}"
|
|
1483
1475
|
style="background: ${s}; border-right: 1px solid var(--fc-border-color); border-bottom: 1px solid var(--fc-border-color); padding: 4px; min-height: 80px; cursor: pointer; display: flex; flex-direction: column;">
|
|
@@ -1485,7 +1477,7 @@ class w extends E {
|
|
|
1485
1477
|
${t.dayOfMonth}
|
|
1486
1478
|
</div>
|
|
1487
1479
|
<div class="fc-day-events" style="display: flex; flex-direction: column; gap: 2px; flex: 1; overflow: hidden;">
|
|
1488
|
-
${
|
|
1480
|
+
${o.map((d) => this._renderEvent(d)).join("")}
|
|
1489
1481
|
${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>` : ""}
|
|
1490
1482
|
</div>
|
|
1491
1483
|
</div>
|
|
@@ -1509,7 +1501,7 @@ class w extends E {
|
|
|
1509
1501
|
}), this.attachCommonEventHandlers();
|
|
1510
1502
|
}
|
|
1511
1503
|
}
|
|
1512
|
-
class
|
|
1504
|
+
class z extends E {
|
|
1513
1505
|
constructor(t, e) {
|
|
1514
1506
|
super(t, e), this.hourHeight = 60, this.totalHeight = 24 * this.hourHeight;
|
|
1515
1507
|
}
|
|
@@ -1525,14 +1517,14 @@ class I extends E {
|
|
|
1525
1517
|
this.container.innerHTML = r, this._attachEventHandlers(), this._scrollToCurrentTime();
|
|
1526
1518
|
}
|
|
1527
1519
|
_renderWeekView(t, e) {
|
|
1528
|
-
const r = t.days, s = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], i = Array.from({ length: 24 }, (
|
|
1529
|
-
const
|
|
1520
|
+
const r = t.days, s = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], i = Array.from({ length: 24 }, (a, o) => o), n = r.map((a) => {
|
|
1521
|
+
const o = new Date(a.date), c = a.events || [];
|
|
1530
1522
|
return {
|
|
1531
|
-
...
|
|
1532
|
-
date:
|
|
1533
|
-
dayName: s[
|
|
1534
|
-
dayOfMonth:
|
|
1535
|
-
isToday: this.isToday(
|
|
1523
|
+
...a,
|
|
1524
|
+
date: o,
|
|
1525
|
+
dayName: s[o.getDay()],
|
|
1526
|
+
dayOfMonth: o.getDate(),
|
|
1527
|
+
isToday: this.isToday(o),
|
|
1536
1528
|
timedEvents: c.filter((d) => !d.allDay),
|
|
1537
1529
|
allDayEvents: c.filter((d) => d.allDay)
|
|
1538
1530
|
};
|
|
@@ -1631,10 +1623,10 @@ class I extends E {
|
|
|
1631
1623
|
this.addListener(this.container, "click", (t) => {
|
|
1632
1624
|
const e = t.target.closest(".fc-week-day-column");
|
|
1633
1625
|
if (!e || !this.container.contains(e) || t.target.closest(".fc-event")) return;
|
|
1634
|
-
const r = new Date(e.dataset.date), s = this.container.querySelector("#week-scroll-container"), i = e.offsetTop, n = t.clientY - e.getBoundingClientRect().top + (s ? s.scrollTop : 0) - i,
|
|
1626
|
+
const r = new Date(e.dataset.date), s = this.container.querySelector("#week-scroll-container"), i = e.offsetTop, n = t.clientY - e.getBoundingClientRect().top + (s ? s.scrollTop : 0) - i, a = Math.max(0, Math.min(n + i, this.totalHeight));
|
|
1635
1627
|
r.setHours(
|
|
1636
|
-
Math.floor(
|
|
1637
|
-
Math.floor(
|
|
1628
|
+
Math.floor(a / this.hourHeight),
|
|
1629
|
+
Math.floor(a % this.hourHeight / (this.hourHeight / 60)),
|
|
1638
1630
|
0,
|
|
1639
1631
|
0
|
|
1640
1632
|
), this.stateManager.selectDate(r);
|
|
@@ -1646,7 +1638,7 @@ class I extends E {
|
|
|
1646
1638
|
t && (t.scrollTop = 8 * this.hourHeight - 50, this._scrolled = !0);
|
|
1647
1639
|
}
|
|
1648
1640
|
}
|
|
1649
|
-
class
|
|
1641
|
+
class B extends E {
|
|
1650
1642
|
constructor(t, e) {
|
|
1651
1643
|
super(t, e), this.hourHeight = 60, this.totalHeight = 24 * this.hourHeight;
|
|
1652
1644
|
}
|
|
@@ -1662,40 +1654,40 @@ class z extends E {
|
|
|
1662
1654
|
this.container.innerHTML = r, this._attachEventHandlers(), this._scrollToCurrentTime();
|
|
1663
1655
|
}
|
|
1664
1656
|
_renderDayView(t, e) {
|
|
1665
|
-
var l,
|
|
1666
|
-
const r = ((
|
|
1657
|
+
var l, f;
|
|
1658
|
+
const r = ((f = (l = this.stateManager) == null ? void 0 : l.getState()) == null ? void 0 : f.currentDate) || /* @__PURE__ */ new Date(), s = this._extractDayData(t, r);
|
|
1667
1659
|
if (!s)
|
|
1668
1660
|
return '<div style="padding: 20px; text-align: center; color: var(--fc-text-secondary);">No data available for day view.</div>';
|
|
1669
|
-
const { dayDate: i, dayName: n, isToday:
|
|
1661
|
+
const { dayDate: i, dayName: n, isToday: a, allDayEvents: o, timedEvents: c } = s, d = Array.from({ length: 24 }, (g, b) => b);
|
|
1670
1662
|
return `
|
|
1671
1663
|
<div class="fc-day-view" style="display: flex; flex-direction: column; height: 100%; background: var(--fc-background); overflow: hidden;">
|
|
1672
|
-
${this._renderHeader(i, n,
|
|
1673
|
-
${this._renderAllDayRow(
|
|
1674
|
-
${this._renderTimeGrid(c,
|
|
1664
|
+
${this._renderHeader(i, n, a)}
|
|
1665
|
+
${this._renderAllDayRow(o, i)}
|
|
1666
|
+
${this._renderTimeGrid(c, a, i, d)}
|
|
1675
1667
|
</div>
|
|
1676
1668
|
`;
|
|
1677
1669
|
}
|
|
1678
1670
|
_extractDayData(t, e) {
|
|
1679
|
-
let r, s, i, n,
|
|
1680
|
-
const
|
|
1671
|
+
let r, s, i, n, a;
|
|
1672
|
+
const o = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
|
|
1681
1673
|
if (t.type === "day" && t.date)
|
|
1682
|
-
if (r = new Date(t.date), s = t.dayName ||
|
|
1674
|
+
if (r = new Date(t.date), s = t.dayName || o[r.getDay()], i = t.isToday !== void 0 ? t.isToday : this.isToday(r), n = t.allDayEvents || [], t.hours && Array.isArray(t.hours)) {
|
|
1683
1675
|
const c = /* @__PURE__ */ new Map();
|
|
1684
1676
|
t.hours.forEach((d) => {
|
|
1685
1677
|
(d.events || []).forEach((l) => {
|
|
1686
1678
|
c.has(l.id) || c.set(l.id, l);
|
|
1687
1679
|
});
|
|
1688
|
-
}),
|
|
1680
|
+
}), a = Array.from(c.values());
|
|
1689
1681
|
} else
|
|
1690
|
-
|
|
1682
|
+
a = [];
|
|
1691
1683
|
else if (t.days && t.days.length > 0) {
|
|
1692
1684
|
const c = t.days.find((l) => this.isSameDay(new Date(l.date), e)) || t.days[0];
|
|
1693
|
-
r = new Date(c.date), s =
|
|
1685
|
+
r = new Date(c.date), s = o[r.getDay()], i = this.isToday(r);
|
|
1694
1686
|
const d = c.events || [];
|
|
1695
|
-
n = d.filter((l) => l.allDay),
|
|
1687
|
+
n = d.filter((l) => l.allDay), a = d.filter((l) => !l.allDay);
|
|
1696
1688
|
} else
|
|
1697
1689
|
return null;
|
|
1698
|
-
return { dayDate: r, dayName: s, isToday: i, allDayEvents: n, timedEvents:
|
|
1690
|
+
return { dayDate: r, dayName: s, isToday: i, allDayEvents: n, timedEvents: a };
|
|
1699
1691
|
}
|
|
1700
1692
|
_renderHeader(t, e, r) {
|
|
1701
1693
|
return `
|
|
@@ -1775,10 +1767,10 @@ class z extends E {
|
|
|
1775
1767
|
this.addListener(this.container, "click", (t) => {
|
|
1776
1768
|
const e = t.target.closest(".fc-day-column");
|
|
1777
1769
|
if (!e || !this.container.contains(e) || t.target.closest(".fc-event")) return;
|
|
1778
|
-
const r = new Date(e.dataset.date), s = this.container.querySelector("#day-scroll-container"), i = e.offsetTop, n = t.clientY - e.getBoundingClientRect().top + (s ? s.scrollTop : 0) - i,
|
|
1770
|
+
const r = new Date(e.dataset.date), s = this.container.querySelector("#day-scroll-container"), i = e.offsetTop, n = t.clientY - e.getBoundingClientRect().top + (s ? s.scrollTop : 0) - i, a = Math.max(0, Math.min(n + i, this.totalHeight));
|
|
1779
1771
|
r.setHours(
|
|
1780
|
-
Math.floor(
|
|
1781
|
-
Math.floor(
|
|
1772
|
+
Math.floor(a / this.hourHeight),
|
|
1773
|
+
Math.floor(a % this.hourHeight / (this.hourHeight / 60)),
|
|
1782
1774
|
0,
|
|
1783
1775
|
0
|
|
1784
1776
|
), this.stateManager.selectDate(r);
|
|
@@ -1790,7 +1782,7 @@ class z extends E {
|
|
|
1790
1782
|
t && (t.scrollTop = 8 * this.hourHeight - 50, this._scrolled = !0);
|
|
1791
1783
|
}
|
|
1792
1784
|
}
|
|
1793
|
-
class
|
|
1785
|
+
class A extends M {
|
|
1794
1786
|
constructor() {
|
|
1795
1787
|
super(), this._isVisible = !1, this._cleanupFocusTrap = null, this.config = {
|
|
1796
1788
|
title: "New Event",
|
|
@@ -1820,8 +1812,8 @@ class B extends M {
|
|
|
1820
1812
|
}
|
|
1821
1813
|
getStyles() {
|
|
1822
1814
|
return `
|
|
1823
|
-
${
|
|
1824
|
-
${
|
|
1815
|
+
${u.getBaseStyles()}
|
|
1816
|
+
${u.getButtonStyles()}
|
|
1825
1817
|
|
|
1826
1818
|
:host {
|
|
1827
1819
|
display: none;
|
|
@@ -2088,15 +2080,15 @@ class B extends M {
|
|
|
2088
2080
|
this.emit("save", t), this.close();
|
|
2089
2081
|
}
|
|
2090
2082
|
formatDateForInput(t) {
|
|
2091
|
-
const e = (
|
|
2092
|
-
return `${r}-${s}-${i}T${n}:${
|
|
2083
|
+
const e = (o) => String(o).padStart(2, "0"), r = t.getFullYear(), s = e(t.getMonth() + 1), i = e(t.getDate()), n = e(t.getHours()), a = e(t.getMinutes());
|
|
2084
|
+
return `${r}-${s}-${i}T${n}:${a}`;
|
|
2093
2085
|
}
|
|
2094
2086
|
unmount() {
|
|
2095
2087
|
this._cleanupFocusTrap && this._cleanupFocusTrap(), this._handleKeyDown && (window.removeEventListener("keydown", this._handleKeyDown), this._handleKeyDown = null, this._keydownListenerAdded = !1);
|
|
2096
2088
|
}
|
|
2097
2089
|
}
|
|
2098
|
-
customElements.get("forcecal-event-form") || customElements.define("forcecal-event-form",
|
|
2099
|
-
const
|
|
2090
|
+
customElements.get("forcecal-event-form") || customElements.define("forcecal-event-form", A);
|
|
2091
|
+
const m = class m extends M {
|
|
2100
2092
|
static get observedAttributes() {
|
|
2101
2093
|
return ["view", "date", "locale", "timezone", "week-starts-on", "height"];
|
|
2102
2094
|
}
|
|
@@ -2111,7 +2103,7 @@ const v = class v extends M {
|
|
|
2111
2103
|
timeZone: this.getAttribute("timezone") || Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
2112
2104
|
weekStartsOn: parseInt(this.getAttribute("week-starts-on") || "0")
|
|
2113
2105
|
};
|
|
2114
|
-
this.stateManager = new
|
|
2106
|
+
this.stateManager = new I(t), this._stateUnsubscribe = this.stateManager.subscribe(this.handleStateChange.bind(this)), this.setupEventListeners();
|
|
2115
2107
|
}
|
|
2116
2108
|
setupEventListeners() {
|
|
2117
2109
|
this._busUnsubscribers.forEach((r) => r()), this._busUnsubscribers = [];
|
|
@@ -2159,10 +2151,10 @@ const v = class v extends M {
|
|
|
2159
2151
|
);
|
|
2160
2152
|
}
|
|
2161
2153
|
handleStateChange(t, e) {
|
|
2162
|
-
var
|
|
2154
|
+
var o, c;
|
|
2163
2155
|
if (!this._hasRendered)
|
|
2164
2156
|
return;
|
|
2165
|
-
const r = t.view !== (e == null ? void 0 : e.view), s = ((
|
|
2157
|
+
const r = t.view !== (e == null ? void 0 : e.view), s = ((o = t.currentDate) == null ? void 0 : o.getTime()) !== ((c = e == null ? void 0 : e.currentDate) == null ? void 0 : c.getTime()), i = t.events !== (e == null ? void 0 : e.events), n = t.loading !== (e == null ? void 0 : e.loading);
|
|
2166
2158
|
if (t.error !== (e == null ? void 0 : e.error)) {
|
|
2167
2159
|
this.render();
|
|
2168
2160
|
return;
|
|
@@ -2201,7 +2193,7 @@ const v = class v extends M {
|
|
|
2201
2193
|
if (t) {
|
|
2202
2194
|
this._currentViewInstance && this._currentViewInstance.cleanup && this._currentViewInstance.cleanup();
|
|
2203
2195
|
try {
|
|
2204
|
-
const e =
|
|
2196
|
+
const e = m.RENDERERS[this.currentView] || w, r = new e(t, this.stateManager);
|
|
2205
2197
|
r._viewType = this.currentView, this._currentViewInstance = r, r.render();
|
|
2206
2198
|
} catch (e) {
|
|
2207
2199
|
console.error("[ForceCalendar] Error switching view:", e);
|
|
@@ -2230,10 +2222,10 @@ const v = class v extends M {
|
|
|
2230
2222
|
getStyles() {
|
|
2231
2223
|
const t = this.getAttribute("height") || "800px";
|
|
2232
2224
|
return `
|
|
2233
|
-
${
|
|
2234
|
-
${
|
|
2235
|
-
${
|
|
2236
|
-
${
|
|
2225
|
+
${u.getBaseStyles()}
|
|
2226
|
+
${u.getButtonStyles()}
|
|
2227
|
+
${u.getGridStyles()}
|
|
2228
|
+
${u.getAnimations()}
|
|
2237
2229
|
|
|
2238
2230
|
:host {
|
|
2239
2231
|
--calendar-height: ${t};
|
|
@@ -2685,7 +2677,7 @@ const v = class v extends M {
|
|
|
2685
2677
|
return;
|
|
2686
2678
|
this._currentViewInstance && (this._currentViewInstance.cleanup && this._currentViewInstance.cleanup(), this._viewUnsubscribe && (this._viewUnsubscribe(), this._viewUnsubscribe = null));
|
|
2687
2679
|
try {
|
|
2688
|
-
const s =
|
|
2680
|
+
const s = m.RENDERERS[this.currentView] || w, i = new s(t, this.stateManager);
|
|
2689
2681
|
i._viewType = this.currentView, this._currentViewInstance = i, i.render();
|
|
2690
2682
|
} catch (s) {
|
|
2691
2683
|
console.error("[ForceCalendar] Error creating/rendering view:", s);
|
|
@@ -2795,25 +2787,25 @@ const v = class v extends M {
|
|
|
2795
2787
|
this._busUnsubscribers.forEach((t) => t()), this._busUnsubscribers = [], this._stateUnsubscribe && (this._stateUnsubscribe(), this._stateUnsubscribe = null), this._currentViewInstance && this._currentViewInstance.cleanup && (this._currentViewInstance.cleanup(), this._currentViewInstance = null), this.stateManager && this.stateManager.destroy(), super.cleanup();
|
|
2796
2788
|
}
|
|
2797
2789
|
};
|
|
2798
|
-
|
|
2790
|
+
v(m, "RENDERERS", {
|
|
2799
2791
|
month: w,
|
|
2800
|
-
week:
|
|
2801
|
-
day:
|
|
2792
|
+
week: z,
|
|
2793
|
+
day: B
|
|
2802
2794
|
});
|
|
2803
|
-
let k =
|
|
2795
|
+
let k = m;
|
|
2804
2796
|
customElements.get("forcecal-main") || customElements.define("forcecal-main", k);
|
|
2805
2797
|
export {
|
|
2806
2798
|
M as BaseComponent,
|
|
2807
2799
|
E as BaseViewRenderer,
|
|
2808
2800
|
D as DOMUtils,
|
|
2809
2801
|
p as DateUtils,
|
|
2810
|
-
|
|
2802
|
+
B as DayViewRenderer,
|
|
2811
2803
|
T as EventBus,
|
|
2812
2804
|
k as ForceCalendar,
|
|
2813
2805
|
w as MonthViewRenderer,
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2806
|
+
I as StateManager,
|
|
2807
|
+
u as StyleUtils,
|
|
2808
|
+
z as WeekViewRenderer,
|
|
2809
|
+
U as eventBus
|
|
2818
2810
|
};
|
|
2819
2811
|
//# sourceMappingURL=force-calendar-interface.esm.js.map
|