@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,569 @@
1
+ import { resolveSchedulerCalendarModeForView, getSchedulerCalendarAdapter } from './chunk-DYW6WUHE.mjs';
2
+
3
+ // src/utils/display-format.ts
4
+ var DEFAULT_TIME_FORMAT_OPTIONS = {
5
+ format: "auto",
6
+ showAMPM: true,
7
+ showMinutes: "always",
8
+ showSeconds: false,
9
+ rangeDisplay: "full",
10
+ use24HourSlots: false
11
+ };
12
+ var DEFAULT_DATE_DISPLAY_OPTIONS = {
13
+ weekdayFormat: "short",
14
+ monthFormat: "long",
15
+ dayFormat: "numeric",
16
+ showYear: "different",
17
+ relativeTime: false
18
+ };
19
+ var DEFAULT_DISPLAY_OPTIONS = {
20
+ time: DEFAULT_TIME_FORMAT_OPTIONS,
21
+ date: DEFAULT_DATE_DISPLAY_OPTIONS
22
+ };
23
+ var DATE_TIME_FORMATTER_CACHE_LIMIT = 512;
24
+ var dateTimeFormatterCache = /* @__PURE__ */ new Map();
25
+ var localeHour12Cache = /* @__PURE__ */ new Map();
26
+ function normalizeTimeFormatOptions(options) {
27
+ if (!options) {
28
+ return { ...DEFAULT_TIME_FORMAT_OPTIONS };
29
+ }
30
+ return {
31
+ ...DEFAULT_TIME_FORMAT_OPTIONS,
32
+ ...options
33
+ };
34
+ }
35
+ function normalizeDateDisplayOptions(options) {
36
+ if (!options) {
37
+ return { ...DEFAULT_DATE_DISPLAY_OPTIONS };
38
+ }
39
+ return {
40
+ ...DEFAULT_DATE_DISPLAY_OPTIONS,
41
+ ...options
42
+ };
43
+ }
44
+ function normalizeDisplayOptions(options) {
45
+ if (!options) {
46
+ return { ...DEFAULT_DISPLAY_OPTIONS };
47
+ }
48
+ return {
49
+ time: normalizeTimeFormatOptions(options.time),
50
+ date: normalizeDateDisplayOptions(options.date)
51
+ };
52
+ }
53
+ function is12HourLocale(locale) {
54
+ const cached = localeHour12Cache.get(locale);
55
+ if (typeof cached === "boolean") {
56
+ return cached;
57
+ }
58
+ let result = false;
59
+ try {
60
+ const resolved = new Intl.DateTimeFormat(locale, { hour: "numeric" }).resolvedOptions();
61
+ if (typeof resolved.hour12 === "boolean") {
62
+ result = resolved.hour12;
63
+ localeHour12Cache.set(locale, result);
64
+ return result;
65
+ }
66
+ if (resolved.hourCycle) {
67
+ result = resolved.hourCycle === "h11" || resolved.hourCycle === "h12";
68
+ localeHour12Cache.set(locale, result);
69
+ return result;
70
+ }
71
+ } catch {
72
+ }
73
+ const testDate = new Date(Date.UTC(2e3, 0, 1, 13, 0, 0));
74
+ try {
75
+ const parts = new Intl.DateTimeFormat(locale, {
76
+ hour: "numeric",
77
+ minute: "2-digit"
78
+ }).formatToParts(testDate);
79
+ result = parts.some((part) => part.type === "dayPeriod");
80
+ localeHour12Cache.set(locale, result);
81
+ return result;
82
+ } catch {
83
+ const formatted = testDate.toLocaleTimeString(locale, { hour: "numeric", minute: "2-digit" });
84
+ result = /(^|\s)[AP]\.?M\.?($|\s)/i.test(formatted);
85
+ localeHour12Cache.set(locale, result);
86
+ return result;
87
+ }
88
+ }
89
+ function getEffectiveTimeFormat(format, locale) {
90
+ if (format === "auto") {
91
+ return is12HourLocale(locale) ? "12h" : "24h";
92
+ }
93
+ return format;
94
+ }
95
+ function getDateTimeFormatter(locale, options) {
96
+ const normalizedOptions = Object.keys(options).sort().map((key2) => `${key2}:${String(options[key2])}`).join("|");
97
+ const key = `${locale}__${normalizedOptions}`;
98
+ const cached = dateTimeFormatterCache.get(key);
99
+ if (cached) {
100
+ return cached;
101
+ }
102
+ const formatter = new Intl.DateTimeFormat(locale, options);
103
+ dateTimeFormatterCache.set(key, formatter);
104
+ if (dateTimeFormatterCache.size > DATE_TIME_FORMATTER_CACHE_LIMIT) {
105
+ const oldestKey = dateTimeFormatterCache.keys().next().value;
106
+ if (oldestKey) {
107
+ dateTimeFormatterCache.delete(oldestKey);
108
+ }
109
+ }
110
+ return formatter;
111
+ }
112
+ function isSupportedCalendar(locale, calendar) {
113
+ try {
114
+ const resolved = new Intl.DateTimeFormat(locale, { calendar }).resolvedOptions();
115
+ return resolved.calendar === calendar;
116
+ } catch {
117
+ return false;
118
+ }
119
+ }
120
+ function isSupportedNumberingSystem(locale, numberingSystem) {
121
+ try {
122
+ const resolved = new Intl.DateTimeFormat(locale, { numberingSystem }).resolvedOptions();
123
+ return resolved.numberingSystem === numberingSystem;
124
+ } catch {
125
+ return false;
126
+ }
127
+ }
128
+ function resolveSchedulerCalendarDisplayConfig(input = {}) {
129
+ const locale = input.locale || "en";
130
+ const requestedCalendar = resolveSchedulerCalendarModeForView(input.calendar ?? "gregory", input.view);
131
+ const calendar = requestedCalendar === "locale" ? "locale" : isSupportedCalendar(locale, requestedCalendar) ? requestedCalendar : "gregory";
132
+ const requestedNumberingSystem = input.numberingSystem;
133
+ const numberingSystem = requestedNumberingSystem && requestedNumberingSystem !== "locale" && isSupportedNumberingSystem(locale, requestedNumberingSystem) ? requestedNumberingSystem : void 0;
134
+ return {
135
+ locale,
136
+ calendar,
137
+ numberingSystem,
138
+ timeZone: input.timeZone
139
+ };
140
+ }
141
+ function createCalendarIntlOptions(config, options = {}) {
142
+ const intlOptions = { ...options };
143
+ if (config.calendar !== "locale") {
144
+ intlOptions.calendar = config.calendar;
145
+ }
146
+ if (config.numberingSystem) {
147
+ intlOptions.numberingSystem = config.numberingSystem;
148
+ }
149
+ if (config.timeZone && !intlOptions.timeZone) {
150
+ intlOptions.timeZone = config.timeZone;
151
+ }
152
+ return intlOptions;
153
+ }
154
+ function createNumberFormatter(config) {
155
+ const options = {};
156
+ if (config.numberingSystem) {
157
+ options.numberingSystem = config.numberingSystem;
158
+ }
159
+ return new Intl.NumberFormat(config.locale, options);
160
+ }
161
+ function formatDayPart(formatter, date) {
162
+ const dayPart = formatter.formatToParts(date).find((part) => part.type === "day");
163
+ return dayPart?.value ?? formatter.format(date);
164
+ }
165
+ function formatWeekdayDayParts(formatter, date) {
166
+ const parts = formatter.formatToParts(date).filter((part) => part.type === "day" || part.type === "weekday").map((part) => part.value);
167
+ return parts.length ? parts.join(" ") : formatter.format(date);
168
+ }
169
+ function createSchedulerDateFormatter(input = {}) {
170
+ const config = resolveSchedulerCalendarDisplayConfig(input);
171
+ return {
172
+ config,
173
+ format(date, options = {}) {
174
+ return getDateTimeFormatter(config.locale, createCalendarIntlOptions(config, options)).format(date);
175
+ },
176
+ formatDayNumber(date, format = "numeric") {
177
+ return formatDayPart(getDateTimeFormatter(config.locale, createCalendarIntlOptions(config, { day: format })), date);
178
+ },
179
+ formatWeekdayDayNumber(date, weekday = "short", day = "numeric") {
180
+ return formatWeekdayDayParts(getDateTimeFormatter(config.locale, createCalendarIntlOptions(config, { weekday, day })), date);
181
+ },
182
+ formatWeekday(date, width = "short") {
183
+ return getDateTimeFormatter(config.locale, createCalendarIntlOptions(config, { weekday: width })).format(date);
184
+ },
185
+ formatMonth(date, format = "long") {
186
+ return getDateTimeFormatter(config.locale, createCalendarIntlOptions(config, { month: format })).format(date);
187
+ },
188
+ formatMonthTitle(date, options = {}) {
189
+ return getDateTimeFormatter(config.locale, createCalendarIntlOptions(config, { month: "long", year: "numeric", ...options })).format(date);
190
+ },
191
+ formatYear(date) {
192
+ return getDateTimeFormatter(config.locale, createCalendarIntlOptions(config, { year: "numeric" })).format(date);
193
+ },
194
+ formatNumber(value) {
195
+ return createNumberFormatter(config).format(value);
196
+ }
197
+ };
198
+ }
199
+ function normalizeFormattedTime(value) {
200
+ return value.replace(/\u200e|\u200f/g, "").replace(/\s+/g, " ").trim();
201
+ }
202
+ function formatPartsWithoutDayPeriod(parts) {
203
+ const withoutDayPeriod = parts.filter((part) => part.type !== "dayPeriod");
204
+ const merged = withoutDayPeriod.map((part) => part.value).join("");
205
+ return normalizeFormattedTime(merged);
206
+ }
207
+ function getDisplayMinutes(date, timeZone) {
208
+ if (!timeZone) {
209
+ return date.getMinutes();
210
+ }
211
+ const minuteFormatter = getDateTimeFormatter("en-US", {
212
+ minute: "numeric",
213
+ timeZone
214
+ });
215
+ const parts = minuteFormatter.formatToParts(date);
216
+ const minutePart = parts.find((part) => part.type === "minute")?.value;
217
+ const parsed = Number(minutePart);
218
+ if (Number.isFinite(parsed)) {
219
+ return parsed;
220
+ }
221
+ return date.getMinutes();
222
+ }
223
+ function shouldIncludeMinutes(date, options, timeZone) {
224
+ if (options.showMinutes === "always") {
225
+ return true;
226
+ }
227
+ return getDisplayMinutes(date, timeZone) !== 0;
228
+ }
229
+ function resolveHour12(options, locale, force24HourSlots = false) {
230
+ if (force24HourSlots) {
231
+ return false;
232
+ }
233
+ const effectiveFormat = getEffectiveTimeFormat(options.format, locale);
234
+ return effectiveFormat === "12h";
235
+ }
236
+ function createTimeIntlOptions(hour12, includeMinutes, showSeconds, timeZone) {
237
+ const intlOptions = {
238
+ hour: "numeric",
239
+ hour12
240
+ };
241
+ if (timeZone) {
242
+ intlOptions.timeZone = timeZone;
243
+ }
244
+ if (includeMinutes) {
245
+ intlOptions.minute = "2-digit";
246
+ }
247
+ if (showSeconds) {
248
+ intlOptions.second = "2-digit";
249
+ }
250
+ return intlOptions;
251
+ }
252
+ function formatTimeWithFormatter(date, formatter, hour12, showAMPM) {
253
+ if (hour12 && !showAMPM) {
254
+ return formatPartsWithoutDayPeriod(formatter.formatToParts(date));
255
+ }
256
+ return normalizeFormattedTime(formatter.format(date));
257
+ }
258
+ function formatTimeRangeFull(start, end, locale, options, timeZone) {
259
+ const startTime = formatTime(start, locale, options, timeZone);
260
+ const endTime = formatTime(end, locale, options, timeZone);
261
+ return `${startTime} - ${endTime}`;
262
+ }
263
+ function formatTimeRangeCompact(start, end, locale, options, timeZone) {
264
+ const hour12 = resolveHour12(options, locale);
265
+ const includeMinutes = options.showMinutes === "always" || options.showMinutes === "non-zero" && (getDisplayMinutes(start, timeZone) !== 0 || getDisplayMinutes(end, timeZone) !== 0);
266
+ const intlOptions = createTimeIntlOptions(hour12, includeMinutes, options.showSeconds, timeZone);
267
+ const formatter = getDateTimeFormatter(locale, intlOptions);
268
+ const startTime = formatTimeWithFormatter(start, formatter, hour12, options.showAMPM);
269
+ const endTime = formatTimeWithFormatter(end, formatter, hour12, options.showAMPM);
270
+ if (!hour12 || !options.showAMPM) {
271
+ return `${startTime}-${endTime}`;
272
+ }
273
+ const startParts = formatter.formatToParts(start);
274
+ const endParts = formatter.formatToParts(end);
275
+ const startPeriod = startParts.find((part) => part.type === "dayPeriod")?.value;
276
+ const endPeriod = endParts.find((part) => part.type === "dayPeriod")?.value;
277
+ if (!startPeriod || !endPeriod || startPeriod !== endPeriod) {
278
+ return `${startTime}-${endTime}`;
279
+ }
280
+ const startWithoutPeriod = formatPartsWithoutDayPeriod(startParts);
281
+ const endWithPeriod = normalizeFormattedTime(formatter.format(end));
282
+ return `${startWithoutPeriod}-${endWithPeriod}`;
283
+ }
284
+ function formatTimeRangeLocale(start, end, locale, options, timeZone) {
285
+ const hour12 = resolveHour12(options, locale);
286
+ const includeMinutes = options.showMinutes === "always" || options.showMinutes === "non-zero" && (getDisplayMinutes(start, timeZone) !== 0 || getDisplayMinutes(end, timeZone) !== 0);
287
+ const intlOptions = createTimeIntlOptions(hour12, includeMinutes, options.showSeconds, timeZone);
288
+ const formatter = getDateTimeFormatter(locale, intlOptions);
289
+ if (typeof formatter.formatRange !== "function") {
290
+ return formatTimeRangeFull(start, end, locale, options, timeZone);
291
+ }
292
+ if (hour12 && !options.showAMPM && typeof formatter.formatRangeToParts === "function") {
293
+ const rangeParts = formatter.formatRangeToParts(start, end);
294
+ return formatPartsWithoutDayPeriod(rangeParts);
295
+ }
296
+ if (hour12 && !options.showAMPM) {
297
+ return formatTimeRangeFull(start, end, locale, options, timeZone);
298
+ }
299
+ return normalizeFormattedTime(formatter.formatRange(start, end));
300
+ }
301
+ function __getDateTimeFormatterCacheSize() {
302
+ return dateTimeFormatterCache.size;
303
+ }
304
+ function __clearDateTimeFormatterCache() {
305
+ dateTimeFormatterCache.clear();
306
+ localeHour12Cache.clear();
307
+ }
308
+ function formatTime(date, locale, options, timeZone) {
309
+ const opts = normalizeTimeFormatOptions(options);
310
+ const hour12 = resolveHour12(opts, locale);
311
+ const includeMinutes = shouldIncludeMinutes(date, opts, timeZone);
312
+ const intlOptions = createTimeIntlOptions(hour12, includeMinutes, opts.showSeconds, timeZone);
313
+ const formatter = getDateTimeFormatter(locale, intlOptions);
314
+ return formatTimeWithFormatter(date, formatter, hour12, opts.showAMPM);
315
+ }
316
+ function formatTimeRange(start, end, locale, options, timeZone) {
317
+ const opts = normalizeTimeFormatOptions(options);
318
+ switch (opts.rangeDisplay) {
319
+ case "compact":
320
+ return formatTimeRangeCompact(start, end, locale, opts, timeZone);
321
+ case "locale":
322
+ return formatTimeRangeLocale(start, end, locale, opts, timeZone);
323
+ case "full":
324
+ default:
325
+ return formatTimeRangeFull(start, end, locale, opts, timeZone);
326
+ }
327
+ }
328
+ function formatSlotTime(date, locale, options, timeZone) {
329
+ const opts = normalizeTimeFormatOptions(options);
330
+ const hour12 = resolveHour12(opts, locale, opts.use24HourSlots);
331
+ const includeMinutes = shouldIncludeMinutes(date, opts, timeZone);
332
+ const intlOptions = createTimeIntlOptions(hour12, includeMinutes, opts.showSeconds, timeZone);
333
+ const formatter = getDateTimeFormatter(locale, intlOptions);
334
+ return formatTimeWithFormatter(date, formatter, hour12, opts.showAMPM);
335
+ }
336
+ function getComparisonParts(date, timeZone) {
337
+ if (!timeZone) {
338
+ return {
339
+ year: date.getFullYear(),
340
+ month: date.getMonth(),
341
+ day: date.getDate()
342
+ };
343
+ }
344
+ const parts = getDateTimeFormatter("en-US", {
345
+ year: "numeric",
346
+ month: "numeric",
347
+ day: "numeric",
348
+ timeZone
349
+ }).formatToParts(date);
350
+ const getValue = (type) => {
351
+ const value = parts.find((part) => part.type === type)?.value;
352
+ const parsed = value ? Number(value) : NaN;
353
+ return Number.isFinite(parsed) ? parsed : 0;
354
+ };
355
+ return {
356
+ year: getValue("year"),
357
+ month: getValue("month") - 1,
358
+ day: getValue("day")
359
+ };
360
+ }
361
+ function isSameYear(date, reference, timeZone) {
362
+ return getComparisonParts(date, timeZone).year === getComparisonParts(reference, timeZone).year;
363
+ }
364
+ function isSameCalendarDay(date, reference, timeZone) {
365
+ const left = getComparisonParts(date, timeZone);
366
+ const right = getComparisonParts(reference, timeZone);
367
+ return left.year === right.year && left.month === right.month && left.day === right.day;
368
+ }
369
+ function isToday(date, timeZone) {
370
+ const today = /* @__PURE__ */ new Date();
371
+ return isSameCalendarDay(date, today, timeZone);
372
+ }
373
+ function isTomorrow(date, timeZone) {
374
+ const tomorrow = /* @__PURE__ */ new Date();
375
+ tomorrow.setDate(tomorrow.getDate() + 1);
376
+ return isSameCalendarDay(date, tomorrow, timeZone);
377
+ }
378
+ function isYesterday(date, timeZone) {
379
+ const yesterday = /* @__PURE__ */ new Date();
380
+ yesterday.setDate(yesterday.getDate() - 1);
381
+ return isSameCalendarDay(date, yesterday, timeZone);
382
+ }
383
+ function getRelativeDay(date, locale, timeZone) {
384
+ if (isToday(date, timeZone)) {
385
+ return getRelativeTimeLabel("today", locale);
386
+ }
387
+ if (isTomorrow(date, timeZone)) {
388
+ return getRelativeTimeLabel("tomorrow", locale);
389
+ }
390
+ if (isYesterday(date, timeZone)) {
391
+ return getRelativeTimeLabel("yesterday", locale);
392
+ }
393
+ return null;
394
+ }
395
+ function getRelativeTimeLabel(key, locale) {
396
+ const labels = {
397
+ en: { today: "Today", tomorrow: "Tomorrow", yesterday: "Yesterday" },
398
+ es: { today: "Hoy", tomorrow: "Ma\xF1ana", yesterday: "Ayer" },
399
+ fr: { today: "Aujourd'hui", tomorrow: "Demain", yesterday: "Hier" },
400
+ de: { today: "Heute", tomorrow: "Morgen", yesterday: "Gestern" },
401
+ it: { today: "Oggi", tomorrow: "Domani", yesterday: "Ieri" },
402
+ pt: { today: "Hoje", tomorrow: "Amanh\xE3", yesterday: "Ontem" },
403
+ ja: { today: "\u4ECA\u65E5", tomorrow: "\u660E\u65E5", yesterday: "\u6628\u65E5" },
404
+ zh: { today: "\u4ECA\u5929", tomorrow: "\u660E\u5929", yesterday: "\u6628\u5929" },
405
+ ko: { today: "\uC624\uB298", tomorrow: "\uB0B4\uC77C", yesterday: "\uC5B4\uC81C" },
406
+ ru: { today: "\u0421\u0435\u0433\u043E\u0434\u043D\u044F", tomorrow: "\u0417\u0430\u0432\u0442\u0440\u0430", yesterday: "\u0412\u0447\u0435\u0440\u0430" },
407
+ ar: { today: "\u0627\u0644\u064A\u0648\u0645", tomorrow: "\u063A\u062F\u0627\u064B", yesterday: "\u0623\u0645\u0633" },
408
+ tr: { today: "Bug\xFCn", tomorrow: "Yar\u0131n", yesterday: "D\xFCn" }
409
+ };
410
+ const langCode = locale.split("-")[0].toLowerCase();
411
+ return labels[langCode]?.[key] ?? labels.en[key];
412
+ }
413
+ function getSchedulerDisplayFormatter(locale, timeZone, displayConfig) {
414
+ return createSchedulerDateFormatter({
415
+ ...displayConfig,
416
+ locale,
417
+ timeZone
418
+ });
419
+ }
420
+ function formatDate(date, locale, options, timeZone, displayConfig) {
421
+ const opts = normalizeDateDisplayOptions(options);
422
+ const formatter = getSchedulerDisplayFormatter(locale, timeZone, displayConfig);
423
+ if (opts.relativeTime) {
424
+ const relativeDay = getRelativeDay(date, locale, timeZone);
425
+ if (relativeDay) {
426
+ return relativeDay;
427
+ }
428
+ }
429
+ const formatOptions = {
430
+ day: opts.dayFormat,
431
+ month: opts.monthFormat
432
+ };
433
+ if (timeZone) {
434
+ formatOptions.timeZone = timeZone;
435
+ }
436
+ if (opts.weekdayFormat) {
437
+ formatOptions.weekday = opts.weekdayFormat;
438
+ }
439
+ const now = /* @__PURE__ */ new Date();
440
+ if (opts.showYear === "always" || opts.showYear === "different" && !isSameYear(date, now, timeZone)) {
441
+ formatOptions.year = "numeric";
442
+ }
443
+ return formatter.format(date, formatOptions);
444
+ }
445
+ function formatWeekday(date, locale, format = "short", timeZone, displayConfig) {
446
+ return getSchedulerDisplayFormatter(locale, timeZone, displayConfig).formatWeekday(date, format);
447
+ }
448
+ function formatMonth(date, locale, format = "long", timeZone, displayConfig) {
449
+ return getSchedulerDisplayFormatter(locale, timeZone, displayConfig).formatMonth(date, format);
450
+ }
451
+ function formatDayOfMonth(date, locale, format = "numeric", timeZone, displayConfig) {
452
+ return getSchedulerDisplayFormatter(locale, timeZone, displayConfig).formatDayNumber(date, format);
453
+ }
454
+ function formatMonthYear(date, locale, options, timeZone, displayConfig) {
455
+ const opts = normalizeDateDisplayOptions(options);
456
+ const formatter = getSchedulerDisplayFormatter(locale, timeZone, displayConfig);
457
+ return formatter.format(date, {
458
+ month: opts.monthFormat,
459
+ year: "numeric"
460
+ });
461
+ }
462
+ function formatDateRange(start, end, locale, options, timeZone, displayConfig) {
463
+ const opts = normalizeDateDisplayOptions(options);
464
+ const formatter = getSchedulerDisplayFormatter(locale, timeZone, displayConfig);
465
+ const startParts = getComparisonParts(start, timeZone);
466
+ const endParts = getComparisonParts(end, timeZone);
467
+ const sameMonth = startParts.month === endParts.month && startParts.year === endParts.year;
468
+ const sameYear = startParts.year === endParts.year;
469
+ if (sameMonth) {
470
+ const startDay = formatDayOfMonth(start, locale, opts.dayFormat, timeZone, displayConfig);
471
+ const endFormatted2 = formatDate(end, locale, { ...opts, weekdayFormat: void 0 }, timeZone, displayConfig);
472
+ return `${startDay} - ${endFormatted2}`;
473
+ }
474
+ if (sameYear) {
475
+ const startFormatted2 = formatter.format(start, {
476
+ day: opts.dayFormat,
477
+ month: opts.monthFormat
478
+ });
479
+ const endFormatted2 = formatDate(end, locale, { ...opts, weekdayFormat: void 0 }, timeZone, displayConfig);
480
+ return `${startFormatted2} - ${endFormatted2}`;
481
+ }
482
+ const startFormatted = formatDate(start, locale, { ...opts, showYear: "always", weekdayFormat: void 0 }, timeZone, displayConfig);
483
+ const endFormatted = formatDate(end, locale, { ...opts, showYear: "always", weekdayFormat: void 0 }, timeZone, displayConfig);
484
+ return `${startFormatted} - ${endFormatted}`;
485
+ }
486
+ function formatEventDateTime(event, locale, displayOptions, timeZone, displayConfig) {
487
+ const opts = normalizeDisplayOptions(displayOptions);
488
+ const start = typeof event.start === "string" ? new Date(event.start) : event.start;
489
+ const end = event.end ? typeof event.end === "string" ? new Date(event.end) : event.end : start;
490
+ if (event.allDay) {
491
+ const sameDay2 = isSameCalendarDay(start, end, timeZone);
492
+ if (sameDay2) {
493
+ return formatDate(start, locale, opts.date, timeZone, displayConfig);
494
+ }
495
+ return formatDateRange(start, end, locale, opts.date, timeZone, displayConfig);
496
+ }
497
+ const sameDay = isSameCalendarDay(start, end, timeZone);
498
+ if (sameDay) {
499
+ const dateStr = formatDate(start, locale, opts.date, timeZone, displayConfig);
500
+ const timeRange = formatTimeRange(start, end, locale, opts.time, timeZone);
501
+ return `${dateStr}, ${timeRange}`;
502
+ }
503
+ const startStr = `${formatDate(start, locale, opts.date, timeZone, displayConfig)}, ${formatTime(start, locale, opts.time, timeZone)}`;
504
+ const endStr = `${formatDate(end, locale, opts.date, timeZone, displayConfig)}, ${formatTime(end, locale, opts.time, timeZone)}`;
505
+ return `${startStr} - ${endStr}`;
506
+ }
507
+ function getHeaderCalendarAdapter(locale, view, displayConfig) {
508
+ const calendar = resolveSchedulerCalendarModeForView(displayConfig?.calendar ?? "gregory", view);
509
+ return getSchedulerCalendarAdapter(calendar, { locale });
510
+ }
511
+ function toHeaderDate(adapter, date) {
512
+ return adapter.toDate(date);
513
+ }
514
+ function formatHeaderTitle(date, view, locale, options, context, timeZone, displayConfig) {
515
+ const opts = normalizeDateDisplayOptions(options);
516
+ const viewDisplayConfig = { ...displayConfig, view };
517
+ const formatter = getSchedulerDisplayFormatter(locale, timeZone, viewDisplayConfig);
518
+ switch (view) {
519
+ case "month":
520
+ case "resourceMonth":
521
+ case "dateMonth":
522
+ case "timelineMonth":
523
+ case "resourceTimelineMonth":
524
+ return formatMonthYear(date, locale, opts, timeZone, viewDisplayConfig);
525
+ case "week":
526
+ case "resourceWeek":
527
+ case "dateWeek":
528
+ case "timelineWeek":
529
+ case "resourceTimelineWeek": {
530
+ const fdow = context?.firstDayOfWeek ?? 0;
531
+ const adapter = getHeaderCalendarAdapter(locale, view, viewDisplayConfig);
532
+ const weekStart = adapter.startOfWeek(adapter.fromDate(date), fdow);
533
+ const weekEnd = adapter.add(weekStart, { days: 6 });
534
+ const activeDays = context?.daysOfWeek?.filter((day) => Number.isInteger(day) && day >= 0 && day <= 6);
535
+ if (!activeDays || activeDays.length === 0 || activeDays.length === 7) {
536
+ return formatDateRange(toHeaderDate(adapter, weekStart), toHeaderDate(adapter, weekEnd), locale, { ...opts, weekdayFormat: void 0 }, timeZone, viewDisplayConfig);
537
+ }
538
+ let firstVisible = null;
539
+ let lastVisible = null;
540
+ for (let i = 0; i < 7; i++) {
541
+ const calendarDate = adapter.add(weekStart, { days: i });
542
+ const d = toHeaderDate(adapter, calendarDate);
543
+ if (activeDays.includes(adapter.getDayOfWeek(calendarDate))) {
544
+ if (!firstVisible) firstVisible = d;
545
+ lastVisible = d;
546
+ }
547
+ }
548
+ if (!firstVisible || !lastVisible) {
549
+ return formatMonthYear(date, locale, opts, timeZone, viewDisplayConfig);
550
+ }
551
+ return formatDateRange(firstVisible, lastVisible, locale, { ...opts, weekdayFormat: void 0 }, timeZone, viewDisplayConfig);
552
+ }
553
+ case "day":
554
+ case "resourceDay":
555
+ case "dateDay":
556
+ case "timelineDay":
557
+ case "resourceTimelineDay":
558
+ return formatDate(date, locale, { ...opts, showYear: "always" }, timeZone, viewDisplayConfig);
559
+ case "year":
560
+ case "timelineYear":
561
+ return formatter.formatYear(date);
562
+ case "agenda":
563
+ return formatMonthYear(date, locale, opts, timeZone, viewDisplayConfig);
564
+ default:
565
+ return formatDate(date, locale, opts, timeZone, viewDisplayConfig);
566
+ }
567
+ }
568
+
569
+ export { DEFAULT_DATE_DISPLAY_OPTIONS, DEFAULT_DISPLAY_OPTIONS, DEFAULT_TIME_FORMAT_OPTIONS, __clearDateTimeFormatterCache, __getDateTimeFormatterCacheSize, createSchedulerDateFormatter, formatDate, formatDateRange, formatDayOfMonth, formatEventDateTime, formatHeaderTitle, formatMonth, formatMonthYear, formatSlotTime, formatTime, formatTimeRange, formatWeekday, getRelativeDay, normalizeDateDisplayOptions, normalizeDisplayOptions, normalizeTimeFormatOptions, resolveSchedulerCalendarDisplayConfig };
@@ -0,0 +1 @@
1
+