@navikt/ds-react 5.12.5 → 5.14.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 +285 -138
- package/cjs/accordion/Accordion.js +2 -2
- package/cjs/accordion/AccordionHeader.js +3 -5
- package/cjs/accordion/AccordionItem.js +11 -14
- package/cjs/alert/Alert.js +2 -2
- package/cjs/button/Button.js +11 -12
- 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 +4 -7
- package/cjs/copybutton/CopyButton.js +6 -7
- package/cjs/date/datepicker/DatePicker.js +4 -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/datepicker/parts/WeekRow.js +2 -2
- package/cjs/date/monthpicker/MonthCaption.js +1 -1
- package/cjs/date/monthpicker/MonthPicker.js +4 -3
- package/cjs/date/parts/DateInput.js +1 -1
- package/cjs/date/parts/DateWrapper.js +2 -2
- 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/dropdown/Menu/GroupedList/GroupedItem.js +3 -6
- package/cjs/dropdown/Menu/List/Item.js +3 -6
- package/cjs/dropdown/Toggle.js +6 -5
- package/cjs/expansion-card/ExpansionCardHeader.js +1 -1
- package/cjs/form/ConfirmationPanel.js +2 -2
- package/cjs/form/ReadOnlyIcon.js +1 -1
- package/cjs/form/Select.js +1 -1
- package/cjs/form/Textarea.js +2 -1
- package/cjs/form/checkbox/Checkbox.js +3 -2
- package/cjs/form/combobox/Combobox.js +7 -7
- package/cjs/form/combobox/ComboboxProvider.js +2 -2
- package/cjs/form/combobox/FilteredOptions/FilteredOptions.js +4 -4
- package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js +5 -6
- package/cjs/form/combobox/Input/inputContext.js +2 -2
- package/cjs/form/combobox/SelectedOptions/SelectedOptions.js +1 -1
- package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.js +2 -5
- package/cjs/form/error-summary/ErrorSummary.js +3 -3
- package/cjs/form/error-summary/ErrorSummaryItem.js +1 -1
- package/cjs/form/radio/Radio.js +3 -2
- package/cjs/form/radio/RadioGroup.js +2 -2
- package/cjs/form/search/Search.js +3 -2
- package/cjs/form/search/SearchButton.js +3 -5
- package/cjs/form/useFormField.js +2 -2
- package/cjs/grid/Cell.js +1 -1
- package/cjs/grid/Grid.js +1 -1
- package/cjs/guide-panel/GuidePanel.js +1 -1
- package/cjs/guide-panel/Illustration.js +2 -2
- package/cjs/help-text/HelpText.js +5 -7
- package/cjs/help-text/HelpTextIcon.js +2 -2
- 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/list/List.js +2 -2
- package/cjs/loader/Loader.js +2 -1
- package/cjs/modal/Modal.js +21 -18
- 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/Popover.js +6 -5
- package/cjs/popover/PopoverContent.js +1 -1
- package/cjs/read-more/ReadMore.js +12 -12
- package/cjs/skeleton/Skeleton.js +1 -1
- package/cjs/stepper/Step.js +6 -6
- package/cjs/table/Body.js +1 -1
- package/cjs/table/ColumnHeader.js +1 -1
- package/cjs/table/DataCell.js +3 -3
- package/cjs/table/ExpandableRow.js +23 -22
- package/cjs/table/Header.js +1 -1
- package/cjs/table/HeaderCell.js +2 -1
- package/cjs/table/Row.js +1 -1
- package/cjs/tabs/TabList.js +3 -2
- package/cjs/tabs/Tabs.js +1 -1
- package/cjs/tag/Tag.js +5 -3
- package/cjs/timeline/AxisLabels.js +1 -1
- package/cjs/timeline/Pin.js +2 -2
- package/cjs/timeline/TimelineRow.js +2 -2
- package/cjs/timeline/hooks/useTimelineRows.js +5 -3
- package/cjs/timeline/period/ClickablePeriod.js +2 -2
- package/cjs/timeline/utils/timeline.js +1 -1
- package/cjs/timeline/zoom/ZoomButton.js +1 -1
- package/cjs/toggle-group/ToggleGroup.js +3 -3
- package/cjs/tooltip/Tooltip.js +18 -12
- package/cjs/typography/BodyLong.js +1 -1
- package/cjs/typography/ErrorMessage.js +1 -1
- package/cjs/typography/Ingress.js +1 -1
- package/cjs/util/Slot.js +2 -5
- package/cjs/util/TextareaAutoSize.js +7 -5
- package/cjs/util/composeEventHandlers.js +17 -0
- package/cjs/util/hooks/index.js +19 -0
- package/cjs/util/hooks/package.json +6 -0
- package/cjs/util/hooks/useCallbackRef.js +18 -0
- package/cjs/util/hooks/useClientLayoutEffect.js +7 -0
- package/cjs/util/hooks/useControllableState.js +25 -0
- package/cjs/util/hooks/useMergeRefs.js +37 -0
- package/cjs/util/{usePrevious.js → hooks/usePrevious.js} +2 -1
- package/cjs/util/index.js +7 -7
- package/cjs/util/types/index.js +2 -0
- package/cjs/util/types/package.json +6 -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 +3 -5
- 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/button/Button.d.ts +1 -1
- package/esm/button/Button.js +12 -13
- package/esm/button/Button.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 +4 -7
- package/esm/chips/Removable.js.map +1 -1
- package/esm/chips/Toggle.d.ts +1 -1
- package/esm/copybutton/CopyButton.js +6 -7
- package/esm/copybutton/CopyButton.js.map +1 -1
- package/esm/date/context/useSharedMonthContext.js.map +1 -1
- package/esm/date/datepicker/DatePicker.js +5 -3
- package/esm/date/datepicker/DatePicker.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/datepicker/parts/WeekRow.js +1 -1
- package/esm/date/datepicker/parts/WeekRow.js.map +1 -1
- package/esm/date/monthpicker/MonthCaption.js +1 -1
- package/esm/date/monthpicker/MonthCaption.js.map +1 -1
- package/esm/date/monthpicker/MonthPicker.js +4 -3
- package/esm/date/monthpicker/MonthPicker.js.map +1 -1
- package/esm/date/parts/DateInput.js +1 -1
- package/esm/date/parts/DateInput.js.map +1 -1
- package/esm/date/parts/DateWrapper.js +1 -1
- package/esm/date/parts/DateWrapper.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/dropdown/Menu/GroupedList/GroupedItem.d.ts +1 -1
- package/esm/dropdown/Menu/GroupedList/GroupedItem.js +3 -6
- package/esm/dropdown/Menu/GroupedList/GroupedItem.js.map +1 -1
- package/esm/dropdown/Menu/GroupedList/index.d.ts +1 -1
- package/esm/dropdown/Menu/List/Item.d.ts +1 -1
- package/esm/dropdown/Menu/List/Item.js +3 -6
- package/esm/dropdown/Menu/List/Item.js.map +1 -1
- package/esm/dropdown/Menu/List/index.d.ts +1 -1
- package/esm/dropdown/Toggle.js +6 -5
- package/esm/dropdown/Toggle.js.map +1 -1
- package/esm/expansion-card/ExpansionCard.d.ts +1 -1
- package/esm/expansion-card/ExpansionCardHeader.js +1 -1
- package/esm/expansion-card/ExpansionCardHeader.js.map +1 -1
- package/esm/expansion-card/ExpansionCardTitle.d.ts +1 -1
- package/esm/form/ConfirmationPanel.js +1 -1
- package/esm/form/ConfirmationPanel.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/Textarea.js +2 -1
- package/esm/form/Textarea.js.map +1 -1
- package/esm/form/checkbox/Checkbox.js +2 -1
- package/esm/form/checkbox/Checkbox.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 +8 -8
- 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 +3 -4
- package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
- package/esm/form/combobox/Input/inputContext.js +1 -1
- package/esm/form/combobox/Input/inputContext.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/SelectedOptions/selectedOptionsContext.js +1 -1
- package/esm/form/combobox/SelectedOptions/selectedOptionsContext.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.d.ts +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/Radio.js +2 -1
- package/esm/form/radio/Radio.js.map +1 -1
- package/esm/form/radio/RadioGroup.js +1 -1
- package/esm/form/radio/RadioGroup.js.map +1 -1
- package/esm/form/radio/useRadio.d.ts +1 -1
- package/esm/form/search/Search.js +5 -4
- package/esm/form/search/Search.js.map +1 -1
- package/esm/form/search/SearchButton.js +3 -5
- package/esm/form/search/SearchButton.js.map +1 -1
- package/esm/form/useFormField.js +1 -1
- package/esm/form/useFormField.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/guide-panel/Illustration.js +1 -1
- package/esm/guide-panel/Illustration.js.map +1 -1
- package/esm/help-text/HelpText.d.ts +0 -5
- package/esm/help-text/HelpText.js +6 -8
- package/esm/help-text/HelpText.js.map +1 -1
- package/esm/help-text/HelpTextIcon.js +1 -1
- package/esm/internal-header/InternalHeader.d.ts +1 -1
- package/esm/internal-header/InternalHeader.js.map +1 -1
- package/esm/internal-header/InternalHeaderButton.d.ts +1 -1
- package/esm/internal-header/InternalHeaderButton.js +1 -1
- package/esm/internal-header/InternalHeaderButton.js.map +1 -1
- package/esm/internal-header/InternalHeaderTitle.d.ts +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.d.ts +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 +2 -2
- 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 +7 -6
- 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.d.ts +1 -1
- package/esm/layout/stack/HStack.js.map +1 -1
- package/esm/layout/stack/Stack.d.ts +1 -1
- package/esm/layout/stack/Stack.js.map +1 -1
- package/esm/layout/stack/VStack.d.ts +1 -1
- package/esm/layout/stack/VStack.js.map +1 -1
- package/esm/layout/utilities/types.d.ts +2 -2
- package/esm/link/Link.d.ts +1 -1
- 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.d.ts +1 -1
- package/esm/link-panel/LinkPanelTitle.js +1 -1
- package/esm/link-panel/LinkPanelTitle.js.map +1 -1
- package/esm/list/List.js +1 -1
- package/esm/loader/Loader.js +2 -1
- package/esm/loader/Loader.js.map +1 -1
- package/esm/modal/Modal.js +21 -18
- package/esm/modal/Modal.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/modal/types.d.ts +1 -1
- package/esm/pagination/Pagination.js.map +1 -1
- package/esm/pagination/PaginationItem.d.ts +1 -1
- package/esm/pagination/PaginationItem.js +1 -1
- package/esm/pagination/PaginationItem.js.map +1 -1
- package/esm/panel/Panel.d.ts +1 -1
- package/esm/panel/Panel.js +1 -1
- package/esm/panel/Panel.js.map +1 -1
- package/esm/popover/Popover.d.ts +1 -1
- package/esm/popover/Popover.js +4 -3
- 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 -13
- 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/stepper/Step.d.ts +1 -1
- package/esm/stepper/Step.js +6 -6
- package/esm/stepper/Step.js.map +1 -1
- package/esm/table/AnimateHeight.js.map +1 -0
- 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.d.ts +4 -0
- package/esm/table/DataCell.js +3 -3
- package/esm/table/DataCell.js.map +1 -1
- package/esm/table/ExpandableRow.js +23 -22
- 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/HeaderCell.d.ts +4 -0
- package/esm/table/HeaderCell.js +2 -1
- package/esm/table/HeaderCell.js.map +1 -1
- package/esm/table/Row.js +1 -1
- package/esm/table/Row.js.map +1 -1
- package/esm/tabs/Tab.d.ts +1 -1
- package/esm/tabs/TabList.js +4 -3
- package/esm/tabs/TabList.js.map +1 -1
- package/esm/tabs/Tabs.d.ts +1 -1
- package/esm/tabs/Tabs.js +1 -1
- package/esm/tabs/Tabs.js.map +1 -1
- package/esm/tag/Tag.d.ts +4 -0
- package/esm/tag/Tag.js +5 -3
- 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/Pin.js +3 -3
- package/esm/timeline/Pin.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/period/ClickablePeriod.js +3 -3
- package/esm/timeline/period/ClickablePeriod.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 +2 -2
- package/esm/toggle-group/ToggleGroup.js.map +1 -1
- package/esm/tooltip/Tooltip.d.ts +4 -0
- package/esm/tooltip/Tooltip.js +18 -12
- package/esm/tooltip/Tooltip.js.map +1 -1
- package/esm/typography/BodyLong.d.ts +1 -1
- package/esm/typography/BodyLong.js +1 -1
- package/esm/typography/BodyLong.js.map +1 -1
- package/esm/typography/BodyShort.d.ts +1 -1
- package/esm/typography/Detail.d.ts +1 -1
- package/esm/typography/ErrorMessage.d.ts +1 -1
- package/esm/typography/ErrorMessage.js +1 -1
- package/esm/typography/ErrorMessage.js.map +1 -1
- package/esm/typography/Heading.d.ts +1 -1
- package/esm/typography/Ingress.d.ts +1 -1
- package/esm/typography/Ingress.js +1 -1
- package/esm/typography/Ingress.js.map +1 -1
- package/esm/typography/Label.d.ts +1 -1
- package/esm/util/Slot.js +1 -1
- package/esm/util/Slot.js.map +1 -1
- package/esm/util/TextareaAutoSize.js +5 -3
- package/esm/util/TextareaAutoSize.js.map +1 -1
- package/esm/util/composeEventHandlers.d.ts +8 -0
- package/esm/util/composeEventHandlers.js +14 -0
- package/esm/util/composeEventHandlers.js.map +1 -0
- package/esm/util/hooks/index.d.ts +8 -0
- package/esm/util/hooks/index.js +9 -0
- package/esm/util/hooks/index.js.map +1 -0
- 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/useClientLayoutEffect.js +5 -0
- package/esm/util/hooks/useClientLayoutEffect.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/{useEventListener.d.ts → hooks/useEventListener.d.ts} +1 -1
- package/esm/util/hooks/useEventListener.js.map +1 -0
- package/esm/util/hooks/useId.js.map +1 -0
- package/esm/util/hooks/useMedia.js.map +1 -0
- package/esm/util/hooks/useMergeRefs.d.ts +15 -0
- package/esm/util/hooks/useMergeRefs.js +30 -0
- package/esm/util/hooks/useMergeRefs.js.map +1 -0
- package/esm/util/hooks/usePrevious.d.ts +1 -0
- package/esm/util/{usePrevious.js → hooks/usePrevious.js} +1 -2
- package/esm/util/hooks/usePrevious.js.map +1 -0
- package/esm/util/index.d.ts +4 -5
- package/esm/util/index.js +3 -5
- package/esm/util/index.js.map +1 -1
- package/esm/util/types/OverridableComponent.js.map +1 -0
- package/esm/util/types/index.d.ts +1 -0
- package/esm/util/types/index.js +2 -0
- package/esm/util/types/index.js.map +1 -0
- package/package.json +3 -3
- package/src/accordion/Accordion.tsx +5 -5
- package/src/accordion/AccordionContent.tsx +3 -3
- package/src/accordion/AccordionHeader.tsx +5 -7
- package/src/accordion/AccordionItem.tsx +22 -22
- package/src/accordion/accordion.stories.tsx +8 -5
- package/src/alert/Alert.tsx +8 -8
- package/src/alert/alert.stories.tsx +6 -7
- package/src/button/Button.tsx +18 -23
- 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 +7 -8
- package/src/chips/Toggle.tsx +4 -4
- package/src/chips/chips.stories.tsx +5 -5
- package/src/copybutton/CopyButton.tsx +9 -10
- package/src/copybutton/copy-button.stories.tsx +3 -3
- package/src/date/context/useSharedMonthContext.tsx +1 -1
- package/src/date/datepicker/DatePicker.tsx +7 -5
- 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/datepicker/parts/WeekRow.tsx +1 -1
- 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 +7 -6
- 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/parts/DateWrapper.tsx +1 -1
- 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 +23 -23
- package/src/dropdown/Menu/GroupedList/index.tsx +2 -2
- package/src/dropdown/Menu/List/Item.tsx +23 -23
- package/src/dropdown/Menu/List/index.tsx +1 -1
- package/src/dropdown/Menu/index.tsx +1 -1
- package/src/dropdown/Toggle.tsx +10 -6
- package/src/dropdown/dropdown.stories.tsx +1 -1
- package/src/expansion-card/ExpansionCard.tsx +4 -4
- 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 +3 -3
- package/src/expansion-card/expansion-card.stories.tsx +1 -1
- package/src/form/ConfirmationPanel.test.tsx +1 -1
- package/src/form/ConfirmationPanel.tsx +3 -3
- 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 +6 -5
- package/src/form/checkbox/Checkbox.test.tsx +8 -8
- package/src/form/checkbox/Checkbox.tsx +5 -4
- package/src/form/checkbox/CheckboxGroup.tsx +4 -4
- package/src/form/checkbox/useCheckbox.ts +3 -3
- package/src/form/combobox/Combobox.tsx +9 -12
- 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 +17 -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 +7 -7
- package/src/form/combobox/SelectedOptions/SelectedOptions.tsx +1 -1
- package/src/form/combobox/SelectedOptions/selectedOptionsContext.tsx +10 -10
- package/src/form/combobox/ToggleListButton.tsx +1 -2
- package/src/form/combobox/combobox.stories.tsx +17 -18
- 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 +3 -3
- 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 +3 -2
- package/src/form/radio/RadioGroup.tsx +4 -4
- package/src/form/radio/useRadio.ts +1 -1
- package/src/form/search/Search.tsx +9 -9
- package/src/form/search/SearchButton.tsx +4 -6
- 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 +4 -4
- 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/Illustration.tsx +1 -1
- package/src/guide-panel/guidepanel.stories.tsx +1 -1
- package/src/help-text/HelpText.tsx +9 -27
- package/src/help-text/HelpTextIcon.tsx +1 -1
- package/src/help-text/help-text.stories.tsx +58 -68
- package/src/internal-header/InternalHeader.tsx +2 -2
- package/src/internal-header/InternalHeaderButton.tsx +2 -2
- package/src/internal-header/InternalHeaderTitle.tsx +2 -2
- package/src/internal-header/InternalHeaderUser.tsx +1 -1
- package/src/internal-header/InternalHeaderUserButton.tsx +2 -2
- 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 +8 -8
- 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 +9 -8
- 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 +2 -2
- package/src/layout/stack/Stack.tsx +4 -4
- package/src/layout/stack/VStack.tsx +2 -2
- 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 +3 -3
- package/src/link/{link.stories.tsx → stories/link.stories.tsx} +3 -3
- package/src/link-panel/LinkPanel.tsx +6 -7
- package/src/link-panel/LinkPanelDescription.tsx +1 -1
- package/src/link-panel/LinkPanelTitle.tsx +3 -3
- package/src/list/List.tsx +3 -3
- package/src/list/ListItem.tsx +2 -2
- package/src/list/list.stories.tsx +2 -2
- package/src/loader/Loader.tsx +6 -5
- package/src/loader/loader.stories.tsx +1 -0
- package/src/modal/Modal.test.tsx +4 -4
- package/src/modal/Modal.tsx +32 -32
- 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/modal/types.ts +1 -1
- package/src/pagination/Pagination.tsx +5 -6
- package/src/pagination/PaginationItem.tsx +4 -4
- package/src/pagination/steps.test.ts +8 -8
- package/src/panel/Panel.tsx +4 -4
- package/src/panel/panel.stories.tsx +2 -1
- package/src/popover/Popover.test.tsx +7 -7
- package/src/popover/Popover.tsx +11 -14
- package/src/popover/PopoverContent.tsx +2 -2
- package/src/provider/Provider.tsx +1 -1
- package/src/read-more/ReadMore.tsx +20 -16
- package/src/read-more/readmore.stories.tsx +4 -0
- package/src/skeleton/Skeleton.tsx +4 -4
- package/src/stepper/Step.tsx +10 -7
- package/src/stepper/Stepper.tsx +3 -3
- package/src/{util → table}/AnimateHeight.tsx +1 -1
- package/src/table/Body.tsx +1 -1
- package/src/table/ColumnHeader.tsx +2 -2
- package/src/table/DataCell.tsx +8 -3
- package/src/table/ExpandableRow.tsx +30 -23
- package/src/table/Header.tsx +1 -1
- package/src/table/HeaderCell.tsx +7 -2
- 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 +44 -30
- package/src/table/stories/tests/table.stories.tsx +2 -3
- package/src/tabs/Tab.tsx +4 -4
- package/src/tabs/TabList.tsx +8 -6
- package/src/tabs/TabPanel.tsx +1 -1
- package/src/tabs/Tabs.stories.tsx +1 -1
- package/src/tabs/Tabs.tsx +5 -5
- package/src/tag/Tag.tsx +12 -5
- package/src/tag/tag.stories.tsx +28 -2
- package/src/timeline/AxisLabels.tsx +9 -9
- package/src/timeline/Pin.tsx +4 -7
- 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 +6 -9
- 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 +6 -6
- 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 +31 -33
- package/src/tooltip/tooltip.stories.tsx +1 -1
- package/src/typography/BodyLong.tsx +5 -5
- package/src/typography/BodyShort.tsx +4 -4
- package/src/typography/Detail.tsx +4 -4
- package/src/typography/ErrorMessage.tsx +4 -4
- package/src/typography/Heading.tsx +4 -4
- package/src/typography/Ingress.tsx +2 -2
- package/src/typography/Label.tsx +4 -4
- package/src/typography/stories/bodylong.stories.tsx +1 -2
- package/src/typography/stories/bodyshort.stories.tsx +1 -2
- package/src/typography/stories/detail.stories.tsx +1 -2
- package/src/typography/stories/error-message.stories.tsx +1 -2
- package/src/typography/stories/heading.stories.tsx +1 -3
- package/src/typography/stories/ingress.stories.tsx +1 -2
- package/src/typography/stories/label.stories.tsx +1 -2
- package/src/util/Slot.tsx +4 -4
- package/src/util/TextareaAutoSize.tsx +11 -7
- package/src/util/__tests__/Slot.test.tsx +11 -11
- package/src/util/__tests__/useMedia.test.tsx +1 -1
- package/src/util/composeEventHandlers.ts +19 -0
- package/src/util/hooks/index.ts +8 -0
- package/src/util/hooks/useCallbackRef.ts +20 -0
- package/src/util/hooks/useClientLayoutEffect.ts +5 -0
- package/src/util/hooks/useControllableState.ts +40 -0
- package/src/util/{useEventListener.ts → hooks/useEventListener.ts} +1 -1
- package/src/util/{useMedia.ts → hooks/useMedia.ts} +1 -1
- package/src/util/hooks/useMergeRefs.ts +32 -0
- package/src/util/{usePrevious.ts → hooks/usePrevious.ts} +1 -4
- package/src/util/index.ts +4 -5
- package/src/util/omit.ts +1 -1
- package/src/util/{OverridableComponent.ts → types/OverridableComponent.ts} +1 -1
- package/src/util/types/index.ts +1 -0
- package/cjs/util/RandomIcon.js +0 -38
- package/cjs/util/mergeRefs.js +0 -16
- package/cjs/util/useClientLayoutEffect.js +0 -10
- package/esm/util/AnimateHeight.js.map +0 -1
- package/esm/util/OverridableComponent.js.map +0 -1
- package/esm/util/RandomIcon.d.ts +0 -2
- package/esm/util/RandomIcon.js +0 -9
- package/esm/util/RandomIcon.js.map +0 -1
- package/esm/util/mergeRefs.d.ts +0 -2
- package/esm/util/mergeRefs.js +0 -14
- package/esm/util/mergeRefs.js.map +0 -1
- package/esm/util/useClientLayoutEffect.js +0 -8
- package/esm/util/useClientLayoutEffect.js.map +0 -1
- package/esm/util/useEventListener.js.map +0 -1
- package/esm/util/useId.js.map +0 -1
- package/esm/util/useMedia.js.map +0 -1
- package/esm/util/usePrevious.d.ts +0 -2
- package/esm/util/usePrevious.js.map +0 -1
- package/src/util/mergeRefs.tsx +0 -15
- package/src/util/useClientLayoutEffect.ts +0 -11
- package/cjs/{util → table}/AnimateHeight.js +0 -0
- package/cjs/util/{useEventListener.js → hooks/useEventListener.js} +0 -0
- package/cjs/util/{useId.js → hooks/useId.js} +0 -0
- package/cjs/util/{useMedia.js → hooks/useMedia.js} +0 -0
- package/cjs/util/{OverridableComponent.js → types/OverridableComponent.js} +0 -0
- package/esm/{util → table}/AnimateHeight.d.ts +0 -0
- package/esm/{util → table}/AnimateHeight.js +0 -0
- package/esm/util/{useClientLayoutEffect.d.ts → hooks/useClientLayoutEffect.d.ts} +0 -0
- package/esm/util/{useEventListener.js → hooks/useEventListener.js} +0 -0
- package/esm/util/{useId.d.ts → hooks/useId.d.ts} +0 -0
- package/esm/util/{useId.js → hooks/useId.js} +0 -0
- package/esm/util/{useMedia.d.ts → hooks/useMedia.d.ts} +0 -0
- package/esm/util/{useMedia.js → hooks/useMedia.js} +0 -0
- package/esm/util/{OverridableComponent.d.ts → types/OverridableComponent.d.ts} +0 -0
- package/esm/util/{OverridableComponent.js → types/OverridableComponent.js} +0 -0
- package/src/{util → link/stories}/RandomIcon.tsx +1 -1
- /package/src/util/{useId.ts → hooks/useId.ts} +0 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { CheckmarkIcon, FilesIcon } from "@navikt/aksel-icons";
|
|
2
1
|
import cl from "clsx";
|
|
3
2
|
import React, {
|
|
4
3
|
ButtonHTMLAttributes,
|
|
@@ -7,8 +6,10 @@ import React, {
|
|
|
7
6
|
useRef,
|
|
8
7
|
useState,
|
|
9
8
|
} from "react";
|
|
10
|
-
import
|
|
9
|
+
import { CheckmarkIcon, FilesIcon } from "@navikt/aksel-icons";
|
|
11
10
|
import { Label } from "../typography";
|
|
11
|
+
import { composeEventHandlers } from "../util/composeEventHandlers";
|
|
12
|
+
import copy from "../util/copy";
|
|
12
13
|
|
|
13
14
|
export interface CopyButtonProps
|
|
14
15
|
extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children"> {
|
|
@@ -97,9 +98,10 @@ export const CopyButton = forwardRef<HTMLButtonElement, CopyButtonProps>(
|
|
|
97
98
|
title = "Kopier",
|
|
98
99
|
activeTitle = "Kopiert",
|
|
99
100
|
iconPosition = "left",
|
|
101
|
+
onClick,
|
|
100
102
|
...rest
|
|
101
103
|
},
|
|
102
|
-
ref
|
|
104
|
+
ref,
|
|
103
105
|
) => {
|
|
104
106
|
const [active, setActive] = useState(false);
|
|
105
107
|
const timeoutRef = useRef<number>();
|
|
@@ -110,14 +112,11 @@ export const CopyButton = forwardRef<HTMLButtonElement, CopyButtonProps>(
|
|
|
110
112
|
};
|
|
111
113
|
}, []);
|
|
112
114
|
|
|
113
|
-
const handleClick = (
|
|
114
|
-
event: React.MouseEvent<HTMLButtonElement, MouseEvent>
|
|
115
|
-
) => {
|
|
115
|
+
const handleClick = () => {
|
|
116
116
|
timeoutRef.current && clearTimeout(timeoutRef.current);
|
|
117
117
|
copy(copyText);
|
|
118
118
|
setActive(true);
|
|
119
119
|
onActiveChange?.(true);
|
|
120
|
-
rest.onClick?.(event);
|
|
121
120
|
|
|
122
121
|
timeoutRef.current = window.setTimeout(() => {
|
|
123
122
|
setActive(false);
|
|
@@ -158,9 +157,9 @@ export const CopyButton = forwardRef<HTMLButtonElement, CopyButtonProps>(
|
|
|
158
157
|
"navds-copybutton--icon-only": !text,
|
|
159
158
|
"navds-copybutton--icon-right": iconPosition === "right",
|
|
160
159
|
"navds-copybutton--active": active,
|
|
161
|
-
}
|
|
160
|
+
},
|
|
162
161
|
)}
|
|
163
|
-
onClick={handleClick}
|
|
162
|
+
onClick={composeEventHandlers(onClick, handleClick)}
|
|
164
163
|
>
|
|
165
164
|
<span className="navds-copybutton__content">
|
|
166
165
|
{iconPosition === "left" && copyIcon}
|
|
@@ -186,7 +185,7 @@ export const CopyButton = forwardRef<HTMLButtonElement, CopyButtonProps>(
|
|
|
186
185
|
</span>
|
|
187
186
|
</button>
|
|
188
187
|
);
|
|
189
|
-
}
|
|
188
|
+
},
|
|
190
189
|
);
|
|
191
190
|
|
|
192
191
|
export default CopyButton;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { userEvent, within } from "@storybook/testing-library";
|
|
3
1
|
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { userEvent, within } from "@storybook/test";
|
|
3
|
+
import React from "react";
|
|
4
4
|
import { LinkIcon, ThumbUpIcon } from "@navikt/aksel-icons";
|
|
5
|
-
import { Tooltip } from "../tooltip";
|
|
6
5
|
import { CopyButton } from ".";
|
|
6
|
+
import { Tooltip } from "../tooltip";
|
|
7
7
|
|
|
8
8
|
const meta: Meta<typeof CopyButton> = {
|
|
9
9
|
title: "ds-react/CopyButton",
|
|
@@ -2,7 +2,7 @@ import setYear from "date-fns/setYear";
|
|
|
2
2
|
import startOfMonth from "date-fns/startOfMonth";
|
|
3
3
|
import React, { createContext, useContext, useState } from "react";
|
|
4
4
|
import { useDayPicker } from "react-day-picker";
|
|
5
|
-
import {
|
|
5
|
+
import { Matcher, getInitialYear } from "../utils";
|
|
6
6
|
|
|
7
7
|
export type SharedMonthContextType = {
|
|
8
8
|
hasDropdown: boolean;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import isWeekend from "date-fns/isWeekend";
|
|
3
|
-
import React, { forwardRef,
|
|
3
|
+
import React, { forwardRef, useRef, useState } from "react";
|
|
4
4
|
import { DateRange, DayPicker, isMatch } from "react-day-picker";
|
|
5
|
-
import {
|
|
5
|
+
import { omit } from "../../util";
|
|
6
|
+
import { useId } from "../../util/hooks";
|
|
7
|
+
import { useMergeRefs } from "../../util/hooks/useMergeRefs";
|
|
6
8
|
import { DateContext } from "../context";
|
|
7
9
|
import { DatePickerInput } from "../parts/DateInput";
|
|
8
10
|
import { DateWrapper } from "../parts/DateWrapper";
|
|
@@ -82,13 +84,13 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
|
|
|
82
84
|
onWeekNumberClick,
|
|
83
85
|
...rest
|
|
84
86
|
},
|
|
85
|
-
ref
|
|
87
|
+
ref,
|
|
86
88
|
) => {
|
|
87
89
|
const ariaId = useId(id);
|
|
88
90
|
const [open, setOpen] = useState(_open ?? false);
|
|
89
91
|
|
|
90
92
|
const wrapperRef = useRef<HTMLDivElement | null>(null);
|
|
91
|
-
const mergedRef =
|
|
93
|
+
const mergedRef = useMergeRefs(wrapperRef, ref);
|
|
92
94
|
|
|
93
95
|
const [selectedDates, setSelectedDates] = React.useState<
|
|
94
96
|
Date | Date[] | DateRange | undefined
|
|
@@ -181,7 +183,7 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
|
|
|
181
183
|
</div>
|
|
182
184
|
</DateContext.Provider>
|
|
183
185
|
);
|
|
184
|
-
}
|
|
186
|
+
},
|
|
185
187
|
) as DatePickerComponent;
|
|
186
188
|
|
|
187
189
|
DatePicker.Standalone = DatePickerStandalone;
|
|
@@ -62,7 +62,7 @@ export const DatePickerStandalone: DatePickerStandaloneType = forwardRef<
|
|
|
62
62
|
onWeekNumberClick,
|
|
63
63
|
...rest
|
|
64
64
|
},
|
|
65
|
-
ref
|
|
65
|
+
ref,
|
|
66
66
|
) => {
|
|
67
67
|
const [selectedDates, setSelectedDates] = React.useState<
|
|
68
68
|
Date | Date[] | DateRange | undefined
|
|
@@ -122,7 +122,7 @@ export const DatePickerStandalone: DatePickerStandaloneType = forwardRef<
|
|
|
122
122
|
/>
|
|
123
123
|
</div>
|
|
124
124
|
);
|
|
125
|
-
}
|
|
125
|
+
},
|
|
126
126
|
);
|
|
127
127
|
|
|
128
128
|
export default DatePickerStandalone;
|
|
@@ -58,8 +58,8 @@ export const Default: StoryObj<DefaultStoryProps> = {
|
|
|
58
58
|
{...(props.mode === "single"
|
|
59
59
|
? singleCtx.datepickerProps
|
|
60
60
|
: props.mode === "range"
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
? rangeCtx.datepickerProps
|
|
62
|
+
: {})}
|
|
63
63
|
{...newProps}
|
|
64
64
|
locale={props.locale}
|
|
65
65
|
disableWeekends={props.disableWeekends}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { ArrowLeftIcon, ArrowRightIcon } from "@navikt/aksel-icons";
|
|
2
1
|
import React from "react";
|
|
3
2
|
import { CaptionProps, useDayPicker, useNavigation } from "react-day-picker";
|
|
4
|
-
|
|
5
|
-
import WeekRow from "./WeekRow";
|
|
3
|
+
import { ArrowLeftIcon, ArrowRightIcon } from "@navikt/aksel-icons";
|
|
6
4
|
import { Button } from "../../../button";
|
|
7
5
|
import { Label } from "../../../typography";
|
|
6
|
+
import WeekRow from "./WeekRow";
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* https://github.com/gpbl/react-day-picker/tree/main/src/components/Caption
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ArrowLeftIcon, ArrowRightIcon } from "@navikt/aksel-icons";
|
|
2
1
|
import { max, min } from "date-fns";
|
|
3
2
|
import setMonth from "date-fns/setMonth";
|
|
4
3
|
import setYear from "date-fns/setYear";
|
|
5
4
|
import startOfMonth from "date-fns/startOfMonth";
|
|
6
5
|
import React from "react";
|
|
7
6
|
import { CaptionProps, useDayPicker, useNavigation } 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 { getMonths, getYears } from "../../utils/get-dates";
|
|
@@ -32,7 +32,7 @@ export const DropdownCaption = ({ displayMonth, id }: CaptionProps) => {
|
|
|
32
32
|
const handleYearChange: React.ChangeEventHandler<HTMLSelectElement> = (e) => {
|
|
33
33
|
const newMonth = setYear(
|
|
34
34
|
startOfMonth(displayMonth),
|
|
35
|
-
Number(e.target.value)
|
|
35
|
+
Number(e.target.value),
|
|
36
36
|
);
|
|
37
37
|
goToMonth(startOfMonth(min([max([newMonth, fromDate]), toDate])));
|
|
38
38
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from "react";
|
|
2
1
|
import { getUnixTime } from "date-fns";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Day, useDayPicker } from "react-day-picker";
|
|
5
4
|
import { Hide } from "../../../layout/responsive";
|
|
5
|
+
import WeekNumber from "./WeekNumber";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* The props for the {@link Row} component.
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { useDayPicker } from "react-day-picker";
|
|
3
3
|
import { Show } from "../../../layout/responsive";
|
|
4
4
|
import { Detail } from "../../../typography";
|
|
5
|
-
import { useId } from "../../../util";
|
|
5
|
+
import { useId } from "../../../util/hooks";
|
|
6
6
|
import { getMonthWeeks } from "../../utils/get-month-weeks";
|
|
7
7
|
import { labelWeek } from "../../utils/labels";
|
|
8
8
|
import WeekNumber from "./WeekNumber";
|
|
@@ -132,7 +132,7 @@ const getValidationMessage = (val = {}): DateValidationT => ({
|
|
|
132
132
|
* });
|
|
133
133
|
*/
|
|
134
134
|
export const useDatepicker = (
|
|
135
|
-
opt: UseDatepickerOptions = {}
|
|
135
|
+
opt: UseDatepickerOptions = {},
|
|
136
136
|
): UseDatepickerValue => {
|
|
137
137
|
const {
|
|
138
138
|
locale: _locale = "nb",
|
|
@@ -171,7 +171,7 @@ export const useDatepicker = (
|
|
|
171
171
|
newOpen &&
|
|
172
172
|
setMonth(selectedDay ?? defaultSelected ?? defaultMonth ?? today);
|
|
173
173
|
},
|
|
174
|
-
[defaultMonth, defaultSelected, selectedDay, today]
|
|
174
|
+
[defaultMonth, defaultSelected, selectedDay, today],
|
|
175
175
|
);
|
|
176
176
|
|
|
177
177
|
const updateDate = (date?: Date) => {
|
|
@@ -193,7 +193,7 @@ export const useDatepicker = (
|
|
|
193
193
|
updateDate(date);
|
|
194
194
|
setMonth(date ?? defaultMonth ?? today);
|
|
195
195
|
setInputValue(
|
|
196
|
-
date ? formatDateForInput(date, locale, "date", inputFormat) : ""
|
|
196
|
+
date ? formatDateForInput(date, locale, "date", inputFormat) : "",
|
|
197
197
|
);
|
|
198
198
|
};
|
|
199
199
|
|
|
@@ -206,7 +206,7 @@ export const useDatepicker = (
|
|
|
206
206
|
today,
|
|
207
207
|
locale,
|
|
208
208
|
"date",
|
|
209
|
-
allowTwoDigitYear
|
|
209
|
+
allowTwoDigitYear,
|
|
210
210
|
);
|
|
211
211
|
if (isValidDate(day)) {
|
|
212
212
|
setInputValue(formatDateForInput(day, locale, "date", inputFormat));
|
|
@@ -226,7 +226,7 @@ export const useDatepicker = (
|
|
|
226
226
|
today,
|
|
227
227
|
locale,
|
|
228
228
|
"date",
|
|
229
|
-
allowTwoDigitYear
|
|
229
|
+
allowTwoDigitYear,
|
|
230
230
|
);
|
|
231
231
|
isValidDate(day) &&
|
|
232
232
|
setInputValue(formatDateForInput(day, locale, "date", inputFormat));
|
|
@@ -249,7 +249,7 @@ export const useDatepicker = (
|
|
|
249
249
|
updateValidation();
|
|
250
250
|
setMonth(day);
|
|
251
251
|
setInputValue(
|
|
252
|
-
day ? formatDateForInput(day, locale, "date", inputFormat) : ""
|
|
252
|
+
day ? formatDateForInput(day, locale, "date", inputFormat) : "",
|
|
253
253
|
);
|
|
254
254
|
};
|
|
255
255
|
|
|
@@ -263,7 +263,7 @@ export const useDatepicker = (
|
|
|
263
263
|
today,
|
|
264
264
|
locale,
|
|
265
265
|
"date",
|
|
266
|
-
allowTwoDigitYear
|
|
266
|
+
allowTwoDigitYear,
|
|
267
267
|
);
|
|
268
268
|
|
|
269
269
|
const isBefore =
|
|
@@ -127,7 +127,7 @@ const getIsAfter = (opt: { toDate?: Date; date?: Date }) =>
|
|
|
127
127
|
* });
|
|
128
128
|
*/
|
|
129
129
|
export const useMonthpicker = (
|
|
130
|
-
opt: UseMonthPickerOptions = {}
|
|
130
|
+
opt: UseMonthPickerOptions = {},
|
|
131
131
|
): UseMonthPickerValue => {
|
|
132
132
|
const {
|
|
133
133
|
locale: _locale = "nb",
|
|
@@ -166,7 +166,7 @@ export const useMonthpicker = (
|
|
|
166
166
|
newOpen &&
|
|
167
167
|
setYear(selectedMonth ?? defaultSelected ?? defaultYear ?? today);
|
|
168
168
|
},
|
|
169
|
-
[defaultSelected, defaultYear, selectedMonth, today]
|
|
169
|
+
[defaultSelected, defaultYear, selectedMonth, today],
|
|
170
170
|
);
|
|
171
171
|
|
|
172
172
|
const updateMonth = (date?: Date) => {
|
|
@@ -188,7 +188,7 @@ export const useMonthpicker = (
|
|
|
188
188
|
updateMonth(date);
|
|
189
189
|
setYear(date ?? defaultYear ?? today);
|
|
190
190
|
setInputValue(
|
|
191
|
-
date ? formatDateForInput(date, locale, "month", inputFormat) : ""
|
|
191
|
+
date ? formatDateForInput(date, locale, "month", inputFormat) : "",
|
|
192
192
|
);
|
|
193
193
|
};
|
|
194
194
|
|
|
@@ -202,7 +202,7 @@ export const useMonthpicker = (
|
|
|
202
202
|
today,
|
|
203
203
|
locale,
|
|
204
204
|
"month",
|
|
205
|
-
allowTwoDigitYear
|
|
205
|
+
allowTwoDigitYear,
|
|
206
206
|
);
|
|
207
207
|
const isBefore = getIsBefore({ fromDate, date: day });
|
|
208
208
|
const isAfter = getIsAfter({ toDate, date: day });
|
|
@@ -221,7 +221,7 @@ export const useMonthpicker = (
|
|
|
221
221
|
today,
|
|
222
222
|
locale,
|
|
223
223
|
"month",
|
|
224
|
-
allowTwoDigitYear
|
|
224
|
+
allowTwoDigitYear,
|
|
225
225
|
);
|
|
226
226
|
isValidDate(day) &&
|
|
227
227
|
setInputValue(formatDateForInput(day, locale, "month", inputFormat));
|
|
@@ -245,7 +245,7 @@ export const useMonthpicker = (
|
|
|
245
245
|
updateMonth(month);
|
|
246
246
|
updateValidation();
|
|
247
247
|
setInputValue(
|
|
248
|
-
month ? formatDateForInput(month, locale, "month", inputFormat) : ""
|
|
248
|
+
month ? formatDateForInput(month, locale, "month", inputFormat) : "",
|
|
249
249
|
);
|
|
250
250
|
};
|
|
251
251
|
|
|
@@ -259,7 +259,7 @@ export const useMonthpicker = (
|
|
|
259
259
|
today,
|
|
260
260
|
locale,
|
|
261
261
|
"month",
|
|
262
|
-
allowTwoDigitYear
|
|
262
|
+
allowTwoDigitYear,
|
|
263
263
|
);
|
|
264
264
|
|
|
265
265
|
const isBefore = getIsBefore({ fromDate, date: month });
|
|
@@ -36,7 +36,7 @@ describe("Writing in input sets correct values", () => {
|
|
|
36
36
|
JSON.stringify({
|
|
37
37
|
from: "2022-08-03T00:00:00.000Z",
|
|
38
38
|
to: "2022-08-03T00:00:00.000Z",
|
|
39
|
-
})
|
|
39
|
+
}),
|
|
40
40
|
);
|
|
41
41
|
});
|
|
42
42
|
|
|
@@ -53,7 +53,7 @@ describe("Writing in input sets correct values", () => {
|
|
|
53
53
|
expect(res.innerHTML).toEqual(
|
|
54
54
|
JSON.stringify({
|
|
55
55
|
from: "2022-08-03T00:00:00.000Z",
|
|
56
|
-
})
|
|
56
|
+
}),
|
|
57
57
|
);
|
|
58
58
|
});
|
|
59
59
|
});
|
|
@@ -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";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
|
-
import React, { forwardRef,
|
|
2
|
+
import React, { forwardRef, useRef, useState } from "react";
|
|
3
3
|
import { RootProvider } from "react-day-picker";
|
|
4
|
-
import {
|
|
4
|
+
import { useId } from "../../util/hooks";
|
|
5
|
+
import { useMergeRefs } from "../../util/hooks/useMergeRefs";
|
|
5
6
|
import { DateContext, SharedMonthProvider } from "../context";
|
|
6
7
|
import { MonthPickerInput } from "../parts/DateInput";
|
|
7
8
|
import { DateWrapper } from "../parts/DateWrapper";
|
|
@@ -75,16 +76,16 @@ export const MonthPicker = forwardRef<HTMLDivElement, MonthPickerProps>(
|
|
|
75
76
|
onYearChange,
|
|
76
77
|
strategy = "absolute",
|
|
77
78
|
},
|
|
78
|
-
ref
|
|
79
|
+
ref,
|
|
79
80
|
) => {
|
|
80
81
|
const ariaId = useId(id);
|
|
81
82
|
const [open, setOpen] = useState(_open ?? false);
|
|
82
83
|
|
|
83
84
|
const wrapperRef = useRef<HTMLDivElement | null>(null);
|
|
84
|
-
const mergedRef =
|
|
85
|
+
const mergedRef = useMergeRefs(wrapperRef, ref);
|
|
85
86
|
|
|
86
87
|
const [selectedMonth, setSelectedMonth] = useState<Date | undefined>(
|
|
87
|
-
defaultSelected
|
|
88
|
+
defaultSelected,
|
|
88
89
|
);
|
|
89
90
|
|
|
90
91
|
const handleSelect = (month?: Date) => {
|
|
@@ -151,7 +152,7 @@ export const MonthPicker = forwardRef<HTMLDivElement, MonthPickerProps>(
|
|
|
151
152
|
</div>
|
|
152
153
|
</DateContext.Provider>
|
|
153
154
|
);
|
|
154
|
-
}
|
|
155
|
+
},
|
|
155
156
|
) as MonthPickerComponent;
|
|
156
157
|
|
|
157
158
|
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;
|