@helsenorge/datepicker 12.4.0 → 12.7.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/CHANGELOG.md +92 -0
- package/components/DatePicker/DatePicker.d.ts +4 -1
- package/components/DatePicker/index.js +190 -51
- package/components/DatePicker/index.js.map +1 -1
- package/components/DatePicker/resourceHelper.d.ts +3 -0
- package/package.json +1 -1
- package/resources/HN.Designsystem.DatePicker.en-GB.json.d.ts +13 -0
- package/resources/HN.Designsystem.DatePicker.nb-NO.json.d.ts +13 -0
- package/resources/index.d.ts +0 -0
- package/resources/index.js +2 -0
- package/resources/index.js.map +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,95 @@
|
|
|
1
|
+
## [12.7.0](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv12.6.4&targetVersion=GTv12.7.0) (2025-10-17)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
- **formgroup:** endre prop for FormFieldTag til å være lik som i label
|
|
6
|
+
([850b4e0](https://github.com/helsenorge/designsystem/commit/850b4e0cdc5888dbe29ba894c23e460dfe9d4930)), closes
|
|
7
|
+
[#362503](https://github.com/helsenorge/designsystem/issues/362503)
|
|
8
|
+
|
|
9
|
+
## [12.6.4](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv12.6.3&targetVersion=GTv12.6.4) (2025-10-16)
|
|
10
|
+
|
|
11
|
+
### Reverts
|
|
12
|
+
|
|
13
|
+
- Revert "v12.6.3" ([973e6b8](https://github.com/helsenorge/designsystem/commit/973e6b8893fc765892a993adf83d93f4d5bfd5dd))
|
|
14
|
+
|
|
15
|
+
## [12.6.3](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv12.6.2&targetVersion=GTv12.6.3) (2025-10-16)
|
|
16
|
+
|
|
17
|
+
## [12.6.2](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv12.6.1&targetVersion=GTv12.6.2) (2025-10-16)
|
|
18
|
+
|
|
19
|
+
## [12.6.1](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv12.6.0&targetVersion=GTv12.6.1) (2025-10-16)
|
|
20
|
+
|
|
21
|
+
## [12.6.0](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv12.5.0&targetVersion=GTv12.6.0) (2025-10-16)
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
- **formfieldtag:** ny komponent for å markere obligatoriske felter
|
|
26
|
+
([43186e8](https://github.com/helsenorge/designsystem/commit/43186e85e06d6b3e34124c3afd372180ecff9af9)), closes
|
|
27
|
+
[#361861](https://github.com/helsenorge/designsystem/issues/361861)
|
|
28
|
+
- **stickynote:** justeringer etter ny figma komponent
|
|
29
|
+
([b3afb5a](https://github.com/helsenorge/designsystem/commit/b3afb5a41f1400bef0afce40b244deafcac7b505)), closes
|
|
30
|
+
[#361520](https://github.com/helsenorge/designsystem/issues/361520)
|
|
31
|
+
|
|
32
|
+
### Bug Fixes
|
|
33
|
+
|
|
34
|
+
- **formfieldtag:** fiks display for at den holder seg i riktig størrelse
|
|
35
|
+
([1e53dc1](https://github.com/helsenorge/designsystem/commit/1e53dc1cf52215a3476a1d6d86c36f8108b0fbc1)), closes
|
|
36
|
+
[#361861](https://github.com/helsenorge/designsystem/issues/361861)
|
|
37
|
+
- **label:** bruk formfieldtag som komponent slik at man får satt id
|
|
38
|
+
([006e152](https://github.com/helsenorge/designsystem/commit/006e1520cc16b66f637c11c193902510ebd72b76)), closes
|
|
39
|
+
[#361861](https://github.com/helsenorge/designsystem/issues/361861)
|
|
40
|
+
|
|
41
|
+
## [12.5.0](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv12.4.0&targetVersion=GTv12.5.0) (2025-10-08)
|
|
42
|
+
|
|
43
|
+
### Features
|
|
44
|
+
|
|
45
|
+
- **datepicker:** default språkstøtte fra sot
|
|
46
|
+
([1f2b2ae](https://github.com/helsenorge/designsystem/commit/1f2b2ae2ddd0ab527d976ec2d3dc6ec9293f58a0))
|
|
47
|
+
- **drawer:** default språkstøtte fra sot
|
|
48
|
+
([56517c5](https://github.com/helsenorge/designsystem/commit/56517c50ec9f4d61ecbbd3ce2ebbe509d9af898b))
|
|
49
|
+
- **formgroup:** lagt til legendclassname prop
|
|
50
|
+
([9dbd90c](https://github.com/helsenorge/designsystem/commit/9dbd90c7efbb838fb5204870bcfd90a089d03f4c)), closes
|
|
51
|
+
[#360836](https://github.com/helsenorge/designsystem/issues/360836)
|
|
52
|
+
- **helptriggericon:** lagt til classname prop
|
|
53
|
+
([b9d207e](https://github.com/helsenorge/designsystem/commit/b9d207ec0871ce79259562042f4b321b21b94fd8)), closes
|
|
54
|
+
[#360496](https://github.com/helsenorge/designsystem/issues/360496)
|
|
55
|
+
- **icon:** nytt ikon feedback ([0e3f89c](https://github.com/helsenorge/designsystem/commit/0e3f89c04c897c8667593396cecaceb8d50fd879)),
|
|
56
|
+
closes [#360055](https://github.com/helsenorge/designsystem/issues/360055)
|
|
57
|
+
- **listeditmode:** funksjonalitet for å redigere liste
|
|
58
|
+
([d87e8c5](https://github.com/helsenorge/designsystem/commit/d87e8c59d44ce2278b403df3c3858029db280ad0)), closes
|
|
59
|
+
[#359697](https://github.com/helsenorge/designsystem/issues/359697)
|
|
60
|
+
- **tabs:** default språkstøtte fra sot
|
|
61
|
+
([733fd7e](https://github.com/helsenorge/designsystem/commit/733fd7e559e57cb3dfaf5e2efd52ac8754db8f6d))
|
|
62
|
+
|
|
63
|
+
### Bug Fixes
|
|
64
|
+
|
|
65
|
+
- **drawer:** legg breakpoint check på outer level for å vise animasjon riktig igjen
|
|
66
|
+
([04f604a](https://github.com/helsenorge/designsystem/commit/04f604aaba66738ac710c28cb5514ec7b0d2967a)), closes
|
|
67
|
+
[#360641](https://github.com/helsenorge/designsystem/issues/360641)
|
|
68
|
+
- **favoritebutton:** kun vis fokusstrek på focus-visible"
|
|
69
|
+
([2dc6b2f](https://github.com/helsenorge/designsystem/commit/2dc6b2f954cdb7a5b5b3e7326a8c0d42723ef972)), closes
|
|
70
|
+
[#357829](https://github.com/helsenorge/designsystem/issues/357829)
|
|
71
|
+
- **helptriggericon:** fiks så komponenten fungerer i liste igjen
|
|
72
|
+
([45f801e](https://github.com/helsenorge/designsystem/commit/45f801edb77306cd7cba614396a7abc1089a610b)), closes
|
|
73
|
+
[#353532](https://github.com/helsenorge/designsystem/issues/353532) [#360885](https://github.com/helsenorge/designsystem/issues/360885)
|
|
74
|
+
- **helptriggericon:** juster ikon ift tekst uten å endre linjehøyde
|
|
75
|
+
([687a0fa](https://github.com/helsenorge/designsystem/commit/687a0fa13798a757408d417bde0d9bdb57cb59e1)), closes
|
|
76
|
+
[#360885](https://github.com/helsenorge/designsystem/issues/360885)
|
|
77
|
+
- **list:** vertikalt align knapper riktig i liste
|
|
78
|
+
([2926423](https://github.com/helsenorge/designsystem/commit/2926423198f6459228ea28b5c68945407756c6e3)), closes
|
|
79
|
+
[#353532](https://github.com/helsenorge/designsystem/issues/353532)
|
|
80
|
+
- **panel:** juster paddings for å ta hensyn til statuslinje
|
|
81
|
+
([1e8f5ff](https://github.com/helsenorge/designsystem/commit/1e8f5ff07c8e796af7269b3f4b92269a50d4fdcb)), closes
|
|
82
|
+
[#360101](https://github.com/helsenorge/designsystem/issues/360101)
|
|
83
|
+
- **popmenu:** ikon sentreres riktig
|
|
84
|
+
([3a8f5ac](https://github.com/helsenorge/designsystem/commit/3a8f5ac3dd9dfcff4fc75f101a4f4a6dbfbd1c88)), closes
|
|
85
|
+
[#361064](https://github.com/helsenorge/designsystem/issues/361064)
|
|
86
|
+
- **radiobutton:** disabled har samme radius som andre states
|
|
87
|
+
([27548a7](https://github.com/helsenorge/designsystem/commit/27548a74a68ac6c2d4c5783b84da056971995a4d)), closes
|
|
88
|
+
[#350142](https://github.com/helsenorge/designsystem/issues/350142)
|
|
89
|
+
- **radiobutton:** hele wrapperen skal ikke se klikkbar ut
|
|
90
|
+
([2c396cd](https://github.com/helsenorge/designsystem/commit/2c396cd1a5c79869ef9d72941c9c93efba47dc47)), closes
|
|
91
|
+
[#350142](https://github.com/helsenorge/designsystem/issues/350142)
|
|
92
|
+
|
|
1
93
|
## [12.4.0](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv12.3.0&targetVersion=GTv12.4.0) (2025-09-23)
|
|
2
94
|
|
|
3
95
|
### Features
|
|
@@ -4,13 +4,14 @@ import { DayPickerProps } from 'react-day-picker';
|
|
|
4
4
|
import { ErrorWrapperClassNameProps } from '@helsenorge/designsystem-react/components/ErrorWrapper';
|
|
5
5
|
import { PopOverVariant } from '@helsenorge/designsystem-react/components/PopOver';
|
|
6
6
|
import { DatePickerAriaLabels } from './DatePickerPopup';
|
|
7
|
+
import { HNDesignsystemDatePicker } from '../../resources/Resources';
|
|
7
8
|
export type DateFormat = 'dd.MM.yyyy';
|
|
8
9
|
export interface DatePickerProps extends ErrorWrapperClassNameProps, Pick<React.InputHTMLAttributes<HTMLInputElement>, 'name' | 'aria-describedby' | 'onBlur' | 'autoComplete'>, Pick<DayPickerProps, 'dir' | 'initialFocus'> {
|
|
9
10
|
/** Setter labels for popup på desktop visning */
|
|
10
11
|
ariaLabels?: DatePickerAriaLabels;
|
|
11
12
|
/** Adds custom classes to the element. */
|
|
12
13
|
className?: string;
|
|
13
|
-
/** Sets aria-label on the button that opens the datepicker dialogue */
|
|
14
|
+
/** @deprecated Sets aria-label on the button that opens the datepicker dialogue */
|
|
14
15
|
dateButtonAriaLabel?: string;
|
|
15
16
|
/** Sets the format of the date - only applies for desktop use. Native mobile date fields base their formats on the device */
|
|
16
17
|
dateFormat?: DateFormat;
|
|
@@ -46,6 +47,8 @@ export interface DatePickerProps extends ErrorWrapperClassNameProps, Pick<React.
|
|
|
46
47
|
onChange?: (event: React.ChangeEvent<HTMLInputElement> | React.MouseEvent<Element, MouseEvent> | React.KeyboardEvent<Element>, date?: Date | string) => void;
|
|
47
48
|
/** Only use this to trigger validation. Callback triggered by change in chosen date via the datepicker popup */
|
|
48
49
|
onDatePopupClosed?: (date: Date | string | undefined) => void;
|
|
50
|
+
/** Resources for component */
|
|
51
|
+
resources?: Partial<HNDesignsystemDatePicker>;
|
|
49
52
|
/** Sets the data-testid attribute. */
|
|
50
53
|
testId?: string;
|
|
51
54
|
/** Determines the placement of the DatePicker popup. Default: automatic positioning. */
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
2
|
import React, { createContext, useContext, useCallback, useRef, useLayoutEffect, useState, useEffect, useMemo } from "react";
|
|
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";
|
|
3
|
+
import { addDays, addMonths, addWeeks, addYears, differenceInCalendarDays, differenceInCalendarMonths, eachMonthOfInterval, eachYearOfInterval, 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 { 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";
|
|
7
7
|
import Calendar from "@helsenorge/designsystem-react/components/Icons/Calendar";
|
|
8
8
|
import Input from "@helsenorge/designsystem-react/components/Input";
|
|
9
9
|
import { PopOverVariant } from "@helsenorge/designsystem-react/components/PopOver";
|
|
10
|
-
import { ZIndex, KeyboardEventKey } from "@helsenorge/designsystem-react/constants";
|
|
10
|
+
import { ZIndex, LanguageLocales as LanguageLocales$1, KeyboardEventKey } from "@helsenorge/designsystem-react/constants";
|
|
11
11
|
import { useKeyboardEvent } from "@helsenorge/designsystem-react/hooks/useKeyboardEvent";
|
|
12
12
|
import { useOutsideEvent } from "@helsenorge/designsystem-react/hooks/useOutsideEvent";
|
|
13
13
|
import { usePseudoClasses } from "@helsenorge/designsystem-react/hooks/usePseudoClasses";
|
|
14
|
+
import { useLanguage } from "@helsenorge/designsystem-react/utils/language";
|
|
14
15
|
import { isMobileUA } from "@helsenorge/designsystem-react/utils/mobile";
|
|
15
16
|
import { isMutableRefObject, mergeRefs } from "@helsenorge/designsystem-react/utils/refs";
|
|
16
17
|
import classNames from "classnames";
|
|
@@ -22,6 +23,7 @@ import { useSize } from "@helsenorge/designsystem-react/hooks/useSize";
|
|
|
22
23
|
import { getSpacer } from "@helsenorge/designsystem-react/theme/currys/spacing";
|
|
23
24
|
import styles from "./styles.module.scss";
|
|
24
25
|
import { enUS } from "date-fns/locale/en-US";
|
|
26
|
+
import { LanguageLocales } from "@helsenorge/designsystem-react";
|
|
25
27
|
import ErrorWrapper from "@helsenorge/designsystem-react/components/ErrorWrapper";
|
|
26
28
|
import { useUuid } from "@helsenorge/designsystem-react/hooks/useUuid";
|
|
27
29
|
import { isComponent } from "@helsenorge/designsystem-react/utils/component";
|
|
@@ -323,6 +325,19 @@ class DateLib {
|
|
|
323
325
|
var _a;
|
|
324
326
|
return ((_a = this.overrides) == null ? void 0 : _a.eachMonthOfInterval) ? this.overrides.eachMonthOfInterval(interval) : eachMonthOfInterval(interval);
|
|
325
327
|
};
|
|
328
|
+
this.eachYearOfInterval = (interval) => {
|
|
329
|
+
var _a;
|
|
330
|
+
const years = ((_a = this.overrides) == null ? void 0 : _a.eachYearOfInterval) ? this.overrides.eachYearOfInterval(interval) : eachYearOfInterval(interval);
|
|
331
|
+
const uniqueYears = new Set(years.map((d) => this.getYear(d)));
|
|
332
|
+
if (uniqueYears.size === years.length) {
|
|
333
|
+
return years;
|
|
334
|
+
}
|
|
335
|
+
const yearsArray = [];
|
|
336
|
+
uniqueYears.forEach((y) => {
|
|
337
|
+
yearsArray.push(new Date(y, 0, 1));
|
|
338
|
+
});
|
|
339
|
+
return yearsArray;
|
|
340
|
+
};
|
|
326
341
|
this.endOfBroadcastWeek = (date) => {
|
|
327
342
|
var _a;
|
|
328
343
|
return ((_a = this.overrides) == null ? void 0 : _a.endOfBroadcastWeek) ? this.overrides.endOfBroadcastWeek(date) : endOfBroadcastWeek(date, this);
|
|
@@ -473,7 +488,62 @@ class DateLib {
|
|
|
473
488
|
formatNumber(value) {
|
|
474
489
|
return this.replaceDigits(value.toString());
|
|
475
490
|
}
|
|
476
|
-
|
|
491
|
+
/**
|
|
492
|
+
* Returns the preferred ordering for month and year labels for the current
|
|
493
|
+
* locale.
|
|
494
|
+
*/
|
|
495
|
+
getMonthYearOrder() {
|
|
496
|
+
var _a;
|
|
497
|
+
const code = (_a = this.options.locale) == null ? void 0 : _a.code;
|
|
498
|
+
if (!code) {
|
|
499
|
+
return "month-first";
|
|
500
|
+
}
|
|
501
|
+
return DateLib.yearFirstLocales.has(code) ? "year-first" : "month-first";
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Formats the month/year pair respecting locale conventions.
|
|
505
|
+
*
|
|
506
|
+
* @since 9.11.0
|
|
507
|
+
*/
|
|
508
|
+
formatMonthYear(date) {
|
|
509
|
+
const { locale, timeZone, numerals } = this.options;
|
|
510
|
+
const localeCode = locale == null ? void 0 : locale.code;
|
|
511
|
+
if (localeCode && DateLib.yearFirstLocales.has(localeCode)) {
|
|
512
|
+
try {
|
|
513
|
+
const intl = new Intl.DateTimeFormat(localeCode, {
|
|
514
|
+
month: "long",
|
|
515
|
+
year: "numeric",
|
|
516
|
+
timeZone,
|
|
517
|
+
numberingSystem: numerals
|
|
518
|
+
});
|
|
519
|
+
const formatted = intl.format(date);
|
|
520
|
+
return formatted;
|
|
521
|
+
} catch {
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
const pattern = this.getMonthYearOrder() === "year-first" ? "y LLLL" : "LLLL y";
|
|
525
|
+
return this.format(date, pattern);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
DateLib.yearFirstLocales = /* @__PURE__ */ new Set([
|
|
529
|
+
"eu",
|
|
530
|
+
"hu",
|
|
531
|
+
"ja",
|
|
532
|
+
"ja-Hira",
|
|
533
|
+
"ja-JP",
|
|
534
|
+
"ko",
|
|
535
|
+
"ko-KR",
|
|
536
|
+
"lt",
|
|
537
|
+
"lt-LT",
|
|
538
|
+
"lv",
|
|
539
|
+
"lv-LV",
|
|
540
|
+
"mn",
|
|
541
|
+
"mn-MN",
|
|
542
|
+
"zh",
|
|
543
|
+
"zh-CN",
|
|
544
|
+
"zh-HK",
|
|
545
|
+
"zh-TW"
|
|
546
|
+
]);
|
|
477
547
|
const defaultDateLib = new DateLib();
|
|
478
548
|
class CalendarDay {
|
|
479
549
|
constructor(date, displayMonth, dateLib = defaultDateLib) {
|
|
@@ -641,30 +711,30 @@ function MonthsDropdown(props) {
|
|
|
641
711
|
return React.createElement(components2.Dropdown, { ...props });
|
|
642
712
|
}
|
|
643
713
|
function Nav(props) {
|
|
644
|
-
const { onPreviousClick, onNextClick, previousMonth, nextMonth, ...navProps } = props;
|
|
714
|
+
const { onPreviousClick, onNextClick, previousMonth: previousMonth2, nextMonth: nextMonth2, ...navProps } = props;
|
|
645
715
|
const { components: components2, classNames: classNames2, labels: { labelPrevious: labelPrevious2, labelNext: labelNext2 } } = useDayPicker();
|
|
646
716
|
const handleNextClick = useCallback((e) => {
|
|
647
|
-
if (
|
|
717
|
+
if (nextMonth2) {
|
|
648
718
|
onNextClick == null ? void 0 : onNextClick(e);
|
|
649
719
|
}
|
|
650
|
-
}, [
|
|
720
|
+
}, [nextMonth2, onNextClick]);
|
|
651
721
|
const handlePreviousClick = useCallback((e) => {
|
|
652
|
-
if (
|
|
722
|
+
if (previousMonth2) {
|
|
653
723
|
onPreviousClick == null ? void 0 : onPreviousClick(e);
|
|
654
724
|
}
|
|
655
|
-
}, [
|
|
725
|
+
}, [previousMonth2, onPreviousClick]);
|
|
656
726
|
return React.createElement(
|
|
657
727
|
"nav",
|
|
658
728
|
{ ...navProps },
|
|
659
729
|
React.createElement(
|
|
660
730
|
components2.PreviousMonthButton,
|
|
661
|
-
{ type: "button", className: classNames2[UI.PreviousMonthButton], tabIndex:
|
|
662
|
-
React.createElement(components2.Chevron, { disabled:
|
|
731
|
+
{ type: "button", className: classNames2[UI.PreviousMonthButton], tabIndex: previousMonth2 ? void 0 : -1, "aria-disabled": previousMonth2 ? void 0 : true, "aria-label": labelPrevious2(previousMonth2), onClick: handlePreviousClick },
|
|
732
|
+
React.createElement(components2.Chevron, { disabled: previousMonth2 ? void 0 : true, className: classNames2[UI.Chevron], orientation: "left" })
|
|
663
733
|
),
|
|
664
734
|
React.createElement(
|
|
665
735
|
components2.NextMonthButton,
|
|
666
|
-
{ type: "button", className: classNames2[UI.NextMonthButton], tabIndex:
|
|
667
|
-
React.createElement(components2.Chevron, { disabled:
|
|
736
|
+
{ type: "button", className: classNames2[UI.NextMonthButton], tabIndex: nextMonth2 ? void 0 : -1, "aria-disabled": nextMonth2 ? void 0 : true, "aria-label": labelNext2(nextMonth2), onClick: handleNextClick },
|
|
737
|
+
React.createElement(components2.Chevron, { disabled: nextMonth2 ? void 0 : true, orientation: "right", className: classNames2[UI.Chevron] })
|
|
668
738
|
)
|
|
669
739
|
);
|
|
670
740
|
}
|
|
@@ -945,7 +1015,8 @@ function getDefaultClassNames() {
|
|
|
945
1015
|
return classNames2;
|
|
946
1016
|
}
|
|
947
1017
|
function formatCaption(month, options, dateLib) {
|
|
948
|
-
|
|
1018
|
+
const lib = dateLib ?? new DateLib(options);
|
|
1019
|
+
return lib.formatMonthYear(month);
|
|
949
1020
|
}
|
|
950
1021
|
const formatMonthCaption = formatCaption;
|
|
951
1022
|
function formatDay(date, options, dateLib) {
|
|
@@ -1033,21 +1104,16 @@ function getYearOptions(navStart, navEnd, formatters, dateLib, reverse = false)
|
|
|
1033
1104
|
return void 0;
|
|
1034
1105
|
if (!navEnd)
|
|
1035
1106
|
return void 0;
|
|
1036
|
-
const { startOfYear: startOfYear2, endOfYear: endOfYear2,
|
|
1107
|
+
const { startOfYear: startOfYear2, endOfYear: endOfYear2, eachYearOfInterval: eachYearOfInterval2, getYear: getYear2 } = dateLib;
|
|
1037
1108
|
const firstNavYear = startOfYear2(navStart);
|
|
1038
1109
|
const lastNavYear = endOfYear2(navEnd);
|
|
1039
|
-
const years =
|
|
1040
|
-
let year = firstNavYear;
|
|
1041
|
-
while (isBefore2(year, lastNavYear) || isSameYear2(year, lastNavYear)) {
|
|
1042
|
-
years.push(year);
|
|
1043
|
-
year = addYears2(year, 1);
|
|
1044
|
-
}
|
|
1110
|
+
const years = eachYearOfInterval2({ start: firstNavYear, end: lastNavYear });
|
|
1045
1111
|
if (reverse)
|
|
1046
1112
|
years.reverse();
|
|
1047
|
-
return years.map((
|
|
1048
|
-
const label = formatters.formatYearDropdown(
|
|
1113
|
+
return years.map((year) => {
|
|
1114
|
+
const label = formatters.formatYearDropdown(year, dateLib);
|
|
1049
1115
|
return {
|
|
1050
|
-
value: getYear2(
|
|
1116
|
+
value: getYear2(year),
|
|
1051
1117
|
label,
|
|
1052
1118
|
disabled: false
|
|
1053
1119
|
};
|
|
@@ -1063,7 +1129,8 @@ function labelDayButton(date, modifiers, options, dateLib) {
|
|
|
1063
1129
|
}
|
|
1064
1130
|
const labelDay = labelDayButton;
|
|
1065
1131
|
function labelGrid(date, options, dateLib) {
|
|
1066
|
-
|
|
1132
|
+
const lib = dateLib ?? new DateLib(options);
|
|
1133
|
+
return lib.formatMonthYear(date);
|
|
1067
1134
|
}
|
|
1068
1135
|
const labelCaption = labelGrid;
|
|
1069
1136
|
function labelGridcell(date, modifiers, options, dateLib) {
|
|
@@ -1434,8 +1501,8 @@ function useCalendar(props, dateLib) {
|
|
|
1434
1501
|
const months = getMonths(displayMonths, dates, props, dateLib);
|
|
1435
1502
|
const weeks = getWeeks(months);
|
|
1436
1503
|
const days = getDays(months);
|
|
1437
|
-
const
|
|
1438
|
-
const
|
|
1504
|
+
const previousMonth2 = getPreviousMonth(firstMonth, navStart, props, dateLib);
|
|
1505
|
+
const nextMonth2 = getNextMonth(firstMonth, navEnd, props, dateLib);
|
|
1439
1506
|
const { disableNavigation, onMonthChange } = props;
|
|
1440
1507
|
const isDayInCalendar = (day) => weeks.some((week) => week.days.some((d) => d.isEqualTo(day)));
|
|
1441
1508
|
const goToMonth = (date) => {
|
|
@@ -1464,8 +1531,8 @@ function useCalendar(props, dateLib) {
|
|
|
1464
1531
|
days,
|
|
1465
1532
|
navStart,
|
|
1466
1533
|
navEnd,
|
|
1467
|
-
previousMonth,
|
|
1468
|
-
nextMonth,
|
|
1534
|
+
previousMonth: previousMonth2,
|
|
1535
|
+
nextMonth: nextMonth2,
|
|
1469
1536
|
goToMonth,
|
|
1470
1537
|
goToDay
|
|
1471
1538
|
};
|
|
@@ -1555,6 +1622,12 @@ function useFocus(props, calendar, getModifiers, isSelected, dateLib) {
|
|
|
1555
1622
|
const nextFocus = getNextFocus(moveBy, moveDir, focusedDay, calendar.navStart, calendar.navEnd, props, dateLib);
|
|
1556
1623
|
if (!nextFocus)
|
|
1557
1624
|
return;
|
|
1625
|
+
if (props.disableNavigation) {
|
|
1626
|
+
const isNextInCalendar = calendar.days.some((day) => day.isEqualTo(nextFocus));
|
|
1627
|
+
if (!isNextInCalendar) {
|
|
1628
|
+
return;
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1558
1631
|
calendar.goToDay(nextFocus);
|
|
1559
1632
|
setFocused(nextFocus);
|
|
1560
1633
|
};
|
|
@@ -1867,7 +1940,7 @@ function DayPicker(initialProps) {
|
|
|
1867
1940
|
const { captionLayout, mode, navLayout, numberOfMonths = 1, onDayBlur, onDayClick, onDayFocus, onDayKeyDown, onDayMouseEnter, onDayMouseLeave, onNextClick, onPrevClick, showWeekNumber, styles: styles2 } = props;
|
|
1868
1941
|
const { formatCaption: formatCaption2, formatDay: formatDay2, formatMonthDropdown: formatMonthDropdown2, formatWeekNumber: formatWeekNumber2, formatWeekNumberHeader: formatWeekNumberHeader2, formatWeekdayName: formatWeekdayName2, formatYearDropdown: formatYearDropdown2 } = formatters;
|
|
1869
1942
|
const calendar = useCalendar(props, dateLib);
|
|
1870
|
-
const { days, months, navStart, navEnd, previousMonth, nextMonth, goToMonth } = calendar;
|
|
1943
|
+
const { days, months, navStart, navEnd, previousMonth: previousMonth2, nextMonth: nextMonth2, goToMonth } = calendar;
|
|
1871
1944
|
const getModifiers = createGetModifiers(days, props, navStart, navEnd, dateLib);
|
|
1872
1945
|
const { isSelected, select, selected: selectedValue } = useSelection(props, dateLib) ?? {};
|
|
1873
1946
|
const { blur, focused, isFocusTarget, moveFocus, setFocused } = useFocus(props, calendar, getModifiers, isSelected ?? (() => false), dateLib);
|
|
@@ -1875,17 +1948,17 @@ function DayPicker(initialProps) {
|
|
|
1875
1948
|
const weekdays = useMemo(() => getWeekdays(dateLib, props.ISOWeek), [dateLib, props.ISOWeek]);
|
|
1876
1949
|
const isInteractive = mode !== void 0 || onDayClick !== void 0;
|
|
1877
1950
|
const handlePreviousClick = useCallback(() => {
|
|
1878
|
-
if (!
|
|
1951
|
+
if (!previousMonth2)
|
|
1879
1952
|
return;
|
|
1880
|
-
goToMonth(
|
|
1881
|
-
onPrevClick == null ? void 0 : onPrevClick(
|
|
1882
|
-
}, [
|
|
1953
|
+
goToMonth(previousMonth2);
|
|
1954
|
+
onPrevClick == null ? void 0 : onPrevClick(previousMonth2);
|
|
1955
|
+
}, [previousMonth2, goToMonth, onPrevClick]);
|
|
1883
1956
|
const handleNextClick = useCallback(() => {
|
|
1884
|
-
if (!
|
|
1957
|
+
if (!nextMonth2)
|
|
1885
1958
|
return;
|
|
1886
|
-
goToMonth(
|
|
1887
|
-
onNextClick == null ? void 0 : onNextClick(
|
|
1888
|
-
}, [goToMonth,
|
|
1959
|
+
goToMonth(nextMonth2);
|
|
1960
|
+
onNextClick == null ? void 0 : onNextClick(nextMonth2);
|
|
1961
|
+
}, [goToMonth, nextMonth2, onNextClick]);
|
|
1889
1962
|
const handleDayClick = useCallback((day, m) => (e) => {
|
|
1890
1963
|
e.preventDefault();
|
|
1891
1964
|
e.stopPropagation();
|
|
@@ -1960,8 +2033,8 @@ function DayPicker(initialProps) {
|
|
|
1960
2033
|
select,
|
|
1961
2034
|
isSelected,
|
|
1962
2035
|
months,
|
|
1963
|
-
nextMonth,
|
|
1964
|
-
previousMonth,
|
|
2036
|
+
nextMonth: nextMonth2,
|
|
2037
|
+
previousMonth: previousMonth2,
|
|
1965
2038
|
goToMonth,
|
|
1966
2039
|
getModifiers,
|
|
1967
2040
|
components: components2,
|
|
@@ -1975,11 +2048,11 @@ function DayPicker(initialProps) {
|
|
|
1975
2048
|
{ value: contextValue },
|
|
1976
2049
|
React.createElement(
|
|
1977
2050
|
components2.Root,
|
|
1978
|
-
{ rootRef: props.animate ? rootElRef : void 0, className, style, dir: props.dir, id: props.id, lang: props.lang, nonce: props.nonce, title: props.title, role: props.role, "aria-label": props["aria-label"], ...dataAttributes },
|
|
2051
|
+
{ rootRef: props.animate ? rootElRef : void 0, className, style, dir: props.dir, id: props.id, lang: props.lang, nonce: props.nonce, title: props.title, role: props.role, "aria-label": props["aria-label"], "aria-labelledby": props["aria-labelledby"], ...dataAttributes },
|
|
1979
2052
|
React.createElement(
|
|
1980
2053
|
components2.Months,
|
|
1981
2054
|
{ className: classNames2[UI.Months], style: styles2 == null ? void 0 : styles2[UI.Months] },
|
|
1982
|
-
!props.hideNavigation && !navLayout && React.createElement(components2.Nav, { "data-animated-nav": props.animate ? "true" : void 0, className: classNames2[UI.Nav], style: styles2 == null ? void 0 : styles2[UI.Nav], "aria-label": labelNav2(), onPreviousClick: handlePreviousClick, onNextClick: handleNextClick, previousMonth, nextMonth }),
|
|
2055
|
+
!props.hideNavigation && !navLayout && React.createElement(components2.Nav, { "data-animated-nav": props.animate ? "true" : void 0, className: classNames2[UI.Nav], style: styles2 == null ? void 0 : styles2[UI.Nav], "aria-label": labelNav2(), onPreviousClick: handlePreviousClick, onNextClick: handleNextClick, previousMonth: previousMonth2, nextMonth: nextMonth2 }),
|
|
1983
2056
|
months.map((calendarMonth, displayIndex) => {
|
|
1984
2057
|
return React.createElement(
|
|
1985
2058
|
components2.Month,
|
|
@@ -1994,14 +2067,18 @@ function DayPicker(initialProps) {
|
|
|
1994
2067
|
},
|
|
1995
2068
|
navLayout === "around" && !props.hideNavigation && displayIndex === 0 && React.createElement(
|
|
1996
2069
|
components2.PreviousMonthButton,
|
|
1997
|
-
{ type: "button", className: classNames2[UI.PreviousMonthButton], tabIndex:
|
|
1998
|
-
React.createElement(components2.Chevron, { disabled:
|
|
2070
|
+
{ type: "button", className: classNames2[UI.PreviousMonthButton], tabIndex: previousMonth2 ? void 0 : -1, "aria-disabled": previousMonth2 ? void 0 : true, "aria-label": labelPrevious2(previousMonth2), onClick: handlePreviousClick, "data-animated-button": props.animate ? "true" : void 0 },
|
|
2071
|
+
React.createElement(components2.Chevron, { disabled: previousMonth2 ? void 0 : true, className: classNames2[UI.Chevron], orientation: props.dir === "rtl" ? "right" : "left" })
|
|
1999
2072
|
),
|
|
2000
2073
|
React.createElement(components2.MonthCaption, { "data-animated-caption": props.animate ? "true" : void 0, className: classNames2[UI.MonthCaption], style: styles2 == null ? void 0 : styles2[UI.MonthCaption], calendarMonth, displayIndex }, (captionLayout == null ? void 0 : captionLayout.startsWith("dropdown")) ? React.createElement(
|
|
2001
2074
|
components2.DropdownNav,
|
|
2002
2075
|
{ className: classNames2[UI.Dropdowns], style: styles2 == null ? void 0 : styles2[UI.Dropdowns] },
|
|
2003
|
-
|
|
2004
|
-
|
|
2076
|
+
(() => {
|
|
2077
|
+
const monthControl = captionLayout === "dropdown" || captionLayout === "dropdown-months" ? React.createElement(components2.MonthsDropdown, { key: "month", className: classNames2[UI.MonthsDropdown], "aria-label": labelMonthDropdown2(), classNames: classNames2, components: components2, disabled: Boolean(props.disableNavigation), onChange: handleMonthChange(calendarMonth.date), options: getMonthOptions(calendarMonth.date, navStart, navEnd, formatters, dateLib), style: styles2 == null ? void 0 : styles2[UI.Dropdown], value: dateLib.getMonth(calendarMonth.date) }) : React.createElement("span", { key: "month" }, formatMonthDropdown2(calendarMonth.date, dateLib));
|
|
2078
|
+
const yearControl = captionLayout === "dropdown" || captionLayout === "dropdown-years" ? React.createElement(components2.YearsDropdown, { key: "year", className: classNames2[UI.YearsDropdown], "aria-label": labelYearDropdown2(dateLib.options), classNames: classNames2, components: components2, disabled: Boolean(props.disableNavigation), onChange: handleYearChange(calendarMonth.date), options: getYearOptions(navStart, navEnd, formatters, dateLib, Boolean(props.reverseYears)), style: styles2 == null ? void 0 : styles2[UI.Dropdown], value: dateLib.getYear(calendarMonth.date) }) : React.createElement("span", { key: "year" }, formatYearDropdown2(calendarMonth.date, dateLib));
|
|
2079
|
+
const controls = dateLib.getMonthYearOrder() === "year-first" ? [yearControl, monthControl] : [monthControl, yearControl];
|
|
2080
|
+
return controls;
|
|
2081
|
+
})(),
|
|
2005
2082
|
React.createElement("span", { role: "status", "aria-live": "polite", style: {
|
|
2006
2083
|
border: 0,
|
|
2007
2084
|
clip: "rect(0 0 0 0)",
|
|
@@ -2020,10 +2097,10 @@ function DayPicker(initialProps) {
|
|
|
2020
2097
|
)),
|
|
2021
2098
|
navLayout === "around" && !props.hideNavigation && displayIndex === numberOfMonths - 1 && React.createElement(
|
|
2022
2099
|
components2.NextMonthButton,
|
|
2023
|
-
{ type: "button", className: classNames2[UI.NextMonthButton], tabIndex:
|
|
2024
|
-
React.createElement(components2.Chevron, { disabled:
|
|
2100
|
+
{ type: "button", className: classNames2[UI.NextMonthButton], tabIndex: nextMonth2 ? void 0 : -1, "aria-disabled": nextMonth2 ? void 0 : true, "aria-label": labelNext2(nextMonth2), onClick: handleNextClick, "data-animated-button": props.animate ? "true" : void 0 },
|
|
2101
|
+
React.createElement(components2.Chevron, { disabled: nextMonth2 ? void 0 : true, className: classNames2[UI.Chevron], orientation: props.dir === "rtl" ? "left" : "right" })
|
|
2025
2102
|
),
|
|
2026
|
-
displayIndex === numberOfMonths - 1 && navLayout === "after" && !props.hideNavigation && React.createElement(components2.Nav, { "data-animated-nav": props.animate ? "true" : void 0, className: classNames2[UI.Nav], style: styles2 == null ? void 0 : styles2[UI.Nav], "aria-label": labelNav2(), onPreviousClick: handlePreviousClick, onNextClick: handleNextClick, previousMonth, nextMonth }),
|
|
2103
|
+
displayIndex === numberOfMonths - 1 && navLayout === "after" && !props.hideNavigation && React.createElement(components2.Nav, { "data-animated-nav": props.animate ? "true" : void 0, className: classNames2[UI.Nav], style: styles2 == null ? void 0 : styles2[UI.Nav], "aria-label": labelNav2(), onPreviousClick: handlePreviousClick, onNextClick: handleNextClick, previousMonth: previousMonth2, nextMonth: nextMonth2 }),
|
|
2027
2104
|
React.createElement(
|
|
2028
2105
|
components2.MonthGrid,
|
|
2029
2106
|
{ role: "grid", "aria-multiselectable": mode === "multiple" || mode === "range", "aria-label": labelGrid2(calendarMonth.date, dateLib.options, dateLib) || void 0, className: classNames2[UI.MonthGrid], style: styles2 == null ? void 0 : styles2[UI.MonthGrid] },
|
|
@@ -2282,10 +2359,55 @@ const DatePickerPopup = (props) => {
|
|
|
2282
2359
|
/* @__PURE__ */ jsx("div", { ref: arrowRef, className: popupArrowClasses, style: { ...arrowStyle, zIndex } })
|
|
2283
2360
|
] });
|
|
2284
2361
|
};
|
|
2362
|
+
const dateButtonAriaLabel$1 = "Open datepicker";
|
|
2363
|
+
const dayButtonBase$1 = "{date}";
|
|
2364
|
+
const dayButtonToday$1 = "Today, {date}";
|
|
2365
|
+
const dayButtonSelected$1 = "{date}, selected";
|
|
2366
|
+
const nextMonth$1 = "Next month";
|
|
2367
|
+
const previousMonth$1 = "Previous month";
|
|
2368
|
+
const monthDropdown$1 = "Select month";
|
|
2369
|
+
const yearDropdown$1 = "Select year";
|
|
2370
|
+
const enGB = {
|
|
2371
|
+
dateButtonAriaLabel: dateButtonAriaLabel$1,
|
|
2372
|
+
dayButtonBase: dayButtonBase$1,
|
|
2373
|
+
dayButtonToday: dayButtonToday$1,
|
|
2374
|
+
dayButtonSelected: dayButtonSelected$1,
|
|
2375
|
+
nextMonth: nextMonth$1,
|
|
2376
|
+
previousMonth: previousMonth$1,
|
|
2377
|
+
monthDropdown: monthDropdown$1,
|
|
2378
|
+
yearDropdown: yearDropdown$1
|
|
2379
|
+
};
|
|
2380
|
+
const dateButtonAriaLabel = "Åpne datovelger";
|
|
2381
|
+
const dayButtonBase = "{date}";
|
|
2382
|
+
const dayButtonToday = "I dag, {date}";
|
|
2383
|
+
const dayButtonSelected = "{date} valgt";
|
|
2384
|
+
const nextMonth = "Neste måned";
|
|
2385
|
+
const previousMonth = "Forrige måned";
|
|
2386
|
+
const monthDropdown = "Velg måned";
|
|
2387
|
+
const yearDropdown = "Velg år";
|
|
2388
|
+
const nbNO = {
|
|
2389
|
+
dateButtonAriaLabel,
|
|
2390
|
+
dayButtonBase,
|
|
2391
|
+
dayButtonToday,
|
|
2392
|
+
dayButtonSelected,
|
|
2393
|
+
nextMonth,
|
|
2394
|
+
previousMonth,
|
|
2395
|
+
monthDropdown,
|
|
2396
|
+
yearDropdown
|
|
2397
|
+
};
|
|
2398
|
+
const getResources = (language) => {
|
|
2399
|
+
switch (language) {
|
|
2400
|
+
case LanguageLocales.ENGLISH:
|
|
2401
|
+
return enGB;
|
|
2402
|
+
case LanguageLocales.NORWEGIAN:
|
|
2403
|
+
default:
|
|
2404
|
+
return nbNO;
|
|
2405
|
+
}
|
|
2406
|
+
};
|
|
2285
2407
|
const DatePicker = React.forwardRef((props, ref) => {
|
|
2286
2408
|
const {
|
|
2287
2409
|
className,
|
|
2288
|
-
dateButtonAriaLabel,
|
|
2410
|
+
dateButtonAriaLabel: dateButtonAriaLabel2,
|
|
2289
2411
|
dateFormat = "dd.MM.yyyy",
|
|
2290
2412
|
dateValue,
|
|
2291
2413
|
defaultMonth,
|
|
@@ -2308,6 +2430,7 @@ const DatePicker = React.forwardRef((props, ref) => {
|
|
|
2308
2430
|
onChange,
|
|
2309
2431
|
onDatePopupClosed,
|
|
2310
2432
|
testId,
|
|
2433
|
+
resources,
|
|
2311
2434
|
autoComplete = "off",
|
|
2312
2435
|
variant = PopOverVariant.positionautomatic,
|
|
2313
2436
|
zIndex = ZIndex.PopOver,
|
|
@@ -2318,6 +2441,22 @@ const DatePicker = React.forwardRef((props, ref) => {
|
|
|
2318
2441
|
const [month, setMonth2] = useState(defaultMonth);
|
|
2319
2442
|
const [datePickerOpen, setDatePickerOpen] = useState(false);
|
|
2320
2443
|
const [returnInputFocus, setReturnInputFocus] = useState(false);
|
|
2444
|
+
const { language } = useLanguage(LanguageLocales$1.NORWEGIAN);
|
|
2445
|
+
const defaultResources = getResources(language);
|
|
2446
|
+
const mergedResources = {
|
|
2447
|
+
...defaultResources,
|
|
2448
|
+
...resources,
|
|
2449
|
+
dateButtonAriaLabel: dateButtonAriaLabel2 || (resources == null ? void 0 : resources.dateButtonAriaLabel) || defaultResources.dateButtonAriaLabel
|
|
2450
|
+
};
|
|
2451
|
+
const popupAriaLabels = {
|
|
2452
|
+
dayButtonBase: (ariaLabels == null ? void 0 : ariaLabels.dayButtonBase) || mergedResources.dayButtonBase,
|
|
2453
|
+
dayButtonToday: (ariaLabels == null ? void 0 : ariaLabels.dayButtonToday) || mergedResources.dayButtonToday,
|
|
2454
|
+
dayButtonSelected: (ariaLabels == null ? void 0 : ariaLabels.dayButtonSelected) || mergedResources.dayButtonSelected,
|
|
2455
|
+
nextMonth: (ariaLabels == null ? void 0 : ariaLabels.nextMonth) || mergedResources.nextMonth,
|
|
2456
|
+
previousMonth: (ariaLabels == null ? void 0 : ariaLabels.previousMonth) || mergedResources.previousMonth,
|
|
2457
|
+
monthDropdown: (ariaLabels == null ? void 0 : ariaLabels.monthDropdown) || mergedResources.monthDropdown,
|
|
2458
|
+
yearDropdown: (ariaLabels == null ? void 0 : ariaLabels.yearDropdown) || mergedResources.yearDropdown
|
|
2459
|
+
};
|
|
2321
2460
|
const weekendMatcher = {
|
|
2322
2461
|
dayOfWeek: [0, 6]
|
|
2323
2462
|
};
|
|
@@ -2493,7 +2632,7 @@ const DatePicker = React.forwardRef((props, ref) => {
|
|
|
2493
2632
|
Button$1,
|
|
2494
2633
|
{
|
|
2495
2634
|
disabled,
|
|
2496
|
-
ariaLabel:
|
|
2635
|
+
ariaLabel: dateButtonAriaLabel2 ?? "Velg dato",
|
|
2497
2636
|
onClick: handleButtonClick,
|
|
2498
2637
|
tabIndex: datePickerOpen ? -1 : 0,
|
|
2499
2638
|
variant: "borderless",
|
|
@@ -2522,7 +2661,7 @@ const DatePicker = React.forwardRef((props, ref) => {
|
|
|
2522
2661
|
onMonthChange: setMonth2,
|
|
2523
2662
|
variant,
|
|
2524
2663
|
zIndex,
|
|
2525
|
-
ariaLabels
|
|
2664
|
+
ariaLabels: popupAriaLabels
|
|
2526
2665
|
}
|
|
2527
2666
|
)
|
|
2528
2667
|
] });
|