@helsenorge/datepicker 10.1.0 → 10.2.0

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.
@@ -1,6 +1,6 @@
1
1
  import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
2
  import React, { createContext, useContext, useState, useEffect, useMemo, useCallback, useRef } from "react";
3
- import { addDays, addMonths, addWeeks, addYears, differenceInCalendarDays, differenceInCalendarMonths, endOfISOWeek, endOfMonth, endOfWeek, endOfYear, format, getISOWeek, getWeek, isAfter, isBefore, isDate, isSameDay, isSameMonth, isSameYear, max, min, setMonth, setYear, startOfDay, startOfISOWeek, startOfMonth, startOfWeek, startOfYear, isValid, parse, isWithinInterval } from "date-fns";
3
+ import { addDays, addMonths, addWeeks, addYears, differenceInCalendarDays, differenceInCalendarMonths, eachMonthOfInterval, endOfISOWeek, endOfMonth, endOfWeek, endOfYear, format, getISOWeek, getMonth, getYear, getWeek, isAfter, isBefore, isDate, isSameDay, isSameMonth, isSameYear, max, min, setMonth, setYear, startOfDay, startOfISOWeek, startOfMonth, startOfWeek, startOfYear, isValid, parse, isWithinInterval } from "date-fns";
4
4
  import { enUS, nb } from "date-fns/locale";
5
5
  import Button$1 from "@helsenorge/designsystem-react/components/Button";
6
6
  import Icon from "@helsenorge/designsystem-react/components/Icon";
@@ -67,6 +67,206 @@ var SelectionState;
67
67
  SelectionState2["range_start"] = "range_start";
68
68
  SelectionState2["selected"] = "selected";
69
69
  })(SelectionState || (SelectionState = {}));
70
+ const offsetFormatCache = {};
71
+ const offsetCache = {};
72
+ function tzOffset(timeZone, date) {
73
+ try {
74
+ const format2 = offsetFormatCache[timeZone] || (offsetFormatCache[timeZone] = new Intl.DateTimeFormat("en-GB", {
75
+ timeZone,
76
+ hour: "numeric",
77
+ timeZoneName: "longOffset"
78
+ }).format);
79
+ const offsetStr = format2(date).split("GMT")[1] || "";
80
+ if (offsetStr in offsetCache) return offsetCache[offsetStr];
81
+ return calcOffset(offsetStr, offsetStr.split(":"));
82
+ } catch {
83
+ if (timeZone in offsetCache) return offsetCache[timeZone];
84
+ const captures = timeZone == null ? void 0 : timeZone.match(offsetRe);
85
+ if (captures) return calcOffset(timeZone, captures.slice(1));
86
+ return NaN;
87
+ }
88
+ }
89
+ const offsetRe = /([+-]\d\d):?(\d\d)?/;
90
+ function calcOffset(cacheStr, values) {
91
+ const hours = +values[0];
92
+ const minutes = +(values[1] || 0);
93
+ return offsetCache[cacheStr] = hours > 0 ? hours * 60 + minutes : hours * 60 - minutes;
94
+ }
95
+ class TZDateMini extends Date {
96
+ //#region static
97
+ constructor(...args) {
98
+ super();
99
+ if (args.length > 1 && typeof args[args.length - 1] === "string") {
100
+ this.timeZone = args.pop();
101
+ }
102
+ this.internal = /* @__PURE__ */ new Date();
103
+ if (isNaN(tzOffset(this.timeZone, this))) {
104
+ this.setTime(NaN);
105
+ } else {
106
+ if (!args.length) {
107
+ this.setTime(Date.now());
108
+ } else if (typeof args[0] === "number" && (args.length === 1 || args.length === 2 && typeof args[1] !== "number")) {
109
+ this.setTime(args[0]);
110
+ } else if (typeof args[0] === "string") {
111
+ this.setTime(+new Date(args[0]));
112
+ } else if (args[0] instanceof Date) {
113
+ this.setTime(+args[0]);
114
+ } else {
115
+ this.setTime(+new Date(...args));
116
+ adjustToSystemTZ(this);
117
+ syncToInternal(this);
118
+ }
119
+ }
120
+ }
121
+ static tz(tz, ...args) {
122
+ return args.length ? new TZDateMini(...args, tz) : new TZDateMini(Date.now(), tz);
123
+ }
124
+ //#endregion
125
+ //#region time zone
126
+ withTimeZone(timeZone) {
127
+ return new TZDateMini(+this, timeZone);
128
+ }
129
+ getTimezoneOffset() {
130
+ return -tzOffset(this.timeZone, this);
131
+ }
132
+ //#endregion
133
+ //#region time
134
+ setTime(time) {
135
+ Date.prototype.setTime.apply(this, arguments);
136
+ syncToInternal(this);
137
+ return +this;
138
+ }
139
+ //#endregion
140
+ //#region date-fns integration
141
+ [Symbol.for("constructDateFrom")](date) {
142
+ return new TZDateMini(+new Date(date), this.timeZone);
143
+ }
144
+ //#endregion
145
+ }
146
+ const re = /^(get|set)(?!UTC)/;
147
+ Object.getOwnPropertyNames(Date.prototype).forEach((method) => {
148
+ if (!re.test(method)) return;
149
+ const utcMethod = method.replace(re, "$1UTC");
150
+ if (!TZDateMini.prototype[utcMethod]) return;
151
+ if (method.startsWith("get")) {
152
+ TZDateMini.prototype[method] = function() {
153
+ return this.internal[utcMethod]();
154
+ };
155
+ } else {
156
+ TZDateMini.prototype[method] = function() {
157
+ Date.prototype[utcMethod].apply(this.internal, arguments);
158
+ syncFromInternal(this);
159
+ return +this;
160
+ };
161
+ TZDateMini.prototype[utcMethod] = function() {
162
+ Date.prototype[utcMethod].apply(this, arguments);
163
+ syncToInternal(this);
164
+ return +this;
165
+ };
166
+ }
167
+ });
168
+ function syncToInternal(date) {
169
+ date.internal.setTime(+date);
170
+ date.internal.setUTCMinutes(date.internal.getUTCMinutes() - date.getTimezoneOffset());
171
+ }
172
+ function syncFromInternal(date) {
173
+ Date.prototype.setFullYear.call(date, date.internal.getUTCFullYear(), date.internal.getUTCMonth(), date.internal.getUTCDate());
174
+ Date.prototype.setHours.call(date, date.internal.getUTCHours(), date.internal.getUTCMinutes(), date.internal.getUTCSeconds(), date.internal.getUTCMilliseconds());
175
+ adjustToSystemTZ(date);
176
+ }
177
+ function adjustToSystemTZ(date) {
178
+ const offset = tzOffset(date.timeZone, date);
179
+ const prevHour = /* @__PURE__ */ new Date(+date);
180
+ prevHour.setUTCHours(prevHour.getUTCHours() - 1);
181
+ const systemOffset = -(/* @__PURE__ */ new Date(+date)).getTimezoneOffset();
182
+ const prevHourSystemOffset = -(/* @__PURE__ */ new Date(+prevHour)).getTimezoneOffset();
183
+ const systemDSTChange = systemOffset - prevHourSystemOffset;
184
+ const dstShift = Date.prototype.getHours.apply(date) !== date.internal.getUTCHours();
185
+ if (systemDSTChange && dstShift) date.internal.setUTCMinutes(date.internal.getUTCMinutes() + systemDSTChange);
186
+ const offsetDiff = systemOffset - offset;
187
+ if (offsetDiff) Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + offsetDiff);
188
+ const postOffset = tzOffset(date.timeZone, date);
189
+ const postSystemOffset = -(/* @__PURE__ */ new Date(+date)).getTimezoneOffset();
190
+ const postOffsetDiff = postSystemOffset - postOffset;
191
+ const offsetChanged = postOffset !== offset;
192
+ const postDiff = postOffsetDiff - offsetDiff;
193
+ if (offsetChanged && postDiff) {
194
+ Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + postDiff);
195
+ const newOffset = tzOffset(date.timeZone, date);
196
+ const offsetChange = postOffset - newOffset;
197
+ if (offsetChange) {
198
+ date.internal.setUTCMinutes(date.internal.getUTCMinutes() + offsetChange);
199
+ Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + offsetChange);
200
+ }
201
+ }
202
+ }
203
+ class TZDate extends TZDateMini {
204
+ //#region static
205
+ static tz(tz, ...args) {
206
+ return args.length ? new TZDate(...args, tz) : new TZDate(Date.now(), tz);
207
+ }
208
+ //#endregion
209
+ //#region representation
210
+ toISOString() {
211
+ const [sign, hours, minutes] = this.tzComponents();
212
+ const tz = `${sign}${hours}:${minutes}`;
213
+ return this.internal.toISOString().slice(0, -1) + tz;
214
+ }
215
+ toString() {
216
+ return `${this.toDateString()} ${this.toTimeString()}`;
217
+ }
218
+ toDateString() {
219
+ const [day, date, month, year] = this.internal.toUTCString().split(" ");
220
+ return `${day == null ? void 0 : day.slice(0, -1)} ${month} ${date} ${year}`;
221
+ }
222
+ toTimeString() {
223
+ const time = this.internal.toUTCString().split(" ")[4];
224
+ const [sign, hours, minutes] = this.tzComponents();
225
+ return `${time} GMT${sign}${hours}${minutes} (${tzName(this.timeZone, this)})`;
226
+ }
227
+ toLocaleString(locales, options) {
228
+ return Date.prototype.toLocaleString.call(this, locales, {
229
+ ...options,
230
+ timeZone: (options == null ? void 0 : options.timeZone) || this.timeZone
231
+ });
232
+ }
233
+ toLocaleDateString(locales, options) {
234
+ return Date.prototype.toLocaleDateString.call(this, locales, {
235
+ ...options,
236
+ timeZone: (options == null ? void 0 : options.timeZone) || this.timeZone
237
+ });
238
+ }
239
+ toLocaleTimeString(locales, options) {
240
+ return Date.prototype.toLocaleTimeString.call(this, locales, {
241
+ ...options,
242
+ timeZone: (options == null ? void 0 : options.timeZone) || this.timeZone
243
+ });
244
+ }
245
+ //#endregion
246
+ //#region private
247
+ tzComponents() {
248
+ const offset = this.getTimezoneOffset();
249
+ const sign = offset > 0 ? "-" : "+";
250
+ const hours = String(Math.floor(Math.abs(offset) / 60)).padStart(2, "0");
251
+ const minutes = String(Math.abs(offset) % 60).padStart(2, "0");
252
+ return [sign, hours, minutes];
253
+ }
254
+ //#endregion
255
+ withTimeZone(timeZone) {
256
+ return new TZDate(+this, timeZone);
257
+ }
258
+ //#region date-fns integration
259
+ [Symbol.for("constructDateFrom")](date) {
260
+ return new TZDate(+new Date(date), this.timeZone);
261
+ }
262
+ //#endregion
263
+ }
264
+ function tzName(tz, date) {
265
+ return new Intl.DateTimeFormat("en-GB", {
266
+ timeZone: tz,
267
+ timeZoneName: "long"
268
+ }).format(date).slice(12);
269
+ }
70
270
  const FIVE_WEEKS = 5;
