@primeui/scheduler-core 0.0.1-alpha.1

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.
Files changed (63) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +1 -0
  3. package/dist/calendar/index.d.mts +57 -0
  4. package/dist/calendar/index.mjs +1 -0
  5. package/dist/chunk-2B3YLWHA.mjs +196 -0
  6. package/dist/chunk-2THQAZ26.mjs +1669 -0
  7. package/dist/chunk-5KORIWDT.mjs +41 -0
  8. package/dist/chunk-5N4ZOBJV.mjs +866 -0
  9. package/dist/chunk-6OZAPQZ5.mjs +229 -0
  10. package/dist/chunk-6PK5WSKT.mjs +369 -0
  11. package/dist/chunk-6VYWVIGM.mjs +1170 -0
  12. package/dist/chunk-AAVM7UCG.mjs +100 -0
  13. package/dist/chunk-C7ADJGNV.mjs +157 -0
  14. package/dist/chunk-DYW6WUHE.mjs +277 -0
  15. package/dist/chunk-F5W5HD7S.mjs +285 -0
  16. package/dist/chunk-FIBAZFC4.mjs +871 -0
  17. package/dist/chunk-HPC5B3AR.mjs +558 -0
  18. package/dist/chunk-KQGRXTP5.mjs +650 -0
  19. package/dist/chunk-NMX4BW42.mjs +672 -0
  20. package/dist/chunk-NX46LPLF.mjs +440 -0
  21. package/dist/chunk-NZGJN7HG.mjs +314 -0
  22. package/dist/chunk-QDMZBJDV.mjs +251 -0
  23. package/dist/chunk-QR2SVYAD.mjs +1144 -0
  24. package/dist/chunk-SYJ5O4KH.mjs +136 -0
  25. package/dist/chunk-TNKJPFGI.mjs +569 -0
  26. package/dist/chunk-UMAMDBU4.mjs +1 -0
  27. package/dist/chunk-W2SJW3QQ.mjs +3925 -0
  28. package/dist/chunk-WFUJWDST.mjs +352 -0
  29. package/dist/chunk-XUBQ2IQS.mjs +1 -0
  30. package/dist/chunk-ZUKUKGNK.mjs +613 -0
  31. package/dist/controllers/index.d.mts +384 -0
  32. package/dist/controllers/index.mjs +13 -0
  33. package/dist/date-D_CjQPmM.d.mts +74 -0
  34. package/dist/display-format-CLVvRt4I.d.mts +57 -0
  35. package/dist/event/index.d.mts +267 -0
  36. package/dist/event/index.mjs +8 -0
  37. package/dist/event-surface-_R_LHD95.d.mts +21 -0
  38. package/dist/event.positioning-BdzAVPk7.d.mts +51 -0
  39. package/dist/event.utils-QSNdd-3W.d.mts +35 -0
  40. package/dist/index.d.mts +1128 -0
  41. package/dist/index.mjs +1022 -0
  42. package/dist/interaction/index.d.mts +442 -0
  43. package/dist/interaction/index.mjs +9 -0
  44. package/dist/month/index.d.mts +104 -0
  45. package/dist/month/index.mjs +6 -0
  46. package/dist/overlay-BYM9B6nC.d.mts +64 -0
  47. package/dist/resource/index.d.mts +172 -0
  48. package/dist/resource/index.mjs +1 -0
  49. package/dist/selection-CO_98HdS.d.mts +56 -0
  50. package/dist/time-grid/index.d.mts +92 -0
  51. package/dist/time-grid/index.mjs +13 -0
  52. package/dist/timeline/index.d.mts +165 -0
  53. package/dist/timeline/index.mjs +6 -0
  54. package/dist/touch-BhsMWsjf.d.mts +69 -0
  55. package/dist/utils/index.d.mts +494 -0
  56. package/dist/utils/index.mjs +17 -0
  57. package/dist/views/index.d.mts +51 -0
  58. package/dist/views/index.mjs +8 -0
  59. package/dist/views/timeline/index.d.mts +37 -0
  60. package/dist/views/timeline/index.mjs +4 -0
  61. package/dist/year/index.d.mts +70 -0
  62. package/dist/year/index.mjs +6 -0
  63. package/package.json +58 -0
