@navikt/ds-react 5.12.5 → 5.13.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 +79 -3
- package/cjs/accordion/Accordion.js +2 -2
- package/cjs/accordion/AccordionHeader.js +1 -1
- package/cjs/accordion/AccordionItem.js +11 -14
- package/cjs/alert/Alert.js +2 -2
- package/cjs/chat/Bubble.js +1 -1
- package/cjs/chat/Chat.js +2 -2
- package/cjs/chips/Chips.js +1 -1
- package/cjs/chips/Removable.js +1 -1
- package/cjs/copybutton/CopyButton.js +2 -2
- package/cjs/date/datepicker/parts/Caption.js +2 -2
- package/cjs/date/datepicker/parts/DropdownCaption.js +1 -1
- package/cjs/date/datepicker/parts/HeadRow.js +1 -1
- package/cjs/date/datepicker/parts/Row.js +2 -2
- package/cjs/date/monthpicker/MonthCaption.js +1 -1
- package/cjs/date/parts/DateInput.js +1 -1
- package/cjs/date/utils/check-dates.js +1 -1
- package/cjs/date/utils/is-match.js +2 -2
- package/cjs/date/utils/parse-date.js +1 -1
- package/cjs/dropdown/Dropdown.js +10 -12
- package/cjs/dropdown/Menu/Divider.js +1 -1
- package/cjs/dropdown/Menu/GroupedList/GroupedHeading.js +1 -1
- package/cjs/expansion-card/ExpansionCardHeader.js +1 -1
- package/cjs/form/ReadOnlyIcon.js +1 -1
- package/cjs/form/Select.js +1 -1
- package/cjs/form/combobox/Combobox.js +6 -6
- package/cjs/form/combobox/ComboboxProvider.js +2 -2
- package/cjs/form/combobox/FilteredOptions/FilteredOptions.js +4 -4
- package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js +4 -4
- package/cjs/form/combobox/SelectedOptions/SelectedOptions.js +1 -1
- package/cjs/form/error-summary/ErrorSummary.js +2 -2
- package/cjs/form/error-summary/ErrorSummaryItem.js +1 -1
- package/cjs/form/search/Search.js +1 -1
- package/cjs/form/search/SearchButton.js +1 -1
- package/cjs/grid/Cell.js +1 -1
- package/cjs/grid/Grid.js +1 -1
- package/cjs/guide-panel/GuidePanel.js +1 -1
- package/cjs/internal-header/InternalHeaderButton.js +1 -1
- package/cjs/internal-header/InternalHeaderTitle.js +1 -1
- package/cjs/internal-header/InternalHeaderUser.js +1 -1
- package/cjs/internal-header/InternalHeaderUserButton.js +1 -1
- package/cjs/layout/bleed/Bleed.js +1 -1
- package/cjs/layout/content-container/ContentContainer.js +1 -1
- package/cjs/layout/grid/HGrid.js +1 -1
- package/cjs/layout/page/parts/PageBlock.js +1 -1
- package/cjs/layout/sidemal-test/AvatarPanel.js +1 -1
- package/cjs/layout/sidemal-test/Content.js +3 -3
- package/cjs/layout/sidemal-test/Filter.js +1 -1
- package/cjs/layout/sidemal-test/Intro.js +1 -1
- package/cjs/link-panel/LinkPanel.js +3 -3
- package/cjs/link-panel/LinkPanelDescription.js +1 -1
- package/cjs/link-panel/LinkPanelTitle.js +1 -1
- package/cjs/modal/ModalBody.js +1 -1
- package/cjs/modal/ModalFooter.js +1 -1
- package/cjs/modal/ModalHeader.js +1 -1
- package/cjs/pagination/PaginationItem.js +1 -1
- package/cjs/panel/Panel.js +1 -1
- package/cjs/popover/PopoverContent.js +1 -1
- package/cjs/read-more/ReadMore.js +12 -10
- package/cjs/skeleton/Skeleton.js +1 -1
- package/cjs/table/Body.js +1 -1
- package/cjs/table/ColumnHeader.js +1 -1
- package/cjs/table/DataCell.js +1 -1
- package/cjs/table/ExpandableRow.js +14 -13
- package/cjs/table/Header.js +1 -1
- package/cjs/table/Row.js +1 -1
- package/cjs/tabs/TabList.js +1 -1
- package/cjs/tabs/Tabs.js +1 -1
- package/cjs/tag/Tag.js +1 -1
- package/cjs/timeline/AxisLabels.js +1 -1
- package/cjs/timeline/TimelineRow.js +2 -2
- package/cjs/timeline/hooks/useTimelineRows.js +5 -3
- package/cjs/timeline/utils/timeline.js +1 -1
- package/cjs/timeline/zoom/ZoomButton.js +1 -1
- package/cjs/toggle-group/ToggleGroup.js +1 -1
- package/cjs/tooltip/Tooltip.js +12 -7
- package/cjs/typography/BodyLong.js +1 -1
- package/cjs/typography/ErrorMessage.js +1 -1
- package/cjs/typography/Ingress.js +1 -1
- package/cjs/util/RandomIcon.js +1 -1
- package/cjs/util/hooks/useCallbackRef.js +18 -0
- package/cjs/util/hooks/useControllableState.js +25 -0
- package/esm/accordion/Accordion.d.ts +1 -1
- package/esm/accordion/Accordion.js +2 -2
- package/esm/accordion/Accordion.js.map +1 -1
- package/esm/accordion/AccordionHeader.js +1 -1
- package/esm/accordion/AccordionHeader.js.map +1 -1
- package/esm/accordion/AccordionItem.d.ts +4 -0
- package/esm/accordion/AccordionItem.js +12 -15
- package/esm/accordion/AccordionItem.js.map +1 -1
- package/esm/alert/Alert.js +2 -2
- package/esm/alert/Alert.js.map +1 -1
- package/esm/chat/Bubble.js +1 -1
- package/esm/chat/Bubble.js.map +1 -1
- package/esm/chat/Chat.js +2 -2
- package/esm/chat/Chat.js.map +1 -1
- package/esm/chips/Chips.d.ts +2 -2
- package/esm/chips/Chips.js +1 -1
- package/esm/chips/Chips.js.map +1 -1
- package/esm/chips/Removable.js +1 -1
- package/esm/chips/Removable.js.map +1 -1
- package/esm/copybutton/CopyButton.js +2 -2
- package/esm/copybutton/CopyButton.js.map +1 -1
- package/esm/date/context/useSharedMonthContext.js.map +1 -1
- package/esm/date/datepicker/parts/Caption.js +2 -2
- package/esm/date/datepicker/parts/Caption.js.map +1 -1
- package/esm/date/datepicker/parts/DropdownCaption.js +1 -1
- package/esm/date/datepicker/parts/DropdownCaption.js.map +1 -1
- package/esm/date/datepicker/parts/HeadRow.js +1 -1
- package/esm/date/datepicker/parts/HeadRow.js.map +1 -1
- package/esm/date/datepicker/parts/Row.js +3 -3
- package/esm/date/datepicker/parts/Row.js.map +1 -1
- package/esm/date/monthpicker/MonthCaption.js +1 -1
- package/esm/date/monthpicker/MonthCaption.js.map +1 -1
- package/esm/date/parts/DateInput.js +1 -1
- package/esm/date/parts/DateInput.js.map +1 -1
- package/esm/date/utils/check-dates.js +1 -1
- package/esm/date/utils/check-dates.js.map +1 -1
- package/esm/date/utils/get-month-weeks.js.map +1 -1
- package/esm/date/utils/is-match.js +2 -2
- package/esm/date/utils/is-match.js.map +1 -1
- package/esm/date/utils/navigation.js.map +1 -1
- package/esm/date/utils/parse-date.js +1 -1
- package/esm/date/utils/parse-date.js.map +1 -1
- package/esm/dropdown/Dropdown.d.ts +4 -0
- package/esm/dropdown/Dropdown.js +10 -12
- package/esm/dropdown/Dropdown.js.map +1 -1
- package/esm/dropdown/Menu/Divider.js +1 -1
- package/esm/dropdown/Menu/Divider.js.map +1 -1
- package/esm/dropdown/Menu/GroupedList/GroupedHeading.js +1 -1
- package/esm/dropdown/Menu/GroupedList/GroupedHeading.js.map +1 -1
- package/esm/expansion-card/ExpansionCardHeader.js +1 -1
- package/esm/expansion-card/ExpansionCardHeader.js.map +1 -1
- package/esm/form/Fieldset/useFieldset.d.ts +1 -1
- package/esm/form/ReadOnlyIcon.js +1 -1
- package/esm/form/ReadOnlyIcon.js.map +1 -1
- package/esm/form/Select.js +1 -1
- package/esm/form/Select.js.map +1 -1
- package/esm/form/Switch.js.map +1 -1
- package/esm/form/TextField.js.map +1 -1
- package/esm/form/checkbox/useCheckbox.d.ts +1 -1
- package/esm/form/combobox/Combobox.d.ts +1 -1
- package/esm/form/combobox/Combobox.js +6 -6
- package/esm/form/combobox/Combobox.js.map +1 -1
- package/esm/form/combobox/ComboboxProvider.js +2 -2
- package/esm/form/combobox/ComboboxProvider.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/FilteredOptions.js +4 -4
- package/esm/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/filteredOptionsContext.d.ts +1 -1
- package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js +4 -4
- package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
- package/esm/form/combobox/SelectedOptions/SelectedOptions.js +1 -1
- package/esm/form/combobox/SelectedOptions/SelectedOptions.js.map +1 -1
- package/esm/form/combobox/ToggleListButton.js +1 -1
- package/esm/form/combobox/ToggleListButton.js.map +1 -1
- package/esm/form/combobox/customOptionsContext.js +1 -1
- package/esm/form/combobox/customOptionsContext.js.map +1 -1
- package/esm/form/error-summary/ErrorSummary.js +3 -3
- package/esm/form/error-summary/ErrorSummary.js.map +1 -1
- package/esm/form/error-summary/ErrorSummaryItem.js +1 -1
- package/esm/form/error-summary/ErrorSummaryItem.js.map +1 -1
- package/esm/form/radio/useRadio.d.ts +1 -1
- package/esm/form/search/Search.js +1 -1
- package/esm/form/search/Search.js.map +1 -1
- package/esm/form/search/SearchButton.js +1 -1
- package/esm/form/search/SearchButton.js.map +1 -1
- package/esm/grid/Cell.js +1 -1
- package/esm/grid/Cell.js.map +1 -1
- package/esm/grid/Grid.js +1 -1
- package/esm/grid/Grid.js.map +1 -1
- package/esm/guide-panel/GuidePanel.js +1 -1
- package/esm/guide-panel/GuidePanel.js.map +1 -1
- package/esm/internal-header/InternalHeader.js.map +1 -1
- package/esm/internal-header/InternalHeaderButton.js +1 -1
- package/esm/internal-header/InternalHeaderButton.js.map +1 -1
- package/esm/internal-header/InternalHeaderTitle.js +1 -1
- package/esm/internal-header/InternalHeaderTitle.js.map +1 -1
- package/esm/internal-header/InternalHeaderUser.js +1 -1
- package/esm/internal-header/InternalHeaderUser.js.map +1 -1
- package/esm/internal-header/InternalHeaderUserButton.js +1 -1
- package/esm/internal-header/InternalHeaderUserButton.js.map +1 -1
- package/esm/layout/bleed/Bleed.js +1 -1
- package/esm/layout/bleed/Bleed.js.map +1 -1
- package/esm/layout/box/Box.d.ts +1 -1
- package/esm/layout/content-container/ContentContainer.js +1 -1
- package/esm/layout/content-container/ContentContainer.js.map +1 -1
- package/esm/layout/grid/HGrid.js +1 -1
- package/esm/layout/grid/HGrid.js.map +1 -1
- package/esm/layout/page/Page.d.ts +2 -2
- package/esm/layout/page/Page.js.map +1 -1
- package/esm/layout/page/parts/PageBlock.d.ts +6 -5
- package/esm/layout/page/parts/PageBlock.js +1 -1
- package/esm/layout/page/parts/PageBlock.js.map +1 -1
- package/esm/layout/responsive/Responsive.js.map +1 -1
- package/esm/layout/sidemal-test/AvatarPanel.js +1 -1
- package/esm/layout/sidemal-test/AvatarPanel.js.map +1 -1
- package/esm/layout/sidemal-test/Content.js +4 -4
- package/esm/layout/sidemal-test/Content.js.map +1 -1
- package/esm/layout/sidemal-test/Filter.js +1 -1
- package/esm/layout/sidemal-test/Filter.js.map +1 -1
- package/esm/layout/sidemal-test/Header.js +1 -1
- package/esm/layout/sidemal-test/Header.js.map +1 -1
- package/esm/layout/sidemal-test/Intro.js +2 -2
- package/esm/layout/sidemal-test/Intro.js.map +1 -1
- package/esm/layout/sidemal-test/content-box/ContentBox.js.map +1 -1
- package/esm/layout/stack/HStack.js.map +1 -1
- package/esm/layout/stack/Stack.js.map +1 -1
- package/esm/layout/stack/VStack.js.map +1 -1
- package/esm/layout/utilities/types.d.ts +2 -2
- package/esm/link-panel/LinkPanel.d.ts +2 -2
- package/esm/link-panel/LinkPanel.js +3 -3
- package/esm/link-panel/LinkPanel.js.map +1 -1
- package/esm/link-panel/LinkPanelDescription.js +1 -1
- package/esm/link-panel/LinkPanelDescription.js.map +1 -1
- package/esm/link-panel/LinkPanelTitle.js +1 -1
- package/esm/link-panel/LinkPanelTitle.js.map +1 -1
- package/esm/loader/Loader.js.map +1 -1
- package/esm/modal/ModalBody.js +1 -1
- package/esm/modal/ModalBody.js.map +1 -1
- package/esm/modal/ModalFooter.js +1 -1
- package/esm/modal/ModalFooter.js.map +1 -1
- package/esm/modal/ModalHeader.js +1 -1
- package/esm/modal/ModalHeader.js.map +1 -1
- package/esm/pagination/Pagination.js.map +1 -1
- package/esm/pagination/PaginationItem.js +1 -1
- package/esm/pagination/PaginationItem.js.map +1 -1
- package/esm/panel/Panel.js +1 -1
- package/esm/panel/Panel.js.map +1 -1
- package/esm/popover/Popover.js.map +1 -1
- package/esm/popover/PopoverContent.js +1 -1
- package/esm/popover/PopoverContent.js.map +1 -1
- package/esm/read-more/ReadMore.d.ts +4 -0
- package/esm/read-more/ReadMore.js +13 -11
- package/esm/read-more/ReadMore.js.map +1 -1
- package/esm/skeleton/Skeleton.js +1 -1
- package/esm/skeleton/Skeleton.js.map +1 -1
- package/esm/table/Body.js +1 -1
- package/esm/table/Body.js.map +1 -1
- package/esm/table/ColumnHeader.js +1 -1
- package/esm/table/ColumnHeader.js.map +1 -1
- package/esm/table/DataCell.js +1 -1
- package/esm/table/DataCell.js.map +1 -1
- package/esm/table/ExpandableRow.js +15 -14
- package/esm/table/ExpandableRow.js.map +1 -1
- package/esm/table/Header.js +1 -1
- package/esm/table/Header.js.map +1 -1
- package/esm/table/Row.js +1 -1
- package/esm/table/Row.js.map +1 -1
- package/esm/tabs/TabList.js +1 -1
- package/esm/tabs/TabList.js.map +1 -1
- package/esm/tabs/Tabs.js +1 -1
- package/esm/tabs/Tabs.js.map +1 -1
- package/esm/tag/Tag.js +1 -1
- package/esm/tag/Tag.js.map +1 -1
- package/esm/timeline/AxisLabels.js +1 -1
- package/esm/timeline/AxisLabels.js.map +1 -1
- package/esm/timeline/TimelineRow.js +2 -2
- package/esm/timeline/TimelineRow.js.map +1 -1
- package/esm/timeline/hooks/useTimelineRows.js +5 -3
- package/esm/timeline/hooks/useTimelineRows.js.map +1 -1
- package/esm/timeline/utils/timeline.js +1 -1
- package/esm/timeline/utils/timeline.js.map +1 -1
- package/esm/timeline/zoom/ZoomButton.js +1 -1
- package/esm/timeline/zoom/ZoomButton.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.d.ts +4 -0
- package/esm/tooltip/Tooltip.js +13 -8
- package/esm/tooltip/Tooltip.js.map +1 -1
- package/esm/typography/BodyLong.js +1 -1
- package/esm/typography/BodyLong.js.map +1 -1
- package/esm/typography/ErrorMessage.js +1 -1
- package/esm/typography/ErrorMessage.js.map +1 -1
- package/esm/typography/Ingress.js +1 -1
- package/esm/typography/Ingress.js.map +1 -1
- package/esm/util/RandomIcon.js +1 -1
- package/esm/util/RandomIcon.js.map +1 -1
- package/esm/util/hooks/useCallbackRef.d.ts +7 -0
- package/esm/util/hooks/useCallbackRef.js +15 -0
- package/esm/util/hooks/useCallbackRef.js.map +1 -0
- package/esm/util/hooks/useControllableState.d.ts +9 -0
- package/esm/util/hooks/useControllableState.js +22 -0
- package/esm/util/hooks/useControllableState.js.map +1 -0
- package/esm/util/mergeRefs.js.map +1 -1
- package/package.json +3 -3
- package/src/accordion/Accordion.tsx +5 -5
- package/src/accordion/AccordionContent.tsx +3 -3
- package/src/accordion/AccordionHeader.tsx +3 -3
- package/src/accordion/AccordionItem.tsx +21 -21
- package/src/accordion/accordion.stories.tsx +8 -5
- package/src/alert/Alert.tsx +8 -8
- package/src/alert/alert.stories.tsx +7 -7
- package/src/button/Button.tsx +4 -4
- package/src/button/button.stories.tsx +1 -1
- package/src/chat/Bubble.tsx +4 -4
- package/src/chat/Chat.tsx +5 -5
- package/src/chat/chat.stories.tsx +1 -1
- package/src/chips/Chips.tsx +4 -4
- package/src/chips/Removable.tsx +4 -4
- package/src/chips/Toggle.tsx +3 -3
- package/src/chips/chips.stories.tsx +5 -5
- package/src/copybutton/CopyButton.tsx +6 -6
- package/src/copybutton/copy-button.stories.tsx +3 -3
- package/src/date/context/useSharedMonthContext.tsx +1 -1
- package/src/date/datepicker/DatePicker.tsx +2 -2
- package/src/date/datepicker/DatePickerStandalone.tsx +2 -2
- package/src/date/datepicker/datepicker.stories.tsx +2 -2
- package/src/date/datepicker/parts/Caption.tsx +2 -3
- package/src/date/datepicker/parts/DropdownCaption.tsx +2 -2
- package/src/date/datepicker/parts/HeadRow.tsx +1 -1
- package/src/date/datepicker/parts/Row.tsx +3 -3
- package/src/date/hooks/useDatepicker.tsx +7 -7
- package/src/date/hooks/useMonthPicker.tsx +7 -7
- package/src/date/hooks/useRangeDatepicker.test.tsx +2 -2
- package/src/date/hooks/useRangeDatepicker.tsx +28 -28
- package/src/date/monthpicker/MonthButton.tsx +1 -1
- package/src/date/monthpicker/MonthCaption.tsx +1 -1
- package/src/date/monthpicker/MonthPicker.tsx +3 -3
- package/src/date/monthpicker/MonthPickerStandalone.tsx +3 -3
- package/src/date/monthpicker/MonthSelector.tsx +1 -1
- package/src/date/parts/DateInput.tsx +6 -6
- package/src/date/utils/__tests__/check-dates.test.ts +3 -3
- package/src/date/utils/__tests__/format-dates.test.ts +7 -7
- package/src/date/utils/__tests__/get-initial-year.test.ts +14 -14
- package/src/date/utils/__tests__/get-month-weeks.test.ts +0 -1
- package/src/date/utils/__tests__/is-match.test.ts +4 -4
- package/src/date/utils/__tests__/parse-dates.test.ts +2 -2
- package/src/date/utils/check-dates.ts +2 -2
- package/src/date/utils/dates-disabled.ts +1 -1
- package/src/date/utils/format-date.ts +1 -1
- package/src/date/utils/get-dates.ts +1 -1
- package/src/date/utils/get-month-weeks.ts +6 -6
- package/src/date/utils/is-match.ts +2 -3
- package/src/date/utils/labels.ts +1 -1
- package/src/date/utils/navigation.ts +18 -18
- package/src/date/utils/parse-date.ts +8 -8
- package/src/dropdown/Dropdown.tsx +14 -11
- package/src/dropdown/Menu/Divider.tsx +1 -1
- package/src/dropdown/Menu/GroupedList/GroupedHeading.tsx +2 -2
- package/src/dropdown/Menu/GroupedList/GroupedItem.tsx +1 -1
- package/src/dropdown/Menu/GroupedList/index.tsx +1 -1
- package/src/dropdown/Menu/List/Item.tsx +1 -1
- package/src/dropdown/Menu/index.tsx +1 -1
- package/src/dropdown/dropdown.stories.tsx +1 -1
- package/src/expansion-card/ExpansionCard.tsx +3 -3
- package/src/expansion-card/ExpansionCardContent.tsx +1 -1
- package/src/expansion-card/ExpansionCardDescription.tsx +1 -1
- package/src/expansion-card/ExpansionCardHeader.tsx +2 -2
- package/src/expansion-card/ExpansionCardTitle.tsx +2 -2
- package/src/expansion-card/expansion-card.stories.tsx +1 -1
- package/src/form/ConfirmationPanel.test.tsx +1 -1
- package/src/form/ConfirmationPanel.tsx +2 -2
- package/src/form/Fieldset/Fieldset.tsx +2 -2
- package/src/form/ReadOnlyIcon.tsx +1 -1
- package/src/form/Select.tsx +6 -6
- package/src/form/Switch.tsx +4 -4
- package/src/form/TextField.tsx +4 -4
- package/src/form/Textarea.tsx +4 -4
- package/src/form/checkbox/Checkbox.test.tsx +8 -8
- package/src/form/checkbox/Checkbox.tsx +3 -3
- package/src/form/checkbox/CheckboxGroup.tsx +4 -4
- package/src/form/checkbox/useCheckbox.ts +3 -3
- package/src/form/combobox/Combobox.tsx +8 -8
- package/src/form/combobox/ComboboxProvider.tsx +3 -3
- package/src/form/combobox/ComboboxWrapper.tsx +1 -1
- package/src/form/combobox/FilteredOptions/FilteredOptions.tsx +6 -6
- package/src/form/combobox/FilteredOptions/filteredOptionsContext.tsx +18 -18
- package/src/form/combobox/FilteredOptions/useVirtualFocus.ts +5 -5
- package/src/form/combobox/Input/Input.tsx +6 -6
- package/src/form/combobox/Input/inputContext.tsx +6 -6
- package/src/form/combobox/SelectedOptions/SelectedOptions.tsx +1 -1
- package/src/form/combobox/SelectedOptions/selectedOptionsContext.tsx +9 -9
- package/src/form/combobox/ToggleListButton.tsx +1 -2
- package/src/form/combobox/combobox.stories.tsx +8 -8
- package/src/form/combobox/combobox.test.tsx +14 -12
- package/src/form/combobox/customOptionsContext.tsx +6 -6
- package/src/form/combobox/types.ts +2 -2
- package/src/form/error-summary/ErrorSummary.tsx +6 -6
- package/src/form/error-summary/ErrorSummaryItem.tsx +2 -2
- package/src/form/error-summary/error-summary.stories.tsx +2 -1
- package/src/form/radio/Radio.test.tsx +1 -1
- package/src/form/radio/Radio.tsx +1 -1
- package/src/form/radio/RadioGroup.tsx +3 -3
- package/src/form/radio/useRadio.ts +1 -1
- package/src/form/search/Search.tsx +6 -6
- package/src/form/search/SearchButton.tsx +2 -2
- package/src/form/search/search.stories.tsx +1 -1
- package/src/form/stories/fieldset.stories.tsx +3 -2
- package/src/form/stories/select.stories.tsx +2 -1
- package/src/form/stories/text-field.stories.tsx +2 -1
- package/src/form/useFormField.ts +3 -3
- package/src/grid/Cell.tsx +3 -3
- package/src/grid/Grid.tsx +2 -2
- package/src/grid/grid.stories.tsx +1 -1
- package/src/guide-panel/GuidePanel.tsx +2 -2
- package/src/guide-panel/guidepanel.stories.tsx +1 -1
- package/src/help-text/HelpText.tsx +2 -2
- package/src/internal-header/InternalHeader.tsx +1 -1
- package/src/internal-header/InternalHeaderButton.tsx +1 -1
- package/src/internal-header/InternalHeaderTitle.tsx +1 -1
- package/src/internal-header/InternalHeaderUser.tsx +1 -1
- package/src/internal-header/InternalHeaderUserButton.tsx +1 -1
- package/src/internal-header/header.stories.tsx +3 -3
- package/src/layout/bleed/Bleed.tsx +7 -7
- package/src/layout/box/Box.stories.tsx +4 -4
- package/src/layout/box/Box.tsx +7 -7
- package/src/layout/content-container/ContentContainer.tsx +1 -1
- package/src/layout/grid/HGrid.tsx +4 -4
- package/src/layout/page/Page.stories.tsx +1 -1
- package/src/layout/page/Page.tsx +4 -4
- package/src/layout/page/parts/PageBlock.tsx +8 -7
- package/src/layout/responsive/Responsive.tsx +6 -6
- package/src/layout/responsive/hide.stories.tsx +1 -1
- package/src/layout/responsive/show.stories.tsx +1 -1
- package/src/layout/sidemal-test/AvatarPanel.tsx +1 -1
- package/src/layout/sidemal-test/Content.tsx +4 -4
- package/src/layout/sidemal-test/Filter.tsx +1 -1
- package/src/layout/sidemal-test/Header.tsx +1 -1
- package/src/layout/sidemal-test/Intro.tsx +2 -2
- package/src/layout/sidemal-test/content-box/ContentBox.tsx +6 -6
- package/src/layout/sidemal-test/navno-sidemal.stories.tsx +1 -1
- package/src/layout/stack/HStack.tsx +1 -1
- package/src/layout/stack/Stack.tsx +3 -3
- package/src/layout/stack/VStack.tsx +1 -1
- package/src/layout/stack/stack.stories.tsx +2 -2
- package/src/layout/utilities/css.ts +6 -6
- package/src/layout/utilities/types.ts +2 -2
- package/src/link/Link.tsx +2 -2
- package/src/link/link.stories.tsx +1 -1
- package/src/link-panel/LinkPanel.tsx +6 -7
- package/src/link-panel/LinkPanelDescription.tsx +1 -1
- package/src/link-panel/LinkPanelTitle.tsx +2 -2
- package/src/list/List.tsx +2 -2
- package/src/list/ListItem.tsx +2 -2
- package/src/list/list.stories.tsx +2 -2
- package/src/loader/Loader.tsx +4 -4
- package/src/loader/loader.stories.tsx +1 -0
- package/src/modal/Modal.test.tsx +4 -4
- package/src/modal/Modal.tsx +2 -2
- package/src/modal/ModalBody.tsx +2 -2
- package/src/modal/ModalFooter.tsx +2 -2
- package/src/modal/ModalHeader.tsx +2 -2
- package/src/modal/ModalUtils.ts +2 -2
- package/src/modal/dialog-polyfill.ts +16 -16
- package/src/pagination/Pagination.tsx +5 -6
- package/src/pagination/PaginationItem.tsx +3 -3
- package/src/pagination/steps.test.ts +8 -8
- package/src/panel/Panel.tsx +3 -3
- package/src/panel/panel.stories.tsx +2 -1
- package/src/popover/Popover.test.tsx +7 -7
- package/src/popover/Popover.tsx +8 -8
- package/src/popover/PopoverContent.tsx +2 -2
- package/src/provider/Provider.tsx +1 -1
- package/src/read-more/ReadMore.tsx +19 -13
- package/src/read-more/readmore.stories.tsx +4 -0
- package/src/skeleton/Skeleton.tsx +4 -4
- package/src/stepper/Step.tsx +2 -2
- package/src/stepper/Stepper.tsx +3 -3
- package/src/table/Body.tsx +1 -1
- package/src/table/ColumnHeader.tsx +2 -2
- package/src/table/DataCell.tsx +2 -2
- package/src/table/ExpandableRow.tsx +19 -17
- package/src/table/Header.tsx +1 -1
- package/src/table/HeaderCell.tsx +1 -1
- package/src/table/Row.tsx +2 -2
- package/src/table/Table.tsx +2 -2
- package/src/table/stories/table-async.stories.tsx +4 -4
- package/src/table/stories/table.stories.tsx +1 -1
- package/src/tabs/Tab.tsx +3 -3
- package/src/tabs/TabList.tsx +4 -4
- package/src/tabs/TabPanel.tsx +1 -1
- package/src/tabs/Tabs.stories.tsx +1 -1
- package/src/tabs/Tabs.tsx +4 -4
- package/src/tag/Tag.tsx +3 -3
- package/src/tag/tag.stories.tsx +1 -1
- package/src/timeline/AxisLabels.tsx +9 -9
- package/src/timeline/Pin.tsx +2 -2
- package/src/timeline/Timeline.tsx +7 -7
- package/src/timeline/TimelineRow.tsx +5 -5
- package/src/timeline/hooks/useTimelineContext.tsx +1 -1
- package/src/timeline/hooks/useTimelineRows.ts +18 -19
- package/src/timeline/period/ClickablePeriod.tsx +4 -4
- package/src/timeline/period/NonClickablePeriod.tsx +1 -1
- package/src/timeline/period/index.tsx +1 -1
- package/src/timeline/timeline.stories.tsx +2 -2
- package/src/timeline/utils/calc.ts +2 -2
- package/src/timeline/utils/filter.ts +2 -2
- package/src/timeline/utils/period.ts +2 -2
- package/src/timeline/utils/timeline.ts +1 -1
- package/src/timeline/zoom/ZoomButton.tsx +3 -3
- package/src/timeline/zoom/index.tsx +1 -1
- package/src/toggle-group/ToggleGroup.stories.tsx +2 -2
- package/src/toggle-group/ToggleGroup.tsx +5 -5
- package/src/toggle-group/ToggleItem.tsx +1 -1
- package/src/toggle-group/context.ts +1 -1
- package/src/tooltip/Tooltip.test.tsx +10 -10
- package/src/tooltip/Tooltip.tsx +20 -11
- package/src/tooltip/tooltip.stories.tsx +1 -1
- package/src/typography/BodyLong.tsx +4 -4
- package/src/typography/BodyShort.tsx +3 -3
- package/src/typography/Detail.tsx +3 -3
- package/src/typography/ErrorMessage.tsx +3 -3
- package/src/typography/Heading.tsx +3 -3
- package/src/typography/Ingress.tsx +1 -1
- package/src/typography/Label.tsx +3 -3
- package/src/typography/stories/heading.stories.tsx +1 -2
- package/src/util/AnimateHeight.tsx +1 -1
- package/src/util/OverridableComponent.ts +1 -1
- package/src/util/RandomIcon.tsx +1 -1
- package/src/util/Slot.tsx +3 -3
- package/src/util/TextareaAutoSize.tsx +4 -4
- package/src/util/__tests__/Slot.test.tsx +11 -11
- package/src/util/hooks/useCallbackRef.ts +20 -0
- package/src/util/hooks/useControllableState.ts +40 -0
- package/src/util/mergeRefs.tsx +2 -1
- package/src/util/omit.ts +1 -1
- package/src/util/useEventListener.ts +1 -1
- package/src/util/useMedia.ts +1 -1
|
@@ -148,7 +148,7 @@ const fromValidation = (day: Date, opt?: UseRangeDatepickerOptions) => {
|
|
|
148
148
|
const toValidation = (
|
|
149
149
|
day: Date,
|
|
150
150
|
from: Date,
|
|
151
|
-
opt?: UseRangeDatepickerOptions
|
|
151
|
+
opt?: UseRangeDatepickerOptions,
|
|
152
152
|
) => {
|
|
153
153
|
const isBefore =
|
|
154
154
|
opt?.fromDate && day && differenceInCalendarDays(opt?.fromDate, day) > 0;
|
|
@@ -185,12 +185,12 @@ const toValidation = (
|
|
|
185
185
|
|
|
186
186
|
const initialValidation = (
|
|
187
187
|
range?: DateRange,
|
|
188
|
-
opt?: UseRangeDatepickerOptions
|
|
188
|
+
opt?: UseRangeDatepickerOptions,
|
|
189
189
|
): RangeValidationT => {
|
|
190
190
|
if (!range || !range?.from) {
|
|
191
191
|
return getValidationMessage(
|
|
192
192
|
{ isEmpty: true, isValidDate: false },
|
|
193
|
-
{ isEmpty: true, isValidDate: false }
|
|
193
|
+
{ isEmpty: true, isValidDate: false },
|
|
194
194
|
);
|
|
195
195
|
}
|
|
196
196
|
|
|
@@ -215,7 +215,7 @@ const initialValidation = (
|
|
|
215
215
|
* });
|
|
216
216
|
*/
|
|
217
217
|
export const useRangeDatepicker = (
|
|
218
|
-
opt: UseRangeDatepickerOptions = {}
|
|
218
|
+
opt: UseRangeDatepickerOptions = {},
|
|
219
219
|
): UseRangeDatepickerValue => {
|
|
220
220
|
const {
|
|
221
221
|
locale: _locale = "nb",
|
|
@@ -240,26 +240,26 @@ export const useRangeDatepicker = (
|
|
|
240
240
|
|
|
241
241
|
// Initialize states
|
|
242
242
|
const [month, setMonth] = useState(
|
|
243
|
-
defaultSelected ? defaultSelected?.from : defaultMonth ?? today
|
|
243
|
+
defaultSelected ? defaultSelected?.from : defaultMonth ?? today,
|
|
244
244
|
);
|
|
245
245
|
const [selectedRange, setSelectedRange] = useState<DateRange | undefined>(
|
|
246
|
-
defaultSelected ?? { from: undefined, to: undefined }
|
|
246
|
+
defaultSelected ?? { from: undefined, to: undefined },
|
|
247
247
|
);
|
|
248
248
|
|
|
249
249
|
const [fromInputValue, setFromInputValue] = useState(
|
|
250
250
|
defaultSelected?.from
|
|
251
251
|
? formatDateForInput(defaultSelected.from, locale, "date", inputFormat)
|
|
252
|
-
: ""
|
|
252
|
+
: "",
|
|
253
253
|
);
|
|
254
254
|
|
|
255
255
|
const [toInputValue, setToInputValue] = useState(
|
|
256
256
|
defaultSelected?.to
|
|
257
257
|
? formatDateForInput(defaultSelected.to, locale, "date", inputFormat)
|
|
258
|
-
: ""
|
|
258
|
+
: "",
|
|
259
259
|
);
|
|
260
260
|
|
|
261
261
|
const [validation, setValidation] = useState<RangeValidationT>(
|
|
262
|
-
initialValidation(selectedRange, opt)
|
|
262
|
+
initialValidation(selectedRange, opt),
|
|
263
263
|
);
|
|
264
264
|
|
|
265
265
|
const [open, setOpen] = useState(false);
|
|
@@ -271,7 +271,7 @@ export const useRangeDatepicker = (
|
|
|
271
271
|
|
|
272
272
|
const updateValidation = (
|
|
273
273
|
from: Partial<RangeValidationT["from"]> = {},
|
|
274
|
-
to: Partial<RangeValidationT["to"]> = {}
|
|
274
|
+
to: Partial<RangeValidationT["to"]> = {},
|
|
275
275
|
) => {
|
|
276
276
|
const msg = getValidationMessage(from, to);
|
|
277
277
|
setValidation(msg);
|
|
@@ -284,18 +284,18 @@ export const useRangeDatepicker = (
|
|
|
284
284
|
setValidation(
|
|
285
285
|
initialValidation(
|
|
286
286
|
defaultSelected ?? { from: undefined, to: undefined },
|
|
287
|
-
opt
|
|
288
|
-
)
|
|
287
|
+
opt,
|
|
288
|
+
),
|
|
289
289
|
);
|
|
290
290
|
setFromInputValue(
|
|
291
291
|
defaultSelected?.from
|
|
292
292
|
? formatDateForInput(defaultSelected.from, locale, "date", inputFormat)
|
|
293
|
-
: ""
|
|
293
|
+
: "",
|
|
294
294
|
);
|
|
295
295
|
setToInputValue(
|
|
296
296
|
defaultSelected?.to
|
|
297
297
|
? formatDateForInput(defaultSelected.to, locale, "date", inputFormat)
|
|
298
|
-
: ""
|
|
298
|
+
: "",
|
|
299
299
|
);
|
|
300
300
|
setDefaultSelected(_defaultSelected);
|
|
301
301
|
};
|
|
@@ -305,12 +305,12 @@ export const useRangeDatepicker = (
|
|
|
305
305
|
setFromInputValue(
|
|
306
306
|
range?.from
|
|
307
307
|
? formatDateForInput(range.from, locale, "date", inputFormat)
|
|
308
|
-
: ""
|
|
308
|
+
: "",
|
|
309
309
|
);
|
|
310
310
|
setToInputValue(
|
|
311
311
|
range?.to
|
|
312
312
|
? formatDateForInput(range?.to, locale, "date", inputFormat)
|
|
313
|
-
: ""
|
|
313
|
+
: "",
|
|
314
314
|
);
|
|
315
315
|
setValidation(initialValidation(range, opt));
|
|
316
316
|
};
|
|
@@ -324,12 +324,12 @@ export const useRangeDatepicker = (
|
|
|
324
324
|
today,
|
|
325
325
|
locale,
|
|
326
326
|
"date",
|
|
327
|
-
allowTwoDigitYear
|
|
327
|
+
allowTwoDigitYear,
|
|
328
328
|
);
|
|
329
329
|
if (isValidDate(day)) {
|
|
330
330
|
src === RANGE.FROM
|
|
331
331
|
? setFromInputValue(
|
|
332
|
-
formatDateForInput(day, locale, "date", inputFormat)
|
|
332
|
+
formatDateForInput(day, locale, "date", inputFormat),
|
|
333
333
|
)
|
|
334
334
|
: setToInputValue(formatDateForInput(day, locale, "date", inputFormat));
|
|
335
335
|
|
|
@@ -348,7 +348,7 @@ export const useRangeDatepicker = (
|
|
|
348
348
|
today,
|
|
349
349
|
locale,
|
|
350
350
|
"date",
|
|
351
|
-
allowTwoDigitYear
|
|
351
|
+
allowTwoDigitYear,
|
|
352
352
|
);
|
|
353
353
|
if (!isValidDate(day)) {
|
|
354
354
|
return;
|
|
@@ -381,18 +381,18 @@ export const useRangeDatepicker = (
|
|
|
381
381
|
|
|
382
382
|
range?.from
|
|
383
383
|
? setFromInputValue(
|
|
384
|
-
formatDateForInput(range?.from, locale, "date", inputFormat)
|
|
384
|
+
formatDateForInput(range?.from, locale, "date", inputFormat),
|
|
385
385
|
)
|
|
386
386
|
: setFromInputValue("");
|
|
387
387
|
prevToRange && !resetTo
|
|
388
388
|
? setToInputValue(
|
|
389
|
-
formatDateForInput(prevToRange, locale, "date", inputFormat)
|
|
389
|
+
formatDateForInput(prevToRange, locale, "date", inputFormat),
|
|
390
390
|
)
|
|
391
391
|
: setToInputValue("");
|
|
392
392
|
updateRange({ from: range?.from, to: resetTo ? undefined : prevToRange });
|
|
393
393
|
updateValidation(
|
|
394
394
|
{ isValidDate: !!range?.from, isEmpty: !range?.from },
|
|
395
|
-
{ isValidDate: !!range?.to, isEmpty: !prevToRange || resetTo }
|
|
395
|
+
{ isValidDate: !!range?.to, isEmpty: !prevToRange || resetTo },
|
|
396
396
|
);
|
|
397
397
|
};
|
|
398
398
|
|
|
@@ -400,7 +400,7 @@ export const useRangeDatepicker = (
|
|
|
400
400
|
val: string = "",
|
|
401
401
|
day: Date,
|
|
402
402
|
isBefore = false,
|
|
403
|
-
isAfter = false
|
|
403
|
+
isAfter = false,
|
|
404
404
|
) => {
|
|
405
405
|
setFromInputValue(val);
|
|
406
406
|
if (!validateDay(day)) {
|
|
@@ -415,7 +415,7 @@ export const useRangeDatepicker = (
|
|
|
415
415
|
isBefore,
|
|
416
416
|
isAfter,
|
|
417
417
|
},
|
|
418
|
-
validation.to
|
|
418
|
+
validation.to,
|
|
419
419
|
);
|
|
420
420
|
return;
|
|
421
421
|
}
|
|
@@ -427,7 +427,7 @@ export const useRangeDatepicker = (
|
|
|
427
427
|
isBefore,
|
|
428
428
|
isAfter,
|
|
429
429
|
},
|
|
430
|
-
validation.to
|
|
430
|
+
validation.to,
|
|
431
431
|
);
|
|
432
432
|
return;
|
|
433
433
|
}
|
|
@@ -449,7 +449,7 @@ export const useRangeDatepicker = (
|
|
|
449
449
|
today,
|
|
450
450
|
locale,
|
|
451
451
|
"date",
|
|
452
|
-
allowTwoDigitYear
|
|
452
|
+
allowTwoDigitYear,
|
|
453
453
|
);
|
|
454
454
|
if (validateDay(toDay)) {
|
|
455
455
|
updateRange({ from: day, to: toDay });
|
|
@@ -467,7 +467,7 @@ export const useRangeDatepicker = (
|
|
|
467
467
|
val: string = "",
|
|
468
468
|
day: Date,
|
|
469
469
|
isBefore = false,
|
|
470
|
-
isAfter = false
|
|
470
|
+
isAfter = false,
|
|
471
471
|
) => {
|
|
472
472
|
setToInputValue(val);
|
|
473
473
|
if (!validateDay(day)) {
|
|
@@ -518,7 +518,7 @@ export const useRangeDatepicker = (
|
|
|
518
518
|
today,
|
|
519
519
|
locale,
|
|
520
520
|
"date",
|
|
521
|
-
allowTwoDigitYear
|
|
521
|
+
allowTwoDigitYear,
|
|
522
522
|
);
|
|
523
523
|
const isBefore = fromDate && differenceInCalendarDays(fromDate, day) > 0;
|
|
524
524
|
const isAfter = toDate && differenceInCalendarDays(day, toDate) > 0;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ArrowLeftIcon, ArrowRightIcon } from "@navikt/aksel-icons";
|
|
2
1
|
import { isAfter, isBefore } from "date-fns";
|
|
3
2
|
import setYear from "date-fns/setYear";
|
|
4
3
|
import startOfMonth from "date-fns/startOfMonth";
|
|
5
4
|
import startOfYear from "date-fns/startOfYear";
|
|
6
5
|
import React from "react";
|
|
7
6
|
import { useDayPicker } from "react-day-picker";
|
|
7
|
+
import { ArrowLeftIcon, ArrowRightIcon } from "@navikt/aksel-icons";
|
|
8
8
|
import { Button } from "../../button";
|
|
9
9
|
import { Select } from "../../form/Select";
|
|
10
10
|
import { useSharedMonthContext } from "../context";
|
|
@@ -75,7 +75,7 @@ export const MonthPicker = forwardRef<HTMLDivElement, MonthPickerProps>(
|
|
|
75
75
|
onYearChange,
|
|
76
76
|
strategy = "absolute",
|
|
77
77
|
},
|
|
78
|
-
ref
|
|
78
|
+
ref,
|
|
79
79
|
) => {
|
|
80
80
|
const ariaId = useId(id);
|
|
81
81
|
const [open, setOpen] = useState(_open ?? false);
|
|
@@ -84,7 +84,7 @@ export const MonthPicker = forwardRef<HTMLDivElement, MonthPickerProps>(
|
|
|
84
84
|
const mergedRef = useMemo(() => mergeRefs([wrapperRef, ref]), [ref]);
|
|
85
85
|
|
|
86
86
|
const [selectedMonth, setSelectedMonth] = useState<Date | undefined>(
|
|
87
|
-
defaultSelected
|
|
87
|
+
defaultSelected,
|
|
88
88
|
);
|
|
89
89
|
|
|
90
90
|
const handleSelect = (month?: Date) => {
|
|
@@ -151,7 +151,7 @@ export const MonthPicker = forwardRef<HTMLDivElement, MonthPickerProps>(
|
|
|
151
151
|
</div>
|
|
152
152
|
</DateContext.Provider>
|
|
153
153
|
);
|
|
154
|
-
}
|
|
154
|
+
},
|
|
155
155
|
) as MonthPickerComponent;
|
|
156
156
|
|
|
157
157
|
MonthPicker.Standalone = MonthPickerStandalone;
|
|
@@ -40,10 +40,10 @@ export const MonthPickerStandalone = forwardRef<
|
|
|
40
40
|
year,
|
|
41
41
|
onYearChange,
|
|
42
42
|
},
|
|
43
|
-
ref
|
|
43
|
+
ref,
|
|
44
44
|
) => {
|
|
45
45
|
const [selectedMonth, setSelectedMonth] = useState<Date | undefined>(
|
|
46
|
-
defaultSelected
|
|
46
|
+
defaultSelected,
|
|
47
47
|
);
|
|
48
48
|
|
|
49
49
|
const handleSelect = (month?: Date) => {
|
|
@@ -81,7 +81,7 @@ export const MonthPickerStandalone = forwardRef<
|
|
|
81
81
|
</RootProvider>
|
|
82
82
|
</div>
|
|
83
83
|
);
|
|
84
|
-
}
|
|
84
|
+
},
|
|
85
85
|
);
|
|
86
86
|
|
|
87
87
|
export default MonthPickerStandalone;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CalendarIcon } from "@navikt/aksel-icons";
|
|
2
1
|
import cl from "clsx";
|
|
3
|
-
import React, {
|
|
2
|
+
import React, { InputHTMLAttributes, forwardRef, useRef } from "react";
|
|
3
|
+
import { CalendarIcon } from "@navikt/aksel-icons";
|
|
4
4
|
import { ReadOnlyIcon } from "../../form/ReadOnlyIcon";
|
|
5
5
|
import { FormFieldProps, useFormField } from "../../form/useFormField";
|
|
6
6
|
import { BodyShort, ErrorMessage, Label } from "../../typography";
|
|
@@ -84,7 +84,7 @@ const DateInput = forwardRef<HTMLInputElement, DateInputProps>((props, ref) => {
|
|
|
84
84
|
"navds-form-field--readonly": readOnly,
|
|
85
85
|
"navds-text-field--readonly": readOnly,
|
|
86
86
|
"navds-date__field--readonly": readOnly,
|
|
87
|
-
}
|
|
87
|
+
},
|
|
88
88
|
)}
|
|
89
89
|
>
|
|
90
90
|
<Label
|
|
@@ -121,7 +121,7 @@ const DateInput = forwardRef<HTMLInputElement, DateInputProps>((props, ref) => {
|
|
|
121
121
|
"navds-date__field-input",
|
|
122
122
|
"navds-text-field__input",
|
|
123
123
|
"navds-body-short",
|
|
124
|
-
`navds-body-short--${size}
|
|
124
|
+
`navds-body-short--${size}`,
|
|
125
125
|
)}
|
|
126
126
|
size={isDatepickerVariant ? 11 : 14}
|
|
127
127
|
/>
|
|
@@ -159,9 +159,9 @@ const DateInput = forwardRef<HTMLInputElement, DateInputProps>((props, ref) => {
|
|
|
159
159
|
});
|
|
160
160
|
|
|
161
161
|
export const DatePickerInput = forwardRef<HTMLInputElement, DateInputProps>(
|
|
162
|
-
(props, ref) => <DateInput {...props} ref={ref}
|
|
162
|
+
(props, ref) => <DateInput {...props} ref={ref} />,
|
|
163
163
|
);
|
|
164
164
|
|
|
165
165
|
export const MonthPickerInput = forwardRef<HTMLInputElement, DateInputProps>(
|
|
166
|
-
(props, ref) => <DateInput {...props} variant="monthpicker" ref={ref}
|
|
166
|
+
(props, ref) => <DateInput {...props} variant="monthpicker" ref={ref} />,
|
|
167
167
|
);
|
|
@@ -9,13 +9,13 @@ describe("Returns if date is in current month", () => {
|
|
|
9
9
|
|
|
10
10
|
test("Date should not be within current month (false)", () => {
|
|
11
11
|
expect(
|
|
12
|
-
dateIsInCurrentMonth(new Date("Sep 2 2021"), selectedDate)
|
|
12
|
+
dateIsInCurrentMonth(new Date("Sep 2 2021"), selectedDate),
|
|
13
13
|
).toBeFalsy();
|
|
14
14
|
expect(
|
|
15
|
-
dateIsInCurrentMonth(new Date("Sep 1 2021"), selectedDate)
|
|
15
|
+
dateIsInCurrentMonth(new Date("Sep 1 2021"), selectedDate),
|
|
16
16
|
).toBeFalsy();
|
|
17
17
|
expect(
|
|
18
|
-
dateIsInCurrentMonth(new Date("Sep 30 2021"), selectedDate)
|
|
18
|
+
dateIsInCurrentMonth(new Date("Sep 30 2021"), selectedDate),
|
|
19
19
|
).toBeFalsy();
|
|
20
20
|
});
|
|
21
21
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { parseDate } from "../parse-date";
|
|
2
1
|
import nb from "date-fns/locale/nb";
|
|
3
2
|
import { formatDateForInput } from "../format-date";
|
|
3
|
+
import { parseDate } from "../parse-date";
|
|
4
4
|
|
|
5
5
|
const parse = (inp: string) => parseDate(inp, new Date(), nb, "date", false);
|
|
6
6
|
const parseTwoDigit = (inp: string) =>
|
|
@@ -9,24 +9,24 @@ const parseTwoDigit = (inp: string) =>
|
|
|
9
9
|
describe("Format date to correct output", () => {
|
|
10
10
|
test("formatDateForInput", () => {
|
|
11
11
|
expect(formatDateForInput(parse("15/05/2022"), nb, "date")).toEqual(
|
|
12
|
-
"15.05.2022"
|
|
12
|
+
"15.05.2022",
|
|
13
13
|
);
|
|
14
14
|
expect(formatDateForInput(parse("1/5/2022"), nb, "date")).toEqual(
|
|
15
|
-
"01.05.2022"
|
|
15
|
+
"01.05.2022",
|
|
16
16
|
);
|
|
17
17
|
expect(formatDateForInput(parse("1/05/2022"), nb, "date")).toEqual(
|
|
18
|
-
"01.05.2022"
|
|
18
|
+
"01.05.2022",
|
|
19
19
|
);
|
|
20
20
|
expect(formatDateForInput(parse("15/5/2022"), nb, "date")).toEqual(
|
|
21
|
-
"15.05.2022"
|
|
21
|
+
"15.05.2022",
|
|
22
22
|
);
|
|
23
23
|
});
|
|
24
24
|
test("formatDateForInput with twoDigitYears", () => {
|
|
25
25
|
expect(formatDateForInput(parseTwoDigit("15/05/22"), nb, "date")).toEqual(
|
|
26
|
-
"15.05.2022"
|
|
26
|
+
"15.05.2022",
|
|
27
27
|
);
|
|
28
28
|
expect(formatDateForInput(parseTwoDigit("1/5/95"), nb, "date")).toEqual(
|
|
29
|
-
"01.05.1995"
|
|
29
|
+
"01.05.1995",
|
|
30
30
|
);
|
|
31
31
|
});
|
|
32
32
|
});
|
|
@@ -8,8 +8,8 @@ describe("Returns initial year for monthpicker", () => {
|
|
|
8
8
|
new Date("Oct 4 2021"),
|
|
9
9
|
getInitialYear({
|
|
10
10
|
defaultMonth: new Date("Aug 4 2021"),
|
|
11
|
-
})
|
|
12
|
-
)
|
|
11
|
+
}),
|
|
12
|
+
),
|
|
13
13
|
).toBeTruthy();
|
|
14
14
|
});
|
|
15
15
|
test("Default selected should not be valid (false)", () => {
|
|
@@ -18,8 +18,8 @@ describe("Returns initial year for monthpicker", () => {
|
|
|
18
18
|
new Date("Oct 4 2021"),
|
|
19
19
|
getInitialYear({
|
|
20
20
|
defaultMonth: new Date("Aug 4 2020"),
|
|
21
|
-
})
|
|
22
|
-
)
|
|
21
|
+
}),
|
|
22
|
+
),
|
|
23
23
|
).toBeFalsy();
|
|
24
24
|
});
|
|
25
25
|
test("Default selected should be valid with fromDate", () => {
|
|
@@ -30,8 +30,8 @@ describe("Returns initial year for monthpicker", () => {
|
|
|
30
30
|
defaultMonth: new Date("Aug 4 2021"),
|
|
31
31
|
/* toDate: new Date("Oct 4 2021"), */
|
|
32
32
|
fromDate: new Date("Oct 4 2021"),
|
|
33
|
-
})
|
|
34
|
-
)
|
|
33
|
+
}),
|
|
34
|
+
),
|
|
35
35
|
).toBeTruthy();
|
|
36
36
|
});
|
|
37
37
|
test("Default selected should be valid with toDate", () => {
|
|
@@ -41,8 +41,8 @@ describe("Returns initial year for monthpicker", () => {
|
|
|
41
41
|
getInitialYear({
|
|
42
42
|
defaultMonth: new Date("Aug 4 2021"),
|
|
43
43
|
toDate: new Date("Jun 4 2021"),
|
|
44
|
-
})
|
|
45
|
-
)
|
|
44
|
+
}),
|
|
45
|
+
),
|
|
46
46
|
).toBeTruthy();
|
|
47
47
|
});
|
|
48
48
|
test("Default selected should be moved to toDate", () => {
|
|
@@ -52,8 +52,8 @@ describe("Returns initial year for monthpicker", () => {
|
|
|
52
52
|
getInitialYear({
|
|
53
53
|
defaultMonth: new Date("Aug 4 2021"),
|
|
54
54
|
toDate: new Date("Jun 4 2020"),
|
|
55
|
-
})
|
|
56
|
-
)
|
|
55
|
+
}),
|
|
56
|
+
),
|
|
57
57
|
).toBeTruthy();
|
|
58
58
|
});
|
|
59
59
|
test("Default selected should be moved to fromDate", () => {
|
|
@@ -63,8 +63,8 @@ describe("Returns initial year for monthpicker", () => {
|
|
|
63
63
|
getInitialYear({
|
|
64
64
|
defaultMonth: new Date("Aug 4 2021"),
|
|
65
65
|
fromDate: new Date("Jun 4 2022"),
|
|
66
|
-
})
|
|
67
|
-
)
|
|
66
|
+
}),
|
|
67
|
+
),
|
|
68
68
|
).toBeTruthy();
|
|
69
69
|
});
|
|
70
70
|
test("Default selected should be moved to fromDate, not toDate", () => {
|
|
@@ -75,8 +75,8 @@ describe("Returns initial year for monthpicker", () => {
|
|
|
75
75
|
defaultMonth: new Date("Aug 4 2021"),
|
|
76
76
|
toDate: new Date("Oct 4 2023"),
|
|
77
77
|
fromDate: new Date("Jun 4 2022"),
|
|
78
|
-
})
|
|
79
|
-
)
|
|
78
|
+
}),
|
|
79
|
+
),
|
|
80
80
|
).toBeTruthy();
|
|
81
81
|
});
|
|
82
82
|
});
|
|
@@ -21,22 +21,22 @@ describe("Returns if date is disabled", () => {
|
|
|
21
21
|
});
|
|
22
22
|
test("Date should be disabled type After (same month)(true)", () => {
|
|
23
23
|
expect(
|
|
24
|
-
isMatch(new Date("Aug 5 2018"), [{ after: new Date("Aug 2 2018") }])
|
|
24
|
+
isMatch(new Date("Aug 5 2018"), [{ after: new Date("Aug 2 2018") }]),
|
|
25
25
|
).toBeTruthy();
|
|
26
26
|
});
|
|
27
27
|
test("Date should be disabled type After (true)", () => {
|
|
28
28
|
expect(
|
|
29
|
-
isMatch(new Date("Oct 5 2018"), [{ after: new Date("Aug 2 2018") }])
|
|
29
|
+
isMatch(new Date("Oct 5 2018"), [{ after: new Date("Aug 2 2018") }]),
|
|
30
30
|
).toBeTruthy();
|
|
31
31
|
});
|
|
32
32
|
test("Date should be disabled type Before (true)", () => {
|
|
33
33
|
expect(
|
|
34
|
-
isMatch(new Date("Aug 1 2018"), [{ before: new Date("Aug 2 2018") }])
|
|
34
|
+
isMatch(new Date("Aug 1 2018"), [{ before: new Date("Aug 2 2018") }]),
|
|
35
35
|
).toBeTruthy();
|
|
36
36
|
});
|
|
37
37
|
test("Date should be disabled type Before (false)", () => {
|
|
38
38
|
expect(
|
|
39
|
-
isMatch(new Date("Jul 1 2018"), [{ before: new Date("Aug 2 2018") }])
|
|
39
|
+
isMatch(new Date("Jul 1 2018"), [{ before: new Date("Aug 2 2018") }]),
|
|
40
40
|
).toBeTruthy();
|
|
41
41
|
});
|
|
42
42
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable jest/expect-expect */
|
|
2
|
-
import { parseDate, isValidDate } from "..";
|
|
3
|
-
import nb from "date-fns/locale/nb";
|
|
4
2
|
import getMonth from "date-fns/getMonth";
|
|
3
|
+
import nb from "date-fns/locale/nb";
|
|
4
|
+
import { isValidDate, parseDate } from "..";
|
|
5
5
|
|
|
6
6
|
const check = (inp: string) =>
|
|
7
7
|
// eslint-disable-next-line jest/valid-expect
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import setYear from "date-fns/setYear";
|
|
2
1
|
import isThisMonth from "date-fns/isThisMonth";
|
|
2
|
+
import setYear from "date-fns/setYear";
|
|
3
3
|
|
|
4
4
|
export const dateIsInCurrentMonth = (
|
|
5
5
|
date: Date,
|
|
6
|
-
dateToCompare: Date
|
|
6
|
+
dateToCompare: Date,
|
|
7
7
|
): boolean => {
|
|
8
8
|
return isThisMonth(setYear(date, Number(dateToCompare.getFullYear())));
|
|
9
9
|
};
|
|
@@ -4,7 +4,7 @@ import { isDateRange } from "react-day-picker";
|
|
|
4
4
|
// TODO: ((date: Date) => boolean)
|
|
5
5
|
export const disableDate = (
|
|
6
6
|
disabledSelection: Date | Array<any>,
|
|
7
|
-
date: Date
|
|
7
|
+
date: Date,
|
|
8
8
|
): boolean => {
|
|
9
9
|
let result: boolean = false;
|
|
10
10
|
if (disabledSelection instanceof Date) {
|
|
@@ -40,7 +40,7 @@ export const getMonths = (start: Date, end: Date, current: Date): Date[] => {
|
|
|
40
40
|
export const getYears = (
|
|
41
41
|
start: Date,
|
|
42
42
|
end: Date,
|
|
43
|
-
currentYear: number
|
|
43
|
+
currentYear: number,
|
|
44
44
|
): Date[] => {
|
|
45
45
|
const years: Date[] = [];
|
|
46
46
|
const fromYear = start.getFullYear();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
Locale,
|
|
2
3
|
addDays,
|
|
3
4
|
addWeeks,
|
|
4
5
|
differenceInCalendarDays,
|
|
@@ -6,7 +7,6 @@ import {
|
|
|
6
7
|
endOfWeek,
|
|
7
8
|
getWeek,
|
|
8
9
|
getWeeksInMonth,
|
|
9
|
-
Locale,
|
|
10
10
|
startOfMonth,
|
|
11
11
|
startOfWeek,
|
|
12
12
|
} from "date-fns";
|
|
@@ -23,7 +23,7 @@ export function getMonthWeeks(
|
|
|
23
23
|
options: {
|
|
24
24
|
locale: Locale;
|
|
25
25
|
useFixedWeeks?: boolean;
|
|
26
|
-
}
|
|
26
|
+
},
|
|
27
27
|
): MonthWeek[] {
|
|
28
28
|
const _options = {
|
|
29
29
|
...options,
|
|
@@ -32,7 +32,7 @@ export function getMonthWeeks(
|
|
|
32
32
|
const weeksInMonth: MonthWeek[] = daysToMonthWeeks(
|
|
33
33
|
startOfMonth(month),
|
|
34
34
|
endOfMonth(month),
|
|
35
|
-
_options
|
|
35
|
+
_options,
|
|
36
36
|
);
|
|
37
37
|
|
|
38
38
|
if (_options?.useFixedWeeks) {
|
|
@@ -45,7 +45,7 @@ export function getMonthWeeks(
|
|
|
45
45
|
const extraWeeks = daysToMonthWeeks(
|
|
46
46
|
addWeeks(lastDate, 1),
|
|
47
47
|
toDate,
|
|
48
|
-
_options
|
|
48
|
+
_options,
|
|
49
49
|
);
|
|
50
50
|
weeksInMonth.push(...extraWeeks);
|
|
51
51
|
}
|
|
@@ -60,7 +60,7 @@ export function daysToMonthWeeks(
|
|
|
60
60
|
options?: {
|
|
61
61
|
locale?: Locale;
|
|
62
62
|
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
63
|
-
}
|
|
63
|
+
},
|
|
64
64
|
): MonthWeek[] {
|
|
65
65
|
const toWeek = endOfWeek(toDate, options);
|
|
66
66
|
const fromWeek = startOfWeek(fromDate, options);
|
|
@@ -76,7 +76,7 @@ export function daysToMonthWeeks(
|
|
|
76
76
|
const weekNumber = getWeek(date, options);
|
|
77
77
|
|
|
78
78
|
const existingWeek = result.find(
|
|
79
|
-
(value) => value.weekNumber === weekNumber
|
|
79
|
+
(value) => value.weekNumber === weekNumber,
|
|
80
80
|
);
|
|
81
81
|
if (existingWeek) {
|
|
82
82
|
existingWeek.dates.push(date);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import isSameDay from "date-fns/isSameDay";
|
|
2
|
-
import isDate from "date-fns/isDate";
|
|
3
1
|
import differenceInCalendarDays from "date-fns/differenceInCalendarDays";
|
|
2
|
+
import isDate from "date-fns/isDate";
|
|
3
|
+
import isSameDay from "date-fns/isSameDay";
|
|
4
4
|
import isSameMonth from "date-fns/isSameMonth";
|
|
5
|
-
|
|
6
5
|
import {
|
|
7
6
|
DateAfter,
|
|
8
7
|
DateBefore,
|
package/src/date/utils/labels.ts
CHANGED
|
@@ -188,7 +188,7 @@ const modalLabelMonth = (localeCode?: string): string => {
|
|
|
188
188
|
|
|
189
189
|
export const modalLabel = (
|
|
190
190
|
localeCode: string,
|
|
191
|
-
variant: "single" | "multiple" | "range" | "month"
|
|
191
|
+
variant: "single" | "multiple" | "range" | "month",
|
|
192
192
|
) => {
|
|
193
193
|
switch (variant) {
|
|
194
194
|
case "single":
|