@forcecalendar/interface 1.0.23 → 1.0.25

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.23",
3
+ "version": "1.0.25",
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",
@@ -68,9 +68,31 @@ export class ForceCalendar extends BaseComponent {
68
68
  this.emit('calendar-view-change', data);
69
69
  }));
70
70
 
71
- // Event management events
72
- this._busUnsubscribers.push(eventBus.on('event:*', (data, event) => {
73
- this.emit(`calendar-event-${event.split(':')[1]}`, data);
71
+ const forwardEventAction = (action, data) => {
72
+ this.emit(`calendar-event-${action}`, data);
73
+ };
74
+
75
+ // Event management events (canonical + backward-compatible aliases)
76
+ this._busUnsubscribers.push(eventBus.on('event:add', (data) => {
77
+ forwardEventAction('add', data);
78
+ }));
79
+ this._busUnsubscribers.push(eventBus.on('event:update', (data) => {
80
+ forwardEventAction('update', data);
81
+ }));
82
+ this._busUnsubscribers.push(eventBus.on('event:remove', (data) => {
83
+ forwardEventAction('remove', data);
84
+ }));
85
+ this._busUnsubscribers.push(eventBus.on('event:added', (data) => {
86
+ forwardEventAction('add', data);
87
+ this.emit('calendar-event-added', data);
88
+ }));
89
+ this._busUnsubscribers.push(eventBus.on('event:updated', (data) => {
90
+ forwardEventAction('update', data);
91
+ this.emit('calendar-event-updated', data);
92
+ }));
93
+ this._busUnsubscribers.push(eventBus.on('event:deleted', (data) => {
94
+ forwardEventAction('remove', data);
95
+ this.emit('calendar-event-deleted', data);
74
96
  }));
75
97
 
76
98
  // Date selection events
@@ -215,6 +215,7 @@ class StateManager {
215
215
  }
216
216
  // Sync from Core to ensure consistency (single source of truth)
217
217
  this._syncEventsFromCore();
218
+ eventBus.emit('event:add', { event: addedEvent });
218
219
  eventBus.emit('event:added', { event: addedEvent });
219
220
  return addedEvent;
220
221
  }
@@ -232,6 +233,7 @@ class StateManager {
232
233
 
233
234
  // Sync from Core to ensure consistency (single source of truth)
234
235
  this._syncEventsFromCore();
236
+ eventBus.emit('event:update', { event });
235
237
  eventBus.emit('event:updated', { event });
236
238
  return event;
237
239
  }
@@ -248,6 +250,7 @@ class StateManager {
248
250
  }
249
251
  // Sync from Core to ensure consistency (single source of truth)
250
252
  this._syncEventsFromCore();
253
+ eventBus.emit('event:remove', { eventId });
251
254
  eventBus.emit('event:deleted', { eventId });
252
255
  return true;
253
256
  }
@@ -409,4 +412,4 @@ class StateManager {
409
412
  }
410
413
 
411
414
  // Export StateManager
412
- export default StateManager;
415
+ export default StateManager;
@@ -171,7 +171,7 @@ export class BaseViewRenderer {
171
171
  const end = new Date(event.end);
172
172
  const startMinutes = start.getHours() * 60 + start.getMinutes();
173
173
  const durationMinutes = Math.max((end - start) / (1000 * 60), compact ? 20 : 30);
174
- const color = event.backgroundColor || '#2563eb';
174
+ const color = this.getEventColor(event);
175
175
 
176
176
  const padding = compact ? '4px 8px' : '8px 12px';
177
177
  const fontSize = compact ? '11px' : '13px';
@@ -198,6 +198,15 @@ export class BaseViewRenderer {
198
198
  `;
199
199
  }
200
200
 
201
+ /**
202
+ * Get a safe, sanitized event color value.
203
+ * @param {Object} event
204
+ * @returns {string}
205
+ */
206
+ getEventColor(event) {
207
+ return StyleUtils.sanitizeColor(event?.backgroundColor, '#2563eb');
208
+ }
209
+
201
210
  /**
202
211
  * Attach common event handlers for day/event clicks
203
212
  */
@@ -116,7 +116,7 @@ export class DayViewRenderer extends BaseViewRenderer {
116
116
  <div class="fc-all-day-cell" data-date="${dayDate.toISOString()}" style="padding: 6px 12px; display: flex; flex-wrap: wrap; gap: 4px;">
117
117
  ${allDayEvents.map(evt => `
118
118
  <div class="fc-event fc-all-day-event" data-event-id="${this.escapeHTML(evt.id)}"
119
- style="background-color: ${evt.backgroundColor || '#2563eb'}; font-size: 12px; padding: 4px 8px; border-radius: 4px; color: white; cursor: pointer; font-weight: 500;">
119
+ style="background-color: ${this.getEventColor(evt)}; font-size: 12px; padding: 4px 8px; border-radius: 4px; color: white; cursor: pointer; font-weight: 500;">
120
120
  ${this.escapeHTML(evt.title)}
121
121
  </div>
122
122
  `).join('')}
@@ -98,7 +98,7 @@ export class MonthViewRenderer extends BaseViewRenderer {
98
98
  }
99
99
 
100
100
  _renderEvent(event) {
101
- const color = event.backgroundColor || '#2563eb';
101
+ const color = this.getEventColor(event);
102
102
  return `
103
103
  <div class="fc-event" data-event-id="${this.escapeHTML(event.id)}"
104
104
  style="background-color: ${color}; font-size: 11px; padding: 2px 6px; border-radius: 3px; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;">
@@ -87,7 +87,7 @@ export class WeekViewRenderer extends BaseViewRenderer {
87
87
  <div class="fc-all-day-cell" data-date="${day.date.toISOString()}" style="border-right: 1px solid #e5e7eb; padding: 4px; display: flex; flex-direction: column; gap: 2px;">
88
88
  ${day.allDayEvents.map(evt => `
89
89
  <div class="fc-event fc-all-day-event" data-event-id="${this.escapeHTML(evt.id)}"
90
- style="background-color: ${evt.backgroundColor || '#2563eb'}; font-size: 10px; padding: 2px 4px; border-radius: 2px; color: white; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
90
+ style="background-color: ${this.getEventColor(evt)}; font-size: 10px; padding: 2px 4px; border-radius: 2px; color: white; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
91
91
  ${this.escapeHTML(evt.title)}
92
92
  </div>
93
93
  `).join('')}