@navikt/ds-react 5.5.0 → 5.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/_docs.json +507 -106
- package/cjs/accordion/Accordion.js +1 -0
- package/cjs/accordion/AccordionContext.js +1 -1
- package/cjs/accordion/AccordionHeader.js +2 -2
- package/cjs/accordion/AccordionItem.js +6 -2
- package/cjs/date/datepicker/DatePicker.js +30 -34
- package/cjs/date/datepicker/DatePickerStandalone.js +23 -26
- package/cjs/date/datepicker/parts/Caption.js +28 -0
- package/cjs/date/datepicker/{DayButton.js → parts/DayButton.js} +1 -2
- package/cjs/date/datepicker/{caption → parts}/DropdownCaption.js +13 -7
- package/cjs/date/datepicker/parts/HeadRow.js +36 -0
- package/cjs/date/datepicker/parts/Row.js +23 -0
- package/cjs/date/datepicker/{TableHead.js → parts/TableHead.js} +4 -3
- package/cjs/date/datepicker/parts/WeekNumber.js +35 -0
- package/cjs/date/datepicker/parts/WeekRow.js +34 -0
- package/cjs/date/hooks/useDatepicker.js +2 -2
- package/cjs/date/hooks/useMonthPicker.js +2 -2
- package/cjs/date/hooks/useRangeDatepicker.js +3 -3
- package/cjs/date/monthpicker/MonthSelector.js +1 -1
- package/cjs/date/utils/get-month-weeks.js +46 -0
- package/cjs/date/utils/labels.js +40 -1
- package/cjs/dropdown/Toggle.js +2 -2
- package/cjs/dropdown/index.js +0 -15
- package/cjs/form/Select.js +1 -1
- package/cjs/form/checkbox/useCheckbox.js +3 -4
- package/cjs/form/combobox/Combobox.js +1 -1
- package/cjs/form/combobox/Input/Input.js +1 -1
- package/cjs/form/search/Search.js +3 -1
- package/cjs/index.js +1 -0
- package/cjs/layout/bleed/Bleed.js +69 -0
- package/cjs/layout/bleed/index.js +5 -0
- package/cjs/layout/bleed/package.json +6 -0
- package/cjs/layout/box/Box.js +1 -1
- package/cjs/layout/responsive/Responsive.js +8 -6
- package/cjs/layout/sidemal-test/AvatarPanel.js +18 -0
- package/cjs/layout/sidemal-test/Content.js +66 -0
- package/cjs/layout/sidemal-test/Filter.js +48 -0
- package/cjs/layout/sidemal-test/Header.js +48 -0
- package/cjs/layout/sidemal-test/Intro.js +36 -0
- package/cjs/layout/sidemal-test/Sidebar.js +49 -0
- package/cjs/layout/sidemal-test/content-box/ContentBox.js +65 -0
- package/cjs/layout/sidemal-test/content-box/index.js +8 -0
- package/cjs/layout/sidemal-test/content-box/package.json +6 -0
- package/cjs/layout/stack/Stack.js +2 -2
- package/cjs/layout/stack/index.js +3 -1
- package/cjs/layout/utilities/css.js +37 -14
- package/cjs/loader/Loader.js +2 -2
- package/cjs/modal/dialog-polyfill.js +2 -0
- package/cjs/popover/Popover.js +3 -2
- package/cjs/tabs/TabList.js +6 -7
- package/cjs/timeline/Pin.js +20 -20
- package/cjs/timeline/Timeline.js +4 -4
- package/cjs/timeline/period/ClickablePeriod.js +19 -19
- package/cjs/timeline/period/index.js +1 -1
- package/cjs/timeline/utils/timeline.js +3 -3
- package/cjs/toggle-group/ToggleGroup.js +1 -1
- package/cjs/tooltip/Tooltip.js +1 -1
- package/cjs/typography/Heading.js +1 -1
- package/cjs/util/RandomIcon.js +1 -0
- package/cjs/util/Slot.js +88 -0
- package/cjs/util/useId.js +2 -4
- package/esm/accordion/Accordion.js +1 -0
- package/esm/accordion/Accordion.js.map +1 -1
- package/esm/accordion/AccordionContext.d.ts +1 -0
- package/esm/accordion/AccordionContext.js +1 -1
- package/esm/accordion/AccordionContext.js.map +1 -1
- package/esm/accordion/AccordionHeader.js +2 -2
- package/esm/accordion/AccordionHeader.js.map +1 -1
- package/esm/accordion/AccordionItem.js +6 -2
- package/esm/accordion/AccordionItem.js.map +1 -1
- package/esm/date/datepicker/DatePicker.d.ts +14 -5
- package/esm/date/datepicker/DatePicker.js +29 -33
- package/esm/date/datepicker/DatePicker.js.map +1 -1
- package/esm/date/datepicker/DatePickerStandalone.d.ts +3 -2
- package/esm/date/datepicker/DatePickerStandalone.js +22 -25
- package/esm/date/datepicker/DatePickerStandalone.js.map +1 -1
- package/esm/date/datepicker/{caption → parts}/Caption.d.ts +3 -0
- package/esm/date/datepicker/parts/Caption.js +22 -0
- package/esm/date/datepicker/parts/Caption.js.map +1 -0
- package/esm/date/datepicker/parts/DayButton.d.ts +4 -0
- package/esm/date/datepicker/{DayButton.js → parts/DayButton.js} +2 -1
- package/esm/date/datepicker/parts/DayButton.js.map +1 -0
- package/esm/date/datepicker/{caption → parts}/DropdownCaption.d.ts +3 -0
- package/esm/date/datepicker/parts/DropdownCaption.js +44 -0
- package/esm/date/datepicker/parts/DropdownCaption.js.map +1 -0
- package/esm/date/datepicker/parts/HeadRow.d.ts +11 -0
- package/esm/date/datepicker/parts/HeadRow.js +29 -0
- package/esm/date/datepicker/parts/HeadRow.js.map +1 -0
- package/esm/date/datepicker/parts/Row.d.ts +17 -0
- package/esm/date/datepicker/parts/Row.js +19 -0
- package/esm/date/datepicker/parts/Row.js.map +1 -0
- package/esm/date/datepicker/parts/TableHead.d.ts +6 -0
- package/esm/date/datepicker/{TableHead.js → parts/TableHead.js} +5 -2
- package/esm/date/datepicker/parts/TableHead.js.map +1 -0
- package/esm/date/datepicker/parts/WeekNumber.d.ts +13 -0
- package/esm/date/datepicker/parts/WeekNumber.js +31 -0
- package/esm/date/datepicker/parts/WeekNumber.js.map +1 -0
- package/esm/date/datepicker/parts/WeekRow.d.ts +5 -0
- package/esm/date/datepicker/parts/WeekRow.js +30 -0
- package/esm/date/datepicker/parts/WeekRow.js.map +1 -0
- package/esm/date/hooks/useDatepicker.js +2 -2
- package/esm/date/hooks/useDatepicker.js.map +1 -1
- package/esm/date/hooks/useMonthPicker.js +2 -2
- package/esm/date/hooks/useMonthPicker.js.map +1 -1
- package/esm/date/hooks/useRangeDatepicker.js +3 -3
- package/esm/date/hooks/useRangeDatepicker.js.map +1 -1
- package/esm/date/monthpicker/MonthButton.d.ts +2 -2
- package/esm/date/monthpicker/MonthPicker.d.ts +1 -1
- package/esm/date/monthpicker/MonthSelector.js +1 -1
- package/esm/date/monthpicker/MonthSelector.js.map +1 -1
- package/esm/date/utils/get-month-weeks.d.ts +16 -0
- package/esm/date/utils/get-month-weeks.js +42 -0
- package/esm/date/utils/get-month-weeks.js.map +1 -0
- package/esm/date/utils/labels.d.ts +9 -0
- package/esm/date/utils/labels.js +36 -0
- package/esm/date/utils/labels.js.map +1 -1
- package/esm/date/utils/navigation.d.ts +1 -1
- package/esm/date/utils/navigation.js.map +1 -1
- package/esm/dropdown/Toggle.js +1 -1
- package/esm/dropdown/Toggle.js.map +1 -1
- package/esm/dropdown/index.d.ts +1 -2
- package/esm/dropdown/index.js +0 -1
- package/esm/dropdown/index.js.map +1 -1
- package/esm/form/Select.js +1 -1
- package/esm/form/Select.js.map +1 -1
- package/esm/form/checkbox/useCheckbox.d.ts +1 -1
- package/esm/form/checkbox/useCheckbox.js +3 -4
- package/esm/form/checkbox/useCheckbox.js.map +1 -1
- package/esm/form/combobox/Combobox.d.ts +1 -1
- package/esm/form/combobox/Combobox.js +1 -1
- package/esm/form/combobox/Combobox.js.map +1 -1
- package/esm/form/combobox/Input/Input.d.ts +0 -2
- package/esm/form/combobox/Input/Input.js +1 -1
- package/esm/form/combobox/Input/Input.js.map +1 -1
- package/esm/form/search/Search.js +3 -1
- package/esm/form/search/Search.js.map +1 -1
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/layout/bleed/Bleed.d.ts +47 -0
- package/esm/layout/bleed/Bleed.js +41 -0
- package/esm/layout/bleed/Bleed.js.map +1 -0
- package/esm/layout/bleed/index.d.ts +1 -0
- package/esm/layout/bleed/index.js +2 -0
- package/esm/layout/bleed/index.js.map +1 -0
- package/esm/layout/box/Box.d.ts +1 -2
- package/esm/layout/box/Box.js +1 -1
- package/esm/layout/box/Box.js.map +1 -1
- package/esm/layout/responsive/Responsive.d.ts +8 -4
- package/esm/layout/responsive/Responsive.js +8 -6
- package/esm/layout/responsive/Responsive.js.map +1 -1
- package/esm/layout/sidemal-test/AvatarPanel.d.ts +4 -0
- package/esm/layout/sidemal-test/AvatarPanel.js +12 -0
- package/esm/layout/sidemal-test/AvatarPanel.js.map +1 -0
- package/esm/layout/sidemal-test/Content.d.ts +2 -0
- package/esm/layout/sidemal-test/Content.js +60 -0
- package/esm/layout/sidemal-test/Content.js.map +1 -0
- package/esm/layout/sidemal-test/Filter.d.ts +2 -0
- package/esm/layout/sidemal-test/Filter.js +22 -0
- package/esm/layout/sidemal-test/Filter.js.map +1 -0
- package/esm/layout/sidemal-test/Header.d.ts +2 -0
- package/esm/layout/sidemal-test/Header.js +42 -0
- package/esm/layout/sidemal-test/Header.js.map +1 -0
- package/esm/layout/sidemal-test/Intro.d.ts +2 -0
- package/esm/layout/sidemal-test/Intro.js +30 -0
- package/esm/layout/sidemal-test/Intro.js.map +1 -0
- package/esm/layout/sidemal-test/Sidebar.d.ts +4 -0
- package/esm/layout/sidemal-test/Sidebar.js +41 -0
- package/esm/layout/sidemal-test/Sidebar.js.map +1 -0
- package/esm/layout/sidemal-test/content-box/ContentBox.d.ts +8 -0
- package/esm/layout/sidemal-test/content-box/ContentBox.js +37 -0
- package/esm/layout/sidemal-test/content-box/ContentBox.js.map +1 -0
- package/esm/layout/sidemal-test/content-box/index.d.ts +1 -0
- package/esm/layout/sidemal-test/content-box/index.js +2 -0
- package/esm/layout/sidemal-test/content-box/index.js.map +1 -0
- package/esm/layout/stack/Stack.d.ts +7 -3
- package/esm/layout/stack/Stack.js +3 -3
- package/esm/layout/stack/Stack.js.map +1 -1
- package/esm/layout/stack/index.d.ts +1 -0
- package/esm/layout/stack/index.js +1 -0
- package/esm/layout/stack/index.js.map +1 -1
- package/esm/layout/utilities/css.d.ts +1 -1
- package/esm/layout/utilities/css.js +37 -14
- package/esm/layout/utilities/css.js.map +1 -1
- package/esm/loader/Loader.js +3 -3
- package/esm/loader/Loader.js.map +1 -1
- package/esm/modal/dialog-polyfill.js +2 -0
- package/esm/modal/dialog-polyfill.js.map +1 -1
- package/esm/popover/Popover.js +3 -2
- package/esm/popover/Popover.js.map +1 -1
- package/esm/tabs/TabList.js +6 -7
- package/esm/tabs/TabList.js.map +1 -1
- package/esm/timeline/Pin.js +21 -21
- package/esm/timeline/Pin.js.map +1 -1
- package/esm/timeline/Timeline.js +4 -4
- package/esm/timeline/Timeline.js.map +1 -1
- package/esm/timeline/TimelineRow.js.map +1 -1
- package/esm/timeline/hooks/usePeriodContext.d.ts +1 -1
- package/esm/timeline/period/ClickablePeriod.js +20 -20
- package/esm/timeline/period/ClickablePeriod.js.map +1 -1
- package/esm/timeline/period/index.d.ts +2 -2
- package/esm/timeline/period/index.js +1 -1
- package/esm/timeline/period/index.js.map +1 -1
- package/esm/timeline/utils/timeline.js +3 -3
- package/esm/timeline/utils/timeline.js.map +1 -1
- package/esm/toggle-group/ToggleGroup.js +1 -1
- package/esm/toggle-group/ToggleGroup.js.map +1 -1
- package/esm/tooltip/Tooltip.js +1 -1
- package/esm/tooltip/Tooltip.js.map +1 -1
- package/esm/typography/Heading.js +1 -1
- package/esm/typography/Heading.js.map +1 -1
- package/esm/util/RandomIcon.js +1 -0
- package/esm/util/RandomIcon.js.map +1 -1
- package/esm/util/Slot.d.ts +6 -0
- package/esm/util/Slot.js +60 -0
- package/esm/util/Slot.js.map +1 -0
- package/esm/util/mergeRefs.d.ts +1 -1
- package/esm/util/useId.js +2 -4
- package/esm/util/useId.js.map +1 -1
- package/package.json +4 -4
- package/src/accordion/Accordion.tsx +1 -0
- package/src/accordion/AccordionContext.tsx +2 -1
- package/src/accordion/AccordionHeader.tsx +2 -2
- package/src/accordion/AccordionItem.tsx +7 -5
- package/src/accordion/accordion.stories.tsx +21 -34
- package/src/alert/alert.stories.tsx +2 -2
- package/src/chips/chips.stories.tsx +29 -32
- package/src/date/datepicker/DatePicker.tsx +63 -58
- package/src/date/datepicker/DatePickerStandalone.tsx +36 -39
- package/src/date/datepicker/datepicker.stories.tsx +67 -2
- package/src/date/datepicker/datepicker.test.tsx +5 -4
- package/src/date/datepicker/{caption → parts}/Caption.tsx +19 -17
- package/src/date/datepicker/{DayButton.tsx → parts/DayButton.tsx} +3 -1
- package/src/date/datepicker/parts/DropdownCaption.tsx +113 -0
- package/src/date/datepicker/parts/HeadRow.tsx +56 -0
- package/src/date/datepicker/parts/Row.tsx +47 -0
- package/src/date/datepicker/{TableHead.tsx → parts/TableHead.tsx} +6 -2
- package/src/date/datepicker/parts/WeekNumber.tsx +79 -0
- package/src/date/datepicker/parts/WeekRow.tsx +60 -0
- package/src/date/hooks/useDatepicker.tsx +2 -2
- package/src/date/hooks/useMonthPicker.tsx +2 -2
- package/src/date/hooks/useRangeDatepicker.test.tsx +11 -11
- package/src/date/hooks/useRangeDatepicker.tsx +3 -3
- package/src/date/monthpicker/MonthButton.tsx +2 -2
- package/src/date/monthpicker/MonthPicker.tsx +1 -1
- package/src/date/monthpicker/MonthSelector.tsx +3 -3
- package/src/date/monthpicker/monthpicker.stories.tsx +1 -1
- package/src/date/utils/__tests__/get-initial-year.test.ts +0 -12
- package/src/date/utils/__tests__/get-month-weeks.test.ts +113 -0
- package/src/date/utils/__tests__/is-match.test.ts +3 -3
- package/src/date/utils/__tests__/parse-dates.test.ts +4 -2
- package/src/date/utils/get-month-weeks.ts +93 -0
- package/src/date/utils/labels.ts +51 -0
- package/src/date/utils/navigation.ts +3 -3
- package/src/dropdown/Toggle.tsx +1 -1
- package/src/dropdown/dropdown.stories.tsx +25 -28
- package/src/dropdown/index.ts +1 -2
- package/src/expansion-card/expansion-card.stories.tsx +143 -161
- package/src/form/ConfirmationPanel.test.tsx +5 -5
- package/src/form/Select.tsx +1 -1
- package/src/form/checkbox/Checkbox.test.tsx +14 -26
- package/src/form/checkbox/checkbox.stories.tsx +66 -71
- package/src/form/checkbox/useCheckbox.ts +3 -4
- package/src/form/combobox/Combobox.tsx +2 -3
- package/src/form/combobox/Input/Input.tsx +1 -3
- package/src/form/combobox/combobox.stories.tsx +20 -23
- package/src/form/combobox/combobox.test.tsx +22 -20
- package/src/form/radio/radio.stories.tsx +39 -44
- package/src/form/search/Search.tsx +1 -0
- package/src/form/search/search.stories.tsx +22 -26
- package/src/form/stories/fieldset.stories.tsx +1 -1
- package/src/index.ts +1 -0
- package/src/layout/bleed/Bleed.stories.tsx +381 -0
- package/src/layout/bleed/Bleed.tsx +130 -0
- package/src/layout/bleed/index.ts +1 -0
- package/src/layout/box/Box.stories.tsx +251 -256
- package/src/layout/box/Box.tsx +2 -1
- package/src/layout/responsive/Responsive.tsx +21 -6
- package/src/layout/responsive/hide.stories.tsx +35 -0
- package/src/layout/responsive/show.stories.tsx +35 -0
- package/src/layout/sidemal-test/AvatarPanel.tsx +27 -0
- package/src/layout/sidemal-test/Content.tsx +129 -0
- package/src/layout/sidemal-test/Filter.tsx +46 -0
- package/src/layout/sidemal-test/Header.tsx +96 -0
- package/src/layout/sidemal-test/Intro.tsx +91 -0
- package/src/layout/sidemal-test/Sidebar.tsx +77 -0
- package/src/layout/sidemal-test/content-box/ContentBox.tsx +46 -0
- package/src/layout/sidemal-test/content-box/index.ts +1 -0
- package/src/layout/sidemal-test/navno-sidemal.stories.mdx +29 -0
- package/src/layout/sidemal-test/navno-sidemal.stories.tsx +65 -0
- package/src/layout/sidemal-test/styling.css +43 -0
- package/src/layout/stack/Stack.tsx +14 -8
- package/src/layout/stack/index.ts +1 -0
- package/src/layout/stack/stack.stories.tsx +23 -1
- package/src/layout/utilities/css.ts +59 -20
- package/src/loader/Loader.tsx +2 -3
- package/src/modal/dialog-polyfill.ts +2 -0
- package/src/pagination/pagination.stories.tsx +35 -42
- package/src/popover/Popover.test.tsx +21 -35
- package/src/popover/Popover.tsx +2 -2
- package/src/popover/popover.stories.tsx +25 -41
- package/src/react-css.d.ts +0 -1
- package/src/read-more/readmore.stories.tsx +35 -36
- package/src/stepper/stepper.stories.tsx +45 -52
- package/src/table/stories/table-expandable.stories.tsx +59 -63
- package/src/tabs/TabList.tsx +4 -6
- package/src/tabs/Tabs.stories.tsx +3 -3
- package/src/tag/tag.stories.tsx +4 -4
- package/src/timeline/Pin.tsx +44 -39
- package/src/timeline/Timeline.tsx +6 -6
- package/src/timeline/TimelineRow.tsx +1 -0
- package/src/timeline/hooks/usePeriodContext.tsx +1 -1
- package/src/timeline/period/ClickablePeriod.tsx +42 -38
- package/src/timeline/period/index.tsx +5 -4
- package/src/timeline/timeline.stories.tsx +11 -10
- package/src/timeline/utils/timeline.ts +3 -3
- package/src/toggle-group/ToggleGroup.stories.tsx +25 -29
- package/src/toggle-group/ToggleGroup.tsx +0 -1
- package/src/tooltip/Tooltip.test.tsx +40 -54
- package/src/tooltip/Tooltip.tsx +1 -1
- package/src/typography/Heading.tsx +1 -1
- package/src/util/RandomIcon.tsx +1 -0
- package/src/util/Slot.tsx +69 -0
- package/src/util/__tests__/Slot.test.tsx +98 -0
- package/src/util/mergeRefs.tsx +1 -1
- package/src/util/useId.ts +1 -3
- package/cjs/date/datepicker/caption/Caption.js +0 -23
- package/cjs/date/datepicker/caption/index.js +0 -10
- package/cjs/date/datepicker/caption/package.json +0 -6
- package/esm/date/datepicker/DayButton.d.ts +0 -3
- package/esm/date/datepicker/DayButton.js.map +0 -1
- package/esm/date/datepicker/TableHead.d.ts +0 -3
- package/esm/date/datepicker/TableHead.js.map +0 -1
- package/esm/date/datepicker/caption/Caption.js +0 -17
- package/esm/date/datepicker/caption/Caption.js.map +0 -1
- package/esm/date/datepicker/caption/DropdownCaption.js +0 -38
- package/esm/date/datepicker/caption/DropdownCaption.js.map +0 -1
- package/esm/date/datepicker/caption/index.d.ts +0 -2
- package/esm/date/datepicker/caption/index.js +0 -3
- package/esm/date/datepicker/caption/index.js.map +0 -1
- package/src/date/datepicker/caption/DropdownCaption.tsx +0 -108
- package/src/date/datepicker/caption/index.ts +0 -2
|
@@ -2,7 +2,7 @@ import format from "date-fns/format";
|
|
|
2
2
|
import React, { useRef } from "react";
|
|
3
3
|
import { Button, DayProps, useDayPicker, useDayRender } from "react-day-picker";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const DayButton = (props: DayProps) => {
|
|
6
6
|
const buttonRef = useRef<HTMLButtonElement>(null);
|
|
7
7
|
const dayRender = useDayRender(props.date, props.displayMonth, buttonRef);
|
|
8
8
|
const { locale } = useDayPicker();
|
|
@@ -25,3 +25,5 @@ export const DayButton = (props: DayProps) => {
|
|
|
25
25
|
/>
|
|
26
26
|
);
|
|
27
27
|
};
|
|
28
|
+
|
|
29
|
+
export default DayButton;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { ArrowLeftIcon, ArrowRightIcon } from "@navikt/aksel-icons";
|
|
2
|
+
import setMonth from "date-fns/setMonth";
|
|
3
|
+
import setYear from "date-fns/setYear";
|
|
4
|
+
import startOfMonth from "date-fns/startOfMonth";
|
|
5
|
+
import React from "react";
|
|
6
|
+
import { CaptionProps, useDayPicker, useNavigation } from "react-day-picker";
|
|
7
|
+
import { Button, Select } from "../../..";
|
|
8
|
+
import { getMonths, getYears } from "../../utils/get-dates";
|
|
9
|
+
import { labelMonthDropdown, labelYearDropdown } from "../../utils/labels";
|
|
10
|
+
import { max, min } from "date-fns";
|
|
11
|
+
import WeekRow from "./WeekRow";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* https://github.com/gpbl/react-day-picker/tree/main/src/components/CaptionDropdowns
|
|
15
|
+
*/
|
|
16
|
+
export const DropdownCaption = ({ displayMonth, id }: CaptionProps) => {
|
|
17
|
+
const { goToMonth, nextMonth, previousMonth } = useNavigation();
|
|
18
|
+
const {
|
|
19
|
+
fromDate,
|
|
20
|
+
toDate,
|
|
21
|
+
formatters: { formatYearCaption, formatMonthCaption, formatCaption },
|
|
22
|
+
labels: { labelPrevious, labelNext },
|
|
23
|
+
locale,
|
|
24
|
+
} = useDayPicker();
|
|
25
|
+
|
|
26
|
+
if (!fromDate || !toDate) {
|
|
27
|
+
console.warn("Using dropdownCaption required fromDate and toDate");
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const handleYearChange: React.ChangeEventHandler<HTMLSelectElement> = (e) => {
|
|
32
|
+
const newMonth = setYear(
|
|
33
|
+
startOfMonth(displayMonth),
|
|
34
|
+
Number(e.target.value)
|
|
35
|
+
);
|
|
36
|
+
goToMonth(startOfMonth(min([max([newMonth, fromDate]), toDate])));
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const handleMonthChange: React.ChangeEventHandler<HTMLSelectElement> = (e) =>
|
|
40
|
+
goToMonth(setMonth(startOfMonth(displayMonth), Number(e.target.value)));
|
|
41
|
+
|
|
42
|
+
const years = getYears(fromDate, toDate, displayMonth.getFullYear());
|
|
43
|
+
const months = getMonths(fromDate, toDate, displayMonth);
|
|
44
|
+
|
|
45
|
+
const previousLabel = labelPrevious(previousMonth, { locale });
|
|
46
|
+
const nextLabel = labelNext(nextMonth, { locale });
|
|
47
|
+
const yearDropdownLabel = labelYearDropdown(locale);
|
|
48
|
+
const MonthDropdownLabel = labelMonthDropdown(locale);
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<>
|
|
52
|
+
<div className="navds-date__caption">
|
|
53
|
+
<span
|
|
54
|
+
aria-live="polite"
|
|
55
|
+
aria-atomic="true"
|
|
56
|
+
id={id}
|
|
57
|
+
className="navds-sr-only"
|
|
58
|
+
>
|
|
59
|
+
{formatCaption(displayMonth, { locale })}
|
|
60
|
+
</span>
|
|
61
|
+
<Button
|
|
62
|
+
variant="tertiary"
|
|
63
|
+
disabled={!previousMonth}
|
|
64
|
+
onClick={() => previousMonth && goToMonth(previousMonth)}
|
|
65
|
+
icon={<ArrowLeftIcon title={previousLabel} />}
|
|
66
|
+
className="navds-date__caption-button"
|
|
67
|
+
type="button"
|
|
68
|
+
/>
|
|
69
|
+
|
|
70
|
+
<div className="navds-date__caption">
|
|
71
|
+
<Select
|
|
72
|
+
label={MonthDropdownLabel}
|
|
73
|
+
hideLabel
|
|
74
|
+
className="navds-date__caption__month"
|
|
75
|
+
value={displayMonth.getMonth()}
|
|
76
|
+
onChange={handleMonthChange}
|
|
77
|
+
>
|
|
78
|
+
{months.map((m) => (
|
|
79
|
+
<option key={m.getMonth()} value={m.getMonth()}>
|
|
80
|
+
{formatMonthCaption(m, { locale })}
|
|
81
|
+
</option>
|
|
82
|
+
))}
|
|
83
|
+
</Select>
|
|
84
|
+
<Select
|
|
85
|
+
label={yearDropdownLabel}
|
|
86
|
+
hideLabel
|
|
87
|
+
value={displayMonth.getFullYear()}
|
|
88
|
+
onChange={handleYearChange}
|
|
89
|
+
className="navds-date__caption__year"
|
|
90
|
+
>
|
|
91
|
+
{years.map((year) => (
|
|
92
|
+
<option key={year.getFullYear()} value={year.getFullYear()}>
|
|
93
|
+
{formatYearCaption(year, { locale })}
|
|
94
|
+
</option>
|
|
95
|
+
))}
|
|
96
|
+
</Select>
|
|
97
|
+
</div>
|
|
98
|
+
|
|
99
|
+
<Button
|
|
100
|
+
icon={<ArrowRightIcon title={nextLabel} />}
|
|
101
|
+
onClick={() => nextMonth && goToMonth(nextMonth)}
|
|
102
|
+
disabled={!nextMonth}
|
|
103
|
+
variant="tertiary"
|
|
104
|
+
className="navds-date__caption-button"
|
|
105
|
+
type="button"
|
|
106
|
+
/>
|
|
107
|
+
</div>
|
|
108
|
+
<WeekRow displayMonth={displayMonth} />
|
|
109
|
+
</>
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export default DropdownCaption;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { addDays, Locale, startOfWeek } from "date-fns";
|
|
3
|
+
import { useDayPicker } from "react-day-picker";
|
|
4
|
+
import { Hide } from "../../../layout/responsive";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* https://github.com/gpbl/react-day-picker/tree/main/src/components/HeadRow
|
|
8
|
+
*/
|
|
9
|
+
export function HeadRow(): JSX.Element {
|
|
10
|
+
const {
|
|
11
|
+
classNames,
|
|
12
|
+
styles,
|
|
13
|
+
showWeekNumber,
|
|
14
|
+
locale,
|
|
15
|
+
formatters: { formatWeekdayName },
|
|
16
|
+
labels: { labelWeekday },
|
|
17
|
+
} = useDayPicker();
|
|
18
|
+
|
|
19
|
+
const weekdays = getWeekdays(locale);
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<tr style={styles.head_row} className={classNames.head_row}>
|
|
23
|
+
{showWeekNumber && (
|
|
24
|
+
<Hide below="sm" asChild>
|
|
25
|
+
<td style={styles.head_cell} className={classNames.head_cell}></td>
|
|
26
|
+
</Hide>
|
|
27
|
+
)}
|
|
28
|
+
{weekdays.map((weekday, i) => (
|
|
29
|
+
<th
|
|
30
|
+
key={i}
|
|
31
|
+
scope="col"
|
|
32
|
+
className={classNames.head_cell}
|
|
33
|
+
style={styles.head_cell}
|
|
34
|
+
aria-label={labelWeekday(weekday, { locale })}
|
|
35
|
+
>
|
|
36
|
+
{formatWeekdayName(weekday, { locale })}
|
|
37
|
+
</th>
|
|
38
|
+
))}
|
|
39
|
+
</tr>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Generate a series of 7 days, starting from the week, to use for formatting
|
|
45
|
+
* the weekday names (Monday, Tuesday, etc.).
|
|
46
|
+
*/
|
|
47
|
+
export function getWeekdays(locale?: Locale): Date[] {
|
|
48
|
+
const start = startOfWeek(new Date(), { locale, weekStartsOn: 1 });
|
|
49
|
+
|
|
50
|
+
const days: Date[] = [];
|
|
51
|
+
for (let i = 0; i < 7; i++) {
|
|
52
|
+
const day = addDays(start, i);
|
|
53
|
+
days.push(day);
|
|
54
|
+
}
|
|
55
|
+
return days;
|
|
56
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { getUnixTime } from "date-fns";
|
|
3
|
+
import { useDayPicker, Day } from "react-day-picker";
|
|
4
|
+
import WeekNumber from "./WeekNumber";
|
|
5
|
+
import { Hide } from "../../../layout/responsive";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The props for the {@link Row} component.
|
|
9
|
+
*/
|
|
10
|
+
export interface RowProps {
|
|
11
|
+
/** The month where the row is displayed. */
|
|
12
|
+
displayMonth: Date;
|
|
13
|
+
/** The number of the week to render. */
|
|
14
|
+
weekNumber: number;
|
|
15
|
+
/** The days contained in the week. */
|
|
16
|
+
dates: Date[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* https://github.com/gpbl/react-day-picker/tree/main/src/components/Row
|
|
21
|
+
*/
|
|
22
|
+
function Row(props: RowProps): JSX.Element {
|
|
23
|
+
const { styles, classNames, showWeekNumber } = useDayPicker();
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<tr className={classNames.row} style={styles.row}>
|
|
27
|
+
{showWeekNumber && (
|
|
28
|
+
<Hide below="sm" asChild>
|
|
29
|
+
<td className={classNames.cell} style={styles.cell}>
|
|
30
|
+
<WeekNumber number={props.weekNumber} dates={props.dates} />
|
|
31
|
+
</td>
|
|
32
|
+
</Hide>
|
|
33
|
+
)}
|
|
34
|
+
{props.dates.map((date) => (
|
|
35
|
+
<td
|
|
36
|
+
className={classNames.cell}
|
|
37
|
+
style={styles.cell}
|
|
38
|
+
key={getUnixTime(date)}
|
|
39
|
+
>
|
|
40
|
+
<Day displayMonth={props.displayMonth} date={date} />
|
|
41
|
+
</td>
|
|
42
|
+
))}
|
|
43
|
+
</tr>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default Row;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { HeadRow, useDayPicker } from "react-day-picker";
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* https://github.com/gpbl/react-day-picker/tree/main/src/components/Head
|
|
6
|
+
*/
|
|
7
|
+
function TableHead(): JSX.Element {
|
|
6
8
|
const { classNames, styles, components } = useDayPicker();
|
|
7
9
|
const HeadRowComponent = components?.HeadRow ?? HeadRow;
|
|
8
10
|
return (
|
|
@@ -11,3 +13,5 @@ export function TableHead(): JSX.Element {
|
|
|
11
13
|
</thead>
|
|
12
14
|
);
|
|
13
15
|
}
|
|
16
|
+
|
|
17
|
+
export default TableHead;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/* https://github.com/gpbl/react-day-picker/blob/7f78cd5/src/components/WeekNumber/WeekNumber.tsx#L21 */
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Button, useDayPicker } from "react-day-picker";
|
|
4
|
+
import { labelWeekNumber, labelWeekNumberButton } from "../../utils/labels";
|
|
5
|
+
|
|
6
|
+
export interface WeekNumberProps {
|
|
7
|
+
/** The number of the week. */
|
|
8
|
+
number: number;
|
|
9
|
+
/** The dates in the week. */
|
|
10
|
+
dates: Date[];
|
|
11
|
+
headerVersion?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* https://github.com/gpbl/react-day-picker/tree/main/src/components/WeekNumber
|
|
16
|
+
*/
|
|
17
|
+
function WeekNumber(props: WeekNumberProps): JSX.Element {
|
|
18
|
+
const { number: weekNumber, dates } = props;
|
|
19
|
+
const {
|
|
20
|
+
onWeekNumberClick,
|
|
21
|
+
styles,
|
|
22
|
+
classNames,
|
|
23
|
+
locale: { code },
|
|
24
|
+
} = useDayPicker();
|
|
25
|
+
|
|
26
|
+
const weekLabel = labelWeekNumber({
|
|
27
|
+
week: Number(weekNumber),
|
|
28
|
+
localeCode: code,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
if (!onWeekNumberClick) {
|
|
32
|
+
return (
|
|
33
|
+
<span
|
|
34
|
+
className={classNames.weeknumber}
|
|
35
|
+
style={styles.weeknumber}
|
|
36
|
+
aria-label={weekLabel}
|
|
37
|
+
>
|
|
38
|
+
{weekNumber}
|
|
39
|
+
</span>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const label = labelWeekNumberButton({
|
|
44
|
+
week: Number(weekNumber),
|
|
45
|
+
localeCode: code,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const handleClick: React.MouseEventHandler = function (e) {
|
|
49
|
+
onWeekNumberClick(weekNumber, dates, e);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
if (props?.headerVersion) {
|
|
53
|
+
return (
|
|
54
|
+
<Button
|
|
55
|
+
name="week-number"
|
|
56
|
+
aria-label={label}
|
|
57
|
+
className={classNames.weeknumber}
|
|
58
|
+
style={styles.weeknumber}
|
|
59
|
+
onClick={handleClick}
|
|
60
|
+
>
|
|
61
|
+
{weekNumber}
|
|
62
|
+
</Button>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<Button
|
|
68
|
+
name="week-number"
|
|
69
|
+
aria-label={label}
|
|
70
|
+
className={classNames.weeknumber}
|
|
71
|
+
style={styles.weeknumber}
|
|
72
|
+
onClick={handleClick}
|
|
73
|
+
>
|
|
74
|
+
{weekNumber}
|
|
75
|
+
</Button>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export default WeekNumber;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { useDayPicker } from "react-day-picker";
|
|
3
|
+
import { Show } from "../../../layout/responsive";
|
|
4
|
+
import { Detail } from "../../../typography";
|
|
5
|
+
import { getMonthWeeks } from "../../utils/get-month-weeks";
|
|
6
|
+
import { labelWeek } from "../../utils/labels";
|
|
7
|
+
import WeekNumber from "./WeekNumber";
|
|
8
|
+
import { useId } from "../../../util";
|
|
9
|
+
|
|
10
|
+
const WeekRow = ({ displayMonth }: { displayMonth: Date }) => {
|
|
11
|
+
const { locale, fixedWeeks, onWeekNumberClick } = useDayPicker();
|
|
12
|
+
|
|
13
|
+
const labelId = useId();
|
|
14
|
+
|
|
15
|
+
if (!onWeekNumberClick) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const weeks = getMonthWeeks(displayMonth, {
|
|
20
|
+
useFixedWeeks: Boolean(fixedWeeks),
|
|
21
|
+
locale,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Show below="sm" asChild>
|
|
26
|
+
<table className="rdp-table" role="grid">
|
|
27
|
+
<tbody className="rdp-tbody">
|
|
28
|
+
<tr className="rdp-row navds-date__week-row">
|
|
29
|
+
<Detail
|
|
30
|
+
as="th"
|
|
31
|
+
weight="semibold"
|
|
32
|
+
className="rdp-cell navds-date__week-cell"
|
|
33
|
+
>
|
|
34
|
+
<span className="navds-date__week-wrapper" id={labelId}>
|
|
35
|
+
{labelWeek(locale?.code)}
|
|
36
|
+
</span>
|
|
37
|
+
</Detail>
|
|
38
|
+
|
|
39
|
+
{weeks.map((week) => (
|
|
40
|
+
<td
|
|
41
|
+
key={week.weekNumber}
|
|
42
|
+
className="rdp-cell navds-date__week-cell"
|
|
43
|
+
>
|
|
44
|
+
<span className="navds-date__week-wrapper">
|
|
45
|
+
<WeekNumber
|
|
46
|
+
number={week.weekNumber}
|
|
47
|
+
dates={week.dates}
|
|
48
|
+
headerVersion
|
|
49
|
+
/>
|
|
50
|
+
</span>
|
|
51
|
+
</td>
|
|
52
|
+
))}
|
|
53
|
+
</tr>
|
|
54
|
+
</tbody>
|
|
55
|
+
</table>
|
|
56
|
+
</Show>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default WeekRow;
|
|
@@ -207,7 +207,7 @@ export const useDatepicker = (
|
|
|
207
207
|
return;
|
|
208
208
|
}
|
|
209
209
|
!open && openOnFocus && handleOpen(true);
|
|
210
|
-
|
|
210
|
+
const day = parseDate(
|
|
211
211
|
e.target.value,
|
|
212
212
|
today,
|
|
213
213
|
locale,
|
|
@@ -227,7 +227,7 @@ export const useDatepicker = (
|
|
|
227
227
|
};
|
|
228
228
|
|
|
229
229
|
const handleBlur: React.FocusEventHandler<HTMLInputElement> = (e) => {
|
|
230
|
-
|
|
230
|
+
const day = parseDate(
|
|
231
231
|
e.target.value,
|
|
232
232
|
today,
|
|
233
233
|
locale,
|
|
@@ -204,7 +204,7 @@ export const useMonthpicker = (
|
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
206
206
|
!open && openOnFocus && handleOpen(true);
|
|
207
|
-
|
|
207
|
+
const day = parseDate(
|
|
208
208
|
e.target.value,
|
|
209
209
|
today,
|
|
210
210
|
locale,
|
|
@@ -223,7 +223,7 @@ export const useMonthpicker = (
|
|
|
223
223
|
};
|
|
224
224
|
|
|
225
225
|
const handleBlur: React.FocusEventHandler<HTMLInputElement> = (e) => {
|
|
226
|
-
|
|
226
|
+
const day = parseDate(
|
|
227
227
|
e.target.value,
|
|
228
228
|
today,
|
|
229
229
|
locale,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* eslint-disable
|
|
2
|
-
import { act, render } from "@testing-library/react";
|
|
1
|
+
/* eslint-disable testing-library/no-unnecessary-act -- https://kentcdodds.com/blog/fix-the-not-wrapped-in-act-warning */
|
|
2
|
+
import { act, render, screen } from "@testing-library/react";
|
|
3
3
|
import userEvent from "@testing-library/user-event";
|
|
4
4
|
import React from "react";
|
|
5
5
|
import { DatePicker, useRangeDatepicker } from "..";
|
|
@@ -23,15 +23,15 @@ const RangeDemo = () => {
|
|
|
23
23
|
|
|
24
24
|
describe("Writing in input sets correct values", () => {
|
|
25
25
|
it("useRangeDatepicker same date", async () => {
|
|
26
|
-
|
|
26
|
+
render(<RangeDemo />);
|
|
27
27
|
|
|
28
|
-
const fraInput =
|
|
29
|
-
const tilInput =
|
|
28
|
+
const fraInput = screen.getByRole("textbox", { name: "Fra" });
|
|
29
|
+
const tilInput = screen.getByRole("textbox", { name: "Til" });
|
|
30
30
|
await act(async () => {
|
|
31
31
|
await userEvent.type(fraInput, "03.08.2022");
|
|
32
32
|
await userEvent.type(tilInput, "03.08.2022");
|
|
33
33
|
});
|
|
34
|
-
const res =
|
|
34
|
+
const res = screen.getByTitle("res");
|
|
35
35
|
expect(res.innerHTML).toEqual(
|
|
36
36
|
JSON.stringify({
|
|
37
37
|
from: "2022-08-03T00:00:00.000Z",
|
|
@@ -40,16 +40,16 @@ describe("Writing in input sets correct values", () => {
|
|
|
40
40
|
);
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
it("useRangeDatepicker before after to
|
|
44
|
-
|
|
43
|
+
it("useRangeDatepicker before after to", async () => {
|
|
44
|
+
render(<RangeDemo />);
|
|
45
45
|
|
|
46
|
-
const fraInput =
|
|
47
|
-
const tilInput =
|
|
46
|
+
const fraInput = screen.getByRole("textbox", { name: "Fra" });
|
|
47
|
+
const tilInput = screen.getByRole("textbox", { name: "Til" });
|
|
48
48
|
await act(async () => {
|
|
49
49
|
await userEvent.type(fraInput, "03.08.2022");
|
|
50
50
|
await userEvent.type(tilInput, "02.08.2022");
|
|
51
51
|
});
|
|
52
|
-
const res =
|
|
52
|
+
const res = screen.getByTitle("res");
|
|
53
53
|
expect(res.innerHTML).toEqual(
|
|
54
54
|
JSON.stringify({
|
|
55
55
|
from: "2022-08-03T00:00:00.000Z",
|
|
@@ -325,7 +325,7 @@ export const useRangeDatepicker = (
|
|
|
325
325
|
return;
|
|
326
326
|
}
|
|
327
327
|
!open && openOnFocus && setOpen(true);
|
|
328
|
-
|
|
328
|
+
const day = parseDate(
|
|
329
329
|
e.target.value,
|
|
330
330
|
today,
|
|
331
331
|
locale,
|
|
@@ -349,7 +349,7 @@ export const useRangeDatepicker = (
|
|
|
349
349
|
};
|
|
350
350
|
|
|
351
351
|
const handleBlur = (e, src: RangeT) => {
|
|
352
|
-
|
|
352
|
+
const day = parseDate(
|
|
353
353
|
e.target.value,
|
|
354
354
|
today,
|
|
355
355
|
locale,
|
|
@@ -379,7 +379,7 @@ export const useRangeDatepicker = (
|
|
|
379
379
|
if (range?.from && range?.to) {
|
|
380
380
|
setOpen(false);
|
|
381
381
|
}
|
|
382
|
-
|
|
382
|
+
const prevToRange =
|
|
383
383
|
!selectedRange?.from && selectedRange?.to ? selectedRange?.to : range?.to;
|
|
384
384
|
|
|
385
385
|
const resetTo = isBefore(prevToRange, range?.from);
|
|
@@ -13,9 +13,9 @@ interface MonthType {
|
|
|
13
13
|
month: Date;
|
|
14
14
|
months: Date[];
|
|
15
15
|
focus: Date | undefined;
|
|
16
|
-
setFocus:
|
|
16
|
+
setFocus: (date?: Date) => void;
|
|
17
17
|
tabRoot?: Date;
|
|
18
|
-
setTabRoot:
|
|
18
|
+
setTabRoot: (date?: Date) => void;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
const disableMonth = (month: Date, fromDate?: Date, toDate?: Date) => {
|
|
@@ -70,7 +70,7 @@ export interface MonthPickerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
70
70
|
/**
|
|
71
71
|
* Callback for user-controlled state
|
|
72
72
|
*/
|
|
73
|
-
onMonthSelect?:
|
|
73
|
+
onMonthSelect?: (month?: Date) => void;
|
|
74
74
|
/**
|
|
75
75
|
* Used to set visible year programmatically. Component controlled by default
|
|
76
76
|
*/
|
|
@@ -62,9 +62,9 @@ export const MonthSelector = () => {
|
|
|
62
62
|
return (
|
|
63
63
|
<BodyShort as="table" className="rdp-table">
|
|
64
64
|
<tbody className="rdp-tbody">
|
|
65
|
-
{tableMonths.map((
|
|
66
|
-
<tr className="rdp-row" key={
|
|
67
|
-
{
|
|
65
|
+
{tableMonths.map((months, i) => (
|
|
66
|
+
<tr className="rdp-row" key={i}>
|
|
67
|
+
{months.map((month: Date) => {
|
|
68
68
|
return (
|
|
69
69
|
<td key={month.toDateString()} className="rdp-cell">
|
|
70
70
|
<MonthButton
|
|
@@ -22,18 +22,6 @@ describe("Returns initial year for monthpicker", () => {
|
|
|
22
22
|
)
|
|
23
23
|
).toBeFalsy();
|
|
24
24
|
});
|
|
25
|
-
test("Default selected should not be valid (false)", () => {
|
|
26
|
-
expect(
|
|
27
|
-
isSameYear(
|
|
28
|
-
new Date("Oct 4 2021"),
|
|
29
|
-
getInitialYear({
|
|
30
|
-
defaultMonth: new Date("Aug 4 2020"),
|
|
31
|
-
/* toDate: new Date("Oct 4 2021"), */
|
|
32
|
-
/* fromDate: new Date("Oct 4 2021"), */
|
|
33
|
-
})
|
|
34
|
-
)
|
|
35
|
-
).toBeFalsy();
|
|
36
|
-
});
|
|
37
25
|
test("Default selected should be valid with fromDate", () => {
|
|
38
26
|
expect(
|
|
39
27
|
isSameYear(
|