@navikt/ds-react 5.6.4 → 5.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_docs.json +297 -257
- package/cjs/accordion/AccordionContent.js +2 -2
- package/cjs/accordion/AccordionHeader.js +2 -2
- package/cjs/alert/Alert.js +2 -2
- package/cjs/button/Button.js +6 -5
- package/cjs/copybutton/CopyButton.js +8 -7
- package/cjs/date/DateInput.js +6 -5
- package/cjs/date/datepicker/DatePicker.js +6 -5
- package/cjs/date/datepicker/DatePickerStandalone.js +6 -6
- package/cjs/date/datepicker/parts/Caption.js +5 -4
- package/cjs/date/datepicker/parts/DropdownCaption.js +7 -6
- package/cjs/date/datepicker/parts/WeekRow.js +1 -1
- package/cjs/date/datepicker/types.js +2 -0
- package/cjs/date/monthpicker/MonthCaption.js +5 -4
- package/cjs/date/monthpicker/MonthPicker.js +4 -3
- package/cjs/date/monthpicker/MonthSelector.js +2 -2
- package/cjs/date/monthpicker/types.js +2 -0
- package/cjs/date/utils/parse-date.js +7 -7
- package/cjs/dropdown/Dropdown.js +4 -4
- package/cjs/dropdown/Menu/GroupedList/GroupedItem.js +2 -2
- package/cjs/dropdown/Menu/List/Item.js +3 -3
- package/cjs/dropdown/Menu/index.js +2 -2
- package/cjs/dropdown/Toggle.js +3 -3
- package/cjs/dropdown/context.js +5 -0
- package/cjs/expansion-card/ExpansionCard.js +3 -7
- package/cjs/expansion-card/ExpansionCardContent.js +4 -4
- package/cjs/expansion-card/ExpansionCardDescription.js +5 -5
- package/cjs/expansion-card/ExpansionCardHeader.js +3 -3
- package/cjs/expansion-card/ExpansionCardTitle.js +1 -1
- package/cjs/expansion-card/context.js +9 -0
- package/cjs/form/ConfirmationPanel.js +8 -6
- package/cjs/form/Fieldset/Fieldset.js +11 -10
- package/cjs/form/Fieldset/context.js +5 -0
- package/cjs/form/Fieldset/index.js +2 -1
- package/cjs/form/Select.js +8 -7
- package/cjs/form/Switch.js +7 -5
- package/cjs/form/TextField.js +6 -5
- package/cjs/form/Textarea.js +8 -7
- package/cjs/form/checkbox/Checkbox.js +1 -1
- package/cjs/form/checkbox/CheckboxGroup.js +4 -4
- package/cjs/form/checkbox/types.js +2 -0
- package/cjs/form/checkbox/useCheckbox.js +2 -2
- package/cjs/form/combobox/Combobox.js +6 -5
- package/cjs/form/combobox/FilteredOptions/FilteredOptions.js +6 -5
- package/cjs/form/combobox/Input/Input.js +2 -2
- package/cjs/form/combobox/SelectedOptions/SelectedOptions.js +3 -3
- package/cjs/form/error-summary/ErrorSummary.js +3 -3
- package/cjs/form/radio/RadioGroup.js +6 -6
- package/cjs/form/radio/types.js +2 -0
- package/cjs/form/radio/useRadio.js +2 -2
- package/cjs/form/search/Search.js +10 -9
- package/cjs/form/search/SearchButton.js +5 -5
- package/cjs/form/search/context.js +5 -0
- package/cjs/form/useFormField.js +5 -5
- package/cjs/guide-panel/Illustration.js +2 -2
- package/cjs/help-text/HelpText.js +5 -4
- package/cjs/link-panel/LinkPanel.js +2 -2
- package/cjs/link-panel/LinkPanelDescription.js +2 -2
- package/cjs/list/List.js +4 -8
- package/cjs/list/ListItem.js +2 -2
- package/cjs/list/context.js +9 -0
- package/cjs/list/types.js +2 -0
- package/cjs/loader/Loader.js +4 -4
- package/cjs/modal/Modal.js +24 -22
- package/cjs/modal/types.js +2 -0
- package/cjs/pagination/Pagination.js +5 -5
- package/cjs/pagination/PaginationItem.js +2 -2
- package/cjs/popover/Popover.js +4 -5
- package/cjs/stepper/Step.js +5 -5
- package/cjs/stepper/Stepper.js +4 -4
- package/cjs/stepper/context.js +5 -0
- package/cjs/table/ColumnHeader.js +3 -3
- package/cjs/table/DataCell.js +2 -2
- package/cjs/table/ExpandableRow.js +2 -2
- package/cjs/table/Table.js +7 -7
- package/cjs/table/context.js +5 -0
- package/cjs/table/types.js +2 -0
- package/cjs/tabs/Tab.js +4 -4
- package/cjs/tabs/TabList.js +5 -5
- package/cjs/tabs/Tabs.js +3 -3
- package/cjs/tabs/context.js +5 -0
- package/cjs/tag/Tag.js +2 -2
- package/cjs/timeline/period/NonClickablePeriod.js +1 -1
- package/cjs/timeline/period/types.js +2 -0
- package/cjs/toggle-group/ToggleGroup.js +7 -6
- package/cjs/toggle-group/ToggleItem.js +4 -4
- package/cjs/toggle-group/context.js +5 -0
- package/cjs/tooltip/Tooltip.js +4 -3
- package/cjs/util/TextareaAutoSize.js +4 -4
- package/cjs/util/index.js +7 -38
- package/cjs/util/omit.js +7 -0
- package/cjs/util/useClientLayoutEffect.js +10 -0
- package/cjs/util/useEventListener.js +17 -0
- package/esm/accordion/AccordionContent.js +1 -1
- package/esm/accordion/AccordionContent.js.map +1 -1
- package/esm/accordion/AccordionHeader.js +1 -1
- package/esm/accordion/AccordionHeader.js.map +1 -1
- package/esm/alert/Alert.js +1 -1
- package/esm/alert/Alert.js.map +1 -1
- package/esm/button/Button.d.ts +1 -1
- package/esm/button/Button.js +4 -3
- package/esm/button/Button.js.map +1 -1
- package/esm/chips/Chips.d.ts +1 -1
- package/esm/chips/Toggle.d.ts +1 -1
- package/esm/copybutton/CopyButton.d.ts +7 -7
- package/esm/copybutton/CopyButton.js +7 -6
- package/esm/copybutton/CopyButton.js.map +1 -1
- package/esm/date/DateInput.js +2 -1
- package/esm/date/DateInput.js.map +1 -1
- package/esm/date/datepicker/DatePicker.d.ts +5 -105
- package/esm/date/datepicker/DatePicker.js +4 -3
- package/esm/date/datepicker/DatePicker.js.map +1 -1
- package/esm/date/datepicker/DatePickerStandalone.d.ts +1 -1
- package/esm/date/datepicker/DatePickerStandalone.js +5 -5
- package/esm/date/datepicker/DatePickerStandalone.js.map +1 -1
- package/esm/date/datepicker/parts/Caption.js +2 -1
- package/esm/date/datepicker/parts/Caption.js.map +1 -1
- package/esm/date/datepicker/parts/DropdownCaption.js +3 -2
- package/esm/date/datepicker/parts/DropdownCaption.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/datepicker/types.d.ts +102 -0
- package/esm/date/datepicker/types.js +2 -0
- package/esm/date/datepicker/types.js.map +1 -0
- package/esm/date/hooks/useMonthPicker.d.ts +1 -1
- package/esm/date/index.d.ts +4 -3
- package/esm/date/index.js +1 -1
- package/esm/date/index.js.map +1 -1
- package/esm/date/monthpicker/MonthCaption.js +2 -1
- package/esm/date/monthpicker/MonthCaption.js.map +1 -1
- package/esm/date/monthpicker/MonthPicker.d.ts +5 -86
- package/esm/date/monthpicker/MonthPicker.js +3 -2
- package/esm/date/monthpicker/MonthPicker.js.map +1 -1
- package/esm/date/monthpicker/MonthPickerStandalone.d.ts +1 -1
- package/esm/date/monthpicker/MonthPickerStandalone.js.map +1 -1
- package/esm/date/monthpicker/MonthSelector.js +1 -1
- package/esm/date/monthpicker/MonthSelector.js.map +1 -1
- package/esm/date/monthpicker/types.d.ts +83 -0
- package/esm/date/monthpicker/types.js +2 -0
- package/esm/date/monthpicker/types.js.map +1 -0
- 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 +1 -9
- package/esm/dropdown/Dropdown.js +3 -3
- package/esm/dropdown/Dropdown.js.map +1 -1
- package/esm/dropdown/Menu/GroupedList/GroupedItem.d.ts +1 -1
- package/esm/dropdown/Menu/GroupedList/GroupedItem.js +1 -1
- 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 +2 -2
- package/esm/dropdown/Menu/List/Item.js.map +1 -1
- package/esm/dropdown/Menu/List/index.d.ts +1 -1
- package/esm/dropdown/Menu/index.js +1 -1
- package/esm/dropdown/Menu/index.js.map +1 -1
- package/esm/dropdown/Toggle.js +2 -2
- package/esm/dropdown/Toggle.js.map +1 -1
- package/esm/dropdown/context.d.ts +9 -0
- package/esm/dropdown/context.js +3 -0
- package/esm/dropdown/context.js.map +1 -0
- package/esm/expansion-card/ExpansionCard.d.ts +1 -7
- package/esm/expansion-card/ExpansionCard.js +2 -6
- package/esm/expansion-card/ExpansionCard.js.map +1 -1
- package/esm/expansion-card/ExpansionCardContent.js +2 -2
- package/esm/expansion-card/ExpansionCardContent.js.map +1 -1
- package/esm/expansion-card/ExpansionCardDescription.js +3 -3
- package/esm/expansion-card/ExpansionCardDescription.js.map +1 -1
- package/esm/expansion-card/ExpansionCardHeader.js +2 -2
- package/esm/expansion-card/ExpansionCardHeader.js.map +1 -1
- package/esm/expansion-card/ExpansionCardTitle.d.ts +1 -1
- package/esm/expansion-card/ExpansionCardTitle.js +1 -1
- package/esm/expansion-card/ExpansionCardTitle.js.map +1 -1
- package/esm/expansion-card/context.d.ts +7 -0
- package/esm/expansion-card/context.js +7 -0
- package/esm/expansion-card/context.js.map +1 -0
- package/esm/form/ConfirmationPanel.d.ts +1 -1
- package/esm/form/ConfirmationPanel.js +4 -2
- package/esm/form/ConfirmationPanel.js.map +1 -1
- package/esm/form/Fieldset/Fieldset.d.ts +0 -23
- package/esm/form/Fieldset/Fieldset.js +4 -3
- package/esm/form/Fieldset/Fieldset.js.map +1 -1
- package/esm/form/Fieldset/context.d.ts +24 -0
- package/esm/form/Fieldset/context.js +3 -0
- package/esm/form/Fieldset/context.js.map +1 -0
- package/esm/form/Fieldset/index.d.ts +2 -1
- package/esm/form/Fieldset/index.js +2 -1
- package/esm/form/Fieldset/index.js.map +1 -1
- package/esm/form/Select.js +4 -3
- package/esm/form/Select.js.map +1 -1
- package/esm/form/Switch.js +3 -1
- package/esm/form/Switch.js.map +1 -1
- package/esm/form/TextField.js +2 -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.d.ts +2 -34
- package/esm/form/checkbox/Checkbox.js +1 -1
- package/esm/form/checkbox/Checkbox.js.map +1 -1
- package/esm/form/checkbox/CheckboxGroup.d.ts +1 -1
- package/esm/form/checkbox/CheckboxGroup.js +2 -2
- package/esm/form/checkbox/CheckboxGroup.js.map +1 -1
- package/esm/form/checkbox/index.d.ts +2 -1
- package/esm/form/checkbox/index.js.map +1 -1
- package/esm/form/checkbox/types.d.ts +34 -0
- package/esm/form/checkbox/types.js +2 -0
- package/esm/form/checkbox/types.js.map +1 -0
- package/esm/form/checkbox/useCheckbox.d.ts +1 -1
- package/esm/form/checkbox/useCheckbox.js +1 -1
- package/esm/form/checkbox/useCheckbox.js.map +1 -1
- package/esm/form/combobox/Combobox.d.ts +1 -1
- package/esm/form/combobox/Combobox.js +2 -1
- package/esm/form/combobox/Combobox.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/FilteredOptions.js +2 -1
- package/esm/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
- package/esm/form/combobox/Input/Input.js +1 -1
- package/esm/form/combobox/Input/Input.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/error-summary/ErrorSummary.js +1 -1
- package/esm/form/error-summary/ErrorSummary.js.map +1 -1
- package/esm/form/error-summary/ErrorSummaryItem.d.ts +1 -1
- package/esm/form/radio/Radio.d.ts +2 -16
- package/esm/form/radio/Radio.js.map +1 -1
- package/esm/form/radio/RadioGroup.d.ts +1 -1
- package/esm/form/radio/RadioGroup.js +3 -3
- package/esm/form/radio/RadioGroup.js.map +1 -1
- package/esm/form/radio/index.d.ts +2 -1
- package/esm/form/radio/index.js.map +1 -1
- package/esm/form/radio/types.d.ts +16 -0
- package/esm/form/radio/types.js +2 -0
- package/esm/form/radio/types.js.map +1 -0
- package/esm/form/radio/useRadio.d.ts +1 -1
- package/esm/form/radio/useRadio.js +1 -1
- package/esm/form/radio/useRadio.js.map +1 -1
- package/esm/form/search/Search.d.ts +0 -7
- package/esm/form/search/Search.js +4 -3
- package/esm/form/search/Search.js.map +1 -1
- package/esm/form/search/SearchButton.d.ts +1 -1
- package/esm/form/search/SearchButton.js +3 -3
- package/esm/form/search/SearchButton.js.map +1 -1
- package/esm/form/search/context.d.ts +8 -0
- package/esm/form/search/context.js +3 -0
- package/esm/form/search/context.js.map +1 -0
- package/esm/form/useFormField.js +3 -3
- package/esm/form/useFormField.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 +1 -1
- package/esm/help-text/HelpText.js +2 -1
- package/esm/help-text/HelpText.js.map +1 -1
- package/esm/link-panel/LinkPanel.d.ts +1 -1
- package/esm/link-panel/LinkPanel.js +1 -1
- 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/list/List.d.ts +4 -35
- package/esm/list/List.js +2 -6
- package/esm/list/List.js.map +1 -1
- package/esm/list/ListItem.js +1 -1
- package/esm/list/ListItem.js.map +1 -1
- package/esm/list/context.d.ts +9 -0
- package/esm/list/context.js +7 -0
- package/esm/list/context.js.map +1 -0
- package/esm/list/index.d.ts +1 -1
- package/esm/list/types.d.ts +27 -0
- package/esm/list/types.js +2 -0
- package/esm/list/types.js.map +1 -0
- package/esm/loader/Loader.js +2 -2
- package/esm/loader/Loader.js.map +1 -1
- package/esm/modal/Modal.d.ts +2 -64
- package/esm/modal/Modal.js +8 -6
- package/esm/modal/Modal.js.map +1 -1
- package/esm/modal/ModalUtils.d.ts +1 -1
- package/esm/modal/index.d.ts +3 -2
- package/esm/modal/index.js.map +1 -1
- package/esm/modal/types.d.ts +64 -0
- package/esm/modal/types.js +2 -0
- package/esm/modal/types.js.map +1 -0
- package/esm/pagination/Pagination.js +1 -1
- package/esm/pagination/Pagination.js.map +1 -1
- package/esm/pagination/PaginationItem.d.ts +2 -1
- package/esm/pagination/PaginationItem.js +1 -1
- package/esm/pagination/PaginationItem.js.map +1 -1
- package/esm/popover/Popover.d.ts +5 -0
- package/esm/popover/Popover.js +5 -6
- package/esm/popover/Popover.js.map +1 -1
- package/esm/stepper/Step.d.ts +1 -1
- package/esm/stepper/Step.js +2 -2
- package/esm/stepper/Step.js.map +1 -1
- package/esm/stepper/Stepper.d.ts +2 -11
- package/esm/stepper/Stepper.js +2 -2
- package/esm/stepper/Stepper.js.map +1 -1
- package/esm/stepper/context.d.ts +10 -0
- package/esm/stepper/context.js +3 -0
- package/esm/stepper/context.js.map +1 -0
- package/esm/table/ColumnHeader.js +2 -2
- 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 +1 -1
- package/esm/table/ExpandableRow.js.map +1 -1
- package/esm/table/Table.d.ts +15 -23
- package/esm/table/Table.js +5 -5
- package/esm/table/Table.js.map +1 -1
- package/esm/table/context.d.ts +7 -0
- package/esm/table/context.js +3 -0
- package/esm/table/context.js.map +1 -0
- package/esm/table/index.d.ts +2 -1
- package/esm/table/index.js.map +1 -1
- package/esm/table/types.d.ts +4 -0
- package/esm/table/types.js +2 -0
- package/esm/table/types.js.map +1 -0
- package/esm/tabs/Tab.d.ts +1 -1
- package/esm/tabs/Tab.js +2 -2
- package/esm/tabs/Tab.js.map +1 -1
- package/esm/tabs/TabList.js +2 -2
- package/esm/tabs/TabList.js.map +1 -1
- package/esm/tabs/Tabs.d.ts +0 -6
- package/esm/tabs/Tabs.js +2 -2
- package/esm/tabs/Tabs.js.map +1 -1
- package/esm/tabs/context.d.ts +8 -0
- package/esm/tabs/context.js +3 -0
- package/esm/tabs/context.js.map +1 -0
- package/esm/tabs/index.d.ts +1 -1
- package/esm/tabs/index.js.map +1 -1
- package/esm/tag/Tag.js +1 -1
- package/esm/tag/Tag.js.map +1 -1
- package/esm/timeline/period/ClickablePeriod.d.ts +1 -1
- package/esm/timeline/period/NonClickablePeriod.d.ts +1 -1
- package/esm/timeline/period/NonClickablePeriod.js +1 -1
- package/esm/timeline/period/NonClickablePeriod.js.map +1 -1
- package/esm/timeline/period/index.d.ts +0 -13
- package/esm/timeline/period/index.js.map +1 -1
- package/esm/timeline/period/types.d.ts +14 -0
- package/esm/timeline/period/types.js +2 -0
- package/esm/timeline/period/types.js.map +1 -0
- package/esm/toggle-group/ToggleGroup.d.ts +0 -4
- package/esm/toggle-group/ToggleGroup.js +4 -3
- package/esm/toggle-group/ToggleGroup.js.map +1 -1
- package/esm/toggle-group/ToggleItem.js +3 -3
- package/esm/toggle-group/ToggleItem.js.map +1 -1
- package/esm/toggle-group/context.d.ts +6 -0
- package/esm/toggle-group/context.js +3 -0
- package/esm/toggle-group/context.js.map +1 -0
- package/esm/tooltip/Tooltip.js +2 -1
- package/esm/tooltip/Tooltip.js.map +1 -1
- package/esm/util/TextareaAutoSize.js +1 -1
- package/esm/util/TextareaAutoSize.js.map +1 -1
- package/esm/util/index.d.ts +5 -11
- package/esm/util/index.js +5 -33
- package/esm/util/index.js.map +1 -1
- package/esm/util/omit.d.ts +1 -0
- package/esm/util/omit.js +4 -0
- package/esm/util/omit.js.map +1 -0
- package/esm/util/useClientLayoutEffect.d.ts +2 -0
- package/esm/util/useClientLayoutEffect.js +8 -0
- package/esm/util/useClientLayoutEffect.js.map +1 -0
- package/esm/util/useEventListener.d.ts +5 -0
- package/esm/util/useEventListener.js +14 -0
- package/esm/util/useEventListener.js.map +1 -0
- package/package.json +3 -3
- package/src/accordion/AccordionContent.tsx +1 -1
- package/src/accordion/AccordionHeader.tsx +1 -1
- package/src/alert/Alert.tsx +1 -1
- package/src/button/Button.tsx +9 -3
- package/src/chips/Chips.tsx +1 -1
- package/src/chips/Toggle.tsx +1 -1
- package/src/copybutton/CopyButton.tsx +28 -29
- package/src/copybutton/copy-button.stories.tsx +24 -22
- package/src/date/DateInput.tsx +2 -1
- package/src/date/datepicker/DatePicker.tsx +9 -124
- package/src/date/datepicker/DatePickerStandalone.tsx +9 -9
- package/src/date/datepicker/parts/Caption.tsx +3 -1
- package/src/date/datepicker/parts/DropdownCaption.tsx +3 -2
- package/src/date/datepicker/parts/WeekRow.tsx +1 -1
- package/src/date/datepicker/types.ts +109 -0
- package/src/date/hooks/useMonthPicker.tsx +1 -1
- package/src/date/index.ts +5 -7
- package/src/date/monthpicker/MonthCaption.tsx +2 -1
- package/src/date/monthpicker/MonthPicker.tsx +9 -92
- package/src/date/monthpicker/MonthPickerStandalone.tsx +1 -1
- package/src/date/monthpicker/MonthSelector.tsx +1 -1
- package/src/date/monthpicker/types.ts +83 -0
- package/src/date/utils/parse-date.ts +1 -1
- package/src/dropdown/Dropdown.tsx +3 -12
- package/src/dropdown/Menu/GroupedList/GroupedItem.tsx +2 -2
- package/src/dropdown/Menu/GroupedList/index.tsx +1 -1
- package/src/dropdown/Menu/List/Item.tsx +3 -3
- package/src/dropdown/Menu/List/index.tsx +1 -1
- package/src/dropdown/Menu/index.tsx +1 -1
- package/src/dropdown/Toggle.tsx +2 -2
- package/src/dropdown/context.ts +11 -0
- package/src/expansion-card/ExpansionCard.tsx +3 -14
- package/src/expansion-card/ExpansionCardContent.tsx +2 -2
- package/src/expansion-card/ExpansionCardDescription.tsx +3 -3
- package/src/expansion-card/ExpansionCardHeader.tsx +2 -2
- package/src/expansion-card/ExpansionCardTitle.tsx +2 -2
- package/src/expansion-card/context.ts +13 -0
- package/src/form/ConfirmationPanel.tsx +4 -2
- package/src/form/Fieldset/Fieldset.tsx +4 -29
- package/src/form/Fieldset/context.ts +26 -0
- package/src/form/Fieldset/index.ts +2 -5
- package/src/form/Select.tsx +4 -4
- package/src/form/Switch.tsx +3 -1
- package/src/form/TextField.tsx +2 -1
- package/src/form/Textarea.tsx +2 -1
- package/src/form/checkbox/Checkbox.tsx +3 -38
- package/src/form/checkbox/CheckboxGroup.tsx +2 -2
- package/src/form/checkbox/index.ts +2 -1
- package/src/form/checkbox/types.ts +37 -0
- package/src/form/checkbox/useCheckbox.ts +2 -1
- package/src/form/combobox/Combobox.tsx +2 -1
- package/src/form/combobox/FilteredOptions/FilteredOptions.tsx +2 -1
- package/src/form/combobox/Input/Input.tsx +1 -1
- package/src/form/combobox/SelectedOptions/SelectedOptions.tsx +1 -1
- package/src/form/error-summary/ErrorSummary.tsx +1 -1
- package/src/form/error-summary/ErrorSummaryItem.tsx +1 -1
- package/src/form/radio/Radio.tsx +2 -19
- package/src/form/radio/RadioGroup.tsx +3 -3
- package/src/form/radio/index.ts +2 -1
- package/src/form/radio/types.ts +19 -0
- package/src/form/radio/useRadio.ts +2 -2
- package/src/form/search/Search.tsx +5 -14
- package/src/form/search/SearchButton.tsx +3 -3
- package/src/form/search/context.ts +10 -0
- package/src/form/useFormField.ts +3 -3
- package/src/guide-panel/Illustration.tsx +1 -1
- package/src/help-text/HelpText.tsx +2 -1
- package/src/link-panel/LinkPanel.tsx +2 -1
- package/src/link-panel/LinkPanelDescription.tsx +1 -1
- package/src/list/List.tsx +8 -45
- package/src/list/ListItem.tsx +1 -1
- package/src/list/context.ts +14 -0
- package/src/list/index.ts +1 -1
- package/src/list/types.ts +26 -0
- package/src/loader/Loader.tsx +2 -2
- package/src/modal/Modal.tsx +9 -71
- package/src/modal/ModalUtils.ts +1 -1
- package/src/modal/index.ts +3 -2
- package/src/modal/types.ts +64 -0
- package/src/pagination/Pagination.tsx +1 -1
- package/src/pagination/PaginationItem.tsx +2 -1
- package/src/popover/Popover.tsx +10 -5
- package/src/stepper/Step.tsx +3 -2
- package/src/stepper/Stepper.tsx +3 -13
- package/src/stepper/context.ts +11 -0
- package/src/table/ColumnHeader.tsx +3 -3
- package/src/table/DataCell.tsx +1 -1
- package/src/table/ExpandableRow.tsx +1 -1
- package/src/table/Table.tsx +17 -27
- package/src/table/context.ts +9 -0
- package/src/table/index.ts +2 -1
- package/src/table/types.ts +4 -0
- package/src/tabs/Tab.tsx +3 -2
- package/src/tabs/TabList.tsx +2 -2
- package/src/tabs/Tabs.tsx +2 -9
- package/src/tabs/context.ts +9 -0
- package/src/tabs/index.ts +1 -1
- package/src/tag/Tag.tsx +1 -1
- package/src/timeline/period/ClickablePeriod.tsx +1 -1
- package/src/timeline/period/NonClickablePeriod.tsx +2 -2
- package/src/timeline/period/index.tsx +0 -14
- package/src/timeline/period/types.ts +13 -0
- package/src/timeline/utils/filter.ts +1 -1
- package/src/toggle-group/ToggleGroup.tsx +4 -15
- package/src/toggle-group/ToggleItem.tsx +3 -3
- package/src/toggle-group/context.ts +9 -0
- package/src/tooltip/Tooltip.tsx +2 -1
- package/src/util/TextareaAutoSize.tsx +1 -1
- package/src/util/index.ts +5 -70
- package/src/util/omit.ts +10 -0
- package/src/util/useClientLayoutEffect.ts +11 -0
- package/src/util/useEventListener.ts +32 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { forwardRef, useContext } from "react";
|
|
3
|
-
import { Heading } from "../typography
|
|
3
|
+
import { Heading } from "../typography";
|
|
4
4
|
import { AccordionContext } from "./AccordionContext";
|
|
5
5
|
import { AccordionItemContext } from "./AccordionItem";
|
|
6
6
|
import { ChevronDownIcon } from "@navikt/aksel-icons";
|
package/src/alert/Alert.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "@navikt/aksel-icons";
|
|
8
8
|
import cl from "clsx";
|
|
9
9
|
import React, { forwardRef } from "react";
|
|
10
|
-
import { BodyLong } from "../typography
|
|
10
|
+
import { BodyLong } from "../typography";
|
|
11
11
|
import { Button } from "../button";
|
|
12
12
|
|
|
13
13
|
export interface AlertProps extends React.HTMLAttributes<HTMLDivElement> {
|
package/src/button/Button.tsx
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import React, { useRef, useState, forwardRef, useMemo } from "react";
|
|
2
1
|
import cl from "clsx";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import React, { forwardRef, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { Loader } from "../loader";
|
|
4
|
+
import { Label } from "../typography";
|
|
5
|
+
import {
|
|
6
|
+
mergeRefs,
|
|
7
|
+
OverridableComponent,
|
|
8
|
+
omit,
|
|
9
|
+
useClientLayoutEffect,
|
|
10
|
+
} from "../util";
|
|
5
11
|
|
|
6
12
|
export interface ButtonProps
|
|
7
13
|
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
package/src/chips/Chips.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import cl from "clsx";
|
|
|
2
2
|
import React, { forwardRef, HTMLAttributes } from "react";
|
|
3
3
|
import ToggleChips, { ToggleChipsProps } from "./Toggle";
|
|
4
4
|
import RemovableChips, { RemovableChipsProps } from "./Removable";
|
|
5
|
-
import { OverridableComponent } from "../util
|
|
5
|
+
import { OverridableComponent } from "../util";
|
|
6
6
|
|
|
7
7
|
export interface ChipsProps extends HTMLAttributes<HTMLUListElement> {
|
|
8
8
|
children: React.ReactNode;
|
package/src/chips/Toggle.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { forwardRef } from "react";
|
|
3
|
-
import { OverridableComponent } from "../util
|
|
3
|
+
import { OverridableComponent } from "../util";
|
|
4
4
|
|
|
5
5
|
export interface ToggleChipsProps
|
|
6
6
|
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
@@ -8,13 +8,13 @@ import React, {
|
|
|
8
8
|
useState,
|
|
9
9
|
} from "react";
|
|
10
10
|
import copy from "../util/copy";
|
|
11
|
-
import Label from "../typography
|
|
11
|
+
import { Label } from "../typography";
|
|
12
12
|
|
|
13
13
|
export interface CopyButtonProps
|
|
14
14
|
extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children"> {
|
|
15
15
|
/**
|
|
16
|
+
* 'xsmall' should only be used in tables
|
|
16
17
|
* @default "medium"
|
|
17
|
-
* xsmall should only be used in tables/
|
|
18
18
|
*/
|
|
19
19
|
size?: "medium" | "small" | "xsmall";
|
|
20
20
|
/**
|
|
@@ -30,12 +30,12 @@ export interface CopyButtonProps
|
|
|
30
30
|
*/
|
|
31
31
|
text?: string;
|
|
32
32
|
/**
|
|
33
|
-
* Text shown when button is clicked
|
|
34
|
-
* Only set if used with
|
|
33
|
+
* Text shown when button is clicked.
|
|
34
|
+
* Only set if used with `text`-prop.
|
|
35
35
|
*/
|
|
36
36
|
activeText?: string;
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
38
|
+
* Callback when 'copied'-state is active
|
|
39
39
|
*/
|
|
40
40
|
onActiveChange?: (state: boolean) => void;
|
|
41
41
|
/**
|
|
@@ -54,17 +54,17 @@ export interface CopyButtonProps
|
|
|
54
54
|
*/
|
|
55
55
|
activeDuration?: number;
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* Accessible label for icon (ignored if text is set)
|
|
58
58
|
* @default 'Kopier'
|
|
59
59
|
*/
|
|
60
60
|
title?: string;
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
62
|
+
* Accessible label for icon in active-state (ignored if text is set)
|
|
63
63
|
* @default 'Kopiert'
|
|
64
64
|
*/
|
|
65
65
|
activeTitle?: string;
|
|
66
66
|
/**
|
|
67
|
-
* Icon position in
|
|
67
|
+
* Icon position in button
|
|
68
68
|
* @default "left"
|
|
69
69
|
*/
|
|
70
70
|
iconPosition?: "left" | "right";
|
|
@@ -125,24 +125,23 @@ export const CopyButton = forwardRef<HTMLButtonElement, CopyButtonProps>(
|
|
|
125
125
|
}, activeDuration);
|
|
126
126
|
};
|
|
127
127
|
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
};
|
|
128
|
+
const copyIcon = (
|
|
129
|
+
<span className="navds-copybutton__icon">
|
|
130
|
+
{active
|
|
131
|
+
? activeIcon ?? (
|
|
132
|
+
<CheckmarkIcon
|
|
133
|
+
aria-hidden={!!text}
|
|
134
|
+
title={text ? undefined : activeTitle}
|
|
135
|
+
/>
|
|
136
|
+
)
|
|
137
|
+
: icon ?? (
|
|
138
|
+
<FilesIcon
|
|
139
|
+
aria-hidden={!!text}
|
|
140
|
+
title={text ? undefined : title}
|
|
141
|
+
/>
|
|
142
|
+
)}
|
|
143
|
+
</span>
|
|
144
|
+
);
|
|
146
145
|
|
|
147
146
|
return (
|
|
148
147
|
<button
|
|
@@ -157,14 +156,14 @@ export const CopyButton = forwardRef<HTMLButtonElement, CopyButtonProps>(
|
|
|
157
156
|
`navds-copybutton--${variant}`,
|
|
158
157
|
{
|
|
159
158
|
"navds-copybutton--icon-only": !text,
|
|
159
|
+
"navds-copybutton--icon-right": iconPosition === "right",
|
|
160
160
|
"navds-copybutton--active": active,
|
|
161
161
|
}
|
|
162
162
|
)}
|
|
163
163
|
onClick={handleClick}
|
|
164
164
|
>
|
|
165
165
|
<span className="navds-copybutton__content">
|
|
166
|
-
{iconPosition === "left" &&
|
|
167
|
-
|
|
166
|
+
{iconPosition === "left" && copyIcon}
|
|
168
167
|
{text &&
|
|
169
168
|
(active ? (
|
|
170
169
|
<Label
|
|
@@ -183,7 +182,7 @@ export const CopyButton = forwardRef<HTMLButtonElement, CopyButtonProps>(
|
|
|
183
182
|
{text}
|
|
184
183
|
</Label>
|
|
185
184
|
))}
|
|
186
|
-
{iconPosition === "right" &&
|
|
185
|
+
{iconPosition === "right" && copyIcon}
|
|
187
186
|
</span>
|
|
188
187
|
</button>
|
|
189
188
|
);
|
|
@@ -1,38 +1,40 @@
|
|
|
1
|
-
import { LinkIcon, ThumbUpIcon } from "@navikt/aksel-icons";
|
|
2
|
-
import { userEvent, within } from "@storybook/testing-library";
|
|
3
1
|
import React from "react";
|
|
4
|
-
import {
|
|
2
|
+
import { userEvent, within } from "@storybook/testing-library";
|
|
3
|
+
import { Meta, StoryObj } from "@storybook/react";
|
|
4
|
+
import { LinkIcon, ThumbUpIcon } from "@navikt/aksel-icons";
|
|
5
5
|
import { Tooltip } from "../tooltip";
|
|
6
|
+
import { CopyButton } from ".";
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
const meta: Meta<typeof CopyButton> = {
|
|
8
9
|
title: "ds-react/CopyButton",
|
|
9
10
|
component: CopyButton,
|
|
11
|
+
};
|
|
12
|
+
export default meta;
|
|
13
|
+
|
|
14
|
+
type Story = StoryObj<typeof CopyButton>;
|
|
15
|
+
|
|
16
|
+
export const Default: Story = {
|
|
17
|
+
render: (props) => <CopyButton {...props} />,
|
|
10
18
|
argTypes: {
|
|
11
19
|
size: {
|
|
12
|
-
defaultValue: "medium",
|
|
13
20
|
control: { type: "radio" },
|
|
14
|
-
options: ["
|
|
21
|
+
options: ["medium", "small", "xsmall"],
|
|
15
22
|
},
|
|
16
23
|
variant: {
|
|
17
|
-
defaultValue: undefined,
|
|
18
24
|
control: { type: "radio" },
|
|
19
25
|
options: ["neutral", "action"],
|
|
20
26
|
},
|
|
21
27
|
},
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const Default = {
|
|
25
|
-
render: (args) => <CopyButton {...args} />,
|
|
26
28
|
args: {
|
|
27
29
|
size: "medium",
|
|
28
|
-
|
|
30
|
+
activeDuration: 2000,
|
|
29
31
|
copyText: "3.14",
|
|
30
32
|
text: "",
|
|
31
33
|
activeText: "",
|
|
32
34
|
},
|
|
33
35
|
};
|
|
34
36
|
|
|
35
|
-
export const Interaction = {
|
|
37
|
+
export const Interaction: Story = {
|
|
36
38
|
render: () => (
|
|
37
39
|
<CopyButton
|
|
38
40
|
copyText="3.14"
|
|
@@ -50,7 +52,7 @@ export const Interaction = {
|
|
|
50
52
|
},
|
|
51
53
|
};
|
|
52
54
|
|
|
53
|
-
export const Variants = {
|
|
55
|
+
export const Variants: Story = {
|
|
54
56
|
render: () => (
|
|
55
57
|
<div className="colgap">
|
|
56
58
|
<CopyButton copyText="3.14" variant="action" text="Kopier" />
|
|
@@ -60,7 +62,7 @@ export const Variants = {
|
|
|
60
62
|
),
|
|
61
63
|
};
|
|
62
64
|
|
|
63
|
-
export const IconPosition = {
|
|
65
|
+
export const IconPosition: Story = {
|
|
64
66
|
render: () => (
|
|
65
67
|
<div className="colgap">
|
|
66
68
|
<CopyButton copyText="3.14" iconPosition="left" text="Kopier" />
|
|
@@ -70,7 +72,7 @@ export const IconPosition = {
|
|
|
70
72
|
),
|
|
71
73
|
};
|
|
72
74
|
|
|
73
|
-
export const Sizes = {
|
|
75
|
+
export const Sizes: Story = {
|
|
74
76
|
render: () => (
|
|
75
77
|
<div className="colgap">
|
|
76
78
|
<div className="rowgap">
|
|
@@ -115,7 +117,7 @@ export const Sizes = {
|
|
|
115
117
|
),
|
|
116
118
|
};
|
|
117
119
|
|
|
118
|
-
export const Texts = {
|
|
120
|
+
export const Texts: Story = {
|
|
119
121
|
render: () => (
|
|
120
122
|
<div className="colgap">
|
|
121
123
|
<div>
|
|
@@ -145,7 +147,7 @@ export const Texts = {
|
|
|
145
147
|
),
|
|
146
148
|
};
|
|
147
149
|
|
|
148
|
-
export const Icons = {
|
|
150
|
+
export const Icons: Story = {
|
|
149
151
|
render: () => (
|
|
150
152
|
<div className="rowgap">
|
|
151
153
|
<div>
|
|
@@ -175,7 +177,7 @@ export const Icons = {
|
|
|
175
177
|
),
|
|
176
178
|
};
|
|
177
179
|
|
|
178
|
-
export const InlineDemo = {
|
|
180
|
+
export const InlineDemo: Story = {
|
|
179
181
|
render: () => (
|
|
180
182
|
<div style={{ display: "flex", gap: "0.5rem", alignItems: "center" }}>
|
|
181
183
|
<CopyButton size="small" copyText="3.14" /> Kopier dette feltet
|
|
@@ -183,7 +185,7 @@ export const InlineDemo = {
|
|
|
183
185
|
),
|
|
184
186
|
};
|
|
185
187
|
|
|
186
|
-
export const WithTooltip = {
|
|
188
|
+
export const WithTooltip: Story = {
|
|
187
189
|
render: () => {
|
|
188
190
|
return (
|
|
189
191
|
<div>
|
|
@@ -195,11 +197,11 @@ export const WithTooltip = {
|
|
|
195
197
|
},
|
|
196
198
|
};
|
|
197
199
|
|
|
198
|
-
export const Duration = {
|
|
200
|
+
export const Duration: Story = {
|
|
199
201
|
render: () => <CopyButton copyText="3.14" activeDuration={300} />,
|
|
200
202
|
};
|
|
201
203
|
|
|
202
|
-
export const Disabled = {
|
|
204
|
+
export const Disabled: Story = {
|
|
203
205
|
render: () => (
|
|
204
206
|
<div className="colgap">
|
|
205
207
|
<CopyButton copyText="3.14" disabled />
|
package/src/date/DateInput.tsx
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { CalendarIcon } from "@navikt/aksel-icons";
|
|
2
2
|
import cl from "clsx";
|
|
3
3
|
import React, { forwardRef, InputHTMLAttributes } from "react";
|
|
4
|
-
import { BodyShort, ErrorMessage, Label, omit } from "..";
|
|
5
4
|
import { FormFieldProps, useFormField } from "../form/useFormField";
|
|
6
5
|
import { useDateInputContext } from "./context";
|
|
7
6
|
import { ReadOnlyIcon } from "../form/ReadOnlyIcon";
|
|
7
|
+
import { BodyShort, ErrorMessage, Label } from "../typography";
|
|
8
|
+
import { omit } from "../util";
|
|
8
9
|
|
|
9
10
|
export interface DateInputProps
|
|
10
11
|
extends FormFieldProps,
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import isWeekend from "date-fns/isWeekend";
|
|
3
3
|
import React, { forwardRef, useRef, useState } from "react";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Matcher,
|
|
9
|
-
isMatch,
|
|
10
|
-
} from "react-day-picker";
|
|
11
|
-
import { Popover, omit, useId } from "../..";
|
|
12
|
-
import { DateInputProps, DatePickerInput } from "../DateInput";
|
|
4
|
+
import { DateRange, DayPicker, isMatch } from "react-day-picker";
|
|
5
|
+
import { Popover } from "../../popover";
|
|
6
|
+
import { omit, useId } from "../../util";
|
|
7
|
+
import { DatePickerInput } from "../DateInput";
|
|
13
8
|
import { DateContext } from "../context";
|
|
14
9
|
import { getLocaleFromString, labels } from "../utils";
|
|
15
|
-
import DatePickerStandalone
|
|
16
|
-
DatePickerStandaloneType,
|
|
17
|
-
} from "./DatePickerStandalone";
|
|
10
|
+
import DatePickerStandalone from "./DatePickerStandalone";
|
|
18
11
|
import Caption from "./parts/Caption";
|
|
19
12
|
import DayButton from "./parts/DayButton";
|
|
20
13
|
import DropdownCaption from "./parts/DropdownCaption";
|
|
@@ -22,114 +15,7 @@ import { HeadRow } from "./parts/HeadRow";
|
|
|
22
15
|
import Row from "./parts/Row";
|
|
23
16
|
import TableHead from "./parts/TableHead";
|
|
24
17
|
import WeekNumber from "./parts/WeekNumber";
|
|
25
|
-
|
|
26
|
-
export type SingleMode = {
|
|
27
|
-
mode?: "single";
|
|
28
|
-
onSelect?: (val?: Date) => void;
|
|
29
|
-
selected?: Date;
|
|
30
|
-
defaultSelected?: Date;
|
|
31
|
-
onWeekNumberClick?: never;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export type MultipleMode = {
|
|
35
|
-
mode: "multiple";
|
|
36
|
-
onSelect?: (val?: Date[]) => void;
|
|
37
|
-
selected?: Date[];
|
|
38
|
-
defaultSelected?: Date[];
|
|
39
|
-
min?: number;
|
|
40
|
-
max?: number;
|
|
41
|
-
/**
|
|
42
|
-
* Allows selecting a week at a time. Only used with mode="multiple".
|
|
43
|
-
*/
|
|
44
|
-
onWeekNumberClick?: DayPickerBase["onWeekNumberClick"];
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export type RangeMode = {
|
|
48
|
-
mode: "range";
|
|
49
|
-
onSelect?: (val?: DateRange) => void;
|
|
50
|
-
selected?: DateRange;
|
|
51
|
-
defaultSelected?: DateRange;
|
|
52
|
-
min?: number;
|
|
53
|
-
max?: number;
|
|
54
|
-
onWeekNumberClick?: never;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
type ConditionalModeProps = SingleMode | MultipleMode | RangeMode;
|
|
58
|
-
|
|
59
|
-
//github.com/gpbl/react-day-picker/blob/50b6dba/packages/react-day-picker/src/types/DayPickerBase.ts#L139
|
|
60
|
-
export interface DatePickerDefaultProps
|
|
61
|
-
extends Omit<React.HTMLAttributes<HTMLDivElement>, "onSelect">,
|
|
62
|
-
Pick<DayPickerBase, "month" | "onMonthChange" | "today" | "onDayClick"> {
|
|
63
|
-
/**
|
|
64
|
-
* Element datepicker anchors to. Use <DatePicker.Input /> for built-in toggle, or make your own with the open/onClose props
|
|
65
|
-
*/
|
|
66
|
-
children?: React.ReactNode;
|
|
67
|
-
/**
|
|
68
|
-
* Classname for datepicker in popover
|
|
69
|
-
*/
|
|
70
|
-
className?: string;
|
|
71
|
-
/**
|
|
72
|
-
* Classname for wrapper
|
|
73
|
-
*/
|
|
74
|
-
wrapperClassName?: string;
|
|
75
|
-
/**
|
|
76
|
-
* Changes datepicker locale
|
|
77
|
-
* @default "nb" (norsk bokmål)
|
|
78
|
-
*/
|
|
79
|
-
locale?: "nb" | "nn" | "en";
|
|
80
|
-
/**
|
|
81
|
-
* The earliest day to start navigation.
|
|
82
|
-
*/
|
|
83
|
-
fromDate?: Date;
|
|
84
|
-
/**
|
|
85
|
-
* The latests day to end navigation.
|
|
86
|
-
*/
|
|
87
|
-
toDate?: Date;
|
|
88
|
-
/**
|
|
89
|
-
* Display dropdown for choosing the month and the year. Needs `fromDate` + `toDate` to work.
|
|
90
|
-
* @default false
|
|
91
|
-
*/
|
|
92
|
-
dropdownCaption?: boolean;
|
|
93
|
-
/**
|
|
94
|
-
* Apply the disabled modifier to the matching days.
|
|
95
|
-
* https://react-day-picker.js.org/api/types/Matcher
|
|
96
|
-
*/
|
|
97
|
-
disabled?: Matcher[];
|
|
98
|
-
/**
|
|
99
|
-
* Disable saturday and sunday.
|
|
100
|
-
* @default false
|
|
101
|
-
*/
|
|
102
|
-
disableWeekends?: boolean;
|
|
103
|
-
/**
|
|
104
|
-
* Shows week numbers in left-column. Use with caution, takes up valuable screenspace for small screens.
|
|
105
|
-
* @default false
|
|
106
|
-
*/
|
|
107
|
-
showWeekNumber?: boolean;
|
|
108
|
-
/**
|
|
109
|
-
* Open state for user-controlled state. Component controlled by default
|
|
110
|
-
*/
|
|
111
|
-
open?: boolean;
|
|
112
|
-
/**
|
|
113
|
-
* onClose callback for user-controlled state
|
|
114
|
-
*/
|
|
115
|
-
onClose?: () => void;
|
|
116
|
-
/**
|
|
117
|
-
* onOpenToggle callback for user-controlled state. Only called if `<DatePicker.Input />` is used
|
|
118
|
-
*/
|
|
119
|
-
onOpenToggle?: () => void;
|
|
120
|
-
/**
|
|
121
|
-
* Avoid using if possible!
|
|
122
|
-
* Changes what CSS position property to use.
|
|
123
|
-
* You want to use "fixed" if parent wrapper has position relative, but you want popover to escape
|
|
124
|
-
* @default See Popover
|
|
125
|
-
*/
|
|
126
|
-
strategy?: "absolute" | "fixed";
|
|
127
|
-
/**
|
|
128
|
-
* Bubbles Escape keydown-event up trough DOM-tree. This is set to false by default to prevent closing components like Modal on Escape
|
|
129
|
-
* @default false
|
|
130
|
-
*/
|
|
131
|
-
bubbleEscape?: boolean;
|
|
132
|
-
}
|
|
18
|
+
import { ConditionalModeProps, DatePickerDefaultProps } from "./types";
|
|
133
19
|
|
|
134
20
|
export type DatePickerProps = DatePickerDefaultProps & ConditionalModeProps;
|
|
135
21
|
|
|
@@ -145,14 +31,12 @@ interface DatePickerComponent
|
|
|
145
31
|
* />
|
|
146
32
|
* ```
|
|
147
33
|
*/
|
|
148
|
-
Standalone:
|
|
34
|
+
Standalone: typeof DatePickerStandalone;
|
|
149
35
|
/**
|
|
150
36
|
* Custom TextField for DatePicker
|
|
151
37
|
* @see 🏷️ {@link DateInputProps}
|
|
152
38
|
*/
|
|
153
|
-
Input:
|
|
154
|
-
DateInputProps & React.RefAttributes<HTMLInputElement>
|
|
155
|
-
>;
|
|
39
|
+
Input: typeof DatePickerInput;
|
|
156
40
|
}
|
|
157
41
|
|
|
158
42
|
/**
|
|
@@ -257,6 +141,7 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
|
|
|
257
141
|
strategy={strategy}
|
|
258
142
|
className="navds-date__popover"
|
|
259
143
|
bubbleEscape={bubbleEscape}
|
|
144
|
+
flip={false}
|
|
260
145
|
>
|
|
261
146
|
<DayPicker
|
|
262
147
|
locale={getLocaleFromString(locale)}
|
|
@@ -2,21 +2,21 @@ import cl from "clsx";
|
|
|
2
2
|
import isWeekend from "date-fns/isWeekend";
|
|
3
3
|
import React, { forwardRef } from "react";
|
|
4
4
|
import { DateRange, DayPicker, isMatch } from "react-day-picker";
|
|
5
|
-
import { omit } from "
|
|
5
|
+
import { omit } from "../../util";
|
|
6
6
|
import { getLocaleFromString, labels } from "../utils";
|
|
7
|
+
import Caption from "./parts/Caption";
|
|
8
|
+
import DayButton from "./parts/DayButton";
|
|
9
|
+
import DropdownCaption from "./parts/DropdownCaption";
|
|
10
|
+
import { HeadRow } from "./parts/HeadRow";
|
|
11
|
+
import Row from "./parts/Row";
|
|
12
|
+
import TableHead from "./parts/TableHead";
|
|
13
|
+
import WeekNumber from "./parts/WeekNumber";
|
|
7
14
|
import {
|
|
8
15
|
DatePickerDefaultProps,
|
|
9
16
|
MultipleMode,
|
|
10
17
|
RangeMode,
|
|
11
18
|
SingleMode,
|
|
12
|
-
} from "./
|
|
13
|
-
import TableHead from "./parts/TableHead";
|
|
14
|
-
import WeekNumber from "./parts/WeekNumber";
|
|
15
|
-
import Caption from "./parts/Caption";
|
|
16
|
-
import DropdownCaption from "./parts/DropdownCaption";
|
|
17
|
-
import Row from "./parts/Row";
|
|
18
|
-
import { HeadRow } from "./parts/HeadRow";
|
|
19
|
-
import DayButton from "./parts/DayButton";
|
|
19
|
+
} from "./types";
|
|
20
20
|
|
|
21
21
|
interface DatePickerStandaloneDefaultProps
|
|
22
22
|
extends Omit<
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ArrowLeftIcon, ArrowRightIcon } from "@navikt/aksel-icons";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { CaptionProps, useDayPicker, useNavigation } from "react-day-picker";
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
import WeekRow from "./WeekRow";
|
|
6
|
+
import { Button } from "../../../button";
|
|
7
|
+
import { Label } from "../../../typography";
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* https://github.com/gpbl/react-day-picker/tree/main/src/components/Caption
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { ArrowLeftIcon, ArrowRightIcon } from "@navikt/aksel-icons";
|
|
2
|
+
import { max, min } from "date-fns";
|
|
2
3
|
import setMonth from "date-fns/setMonth";
|
|
3
4
|
import setYear from "date-fns/setYear";
|
|
4
5
|
import startOfMonth from "date-fns/startOfMonth";
|
|
5
6
|
import React from "react";
|
|
6
7
|
import { CaptionProps, useDayPicker, useNavigation } from "react-day-picker";
|
|
7
|
-
import { Button
|
|
8
|
+
import { Button } from "../../../button";
|
|
9
|
+
import { Select } from "../../../form/Select";
|
|
8
10
|
import { getMonths, getYears } from "../../utils/get-dates";
|
|
9
11
|
import { labelMonthDropdown, labelYearDropdown } from "../../utils/labels";
|
|
10
|
-
import { max, min } from "date-fns";
|
|
11
12
|
import WeekRow from "./WeekRow";
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -2,10 +2,10 @@ 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
6
|
import { getMonthWeeks } from "../../utils/get-month-weeks";
|
|
6
7
|
import { labelWeek } from "../../utils/labels";
|
|
7
8
|
import WeekNumber from "./WeekNumber";
|
|
8
|
-
import { useId } from "../../../util";
|
|
9
9
|
|
|
10
10
|
const WeekRow = ({ displayMonth }: { displayMonth: Date }) => {
|
|
11
11
|
const { locale, fixedWeeks, onWeekNumberClick } = useDayPicker();
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { DateRange, DayPickerBase, Matcher } from "react-day-picker";
|
|
2
|
+
|
|
3
|
+
export type SingleMode = {
|
|
4
|
+
mode?: "single";
|
|
5
|
+
onSelect?: (val?: Date) => void;
|
|
6
|
+
selected?: Date;
|
|
7
|
+
defaultSelected?: Date;
|
|
8
|
+
onWeekNumberClick?: never;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type MultipleMode = {
|
|
12
|
+
mode: "multiple";
|
|
13
|
+
onSelect?: (val?: Date[]) => void;
|
|
14
|
+
selected?: Date[];
|
|
15
|
+
defaultSelected?: Date[];
|
|
16
|
+
min?: number;
|
|
17
|
+
max?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Allows selecting a week at a time. Only used with mode="multiple".
|
|
20
|
+
*/
|
|
21
|
+
onWeekNumberClick?: DayPickerBase["onWeekNumberClick"];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type RangeMode = {
|
|
25
|
+
mode: "range";
|
|
26
|
+
onSelect?: (val?: DateRange) => void;
|
|
27
|
+
selected?: DateRange;
|
|
28
|
+
defaultSelected?: DateRange;
|
|
29
|
+
min?: number;
|
|
30
|
+
max?: number;
|
|
31
|
+
onWeekNumberClick?: never;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type ConditionalModeProps = SingleMode | MultipleMode | RangeMode;
|
|
35
|
+
|
|
36
|
+
//github.com/gpbl/react-day-picker/blob/50b6dba/packages/react-day-picker/src/types/DayPickerBase.ts#L139
|
|
37
|
+
export interface DatePickerDefaultProps
|
|
38
|
+
extends Omit<React.HTMLAttributes<HTMLDivElement>, "onSelect">,
|
|
39
|
+
Pick<DayPickerBase, "month" | "onMonthChange" | "today" | "onDayClick"> {
|
|
40
|
+
/**
|
|
41
|
+
* Element datepicker anchors to. Use <DatePicker.Input /> for built-in toggle, or make your own with the open/onClose props
|
|
42
|
+
*/
|
|
43
|
+
children?: React.ReactNode;
|
|
44
|
+
/**
|
|
45
|
+
* Classname for datepicker in popover
|
|
46
|
+
*/
|
|
47
|
+
className?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Classname for wrapper
|
|
50
|
+
*/
|
|
51
|
+
wrapperClassName?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Changes datepicker locale
|
|
54
|
+
* @default "nb" (norsk bokmål)
|
|
55
|
+
*/
|
|
56
|
+
locale?: "nb" | "nn" | "en";
|
|
57
|
+
/**
|
|
58
|
+
* The earliest day to start navigation.
|
|
59
|
+
*/
|
|
60
|
+
fromDate?: Date;
|
|
61
|
+
/**
|
|
62
|
+
* The latests day to end navigation.
|
|
63
|
+
*/
|
|
64
|
+
toDate?: Date;
|
|
65
|
+
/**
|
|
66
|
+
* Display dropdown for choosing the month and the year. Needs `fromDate` + `toDate` to work.
|
|
67
|
+
* @default false
|
|
68
|
+
*/
|
|
69
|
+
dropdownCaption?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Apply the disabled modifier to the matching days.
|
|
72
|
+
* https://react-day-picker.js.org/api/types/Matcher
|
|
73
|
+
*/
|
|
74
|
+
disabled?: Matcher[];
|
|
75
|
+
/**
|
|
76
|
+
* Disable saturday and sunday.
|
|
77
|
+
* @default false
|
|
78
|
+
*/
|
|
79
|
+
disableWeekends?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Shows week numbers in left-column. Use with caution, takes up valuable screenspace for small screens.
|
|
82
|
+
* @default false
|
|
83
|
+
*/
|
|
84
|
+
showWeekNumber?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Open state for user-controlled state. Component controlled by default
|
|
87
|
+
*/
|
|
88
|
+
open?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* onClose callback for user-controlled state
|
|
91
|
+
*/
|
|
92
|
+
onClose?: () => void;
|
|
93
|
+
/**
|
|
94
|
+
* onOpenToggle callback for user-controlled state. Only called if `<DatePicker.Input />` is used
|
|
95
|
+
*/
|
|
96
|
+
onOpenToggle?: () => void;
|
|
97
|
+
/**
|
|
98
|
+
* Avoid using if possible!
|
|
99
|
+
* Changes what CSS position property to use.
|
|
100
|
+
* You want to use "fixed" if parent wrapper has position relative, but you want popover to escape
|
|
101
|
+
* @default See Popover
|
|
102
|
+
*/
|
|
103
|
+
strategy?: "absolute" | "fixed";
|
|
104
|
+
/**
|
|
105
|
+
* Bubbles Escape keydown-event up trough DOM-tree. This is set to false by default to prevent closing components like Modal on Escape
|
|
106
|
+
* @default false
|
|
107
|
+
*/
|
|
108
|
+
bubbleEscape?: boolean;
|
|
109
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useCallback, useMemo, useRef, useState } from "react";
|
|
2
2
|
import { DateInputProps } from "../DateInput";
|
|
3
|
-
import { MonthPickerProps } from "../monthpicker/
|
|
3
|
+
import { MonthPickerProps } from "../monthpicker/types";
|
|
4
4
|
import {
|
|
5
5
|
formatDateForInput,
|
|
6
6
|
getLocaleFromString,
|