71
271
  const FOUR_WEEKS = 4;
72
272
  function getBroadcastWeeksInMonth(month, dateLib) {
@@ -74,7 +274,7 @@ function getBroadcastWeeksInMonth(month, dateLib) {
74
274
  const firstDayOfWeek = firstDayOfMonth.getDay() > 0 ? firstDayOfMonth.getDay() : 7;
75
275
  const broadcastStartDate = dateLib.addDays(month, -firstDayOfWeek + 1);
76
276
  const lastDateOfLastWeek = dateLib.addDays(broadcastStartDate, FIVE_WEEKS * 7 - 1);
77
- const numberOfWeeks = month.getMonth() === lastDateOfLastWeek.getMonth() ? FIVE_WEEKS : FOUR_WEEKS;
277
+ const numberOfWeeks = dateLib.getMonth(month) === dateLib.getMonth(lastDateOfLastWeek) ? FIVE_WEEKS : FOUR_WEEKS;
78
278
  return numberOfWeeks;
79
279
  }
80
280
  function startOfBroadcastWeek(date, dateLib) {
@@ -103,129 +303,200 @@ class DateLib {
103
303
  */
104
304
  constructor(options, overrides) {
105
305
  this.Date = Date;
106
- this.addDays = (date, amount) => {
306
+ this.today = () => {
107
307
  var _a;
108
- return ((_a = this.overrides) == null ? void 0 : _a.addDays) ? this.overrides.addDays(date, amount) : addDays(date, amount);
308
+ if ((_a = this.overrides) == null ? void 0 : _a.today) {
309
+ return this.overrides.today();
310
+ }
311
+ if (this.options.timeZone) {
312
+ return TZDate.tz(this.options.timeZone);
313
+ }
314
+ return new this.Date();
109
315
  };
110
- this.addMonths = (date, amount) => {
316
+ this.newDate = (year, monthIndex, date) => {
111
317
  var _a;
112
- return ((_a = this.overrides) == null ? void 0 : _a.addMonths) ? this.overrides.addMonths(date, amount) : addMonths(date, amount);
318
+ if ((_a = this.overrides) == null ? void 0 : _a.newDate) {
319
+ return this.overrides.newDate(year, monthIndex, date);
320
+ }
321
+ if (this.options.timeZone) {
322
+ return new TZDate(year, monthIndex, date, this.options.timeZone);
323
+ }
324
+ return new Date(year, monthIndex, date);
325
+ };
326
+ this.addDays = (date, amount) => {
327
+ var _a, _b;
328
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.addDays) == null ? void 0 : _b.call(_a, date, amount)) ?? addDays(date, amount);
329
+ };
330
+ this.addMonths = (date, amount) => {
331
+ var _a, _b;
332
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.addMonths) == null ? void 0 : _b.call(_a, date, amount)) ?? addMonths(date, amount);
113
333
  };
114
334
  this.addWeeks = (date, amount) => {
115
- var _a;
116
- return ((_a = this.overrides) == null ? void 0 : _a.addWeeks) ? this.overrides.addWeeks(date, amount) : addWeeks(date, amount);
335
+ var _a, _b;
336
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.addWeeks) == null ? void 0 : _b.call(_a, date, amount)) ?? addWeeks(date, amount);
117
337
  };