@@ -0,0 +1,285 @@
1
+ import { positionEventsForDay, getAllDayEventsForDay, positionAllDayEventsForWeek } from './chunk-6VYWVIGM.mjs';
2
+ import { parseEvents, getTimedEventsForDayAndResource, eventMatchesResource } from './chunk-2B3YLWHA.mjs';
3
+ import { getTimedBusinessHoursOverlays, getTimedBlockedIntervalsOverlays } from './chunk-AAVM7UCG.mjs';
4
+ import { getAppointmentSlotIndicators, getAppointmentSlotOverlays } from './chunk-NZGJN7HG.mjs';
5
+ import { getDatePartsInTimezone } from './chunk-QDMZBJDV.mjs';
6
+ import { timeStringToMinutes, startOfDay, toDateString } from './chunk-WFUJWDST.mjs';
7
+ import { resolveSchedulerCalendarModeForView, getSchedulerCalendarAdapter } from './chunk-DYW6WUHE.mjs';
8
+
9
+ // src/time-grid/view-model.ts
10
+ var RESOURCE_VIEWS = ["resourceDay", "resourceWeek"];
11
+ var SINGLE_DAY_VIEWS = ["day", "resourceDay", "dateDay"];
12
+ var EMPTY_OVERFLOW_BY_DAY = Object.freeze({});
13
+ function getSlotHeight(density) {
14
+ switch (density) {
15
+ case "compact":
16
+ return 24;
17
+ case "standard":
18
+ return 32;
19
+ case "comfortable":
20
+ return 44;
21
+ default:
22
+ return 48;
23
+ }
24
+ }
25
+ function getMinutesFromMidnight(date) {
26
+ return date.getHours() * 60 + date.getMinutes();
27
+ }
28
+ function getColumnKey(date, resourceId) {
29
+ return `${toDateString(date)}::${resourceId === void 0 ? "__all__" : String(resourceId)}`;
30
+ }
31
+ function matchesEventIdentity(candidate, event) {
32
+ const eventStart = event.start instanceof Date ? event.start : new Date(event.start);
33
+ const eventEnd = event.end instanceof Date ? event.end : new Date(event.end || event.start);
34
+ return candidate.id === event.id && candidate.start.getTime() === eventStart.getTime() && (candidate.end?.getTime() ?? eventStart.getTime()) === eventEnd.getTime();
35
+ }
36
+ function toCalendarDate(view, date, locale, calendar) {
37
+ const mode = resolveSchedulerCalendarModeForView(calendar ?? "gregory", view);
38
+ const adapter = getSchedulerCalendarAdapter(mode, { locale });
39
+ return startOfDay(adapter.toDate(adapter.fromDate(date)));
40
+ }
41
+ function normalizeDaysOfWeek(days) {
42
+ const normalized = Array.from(new Set((days ?? [0, 1, 2, 3, 4, 5, 6]).filter((day) => Number.isInteger(day) && day >= 0 && day <= 6)));
43
+ return normalized.length > 0 ? normalized : [0, 1, 2, 3, 4, 5, 6];
44
+ }
45
+ function normalizeNumberOfDays(value) {
46
+ return typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.floor(value) : void 0;
47
+ }
48
+ function buildTimeGridDays(view, date, firstDayOfWeek, locale, calendar, numberOfDays, daysOfWeek) {
49
+ const mode = resolveSchedulerCalendarModeForView(calendar ?? "gregory", view);
50
+ const adapter = getSchedulerCalendarAdapter(mode, { locale });
51
+ const currentCalendarDate = adapter.fromDate(date);
52
+ if (SINGLE_DAY_VIEWS.includes(view)) {
53
+ return [toCalendarDate(view, date, locale, calendar)];
54
+ }
55
+ const customDayCount = normalizeNumberOfDays(numberOfDays);
56
+ const start = customDayCount ? currentCalendarDate : adapter.startOfWeek(currentCalendarDate, firstDayOfWeek);
57
+ const activeDays = new Set(normalizeDaysOfWeek(daysOfWeek));
58
+ const totalDays = customDayCount ?? 7;
59
+ const result = [];
60
+ for (let i = 0; i < totalDays; i++) {
61
+ const calendarDay = adapter.add(start, { days: i });
62
+ if (activeDays.has(adapter.getDayOfWeek(calendarDay))) {
63
+ result.push(adapter.toDate(calendarDay));
64
+ }
65
+ }
66
+ return result;
67
+ }
68
+ function buildTimeSlots(slotMinTime, slotMaxTime, slotDuration) {
69
+ const minMinutes = timeStringToMinutes(slotMinTime);
70
+ const maxMinutes = timeStringToMinutes(slotMaxTime);
71
+ const slots = [];
72
+ for (let minutes = minMinutes; minutes < maxMinutes; minutes += slotDuration) {
73
+ const hour = Math.floor(minutes / 60);
74
+ const minute = minutes % 60;
75
+ slots.push({
76
+ time: `${String(hour).padStart(2, "0")}:${String(minute).padStart(2, "0")}`,
77
+ minutes
78
+ });
79
+ }
80
+ return slots;
81
+ }
82
+ function resolveNowIndicatorTop(input) {
83
+ if (!input.enabled) return null;
84
+ const currentParts = getDatePartsInTimezone(input.now, input.timezone);
85
+ const todayInView = input.days.some((date) => date.getFullYear() === currentParts.year && date.getMonth() === currentParts.month && date.getDate() === currentParts.day);
86
+ if (!todayInView) return null;
87
+ const nowMinutes = currentParts.hour * 60 + currentParts.minute;
88
+ const minMinutes = timeStringToMinutes(input.slotMinTime);
89
+ const maxMinutes = timeStringToMinutes(input.slotMaxTime);
90
+ if (nowMinutes < minMinutes || nowMinutes > maxMinutes) return null;
91
+ const offset = nowMinutes - minMinutes;
92
+ return offset / input.slotDuration * input.slotHeight;
93
+ }
94
+ function buildTimeGridViewModel(input) {
95
+ const slotDuration = input.slotDuration ?? 30;
96
+ const slotMinTime = input.slotMinTime ?? "00:00";
97
+ const slotMaxTime = input.slotMaxTime ?? "24:00";
98
+ const slotHeight = getSlotHeight(input.density);
99
+ const days = buildTimeGridDays(input.currentView, input.currentDate, input.firstDayOfWeek, input.locale, input.calendar, input.numberOfDays, input.daysOfWeek);
100
+ const resources = RESOURCE_VIEWS.includes(input.currentView) ? input.resources ?? [] : [];
101
+ const minMinutes = timeStringToMinutes(slotMinTime);
102
+ const maxMinutes = timeStringToMinutes(slotMaxTime);
103
+ const totalSlotCount = Math.ceil((maxMinutes - minMinutes) / slotDuration);
104
+ const totalHeight = totalSlotCount * slotHeight;
105
+ const timeSlots = buildTimeSlots(slotMinTime, slotMaxTime, slotDuration);
106
+ const parsedEvents = parseEvents(input.events);
107
+ const positioningOptions = {
108
+ slotMinTime,
109
+ slotMaxTime,
110
+ slotDuration,
111
+ slotHeight
112
+ };
113
+ const usesSpanningAllDayRow = days.length > 1;
114
+ const weekRange = (() => {
115
+ if (days.length === 0) return null;
116
+ const start = startOfDay(days[0]);
117
+ const end = new Date(days[days.length - 1]);
118
+ end.setHours(23, 59, 59, 999);
119
+ return { start, end };
120
+ })();
121
+ const buildPositionedColumn = (date, resourceId) => {
122
+ if (resourceId === void 0) {
123
+ return positionEventsForDay(parsedEvents, date, positioningOptions);
124
+ }
125
+ const resourceEvents = getTimedEventsForDayAndResource(parsedEvents, date, resourceId);
126
+ return positionEventsForDay(resourceEvents, date, positioningOptions);
127
+ };
128
+ const positionedTimedColumns = /* @__PURE__ */ new Map();
129
+ const resourcesForLayouts = resources.map((resource) => resource.id);
130
+ for (const day of days) {
131
+ positionedTimedColumns.set(getColumnKey(day), buildPositionedColumn(day));
132
+ for (const resourceId of resourcesForLayouts) {
133
+ positionedTimedColumns.set(getColumnKey(day, resourceId), buildPositionedColumn(day, resourceId));
134
+ }
135
+ }
136
+ const getPositionedColumn = (date, resourceId) => {
137
+ return positionedTimedColumns.get(getColumnKey(date, resourceId)) ?? buildPositionedColumn(date, resourceId);
138
+ };
139
+ const getAllDayEventsForDay2 = (date, resourceId) => {
140
+ const scopedEvents = parsedEvents.filter((event) => eventMatchesResource(event, resourceId));
141
+ return getAllDayEventsForDay(scopedEvents, date).map((event) => event);
142
+ };
143
+ const buildAllDayWeekLayout = (resourceId) => {
144
+ if (!weekRange) {
145
+ return {
146
+ positioned: [],
147
+ overflowByDay: EMPTY_OVERFLOW_BY_DAY,
148
+ visibleRowCount: 0,
149
+ gridRowCount: 1
150
+ };
151
+ }
152
+ const scopedEvents = parsedEvents.filter((event) => eventMatchesResource(event, resourceId));
153
+ const positioned = positionAllDayEventsForWeek(scopedEvents, weekRange.start, weekRange.end).map((eventPosition) => ({
154
+ event: eventPosition.event,
155
+ row: eventPosition.row,
156
+ startCol: eventPosition.startCol,
157
+ endCol: eventPosition.endCol,
158
+ isContinuationStart: !eventPosition.isStart,
159
+ isContinuationEnd: !eventPosition.isEnd
160
+ }));
161
+ const totalRowCount = positioned.length === 0 ? 0 : Math.max(...positioned.map((event) => event.row)) + 1;
162
+ return {
163
+ positioned,
164
+ overflowByDay: EMPTY_OVERFLOW_BY_DAY,
165
+ visibleRowCount: totalRowCount,
166
+ gridRowCount: Math.max(totalRowCount, 1)
167
+ };
168
+ };
169
+ const allDayWeekLayouts = /* @__PURE__ */ new Map();
170
+ allDayWeekLayouts.set("__all__", buildAllDayWeekLayout());
171
+ for (const resource of resources) {
172
+ allDayWeekLayouts.set(String(resource.id), buildAllDayWeekLayout(resource.id));
173
+ }
174
+ const getWeekAllDayLayout = (resourceId) => {
175
+ return allDayWeekLayouts.get(resourceId === void 0 ? "__all__" : String(resourceId)) ?? buildAllDayWeekLayout(resourceId);
176
+ };
177
+ const getPositionedTimedEvent = (event, date, resourceId) => {
178
+ const match = getPositionedColumn(date, resourceId).find((candidate) => matchesEventIdentity(candidate, event));
179
+ if (!match) return null;
180
+ return {
181
+ event: match,
182
+ top: match.top,
183
+ height: match.height,
184
+ left: match.left,
185
+ width: match.width,
186
+ zIndex: match.zIndex
187
+ };
188
+ };
189
+ const getVisibleAllDayEventsForDay = (date, resourceId) => {
190
+ if (!usesSpanningAllDayRow) {
191
+ return getAllDayEventsForDay2(date, resourceId);
192
+ }
193
+ const dayKey = toDateString(date);
194
+ const dayIndex = days.findIndex((day) => toDateString(day) === dayKey);
195
+ if (dayIndex === -1) return [];
196
+ return getWeekAllDayLayout(resourceId).positioned.filter((event) => event.startCol <= dayIndex && event.endCol >= dayIndex).map((event) => event.event);
197
+ };
198
+ const nowIndicatorTop = resolveNowIndicatorTop({
199
+ enabled: input.nowIndicator ?? false,
200
+ now: input.now ?? /* @__PURE__ */ new Date(),
201
+ days,
202
+ timezone: input.resolvedDisplayTimezone ?? "UTC",
203
+ slotMinTime,
204
+ slotMaxTime,
205
+ slotDuration,
206
+ slotHeight
207
+ });
208
+ const getBusinessHoursOverlays = (date) => {
209
+ if (input.showBusinessHours === false) return [];
210
+ if (!input.businessHours) return [];
211
+ return getTimedBusinessHoursOverlays(date, input.businessHours, slotMinTime, slotMaxTime, slotDuration, slotHeight);
212
+ };
213
+ const getBlockedIntervalOverlays = (date, resourceId) => {
214
+ return getTimedBlockedIntervalsOverlays(date, input.blockedIntervals, slotMinTime, slotMaxTime, slotDuration, slotHeight, resourceId);
215
+ };
216
+ return {
217
+ days,
218
+ resources,
219
+ slotDuration,
220
+ slotMinTime,
221
+ slotMaxTime,
222
+ slotHeight,
223
+ totalSlotCount,
224
+ totalHeight,
225
+ timeSlots,
226
+ parsedEvents,
227
+ usesSpanningAllDayRow,
228
+ hasAllDayEvents: days.some((day) => getAllDayEventsForDay2(day).length > 0),
229
+ nowIndicatorTop,
230
+ showNowIndicator: nowIndicatorTop !== null,
231
+ getTimedEventsForColumn: (date, resourceId) => getPositionedColumn(date, resourceId).map((event) => event),
232
+ getAllDayEventsForDay: getAllDayEventsForDay2,
233
+ getVisibleAllDayEventsForDay,
234
+ getOverflowAllDayEventsForDay: () => [],
235
+ getPositionedTimedEvent,
236
+ getEventTopPosition: (event) => {
237
+ const eventStart = event.start instanceof Date ? event.start : new Date(event.start);
238
+ const eventMinutes = getMinutesFromMidnight(eventStart);
239
+ const offset = eventMinutes - minMinutes;
240
+ return offset / slotDuration * slotHeight;
241
+ },
242
+ getEventHeight: (event) => {
243
+ const eventStart = event.start instanceof Date ? event.start : new Date(event.start);
244
+ const eventEnd = event.end instanceof Date ? event.end : new Date(event.end || event.start);
245
+ const durationMinutes = (eventEnd.getTime() - eventStart.getTime()) / 6e4;
246
+ return Math.max(durationMinutes / slotDuration * slotHeight, slotHeight / 2);
247
+ },
248
+ getOverlapLayout: (event, date, resourceId) => {
249
+ const positioned = getPositionedTimedEvent(event, date, resourceId);
250
+ return {
251
+ left: `${positioned?.left ?? 0}%`,
252
+ width: `${positioned?.width ?? 100}%`,
253
+ zIndex: positioned?.zIndex ?? 1
254
+ };
255
+ },
256
+ getWeekAllDayLayout,
257
+ getBusinessHoursOverlays,
258
+ getBlockedIntervalOverlays,
259
+ getBlockedIntervalStyle: (interval, date, resourceId) => {
260
+ if (!input.blockedIntervals) return null;
261
+ const overlays = getBlockedIntervalOverlays(date, resourceId);
262
+ const overlay = overlays.find((candidate) => {
263
+ const candidateInterval = candidate.interval;
264
+ if (!candidateInterval) return false;
265
+ if (candidateInterval === interval) return true;
266
+ if (candidateInterval.id === interval.id) return true;
267
+ return candidateInterval.originalId === interval.id;
268
+ });
269
+ if (!overlay) return null;
270
+ return overlay.style;
271
+ },
272
+ getAppointmentSlotOverlaysForDay: (date, resourceId) => {
273
+ const config = input.appointmentSlots;
274
+ if (!config || !config.enabled) return [];
275
+ return getAppointmentSlotOverlays(config, date, input.events, slotMinTime, slotMaxTime, slotDuration, slotHeight, resourceId);
276
+ },
277
+ getAppointmentSlotIndicatorsForDay: (date, resourceId) => {
278
+ const config = input.appointmentSlots;
279
+ if (!config || !config.enabled) return [];
280
+ return getAppointmentSlotIndicators(config, date, input.events, slotMinTime, slotMaxTime, slotDuration, slotHeight, resourceId);
281
+ }
282
+ };
283
+ }
284
+
285
+ export { buildTimeGridViewModel };