@navikt/ds-react 6.1.1 → 6.3.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/cjs/accordion/Accordion.d.ts +4 -4
- package/cjs/alert/Alert.d.ts +12 -10
- package/cjs/alert/Alert.js.map +1 -1
- package/cjs/button/Button.d.ts +9 -8
- package/cjs/button/Button.js.map +1 -1
- package/cjs/chat/Chat.d.ts +6 -6
- package/cjs/chips/Chips.d.ts +2 -2
- package/cjs/copybutton/CopyButton.d.ts +14 -12
- package/cjs/copybutton/CopyButton.js.map +1 -1
- package/cjs/date/datepicker/types.d.ts +7 -6
- package/cjs/date/hooks/useDatepicker.d.ts +4 -3
- package/cjs/date/hooks/useDatepicker.js.map +1 -1
- package/cjs/date/hooks/useMonthPicker.d.ts +4 -3
- package/cjs/date/hooks/useMonthPicker.js.map +1 -1
- package/cjs/date/monthpicker/types.d.ts +2 -1
- package/cjs/date/parts/DateInput.d.ts +1 -1
- package/cjs/expansion-card/ExpansionCardTitle.d.ts +1 -1
- package/cjs/form/checkbox/CheckboxGroup.d.ts +3 -3
- package/cjs/form/checkbox/types.d.ts +4 -4
- package/cjs/form/combobox/ComboboxProvider.js +5 -1
- package/cjs/form/combobox/ComboboxProvider.js.map +1 -1
- package/cjs/form/combobox/FilteredOptions/FilteredOptions.js +14 -12
- package/cjs/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
- package/cjs/form/combobox/FilteredOptions/filtered-options-util.d.ts +3 -3
- package/cjs/form/combobox/FilteredOptions/filtered-options-util.js +1 -3
- package/cjs/form/combobox/FilteredOptions/filtered-options-util.js.map +1 -1
- package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.d.ts +8 -5
- package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js +8 -13
- package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
- package/cjs/form/combobox/Input/Input.js +9 -7
- package/cjs/form/combobox/Input/Input.js.map +1 -1
- package/cjs/form/combobox/SelectedOptions/SelectedOptions.d.ts +2 -1
- package/cjs/form/combobox/SelectedOptions/SelectedOptions.js +3 -3
- package/cjs/form/combobox/SelectedOptions/SelectedOptions.js.map +1 -1
- package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.d.ts +10 -7
- package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.js +6 -8
- package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.js.map +1 -1
- package/cjs/form/combobox/combobox-utils.d.ts +10 -0
- package/cjs/form/combobox/combobox-utils.js +27 -0
- package/cjs/form/combobox/combobox-utils.js.map +1 -0
- package/cjs/form/combobox/customOptionsContext.d.ts +5 -4
- package/cjs/form/combobox/customOptionsContext.js +1 -1
- package/cjs/form/combobox/customOptionsContext.js.map +1 -1
- package/cjs/form/combobox/types.d.ts +33 -22
- package/cjs/form/error-summary/ErrorSummary.d.ts +5 -5
- package/cjs/form/file-upload/FileUpload.context.d.ts +8 -0
- package/cjs/form/file-upload/FileUpload.context.js +7 -0
- package/cjs/form/file-upload/FileUpload.context.js.map +1 -0
- package/cjs/form/file-upload/FileUpload.d.ts +118 -0
- package/cjs/form/file-upload/FileUpload.js +73 -0
- package/cjs/form/file-upload/FileUpload.js.map +1 -0
- package/cjs/form/file-upload/FileUpload.types.d.ts +55 -0
- package/cjs/form/file-upload/FileUpload.types.js +8 -0
- package/cjs/form/file-upload/FileUpload.types.js.map +1 -0
- package/cjs/form/file-upload/i18n/get.d.ts +2 -0
- package/cjs/form/file-upload/i18n/get.js +38 -0
- package/cjs/form/file-upload/i18n/get.js.map +1 -0
- package/cjs/form/file-upload/i18n/i18n.context.d.ts +11 -0
- package/cjs/form/file-upload/i18n/i18n.context.js +39 -0
- package/cjs/form/file-upload/i18n/i18n.context.js.map +1 -0
- package/cjs/form/file-upload/i18n/i18n.types.d.ts +13 -0
- package/cjs/form/file-upload/i18n/i18n.types.js +3 -0
- package/cjs/form/file-upload/i18n/i18n.types.js.map +1 -0
- package/cjs/form/file-upload/i18n/locales/nb.json +20 -0
- package/cjs/form/file-upload/i18n/merge.d.ts +2 -0
- package/cjs/form/file-upload/i18n/merge.js +29 -0
- package/cjs/form/file-upload/i18n/merge.js.map +1 -0
- package/cjs/form/file-upload/index.d.ts +7 -0
- package/cjs/form/file-upload/index.js +16 -0
- package/cjs/form/file-upload/index.js.map +1 -0
- package/cjs/form/file-upload/parts/Trigger.d.ts +7 -0
- package/cjs/form/file-upload/parts/Trigger.js +43 -0
- package/cjs/form/file-upload/parts/Trigger.js.map +1 -0
- package/cjs/form/file-upload/parts/dropzone/Dropzone.d.ts +4 -0
- package/cjs/form/file-upload/parts/dropzone/Dropzone.js +106 -0
- package/cjs/form/file-upload/parts/dropzone/Dropzone.js.map +1 -0
- package/cjs/form/file-upload/parts/dropzone/dropzone.types.d.ts +18 -0
- package/cjs/form/file-upload/parts/dropzone/dropzone.types.js +3 -0
- package/cjs/form/file-upload/parts/dropzone/dropzone.types.js.map +1 -0
- package/cjs/form/file-upload/parts/dropzone/useDropzone.d.ts +13 -0
- package/cjs/form/file-upload/parts/dropzone/useDropzone.js +34 -0
- package/cjs/form/file-upload/parts/dropzone/useDropzone.js.map +1 -0
- package/cjs/form/file-upload/parts/item/Item.d.ts +55 -0
- package/cjs/form/file-upload/parts/item/Item.js +79 -0
- package/cjs/form/file-upload/parts/item/Item.js.map +1 -0
- package/cjs/form/file-upload/parts/item/Item.types.d.ts +5 -0
- package/cjs/form/file-upload/parts/item/Item.types.js +3 -0
- package/cjs/form/file-upload/parts/item/Item.types.js.map +1 -0
- package/cjs/form/file-upload/parts/item/ItemButton.d.ts +12 -0
- package/cjs/form/file-upload/parts/item/ItemButton.js +22 -0
- package/cjs/form/file-upload/parts/item/ItemButton.js.map +1 -0
- package/cjs/form/file-upload/parts/item/ItemIcon.d.ts +9 -0
- package/cjs/form/file-upload/parts/item/ItemIcon.js +51 -0
- package/cjs/form/file-upload/parts/item/ItemIcon.js.map +1 -0
- package/cjs/form/file-upload/parts/item/ItemName.d.ts +9 -0
- package/cjs/form/file-upload/parts/item/ItemName.js +32 -0
- package/cjs/form/file-upload/parts/item/ItemName.js.map +1 -0
- package/cjs/form/file-upload/parts/item/utils/download-file.d.ts +1 -0
- package/cjs/form/file-upload/parts/item/utils/download-file.js +13 -0
- package/cjs/form/file-upload/parts/item/utils/download-file.js.map +1 -0
- package/cjs/form/file-upload/parts/item/utils/file-type-checker.d.ts +2 -0
- package/cjs/form/file-upload/parts/item/utils/file-type-checker.js +6 -0
- package/cjs/form/file-upload/parts/item/utils/file-type-checker.js.map +1 -0
- package/cjs/form/file-upload/parts/item/utils/format-file-size.d.ts +2 -0
- package/cjs/form/file-upload/parts/item/utils/format-file-size.js +24 -0
- package/cjs/form/file-upload/parts/item/utils/format-file-size.js.map +1 -0
- package/cjs/form/file-upload/useFileUpload.d.ts +12 -0
- package/cjs/form/file-upload/useFileUpload.js +33 -0
- package/cjs/form/file-upload/useFileUpload.js.map +1 -0
- package/cjs/form/file-upload/utils/is-accepted-file-type.d.ts +1 -0
- package/cjs/form/file-upload/utils/is-accepted-file-type.js +26 -0
- package/cjs/form/file-upload/utils/is-accepted-file-type.js.map +1 -0
- package/cjs/form/file-upload/utils/is-accepted-size.d.ts +1 -0
- package/cjs/form/file-upload/utils/is-accepted-size.js +11 -0
- package/cjs/form/file-upload/utils/is-accepted-size.js.map +1 -0
- package/cjs/form/file-upload/utils/validate-files.d.ts +8 -0
- package/cjs/form/file-upload/utils/validate-files.js +48 -0
- package/cjs/form/file-upload/utils/validate-files.js.map +1 -0
- package/cjs/form/radio/RadioGroup.d.ts +1 -1
- package/cjs/form/search/Search.d.ts +3 -2
- package/cjs/form/search/Search.js.map +1 -1
- package/cjs/form/select/Select.d.ts +9 -9
- package/cjs/form/switch/Switch.d.ts +5 -5
- package/cjs/form/textarea/Textarea.d.ts +5 -4
- package/cjs/form/textarea/Textarea.js.map +1 -1
- package/cjs/form/useFormField.d.ts +10 -8
- package/cjs/form/useFormField.js.map +1 -1
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +3 -1
- package/cjs/index.js.map +1 -1
- package/cjs/layout/bleed/Bleed.d.ts +9 -1
- package/cjs/layout/bleed/Bleed.js.map +1 -1
- package/cjs/layout/box/Box.d.ts +5 -5
- package/cjs/layout/grid/HGrid.d.ts +1 -3
- package/cjs/layout/grid/HGrid.js.map +1 -1
- package/cjs/layout/page/Page.d.ts +2 -2
- package/cjs/layout/responsive/Responsive.d.ts +2 -4
- package/cjs/layout/responsive/Responsive.js.map +1 -1
- package/cjs/layout/stack/Stack.d.ts +18 -4
- package/cjs/layout/stack/Stack.js.map +1 -1
- package/cjs/list/types.d.ts +1 -1
- package/cjs/loader/Loader.d.ts +0 -6
- package/cjs/loader/Loader.js.map +1 -1
- package/cjs/modal/Modal.js +2 -2
- package/cjs/modal/types.d.ts +8 -8
- package/cjs/pagination/Pagination.d.ts +3 -2
- package/cjs/pagination/Pagination.js.map +1 -1
- package/cjs/pagination/PaginationItem.d.ts +1 -1
- package/cjs/popover/Popover.d.ts +2 -1
- package/cjs/popover/Popover.js.map +1 -1
- package/cjs/read-more/ReadMore.d.ts +7 -7
- package/cjs/stepper/Step.d.ts +4 -4
- package/cjs/stepper/Stepper.d.ts +7 -5
- package/cjs/stepper/Stepper.js.map +1 -1
- package/cjs/table/AnimateHeight.d.ts +1 -1
- package/cjs/table/DataCell.d.ts +1 -3
- package/cjs/table/DataCell.js.map +1 -1
- package/cjs/tabs/TabList.d.ts +1 -1
- package/cjs/tabs/Tabs.d.ts +7 -7
- package/cjs/timeline/Timeline.d.ts +6 -3
- package/cjs/timeline/Timeline.js +2 -1
- package/cjs/timeline/Timeline.js.map +1 -1
- package/cjs/timeline/period/index.d.ts +3 -2
- package/cjs/timeline/period/index.js.map +1 -1
- package/cjs/tooltip/Tooltip.d.ts +19 -12
- package/cjs/tooltip/Tooltip.js.map +1 -1
- package/cjs/util/create-context.d.ts +1 -0
- package/cjs/util/create-context.js.map +1 -1
- package/cjs/util/hooks/useEventListener.d.ts +1 -1
- package/cjs/util/hooks/useMergeRefs.d.ts +1 -1
- package/esm/accordion/Accordion.d.ts +4 -4
- package/esm/alert/Alert.d.ts +12 -10
- package/esm/alert/Alert.js.map +1 -1
- package/esm/button/Button.d.ts +9 -8
- package/esm/button/Button.js.map +1 -1
- package/esm/chat/Chat.d.ts +6 -6
- package/esm/chips/Chips.d.ts +2 -2
- package/esm/copybutton/CopyButton.d.ts +14 -12
- package/esm/copybutton/CopyButton.js.map +1 -1
- package/esm/date/datepicker/types.d.ts +7 -6
- package/esm/date/hooks/useDatepicker.d.ts +4 -3
- package/esm/date/hooks/useDatepicker.js.map +1 -1
- package/esm/date/hooks/useMonthPicker.d.ts +4 -3
- package/esm/date/hooks/useMonthPicker.js.map +1 -1
- package/esm/date/monthpicker/types.d.ts +2 -1
- package/esm/date/parts/DateInput.d.ts +1 -1
- package/esm/expansion-card/ExpansionCardTitle.d.ts +1 -1
- package/esm/form/checkbox/CheckboxGroup.d.ts +3 -3
- package/esm/form/checkbox/types.d.ts +4 -4
- package/esm/form/combobox/ComboboxProvider.js +5 -1
- package/esm/form/combobox/ComboboxProvider.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/FilteredOptions.js +14 -12
- package/esm/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/filtered-options-util.d.ts +3 -3
- package/esm/form/combobox/FilteredOptions/filtered-options-util.js +1 -3
- package/esm/form/combobox/FilteredOptions/filtered-options-util.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/filteredOptionsContext.d.ts +8 -5
- package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js +8 -13
- package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
- package/esm/form/combobox/Input/Input.js +9 -7
- package/esm/form/combobox/Input/Input.js.map +1 -1
- package/esm/form/combobox/SelectedOptions/SelectedOptions.d.ts +2 -1
- package/esm/form/combobox/SelectedOptions/SelectedOptions.js +3 -3
- package/esm/form/combobox/SelectedOptions/SelectedOptions.js.map +1 -1
- package/esm/form/combobox/SelectedOptions/selectedOptionsContext.d.ts +10 -7
- package/esm/form/combobox/SelectedOptions/selectedOptionsContext.js +6 -8
- package/esm/form/combobox/SelectedOptions/selectedOptionsContext.js.map +1 -1
- package/esm/form/combobox/combobox-utils.d.ts +10 -0
- package/esm/form/combobox/combobox-utils.js +22 -0
- package/esm/form/combobox/combobox-utils.js.map +1 -0
- package/esm/form/combobox/customOptionsContext.d.ts +5 -4
- package/esm/form/combobox/customOptionsContext.js +1 -1
- package/esm/form/combobox/customOptionsContext.js.map +1 -1
- package/esm/form/combobox/types.d.ts +33 -22
- package/esm/form/error-summary/ErrorSummary.d.ts +5 -5
- package/esm/form/file-upload/FileUpload.context.d.ts +8 -0
- package/esm/form/file-upload/FileUpload.context.js +3 -0
- package/esm/form/file-upload/FileUpload.context.js.map +1 -0
- package/esm/form/file-upload/FileUpload.d.ts +118 -0
- package/esm/form/file-upload/FileUpload.js +44 -0
- package/esm/form/file-upload/FileUpload.js.map +1 -0
- package/esm/form/file-upload/FileUpload.types.d.ts +55 -0
- package/esm/form/file-upload/FileUpload.types.js +5 -0
- package/esm/form/file-upload/FileUpload.types.js.map +1 -0
- package/esm/form/file-upload/i18n/get.d.ts +2 -0
- package/esm/form/file-upload/i18n/get.js +34 -0
- package/esm/form/file-upload/i18n/get.js.map +1 -0
- package/esm/form/file-upload/i18n/i18n.context.d.ts +11 -0
- package/esm/form/file-upload/i18n/i18n.context.js +32 -0
- package/esm/form/file-upload/i18n/i18n.context.js.map +1 -0
- package/esm/form/file-upload/i18n/i18n.types.d.ts +13 -0
- package/esm/form/file-upload/i18n/i18n.types.js +2 -0
- package/esm/form/file-upload/i18n/i18n.types.js.map +1 -0
- package/esm/form/file-upload/i18n/locales/nb.json +20 -0
- package/esm/form/file-upload/i18n/merge.d.ts +2 -0
- package/esm/form/file-upload/i18n/merge.js +25 -0
- package/esm/form/file-upload/i18n/merge.js.map +1 -0
- package/esm/form/file-upload/index.d.ts +7 -0
- package/esm/form/file-upload/index.js +6 -0
- package/esm/form/file-upload/index.js.map +1 -0
- package/esm/form/file-upload/parts/Trigger.d.ts +7 -0
- package/esm/form/file-upload/parts/Trigger.js +18 -0
- package/esm/form/file-upload/parts/Trigger.js.map +1 -0
- package/esm/form/file-upload/parts/dropzone/Dropzone.d.ts +4 -0
- package/esm/form/file-upload/parts/dropzone/Dropzone.js +78 -0
- package/esm/form/file-upload/parts/dropzone/Dropzone.js.map +1 -0
- package/esm/form/file-upload/parts/dropzone/dropzone.types.d.ts +18 -0
- package/esm/form/file-upload/parts/dropzone/dropzone.types.js +2 -0
- package/esm/form/file-upload/parts/dropzone/dropzone.types.js.map +1 -0
- package/esm/form/file-upload/parts/dropzone/useDropzone.d.ts +13 -0
- package/esm/form/file-upload/parts/dropzone/useDropzone.js +30 -0
- package/esm/form/file-upload/parts/dropzone/useDropzone.js.map +1 -0
- package/esm/form/file-upload/parts/item/Item.d.ts +55 -0
- package/esm/form/file-upload/parts/item/Item.js +50 -0
- package/esm/form/file-upload/parts/item/Item.js.map +1 -0
- package/esm/form/file-upload/parts/item/Item.types.d.ts +5 -0
- package/esm/form/file-upload/parts/item/Item.types.js +2 -0
- package/esm/form/file-upload/parts/item/Item.types.js.map +1 -0
- package/esm/form/file-upload/parts/item/ItemButton.d.ts +12 -0
- package/esm/form/file-upload/parts/item/ItemButton.js +17 -0
- package/esm/form/file-upload/parts/item/ItemButton.js.map +1 -0
- package/esm/form/file-upload/parts/item/ItemIcon.d.ts +9 -0
- package/esm/form/file-upload/parts/item/ItemIcon.js +46 -0
- package/esm/form/file-upload/parts/item/ItemIcon.js.map +1 -0
- package/esm/form/file-upload/parts/item/ItemName.d.ts +9 -0
- package/esm/form/file-upload/parts/item/ItemName.js +27 -0
- package/esm/form/file-upload/parts/item/ItemName.js.map +1 -0
- package/esm/form/file-upload/parts/item/utils/download-file.d.ts +1 -0
- package/esm/form/file-upload/parts/item/utils/download-file.js +9 -0
- package/esm/form/file-upload/parts/item/utils/download-file.js.map +1 -0
- package/esm/form/file-upload/parts/item/utils/file-type-checker.d.ts +2 -0
- package/esm/form/file-upload/parts/item/utils/file-type-checker.js +2 -0
- package/esm/form/file-upload/parts/item/utils/file-type-checker.js.map +1 -0
- package/esm/form/file-upload/parts/item/utils/format-file-size.d.ts +2 -0
- package/esm/form/file-upload/parts/item/utils/format-file-size.js +20 -0
- package/esm/form/file-upload/parts/item/utils/format-file-size.js.map +1 -0
- package/esm/form/file-upload/useFileUpload.d.ts +12 -0
- package/esm/form/file-upload/useFileUpload.js +29 -0
- package/esm/form/file-upload/useFileUpload.js.map +1 -0
- package/esm/form/file-upload/utils/is-accepted-file-type.d.ts +1 -0
- package/esm/form/file-upload/utils/is-accepted-file-type.js +22 -0
- package/esm/form/file-upload/utils/is-accepted-file-type.js.map +1 -0
- package/esm/form/file-upload/utils/is-accepted-size.d.ts +1 -0
- package/esm/form/file-upload/utils/is-accepted-size.js +7 -0
- package/esm/form/file-upload/utils/is-accepted-size.js.map +1 -0
- package/esm/form/file-upload/utils/validate-files.d.ts +8 -0
- package/esm/form/file-upload/utils/validate-files.js +44 -0
- package/esm/form/file-upload/utils/validate-files.js.map +1 -0
- package/esm/form/radio/RadioGroup.d.ts +1 -1
- package/esm/form/search/Search.d.ts +3 -2
- package/esm/form/search/Search.js.map +1 -1
- package/esm/form/select/Select.d.ts +9 -9
- package/esm/form/switch/Switch.d.ts +5 -5
- package/esm/form/textarea/Textarea.d.ts +5 -4
- package/esm/form/textarea/Textarea.js.map +1 -1
- package/esm/form/useFormField.d.ts +10 -8
- package/esm/form/useFormField.js.map +1 -1
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/layout/bleed/Bleed.d.ts +9 -1
- package/esm/layout/bleed/Bleed.js.map +1 -1
- package/esm/layout/box/Box.d.ts +5 -5
- package/esm/layout/grid/HGrid.d.ts +1 -3
- package/esm/layout/grid/HGrid.js.map +1 -1
- package/esm/layout/page/Page.d.ts +2 -2
- package/esm/layout/responsive/Responsive.d.ts +2 -4
- package/esm/layout/responsive/Responsive.js.map +1 -1
- package/esm/layout/stack/Stack.d.ts +18 -4
- package/esm/layout/stack/Stack.js.map +1 -1
- package/esm/list/types.d.ts +1 -1
- package/esm/loader/Loader.d.ts +0 -6
- package/esm/loader/Loader.js.map +1 -1
- package/esm/modal/Modal.js +2 -2
- package/esm/modal/types.d.ts +8 -8
- package/esm/pagination/Pagination.d.ts +3 -2
- package/esm/pagination/Pagination.js.map +1 -1
- package/esm/pagination/PaginationItem.d.ts +1 -1
- package/esm/popover/Popover.d.ts +2 -1
- package/esm/popover/Popover.js.map +1 -1
- package/esm/read-more/ReadMore.d.ts +7 -7
- package/esm/stepper/Step.d.ts +4 -4
- package/esm/stepper/Stepper.d.ts +7 -5
- package/esm/stepper/Stepper.js.map +1 -1
- package/esm/table/AnimateHeight.d.ts +1 -1
- package/esm/table/DataCell.d.ts +1 -3
- package/esm/table/DataCell.js.map +1 -1
- package/esm/tabs/TabList.d.ts +1 -1
- package/esm/tabs/Tabs.d.ts +7 -7
- package/esm/timeline/Timeline.d.ts +6 -3
- package/esm/timeline/Timeline.js +2 -1
- package/esm/timeline/Timeline.js.map +1 -1
- package/esm/timeline/period/index.d.ts +3 -2
- package/esm/timeline/period/index.js.map +1 -1
- package/esm/tooltip/Tooltip.d.ts +19 -12
- package/esm/tooltip/Tooltip.js.map +1 -1
- package/esm/util/create-context.d.ts +1 -0
- package/esm/util/create-context.js.map +1 -1
- package/esm/util/hooks/useEventListener.d.ts +1 -1
- package/esm/util/hooks/useMergeRefs.d.ts +1 -1
- package/package.json +13 -3
- package/src/accordion/Accordion.tsx +4 -4
- package/src/accordion/accordion.stories.tsx +0 -2
- package/src/alert/Alert.tsx +12 -10
- package/src/button/Button.tsx +9 -8
- package/src/chat/Chat.tsx +6 -6
- package/src/chips/Chips.tsx +2 -2
- package/src/copybutton/CopyButton.tsx +14 -12
- package/src/date/datepicker/datepicker.stories.tsx +0 -1
- package/src/date/datepicker/types.ts +7 -6
- package/src/date/hooks/useDatepicker.tsx +4 -3
- package/src/date/hooks/useMonthPicker.tsx +4 -3
- package/src/date/monthpicker/types.ts +2 -1
- package/src/date/parts/DateInput.tsx +1 -1
- package/src/expansion-card/ExpansionCardTitle.tsx +1 -1
- package/src/form/checkbox/CheckboxGroup.tsx +3 -3
- package/src/form/checkbox/types.ts +4 -4
- package/src/form/combobox/ComboboxProvider.tsx +7 -3
- package/src/form/combobox/FilteredOptions/FilteredOptions.tsx +22 -15
- package/src/form/combobox/FilteredOptions/filtered-options-util.ts +5 -10
- package/src/form/combobox/FilteredOptions/filteredOptionsContext.tsx +19 -29
- package/src/form/combobox/Input/Input.tsx +14 -8
- package/src/form/combobox/SelectedOptions/SelectedOptions.tsx +8 -5
- package/src/form/combobox/SelectedOptions/selectedOptionsContext.tsx +24 -25
- package/src/form/combobox/combobox-utils.test.ts +67 -0
- package/src/form/combobox/combobox-utils.ts +32 -0
- package/src/form/combobox/combobox.stories.tsx +67 -32
- package/src/form/combobox/combobox.test.tsx +32 -1
- package/src/form/combobox/customOptionsContext.tsx +9 -8
- package/src/form/combobox/types.ts +34 -22
- package/src/form/error-summary/ErrorSummary.tsx +5 -5
- package/src/form/file-upload/FileUpload.context.tsx +9 -0
- package/src/form/file-upload/FileUpload.tsx +142 -0
- package/src/form/file-upload/FileUpload.types.ts +57 -0
- package/src/form/file-upload/file-upload-dropzone.stories.tsx +123 -0
- package/src/form/file-upload/file-upload-item.stories.tsx +136 -0
- package/src/form/file-upload/file-upload.stories.tsx +236 -0
- package/src/form/file-upload/i18n/get.ts +48 -0
- package/src/form/file-upload/i18n/i18n.context.test.tsx +92 -0
- package/src/form/file-upload/i18n/i18n.context.ts +67 -0
- package/src/form/file-upload/i18n/i18n.types.ts +20 -0
- package/src/form/file-upload/i18n/locales/nb.json +20 -0
- package/src/form/file-upload/i18n/merge.ts +35 -0
- package/src/form/file-upload/index.ts +21 -0
- package/src/form/file-upload/parts/Trigger.tsx +48 -0
- package/src/form/file-upload/parts/dropzone/Dropzone.tsx +180 -0
- package/src/form/file-upload/parts/dropzone/dropzone.types.ts +22 -0
- package/src/form/file-upload/parts/dropzone/useDropzone.ts +43 -0
- package/src/form/file-upload/parts/item/Item.tsx +165 -0
- package/src/form/file-upload/parts/item/Item.types.ts +6 -0
- package/src/form/file-upload/parts/item/ItemButton.tsx +52 -0
- package/src/form/file-upload/parts/item/ItemIcon.tsx +74 -0
- package/src/form/file-upload/parts/item/ItemName.tsx +58 -0
- package/src/form/file-upload/parts/item/utils/download-file.ts +9 -0
- package/src/form/file-upload/parts/item/utils/file-type-checker.ts +4 -0
- package/src/form/file-upload/parts/item/utils/format-file-size.test.ts +76 -0
- package/src/form/file-upload/parts/item/utils/format-file-size.ts +25 -0
- package/src/form/file-upload/useFileUpload.ts +54 -0
- package/src/form/file-upload/utils/is-accepted-file-type.test.ts +69 -0
- package/src/form/file-upload/utils/is-accepted-file-type.ts +25 -0
- package/src/form/file-upload/utils/is-accepted-size.test.ts +26 -0
- package/src/form/file-upload/utils/is-accepted-size.ts +7 -0
- package/src/form/file-upload/utils/validate-files.test.ts +132 -0
- package/src/form/file-upload/utils/validate-files.ts +62 -0
- package/src/form/radio/RadioGroup.tsx +1 -1
- package/src/form/search/Search.tsx +3 -2
- package/src/form/select/Select.tsx +9 -9
- package/src/form/select/select.stories.tsx +32 -37
- package/src/form/switch/Switch.tsx +5 -5
- package/src/form/textarea/Textarea.tsx +5 -4
- package/src/form/useFormField.ts +10 -8
- package/src/index.ts +14 -0
- package/src/internal-header/header.stories.tsx +8 -5
- package/src/layout/bleed/Bleed.tsx +9 -1
- package/src/layout/box/Box.tsx +5 -5
- package/src/layout/grid/HGrid.tsx +1 -3
- package/src/layout/page/Page.tsx +2 -2
- package/src/layout/responsive/Responsive.tsx +2 -4
- package/src/layout/stack/Stack.tsx +18 -4
- package/src/list/types.ts +1 -1
- package/src/loader/Loader.tsx +0 -6
- package/src/modal/Modal.tsx +2 -2
- package/src/modal/types.ts +8 -8
- package/src/pagination/Pagination.tsx +3 -2
- package/src/pagination/PaginationItem.tsx +1 -1
- package/src/popover/Popover.tsx +2 -1
- package/src/read-more/ReadMore.tsx +7 -7
- package/src/stepper/Step.tsx +4 -4
- package/src/stepper/Stepper.tsx +7 -5
- package/src/table/AnimateHeight.tsx +1 -1
- package/src/table/DataCell.tsx +1 -6
- package/src/tabs/TabList.tsx +1 -1
- package/src/tabs/Tabs.tsx +7 -7
- package/src/timeline/Timeline.tsx +6 -3
- package/src/timeline/period/index.tsx +3 -2
- package/src/tooltip/Tooltip.tsx +19 -12
- package/src/util/create-context.tsx +1 -0
- package/src/util/hooks/useMergeRefs.ts +1 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isInList,
|
|
3
|
+
mapToComboboxOptionArray,
|
|
4
|
+
toComboboxOption,
|
|
5
|
+
} from "./combobox-utils";
|
|
6
|
+
|
|
7
|
+
const list = [
|
|
8
|
+
{ label: "Hjelpemidler", value: "HJE" },
|
|
9
|
+
{ label: "Oppfølging", value: "OPP" },
|
|
10
|
+
{ label: "Sykepenger", value: "SYK" },
|
|
11
|
+
{ label: "Sykemelding", value: "SYM" },
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
describe("isInList", () => {
|
|
15
|
+
test("finds a string value in a list of ComboboxOptions", () => {
|
|
16
|
+
expect(isInList("Oppfølging", list)).toBe(true);
|
|
17
|
+
expect(isInList("SYM", list)).toBe(true);
|
|
18
|
+
expect(isInList("Arbeidsavklaringspenger", list)).toBe(false);
|
|
19
|
+
expect(isInList("AAP", list)).toBe(false);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test("finds a ComboboxOption in a list of ComboboxOptions", () => {
|
|
23
|
+
expect(isInList({ label: "Oppfølging", value: "OPP" }, list)).toBe(true);
|
|
24
|
+
expect(isInList({ label: "Sykemelding", value: "SYM" }, list)).toBe(true);
|
|
25
|
+
expect(
|
|
26
|
+
isInList({ label: "Arbeidsavklaringspenger", value: "AAP" }, list),
|
|
27
|
+
).toBe(false);
|
|
28
|
+
expect(
|
|
29
|
+
isInList({ label: "Arbeidsavklaringspenger", value: "AAP" }, list),
|
|
30
|
+
).toBe(false);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test("returns false for ComboboxOptions which do not match both label and value", () => {
|
|
34
|
+
expect(isInList({ label: "Oppfølging", value: "SYM" }, list)).toBe(false);
|
|
35
|
+
expect(isInList({ label: "Sykemelding", value: "OPP" }, list)).toBe(false);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe("mapToComboboxOptionArray", () => {
|
|
40
|
+
test("maps an array of strings to an array of ComboboxOptions", () => {
|
|
41
|
+
const stringArray = ["Hjelpemidler", "Oppfølging", "Sykepenger"];
|
|
42
|
+
const comboboxOptions = [
|
|
43
|
+
{ label: "Hjelpemidler", value: "Hjelpemidler" },
|
|
44
|
+
{ label: "Oppfølging", value: "Oppfølging" },
|
|
45
|
+
{ label: "Sykepenger", value: "Sykepenger" },
|
|
46
|
+
];
|
|
47
|
+
expect(mapToComboboxOptionArray(stringArray)).toEqual(comboboxOptions);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test("does not change an array of ComboboxOptions", () => {
|
|
51
|
+
const comboboxOptions = [
|
|
52
|
+
{ label: "Hjelpemidler", value: "Hjelpemidler" },
|
|
53
|
+
{ label: "Oppfølging", value: "Oppfølging" },
|
|
54
|
+
{ label: "Sykepenger", value: "Sykepenger" },
|
|
55
|
+
];
|
|
56
|
+
expect(mapToComboboxOptionArray(comboboxOptions)).toEqual(comboboxOptions);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe("toComboboxOption", () => {
|
|
61
|
+
test("creates a ComboboxOption from a string", () => {
|
|
62
|
+
expect(toComboboxOption("Hjelpemidler")).toEqual({
|
|
63
|
+
label: "Hjelpemidler",
|
|
64
|
+
value: "Hjelpemidler",
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ComboboxOption } from "./types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param option ComboboxOption will be compared by both label and value, while a string option is checked if it matches either the label or value in the list.
|
|
6
|
+
* @param list
|
|
7
|
+
*/
|
|
8
|
+
const isInList = (option: ComboboxOption | string, list: ComboboxOption[]) => {
|
|
9
|
+
if (typeof option === "string") {
|
|
10
|
+
return list.some(
|
|
11
|
+
(listItem) => listItem.label === option || listItem.value === option,
|
|
12
|
+
);
|
|
13
|
+
} else {
|
|
14
|
+
return list.some(
|
|
15
|
+
(listItem) =>
|
|
16
|
+
listItem.label === option.label && listItem.value === option.value,
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const toComboboxOption = (value: string): ComboboxOption => ({
|
|
22
|
+
label: value,
|
|
23
|
+
value,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const mapToComboboxOptionArray = (options?: string[] | ComboboxOption[]) => {
|
|
27
|
+
return options?.map((option: string | ComboboxOption) =>
|
|
28
|
+
typeof option === "string" ? toComboboxOption(option) : option,
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { isInList, mapToComboboxOptionArray, toComboboxOption };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Meta, StoryFn, StoryObj } from "@storybook/react";
|
|
2
2
|
import { expect, fn, userEvent, within } from "@storybook/test";
|
|
3
|
-
import React, {
|
|
3
|
+
import React, { useMemo, useRef, useState } from "react";
|
|
4
4
|
import { Chips } from "../../chips";
|
|
5
5
|
import { TextField } from "../textfield";
|
|
6
6
|
import { ComboboxProps, UNSAFE_Combobox } from "./index";
|
|
@@ -30,10 +30,10 @@ const options = [
|
|
|
30
30
|
"grape fruit",
|
|
31
31
|
];
|
|
32
32
|
|
|
33
|
-
export const Default: StoryFunction = (props) =>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
export const Default: StoryFunction = (props) => (
|
|
34
|
+
<UNSAFE_Combobox {...props} id="combobox" />
|
|
35
|
+
);
|
|
36
|
+
|
|
37
37
|
Default.args = {
|
|
38
38
|
options,
|
|
39
39
|
label: "Hva er dine favorittfrukter?",
|
|
@@ -57,10 +57,9 @@ Default.argTypes = {
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
export const MultiSelect: StoryFunction = (props) => {
|
|
60
|
-
const id = useId();
|
|
61
60
|
return (
|
|
62
61
|
<UNSAFE_Combobox
|
|
63
|
-
id=
|
|
62
|
+
id="combobox-with-multiselect"
|
|
64
63
|
label="Komboboks - velg flere"
|
|
65
64
|
options={props.options}
|
|
66
65
|
isMultiSelect={props.isMultiSelect}
|
|
@@ -75,11 +74,55 @@ MultiSelect.args = {
|
|
|
75
74
|
size: "medium",
|
|
76
75
|
};
|
|
77
76
|
|
|
77
|
+
export const MultiSelectWithComplexOptions: StoryFunction = (props) => {
|
|
78
|
+
const [selectedOptions, setSelectedOptions] = useState<string[]>([]);
|
|
79
|
+
return (
|
|
80
|
+
<>
|
|
81
|
+
<UNSAFE_Combobox
|
|
82
|
+
{...props}
|
|
83
|
+
options={props.options.map((option) => ({
|
|
84
|
+
...option,
|
|
85
|
+
label: `${option.label} [${option.value}]`,
|
|
86
|
+
}))}
|
|
87
|
+
id="combobox-with-complex-options"
|
|
88
|
+
label="Velg temakoder"
|
|
89
|
+
allowNewValues
|
|
90
|
+
onToggleSelected={(value, isSelected) =>
|
|
91
|
+
isSelected
|
|
92
|
+
? setSelectedOptions([...selectedOptions, value])
|
|
93
|
+
: setSelectedOptions(selectedOptions.filter((o) => o !== value))
|
|
94
|
+
}
|
|
95
|
+
selectedOptions={selectedOptions}
|
|
96
|
+
/>
|
|
97
|
+
</>
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
MultiSelectWithComplexOptions.args = {
|
|
102
|
+
options: [
|
|
103
|
+
{ label: "Hjelpemidler", value: "HJE" },
|
|
104
|
+
{ label: "Oppfølging", value: "OPP" },
|
|
105
|
+
{ label: "Sykepenger", value: "SYK" },
|
|
106
|
+
{ label: "Sykemelding", value: "SYM" },
|
|
107
|
+
{ label: "Foreldre- og svangerskapspenger", value: "FOR" },
|
|
108
|
+
{ label: "Arbeidsavklaringspenger", value: "AAP" },
|
|
109
|
+
{ label: "Uføretrygd", value: "UFO" },
|
|
110
|
+
{ label: "Pensjon", value: "PEN" },
|
|
111
|
+
{ label: "Barnetrygd", value: "BAR" },
|
|
112
|
+
{ label: "Kontantstøtte", value: "KON" },
|
|
113
|
+
{ label: "Bostøtte", value: "BOS" },
|
|
114
|
+
{ label: "Barnebidrag", value: "BBI" },
|
|
115
|
+
{ label: "Bidragsforskudd", value: "BIF" },
|
|
116
|
+
{ label: "Grunn- og hjelpestønad", value: "GRU" },
|
|
117
|
+
],
|
|
118
|
+
isMultiSelect: true,
|
|
119
|
+
size: "medium",
|
|
120
|
+
};
|
|
121
|
+
|
|
78
122
|
export const WithAddNewOptions: StoryFunction = (props) => {
|
|
79
|
-
const id = useId();
|
|
80
123
|
return (
|
|
81
124
|
<UNSAFE_Combobox
|
|
82
|
-
id=
|
|
125
|
+
id="combobox-with-add-new-options"
|
|
83
126
|
label="Komboboks med mulighet for å legge til nye verdier"
|
|
84
127
|
options={props.options}
|
|
85
128
|
allowNewValues={props.allowNewValues}
|
|
@@ -95,10 +138,9 @@ WithAddNewOptions.args = {
|
|
|
95
138
|
};
|
|
96
139
|
|
|
97
140
|
export const MultiSelectWithAddNewOptions: StoryFunction = (props) => {
|
|
98
|
-
const id = useId();
|
|
99
141
|
return (
|
|
100
142
|
<UNSAFE_Combobox
|
|
101
|
-
id=
|
|
143
|
+
id="combobox-with-multiselect-and-add-new-options"
|
|
102
144
|
isMultiSelect={props.isMultiSelect}
|
|
103
145
|
label="Multiselect komboboks med mulighet for å legge til nye verdier"
|
|
104
146
|
options={props.options}
|
|
@@ -120,7 +162,6 @@ export const MultiSelectWithExternalChips: StoryFn<{
|
|
|
120
162
|
}> = (props) => {
|
|
121
163
|
const [selectedOptions, setSelectedOptions] = useState<string[]>([]);
|
|
122
164
|
const [value, setValue] = useState("");
|
|
123
|
-
const id = useId();
|
|
124
165
|
|
|
125
166
|
const toggleSelected = (option: string) =>
|
|
126
167
|
selectedOptions.includes(option)
|
|
@@ -142,6 +183,7 @@ export const MultiSelectWithExternalChips: StoryFn<{
|
|
|
142
183
|
</Chips>
|
|
143
184
|
)}
|
|
144
185
|
<UNSAFE_Combobox
|
|
186
|
+
id="combobox-with-external-chips"
|
|
145
187
|
options={props.options}
|
|
146
188
|
selectedOptions={selectedOptions}
|
|
147
189
|
onToggleSelected={(option) => toggleSelected(option)}
|
|
@@ -154,7 +196,6 @@ export const MultiSelectWithExternalChips: StoryFn<{
|
|
|
154
196
|
}
|
|
155
197
|
label="Komboboks"
|
|
156
198
|
size="medium"
|
|
157
|
-
id={id}
|
|
158
199
|
shouldShowSelectedOptions={false}
|
|
159
200
|
/>
|
|
160
201
|
</>
|
|
@@ -166,19 +207,16 @@ MultiSelectWithExternalChips.args = {
|
|
|
166
207
|
options,
|
|
167
208
|
};
|
|
168
209
|
|
|
169
|
-
export const Loading: StoryFunction = (props) =>
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
/>
|
|
180
|
-
);
|
|
181
|
-
};
|
|
210
|
+
export const Loading: StoryFunction = (props) => (
|
|
211
|
+
<UNSAFE_Combobox
|
|
212
|
+
id="combobox-with-loading-indicator"
|
|
213
|
+
label="Komboboks (laster)"
|
|
214
|
+
options={[]}
|
|
215
|
+
selectedOptions={[]}
|
|
216
|
+
isListOpen={props.isListOpen}
|
|
217
|
+
isLoading={props.isLoading}
|
|
218
|
+
/>
|
|
219
|
+
);
|
|
182
220
|
|
|
183
221
|
Loading.args = {
|
|
184
222
|
isLoading: true,
|
|
@@ -186,11 +224,10 @@ Loading.args = {
|
|
|
186
224
|
};
|
|
187
225
|
|
|
188
226
|
export const ComboboxWithNoHits: StoryFunction = (props) => {
|
|
189
|
-
const id = useId();
|
|
190
227
|
const [value, setValue] = useState(props.value);
|
|
191
228
|
return (
|
|
192
229
|
<UNSAFE_Combobox
|
|
193
|
-
id=
|
|
230
|
+
id="combobox-with-no-hits"
|
|
194
231
|
label="Komboboks (uten søketreff)"
|
|
195
232
|
options={props.options}
|
|
196
233
|
value={value}
|
|
@@ -210,7 +247,6 @@ export const Controlled: StoryFn<{
|
|
|
210
247
|
options: string[];
|
|
211
248
|
initialSelectedOptions: string[];
|
|
212
249
|
}> = (props) => {
|
|
213
|
-
const id = useId();
|
|
214
250
|
const [value, setValue] = useState(props.value);
|
|
215
251
|
const [selectedOptions, setSelectedOptions] = useState(
|
|
216
252
|
props.initialSelectedOptions,
|
|
@@ -238,7 +274,7 @@ export const Controlled: StoryFn<{
|
|
|
238
274
|
<br />
|
|
239
275
|
<UNSAFE_Combobox
|
|
240
276
|
label="Hva er dine favorittfrukter?"
|
|
241
|
-
id=
|
|
277
|
+
id="combobox-controlled"
|
|
242
278
|
filteredOptions={filteredOptions}
|
|
243
279
|
isMultiSelect
|
|
244
280
|
options={props.options}
|
|
@@ -292,7 +328,6 @@ export const ComboboxSizes = () => (
|
|
|
292
328
|
);
|
|
293
329
|
|
|
294
330
|
export const MaxSelectedOptions: StoryFunction = () => {
|
|
295
|
-
const id = useId();
|
|
296
331
|
const [value, setValue] = useState<string | undefined>("");
|
|
297
332
|
const [selectedOptions, setSelectedOptions] = useState([
|
|
298
333
|
options[0],
|
|
@@ -301,7 +336,7 @@ export const MaxSelectedOptions: StoryFunction = () => {
|
|
|
301
336
|
const comboboxRef = useRef<HTMLInputElement>(null);
|
|
302
337
|
return (
|
|
303
338
|
<UNSAFE_Combobox
|
|
304
|
-
id=
|
|
339
|
+
id="combobox-with-max-selected-options"
|
|
305
340
|
label="Komboboks med begrenset antall valg"
|
|
306
341
|
options={options}
|
|
307
342
|
maxSelected={{ limit: 2 }}
|
|
@@ -3,7 +3,7 @@ import { render, screen } from "@testing-library/react";
|
|
|
3
3
|
import userEvent from "@testing-library/user-event";
|
|
4
4
|
import React, { useId } from "react";
|
|
5
5
|
import { act } from "react-dom/test-utils";
|
|
6
|
-
import { describe, expect, test } from "vitest";
|
|
6
|
+
import { describe, expect, test, vi } from "vitest";
|
|
7
7
|
import { UNSAFE_Combobox } from "./index";
|
|
8
8
|
|
|
9
9
|
const options = [
|
|
@@ -123,4 +123,35 @@ describe("Combobox state-handling", () => {
|
|
|
123
123
|
await screen.findByRole("option", { name: "banana" }),
|
|
124
124
|
).toBeInTheDocument();
|
|
125
125
|
});
|
|
126
|
+
|
|
127
|
+
test("Should handle complex options with label and value", async () => {
|
|
128
|
+
const onToggleSelected = vi.fn();
|
|
129
|
+
render(
|
|
130
|
+
<App
|
|
131
|
+
options={[
|
|
132
|
+
{ label: "Hjelpemidler [HJE]", value: "HJE" },
|
|
133
|
+
{ label: "Oppfølging [OPP]", value: "OPP" },
|
|
134
|
+
{ label: "Sykepenger [SYK]", value: "SYK" },
|
|
135
|
+
{ label: "Sykemelding [SYM]", value: "SYM" },
|
|
136
|
+
]}
|
|
137
|
+
onToggleSelected={onToggleSelected}
|
|
138
|
+
/>,
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
expect(screen.getByRole("combobox")).toBeInTheDocument();
|
|
142
|
+
const bananaOption = screen.getByRole("option", {
|
|
143
|
+
name: "Hjelpemidler [HJE]",
|
|
144
|
+
selected: false,
|
|
145
|
+
});
|
|
146
|
+
await act(async () => {
|
|
147
|
+
await userEvent.click(bananaOption);
|
|
148
|
+
});
|
|
149
|
+
expect(onToggleSelected).toHaveBeenCalledWith("HJE", true, false);
|
|
150
|
+
expect(
|
|
151
|
+
screen.getByRole("option", {
|
|
152
|
+
name: "Hjelpemidler [HJE]",
|
|
153
|
+
selected: true,
|
|
154
|
+
}),
|
|
155
|
+
).toBeInTheDocument();
|
|
156
|
+
});
|
|
126
157
|
});
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React, { createContext, useCallback, useContext, useState } from "react";
|
|
2
2
|
import { useInputContext } from "./Input/inputContext";
|
|
3
|
+
import { ComboboxOption } from "./types";
|
|
3
4
|
|
|
4
5
|
type CustomOptionsContextType = {
|
|
5
|
-
customOptions:
|
|
6
|
-
removeCustomOption: (option:
|
|
7
|
-
addCustomOption: (option:
|
|
8
|
-
setCustomOptions: React.Dispatch<React.SetStateAction<
|
|
6
|
+
customOptions: ComboboxOption[];
|
|
7
|
+
removeCustomOption: (option: ComboboxOption) => void;
|
|
8
|
+
addCustomOption: (option: ComboboxOption) => void;
|
|
9
|
+
setCustomOptions: React.Dispatch<React.SetStateAction<ComboboxOption[]>>;
|
|
9
10
|
};
|
|
10
11
|
|
|
11
12
|
const CustomOptionsContext = createContext<CustomOptionsContextType>(
|
|
@@ -19,14 +20,14 @@ export const CustomOptionsProvider = ({
|
|
|
19
20
|
children: any;
|
|
20
21
|
value: { isMultiSelect?: boolean };
|
|
21
22
|
}) => {
|
|
22
|
-
const [customOptions, setCustomOptions] = useState<
|
|
23
|
+
const [customOptions, setCustomOptions] = useState<ComboboxOption[]>([]);
|
|
23
24
|
const { focusInput } = useInputContext();
|
|
24
25
|
const { isMultiSelect } = value;
|
|
25
26
|
|
|
26
27
|
const removeCustomOption = useCallback(
|
|
27
|
-
(option:
|
|
28
|
+
(option: ComboboxOption) => {
|
|
28
29
|
setCustomOptions((prevCustomOptions) =>
|
|
29
|
-
prevCustomOptions.filter((o) => o !== option),
|
|
30
|
+
prevCustomOptions.filter((o) => o.label !== option.label),
|
|
30
31
|
);
|
|
31
32
|
focusInput();
|
|
32
33
|
},
|
|
@@ -34,7 +35,7 @@ export const CustomOptionsProvider = ({
|
|
|
34
35
|
);
|
|
35
36
|
|
|
36
37
|
const addCustomOption = useCallback(
|
|
37
|
-
(option:
|
|
38
|
+
(option: ComboboxOption) => {
|
|
38
39
|
if (isMultiSelect) {
|
|
39
40
|
setCustomOptions((prevOptions) => [...prevOptions, option]);
|
|
40
41
|
} else {
|
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import React, { ChangeEvent, InputHTMLAttributes } from "react";
|
|
2
2
|
import { FormFieldProps } from "../useFormField";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* A more complex version of options for the Combobox.
|
|
6
|
+
* Used for separating the label and the value of the option.
|
|
7
|
+
*/
|
|
8
|
+
export type ComboboxOption = {
|
|
9
|
+
/**
|
|
10
|
+
* The label to display in the dropdown list
|
|
11
|
+
*/
|
|
12
|
+
label: string;
|
|
13
|
+
/**
|
|
14
|
+
* The programmatic value of the option, for use internally. Will be returned from onToggleSelected.
|
|
15
|
+
*/
|
|
16
|
+
value: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
4
19
|
export type MaxSelected = {
|
|
5
20
|
/**
|
|
6
21
|
* The limit for maximum selected options
|
|
@@ -16,23 +31,23 @@ export interface ComboboxProps
|
|
|
16
31
|
extends FormFieldProps,
|
|
17
32
|
Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "onChange" | "value"> {
|
|
18
33
|
/**
|
|
19
|
-
* Combobox label
|
|
34
|
+
* Combobox label.
|
|
20
35
|
*/
|
|
21
36
|
label: React.ReactNode;
|
|
22
37
|
/**
|
|
23
|
-
* List of options
|
|
38
|
+
* List of options
|
|
24
39
|
*/
|
|
25
|
-
options: string[];
|
|
40
|
+
options: string[] | ComboboxOption[];
|
|
26
41
|
/**
|
|
27
42
|
* If enabled, adds an option to add the value of the input as an option whenever there are no options matching the value.
|
|
28
43
|
*/
|
|
29
44
|
allowNewValues?: boolean;
|
|
30
45
|
/**
|
|
31
|
-
* If
|
|
46
|
+
* If `true` adds a button to clear the value in the input field
|
|
32
47
|
*/
|
|
33
48
|
clearButton?: boolean;
|
|
34
49
|
/**
|
|
35
|
-
* Custom name for the clear button. Requires
|
|
50
|
+
* Custom name for the clear button. Requires `clearButton` to be `true`.
|
|
36
51
|
*
|
|
37
52
|
* @default "Tøm"
|
|
38
53
|
*/
|
|
@@ -42,7 +57,7 @@ export interface ComboboxProps
|
|
|
42
57
|
* If provided, this overrides the internal search logic in the component.
|
|
43
58
|
* Useful for e.g. searching on a server or when overriding the search algorithm to search for synonyms or similar.
|
|
44
59
|
*/
|
|
45
|
-
filteredOptions?: string[];
|
|
60
|
+
filteredOptions?: string[] | ComboboxOption[];
|
|
46
61
|
/**
|
|
47
62
|
* Optionally hide the label visually.
|
|
48
63
|
* Not recommended, but can be considered for e.g. search fields in the top menu.
|
|
@@ -59,13 +74,13 @@ export interface ComboboxProps
|
|
|
59
74
|
*/
|
|
60
75
|
isListOpen?: boolean;
|
|
61
76
|
/**
|
|
62
|
-
* Set to
|
|
77
|
+
* Set to `true` when doing an async search and waiting for new filteredOptions.
|
|
63
78
|
*
|
|
64
79
|
* Will show a spinner in the dropdown and announce to screen readers that it is loading.
|
|
65
80
|
*/
|
|
66
81
|
isLoading?: boolean;
|
|
67
82
|
/**
|
|
68
|
-
* Set to
|
|
83
|
+
* Set to `true` to allow multiple selections.
|
|
69
84
|
*
|
|
70
85
|
* This will display selected values as a list of Chips in front of the input field, instead of a selection replacing the value of the input.
|
|
71
86
|
*
|
|
@@ -75,29 +90,26 @@ export interface ComboboxProps
|
|
|
75
90
|
* Callback function triggered whenever the value of the input field is triggered.
|
|
76
91
|
*
|
|
77
92
|
* @param event
|
|
78
|
-
* @returns
|
|
79
93
|
*/
|
|
80
94
|
onChange?: (
|
|
81
95
|
event: ChangeEvent<HTMLInputElement> | null,
|
|
82
96
|
value?: string,
|
|
83
97
|
) => void;
|
|
84
98
|
/**
|
|
85
|
-
* Callback function triggered whenever the input field is cleared
|
|
99
|
+
* Callback function triggered whenever the input field is cleared.
|
|
86
100
|
*
|
|
87
101
|
* @param event
|
|
88
|
-
* @returns
|
|
89
102
|
*/
|
|
90
103
|
onClear?: (event: React.PointerEvent | React.KeyboardEvent) => void;
|
|
91
104
|
/**
|
|
92
|
-
* Callback function triggered whenever an option is selected or de-selected
|
|
105
|
+
* Callback function triggered whenever an option is selected or de-selected.
|
|
93
106
|
*
|
|
94
|
-
* @param option
|
|
95
|
-
* @param isSelected
|
|
96
|
-
* @param isCustomOption
|
|
97
|
-
* @returns
|
|
107
|
+
* @param option The option value
|
|
108
|
+
* @param isSelected Whether the option has been selected or unselected
|
|
109
|
+
* @param isCustomOption Whether the option comes from user input, instead of from the list
|
|
98
110
|
*/
|
|
99
111
|
onToggleSelected?: (
|
|
100
|
-
option:
|
|
112
|
+
option: ComboboxOption["value"],
|
|
101
113
|
isSelected: boolean,
|
|
102
114
|
isCustomOption: boolean,
|
|
103
115
|
) => void;
|
|
@@ -107,31 +119,31 @@ export interface ComboboxProps
|
|
|
107
119
|
* Use this prop when controlling the selected state outside for the component,
|
|
108
120
|
* e.g. for a filter, where options can be toggled elsewhere/programmatically.
|
|
109
121
|
*/
|
|
110
|
-
selectedOptions?: string[];
|
|
122
|
+
selectedOptions?: string[] | ComboboxOption[];
|
|
111
123
|
/**
|
|
112
124
|
* Options for the maximum number of selected options.
|
|
113
125
|
*/
|
|
114
126
|
maxSelected?: MaxSelected;
|
|
115
127
|
/**
|
|
116
|
-
* Set to
|
|
128
|
+
* Set to `true` to enable inline autocomplete.
|
|
117
129
|
*
|
|
118
130
|
* @default false
|
|
119
131
|
*/
|
|
120
132
|
shouldAutocomplete?: boolean;
|
|
121
133
|
/**
|
|
122
|
-
* When set to
|
|
134
|
+
* When set to `true` displays selected options as Chips before the input field
|
|
123
135
|
*
|
|
124
136
|
* @default true
|
|
125
137
|
*/
|
|
126
138
|
shouldShowSelectedOptions?: boolean;
|
|
127
139
|
/**
|
|
128
|
-
* When set to
|
|
140
|
+
* When set to `true` displays the toggle button for opening/closing the dropdown list
|
|
129
141
|
*
|
|
130
142
|
* @default true
|
|
131
143
|
*/
|
|
132
144
|
toggleListButton?: boolean;
|
|
133
145
|
/**
|
|
134
|
-
* Custom name for the toggle list-button. Requires "toggleListButton" to be
|
|
146
|
+
* Custom name for the toggle list-button. Requires "toggleListButton" to be `true`.
|
|
135
147
|
*
|
|
136
148
|
* @default "Alternativer"
|
|
137
149
|
*/
|
|
@@ -6,20 +6,20 @@ import ErrorSummaryItem, { ErrorSummaryItemType } from "./ErrorSummaryItem";
|
|
|
6
6
|
|
|
7
7
|
export interface ErrorSummaryProps extends HTMLAttributes<HTMLDivElement> {
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Collection of `ErrorSummary.Item`.
|
|
10
10
|
*/
|
|
11
11
|
children: React.ReactNode;
|
|
12
12
|
/**
|
|
13
|
-
* Changes padding and font-sizes
|
|
13
|
+
* Changes padding and font-sizes.
|
|
14
14
|
* @default "medium"
|
|
15
15
|
*/
|
|
16
16
|
size?: "medium" | "small";
|
|
17
17
|
/**
|
|
18
|
-
* Heading above links
|
|
18
|
+
* Heading above links.
|
|
19
19
|
*/
|
|
20
20
|
heading?: React.ReactNode;
|
|
21
21
|
/**
|
|
22
|
-
* Allows setting a different HTML h-tag
|
|
22
|
+
* Allows setting a different HTML h-tag.
|
|
23
23
|
* @default "h2"
|
|
24
24
|
*/
|
|
25
25
|
headingTag?: React.ElementType<any>;
|
|
@@ -30,7 +30,7 @@ interface ErrorSummaryComponent
|
|
|
30
30
|
ErrorSummaryProps & React.RefAttributes<HTMLDivElement>
|
|
31
31
|
> {
|
|
32
32
|
/**
|
|
33
|
-
* Link to error
|
|
33
|
+
* Link to error.
|
|
34
34
|
*
|
|
35
35
|
* @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
|
|
36
36
|
*
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createContext } from "../../util/create-context";
|
|
2
|
+
import { ComponentTranslation } from "./i18n/i18n.types";
|
|
3
|
+
|
|
4
|
+
export type FileUploadLocaleContextProps = {
|
|
5
|
+
translations?: ComponentTranslation<"FileUpload">;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const [FileUploadLocaleContextProvider, useFileUploadTranslation] =
|
|
9
|
+
createContext<FileUploadLocaleContextProps>();
|