@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
|
@@ -16,7 +16,7 @@ export type MultipleMode = {
|
|
|
16
16
|
min?: number;
|
|
17
17
|
max?: number;
|
|
18
18
|
/**
|
|
19
|
-
* Allows selecting a week at a time. Only used with mode
|
|
19
|
+
* Allows selecting a week at a time. Only used with `mode` is set to "multiple".
|
|
20
20
|
*/
|
|
21
21
|
onWeekNumberClick?: DayPickerBase["onWeekNumberClick"];
|
|
22
22
|
};
|
|
@@ -83,21 +83,22 @@ export interface DatePickerDefaultProps
|
|
|
83
83
|
*/
|
|
84
84
|
showWeekNumber?: boolean;
|
|
85
85
|
/**
|
|
86
|
-
* Open state for user-controlled state. Component controlled by default
|
|
86
|
+
* Open state for user-controlled state. Component controlled by default.
|
|
87
87
|
*/
|
|
88
88
|
open?: boolean;
|
|
89
89
|
/**
|
|
90
|
-
* onClose callback for user-controlled state
|
|
90
|
+
* onClose callback for user-controlled state.
|
|
91
91
|
*/
|
|
92
92
|
onClose?: () => void;
|
|
93
93
|
/**
|
|
94
|
-
* onOpenToggle callback for user-controlled state. Only called if `<DatePicker.Input />` is used
|
|
94
|
+
* onOpenToggle callback for user-controlled state. Only called if `<DatePicker.Input />` is used.
|
|
95
95
|
*/
|
|
96
96
|
onOpenToggle?: () => void;
|
|
97
97
|
/**
|
|
98
|
-
* Avoid using if possible
|
|
98
|
+
* **Avoid using if possible!**
|
|
99
|
+
*
|
|
99
100
|
* 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
|
+
* You want to use "fixed" if parent wrapper has position relative, but you want popover to escape.
|
|
101
102
|
* @default See Popover
|
|
102
103
|
*/
|
|
103
104
|
strategy?: "absolute" | "fixed";
|
|
@@ -49,10 +49,11 @@ export interface UseDatepickerOptions
|
|
|
49
49
|
*/
|
|
50
50
|
onValidate?: (val: DateValidationT) => void;
|
|
51
51
|
/**
|
|
52
|
-
* Allows input of with
|
|
52
|
+
* Allows input of with `yy` year format.
|
|
53
|
+
*
|
|
54
|
+
* Decision between 20th and 21st century is based on before(todays year - 80) ? 21st : 20th.
|
|
55
|
+
* e.g. In 2024 this equals to 1944 - 2043.
|
|
53
56
|
* @default true
|
|
54
|
-
* @Note Decision between 20th and 21st century is based on before(todays year - 80) ? 21st : 20th.
|
|
55
|
-
* In 2024 this equals to 1944 - 2043
|
|
56
57
|
*/
|
|
57
58
|
allowTwoDigitYear?: boolean;
|
|
58
59
|
}
|
|
@@ -36,10 +36,11 @@ export interface UseMonthPickerOptions
|
|
|
36
36
|
*/
|
|
37
37
|
defaultYear?: Date;
|
|
38
38
|
/**
|
|
39
|
-
* Allows input of with
|
|
40
|
-
*
|
|
41
|
-
*
|
|
39
|
+
* Allows input of with `yy` year format.
|
|
40
|
+
*
|
|
41
|
+
* Decision between 20th and 21st century is based on before(todays year - 80) ? 21st : 20th.
|
|
42
42
|
* In 2024 this equals to 1944 - 2043
|
|
43
|
+
* @default true
|
|
43
44
|
*/
|
|
44
45
|
allowTwoDigitYear?: boolean;
|
|
45
46
|
}
|
|
@@ -69,7 +69,8 @@ export interface MonthPickerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
69
69
|
*/
|
|
70
70
|
onYearChange?: (y?: Date) => void;
|
|
71
71
|
/**
|
|
72
|
-
* Avoid using if possible
|
|
72
|
+
* **Avoid using if possible!**
|
|
73
|
+
*
|
|
73
74
|
* Changes what CSS position property to use
|
|
74
75
|
* You want to use "fixed" if parent wrapper has position relative, but you want popover to escape
|
|
75
76
|
* @default "absolute"
|
|
@@ -19,7 +19,7 @@ export interface CheckboxGroupProps
|
|
|
19
19
|
"onChange" | "errorPropagation" | "defaultValue"
|
|
20
20
|
> {
|
|
21
21
|
/**
|
|
22
|
-
* Collection of
|
|
22
|
+
* Collection of `<Checkbox/>`.
|
|
23
23
|
*/
|
|
24
24
|
children: React.ReactNode;
|
|
25
25
|
/**
|
|
@@ -27,11 +27,11 @@ export interface CheckboxGroupProps
|
|
|
27
27
|
*/
|
|
28
28
|
value?: any[];
|
|
29
29
|
/**
|
|
30
|
-
* Default checked checkboxes on render
|
|
30
|
+
* Default checked checkboxes on render.
|
|
31
31
|
*/
|
|
32
32
|
defaultValue?: any[];
|
|
33
33
|
/**
|
|
34
|
-
* Returns current checked checkboxes in group
|
|
34
|
+
* Returns current checked checkboxes in group.
|
|
35
35
|
*/
|
|
36
36
|
onChange?: (value: any[]) => void;
|
|
37
37
|
}
|
|
@@ -5,12 +5,12 @@ export interface CheckboxProps
|
|
|
5
5
|
extends FormFieldProps,
|
|
6
6
|
Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "value"> {
|
|
7
7
|
/**
|
|
8
|
-
* Adds error indication on checkbox
|
|
8
|
+
* Adds error indication on checkbox.
|
|
9
9
|
* @default false
|
|
10
10
|
*/
|
|
11
11
|
error?: boolean;
|
|
12
12
|
/**
|
|
13
|
-
* Id for error resulting in checkbox having error
|
|
13
|
+
* Id for error resulting in checkbox having error.
|
|
14
14
|
*/
|
|
15
15
|
errorId?: string;
|
|
16
16
|
/**
|
|
@@ -26,12 +26,12 @@ export interface CheckboxProps
|
|
|
26
26
|
*/
|
|
27
27
|
value?: any;
|
|
28
28
|
/**
|
|
29
|
-
* Specify whether the Checkbox is in an indeterminate state
|
|
29
|
+
* Specify whether the Checkbox is in an indeterminate state.
|
|
30
30
|
* @default false
|
|
31
31
|
*/
|
|
32
32
|
indeterminate?: boolean;
|
|
33
33
|
/**
|
|
34
|
-
* Adds a description to extend labling of Checkbox
|
|
34
|
+
* Adds a description to extend labling of Checkbox.
|
|
35
35
|
*/
|
|
36
36
|
description?: string;
|
|
37
37
|
}
|
|
@@ -3,6 +3,7 @@ import Combobox from "./Combobox";
|
|
|
3
3
|
import { FilteredOptionsProvider } from "./FilteredOptions/filteredOptionsContext";
|
|
4
4
|
import { InputContextProvider } from "./Input/inputContext";
|
|
5
5
|
import { SelectedOptionsProvider } from "./SelectedOptions/selectedOptionsContext";
|
|
6
|
+
import { mapToComboboxOptionArray } from "./combobox-utils";
|
|
6
7
|
import { CustomOptionsProvider } from "./customOptionsContext";
|
|
7
8
|
import { ComboboxProps } from "./types";
|
|
8
9
|
|
|
@@ -36,15 +37,15 @@ const ComboboxProvider = forwardRef<HTMLInputElement, ComboboxProps>(
|
|
|
36
37
|
defaultValue,
|
|
37
38
|
error,
|
|
38
39
|
errorId,
|
|
39
|
-
filteredOptions,
|
|
40
|
+
filteredOptions: externalFilteredOptions,
|
|
40
41
|
id,
|
|
41
42
|
isListOpen,
|
|
42
43
|
isLoading = false,
|
|
43
44
|
isMultiSelect,
|
|
44
45
|
onToggleSelected,
|
|
45
|
-
selectedOptions,
|
|
46
|
+
selectedOptions: externalSelectedOptions,
|
|
46
47
|
maxSelected,
|
|
47
|
-
options,
|
|
48
|
+
options: externalOptions,
|
|
48
49
|
value,
|
|
49
50
|
onChange,
|
|
50
51
|
onClear,
|
|
@@ -52,6 +53,9 @@ const ComboboxProvider = forwardRef<HTMLInputElement, ComboboxProps>(
|
|
|
52
53
|
size,
|
|
53
54
|
...rest
|
|
54
55
|
} = props;
|
|
56
|
+
const options = mapToComboboxOptionArray(externalOptions) || [];
|
|
57
|
+
const filteredOptions = mapToComboboxOptionArray(externalFilteredOptions);
|
|
58
|
+
const selectedOptions = mapToComboboxOptionArray(externalSelectedOptions);
|
|
55
59
|
return (
|
|
56
60
|
<InputContextProvider
|
|
57
61
|
value={{
|
|
@@ -5,6 +5,8 @@ import { Loader } from "../../../loader";
|
|
|
5
5
|
import { BodyShort, Label } from "../../../typography";
|
|
6
6
|
import { useInputContext } from "../Input/inputContext";
|
|
7
7
|
import { useSelectedOptionsContext } from "../SelectedOptions/selectedOptionsContext";
|
|
8
|
+
import { isInList, toComboboxOption } from "../combobox-utils";
|
|
9
|
+
import { ComboboxOption } from "../types";
|
|
8
10
|
import filteredOptionsUtil from "./filtered-options-util";
|
|
9
11
|
import { useFilteredOptionsContext } from "./filteredOptionsContext";
|
|
10
12
|
|
|
@@ -30,8 +32,8 @@ const FilteredOptions = () => {
|
|
|
30
32
|
const { isMultiSelect, selectedOptions, toggleOption, maxSelected } =
|
|
31
33
|
useSelectedOptionsContext();
|
|
32
34
|
|
|
33
|
-
const isDisabled = (option) =>
|
|
34
|
-
maxSelected?.isLimitReached && !
|
|
35
|
+
const isDisabled = (option: ComboboxOption) =>
|
|
36
|
+
maxSelected?.isLimitReached && !isInList(option.value, selectedOptions);
|
|
35
37
|
|
|
36
38
|
const shouldRenderNonSelectables =
|
|
37
39
|
maxSelected?.isLimitReached || // Render maxSelected message
|
|
@@ -102,8 +104,8 @@ const FilteredOptions = () => {
|
|
|
102
104
|
}
|
|
103
105
|
}}
|
|
104
106
|
onPointerUp={(event) => {
|
|
105
|
-
toggleOption(value, event);
|
|
106
|
-
if (!isMultiSelect && !
|
|
107
|
+
toggleOption(toComboboxOption(value), event);
|
|
108
|
+
if (!isMultiSelect && !isInList(value, selectedOptions))
|
|
107
109
|
toggleIsListOpen(false);
|
|
108
110
|
}}
|
|
109
111
|
id={filteredOptionsUtil.getAddNewOptionId(id)}
|
|
@@ -132,21 +134,23 @@ const FilteredOptions = () => {
|
|
|
132
134
|
className={cl("navds-combobox__list-item", {
|
|
133
135
|
"navds-combobox__list-item--focus":
|
|
134
136
|
activeDecendantId ===
|
|
135
|
-
filteredOptionsUtil.getOptionId(id, option),
|
|
136
|
-
"navds-combobox__list-item--selected":
|
|
137
|
-
|
|
137
|
+
filteredOptionsUtil.getOptionId(id, option.label),
|
|
138
|
+
"navds-combobox__list-item--selected": isInList(
|
|
139
|
+
option.value,
|
|
140
|
+
selectedOptions,
|
|
141
|
+
),
|
|
138
142
|
})}
|
|
139
143
|
data-no-focus={isDisabled(option) || undefined}
|
|
140
|
-
id={filteredOptionsUtil.getOptionId(id, option)}
|
|
141
|
-
key={option}
|
|
144
|
+
id={filteredOptionsUtil.getOptionId(id, option.label)}
|
|
145
|
+
key={option.label}
|
|
142
146
|
tabIndex={-1}
|
|
143
147
|
onMouseMove={() => {
|
|
144
148
|
if (
|
|
145
149
|
activeDecendantId !==
|
|
146
|
-
filteredOptionsUtil.getOptionId(id, option)
|
|
150
|
+
filteredOptionsUtil.getOptionId(id, option.label)
|
|
147
151
|
) {
|
|
148
152
|
virtualFocus.moveFocusToElement(
|
|
149
|
-
filteredOptionsUtil.getOptionId(id, option),
|
|
153
|
+
filteredOptionsUtil.getOptionId(id, option.label),
|
|
150
154
|
);
|
|
151
155
|
setIsMouseLastUsedInputDevice(true);
|
|
152
156
|
}
|
|
@@ -156,16 +160,19 @@ const FilteredOptions = () => {
|
|
|
156
160
|
return;
|
|
157
161
|
}
|
|
158
162
|
toggleOption(option, event);
|
|
159
|
-
if (
|
|
163
|
+
if (
|
|
164
|
+
!isMultiSelect &&
|
|
165
|
+
!isInList(option.value, selectedOptions)
|
|
166
|
+
) {
|
|
160
167
|
toggleIsListOpen(false);
|
|
161
168
|
}
|
|
162
169
|
}}
|
|
163
170
|
role="option"
|
|
164
|
-
aria-selected={
|
|
171
|
+
aria-selected={isInList(option.value, selectedOptions)}
|
|
165
172
|
aria-disabled={isDisabled(option) || undefined}
|
|
166
173
|
>
|
|
167
|
-
<BodyShort size={size}>{option}</BodyShort>
|
|
168
|
-
{
|
|
174
|
+
<BodyShort size={size}>{option.label}</BodyShort>
|
|
175
|
+
{isInList(option.value, selectedOptions) && <CheckmarkIcon />}
|
|
169
176
|
</li>
|
|
170
177
|
))}
|
|
171
178
|
</ul>
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
+
import { ComboboxOption } from "../types";
|
|
2
|
+
|
|
1
3
|
const normalizeText = (text: string): string =>
|
|
2
4
|
typeof text === "string" ? text.toLocaleLowerCase().trim() : "";
|
|
3
5
|
|
|
4
|
-
const isPartOfText = (value, text) =>
|
|
6
|
+
const isPartOfText = (value: string, text: string) =>
|
|
5
7
|
normalizeText(text).startsWith(normalizeText(value ?? ""));
|
|
6
8
|
|
|
7
|
-
const
|
|
8
|
-
list
|
|
9
|
-
|
|
10
|
-
const getMatchingValuesFromList = (value, list, alwaysIncluded) =>
|
|
11
|
-
list?.filter(
|
|
12
|
-
(listItem) =>
|
|
13
|
-
isPartOfText(value, listItem) || alwaysIncluded.includes(listItem),
|
|
14
|
-
);
|
|
9
|
+
const getMatchingValuesFromList = (value: string, list: ComboboxOption[]) =>
|
|
10
|
+
list.filter((listItem) => isPartOfText(value, listItem.label));
|
|
15
11
|
|
|
16
12
|
const getFilteredOptionsId = (comboboxId: string) =>
|
|
17
13
|
`${comboboxId}-filtered-options`;
|
|
@@ -34,7 +30,6 @@ const getMaxSelectedOptionsId = (comboboxId: string) =>
|
|
|
34
30
|
export default {
|
|
35
31
|
normalizeText,
|
|
36
32
|
isPartOfText,
|
|
37
|
-
isValueInList,
|
|
38
33
|
getMatchingValuesFromList,
|
|
39
34
|
getFilteredOptionsId,
|
|
40
35
|
getAddNewOptionId,
|
|
@@ -10,21 +10,18 @@ import React, {
|
|
|
10
10
|
import { useClientLayoutEffect, usePrevious } from "../../../util/hooks";
|
|
11
11
|
import { useInputContext } from "../Input/inputContext";
|
|
12
12
|
import { useSelectedOptionsContext } from "../SelectedOptions/selectedOptionsContext";
|
|
13
|
+
import { toComboboxOption } from "../combobox-utils";
|
|
13
14
|
import { useCustomOptionsContext } from "../customOptionsContext";
|
|
14
|
-
import { ComboboxProps } from "../types";
|
|
15
|
+
import { ComboboxOption, ComboboxProps } from "../types";
|
|
15
16
|
import filteredOptionsUtils from "./filtered-options-util";
|
|
16
17
|
import useVirtualFocus, { VirtualFocusType } from "./useVirtualFocus";
|
|
17
18
|
|
|
18
19
|
type FilteredOptionsProps = {
|
|
19
|
-
children:
|
|
20
|
-
value: Pick<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
| "isListOpen"
|
|
25
|
-
| "isLoading"
|
|
26
|
-
| "options"
|
|
27
|
-
>;
|
|
20
|
+
children: React.ReactNode;
|
|
21
|
+
value: Pick<ComboboxProps, "allowNewValues" | "isListOpen" | "isLoading"> & {
|
|
22
|
+
filteredOptions?: ComboboxOption[];
|
|
23
|
+
options: ComboboxOption[];
|
|
24
|
+
};
|
|
28
25
|
};
|
|
29
26
|
|
|
30
27
|
type FilteredOptionsContextType = {
|
|
@@ -36,12 +33,12 @@ type FilteredOptionsContextType = {
|
|
|
36
33
|
>;
|
|
37
34
|
isListOpen: boolean;
|
|
38
35
|
isLoading?: boolean;
|
|
39
|
-
filteredOptions:
|
|
36
|
+
filteredOptions: ComboboxOption[];
|
|
40
37
|
isMouseLastUsedInputDevice: boolean;
|
|
41
38
|
setIsMouseLastUsedInputDevice: React.Dispatch<SetStateAction<boolean>>;
|
|
42
39
|
isValueNew: boolean;
|
|
43
40
|
toggleIsListOpen: (newState?: boolean) => void;
|
|
44
|
-
currentOption?:
|
|
41
|
+
currentOption?: ComboboxOption;
|
|
45
42
|
shouldAutocomplete?: boolean;
|
|
46
43
|
virtualFocus: VirtualFocusType;
|
|
47
44
|
};
|
|
@@ -71,7 +68,7 @@ export const FilteredOptionsProvider = ({
|
|
|
71
68
|
setSearchTerm,
|
|
72
69
|
shouldAutocomplete,
|
|
73
70
|
} = useInputContext();
|
|
74
|
-
const {
|
|
71
|
+
const { maxSelected } = useSelectedOptionsContext();
|
|
75
72
|
|
|
76
73
|
const [isInternalListOpen, setInternalListOpen] = useState(false);
|
|
77
74
|
const { customOptions } = useCustomOptionsContext();
|
|
@@ -81,18 +78,8 @@ export const FilteredOptionsProvider = ({
|
|
|
81
78
|
return externalFilteredOptions;
|
|
82
79
|
}
|
|
83
80
|
const opts = [...customOptions, ...options];
|
|
84
|
-
return filteredOptionsUtils.getMatchingValuesFromList(
|
|
85
|
-
|
|
86
|
-
opts,
|
|
87
|
-
selectedOptions,
|
|
88
|
-
);
|
|
89
|
-
}, [
|
|
90
|
-
customOptions,
|
|
91
|
-
externalFilteredOptions,
|
|
92
|
-
options,
|
|
93
|
-
searchTerm,
|
|
94
|
-
selectedOptions,
|
|
95
|
-
]);
|
|
81
|
+
return filteredOptionsUtils.getMatchingValuesFromList(searchTerm, opts);
|
|
82
|
+
}, [customOptions, externalFilteredOptions, options, searchTerm]);
|
|
96
83
|
|
|
97
84
|
const previousSearchTerm = usePrevious(searchTerm);
|
|
98
85
|
|
|
@@ -104,11 +91,11 @@ export const FilteredOptionsProvider = ({
|
|
|
104
91
|
options.reduce(
|
|
105
92
|
(map, _option) => ({
|
|
106
93
|
...map,
|
|
107
|
-
[filteredOptionsUtils.getOptionId(id, _option)]: _option,
|
|
94
|
+
[filteredOptionsUtils.getOptionId(id, _option.label)]: _option,
|
|
108
95
|
}),
|
|
109
96
|
{
|
|
110
97
|
[filteredOptionsUtils.getAddNewOptionId(id)]: allowNewValues
|
|
111
|
-
? value
|
|
98
|
+
? toComboboxOption(value)
|
|
112
99
|
: undefined,
|
|
113
100
|
},
|
|
114
101
|
),
|
|
@@ -123,7 +110,7 @@ export const FilteredOptionsProvider = ({
|
|
|
123
110
|
filteredOptions.length > 0
|
|
124
111
|
) {
|
|
125
112
|
setValue(
|
|
126
|
-
`${searchTerm}${filteredOptions[0].substring(searchTerm.length)}`,
|
|
113
|
+
`${searchTerm}${filteredOptions[0].label.substring(searchTerm.length)}`,
|
|
127
114
|
);
|
|
128
115
|
setSearchTerm(searchTerm);
|
|
129
116
|
}
|
|
@@ -161,7 +148,10 @@ export const FilteredOptionsProvider = ({
|
|
|
161
148
|
activeOption = filteredOptionsUtils.getNoHitsId(id);
|
|
162
149
|
} else if ((value && value !== "") || isLoading) {
|
|
163
150
|
if (shouldAutocomplete && filteredOptions[0]) {
|
|
164
|
-
activeOption = filteredOptionsUtils.getOptionId(
|
|
151
|
+
activeOption = filteredOptionsUtils.getOptionId(
|
|
152
|
+
id,
|
|
153
|
+
filteredOptions[0].label,
|
|
154
|
+
);
|
|
165
155
|
} else if (isListOpen && isLoading) {
|
|
166
156
|
activeOption = filteredOptionsUtils.getIsLoadingId(id);
|
|
167
157
|
}
|
|
@@ -43,17 +43,17 @@ const Input = forwardRef<HTMLInputElement, InputProps>(
|
|
|
43
43
|
|
|
44
44
|
const onEnter = useCallback(
|
|
45
45
|
(event: React.KeyboardEvent) => {
|
|
46
|
-
const isTextInSelectedOptions = (text: string) =>
|
|
47
|
-
|
|
48
|
-
(
|
|
46
|
+
const isTextInSelectedOptions = (text: string) =>
|
|
47
|
+
selectedOptions.some(
|
|
48
|
+
(option) =>
|
|
49
|
+
option.label.toLocaleLowerCase() === text.toLocaleLowerCase(),
|
|
49
50
|
);
|
|
50
|
-
};
|
|
51
51
|
|
|
52
52
|
if (currentOption) {
|
|
53
53
|
event.preventDefault();
|
|
54
54
|
// Selecting a value from the dropdown / FilteredOptions
|
|
55
55
|
toggleOption(currentOption, event);
|
|
56
|
-
if (!isMultiSelect && !isTextInSelectedOptions(currentOption)) {
|
|
56
|
+
if (!isMultiSelect && !isTextInSelectedOptions(currentOption.label)) {
|
|
57
57
|
toggleIsListOpen(false);
|
|
58
58
|
}
|
|
59
59
|
} else if (shouldAutocomplete && isTextInSelectedOptions(value)) {
|
|
@@ -64,11 +64,15 @@ const Input = forwardRef<HTMLInputElement, InputProps>(
|
|
|
64
64
|
event.preventDefault();
|
|
65
65
|
// Autocompleting or adding a new value
|
|
66
66
|
const selectedValue =
|
|
67
|
-
allowNewValues && isValueNew
|
|
67
|
+
allowNewValues && isValueNew
|
|
68
|
+
? { label: value, value }
|
|
69
|
+
: filteredOptions[0];
|
|
68
70
|
toggleOption(selectedValue, event);
|
|
69
71
|
if (
|
|
70
72
|
!isMultiSelect &&
|
|
71
|
-
!isTextInSelectedOptions(
|
|
73
|
+
!isTextInSelectedOptions(
|
|
74
|
+
filteredOptions[0].label || selectedValue.label,
|
|
75
|
+
)
|
|
72
76
|
) {
|
|
73
77
|
toggleIsListOpen(false);
|
|
74
78
|
}
|
|
@@ -120,7 +124,9 @@ const Input = forwardRef<HTMLInputElement, InputProps>(
|
|
|
120
124
|
if (value === "") {
|
|
121
125
|
const lastSelectedOption =
|
|
122
126
|
selectedOptions[selectedOptions.length - 1];
|
|
123
|
-
|
|
127
|
+
if (lastSelectedOption) {
|
|
128
|
+
removeSelectedOption(lastSelectedOption);
|
|
129
|
+
}
|
|
124
130
|
}
|
|
125
131
|
} else if (e.key === "ArrowDown") {
|
|
126
132
|
// Check that cursor position is at the end of the input field,
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Chips } from "../../../chips";
|
|
3
3
|
import { useInputContext } from "../Input/inputContext";
|
|
4
|
+
import { ComboboxOption } from "../types";
|
|
4
5
|
import { useSelectedOptionsContext } from "./selectedOptionsContext";
|
|
5
6
|
|
|
6
7
|
interface SelectedOptionsProps {
|
|
7
|
-
selectedOptions?:
|
|
8
|
+
selectedOptions?: ComboboxOption[];
|
|
8
9
|
size?: "medium" | "small";
|
|
9
10
|
children: React.ReactNode;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
const Option = ({ option }: { option:
|
|
13
|
+
const Option = ({ option }: { option: ComboboxOption }) => {
|
|
13
14
|
const { isMultiSelect, removeSelectedOption } = useSelectedOptionsContext();
|
|
14
15
|
const { focusInput } = useInputContext();
|
|
15
16
|
|
|
@@ -21,11 +22,13 @@ const Option = ({ option }: { option: string }) => {
|
|
|
21
22
|
|
|
22
23
|
if (!isMultiSelect) {
|
|
23
24
|
return (
|
|
24
|
-
<div className="navds-combobox__selected-options--no-bg">
|
|
25
|
+
<div className="navds-combobox__selected-options--no-bg">
|
|
26
|
+
{option.label}
|
|
27
|
+
</div>
|
|
25
28
|
);
|
|
26
29
|
}
|
|
27
30
|
|
|
28
|
-
return <Chips.Removable onClick={onClick}>{option}</Chips.Removable>;
|
|
31
|
+
return <Chips.Removable onClick={onClick}>{option.label}</Chips.Removable>;
|
|
29
32
|
};
|
|
30
33
|
|
|
31
34
|
const SelectedOptions: React.FC<SelectedOptionsProps> = ({
|
|
@@ -37,7 +40,7 @@ const SelectedOptions: React.FC<SelectedOptionsProps> = ({
|
|
|
37
40
|
<Chips className="navds-combobox__selected-options" size={size}>
|
|
38
41
|
{selectedOptions.length
|
|
39
42
|
? selectedOptions.map((option, i) => (
|
|
40
|
-
<Option key={option + i} option={option} />
|
|
43
|
+
<Option key={option.label + i} option={option} />
|
|
41
44
|
))
|
|
42
45
|
: []}
|
|
43
46
|
{children}
|
|
@@ -7,19 +7,20 @@ import React, {
|
|
|
7
7
|
} from "react";
|
|
8
8
|
import { usePrevious } from "../../../util/hooks";
|
|
9
9
|
import { useInputContext } from "../Input/inputContext";
|
|
10
|
+
import { isInList } from "../combobox-utils";
|
|
10
11
|
import { useCustomOptionsContext } from "../customOptionsContext";
|
|
11
|
-
import { ComboboxProps, MaxSelected } from "../types";
|
|
12
|
+
import { ComboboxOption, ComboboxProps, MaxSelected } from "../types";
|
|
12
13
|
|
|
13
14
|
type SelectedOptionsContextType = {
|
|
14
|
-
addSelectedOption: (option:
|
|
15
|
+
addSelectedOption: (option: ComboboxOption) => void;
|
|
15
16
|
isMultiSelect?: boolean;
|
|
16
|
-
removeSelectedOption: (option:
|
|
17
|
-
prevSelectedOptions?:
|
|
18
|
-
selectedOptions:
|
|
17
|
+
removeSelectedOption: (option: ComboboxOption) => void;
|
|
18
|
+
prevSelectedOptions?: ComboboxOption[];
|
|
19
|
+
selectedOptions: ComboboxOption[];
|
|
19
20
|
maxSelected?: MaxSelected & { isLimitReached: boolean };
|
|
20
21
|
setSelectedOptions: (any) => void;
|
|
21
22
|
toggleOption: (
|
|
22
|
-
option:
|
|
23
|
+
option: ComboboxOption,
|
|
23
24
|
event: React.KeyboardEvent | React.PointerEvent,
|
|
24
25
|
) => void;
|
|
25
26
|
};
|
|
@@ -35,13 +36,8 @@ export const SelectedOptionsProvider = ({
|
|
|
35
36
|
children: any;
|
|
36
37
|
value: Pick<
|
|
37
38
|
ComboboxProps,
|
|
38
|
-
| "
|
|
39
|
-
|
|
40
|
-
| "options"
|
|
41
|
-
| "selectedOptions"
|
|
42
|
-
| "onToggleSelected"
|
|
43
|
-
| "maxSelected"
|
|
44
|
-
>;
|
|
39
|
+
"allowNewValues" | "isMultiSelect" | "onToggleSelected" | "maxSelected"
|
|
40
|
+
> & { options: ComboboxOption[]; selectedOptions?: ComboboxOption[] };
|
|
45
41
|
}) => {
|
|
46
42
|
const { clearInput, focusInput } = useInputContext();
|
|
47
43
|
const {
|
|
@@ -58,7 +54,9 @@ export const SelectedOptionsProvider = ({
|
|
|
58
54
|
options,
|
|
59
55
|
maxSelected,
|
|
60
56
|
} = value;
|
|
61
|
-
const [internalSelectedOptions, setSelectedOptions] = useState<
|
|
57
|
+
const [internalSelectedOptions, setSelectedOptions] = useState<
|
|
58
|
+
ComboboxOption[]
|
|
59
|
+
>([]);
|
|
62
60
|
const selectedOptions = useMemo(
|
|
63
61
|
() =>
|
|
64
62
|
externalSelectedOptions ?? [...customOptions, ...internalSelectedOptions],
|
|
@@ -66,10 +64,8 @@ export const SelectedOptionsProvider = ({
|
|
|
66
64
|
);
|
|
67
65
|
|
|
68
66
|
const addSelectedOption = useCallback(
|
|
69
|
-
(option:
|
|
70
|
-
const isCustomOption = !options
|
|
71
|
-
.map((opt) => opt.toLowerCase())
|
|
72
|
-
.includes(option?.toLowerCase?.());
|
|
67
|
+
(option: ComboboxOption) => {
|
|
68
|
+
const isCustomOption = !isInList(option, options);
|
|
73
69
|
if (isCustomOption) {
|
|
74
70
|
allowNewValues && addCustomOption(option);
|
|
75
71
|
!isMultiSelect && setSelectedOptions([]);
|
|
@@ -82,7 +78,7 @@ export const SelectedOptionsProvider = ({
|
|
|
82
78
|
setSelectedOptions([option]);
|
|
83
79
|
setCustomOptions([]);
|
|
84
80
|
}
|
|
85
|
-
onToggleSelected?.(option, true, isCustomOption);
|
|
81
|
+
onToggleSelected?.(option.value, true, isCustomOption);
|
|
86
82
|
},
|
|
87
83
|
[
|
|
88
84
|
addCustomOption,
|
|
@@ -95,8 +91,8 @@ export const SelectedOptionsProvider = ({
|
|
|
95
91
|
);
|
|
96
92
|
|
|
97
93
|
const removeSelectedOption = useCallback(
|
|
98
|
-
(option:
|
|
99
|
-
const isCustomOption =
|
|
94
|
+
(option: ComboboxOption) => {
|
|
95
|
+
const isCustomOption = isInList(option, customOptions);
|
|
100
96
|
if (isCustomOption) {
|
|
101
97
|
removeCustomOption(option);
|
|
102
98
|
} else {
|
|
@@ -106,14 +102,17 @@ export const SelectedOptionsProvider = ({
|
|
|
106
102
|
),
|
|
107
103
|
);
|
|
108
104
|
}
|
|
109
|
-
onToggleSelected?.(option, false, isCustomOption);
|
|
105
|
+
onToggleSelected?.(option.value, false, isCustomOption);
|
|
110
106
|
},
|
|
111
107
|
[customOptions, onToggleSelected, removeCustomOption],
|
|
112
108
|
);
|
|
113
109
|
|
|
114
110
|
const toggleOption = useCallback(
|
|
115
|
-
(
|
|
116
|
-
|
|
111
|
+
(
|
|
112
|
+
option: ComboboxOption,
|
|
113
|
+
event: React.KeyboardEvent | React.PointerEvent,
|
|
114
|
+
) => {
|
|
115
|
+
if (isInList(option.value, selectedOptions)) {
|
|
117
116
|
removeSelectedOption(option);
|
|
118
117
|
} else {
|
|
119
118
|
addSelectedOption(option);
|
|
@@ -130,7 +129,7 @@ export const SelectedOptionsProvider = ({
|
|
|
130
129
|
],
|
|
131
130
|
);
|
|
132
131
|
|
|
133
|
-
const prevSelectedOptions = usePrevious<
|
|
132
|
+
const prevSelectedOptions = usePrevious<ComboboxOption[]>(selectedOptions);
|
|
134
133
|
|
|
135
134
|
const isLimitReached =
|
|
136
135
|
!!maxSelected?.limit && selectedOptions.length >= maxSelected.limit;
|