@forcecalendar/interface 1.0.50 → 1.0.52

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forcecalendar/interface",
3
- "version": "1.0.50",
3
+ "version": "1.0.52",
4
4
  "type": "module",
5
5
  "description": "Official interface layer for forceCalendar Core - Enterprise calendar components",
6
6
  "main": "dist/force-calendar-interface.umd.js",
@@ -18,6 +18,7 @@ export class BaseViewRenderer {
18
18
  this.stateManager = stateManager;
19
19
  this._listeners = [];
20
20
  this._scrolled = false;
21
+ this._nowIndicatorTimer = null;
21
22
  }
22
23
 
23
24
  /**
@@ -36,6 +37,10 @@ export class BaseViewRenderer {
36
37
  element.removeEventListener(event, handler);
37
38
  });
38
39
  this._listeners = [];
40
+ if (this._nowIndicatorTimer) {
41
+ clearInterval(this._nowIndicatorTimer);
42
+ this._nowIndicatorTimer = null;
43
+ }
39
44
  }
40
45
 
41
46
  /**
@@ -137,6 +142,23 @@ export class BaseViewRenderer {
137
142
  return `<div class="fc-now-indicator" style="position: absolute; left: 0; right: 0; top: ${minutes}px; height: 2px; background: var(--fc-danger-color); z-index: 15; pointer-events: none;"></div>`;
138
143
  }
139
144
 
145
+ /**
146
+ * Start a timer that updates the now indicator position every 60 seconds.
147
+ * Call this after render() in day/week views that show a now indicator.
148
+ */
149
+ startNowIndicatorTimer() {
150
+ if (this._nowIndicatorTimer) {
151
+ clearInterval(this._nowIndicatorTimer);
152
+ }
153
+ this._nowIndicatorTimer = setInterval(() => {
154
+ const indicator = this.container.querySelector('.fc-now-indicator');
155
+ if (indicator) {
156
+ const now = new Date();
157
+ indicator.style.top = `${now.getHours() * 60 + now.getMinutes()}px`;
158
+ }
159
+ }, 60000);
160
+ }
161
+
140
162
  /**
141
163
  * Compute overlap layout columns for a list of timed events.
142
164
  * Returns a Map of event.id -> { column, totalColumns }.
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  import { BaseViewRenderer } from './BaseViewRenderer.js';
8
+ import { DateUtils } from '../utils/DateUtils.js';
8
9
 
9
10
  export class DayViewRenderer extends BaseViewRenderer {
10
11
  constructor(container, stateManager) {
@@ -30,6 +31,7 @@ export class DayViewRenderer extends BaseViewRenderer {
30
31
  this.container.innerHTML = html;
31
32
  this._attachEventHandlers();
32
33
  this._scrollToCurrentTime();
34
+ this.startNowIndicatorTimer();
33
35
  }
34
36
 
35
37
  _renderDayView(viewData, _config) {
@@ -54,12 +56,12 @@ export class DayViewRenderer extends BaseViewRenderer {
54
56
 
55
57
  _extractDayData(viewData, currentDate) {
56
58
  let dayDate, dayName, isToday, allDayEvents, timedEvents;
57
- const dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
59
+ const locale = this.stateManager.getState().config.locale || 'en-US';
58
60
 
59
61
  if (viewData.type === 'day' && viewData.date) {
60
62
  // Core day view structure
61
63
  dayDate = new Date(viewData.date);
62
- dayName = viewData.dayName || dayNames[dayDate.getDay()];
64
+ dayName = viewData.dayName || DateUtils.getDayName(dayDate.getDay(), locale);
63
65
  isToday = viewData.isToday !== undefined ? viewData.isToday : this.isToday(dayDate);
64
66
  allDayEvents = viewData.allDayEvents || [];
65
67
 
@@ -82,7 +84,7 @@ export class DayViewRenderer extends BaseViewRenderer {
82
84
  const dayDataItem =
83
85
  viewData.days.find(d => this.isSameDay(new Date(d.date), currentDate)) || viewData.days[0];
84
86
  dayDate = new Date(dayDataItem.date);
85
- dayName = dayNames[dayDate.getDay()];
87
+ dayName = DateUtils.getDayName(dayDate.getDay(), locale);
86
88
  isToday = this.isToday(dayDate);
87
89
  const events = dayDataItem.events || [];
88
90
  allDayEvents = events.filter(e => e.allDay);
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  import { BaseViewRenderer } from './BaseViewRenderer.js';
8
+ import { DateUtils } from '../utils/DateUtils.js';
8
9
 
9
10
  export class MonthViewRenderer extends BaseViewRenderer {
10
11
  constructor(container, stateManager) {
@@ -50,11 +51,11 @@ export class MonthViewRenderer extends BaseViewRenderer {
50
51
  }
51
52
 
52
53
  _getDayNames(weekStartsOn) {
53
- const days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
54
+ const locale = this.stateManager.getState().config.locale || 'en-US';
54
55
  const dayNames = [];
55
56
  for (let i = 0; i < 7; i++) {
56
57
  const dayIndex = (weekStartsOn + i) % 7;
57
- dayNames.push(days[dayIndex]);
58
+ dayNames.push(DateUtils.getDayAbbreviation(dayIndex, locale));
58
59
  }
59
60
  return dayNames;
60
61
  }
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  import { BaseViewRenderer } from './BaseViewRenderer.js';
8
+ import { DateUtils } from '../utils/DateUtils.js';
8
9
 
9
10
  export class WeekViewRenderer extends BaseViewRenderer {
10
11
  constructor(container, stateManager) {
@@ -30,11 +31,12 @@ export class WeekViewRenderer extends BaseViewRenderer {
30
31
  this.container.innerHTML = html;
31
32
  this._attachEventHandlers();
32
33
  this._scrollToCurrentTime();
34
+ this.startNowIndicatorTimer();
33
35
  }
34
36
 
35
37
  _renderWeekView(viewData, _config) {
36
38
  const days = viewData.days;
37
- const dayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
39
+ const locale = this.stateManager.getState().config.locale || 'en-US';
38
40
  const hours = Array.from({ length: 24 }, (_, i) => i);
39
41
 
40
42
  // Process days to categorize events
@@ -44,7 +46,7 @@ export class WeekViewRenderer extends BaseViewRenderer {
44
46
  return {
45
47
  ...day,
46
48
  date: dayDate,
47
- dayName: dayNames[dayDate.getDay()],
49
+ dayName: DateUtils.getDayAbbreviation(dayDate.getDay(), locale),
48
50
  dayOfMonth: dayDate.getDate(),
49
51
  isToday: this.isToday(dayDate),
50
52
  timedEvents: events.filter(e => !e.allDay),
@@ -147,6 +147,14 @@ export class DateUtils extends CoreDateUtils {
147
147
  return new Intl.DateTimeFormat(locale, { weekday: 'short' }).format(date);
148
148
  }
149
149
 
150
+ /**
151
+ * Get full day name
152
+ */
153
+ static getDayName(dayIndex, locale = 'en-US') {
154
+ const date = new Date(2024, 0, 7 + dayIndex); // Jan 7, 2024 is a Sunday
155
+ return new Intl.DateTimeFormat(locale, { weekday: 'long' }).format(date);
156
+ }
157
+
150
158
  /**
151
159
  * Get month name
152
160
  */