@forcecalendar/interface 1.0.24 → 1.0.26
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/dist/force-calendar-interface.esm.js +67 -62
- package/dist/force-calendar-interface.esm.js.map +1 -1
- package/dist/force-calendar-interface.umd.js +38 -38
- package/dist/force-calendar-interface.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/renderers/BaseViewRenderer.js +21 -11
- package/src/renderers/DayViewRenderer.js +14 -15
- package/src/renderers/MonthViewRenderer.js +8 -8
- package/src/renderers/WeekViewRenderer.js +14 -15
package/package.json
CHANGED
|
@@ -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
|
|
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,20 +198,30 @@ 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
|
*/
|
|
204
213
|
attachCommonEventHandlers() {
|
|
205
|
-
//
|
|
206
|
-
this.
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
214
|
+
// Delegate event clicks at container level to avoid rebinding per event node.
|
|
215
|
+
this.addListener(this.container, 'click', (e) => {
|
|
216
|
+
const eventEl = e.target.closest('.fc-event');
|
|
217
|
+
if (!eventEl || !this.container.contains(eventEl)) return;
|
|
218
|
+
|
|
219
|
+
e.stopPropagation();
|
|
220
|
+
const eventId = eventEl.dataset.eventId;
|
|
221
|
+
const event = this.stateManager.getEvents().find(ev => ev.id === eventId);
|
|
222
|
+
if (event) {
|
|
223
|
+
this.stateManager.selectEvent(event);
|
|
224
|
+
}
|
|
215
225
|
});
|
|
216
226
|
}
|
|
217
227
|
}
|
|
@@ -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
|
|
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('')}
|
|
@@ -164,20 +164,19 @@ export class DayViewRenderer extends BaseViewRenderer {
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
_attachEventHandlers() {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
});
|
|
167
|
+
this.addListener(this.container, 'click', (e) => {
|
|
168
|
+
const dayEl = e.target.closest('.fc-day-column');
|
|
169
|
+
if (!dayEl || !this.container.contains(dayEl)) return;
|
|
170
|
+
if (e.target.closest('.fc-event')) return;
|
|
171
|
+
|
|
172
|
+
const date = new Date(dayEl.dataset.date);
|
|
173
|
+
const rect = dayEl.getBoundingClientRect();
|
|
174
|
+
const scrollContainer = this.container.querySelector('#day-scroll-container');
|
|
175
|
+
const y = e.clientY - rect.top + (scrollContainer ? scrollContainer.scrollTop : 0);
|
|
176
|
+
|
|
177
|
+
// Calculate time from click position
|
|
178
|
+
date.setHours(Math.floor(y / this.hourHeight), Math.floor((y % this.hourHeight) / (this.hourHeight / 60)), 0, 0);
|
|
179
|
+
this.stateManager.selectDate(date);
|
|
181
180
|
});
|
|
182
181
|
|
|
183
182
|
// Common event handlers (event clicks)
|
|
@@ -98,7 +98,7 @@ export class MonthViewRenderer extends BaseViewRenderer {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
_renderEvent(event) {
|
|
101
|
-
const color = event
|
|
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;">
|
|
@@ -108,13 +108,13 @@ export class MonthViewRenderer extends BaseViewRenderer {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
_attachEventHandlers() {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
111
|
+
this.addListener(this.container, 'click', (e) => {
|
|
112
|
+
const dayEl = e.target.closest('.fc-month-day');
|
|
113
|
+
if (!dayEl || !this.container.contains(dayEl)) return;
|
|
114
|
+
if (e.target.closest('.fc-event')) return;
|
|
115
|
+
|
|
116
|
+
const date = new Date(dayEl.dataset.date);
|
|
117
|
+
this.stateManager.selectDate(date);
|
|
118
118
|
});
|
|
119
119
|
|
|
120
120
|
// Common event handlers (event clicks)
|
|
@@ -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
|
|
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('')}
|
|
@@ -136,20 +136,19 @@ export class WeekViewRenderer extends BaseViewRenderer {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
_attachEventHandlers() {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
});
|
|
139
|
+
this.addListener(this.container, 'click', (e) => {
|
|
140
|
+
const dayEl = e.target.closest('.fc-week-day-column');
|
|
141
|
+
if (!dayEl || !this.container.contains(dayEl)) return;
|
|
142
|
+
if (e.target.closest('.fc-event')) return;
|
|
143
|
+
|
|
144
|
+
const date = new Date(dayEl.dataset.date);
|
|
145
|
+
const rect = dayEl.getBoundingClientRect();
|
|
146
|
+
const scrollContainer = this.container.querySelector('#week-scroll-container');
|
|
147
|
+
const y = e.clientY - rect.top + (scrollContainer ? scrollContainer.scrollTop : 0);
|
|
148
|
+
|
|
149
|
+
// Calculate time from click position
|
|
150
|
+
date.setHours(Math.floor(y / this.hourHeight), Math.floor((y % this.hourHeight) / (this.hourHeight / 60)), 0, 0);
|
|
151
|
+
this.stateManager.selectDate(date);
|
|
153
152
|
});
|
|
154
153
|
|
|
155
154
|
// Common event handlers (event clicks)
|