118
338
  this.addYears = (date, amount) => {
119
- var _a;
120
- return ((_a = this.overrides) == null ? void 0 : _a.addYears) ? this.overrides.addYears(date, amount) : addYears(date, amount);
339
+ var _a, _b;
340
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.addYears) == null ? void 0 : _b.call(_a, date, amount)) ?? addYears(date, amount);
121
341
  };
122
342
  this.differenceInCalendarDays = (dateLeft, dateRight) => {
123
- var _a;
124
- return ((_a = this.overrides) == null ? void 0 : _a.differenceInCalendarDays) ? this.overrides.differenceInCalendarDays(dateLeft, dateRight) : differenceInCalendarDays(dateLeft, dateRight);
343
+ var _a, _b;
344
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.differenceInCalendarDays) == null ? void 0 : _b.call(_a, dateLeft, dateRight)) ?? differenceInCalendarDays(dateLeft, dateRight);
125
345
  };
126
346
  this.differenceInCalendarMonths = (dateLeft, dateRight) => {
127
- var _a;
128
- return ((_a = this.overrides) == null ? void 0 : _a.differenceInCalendarMonths) ? this.overrides.differenceInCalendarMonths(dateLeft, dateRight) : differenceInCalendarMonths(dateLeft, dateRight);
347
+ var _a, _b;
348
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.differenceInCalendarMonths) == null ? void 0 : _b.call(_a, dateLeft, dateRight)) ?? differenceInCalendarMonths(dateLeft, dateRight);
129
349
  };
130
- this.endOfBroadcastWeek = (date) => {
131
- var _a;
132
- return ((_a = this.overrides) == null ? void 0 : _a.endOfBroadcastWeek) ? this.overrides.endOfBroadcastWeek(date, this) : endOfBroadcastWeek(date, this);
350
+ this.eachMonthOfInterval = (interval) => {
351
+ var _a, _b;
352
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.eachMonthOfInterval) == null ? void 0 : _b.call(_a, interval)) ?? eachMonthOfInterval(interval);
353
+ };
354
+ this.endOfBroadcastWeek = (date, dateLib) => {
355
+ var _a, _b;
356
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.endOfBroadcastWeek) == null ? void 0 : _b.call(_a, date, dateLib)) ?? endOfBroadcastWeek(date, this);
133
357
  };
134
358
  this.endOfISOWeek = (date) => {
135
- var _a;
136
- return ((_a = this.overrides) == null ? void 0 : _a.endOfISOWeek) ? this.overrides.endOfISOWeek(date) : endOfISOWeek(date);
359
+ var _a, _b;
360
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.endOfISOWeek) == null ? void 0 : _b.call(_a, date)) ?? endOfISOWeek(date);
137
361
  };
138
362
  this.endOfMonth = (date) => {
139
- var _a;
140
- return ((_a = this.overrides) == null ? void 0 : _a.endOfMonth) ? this.overrides.endOfMonth(date) : endOfMonth(date);
363
+ var _a, _b;
364
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.endOfMonth) == null ? void 0 : _b.call(_a, date)) ?? endOfMonth(date);
141
365
  };
142
- this.endOfWeek = (date) => {
143
- var _a;
144
- return ((_a = this.overrides) == null ? void 0 : _a.endOfWeek) ? this.overrides.endOfWeek(date, this.options) : endOfWeek(date, this.options);
366
+ this.endOfWeek = (date, options2) => {
367
+ var _a, _b;
368
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.endOfWeek) == null ? void 0 : _b.call(_a, date, options2 ?? this.options)) ?? endOfWeek(date, options2 ?? this.options);
145
369
  };
146
370
  this.endOfYear = (date) => {
147
- var _a;
148
- return ((_a = this.overrides) == null ? void 0 : _a.endOfYear) ? this.overrides.endOfYear(date) : endOfYear(date);
371
+ var _a, _b;
372
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.endOfYear) == null ? void 0 : _b.call(_a, date)) ?? endOfYear(date);
149
373
  };
150
- this.format = (date, formatStr) => {
151
- var _a;
152
- return ((_a = this.overrides) == null ? void 0 : _a.format) ? this.overrides.format(date, formatStr, this.options) : format(date, formatStr, this.options);
374
+ this.format = (date, formatStr, options2) => {
375
+ var _a, _b;
376
+ const formatted = ((_b = (_a = this.overrides) == null ? void 0 : _a.format) == null ? void 0 : _b.call(_a, date, formatStr, options2 ?? this.options)) ?? format(date, formatStr, options2 ?? this.options);
377
+ if (this.options.numerals && this.options.numerals !== "latn") {
378
+ return this.replaceDigits(formatted);
379
+ }
380
+ return formatted;
153
381
  };
154
382
  this.getISOWeek = (date) => {
155
- var _a;
156
- return ((_a = this.overrides) == null ? void 0 : _a.getISOWeek) ? this.overrides.getISOWeek(date) : getISOWeek(date);
383
+ var _a, _b;
384
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.getISOWeek) == null ? void 0 : _b.call(_a, date)) ?? getISOWeek(date);
157
385
  };
158
- this.getWeek = (date) => {
159
- var _a;
160
- return ((_a = this.overrides) == null ? void 0 : _a.getWeek) ? this.overrides.getWeek(date, this.options) : getWeek(date, this.options);
386
+ this.getMonth = (date) => {
387
+ var _a, _b;
388
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.getMonth) == null ? void 0 : _b.call(_a, date)) ?? getMonth(date);
389
+ };
390
+ this.getYear = (date) => {
391
+ var _a, _b;
392
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.getYear) == null ? void 0 : _b.call(_a, date)) ?? getYear(date);
393
+ };
394
+ this.getWeek = (date, options2) => {
395
+ var _a, _b;
396
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.getWeek) == null ? void 0 : _b.call(_a, date, options2 ?? this.options)) ?? getWeek(date, options2 ?? this.options);
161
397
  };
162
398
  this.isAfter = (date, dateToCompare) => {
163
- var _a;
164
- return ((_a = this.overrides) == null ? void 0 : _a.isAfter) ? this.overrides.isAfter(date, dateToCompare) : isAfter(date, dateToCompare);
399
+ var _a, _b;
400
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.isAfter) == null ? void 0 : _b.call(_a, date, dateToCompare)) ?? isAfter(date, dateToCompare);
165
401
  };
