@helsenorge/datepicker 13.5.0 → 13.6.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.
- package/lib/CHANGELOG.md +24 -1
- package/lib/DayPicker.js +304 -85
- package/lib/DayPicker.js.map +1 -1
- package/lib/components/DatePicker/DatePicker.d.ts +1 -1
- package/lib/components/DatePicker/index.js.map +1 -1
- package/lib/components/Unsafe_DatePicker/DatePicker.module.scss +16 -0
- package/lib/components/Unsafe_DatePicker/DatePicker.module.scss.d.ts +2 -0
- package/lib/components/Unsafe_DatePicker/TimeInput/TimeInputInternal.d.ts +23 -0
- package/lib/components/Unsafe_DatePicker/TimeInput/Unsafe_TimeInput.d.ts +25 -0
- package/lib/components/Unsafe_DatePicker/Unsafe_DateAndTime.d.ts +16 -0
- package/lib/components/Unsafe_DatePicker/Unsafe_DateAndTime.module.scss +18 -0
- package/lib/components/Unsafe_DatePicker/Unsafe_DateAndTime.module.scss.d.ts +10 -0
- package/lib/components/Unsafe_DatePicker/index.d.ts +3 -1
- package/lib/components/Unsafe_DatePicker/index.js +371 -78
- package/lib/components/Unsafe_DatePicker/index.js.map +1 -1
- package/lib/resources/HN.Designsystem.Unsafe_DatePicker.nb-NO.json.d.ts +3 -1
- package/package.json +1 -1
package/lib/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
## [13.6.0](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv13.5.0&targetVersion=GTv13.6.0) (2026-02-11)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* oppdatert til motion 12 ([af5eb81](https://github.com/helsenorge/designsystem/commit/af5eb8141c74b5b1179f90b838606ae6d41b751d)), closes [#371272](https://github.com/helsenorge/designsystem/issues/371272)
|
|
7
|
+
* **datepicker:** ny komponent for input av tid ([592b6e4](https://github.com/helsenorge/designsystem/commit/592b6e4eabe9f718c142957a041084050e47c71f)), closes [#367381](https://github.com/helsenorge/designsystem/issues/367381)
|
|
8
|
+
* **duolist:** lagt til prop for testid på hver duolistgroup ([004ae83](https://github.com/helsenorge/designsystem/commit/004ae83bdfaa5ba47b70d07c4337d9238d06b774)), closes [#370261](https://github.com/helsenorge/designsystem/issues/370261)
|
|
9
|
+
* **formgroup:** åpne for flere tags for legend og title ([0cbc280](https://github.com/helsenorge/designsystem/commit/0cbc2801b654d8adaa4f610452dfd5043900e53f)), closes [#368142](https://github.com/helsenorge/designsystem/issues/368142)
|
|
10
|
+
* **infoteaser:** legg til prop for å sette høyde på collapsed teaser ([3681d3f](https://github.com/helsenorge/designsystem/commit/3681d3f7ebd16aacf9b4114b48ba7fd0d2ee1e29))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **datepicker:** ikke sett default legend for ny datepicker ([f2230cb](https://github.com/helsenorge/designsystem/commit/f2230cbaff99f7e89320a8b10073c7420614d4ee)), closes [#345238](https://github.com/helsenorge/designsystem/issues/345238)
|
|
16
|
+
* **drawer:** legg på padding så ikke footer-knapper kuttes på iphone ([3616eff](https://github.com/helsenorge/designsystem/commit/3616eff6cfa040ef5d814458978f5dc7f023d470)), closes [#369303](https://github.com/helsenorge/designsystem/issues/369303)
|
|
17
|
+
* **expander:** behold bredde på innhold på desktop ([8ab0315](https://github.com/helsenorge/designsystem/commit/8ab03150ede607ace77d40dc89865f0b0e574858)), closes [#361764](https://github.com/helsenorge/designsystem/issues/361764)
|
|
18
|
+
* **panellist:** gjør panellist sin styling av panel mer robust ([b1c28dc](https://github.com/helsenorge/designsystem/commit/b1c28dc6f31ec44a64e022da653a880347d7a530)), closes [#369909](https://github.com/helsenorge/designsystem/issues/369909)
|
|
19
|
+
* **select:** skjul overflow tekst og vis ellipsis ([a56be99](https://github.com/helsenorge/designsystem/commit/a56be9933ae7dbd6d03441f94384e1b6dd3f69e1)), closes [#370560](https://github.com/helsenorge/designsystem/issues/370560)
|
|
20
|
+
* **toggle:** ariadescribedby settes til undefined ([c6b8e64](https://github.com/helsenorge/designsystem/commit/c6b8e6417e96091b087eb7af7892e54733e5a8a0)), closes [#370572](https://github.com/helsenorge/designsystem/issues/370572)
|
|
21
|
+
* **unsafe_datepicker:** ikke sett aria-controls om popup er lukket ([79349e8](https://github.com/helsenorge/designsystem/commit/79349e8d93018d3274a8af2ae5d8ed201f738601)), closes [#371062](https://github.com/helsenorge/designsystem/issues/371062)
|
|
22
|
+
* **unsafe_datepicker:** lukk kalender med escape på kalender knapp og fjern manglende IDer ([c7d2b09](https://github.com/helsenorge/designsystem/commit/c7d2b09df068719ad3f9ce7be8e54653a5691fae)), closes [#371061](https://github.com/helsenorge/designsystem/issues/371061) [#371062](https://github.com/helsenorge/designsystem/issues/371062)
|
|
23
|
+
|
|
1
24
|
## [13.5.0](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv13.4.0&targetVersion=GTv13.5.0) (2026-01-21)
|
|
2
25
|
|
|
3
26
|
|
|
@@ -214,7 +237,7 @@
|
|
|
214
237
|
|
|
215
238
|
* lib mappen ble ikke med i den publiserte pakken ([1c5409e](https://github.com/helsenorge/designsystem/commit/1c5409eeaf05524c315650ea11a839a70b7dfaa3)), closes [#362474](https://github.com/helsenorge/designsystem/issues/362474)
|
|
216
239
|
|
|
217
|
-
## [12.12.2](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv12.12.1&targetVersion=GTv12.12.2) (2025-11-
|
|
240
|
+
## [12.12.2](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv12.12.1&targetVersion=GTv12.12.2) (2025-11-07)
|
|
218
241
|
|
|
219
242
|
## [12.12.1](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv12.11.1&targetVersion=GTv12.12.1) (2025-11-06)
|
|
220
243
|
|
package/lib/DayPicker.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
2
2
|
import { addDays, addMonths, addWeeks, addYears, differenceInCalendarDays, differenceInCalendarMonths, eachMonthOfInterval, eachYearOfInterval, endOfISOWeek, endOfMonth, endOfWeek, endOfYear, format, getISOWeek, getMonth, getWeek, getYear, isAfter, isBefore, isDate, isSameDay, isSameMonth, isSameYear, max, min, setMonth, setYear, startOfDay, startOfISOWeek, startOfMonth, startOfWeek, startOfYear } from "date-fns";
|
|
3
|
-
import { enUS
|
|
3
|
+
import { enUS } from "date-fns/locale";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __export = (all, symbols) => {
|
|
6
6
|
let target = {};
|
|
@@ -216,6 +216,59 @@ function endOfBroadcastWeek(date, dateLib) {
|
|
|
216
216
|
const numberOfWeeks = getBroadcastWeeksInMonth(date, dateLib);
|
|
217
217
|
return dateLib.addDays(startDate, numberOfWeeks * 7 - 1);
|
|
218
218
|
}
|
|
219
|
+
const enUS$1 = {
|
|
220
|
+
...enUS,
|
|
221
|
+
labels: {
|
|
222
|
+
labelDayButton: (date, modifiers, options, dateLib) => {
|
|
223
|
+
let formatDate;
|
|
224
|
+
if (dateLib && typeof dateLib.format === "function") formatDate = dateLib.format.bind(dateLib);
|
|
225
|
+
else formatDate = (d, pattern) => format(d, pattern, {
|
|
226
|
+
locale: enUS,
|
|
227
|
+
...options
|
|
228
|
+
});
|
|
229
|
+
let label = formatDate(date, "PPPP");
|
|
230
|
+
if (modifiers.today) label = `Today, ${label}`;
|
|
231
|
+
if (modifiers.selected) label = `${label}, selected`;
|
|
232
|
+
return label;
|
|
233
|
+
},
|
|
234
|
+
labelMonthDropdown: "Choose the Month",
|
|
235
|
+
labelNext: "Go to the Next Month",
|
|
236
|
+
labelPrevious: "Go to the Previous Month",
|
|
237
|
+
labelWeekNumber: (weekNumber) => `Week ${weekNumber}`,
|
|
238
|
+
labelYearDropdown: "Choose the Year",
|
|
239
|
+
labelGrid: (date, options, dateLib) => {
|
|
240
|
+
let formatDate;
|
|
241
|
+
if (dateLib && typeof dateLib.format === "function") formatDate = dateLib.format.bind(dateLib);
|
|
242
|
+
else formatDate = (d, pattern) => format(d, pattern, {
|
|
243
|
+
locale: enUS,
|
|
244
|
+
...options
|
|
245
|
+
});
|
|
246
|
+
return formatDate(date, "LLLL yyyy");
|
|
247
|
+
},
|
|
248
|
+
labelGridcell: (date, modifiers, options, dateLib) => {
|
|
249
|
+
let formatDate;
|
|
250
|
+
if (dateLib && typeof dateLib.format === "function") formatDate = dateLib.format.bind(dateLib);
|
|
251
|
+
else formatDate = (d, pattern) => format(d, pattern, {
|
|
252
|
+
locale: enUS,
|
|
253
|
+
...options
|
|
254
|
+
});
|
|
255
|
+
let label = formatDate(date, "PPPP");
|
|
256
|
+
if (modifiers?.today) label = `Today, ${label}`;
|
|
257
|
+
return label;
|
|
258
|
+
},
|
|
259
|
+
labelNav: "Navigation bar",
|
|
260
|
+
labelWeekNumberHeader: "Week Number",
|
|
261
|
+
labelWeekday: (date, options, dateLib) => {
|
|
262
|
+
let formatDate;
|
|
263
|
+
if (dateLib && typeof dateLib.format === "function") formatDate = dateLib.format.bind(dateLib);
|
|
264
|
+
else formatDate = (d, pattern) => format(d, pattern, {
|
|
265
|
+
locale: enUS,
|
|
266
|
+
...options
|
|
267
|
+
});
|
|
268
|
+
return formatDate(date, "cccc");
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
};
|
|
219
272
|
var DateLib = class DateLib {
|
|
220
273
|
constructor(options, overrides) {
|
|
221
274
|
this.Date = Date;
|
|
@@ -341,7 +394,7 @@ var DateLib = class DateLib {
|
|
|
341
394
|
return this.overrides?.startOfYear ? this.overrides.startOfYear(date) : startOfYear(date);
|
|
342
395
|
};
|
|
343
396
|
this.options = {
|
|
344
|
-
locale: enUS,
|
|
397
|
+
locale: enUS$1,
|
|
345
398
|
...options
|
|
346
399
|
};
|
|
347
400
|
this.overrides = overrides;
|
|
@@ -667,7 +720,7 @@ var custom_components_exports = /* @__PURE__ */ __export({
|
|
|
667
720
|
Weekdays: () => Weekdays,
|
|
668
721
|
Weeks: () => Weeks,
|
|
669
722
|
YearsDropdown: () => YearsDropdown
|
|
670
|
-
});
|
|
723
|
+
}, 1);
|
|
671
724
|
function rangeIncludesDate(range, date, excludeEnds = false, dateLib = defaultDateLib) {
|
|
672
725
|
let { from, to } = range;
|
|
673
726
|
const { differenceInCalendarDays: differenceInCalendarDays$1, isSameDay: isSameDay$1 } = dateLib;
|
|
@@ -703,7 +756,7 @@ function dateMatchModifiers(date, matchers, dateLib = defaultDateLib) {
|
|
|
703
756
|
return matchersArr.some((matcher) => {
|
|
704
757
|
if (typeof matcher === "boolean") return matcher;
|
|
705
758
|
if (dateLib.isDate(matcher)) return isSameDay$1(date, matcher);
|
|
706
|
-
if (isDatesArray(matcher, dateLib)) return matcher.
|
|
759
|
+
if (isDatesArray(matcher, dateLib)) return matcher.some((matcherDate) => isSameDay$1(date, matcherDate));
|
|
707
760
|
if (isDateRange(matcher)) return rangeIncludesDate(matcher, date, false, dateLib);
|
|
708
761
|
if (isDayOfWeekType(matcher)) {
|
|
709
762
|
if (!Array.isArray(matcher.dayOfWeek)) return matcher.dayOfWeek === date.getDay();
|
|
@@ -842,7 +895,7 @@ var formatters_exports = /* @__PURE__ */ __export({
|
|
|
842
895
|
formatWeekdayName: () => formatWeekdayName,
|
|
843
896
|
formatYearCaption: () => formatYearCaption,
|
|
844
897
|
formatYearDropdown: () => formatYearDropdown
|
|
845
|
-
});
|
|
898
|
+
}, 1);
|
|
846
899
|
function getFormatters(customFormatters) {
|
|
847
900
|
if (customFormatters?.formatMonthCaption && !customFormatters.formatCaption) customFormatters.formatCaption = customFormatters.formatMonthCaption;
|
|
848
901
|
if (customFormatters?.formatYearCaption && !customFormatters.formatYearDropdown) customFormatters.formatYearDropdown = customFormatters.formatYearCaption;
|
|
@@ -851,6 +904,85 @@ function getFormatters(customFormatters) {
|
|
|
851
904
|
...customFormatters
|
|
852
905
|
};
|
|
853
906
|
}
|
|
907
|
+
function labelDayButton(date, modifiers, options, dateLib) {
|
|
908
|
+
let label = (dateLib ?? new DateLib(options)).format(date, "PPPP");
|
|
909
|
+
if (modifiers.today) label = `Today, ${label}`;
|
|
910
|
+
if (modifiers.selected) label = `${label}, selected`;
|
|
911
|
+
return label;
|
|
912
|
+
}
|
|
913
|
+
const labelDay = labelDayButton;
|
|
914
|
+
function labelGrid(date, options, dateLib) {
|
|
915
|
+
return (dateLib ?? new DateLib(options)).formatMonthYear(date);
|
|
916
|
+
}
|
|
917
|
+
const labelCaption = labelGrid;
|
|
918
|
+
function labelGridcell(date, modifiers, options, dateLib) {
|
|
919
|
+
let label = (dateLib ?? new DateLib(options)).format(date, "PPPP");
|
|
920
|
+
if (modifiers?.today) label = `Today, ${label}`;
|
|
921
|
+
return label;
|
|
922
|
+
}
|
|
923
|
+
function labelMonthDropdown(_options) {
|
|
924
|
+
return "Choose the Month";
|
|
925
|
+
}
|
|
926
|
+
function labelNav() {
|
|
927
|
+
return "";
|
|
928
|
+
}
|
|
929
|
+
var defaultLabel = "Go to the Next Month";
|
|
930
|
+
function labelNext(_month, _options) {
|
|
931
|
+
return defaultLabel;
|
|
932
|
+
}
|
|
933
|
+
function labelPrevious(_month) {
|
|
934
|
+
return "Go to the Previous Month";
|
|
935
|
+
}
|
|
936
|
+
function labelWeekday(date, options, dateLib) {
|
|
937
|
+
return (dateLib ?? new DateLib(options)).format(date, "cccc");
|
|
938
|
+
}
|
|
939
|
+
function labelWeekNumber(weekNumber, _options) {
|
|
940
|
+
return `Week ${weekNumber}`;
|
|
941
|
+
}
|
|
942
|
+
function labelWeekNumberHeader(_options) {
|
|
943
|
+
return "Week Number";
|
|
944
|
+
}
|
|
945
|
+
function labelYearDropdown(_options) {
|
|
946
|
+
return "Choose the Year";
|
|
947
|
+
}
|
|
948
|
+
var labels_exports = /* @__PURE__ */ __export({
|
|
949
|
+
labelCaption: () => labelCaption,
|
|
950
|
+
labelDay: () => labelDay,
|
|
951
|
+
labelDayButton: () => labelDayButton,
|
|
952
|
+
labelGrid: () => labelGrid,
|
|
953
|
+
labelGridcell: () => labelGridcell,
|
|
954
|
+
labelMonthDropdown: () => labelMonthDropdown,
|
|
955
|
+
labelNav: () => labelNav,
|
|
956
|
+
labelNext: () => labelNext,
|
|
957
|
+
labelPrevious: () => labelPrevious,
|
|
958
|
+
labelWeekNumber: () => labelWeekNumber,
|
|
959
|
+
labelWeekNumberHeader: () => labelWeekNumberHeader,
|
|
960
|
+
labelWeekday: () => labelWeekday,
|
|
961
|
+
labelYearDropdown: () => labelYearDropdown
|
|
962
|
+
}, 1);
|
|
963
|
+
var resolveLabel = (defaultLabel$1, customLabel, localeLabel) => {
|
|
964
|
+
if (customLabel) return customLabel;
|
|
965
|
+
if (localeLabel) return typeof localeLabel === "function" ? localeLabel : (..._args) => localeLabel;
|
|
966
|
+
return defaultLabel$1;
|
|
967
|
+
};
|
|
968
|
+
function getLabels(customLabels, options) {
|
|
969
|
+
const localeLabels = options.locale?.labels ?? {};
|
|
970
|
+
return {
|
|
971
|
+
...labels_exports,
|
|
972
|
+
...customLabels ?? {},
|
|
973
|
+
labelDayButton: resolveLabel(labelDayButton, customLabels?.labelDayButton, localeLabels.labelDayButton),
|
|
974
|
+
labelMonthDropdown: resolveLabel(labelMonthDropdown, customLabels?.labelMonthDropdown, localeLabels.labelMonthDropdown),
|
|
975
|
+
labelNext: resolveLabel(labelNext, customLabels?.labelNext, localeLabels.labelNext),
|
|
976
|
+
labelPrevious: resolveLabel(labelPrevious, customLabels?.labelPrevious, localeLabels.labelPrevious),
|
|
977
|
+
labelWeekNumber: resolveLabel(labelWeekNumber, customLabels?.labelWeekNumber, localeLabels.labelWeekNumber),
|
|
978
|
+
labelYearDropdown: resolveLabel(labelYearDropdown, customLabels?.labelYearDropdown, localeLabels.labelYearDropdown),
|
|
979
|
+
labelGrid: resolveLabel(labelGrid, customLabels?.labelGrid, localeLabels.labelGrid),
|
|
980
|
+
labelGridcell: resolveLabel(labelGridcell, customLabels?.labelGridcell, localeLabels.labelGridcell),
|
|
981
|
+
labelNav: resolveLabel(labelNav, customLabels?.labelNav, localeLabels.labelNav),
|
|
982
|
+
labelWeekNumberHeader: resolveLabel(labelWeekNumberHeader, customLabels?.labelWeekNumberHeader, localeLabels.labelWeekNumberHeader),
|
|
983
|
+
labelWeekday: resolveLabel(labelWeekday, customLabels?.labelWeekday, localeLabels.labelWeekday)
|
|
984
|
+
};
|
|
985
|
+
}
|
|
854
986
|
function getMonthOptions(displayMonth, navStart, navEnd, formatters, dateLib) {
|
|
855
987
|
const { startOfMonth: startOfMonth$1, startOfYear: startOfYear$1, endOfYear: endOfYear$1, eachMonthOfInterval: eachMonthOfInterval$1, getMonth: getMonth$1 } = dateLib;
|
|
856
988
|
return eachMonthOfInterval$1({
|
|
@@ -903,61 +1035,132 @@ function getYearOptions(navStart, navEnd, formatters, dateLib, reverse = false)
|
|
|
903
1035
|
};
|
|
904
1036
|
});
|
|
905
1037
|
}
|
|
906
|
-
function
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
}
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
1038
|
+
function createNoonOverrides(timeZone, options = {}) {
|
|
1039
|
+
const { weekStartsOn, locale } = options;
|
|
1040
|
+
const fallbackWeekStartsOn = weekStartsOn ?? locale?.options?.weekStartsOn ?? 0;
|
|
1041
|
+
const toNoonTZDate = (date) => {
|
|
1042
|
+
const normalizedDate = typeof date === "number" || typeof date === "string" ? new Date(date) : date;
|
|
1043
|
+
return new TZDate(normalizedDate.getFullYear(), normalizedDate.getMonth(), normalizedDate.getDate(), 12, 0, 0, timeZone);
|
|
1044
|
+
};
|
|
1045
|
+
const toCalendarDate = (date) => {
|
|
1046
|
+
const zoned = toNoonTZDate(date);
|
|
1047
|
+
return new Date(zoned.getFullYear(), zoned.getMonth(), zoned.getDate(), 0, 0, 0, 0);
|
|
1048
|
+
};
|
|
1049
|
+
return {
|
|
1050
|
+
today: () => {
|
|
1051
|
+
return toNoonTZDate(TZDate.tz(timeZone));
|
|
1052
|
+
},
|
|
1053
|
+
newDate: (year, monthIndex, date) => {
|
|
1054
|
+
return new TZDate(year, monthIndex, date, 12, 0, 0, timeZone);
|
|
1055
|
+
},
|
|
1056
|
+
startOfDay: (date) => {
|
|
1057
|
+
return toNoonTZDate(date);
|
|
1058
|
+
},
|
|
1059
|
+
startOfWeek: (date, options$1) => {
|
|
1060
|
+
const base = toNoonTZDate(date);
|
|
1061
|
+
const weekStartsOnValue = options$1?.weekStartsOn ?? fallbackWeekStartsOn;
|
|
1062
|
+
const diff = (base.getDay() - weekStartsOnValue + 7) % 7;
|
|
1063
|
+
base.setDate(base.getDate() - diff);
|
|
1064
|
+
return base;
|
|
1065
|
+
},
|
|
1066
|
+
startOfISOWeek: (date) => {
|
|
1067
|
+
const base = toNoonTZDate(date);
|
|
1068
|
+
const diff = (base.getDay() - 1 + 7) % 7;
|
|
1069
|
+
base.setDate(base.getDate() - diff);
|
|
1070
|
+
return base;
|
|
1071
|
+
},
|
|
1072
|
+
startOfMonth: (date) => {
|
|
1073
|
+
const base = toNoonTZDate(date);
|
|
1074
|
+
base.setDate(1);
|
|
1075
|
+
return base;
|
|
1076
|
+
},
|
|
1077
|
+
startOfYear: (date) => {
|
|
1078
|
+
const base = toNoonTZDate(date);
|
|
1079
|
+
base.setMonth(0, 1);
|
|
1080
|
+
return base;
|
|
1081
|
+
},
|
|
1082
|
+
endOfWeek: (date, options$1) => {
|
|
1083
|
+
const base = toNoonTZDate(date);
|
|
1084
|
+
const diff = (((options$1?.weekStartsOn ?? fallbackWeekStartsOn) + 6) % 7 - base.getDay() + 7) % 7;
|
|
1085
|
+
base.setDate(base.getDate() + diff);
|
|
1086
|
+
return base;
|
|
1087
|
+
},
|
|
1088
|
+
endOfISOWeek: (date) => {
|
|
1089
|
+
const base = toNoonTZDate(date);
|
|
1090
|
+
const diff = (7 - base.getDay()) % 7;
|
|
1091
|
+
base.setDate(base.getDate() + diff);
|
|
1092
|
+
return base;
|
|
1093
|
+
},
|
|
1094
|
+
endOfMonth: (date) => {
|
|
1095
|
+
const base = toNoonTZDate(date);
|
|
1096
|
+
base.setMonth(base.getMonth() + 1, 0);
|
|
1097
|
+
return base;
|
|
1098
|
+
},
|
|
1099
|
+
endOfYear: (date) => {
|
|
1100
|
+
const base = toNoonTZDate(date);
|
|
1101
|
+
base.setMonth(11, 31);
|
|
1102
|
+
return base;
|
|
1103
|
+
},
|
|
1104
|
+
eachMonthOfInterval: (interval) => {
|
|
1105
|
+
const start = toNoonTZDate(interval.start);
|
|
1106
|
+
const end = toNoonTZDate(interval.end);
|
|
1107
|
+
const result = [];
|
|
1108
|
+
const cursor = new TZDate(start.getFullYear(), start.getMonth(), 1, 12, 0, 0, timeZone);
|
|
1109
|
+
const endKey = end.getFullYear() * 12 + end.getMonth();
|
|
1110
|
+
while (cursor.getFullYear() * 12 + cursor.getMonth() <= endKey) {
|
|
1111
|
+
result.push(new TZDate(cursor, timeZone));
|
|
1112
|
+
cursor.setMonth(cursor.getMonth() + 1, 1);
|
|
1113
|
+
}
|
|
1114
|
+
return result;
|
|
1115
|
+
},
|
|
1116
|
+
addDays: (date, amount) => {
|
|
1117
|
+
const base = toNoonTZDate(date);
|
|
1118
|
+
base.setDate(base.getDate() + amount);
|
|
1119
|
+
return base;
|
|
1120
|
+
},
|
|
1121
|
+
addWeeks: (date, amount) => {
|
|
1122
|
+
const base = toNoonTZDate(date);
|
|
1123
|
+
base.setDate(base.getDate() + amount * 7);
|
|
1124
|
+
return base;
|
|
1125
|
+
},
|
|
1126
|
+
addMonths: (date, amount) => {
|
|
1127
|
+
const base = toNoonTZDate(date);
|
|
1128
|
+
base.setMonth(base.getMonth() + amount);
|
|
1129
|
+
return base;
|
|
1130
|
+
},
|
|
1131
|
+
addYears: (date, amount) => {
|
|
1132
|
+
const base = toNoonTZDate(date);
|
|
1133
|
+
base.setFullYear(base.getFullYear() + amount);
|
|
1134
|
+
return base;
|
|
1135
|
+
},
|
|
1136
|
+
eachYearOfInterval: (interval) => {
|
|
1137
|
+
const start = toNoonTZDate(interval.start);
|
|
1138
|
+
const end = toNoonTZDate(interval.end);
|
|
1139
|
+
const years = [];
|
|
1140
|
+
const cursor = new TZDate(start.getFullYear(), 0, 1, 12, 0, 0, timeZone);
|
|
1141
|
+
while (cursor.getFullYear() <= end.getFullYear()) {
|
|
1142
|
+
years.push(new TZDate(cursor, timeZone));
|
|
1143
|
+
cursor.setFullYear(cursor.getFullYear() + 1, 0, 1);
|
|
1144
|
+
}
|
|
1145
|
+
return years;
|
|
1146
|
+
},
|
|
1147
|
+
getWeek: (date, options$1) => {
|
|
1148
|
+
return getWeek(toCalendarDate(date), {
|
|
1149
|
+
weekStartsOn: options$1?.weekStartsOn ?? fallbackWeekStartsOn,
|
|
1150
|
+
firstWeekContainsDate: options$1?.firstWeekContainsDate ?? locale?.options?.firstWeekContainsDate ?? 1
|
|
1151
|
+
});
|
|
1152
|
+
},
|
|
1153
|
+
getISOWeek: (date) => {
|
|
1154
|
+
return getISOWeek(toCalendarDate(date));
|
|
1155
|
+
},
|
|
1156
|
+
differenceInCalendarDays: (dateLeft, dateRight) => {
|
|
1157
|
+
return differenceInCalendarDays(toCalendarDate(dateLeft), toCalendarDate(dateRight));
|
|
1158
|
+
},
|
|
1159
|
+
differenceInCalendarMonths: (dateLeft, dateRight) => {
|
|
1160
|
+
return differenceInCalendarMonths(toCalendarDate(dateLeft), toCalendarDate(dateRight));
|
|
1161
|
+
}
|
|
1162
|
+
};
|
|
945
1163
|
}
|
|
946
|
-
var labels_exports = /* @__PURE__ */ __export({
|
|
947
|
-
labelCaption: () => labelCaption,
|
|
948
|
-
labelDay: () => labelDay,
|
|
949
|
-
labelDayButton: () => labelDayButton,
|
|
950
|
-
labelGrid: () => labelGrid,
|
|
951
|
-
labelGridcell: () => labelGridcell,
|
|
952
|
-
labelMonthDropdown: () => labelMonthDropdown,
|
|
953
|
-
labelNav: () => labelNav,
|
|
954
|
-
labelNext: () => labelNext,
|
|
955
|
-
labelPrevious: () => labelPrevious,
|
|
956
|
-
labelWeekNumber: () => labelWeekNumber,
|
|
957
|
-
labelWeekNumberHeader: () => labelWeekNumberHeader,
|
|
958
|
-
labelWeekday: () => labelWeekday,
|
|
959
|
-
labelYearDropdown: () => labelYearDropdown
|
|
960
|
-
});
|
|
961
1164
|
var asHtmlElement = (element) => {
|
|
962
1165
|
if (element instanceof HTMLElement) return element;
|
|
963
1166
|
return null;
|
|
@@ -1047,12 +1250,13 @@ function getDates(displayMonths, maxDate, props, dateLib) {
|
|
|
1047
1250
|
const { ISOWeek, fixedWeeks, broadcastCalendar } = props ?? {};
|
|
1048
1251
|
const { addDays: addDays$1, differenceInCalendarDays: differenceInCalendarDays$1, differenceInCalendarMonths: differenceInCalendarMonths$1, endOfBroadcastWeek: endOfBroadcastWeek$1, endOfISOWeek: endOfISOWeek$1, endOfMonth: endOfMonth$1, endOfWeek: endOfWeek$1, isAfter: isAfter$1, startOfBroadcastWeek: startOfBroadcastWeek$1, startOfISOWeek: startOfISOWeek$1, startOfWeek: startOfWeek$1 } = dateLib;
|
|
1049
1252
|
const startWeekFirstDate = broadcastCalendar ? startOfBroadcastWeek$1(firstMonth, dateLib) : ISOWeek ? startOfISOWeek$1(firstMonth) : startOfWeek$1(firstMonth);
|
|
1050
|
-
const
|
|
1253
|
+
const displayMonthsWeekEnd = broadcastCalendar ? endOfBroadcastWeek$1(lastMonth) : ISOWeek ? endOfISOWeek$1(endOfMonth$1(lastMonth)) : endOfWeek$1(endOfMonth$1(lastMonth));
|
|
1254
|
+
const constraintWeekEnd = maxDate && (broadcastCalendar ? endOfBroadcastWeek$1(maxDate) : ISOWeek ? endOfISOWeek$1(maxDate) : endOfWeek$1(maxDate));
|
|
1255
|
+
const nOfDays = differenceInCalendarDays$1(constraintWeekEnd && isAfter$1(displayMonthsWeekEnd, constraintWeekEnd) ? constraintWeekEnd : displayMonthsWeekEnd, startWeekFirstDate);
|
|
1051
1256
|
const nOfMonths = differenceInCalendarMonths$1(lastMonth, firstMonth) + 1;
|
|
1052
1257
|
const dates = [];
|
|
1053
1258
|
for (let i = 0; i <= nOfDays; i++) {
|
|
1054
1259
|
const date = addDays$1(startWeekFirstDate, i);
|
|
1055
|
-
if (maxDate && isAfter$1(date, maxDate)) break;
|
|
1056
1260
|
dates.push(date);
|
|
1057
1261
|
}
|
|
1058
1262
|
const extraDates = (broadcastCalendar ? 35 : 42) * nOfMonths;
|
|
@@ -1527,27 +1731,33 @@ function toTimeZone(date, timeZone) {
|
|
|
1527
1731
|
if (date instanceof TZDate && date.timeZone === timeZone) return date;
|
|
1528
1732
|
return new TZDate(date, timeZone);
|
|
1529
1733
|
}
|
|
1530
|
-
function
|
|
1734
|
+
function toZoneNoon(date, timeZone, noonSafe) {
|
|
1735
|
+
if (!noonSafe) return toTimeZone(date, timeZone);
|
|
1736
|
+
const zoned = toTimeZone(date, timeZone);
|
|
1737
|
+
const noonZoned = new TZDate(zoned.getFullYear(), zoned.getMonth(), zoned.getDate(), 12, 0, 0, timeZone);
|
|
1738
|
+
return new Date(noonZoned.getTime());
|
|
1739
|
+
}
|
|
1740
|
+
function convertMatcher(matcher, timeZone, noonSafe) {
|
|
1531
1741
|
if (typeof matcher === "boolean" || typeof matcher === "function") return matcher;
|
|
1532
|
-
if (matcher instanceof Date) return
|
|
1533
|
-
if (Array.isArray(matcher)) return matcher.map((value) => value instanceof Date ?
|
|
1742
|
+
if (matcher instanceof Date) return toZoneNoon(matcher, timeZone, noonSafe);
|
|
1743
|
+
if (Array.isArray(matcher)) return matcher.map((value) => value instanceof Date ? toZoneNoon(value, timeZone, noonSafe) : value);
|
|
1534
1744
|
if (isDateRange(matcher)) return {
|
|
1535
1745
|
...matcher,
|
|
1536
1746
|
from: matcher.from ? toTimeZone(matcher.from, timeZone) : matcher.from,
|
|
1537
1747
|
to: matcher.to ? toTimeZone(matcher.to, timeZone) : matcher.to
|
|
1538
1748
|
};
|
|
1539
1749
|
if (isDateInterval(matcher)) return {
|
|
1540
|
-
before:
|
|
1541
|
-
after:
|
|
1750
|
+
before: toZoneNoon(matcher.before, timeZone, noonSafe),
|
|
1751
|
+
after: toZoneNoon(matcher.after, timeZone, noonSafe)
|
|
1542
1752
|
};
|
|
1543
|
-
if (isDateAfterType(matcher)) return { after:
|
|
1544
|
-
if (isDateBeforeType(matcher)) return { before:
|
|
1753
|
+
if (isDateAfterType(matcher)) return { after: toZoneNoon(matcher.after, timeZone, noonSafe) };
|
|
1754
|
+
if (isDateBeforeType(matcher)) return { before: toZoneNoon(matcher.before, timeZone, noonSafe) };
|
|
1545
1755
|
return matcher;
|
|
1546
1756
|
}
|
|
1547
|
-
function convertMatchersToTimeZone(matchers, timeZone) {
|
|
1757
|
+
function convertMatchersToTimeZone(matchers, timeZone, noonSafe) {
|
|
1548
1758
|
if (!matchers) return matchers;
|
|
1549
|
-
if (Array.isArray(matchers)) return matchers.map((matcher) => convertMatcher(matcher, timeZone));
|
|
1550
|
-
return convertMatcher(matchers, timeZone);
|
|
1759
|
+
if (Array.isArray(matchers)) return matchers.map((matcher) => convertMatcher(matcher, timeZone, noonSafe));
|
|
1760
|
+
return convertMatcher(matchers, timeZone, noonSafe);
|
|
1551
1761
|
}
|
|
1552
1762
|
function DayPicker(initialProps) {
|
|
1553
1763
|
let props = initialProps;
|
|
@@ -1580,25 +1790,32 @@ function DayPicker(initialProps) {
|
|
|
1580
1790
|
}
|
|
1581
1791
|
const { components, formatters, labels, dateLib, locale, classNames } = useMemo(() => {
|
|
1582
1792
|
const locale$1 = {
|
|
1583
|
-
...
|
|
1793
|
+
...enUS$1,
|
|
1584
1794
|
...props.locale
|
|
1585
1795
|
};
|
|
1796
|
+
const weekStartsOn = props.broadcastCalendar ? 1 : props.weekStartsOn;
|
|
1797
|
+
const noonOverrides = props.noonSafe && props.timeZone ? createNoonOverrides(props.timeZone, {
|
|
1798
|
+
weekStartsOn,
|
|
1799
|
+
locale: locale$1
|
|
1800
|
+
}) : void 0;
|
|
1801
|
+
const overrides = props.dateLib && noonOverrides ? {
|
|
1802
|
+
...noonOverrides,
|
|
1803
|
+
...props.dateLib
|
|
1804
|
+
} : props.dateLib ?? noonOverrides;
|
|
1805
|
+
const dateLib$1 = new DateLib({
|
|
1806
|
+
locale: locale$1,
|
|
1807
|
+
weekStartsOn,
|
|
1808
|
+
firstWeekContainsDate: props.firstWeekContainsDate,
|
|
1809
|
+
useAdditionalWeekYearTokens: props.useAdditionalWeekYearTokens,
|
|
1810
|
+
useAdditionalDayOfYearTokens: props.useAdditionalDayOfYearTokens,
|
|
1811
|
+
timeZone: props.timeZone,
|
|
1812
|
+
numerals: props.numerals
|
|
1813
|
+
}, overrides);
|
|
1586
1814
|
return {
|
|
1587
|
-
dateLib:
|
|
1588
|
-
locale: locale$1,
|
|
1589
|
-
weekStartsOn: props.broadcastCalendar ? 1 : props.weekStartsOn,
|
|
1590
|
-
firstWeekContainsDate: props.firstWeekContainsDate,
|
|
1591
|
-
useAdditionalWeekYearTokens: props.useAdditionalWeekYearTokens,
|
|
1592
|
-
useAdditionalDayOfYearTokens: props.useAdditionalDayOfYearTokens,
|
|
1593
|
-
timeZone: props.timeZone,
|
|
1594
|
-
numerals: props.numerals
|
|
1595
|
-
}, props.dateLib),
|
|
1815
|
+
dateLib: dateLib$1,
|
|
1596
1816
|
components: getComponents(props.components),
|
|
1597
1817
|
formatters: getFormatters(props.formatters),
|
|
1598
|
-
labels:
|
|
1599
|
-
...labels_exports,
|
|
1600
|
-
...props.labels
|
|
1601
|
-
},
|
|
1818
|
+
labels: getLabels(props.labels, dateLib$1.options),
|
|
1602
1819
|
locale: locale$1,
|
|
1603
1820
|
classNames: {
|
|
1604
1821
|
...getDefaultClassNames(),
|
|
@@ -1615,6 +1832,7 @@ function DayPicker(initialProps) {
|
|
|
1615
1832
|
props.timeZone,
|
|
1616
1833
|
props.numerals,
|
|
1617
1834
|
props.dateLib,
|
|
1835
|
+
props.noonSafe,
|
|
1618
1836
|
props.components,
|
|
1619
1837
|
props.formatters,
|
|
1620
1838
|
props.labels,
|
|
@@ -1661,6 +1879,7 @@ function DayPicker(initialProps) {
|
|
|
1661
1879
|
e.preventDefault();
|
|
1662
1880
|
e.stopPropagation();
|
|
1663
1881
|
setFocused(day);
|
|
1882
|
+
if (m.disabled) return;
|
|
1664
1883
|
select?.(day.date, m, e);
|
|
1665
1884
|
onDayClick?.(day.date, m, e);
|
|
1666
1885
|
}, [
|