@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.
- package/LICENSE +23 -0
- package/README.md +1 -0
- package/dist/calendar/index.d.mts +57 -0
- package/dist/calendar/index.mjs +1 -0
- package/dist/chunk-2B3YLWHA.mjs +196 -0
- package/dist/chunk-2THQAZ26.mjs +1669 -0
- package/dist/chunk-5KORIWDT.mjs +41 -0
- package/dist/chunk-5N4ZOBJV.mjs +866 -0
- package/dist/chunk-6OZAPQZ5.mjs +229 -0
- package/dist/chunk-6PK5WSKT.mjs +369 -0
- package/dist/chunk-6VYWVIGM.mjs +1170 -0
- package/dist/chunk-AAVM7UCG.mjs +100 -0
- package/dist/chunk-C7ADJGNV.mjs +157 -0
- package/dist/chunk-DYW6WUHE.mjs +277 -0
- package/dist/chunk-F5W5HD7S.mjs +285 -0
- package/dist/chunk-FIBAZFC4.mjs +871 -0
- package/dist/chunk-HPC5B3AR.mjs +558 -0
- package/dist/chunk-KQGRXTP5.mjs +650 -0
- package/dist/chunk-NMX4BW42.mjs +672 -0
- package/dist/chunk-NX46LPLF.mjs +440 -0
- package/dist/chunk-NZGJN7HG.mjs +314 -0
- package/dist/chunk-QDMZBJDV.mjs +251 -0
- package/dist/chunk-QR2SVYAD.mjs +1144 -0
- package/dist/chunk-SYJ5O4KH.mjs +136 -0
- package/dist/chunk-TNKJPFGI.mjs +569 -0
- package/dist/chunk-UMAMDBU4.mjs +1 -0
- package/dist/chunk-W2SJW3QQ.mjs +3925 -0
- package/dist/chunk-WFUJWDST.mjs +352 -0
- package/dist/chunk-XUBQ2IQS.mjs +1 -0
- package/dist/chunk-ZUKUKGNK.mjs +613 -0
- package/dist/controllers/index.d.mts +384 -0
- package/dist/controllers/index.mjs +13 -0
- package/dist/date-D_CjQPmM.d.mts +74 -0
- package/dist/display-format-CLVvRt4I.d.mts +57 -0
- package/dist/event/index.d.mts +267 -0
- package/dist/event/index.mjs +8 -0
- package/dist/event-surface-_R_LHD95.d.mts +21 -0
- package/dist/event.positioning-BdzAVPk7.d.mts +51 -0
- package/dist/event.utils-QSNdd-3W.d.mts +35 -0
- package/dist/index.d.mts +1128 -0
- package/dist/index.mjs +1022 -0
- package/dist/interaction/index.d.mts +442 -0
- package/dist/interaction/index.mjs +9 -0
- package/dist/month/index.d.mts +104 -0
- package/dist/month/index.mjs +6 -0
- package/dist/overlay-BYM9B6nC.d.mts +64 -0
- package/dist/resource/index.d.mts +172 -0
- package/dist/resource/index.mjs +1 -0
- package/dist/selection-CO_98HdS.d.mts +56 -0
- package/dist/time-grid/index.d.mts +92 -0
- package/dist/time-grid/index.mjs +13 -0
- package/dist/timeline/index.d.mts +165 -0
- package/dist/timeline/index.mjs +6 -0
- package/dist/touch-BhsMWsjf.d.mts +69 -0
- package/dist/utils/index.d.mts +494 -0
- package/dist/utils/index.mjs +17 -0
- package/dist/views/index.d.mts +51 -0
- package/dist/views/index.mjs +8 -0
- package/dist/views/timeline/index.d.mts +37 -0
- package/dist/views/timeline/index.mjs +4 -0
- package/dist/year/index.d.mts +70 -0
- package/dist/year/index.mjs +6 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# License
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2026 PrimeTek
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# PrimeUI Calendar Core
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Calendar } from '@internationalized/date';
|
|
2
|
+
import { SchedulerCalendarMode, SchedulerViewType } from '@primeui/scheduler-types/scheduler';
|
|
3
|
+
|
|
4
|
+
interface SchedulerCalendarDate {
|
|
5
|
+
era?: string;
|
|
6
|
+
year: number;
|
|
7
|
+
month: number;
|
|
8
|
+
day: number;
|
|
9
|
+
}
|
|
10
|
+
interface SchedulerCalendarDuration {
|
|
11
|
+
days?: number;
|
|
12
|
+
months?: number;
|
|
13
|
+
years?: number;
|
|
14
|
+
}
|
|
15
|
+
interface SchedulerCalendarAdapter {
|
|
16
|
+
id: string;
|
|
17
|
+
fromDate(date: Date): SchedulerCalendarDate;
|
|
18
|
+
toDate(date: SchedulerCalendarDate): Date;
|
|
19
|
+
add(date: SchedulerCalendarDate, duration: SchedulerCalendarDuration): SchedulerCalendarDate;
|
|
20
|
+
startOfMonth(date: SchedulerCalendarDate): SchedulerCalendarDate;
|
|
21
|
+
endOfMonth(date: SchedulerCalendarDate): SchedulerCalendarDate;
|
|
22
|
+
startOfWeek(date: SchedulerCalendarDate, firstDayOfWeek: number): SchedulerCalendarDate;
|
|
23
|
+
getDayOfWeek(date: SchedulerCalendarDate): number;
|
|
24
|
+
getDaysInMonth(date: SchedulerCalendarDate): number;
|
|
25
|
+
getMonthsInYear(date: SchedulerCalendarDate): number;
|
|
26
|
+
compare(a: SchedulerCalendarDate, b: SchedulerCalendarDate): number;
|
|
27
|
+
isSameDay(a: SchedulerCalendarDate, b: SchedulerCalendarDate): boolean;
|
|
28
|
+
}
|
|
29
|
+
type SchedulerInternationalCalendarFactory = (calendarId: string) => Calendar | null | undefined;
|
|
30
|
+
interface SchedulerCalendarAdapterOptions {
|
|
31
|
+
locale?: string;
|
|
32
|
+
createCalendar?: SchedulerInternationalCalendarFactory;
|
|
33
|
+
}
|
|
34
|
+
interface SchedulerCalendarInteractionOptions {
|
|
35
|
+
calendar?: SchedulerCalendarMode;
|
|
36
|
+
locale?: string;
|
|
37
|
+
view?: SchedulerViewType | string;
|
|
38
|
+
}
|
|
39
|
+
interface SchedulerCalendarIdResolution {
|
|
40
|
+
requestedCalendar: SchedulerCalendarMode;
|
|
41
|
+
locale: string;
|
|
42
|
+
calendarId: string;
|
|
43
|
+
isSupported: boolean;
|
|
44
|
+
fallbackCalendarId: string | null;
|
|
45
|
+
}
|
|
46
|
+
declare const schedulerInternationalCalendarIds: readonly ["gregory", "buddhist", "ethiopic", "ethioaa", "coptic", "hebrew", "indian", "islamic-civil", "islamic-tbla", "islamic-umalqura", "japanese", "persian", "roc"];
|
|
47
|
+
type SchedulerInternationalCalendarId = (typeof schedulerInternationalCalendarIds)[number];
|
|
48
|
+
declare const gregorianCalendarAdapter: SchedulerCalendarAdapter;
|
|
49
|
+
declare function resolveSchedulerCalendarId(calendar?: SchedulerCalendarMode, options?: Pick<SchedulerCalendarAdapterOptions, 'locale' | 'createCalendar'>): SchedulerCalendarIdResolution;
|
|
50
|
+
declare function isCalendarAdapterCorrectView(view: SchedulerViewType | string | undefined): boolean;
|
|
51
|
+
declare function resolveSchedulerCalendarModeForView(calendar: SchedulerCalendarMode | undefined, view: SchedulerViewType | string | undefined): SchedulerCalendarMode;
|
|
52
|
+
declare function moveDateToCalendarDay(sourceDate: Date, targetDay: Date, options?: SchedulerCalendarInteractionOptions): Date;
|
|
53
|
+
declare function addCalendarDaysToDate(sourceDate: Date, days: number, options?: SchedulerCalendarInteractionOptions): Date;
|
|
54
|
+
declare function differenceInCalendarDays(startDate: Date, endDate: Date, options?: SchedulerCalendarInteractionOptions): number;
|
|
55
|
+
declare function getSchedulerCalendarAdapter(calendar?: SchedulerCalendarMode, options?: SchedulerCalendarAdapterOptions): SchedulerCalendarAdapter;
|
|
56
|
+
|
|
57
|
+
export { type SchedulerCalendarAdapter, type SchedulerCalendarAdapterOptions, type SchedulerCalendarDate, type SchedulerCalendarDuration, type SchedulerCalendarIdResolution, type SchedulerCalendarInteractionOptions, type SchedulerInternationalCalendarFactory, type SchedulerInternationalCalendarId, addCalendarDaysToDate, differenceInCalendarDays, getSchedulerCalendarAdapter, gregorianCalendarAdapter, isCalendarAdapterCorrectView, moveDateToCalendarDay, resolveSchedulerCalendarId, resolveSchedulerCalendarModeForView, schedulerInternationalCalendarIds };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { addCalendarDaysToDate, differenceInCalendarDays, getSchedulerCalendarAdapter, gregorianCalendarAdapter, isCalendarAdapterCorrectView, moveDateToCalendarDay, resolveSchedulerCalendarId, resolveSchedulerCalendarModeForView, schedulerInternationalCalendarIds } from '../chunk-DYW6WUHE.mjs';
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
// src/event/event.utils.ts
|
|
2
|
+
function isStartOfDay(date) {
|
|
3
|
+
return date.getHours() === 0 && date.getMinutes() === 0 && date.getSeconds() === 0 && date.getMilliseconds() === 0;
|
|
4
|
+
}
|
|
5
|
+
function normalizeAllDayEnd(start, end, allDay) {
|
|
6
|
+
if (!allDay) {
|
|
7
|
+
return end;
|
|
8
|
+
}
|
|
9
|
+
if (end.getTime() <= start.getTime() || !isStartOfDay(end)) {
|
|
10
|
+
return end;
|
|
11
|
+
}
|
|
12
|
+
return new Date(end.getTime() - 1);
|
|
13
|
+
}
|
|
14
|
+
function parseEventDate(date) {
|
|
15
|
+
if (!date) return null;
|
|
16
|
+
if (date instanceof Date) return date;
|
|
17
|
+
const parsed = new Date(date);
|
|
18
|
+
return isNaN(parsed.getTime()) ? null : parsed;
|
|
19
|
+
}
|
|
20
|
+
function getEventStart(event) {
|
|
21
|
+
return parseEventDate(event.start) ?? /* @__PURE__ */ new Date();
|
|
22
|
+
}
|
|
23
|
+
function getEventEnd(event) {
|
|
24
|
+
const start = getEventStart(event);
|
|
25
|
+
const end = parseEventDate(event.end);
|
|
26
|
+
if (end) return end;
|
|
27
|
+
if (typeof event.duration === "number" && Number.isFinite(event.duration) && event.duration > 0) {
|
|
28
|
+
return new Date(start.getTime() + event.duration);
|
|
29
|
+
}
|
|
30
|
+
return new Date(start.getTime() + 60 * 60 * 1e3);
|
|
31
|
+
}
|
|
32
|
+
function moveEventTo(event, target) {
|
|
33
|
+
const start = getEventStart(event);
|
|
34
|
+
const end = getEventEnd(event);
|
|
35
|
+
const duration = end.getTime() - start.getTime();
|
|
36
|
+
return {
|
|
37
|
+
...event,
|
|
38
|
+
start: target,
|
|
39
|
+
end: new Date(target.getTime() + duration)
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function resizeEventBy(event, minutes) {
|
|
43
|
+
const end = getEventEnd(event);
|
|
44
|
+
return {
|
|
45
|
+
...event,
|
|
46
|
+
end: new Date(end.getTime() + minutes * 6e4)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function parseEvent(event) {
|
|
50
|
+
const start = parseEventDate(event.start);
|
|
51
|
+
if (!start) return null;
|
|
52
|
+
let end = parseEventDate(event.end);
|
|
53
|
+
if (!end) {
|
|
54
|
+
if (event.allDay) {
|
|
55
|
+
end = new Date(start);
|
|
56
|
+
end.setHours(23, 59, 59, 999);
|
|
57
|
+
} else {
|
|
58
|
+
end = new Date(start.getTime() + 60 * 60 * 1e3);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (end < start) {
|
|
62
|
+
end = new Date(start.getTime() + 60 * 60 * 1e3);
|
|
63
|
+
}
|
|
64
|
+
end = normalizeAllDayEnd(start, end, event.allDay);
|
|
65
|
+
const durationMinutes = Math.round((end.getTime() - start.getTime()) / (1e3 * 60));
|
|
66
|
+
const startDay = new Date(start.getFullYear(), start.getMonth(), start.getDate());
|
|
67
|
+
const endDay = new Date(end.getFullYear(), end.getMonth(), end.getDate());
|
|
68
|
+
const spanDays = Math.ceil((endDay.getTime() - startDay.getTime()) / (1e3 * 60 * 60 * 24)) + 1;
|
|
69
|
+
const isMultiDay = spanDays > 1 || event.allDay === true;
|
|
70
|
+
return {
|
|
71
|
+
...event,
|
|
72
|
+
start,
|
|
73
|
+
end,
|
|
74
|
+
durationMinutes,
|
|
75
|
+
isMultiDay,
|
|
76
|
+
spanDays
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function parseEvents(events) {
|
|
80
|
+
const parsed = [];
|
|
81
|
+
for (const event of events) {
|
|
82
|
+
const p = parseEvent(event);
|
|
83
|
+
if (p) parsed.push(p);
|
|
84
|
+
}
|
|
85
|
+
return parsed;
|
|
86
|
+
}
|
|
87
|
+
function filterEventsByDateRange(events, rangeStart, rangeEnd) {
|
|
88
|
+
return events.filter((event) => {
|
|
89
|
+
return event.start <= rangeEnd && event.end >= rangeStart;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function filterEventsForDay(events, date) {
|
|
93
|
+
const dayStart = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0, 0);
|
|
94
|
+
const dayEnd = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59, 999);
|
|
95
|
+
return events.filter((event) => {
|
|
96
|
+
return event.start <= dayEnd && event.end >= dayStart;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function sortEvents(events) {
|
|
100
|
+
return [...events].sort((a, b) => {
|
|
101
|
+
if (a.allDay && !b.allDay) return -1;
|
|
102
|
+
if (!a.allDay && b.allDay) return 1;
|
|
103
|
+
if (a.isMultiDay && !b.isMultiDay) return -1;
|
|
104
|
+
if (!a.isMultiDay && b.isMultiDay) return 1;
|
|
105
|
+
if (a.isMultiDay && b.isMultiDay) {
|
|
106
|
+
if (b.spanDays !== a.spanDays) return b.spanDays - a.spanDays;
|
|
107
|
+
}
|
|
108
|
+
const startDiff = a.start.getTime() - b.start.getTime();
|
|
109
|
+
if (startDiff !== 0) return startDiff;
|
|
110
|
+
return b.durationMinutes - a.durationMinutes;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function getEventStartMinutes(event) {
|
|
114
|
+
return event.start.getHours() * 60 + event.start.getMinutes();
|
|
115
|
+
}
|
|
116
|
+
function getEventEndMinutes(event) {
|
|
117
|
+
return event.end.getHours() * 60 + event.end.getMinutes();
|
|
118
|
+
}
|
|
119
|
+
function eventsOverlap(a, b) {
|
|
120
|
+
return a.start < b.end && a.end > b.start;
|
|
121
|
+
}
|
|
122
|
+
function getEventColor(event, defaultColor = "") {
|
|
123
|
+
return event.color || defaultColor;
|
|
124
|
+
}
|
|
125
|
+
function getEventTextColor(event, defaultTextColor = "") {
|
|
126
|
+
return event.textColor || defaultTextColor;
|
|
127
|
+
}
|
|
128
|
+
function getEventsForCell(events, cellDate) {
|
|
129
|
+
const cellYear = cellDate.getFullYear();
|
|
130
|
+
const cellMonth = cellDate.getMonth();
|
|
131
|
+
const cellDay = cellDate.getDate();
|
|
132
|
+
const cellStart = new Date(cellYear, cellMonth, cellDay, 0, 0, 0, 0);
|
|
133
|
+
const cellEnd = new Date(cellYear, cellMonth, cellDay, 23, 59, 59, 999);
|
|
134
|
+
return events.filter((event) => {
|
|
135
|
+
if (event.allDay || event.isMultiDay) {
|
|
136
|
+
const eventStartDay = new Date(event.start.getFullYear(), event.start.getMonth(), event.start.getDate());
|
|
137
|
+
const eventEndDay = new Date(event.end.getFullYear(), event.end.getMonth(), event.end.getDate(), 23, 59, 59, 999);
|
|
138
|
+
return cellStart <= eventEndDay && cellEnd >= eventStartDay;
|
|
139
|
+
}
|
|
140
|
+
return event.start.getFullYear() === cellYear && event.start.getMonth() === cellMonth && event.start.getDate() === cellDay;
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
function sortEventsForCell(events) {
|
|
144
|
+
return [...events].sort((a, b) => {
|
|
145
|
+
if (a.allDay && !b.allDay) return -1;
|
|
146
|
+
if (!a.allDay && b.allDay) return 1;
|
|
147
|
+
return a.start.getTime() - b.start.getTime();
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function getVisibleEventsForCell(events, cellDate, maxEvents) {
|
|
151
|
+
const cellEvents = getEventsForCell(events, cellDate);
|
|
152
|
+
const sorted = sortEventsForCell(cellEvents);
|
|
153
|
+
if (maxEvents <= 0) {
|
|
154
|
+
return [];
|
|
155
|
+
}
|
|
156
|
+
if (sorted.length <= maxEvents) {
|
|
157
|
+
return sorted;
|
|
158
|
+
}
|
|
159
|
+
return sorted.slice(0, Math.max(0, maxEvents - 1));
|
|
160
|
+
}
|
|
161
|
+
function getOverflowCountForCell(events, cellDate, maxEvents) {
|
|
162
|
+
const cellEvents = getEventsForCell(events, cellDate);
|
|
163
|
+
const totalEvents = cellEvents.length;
|
|
164
|
+
if (totalEvents === 0) {
|
|
165
|
+
return 0;
|
|
166
|
+
}
|
|
167
|
+
const visibleCount = getVisibleEventsForCell(events, cellDate, maxEvents).length;
|
|
168
|
+
return Math.max(0, totalEvents - visibleCount);
|
|
169
|
+
}
|
|
170
|
+
function isEventStartOnDate(event, date) {
|
|
171
|
+
return event.start.getFullYear() === date.getFullYear() && event.start.getMonth() === date.getMonth() && event.start.getDate() === date.getDate();
|
|
172
|
+
}
|
|
173
|
+
function isEventEndOnDate(event, date) {
|
|
174
|
+
return event.end.getFullYear() === date.getFullYear() && event.end.getMonth() === date.getMonth() && event.end.getDate() === date.getDate();
|
|
175
|
+
}
|
|
176
|
+
function eventMatchesResource(event, resourceId) {
|
|
177
|
+
if (resourceId === void 0) return true;
|
|
178
|
+
return event.resourceId === resourceId || Boolean(event.resourceIds?.includes(resourceId));
|
|
179
|
+
}
|
|
180
|
+
function getEventsForDayAndResource(events, date, resourceId) {
|
|
181
|
+
const dayStart = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0, 0);
|
|
182
|
+
const dayEnd = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59, 999);
|
|
183
|
+
return events.filter((event) => {
|
|
184
|
+
if (!eventMatchesResource(event, resourceId)) return false;
|
|
185
|
+
return event.start <= dayEnd && event.end >= dayStart;
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
function getTimedEventsForDayAndResource(events, date, resourceId) {
|
|
189
|
+
const dayEvents = getEventsForDayAndResource(events, date, resourceId);
|
|
190
|
+
return dayEvents.filter((event) => {
|
|
191
|
+
if (event.allDay) return false;
|
|
192
|
+
return event.start.getFullYear() === date.getFullYear() && event.start.getMonth() === date.getMonth() && event.start.getDate() === date.getDate();
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export { eventMatchesResource, eventsOverlap, filterEventsByDateRange, filterEventsForDay, getEventColor, getEventEnd, getEventEndMinutes, getEventStart, getEventStartMinutes, getEventTextColor, getEventsForCell, getEventsForDayAndResource, getOverflowCountForCell, getTimedEventsForDayAndResource, getVisibleEventsForCell, isEventEndOnDate, isEventStartOnDate, moveEventTo, parseEvent, parseEventDate, parseEvents, resizeEventBy, sortEvents, sortEventsForCell };
|