166
402
  this.isBefore = (date, dateToCompare) => {
167
- var _a;
168
- return ((_a = this.overrides) == null ? void 0 : _a.isBefore) ? this.overrides.isBefore(date, dateToCompare) : isBefore(date, dateToCompare);
403
+ var _a, _b;
404
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.isBefore) == null ? void 0 : _b.call(_a, date, dateToCompare)) ?? isBefore(date, dateToCompare);
169
405
  };
170
406
  this.isDate = (value) => {
171
- var _a;
172
- return ((_a = this.overrides) == null ? void 0 : _a.isDate) ? this.overrides.isDate(value) : isDate(value);
407
+ var _a, _b;
408
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.isDate) == null ? void 0 : _b.call(_a, value)) ?? isDate(value);
173
409
  };
174
410
  this.isSameDay = (dateLeft, dateRight) => {
175
- var _a;
176
- return ((_a = this.overrides) == null ? void 0 : _a.isSameDay) ? this.overrides.isSameDay(dateLeft, dateRight) : isSameDay(dateLeft, dateRight);
411
+ var _a, _b;
412
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.isSameDay) == null ? void 0 : _b.call(_a, dateLeft, dateRight)) ?? isSameDay(dateLeft, dateRight);
177
413
  };
178
414
  this.isSameMonth = (dateLeft, dateRight) => {
179
- var _a;
180
- return ((_a = this.overrides) == null ? void 0 : _a.isSameMonth) ? this.overrides.isSameMonth(dateLeft, dateRight) : isSameMonth(dateLeft, dateRight);
415
+ var _a, _b;
416
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.isSameMonth) == null ? void 0 : _b.call(_a, dateLeft, dateRight)) ?? isSameMonth(dateLeft, dateRight);
181
417
  };
182
418
  this.isSameYear = (dateLeft, dateRight) => {
183
- var _a;
184
- return ((_a = this.overrides) == null ? void 0 : _a.isSameYear) ? this.overrides.isSameYear(dateLeft, dateRight) : isSameYear(dateLeft, dateRight);
419
+ var _a, _b;
420
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.isSameYear) == null ? void 0 : _b.call(_a, dateLeft, dateRight)) ?? isSameYear(dateLeft, dateRight);
185
421
  };
186
422
  this.max = (dates) => {
187
- var _a;
188
- return ((_a = this.overrides) == null ? void 0 : _a.max) ? this.overrides.max(dates) : max(dates);
423
+ var _a, _b;
424
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.max) == null ? void 0 : _b.call(_a, dates)) ?? max(dates);
189
425
  };
190
426
  this.min = (dates) => {
191
- var _a;
192
- return ((_a = this.overrides) == null ? void 0 : _a.min) ? this.overrides.min(dates) : min(dates);
427
+ var _a, _b;
428
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.min) == null ? void 0 : _b.call(_a, dates)) ?? min(dates);
193
429
  };
194
430
  this.setMonth = (date, month) => {
195
- var _a;
196
- return ((_a = this.overrides) == null ? void 0 : _a.setMonth) ? this.overrides.setMonth(date, month) : setMonth(date, month);
431
+ var _a, _b;
432
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.setMonth) == null ? void 0 : _b.call(_a, date, month)) ?? setMonth(date, month);
197
433
  };
198
434
  this.setYear = (date, year) => {
199
- var _a;
200
- return ((_a = this.overrides) == null ? void 0 : _a.setYear) ? this.overrides.setYear(date, year) : setYear(date, year);
435
+ var _a, _b;
436
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.setYear) == null ? void 0 : _b.call(_a, date, year)) ?? setYear(date, year);
201
437
  };
202
- this.startOfBroadcastWeek = (date) => {
203
- var _a;
204
- return ((_a = this.overrides) == null ? void 0 : _a.startOfBroadcastWeek) ? this.overrides.startOfBroadcastWeek(date, this) : startOfBroadcastWeek(date, this);
438
+ this.startOfBroadcastWeek = (date, dateLib) => {
439
+ var _a, _b;
440
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.startOfBroadcastWeek) == null ? void 0 : _b.call(_a, date, dateLib ?? this)) ?? startOfBroadcastWeek(date, dateLib ?? this);
205
441
  };
206
442
  this.startOfDay = (date) => {
207
- var _a;
208
- return ((_a = this.overrides) == null ? void 0 : _a.startOfDay) ? this.overrides.startOfDay(date) : startOfDay(date);
443
+ var _a, _b;
444
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.startOfDay) == null ? void 0 : _b.call(_a, date)) ?? startOfDay(date);
209
445
  };
210
446
  this.startOfISOWeek = (date) => {
211
- var _a;
212
- return ((_a = this.overrides) == null ? void 0 : _a.startOfISOWeek) ? this.overrides.startOfISOWeek(date) : startOfISOWeek(date);
447
+ var _a, _b;
448
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.startOfISOWeek) == null ? void 0 : _b.call(_a, date)) ?? startOfISOWeek(date);
213
449
  };
214
450
  this.startOfMonth = (date) => {
215
- var _a;
216
- return ((_a = this.overrides) == null ? void 0 : _a.startOfMonth) ? this.overrides.startOfMonth(date) : startOfMonth(date);
451
+ var _a, _b;
452
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.startOfMonth) == null ? void 0 : _b.call(_a, date)) ?? startOfMonth(date);
217
453
  };
218
454
  this.startOfWeek = (date) => {
219
- var _a;
220
- return ((_a = this.overrides) == null ? void 0 : _a.startOfWeek) ? this.overrides.startOfWeek(date, this.options) : startOfWeek(date, this.options);
455
+ var _a, _b;
456
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.startOfWeek) == null ? void 0 : _b.call(_a, date)) ?? startOfWeek(date, this.options);
221
457
  };
222
458
  this.startOfYear = (date) => {
223
- var _a;
224
- return ((_a = this.overrides) == null ? void 0 : _a.startOfYear) ? this.overrides.startOfYear(date) : startOfYear(date);
459
+ var _a, _b;
460
+ return ((_b = (_a = this.overrides) == null ? void 0 : _a.startOfYear) == null ? void 0 : _b.call(_a, date)) ?? startOfYear(date);
225
461
  };
226
462
  this.options = { locale: enUS, ...options };
227
463
  this.overrides = overrides;
228
464
  }
465
+ /**
466
+ * Generate digit map dynamically using Intl.NumberFormat.
467
+ *
468
+ * @since 9.5.0
469
+ */
470
+ getDigitMap() {
471
+ const { numerals = "latn" } = this.options;
472
+ const formatter = new Intl.NumberFormat("en-US", {
473
+ numberingSystem: numerals
474
+ });
475
+ const digitMap = {};
476
+ for (let i = 0; i < 10; i++) {
477
+ digitMap[i.toString()] = formatter.format(i);
478
+ }
479
+ return digitMap;
480
+ }
481
+ /**
482
+ * Replace Arabic digits with the target numbering system digits.
483
+ *
484
+ * @since 9.5.0
485
+ */
486
+ replaceDigits(input) {
487
+ const digitMap = this.getDigitMap();
488
+ return input.replace(/\d/g, (digit) => digitMap[digit] || digit);
489
+ }
490
+ /**
491
+ * Format number using the custom numbering system.
492
+ *
493
+ * @since 9.5.0
494
+ * @param value The number to format.
495
+ * @returns The formatted number.
496
+ */
497
+ formatNumber(value) {
498
+ return this.replaceDigits(value.toString());
499
+ }
229
500
  }
230
501
  const defaultDateLib = new DateLib();
231
502
  function getClassNamesForModifiers(modifiers, classNames2, modifiersClassNames = {}) {
@@ -453,9 +724,8 @@ const formatMonthCaption = formatCaption;
453
724
  function formatDay(date, options, dateLib) {
454
725
  return (dateLib ?? new DateLib(options)).format(date, "d");
455
726
  }
456
- function formatMonthDropdown(monthNumber, locale) {
457
- var _a;
458
- return (_a = locale.localize) == null ? void 0 : _a.month(monthNumber);
727
+ function formatMonthDropdown(month, dateLib = defaultDateLib) {
728
+ return dateLib.format(month, "LLLL");
459
729
  }
460
730
  function formatWeekNumber(weekNumber) {
461
731
  if (weekNumber < 10) {
@@ -469,8 +739,8 @@ function formatWeekNumberHeader() {
469
739
  function formatWeekdayName(weekday, options, dateLib) {
470
740
  return (dateLib ?? new DateLib(options)).format(weekday, "cccccc");
471
741
  }
472
- function formatYearDropdown(year) {
473
- return year.toString();
742
+ function formatYearDropdown(year, dateLib = defaultDateLib) {
743
+ return dateLib.format(year, "yyyy");
474
744
  }
475
745
  const formatYearCaption = formatYearDropdown;
476
746
  const defaultFormatters = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
@@ -498,25 +768,15 @@ function getFormatters(customFormatters) {
498
768
  };
499
769
  }
500
770
  function getMonthOptions(displayMonth, navStart, navEnd, formatters, dateLib) {
501
- if (!navStart)
502
- return void 0;
503
- if (!navEnd)
504
- return void 0;
505
- const { addMonths: addMonths2, startOfMonth: startOfMonth2 } = dateLib;
506
- const year = displayMonth.getFullYear();
507
- const months = [];
508
- let month = navStart;
509
- while (months.length < 12) {
510
- months.push(month.getMonth());
511
- month = addMonths2(month, 1);
512
- }
513
- const sortedMonths = months.sort((a, b) => {
514
- return a - b;
771
+ const { startOfMonth: startOfMonth2, startOfYear: startOfYear2, endOfYear: endOfYear2, eachMonthOfInterval: eachMonthOfInterval2, getMonth: getMonth2 } = dateLib;
772
+ const months = eachMonthOfInterval2({
773
+ start: startOfYear2(displayMonth),
774
+ end: endOfYear2(displayMonth)
515
775
  });
516
- const options = sortedMonths.map((value) => {
517
- const label = formatters.formatMonthDropdown(value, dateLib.options.locale ?? enUS$1);
518
- const month2 = dateLib.Date ? new dateLib.Date(year, value) : new Date(year, value);
519
- const disabled = navStart && month2 < startOfMonth2(navStart) || navEnd && month2 > startOfMonth2(navEnd) || false;
776
+ const options = months.map((month) => {
777
+ const label = formatters.formatMonthDropdown(month, dateLib);
778
+ const value = getMonth2(month);
779
+ const disabled = navStart && month < startOfMonth2(navStart) || navEnd && month > startOfMonth2(navEnd) || false;
520
780
  return { value, label, disabled };
521
781
  });
522
782
  return options;
@@ -531,209 +791,9 @@ function getStyleForModifiers(dayModifiers, styles2 = {}, modifiersStyles = {})
531
791
  });
532
792
  return style;
533
793
  }
534
- const offsetFormatCache = {};
535
- const offsetCache = {};
536
- function tzOffset(timeZone, date) {
537
- try {
538
- const format2 = offsetFormatCache[timeZone] || (offsetFormatCache[timeZone] = new Intl.DateTimeFormat("en-GB", {
539
- timeZone,
540
- hour: "numeric",
541
- timeZoneName: "longOffset"
542
- }).format);
543
- const offsetStr = format2(date).split("GMT")[1] || "";
544
- if (offsetStr in offsetCache) return offsetCache[offsetStr];
545
- return calcOffset(offsetStr, offsetStr.split(":"));
546
- } catch {
547
- if (timeZone in offsetCache) return offsetCache[timeZone];
548
- const captures = timeZone == null ? void 0 : timeZone.match(offsetRe);
549
- if (captures) return calcOffset(timeZone, captures.slice(1));
550
- return NaN;
551
- }
552
- }
553
- const offsetRe = /([+-]\d\d):?(\d\d)?/;
554
- function calcOffset(cacheStr, values) {
555
- const hours = +values[0];
556
- const minutes = +(values[1] || 0);
557
- return offsetCache[cacheStr] = hours > 0 ? hours * 60 + minutes : hours * 60 - minutes;
558
- }
559
- class TZDateMini extends Date {
560
- //#region static
561
- constructor(...args) {
562
- super();
563
- if (args.length > 1 && typeof args[args.length - 1] === "string") {
564
- this.timeZone = args.pop();
565
- }
566
- this.internal = /* @__PURE__ */ new Date();
567
- if (isNaN(tzOffset(this.timeZone, this))) {
568
- this.setTime(NaN);
569
- } else {
570
- if (!args.length) {
571
- this.setTime(Date.now());
572
- } else if (typeof args[0] === "number" && (args.length === 1 || args.length === 2 && typeof args[1] !== "number")) {
573
- this.setTime(args[0]);
574
- } else if (typeof args[0] === "string") {
575
- this.setTime(+new Date(args[0]));
576
- } else if (args[0] instanceof Date) {
577
- this.setTime(+args[0]);
578
- } else {
579
- this.setTime(+new Date(...args));
580
- adjustToSystemTZ(this);
581
- syncToInternal(this);
582
- }
583
- }
584
- }
585
- static tz(tz, ...args) {
586
- return args.length ? new TZDateMini(...args, tz) : new TZDateMini(Date.now(), tz);
587
- }
588
- //#endregion
589
- //#region time zone
590
- withTimeZone(timeZone) {
591
- return new TZDateMini(+this, timeZone);
592
- }
593
- getTimezoneOffset() {
594
- return -tzOffset(this.timeZone, this);
595
- }
596
- //#endregion
597
- //#region time
598
- setTime(time) {
599
- Date.prototype.setTime.apply(this, arguments);
600
- syncToInternal(this);
601
- return +this;
602
- }
603
- //#endregion
604
- //#region date-fns integration
605
- [Symbol.for("constructDateFrom")](date) {
606
- return new TZDateMini(+new Date(date), this.timeZone);
607
- }
608
- //#endregion
609
- }
610
- const re = /^(get|set)(?!UTC)/;
611
- Object.getOwnPropertyNames(Date.prototype).forEach((method) => {
612
- if (!re.test(method)) return;
613
- const utcMethod = method.replace(re, "$1UTC");
614
- if (!TZDateMini.prototype[utcMethod]) return;
615
- if (method.startsWith("get")) {
616
- TZDateMini.prototype[method] = function() {
617
- return this.internal[utcMethod]();
618
- };
619
- } else {
620
- TZDateMini.prototype[method] = function() {
621
- Date.prototype[utcMethod].apply(this.internal, arguments);
622
- syncFromInternal(this);
623
- return +this;
624
- };
625
- TZDateMini.prototype[utcMethod] = function() {
626
- Date.prototype[utcMethod].apply(this, arguments);
627
- syncToInternal(this);
628
- return +this;
629
- };
630
- }
631
- });
632
- function syncToInternal(date) {
633
- date.internal.setTime(+date);
634
- date.internal.setUTCMinutes(date.internal.getUTCMinutes() - date.getTimezoneOffset());
635
- }
636
- function syncFromInternal(date) {
637
- Date.prototype.setFullYear.call(date, date.internal.getUTCFullYear(), date.internal.getUTCMonth(), date.internal.getUTCDate());
638
- Date.prototype.setHours.call(date, date.internal.getUTCHours(), date.internal.getUTCMinutes(), date.internal.getUTCSeconds(), date.internal.getUTCMilliseconds());
639
- adjustToSystemTZ(date);
640
- }
641
- function adjustToSystemTZ(date) {
642
- const offset = tzOffset(date.timeZone, date);
643
- const prevHour = /* @__PURE__ */ new Date(+date);
644
- prevHour.setUTCHours(prevHour.getUTCHours() - 1);
645
- const systemOffset = -(/* @__PURE__ */ new Date(+date)).getTimezoneOffset();
646
- const prevHourSystemOffset = -(/* @__PURE__ */ new Date(+prevHour)).getTimezoneOffset();
647
- const systemDSTChange = systemOffset - prevHourSystemOffset;
648
- const dstShift = Date.prototype.getHours.apply(date) !== date.internal.getUTCHours();
649
- if (systemDSTChange && dstShift) date.internal.setUTCMinutes(date.internal.getUTCMinutes() + systemDSTChange);
650
- const offsetDiff = systemOffset - offset;
651
- if (offsetDiff) Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + offsetDiff);
652
- const postOffset = tzOffset(date.timeZone, date);
653
- const postSystemOffset = -(/* @__PURE__ */ new Date(+date)).getTimezoneOffset();
654
- const postOffsetDiff = postSystemOffset - postOffset;
655
- const offsetChanged = postOffset !== offset;
656
- const postDiff = postOffsetDiff - offsetDiff;
657
- if (offsetChanged && postDiff) {
658
- Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + postDiff);
659
- const newOffset = tzOffset(date.timeZone, date);
660
- const offsetChange = postOffset - newOffset;
661
- if (offsetChange) {
662
- date.internal.setUTCMinutes(date.internal.getUTCMinutes() + offsetChange);
663
- Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + offsetChange);
664
- }
665
- }
666
- }
667
- class TZDate extends TZDateMini {
668
- //#region static
669
- static tz(tz, ...args) {
670
- return args.length ? new TZDate(...args, tz) : new TZDate(Date.now(), tz);
671
- }
672
- //#endregion
673
- //#region representation
674
- toISOString() {
675
- const [sign, hours, minutes] = this.tzComponents();
676
- const tz = `${sign}${hours}:${minutes}`;
677
- return this.internal.toISOString().slice(0, -1) + tz;
678
- }
679
- toString() {
680
- return `${this.toDateString()} ${this.toTimeString()}`;
681
- }
682
- toDateString() {
683
- const [day, date, month, year] = this.internal.toUTCString().split(" ");
684
- return `${day == null ? void 0 : day.slice(0, -1)} ${month} ${date} ${year}`;
685
- }
686
- toTimeString() {
687
- const time = this.internal.toUTCString().split(" ")[4];
688
- const [sign, hours, minutes] = this.tzComponents();
689
- return `${time} GMT${sign}${hours}${minutes} (${tzName(this.timeZone, this)})`;
690
- }
691
- toLocaleString(locales, options) {
692
- return Date.prototype.toLocaleString.call(this, locales, {
693
- ...options,
694
- timeZone: (options == null ? void 0 : options.timeZone) || this.timeZone
695
- });
696
- }
697
- toLocaleDateString(locales, options) {
698
- return Date.prototype.toLocaleDateString.call(this, locales, {
699
- ...options,
700
- timeZone: (options == null ? void 0 : options.timeZone) || this.timeZone
701
- });
702
- }
703
- toLocaleTimeString(locales, options) {
704
- return Date.prototype.toLocaleTimeString.call(this, locales, {
705
- ...options,
706
- timeZone: (options == null ? void 0 : options.timeZone) || this.timeZone
707
- });
708
- }
709
- //#endregion
710
- //#region private
711
- tzComponents() {
712
- const offset = this.getTimezoneOffset();
713
- const sign = offset > 0 ? "-" : "+";
714
- const hours = String(Math.floor(Math.abs(offset) / 60)).padStart(2, "0");
715
- const minutes = String(Math.abs(offset) % 60).padStart(2, "0");
716
- return [sign, hours, minutes];
717
- }
718
- //#endregion
719
- withTimeZone(timeZone) {
720
- return new TZDate(+this, timeZone);
721
- }
722
- //#region date-fns integration
723
- [Symbol.for("constructDateFrom")](date) {
724
- return new TZDate(+new Date(date), this.timeZone);
725
- }
726
- //#endregion
727
- }
728
- function tzName(tz, date) {
729
- return new Intl.DateTimeFormat("en-GB", {
730
- timeZone: tz,
731
- timeZoneName: "long"
732
- }).format(date).slice(12);
733
- }
734
- function getWeekdays(dateLib, ISOWeek, timeZone, broadcastCalendar) {
735
- const date = timeZone ? TZDate.tz(timeZone) : dateLib.Date ? new dateLib.Date() : /* @__PURE__ */ new Date();
736
- const start = ISOWeek ? dateLib.startOfISOWeek(date) : dateLib.startOfWeek(date);
794
+ function getWeekdays(dateLib, ISOWeek, broadcastCalendar) {
795
+ const today = dateLib.today();
796
+ const start = ISOWeek ? dateLib.startOfISOWeek(today) : dateLib.startOfWeek(today);
737
797
  const days = [];
738
798
  for (let i = 0; i < 7; i++) {
739
799
  const day = dateLib.addDays(start, i);
@@ -746,19 +806,19 @@ function getYearOptions(navStart, navEnd, formatters, dateLib) {
746
806
  return void 0;
747
807
  if (!navEnd)
748
808
  return void 0;
749
- const { startOfYear: startOfYear2, endOfYear: endOfYear2, addYears: addYears2, isBefore: isBefore2, isSameYear: isSameYear2 } = dateLib;
809
+ const { startOfYear: startOfYear2, endOfYear: endOfYear2, addYears: addYears2, getYear: getYear2, isBefore: isBefore2, isSameYear: isSameYear2 } = dateLib;
750
810
  const firstNavYear = startOfYear2(navStart);
751
811
  const lastNavYear = endOfYear2(navEnd);
752
812
  const years = [];
753
813
  let year = firstNavYear;
754
814
  while (isBefore2(year, lastNavYear) || isSameYear2(year, lastNavYear)) {
755
- years.push(year.getFullYear());
815
+ years.push(year);
756
816
  year = addYears2(year, 1);
757
817
  }
758
- return years.map((value) => {
759
- const label = formatters.formatYearDropdown(value);
818
+ return years.map((year2) => {
819
+ const label = formatters.formatYearDropdown(year2, dateLib);
760
820
  return {
761
- value,
821
+ value: getYear2(year2),
762
822
  label,
763
823
  disabled: false
764
824
  };
@@ -875,7 +935,7 @@ function getDisplayMonths(firstDisplayedMonth, calendarEndMonth, props, dateLib)
875
935
  return months;
876
936
  }
877
937
  function getInitialMonth(props, dateLib) {
878
- const { month, defaultMonth, today = props.timeZone ? TZDate.tz(props.timeZone) : dateLib.Date ? new dateLib.Date() : /* @__PURE__ */ new Date(), numberOfMonths = 1, endMonth, startMonth } = props;
938
+ const { month, defaultMonth, today = dateLib.today(), numberOfMonths = 1, endMonth, startMonth } = props;
879
939
  let initialMonth = month || defaultMonth || today;
880
940
  const { differenceInCalendarMonths: differenceInCalendarMonths2, addMonths: addMonths2, startOfMonth: startOfMonth2 } = dateLib;
881
941
  if (endMonth && differenceInCalendarMonths2(endMonth, initialMonth) < 0) {
@@ -952,38 +1012,35 @@ function getMonths(displayMonths, dates, props, dateLib) {
952
1012
  }
953
1013
  }
954
1014
  function getNavMonths(props, dateLib) {
955
- var _a;
956
1015
  let { startMonth, endMonth } = props;
957
- const { startOfYear: startOfYear2, startOfDay: startOfDay2, startOfMonth: startOfMonth2, endOfMonth: endOfMonth2, addYears: addYears2, endOfYear: endOfYear2 } = dateLib;
1016
+ const { startOfYear: startOfYear2, startOfDay: startOfDay2, startOfMonth: startOfMonth2, endOfMonth: endOfMonth2, addYears: addYears2, endOfYear: endOfYear2, newDate, today } = dateLib;
958
1017
  const { fromYear, toYear, fromMonth, toMonth } = props;
959
1018
  if (!startMonth && fromMonth) {
960
1019
  startMonth = fromMonth;
961
1020
  }
962
1021
  if (!startMonth && fromYear) {
963
- startMonth = new Date(fromYear, 0, 1);
1022
+ startMonth = dateLib.newDate(fromYear, 0, 1);
964
1023
  }
965
1024
  if (!endMonth && toMonth) {
966
1025
  endMonth = toMonth;
967
1026
  }
968
1027
  if (!endMonth && toYear) {
969
- endMonth = new Date(toYear, 11, 31);
1028
+ endMonth = newDate(toYear, 11, 31);
970
1029
  }
971
- const hasDropdowns = (_a = props.captionLayout) == null ? void 0 : _a.startsWith("dropdown");
1030
+ const hasYearDropdown = props.captionLayout === "dropdown" || props.captionLayout === "dropdown-years";
972
1031
  if (startMonth) {
973
1032
  startMonth = startOfMonth2(startMonth);
974
1033
  } else if (fromYear) {
975
- startMonth = new Date(fromYear, 0, 1);
976
- } else if (!startMonth && hasDropdowns) {
977
- const today = props.today ?? (props.timeZone ? TZDate.tz(props.timeZone) : dateLib.Date ? new dateLib.Date() : /* @__PURE__ */ new Date());
978
- startMonth = startOfYear2(addYears2(today, -100));
1034
+ startMonth = newDate(fromYear, 0, 1);
1035
+ } else if (!startMonth && hasYearDropdown) {
1036
+ startMonth = startOfYear2(addYears2(props.today ?? today(), -100));
979
1037
  }
980
1038
  if (endMonth) {
981
1039
  endMonth = endOfMonth2(endMonth);
982
1040
  } else if (toYear) {
983
- endMonth = new Date(toYear, 11, 31);
984
- } else if (!endMonth && hasDropdowns) {
985
- const today = props.today ?? (props.timeZone ? TZDate.tz(props.timeZone) : dateLib.Date ? new dateLib.Date() : /* @__PURE__ */ new Date());
986
- endMonth = endOfYear2(today);
1041
+ endMonth = newDate(toYear, 11, 31);
1042
+ } else if (!endMonth && hasYearDropdown) {
1043
+ endMonth = endOfYear2(props.today ?? today());
987
1044
  }
988
1045
  return [
989
1046
  startMonth ? startOfDay2(startMonth) : startMonth,
@@ -1039,7 +1096,11 @@ function useCalendar(props, dateLib) {
1039
1096
  const [navStart, navEnd] = getNavMonths(props, dateLib);
1040
1097
  const { startOfMonth: startOfMonth2, endOfMonth: endOfMonth2 } = dateLib;
1041
1098
  const initialMonth = getInitialMonth(props, dateLib);
1042
- const [firstMonth, setFirstMonth] = useControlledValue(initialMonth, props.month ? startOfMonth2(props.month) : void 0);
1099
+ const [firstMonth, setFirstMonth] = useControlledValue(
1100
+ initialMonth,
1101
+ // initialMonth is always computed from props.month if provided
1102
+ props.month ? initialMonth : void 0
1103
+ );
1043
1104
  useEffect(() => {
1044
1105
  const newInitialMonth = getInitialMonth(props, dateLib);
1045
1106
  setFirstMonth(newInitialMonth);
@@ -1294,7 +1355,7 @@ function useGetModifiers(days, props, dateLib) {
1294
1355
  const isDisabled = Boolean(disabled && dateMatchModifiers(date, disabled, dateLib));
1295
1356
  const isHidden = Boolean(hidden && dateMatchModifiers(date, hidden, dateLib)) || isBeforeStartMonth || isAfterEndMonth || // Broadcast calendar will show outside days as default
1296
1357
  !broadcastCalendar && !showOutsideDays && isOutside || broadcastCalendar && showOutsideDays === false && isOutside;
1297
- const isToday = isSameDay2(date, today ?? (props.timeZone ? TZDate.tz(props.timeZone) : dateLib.Date ? new dateLib.Date() : /* @__PURE__ */ new Date()));
1358
+ const isToday = isSameDay2(date, today ?? dateLib.today());
1298
1359
  if (isOutside)
1299
1360
  internalModifiersMap.outside.push(day);
1300
1361
  if (isDisabled)
@@ -1573,7 +1634,9 @@ function DayPicker(props) {
1573
1634
  weekStartsOn: props.broadcastCalendar ? 1 : props.weekStartsOn,
1574
1635
  firstWeekContainsDate: props.firstWeekContainsDate,
1575
1636
  useAdditionalWeekYearTokens: props.useAdditionalWeekYearTokens,
1576
- useAdditionalDayOfYearTokens: props.useAdditionalDayOfYearTokens
1637
+ useAdditionalDayOfYearTokens: props.useAdditionalDayOfYearTokens,
1638
+ timeZone: props.timeZone,
1639
+ numerals: props.numerals
1577
1640
  }, props.dateLib);
1578
1641
  return {
1579
1642
  dateLib: dateLib2,
@@ -1584,17 +1647,19 @@ function DayPicker(props) {
1584
1647
  classNames: { ...getDefaultClassNames(), ...props.classNames }
1585
1648
  };
1586
1649
  }, [
1587
- props.classNames,
1588
- props.components,
1589
- props.dateLib,
1650
+ props.locale,
1651
+ props.broadcastCalendar,
1652
+ props.weekStartsOn,
1590
1653
  props.firstWeekContainsDate,
1654
+ props.useAdditionalWeekYearTokens,
1655
+ props.useAdditionalDayOfYearTokens,
1656
+ props.timeZone,
1657
+ props.numerals,
1658
+ props.dateLib,
1659
+ props.components,
1591
1660
  props.formatters,
1592
1661
  props.labels,
1593
- props.locale,
1594
- props.useAdditionalDayOfYearTokens,
1595
- props.useAdditionalWeekYearTokens,
1596
- props.weekStartsOn,
1597
- props.broadcastCalendar
1662
+ props.classNames
1598
1663
  ]);
1599
1664
  const { captionLayout, mode, onDayBlur, onDayClick, onDayFocus, onDayKeyDown, onDayMouseEnter, onDayMouseLeave, onNextClick, onPrevClick, showWeekNumber, styles: styles2 } = props;
1600
1665
  const { formatCaption: formatCaption2, formatDay: formatDay2, formatMonthDropdown: formatMonthDropdown2, formatWeekNumber: formatWeekNumber2, formatWeekNumberHeader: formatWeekNumberHeader2, formatWeekdayName: formatWeekdayName2, formatYearDropdown: formatYearDropdown2 } = formatters;
@@ -1604,7 +1669,7 @@ function DayPicker(props) {
1604
1669
  const { isSelected, select, selected: selectedValue } = useSelection(props, dateLib) ?? {};
1605
1670
  const { blur, focused, isFocusTarget, moveFocus, setFocused } = useFocus(props, calendar, getModifiers, isSelected ?? (() => false), dateLib);
1606
1671
  const { labelDayButton: labelDayButton2, labelGridcell: labelGridcell2, labelGrid: labelGrid2, labelMonthDropdown: labelMonthDropdown2, labelNav: labelNav2, labelWeekday: labelWeekday2, labelWeekNumber: labelWeekNumber2, labelWeekNumberHeader: labelWeekNumberHeader2, labelYearDropdown: labelYearDropdown2 } = labels;
1607
- const weekdays = useMemo(() => getWeekdays(dateLib, props.ISOWeek, props.timeZone), [dateLib, props.ISOWeek, props.timeZone]);
1672
+ const weekdays = useMemo(() => getWeekdays(dateLib, props.ISOWeek), [dateLib, props.ISOWeek]);
1608
1673
  const isInteractive = mode !== void 0 || onDayClick !== void 0;
1609
1674
  const handlePreviousClick = useCallback(() => {
1610
1675
  if (!previousMonth)
@@ -1708,8 +1773,8 @@ function DayPicker(props) {
1708
1773
  React.createElement(components2.MonthCaption, { className: classNames2[UI.MonthCaption], style: styles2 == null ? void 0 : styles2[UI.MonthCaption], calendarMonth, displayIndex }, (captionLayout == null ? void 0 : captionLayout.startsWith("dropdown")) ? React.createElement(
1709
1774
  components2.DropdownNav,
1710
1775
  { className: classNames2[UI.Dropdowns], style: styles2 == null ? void 0 : styles2[UI.Dropdowns] },
1711
- captionLayout === "dropdown" || captionLayout === "dropdown-months" ? React.createElement(components2.MonthsDropdown, { className: classNames2[UI.MonthsDropdown], "aria-label": labelMonthDropdown2(), classNames: classNames2, components: components2, disabled: Boolean(props.disableNavigation), onChange: handleMonthChange(calendarMonth.date), options: dropdownMonths, style: styles2 == null ? void 0 : styles2[UI.Dropdown], value: calendarMonth.date.getMonth() }) : React.createElement("span", { role: "status", "aria-live": "polite" }, formatMonthDropdown2(calendarMonth.date.getMonth(), locale)),
1712
- captionLayout === "dropdown" || captionLayout === "dropdown-years" ? React.createElement(components2.YearsDropdown, { className: classNames2[UI.YearsDropdown], "aria-label": labelYearDropdown2(dateLib.options), classNames: classNames2, components: components2, disabled: Boolean(props.disableNavigation), onChange: handleYearChange(calendarMonth.date), options: dropdownYears, style: styles2 == null ? void 0 : styles2[UI.Dropdown], value: calendarMonth.date.getFullYear() }) : React.createElement("span", { role: "status", "aria-live": "polite" }, formatYearDropdown2(calendarMonth.date.getFullYear()))
1776
+ captionLayout === "dropdown" || captionLayout === "dropdown-months" ? React.createElement(components2.MonthsDropdown, { className: classNames2[UI.MonthsDropdown], "aria-label": labelMonthDropdown2(), classNames: classNames2, components: components2, disabled: Boolean(props.disableNavigation), onChange: handleMonthChange(calendarMonth.date), options: dropdownMonths, style: styles2 == null ? void 0 : styles2[UI.Dropdown], value: dateLib.getMonth(calendarMonth.date) }) : React.createElement("span", { role: "status", "aria-live": "polite" }, formatMonthDropdown2(calendarMonth.date, dateLib)),
1777
+ captionLayout === "dropdown" || captionLayout === "dropdown-years" ? React.createElement(components2.YearsDropdown, { className: classNames2[UI.YearsDropdown], "aria-label": labelYearDropdown2(dateLib.options), classNames: classNames2, components: components2, disabled: Boolean(props.disableNavigation), onChange: handleYearChange(calendarMonth.date), options: dropdownYears, style: styles2 == null ? void 0 : styles2[UI.Dropdown], value: dateLib.getYear(calendarMonth.date) }) : React.createElement("span", { role: "status", "aria-live": "polite" }, formatYearDropdown2(calendarMonth.date, dateLib))
1713
1778
  ) : React.createElement(components2.CaptionLabel, { className: classNames2[UI.CaptionLabel], role: "status", "aria-live": "polite" }, formatCaption2(calendarMonth.date, dateLib.options, dateLib))),
1714
1779
  React.createElement(
1715
1780
  components2.MonthGrid,