@navikt/ds-react 6.0.0-alpha.2 → 6.0.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_docs.json +520 -60
- package/cjs/chat/Bubble.d.ts +0 -5
- package/cjs/chat/Bubble.js +2 -2
- package/cjs/chat/Bubble.js.map +1 -1
- package/cjs/chat/Chat.d.ts +0 -10
- package/cjs/chat/Chat.js +3 -3
- package/cjs/chat/Chat.js.map +1 -1
- package/cjs/date/context/useSharedMonthContext.js +2 -6
- package/cjs/date/context/useSharedMonthContext.js.map +1 -1
- package/cjs/date/datepicker/DatePicker.js +3 -5
- package/cjs/date/datepicker/DatePicker.js.map +1 -1
- package/cjs/date/datepicker/DatePickerStandalone.js +3 -5
- package/cjs/date/datepicker/DatePickerStandalone.js.map +1 -1
- package/cjs/date/datepicker/parts/DayButton.js +2 -5
- package/cjs/date/datepicker/parts/DayButton.js.map +1 -1
- package/cjs/date/datepicker/parts/DropdownCaption.js +3 -6
- package/cjs/date/datepicker/parts/DropdownCaption.js.map +1 -1
- package/cjs/date/datepicker/parts/Row.js +2 -1
- package/cjs/date/datepicker/parts/Row.js.map +1 -1
- package/cjs/date/hooks/useDatepicker.d.ts +1 -6
- package/cjs/date/hooks/useDatepicker.js +7 -11
- package/cjs/date/hooks/useDatepicker.js.map +1 -1
- package/cjs/date/hooks/useMonthPicker.d.ts +1 -6
- package/cjs/date/hooks/useMonthPicker.js.map +1 -1
- package/cjs/date/hooks/useRangeDatepicker.js +20 -25
- package/cjs/date/hooks/useRangeDatepicker.js.map +1 -1
- package/cjs/date/monthpicker/MonthButton.js +11 -15
- package/cjs/date/monthpicker/MonthButton.js.map +1 -1
- package/cjs/date/monthpicker/MonthCaption.js +4 -7
- package/cjs/date/monthpicker/MonthCaption.js.map +1 -1
- package/cjs/date/monthpicker/MonthPicker.js +7 -1
- package/cjs/date/monthpicker/MonthPicker.js.map +1 -1
- package/cjs/date/monthpicker/MonthPickerStandalone.js +7 -1
- package/cjs/date/monthpicker/MonthPickerStandalone.js.map +1 -1
- package/cjs/date/monthpicker/MonthSelector.js +8 -11
- package/cjs/date/monthpicker/MonthSelector.js.map +1 -1
- package/cjs/date/parts/DateInput.d.ts +1 -1
- package/cjs/date/utils/check-dates.js +2 -6
- package/cjs/date/utils/check-dates.js.map +1 -1
- package/cjs/date/utils/dates-disabled.js +3 -6
- package/cjs/date/utils/dates-disabled.js.map +1 -1
- package/cjs/date/utils/format-date.d.ts +1 -0
- package/cjs/date/utils/format-date.js +2 -5
- package/cjs/date/utils/format-date.js.map +1 -1
- package/cjs/date/utils/get-dates.js +14 -21
- package/cjs/date/utils/get-dates.js.map +1 -1
- package/cjs/date/utils/get-initial-year.js +2 -5
- package/cjs/date/utils/get-initial-year.js.map +1 -1
- package/cjs/date/utils/is-match.js +14 -20
- package/cjs/date/utils/is-match.js.map +1 -1
- package/cjs/date/utils/labels.d.ts +1 -0
- package/cjs/date/utils/labels.js.map +1 -1
- package/cjs/date/utils/locale.d.ts +1 -1
- package/cjs/date/utils/locale.js +4 -9
- package/cjs/date/utils/locale.js.map +1 -1
- package/cjs/date/utils/navigation.js +21 -24
- package/cjs/date/utils/navigation.js.map +1 -1
- package/cjs/date/utils/parse-date.d.ts +1 -0
- package/cjs/date/utils/parse-date.js +8 -13
- package/cjs/date/utils/parse-date.js.map +1 -1
- package/cjs/form/Textarea.js +8 -8
- package/cjs/form/Textarea.js.map +1 -1
- package/cjs/form/combobox/Combobox.js +1 -1
- package/cjs/form/combobox/Combobox.js.map +1 -1
- package/cjs/form/combobox/ComboboxProvider.js +2 -1
- package/cjs/form/combobox/ComboboxProvider.js.map +1 -1
- package/cjs/form/combobox/ComboboxWrapper.js +1 -1
- package/cjs/form/combobox/ComboboxWrapper.js.map +1 -1
- package/cjs/form/combobox/FilteredOptions/FilteredOptions.js +59 -41
- package/cjs/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
- package/cjs/form/combobox/FilteredOptions/filtered-options-util.d.ts +2 -1
- package/cjs/form/combobox/FilteredOptions/filtered-options-util.js +3 -1
- package/cjs/form/combobox/FilteredOptions/filtered-options-util.js.map +1 -1
- package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js +15 -3
- package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
- package/cjs/form/combobox/FilteredOptions/useVirtualFocus.d.ts +2 -4
- package/cjs/form/combobox/FilteredOptions/useVirtualFocus.js +52 -32
- package/cjs/form/combobox/FilteredOptions/useVirtualFocus.js.map +1 -1
- package/cjs/form/combobox/Input/Input.js +3 -1
- package/cjs/form/combobox/Input/Input.js.map +1 -1
- package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.d.ts +5 -2
- package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.js +3 -1
- package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.js.map +1 -1
- package/cjs/form/combobox/types.d.ts +14 -0
- package/cjs/form/error-summary/ErrorSummary.d.ts +9 -3
- package/cjs/form/error-summary/ErrorSummary.js +4 -9
- package/cjs/form/error-summary/ErrorSummary.js.map +1 -1
- package/cjs/form/error-summary/ErrorSummaryItem.d.ts +1 -1
- package/cjs/form/error-summary/ErrorSummaryItem.js +2 -1
- package/cjs/form/error-summary/ErrorSummaryItem.js.map +1 -1
- package/cjs/form/search/Search.d.ts +1 -0
- package/cjs/form/search/Search.js +2 -2
- package/cjs/form/search/Search.js.map +1 -1
- package/cjs/index.d.ts +1 -2
- package/cjs/index.js +1 -3
- package/cjs/index.js.map +1 -1
- package/cjs/layout/bleed/Bleed.d.ts +2 -2
- package/cjs/layout/utilities/css.js +4 -0
- package/cjs/layout/utilities/css.js.map +1 -1
- package/cjs/layout/utilities/types.d.ts +1 -1
- package/cjs/overlays/index.d.ts +2 -0
- package/cjs/overlays/index.js +6 -0
- package/cjs/overlays/index.js.map +1 -0
- package/cjs/overlays/portal/Portal.d.ts +11 -0
- package/cjs/{grid/Grid.js → overlays/portal/Portal.js} +15 -11
- package/cjs/overlays/portal/Portal.js.map +1 -0
- package/cjs/tabs/TabList.js +2 -2
- package/cjs/tabs/TabList.js.map +1 -1
- package/cjs/tabs/TabPanel.js +2 -2
- package/cjs/tabs/TabPanel.js.map +1 -1
- package/cjs/timeline/AxisLabels.js +4 -4
- package/cjs/timeline/AxisLabels.js.map +1 -1
- package/cjs/tooltip/Tooltip.js +3 -7
- package/cjs/tooltip/Tooltip.js.map +1 -1
- package/cjs/util/Slot.js +5 -2
- package/cjs/util/Slot.js.map +1 -1
- package/cjs/util/TextareaAutoSize.js +14 -24
- package/cjs/util/TextareaAutoSize.js.map +1 -1
- package/cjs/util/types/AsChildProps.d.ts +36 -0
- package/cjs/util/types/AsChildProps.js +3 -0
- package/cjs/util/types/AsChildProps.js.map +1 -0
- package/cjs/util/types/index.d.ts +1 -0
- package/esm/accordion/Accordion.d.ts +3 -3
- package/esm/accordion/Accordion.js +4 -4
- package/esm/accordion/AccordionContent.js +2 -2
- package/esm/accordion/AccordionHeader.js +4 -4
- package/esm/accordion/AccordionItem.js +3 -3
- package/esm/accordion/index.d.ts +1 -1
- package/esm/accordion/index.js +1 -1
- package/esm/alert/Alert.js +2 -2
- package/esm/alert/index.d.ts +2 -2
- package/esm/alert/index.js +1 -1
- package/esm/button/Button.d.ts +1 -1
- package/esm/button/Button.js +6 -6
- package/esm/button/index.d.ts +2 -2
- package/esm/button/index.js +1 -1
- package/esm/chat/Bubble.d.ts +0 -5
- package/esm/chat/Bubble.js +3 -3
- package/esm/chat/Bubble.js.map +1 -1
- package/esm/chat/Chat.d.ts +1 -11
- package/esm/chat/Chat.js +5 -5
- package/esm/chat/Chat.js.map +1 -1
- package/esm/chat/index.d.ts +1 -1
- package/esm/chat/index.js +1 -1
- package/esm/chips/Chips.d.ts +3 -3
- package/esm/chips/Chips.js +2 -2
- package/esm/chips/Removable.js +1 -1
- package/esm/chips/Toggle.d.ts +1 -1
- package/esm/chips/index.d.ts +1 -1
- package/esm/chips/index.js +1 -1
- package/esm/copybutton/CopyButton.js +3 -3
- package/esm/copybutton/index.d.ts +1 -1
- package/esm/copybutton/index.js +1 -1
- package/esm/date/context/index.d.ts +2 -2
- package/esm/date/context/index.js +2 -2
- package/esm/date/context/useSharedMonthContext.d.ts +1 -1
- package/esm/date/context/useSharedMonthContext.js +2 -3
- package/esm/date/context/useSharedMonthContext.js.map +1 -1
- package/esm/date/datepicker/DatePicker.d.ts +3 -3
- package/esm/date/datepicker/DatePicker.js +15 -17
- package/esm/date/datepicker/DatePicker.js.map +1 -1
- package/esm/date/datepicker/DatePickerStandalone.d.ts +1 -1
- package/esm/date/datepicker/DatePickerStandalone.js +9 -11
- package/esm/date/datepicker/DatePickerStandalone.js.map +1 -1
- package/esm/date/datepicker/parts/Caption.js +3 -3
- package/esm/date/datepicker/parts/DayButton.js +1 -1
- package/esm/date/datepicker/parts/DayButton.js.map +1 -1
- package/esm/date/datepicker/parts/DropdownCaption.js +6 -9
- package/esm/date/datepicker/parts/DropdownCaption.js.map +1 -1
- package/esm/date/datepicker/parts/HeadRow.js +1 -1
- package/esm/date/datepicker/parts/Row.js +5 -4
- package/esm/date/datepicker/parts/Row.js.map +1 -1
- package/esm/date/datepicker/parts/WeekNumber.js +1 -1
- package/esm/date/datepicker/parts/WeekRow.js +6 -6
- package/esm/date/hooks/index.d.ts +6 -6
- package/esm/date/hooks/index.js +3 -3
- package/esm/date/hooks/useDatepicker.d.ts +3 -8
- package/esm/date/hooks/useDatepicker.js +2 -3
- package/esm/date/hooks/useDatepicker.js.map +1 -1
- package/esm/date/hooks/useMonthPicker.d.ts +3 -8
- package/esm/date/hooks/useMonthPicker.js +1 -1
- package/esm/date/hooks/useMonthPicker.js.map +1 -1
- package/esm/date/hooks/useRangeDatepicker.d.ts +3 -3
- package/esm/date/hooks/useRangeDatepicker.js +2 -4
- package/esm/date/hooks/useRangeDatepicker.js.map +1 -1
- package/esm/date/index.d.ts +7 -7
- package/esm/date/index.js +3 -3
- package/esm/date/monthpicker/MonthButton.js +3 -7
- package/esm/date/monthpicker/MonthButton.js.map +1 -1
- package/esm/date/monthpicker/MonthCaption.js +5 -8
- package/esm/date/monthpicker/MonthCaption.js.map +1 -1
- package/esm/date/monthpicker/MonthPicker.d.ts +3 -3
- package/esm/date/monthpicker/MonthPicker.js +17 -11
- package/esm/date/monthpicker/MonthPicker.js.map +1 -1
- package/esm/date/monthpicker/MonthPickerStandalone.d.ts +1 -1
- package/esm/date/monthpicker/MonthPickerStandalone.js +12 -6
- package/esm/date/monthpicker/MonthPickerStandalone.js.map +1 -1
- package/esm/date/monthpicker/MonthSelector.js +5 -8
- package/esm/date/monthpicker/MonthSelector.js.map +1 -1
- package/esm/date/monthpicker/types.d.ts +1 -1
- package/esm/date/parts/DateInput.d.ts +2 -2
- package/esm/date/parts/DateInput.js +5 -5
- package/esm/date/parts/DateWrapper.js +6 -6
- package/esm/date/utils/check-dates.js +1 -2
- package/esm/date/utils/check-dates.js.map +1 -1
- package/esm/date/utils/dates-disabled.js +1 -1
- package/esm/date/utils/dates-disabled.js.map +1 -1
- package/esm/date/utils/format-date.d.ts +1 -0
- package/esm/date/utils/format-date.js +2 -2
- package/esm/date/utils/format-date.js.map +1 -1
- package/esm/date/utils/get-dates.js +1 -5
- package/esm/date/utils/get-dates.js.map +1 -1
- package/esm/date/utils/get-initial-year.js +1 -1
- package/esm/date/utils/get-initial-year.js.map +1 -1
- package/esm/date/utils/index.d.ts +10 -10
- package/esm/date/utils/index.js +10 -10
- package/esm/date/utils/is-match.js +1 -4
- package/esm/date/utils/is-match.js.map +1 -1
- package/esm/date/utils/labels.d.ts +1 -0
- package/esm/date/utils/labels.js.map +1 -1
- package/esm/date/utils/locale.d.ts +1 -1
- package/esm/date/utils/locale.js +1 -3
- package/esm/date/utils/locale.js.map +1 -1
- package/esm/date/utils/navigation.d.ts +1 -1
- package/esm/date/utils/navigation.js +2 -2
- package/esm/date/utils/navigation.js.map +1 -1
- package/esm/date/utils/parse-date.d.ts +1 -0
- package/esm/date/utils/parse-date.js +2 -4
- package/esm/date/utils/parse-date.js.map +1 -1
- package/esm/dropdown/Dropdown.d.ts +2 -2
- package/esm/dropdown/Dropdown.js +4 -4
- package/esm/dropdown/Menu/GroupedList/GroupedItem.d.ts +1 -1
- package/esm/dropdown/Menu/GroupedList/GroupedItem.js +2 -2
- package/esm/dropdown/Menu/GroupedList/index.d.ts +3 -3
- package/esm/dropdown/Menu/GroupedList/index.js +2 -2
- package/esm/dropdown/Menu/List/Item.d.ts +1 -1
- package/esm/dropdown/Menu/List/Item.js +2 -2
- package/esm/dropdown/Menu/List/index.d.ts +2 -2
- package/esm/dropdown/Menu/List/index.js +1 -1
- package/esm/dropdown/Menu/index.d.ts +2 -2
- package/esm/dropdown/Menu/index.js +5 -5
- package/esm/dropdown/Toggle.js +2 -2
- package/esm/dropdown/index.d.ts +1 -1
- package/esm/dropdown/index.js +1 -1
- package/esm/expansion-card/ExpansionCard.d.ts +5 -5
- package/esm/expansion-card/ExpansionCard.js +5 -5
- package/esm/expansion-card/ExpansionCardContent.js +2 -2
- package/esm/expansion-card/ExpansionCardDescription.js +2 -2
- package/esm/expansion-card/ExpansionCardHeader.js +1 -1
- package/esm/expansion-card/ExpansionCardTitle.d.ts +1 -1
- package/esm/expansion-card/index.d.ts +1 -1
- package/esm/expansion-card/index.js +1 -1
- package/esm/form/ConfirmationPanel.d.ts +1 -1
- package/esm/form/ConfirmationPanel.js +4 -4
- package/esm/form/Fieldset/Fieldset.d.ts +1 -1
- package/esm/form/Fieldset/Fieldset.js +5 -5
- package/esm/form/Fieldset/index.d.ts +2 -2
- package/esm/form/Fieldset/index.js +2 -2
- package/esm/form/Fieldset/useFieldset.js +1 -1
- package/esm/form/Select.d.ts +1 -1
- package/esm/form/Select.js +4 -4
- package/esm/form/Switch.d.ts +1 -1
- package/esm/form/Switch.js +5 -5
- package/esm/form/TextField.d.ts +1 -1
- package/esm/form/TextField.js +4 -4
- package/esm/form/Textarea.d.ts +1 -1
- package/esm/form/Textarea.js +15 -15
- package/esm/form/Textarea.js.map +1 -1
- package/esm/form/TextareaCounter.d.ts +1 -1
- package/esm/form/TextareaCounter.js +2 -2
- package/esm/form/checkbox/Checkbox.d.ts +1 -1
- package/esm/form/checkbox/Checkbox.js +5 -5
- package/esm/form/checkbox/CheckboxGroup.d.ts +1 -1
- package/esm/form/checkbox/CheckboxGroup.js +1 -1
- package/esm/form/checkbox/index.d.ts +3 -3
- package/esm/form/checkbox/index.js +2 -2
- package/esm/form/checkbox/types.d.ts +1 -1
- package/esm/form/checkbox/useCheckbox.d.ts +1 -1
- package/esm/form/checkbox/useCheckbox.js +3 -3
- package/esm/form/combobox/Combobox.d.ts +1 -1
- package/esm/form/combobox/Combobox.js +12 -12
- package/esm/form/combobox/Combobox.js.map +1 -1
- package/esm/form/combobox/ComboboxProvider.d.ts +1 -1
- package/esm/form/combobox/ComboboxProvider.js +7 -6
- package/esm/form/combobox/ComboboxProvider.js.map +1 -1
- package/esm/form/combobox/ComboboxWrapper.js +1 -1
- package/esm/form/combobox/ComboboxWrapper.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/FilteredOptions.js +65 -47
- package/esm/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/filtered-options-util.d.ts +2 -1
- package/esm/form/combobox/FilteredOptions/filtered-options-util.js +3 -1
- package/esm/form/combobox/FilteredOptions/filtered-options-util.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/filteredOptionsContext.d.ts +2 -2
- package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js +20 -8
- package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/useVirtualFocus.d.ts +2 -4
- package/esm/form/combobox/FilteredOptions/useVirtualFocus.js +52 -32
- package/esm/form/combobox/FilteredOptions/useVirtualFocus.js.map +1 -1
- package/esm/form/combobox/Input/Input.js +8 -6
- package/esm/form/combobox/Input/Input.js.map +1 -1
- package/esm/form/combobox/Input/inputContext.d.ts +1 -1
- package/esm/form/combobox/Input/inputContext.js +2 -2
- package/esm/form/combobox/SelectedOptions/SelectedOptions.js +3 -3
- package/esm/form/combobox/SelectedOptions/selectedOptionsContext.d.ts +5 -2
- package/esm/form/combobox/SelectedOptions/selectedOptionsContext.js +6 -4
- package/esm/form/combobox/SelectedOptions/selectedOptionsContext.js.map +1 -1
- package/esm/form/combobox/ToggleListButton.js +1 -1
- package/esm/form/combobox/customOptionsContext.js +1 -1
- package/esm/form/combobox/index.d.ts +2 -2
- package/esm/form/combobox/index.js +1 -1
- package/esm/form/combobox/types.d.ts +15 -1
- package/esm/form/error-summary/ErrorSummary.d.ts +9 -3
- package/esm/form/error-summary/ErrorSummary.js +8 -13
- package/esm/form/error-summary/ErrorSummary.js.map +1 -1
- package/esm/form/error-summary/ErrorSummaryItem.d.ts +2 -2
- package/esm/form/error-summary/ErrorSummaryItem.js +2 -1
- package/esm/form/error-summary/ErrorSummaryItem.js.map +1 -1
- package/esm/form/error-summary/index.d.ts +2 -2
- package/esm/form/error-summary/index.js +1 -1
- package/esm/form/index.d.ts +11 -11
- package/esm/form/index.js +11 -11
- package/esm/form/radio/Radio.d.ts +1 -1
- package/esm/form/radio/Radio.js +4 -4
- package/esm/form/radio/RadioGroup.d.ts +1 -1
- package/esm/form/radio/RadioGroup.js +2 -2
- package/esm/form/radio/index.d.ts +3 -3
- package/esm/form/radio/index.js +2 -2
- package/esm/form/radio/types.d.ts +1 -1
- package/esm/form/radio/useRadio.d.ts +1 -1
- package/esm/form/radio/useRadio.js +3 -3
- package/esm/form/search/Search.d.ts +3 -2
- package/esm/form/search/Search.js +8 -8
- package/esm/form/search/Search.js.map +1 -1
- package/esm/form/search/SearchButton.d.ts +1 -1
- package/esm/form/search/SearchButton.js +3 -3
- package/esm/form/search/index.d.ts +1 -1
- package/esm/form/search/index.js +1 -1
- package/esm/form/useFormField.js +2 -2
- package/esm/guide-panel/GuidePanel.js +1 -1
- package/esm/guide-panel/Illustration.js +1 -1
- package/esm/guide-panel/index.d.ts +2 -2
- package/esm/guide-panel/index.js +2 -2
- package/esm/help-text/HelpText.d.ts +1 -1
- package/esm/help-text/HelpText.js +4 -4
- package/esm/help-text/HelpTextIcon.js +1 -1
- package/esm/help-text/index.d.ts +2 -2
- package/esm/help-text/index.js +1 -1
- package/esm/index.d.ts +40 -41
- package/esm/index.js +40 -42
- package/esm/index.js.map +1 -1
- package/esm/internal-header/InternalHeader.d.ts +5 -5
- package/esm/internal-header/InternalHeader.js +4 -4
- package/esm/internal-header/InternalHeaderButton.d.ts +1 -1
- package/esm/internal-header/InternalHeaderTitle.d.ts +1 -1
- package/esm/internal-header/InternalHeaderUser.js +1 -1
- package/esm/internal-header/InternalHeaderUserButton.d.ts +1 -1
- package/esm/internal-header/InternalHeaderUserButton.js +2 -2
- package/esm/internal-header/index.d.ts +5 -5
- package/esm/internal-header/index.js +1 -1
- package/esm/layout/bleed/Bleed.d.ts +3 -3
- package/esm/layout/bleed/Bleed.js +2 -2
- package/esm/layout/bleed/index.d.ts +1 -1
- package/esm/layout/bleed/index.js +1 -1
- package/esm/layout/box/Box.d.ts +2 -2
- package/esm/layout/box/Box.js +1 -1
- package/esm/layout/box/index.d.ts +1 -1
- package/esm/layout/box/index.js +1 -1
- package/esm/layout/grid/HGrid.d.ts +1 -1
- package/esm/layout/grid/HGrid.js +1 -1
- package/esm/layout/grid/index.d.ts +1 -1
- package/esm/layout/grid/index.js +1 -1
- package/esm/layout/page/Page.d.ts +2 -2
- package/esm/layout/page/Page.js +1 -1
- package/esm/layout/page/index.d.ts +2 -2
- package/esm/layout/page/index.js +1 -1
- package/esm/layout/page/parts/PageBlock.d.ts +1 -1
- package/esm/layout/responsive/Responsive.d.ts +1 -1
- package/esm/layout/responsive/Responsive.js +1 -1
- package/esm/layout/responsive/index.d.ts +1 -1
- package/esm/layout/responsive/index.js +1 -1
- package/esm/layout/sidemal-test/AvatarPanel.js +2 -2
- package/esm/layout/sidemal-test/Content.js +9 -9
- package/esm/layout/sidemal-test/Filter.js +4 -4
- package/esm/layout/sidemal-test/Header.js +5 -5
- package/esm/layout/sidemal-test/Intro.js +4 -4
- package/esm/layout/sidemal-test/Sidebar.js +4 -4
- package/esm/layout/sidemal-test/content-box/ContentBox.d.ts +1 -1
- package/esm/layout/sidemal-test/content-box/index.d.ts +1 -1
- package/esm/layout/sidemal-test/content-box/index.js +1 -1
- package/esm/layout/stack/HStack.d.ts +2 -2
- package/esm/layout/stack/HStack.js +1 -1
- package/esm/layout/stack/Stack.d.ts +2 -2
- package/esm/layout/stack/Stack.js +1 -1
- package/esm/layout/stack/VStack.d.ts +2 -2
- package/esm/layout/stack/VStack.js +1 -1
- package/esm/layout/stack/index.d.ts +4 -4
- package/esm/layout/stack/index.js +4 -4
- package/esm/layout/utilities/css.d.ts +1 -1
- package/esm/layout/utilities/css.js +4 -0
- package/esm/layout/utilities/css.js.map +1 -1
- package/esm/layout/utilities/types.d.ts +1 -1
- package/esm/link/Link.d.ts +1 -1
- package/esm/link/index.d.ts +2 -2
- package/esm/link/index.js +1 -1
- package/esm/link-panel/LinkPanel.d.ts +3 -3
- package/esm/link-panel/LinkPanel.js +3 -3
- package/esm/link-panel/LinkPanelDescription.js +1 -1
- package/esm/link-panel/LinkPanelTitle.d.ts +1 -1
- package/esm/link-panel/index.d.ts +2 -2
- package/esm/link-panel/index.js +1 -1
- package/esm/list/List.d.ts +2 -2
- package/esm/list/List.js +4 -4
- package/esm/list/ListItem.js +2 -2
- package/esm/list/context.d.ts +1 -1
- package/esm/list/index.d.ts +2 -2
- package/esm/list/index.js +1 -1
- package/esm/loader/Loader.js +2 -2
- package/esm/loader/index.d.ts +2 -2
- package/esm/loader/index.js +1 -1
- package/esm/modal/Modal.d.ts +4 -4
- package/esm/modal/Modal.js +12 -12
- package/esm/modal/ModalHeader.js +2 -2
- package/esm/modal/ModalUtils.d.ts +1 -1
- package/esm/modal/index.d.ts +5 -5
- package/esm/modal/index.js +1 -1
- package/esm/overlays/index.d.ts +2 -0
- package/esm/overlays/index.js +2 -0
- package/esm/overlays/index.js.map +1 -0
- package/esm/overlays/portal/Portal.d.ts +11 -0
- package/esm/overlays/portal/Portal.js +27 -0
- package/esm/overlays/portal/Portal.js.map +1 -0
- package/esm/package.json +1 -1
- package/esm/pagination/Pagination.d.ts +1 -1
- package/esm/pagination/Pagination.js +2 -2
- package/esm/pagination/PaginationItem.d.ts +2 -2
- package/esm/pagination/PaginationItem.js +1 -1
- package/esm/pagination/index.d.ts +1 -1
- package/esm/pagination/index.js +1 -1
- package/esm/panel/Panel.d.ts +1 -1
- package/esm/panel/index.d.ts +2 -2
- package/esm/panel/index.js +1 -1
- package/esm/popover/Popover.d.ts +1 -1
- package/esm/popover/Popover.js +5 -5
- package/esm/popover/index.d.ts +2 -2
- package/esm/popover/index.js +1 -1
- package/esm/provider/index.d.ts +1 -1
- package/esm/provider/index.js +1 -1
- package/esm/read-more/ReadMore.js +3 -3
- package/esm/read-more/index.d.ts +2 -2
- package/esm/read-more/index.js +1 -1
- package/esm/skeleton/index.d.ts +2 -2
- package/esm/skeleton/index.js +1 -1
- package/esm/stepper/Step.d.ts +1 -1
- package/esm/stepper/Step.js +3 -3
- package/esm/stepper/Stepper.d.ts +1 -1
- package/esm/stepper/Stepper.js +2 -2
- package/esm/stepper/index.d.ts +1 -1
- package/esm/stepper/index.js +1 -1
- package/esm/table/ColumnHeader.d.ts +1 -1
- package/esm/table/ColumnHeader.js +2 -2
- package/esm/table/DataCell.js +1 -1
- package/esm/table/ExpandableRow.d.ts +1 -1
- package/esm/table/ExpandableRow.js +6 -6
- package/esm/table/Table.d.ts +8 -8
- package/esm/table/Table.js +8 -8
- package/esm/table/context.d.ts +1 -1
- package/esm/table/index.d.ts +9 -9
- package/esm/table/index.js +1 -1
- package/esm/tabs/Tab.d.ts +1 -1
- package/esm/tabs/Tab.js +2 -2
- package/esm/tabs/TabList.js +5 -5
- package/esm/tabs/TabList.js.map +1 -1
- package/esm/tabs/TabPanel.js +2 -2
- package/esm/tabs/TabPanel.js.map +1 -1
- package/esm/tabs/Tabs.d.ts +4 -4
- package/esm/tabs/Tabs.js +4 -4
- package/esm/tabs/index.d.ts +4 -4
- package/esm/tabs/index.js +1 -1
- package/esm/tag/Tag.js +1 -1
- package/esm/tag/index.d.ts +1 -1
- package/esm/tag/index.js +1 -1
- package/esm/timeline/AxisLabels.d.ts +1 -1
- package/esm/timeline/AxisLabels.js +5 -5
- package/esm/timeline/AxisLabels.js.map +1 -1
- package/esm/timeline/Pin.d.ts +1 -1
- package/esm/timeline/Pin.js +3 -3
- package/esm/timeline/Timeline.d.ts +5 -5
- package/esm/timeline/Timeline.js +9 -9
- package/esm/timeline/TimelineRow.d.ts +1 -1
- package/esm/timeline/TimelineRow.js +5 -5
- package/esm/timeline/hooks/useRowContext.d.ts +1 -1
- package/esm/timeline/hooks/useTimelineRows.d.ts +1 -1
- package/esm/timeline/hooks/useTimelineRows.js +3 -3
- package/esm/timeline/index.d.ts +6 -6
- package/esm/timeline/index.js +1 -1
- package/esm/timeline/period/ClickablePeriod.d.ts +1 -1
- package/esm/timeline/period/ClickablePeriod.js +5 -5
- package/esm/timeline/period/NonClickablePeriod.d.ts +1 -1
- package/esm/timeline/period/NonClickablePeriod.js +1 -1
- package/esm/timeline/period/index.d.ts +1 -1
- package/esm/timeline/period/index.js +4 -4
- package/esm/timeline/utils/filter.d.ts +1 -1
- package/esm/timeline/utils/index.d.ts +1 -1
- package/esm/timeline/utils/index.js +1 -1
- package/esm/timeline/utils/sort.d.ts +1 -1
- package/esm/timeline/utils/timeline.d.ts +1 -1
- package/esm/timeline/utils/timeline.js +1 -1
- package/esm/timeline/zoom/ZoomButton.js +2 -2
- package/esm/timeline/zoom/index.d.ts +1 -1
- package/esm/timeline/zoom/index.js +1 -1
- package/esm/toggle-group/ToggleGroup.d.ts +1 -1
- package/esm/toggle-group/ToggleGroup.js +4 -4
- package/esm/toggle-group/ToggleItem.js +2 -2
- package/esm/toggle-group/index.d.ts +2 -2
- package/esm/toggle-group/index.js +1 -1
- package/esm/tooltip/Tooltip.js +9 -13
- package/esm/tooltip/Tooltip.js.map +1 -1
- package/esm/tooltip/index.d.ts +1 -1
- package/esm/tooltip/index.js +1 -1
- package/esm/typography/BodyLong.d.ts +2 -2
- package/esm/typography/BodyLong.js +1 -1
- package/esm/typography/BodyShort.d.ts +2 -2
- package/esm/typography/BodyShort.js +1 -1
- package/esm/typography/Detail.d.ts +2 -2
- package/esm/typography/Detail.js +1 -1
- package/esm/typography/ErrorMessage.d.ts +2 -2
- package/esm/typography/ErrorMessage.js +1 -1
- package/esm/typography/Heading.d.ts +2 -2
- package/esm/typography/Heading.js +1 -1
- package/esm/typography/Ingress.d.ts +1 -1
- package/esm/typography/Label.d.ts +2 -2
- package/esm/typography/Label.js +1 -1
- package/esm/typography/index.d.ts +7 -7
- package/esm/typography/index.js +7 -7
- package/esm/typography/util.d.ts +1 -1
- package/esm/util/Slot.js +6 -3
- package/esm/util/Slot.js.map +1 -1
- package/esm/util/TextareaAutoSize.js +17 -27
- package/esm/util/TextareaAutoSize.js.map +1 -1
- package/esm/util/hooks/descendants/descendant.js +1 -1
- package/esm/util/hooks/descendants/useDescendant.d.ts +1 -1
- package/esm/util/hooks/descendants/useDescendant.js +5 -5
- package/esm/util/hooks/index.d.ts +8 -8
- package/esm/util/hooks/index.js +8 -8
- package/esm/util/hooks/useControllableState.js +1 -1
- package/esm/util/index.d.ts +6 -6
- package/esm/util/index.js +5 -5
- package/esm/util/types/AsChildProps.d.ts +36 -0
- package/esm/util/types/AsChildProps.js +2 -0
- package/esm/util/types/AsChildProps.js.map +1 -0
- package/esm/util/types/index.d.ts +2 -1
- package/package.json +9 -8
- package/src/alert/alert.stories.tsx +202 -113
- package/src/chat/Bubble.tsx +2 -23
- package/src/chat/Chat.tsx +1 -18
- package/src/chat/chat.stories.tsx +0 -31
- package/src/date/context/useSharedMonthContext.tsx +1 -2
- package/src/date/datepicker/DatePicker.tsx +1 -3
- package/src/date/datepicker/DatePickerStandalone.tsx +1 -3
- package/src/date/datepicker/datepicker.stories.tsx +5 -5
- package/src/date/datepicker/parts/DayButton.tsx +1 -1
- package/src/date/datepicker/parts/DropdownCaption.tsx +1 -4
- package/src/date/datepicker/parts/Row.tsx +3 -2
- package/src/date/hooks/useDatepicker.tsx +2 -8
- package/src/date/hooks/useMonthPicker.tsx +1 -6
- package/src/date/hooks/useRangeDatepicker.tsx +5 -3
- package/src/date/monthpicker/MonthButton.tsx +7 -5
- package/src/date/monthpicker/MonthCaption.tsx +7 -4
- package/src/date/monthpicker/MonthPicker.tsx +10 -8
- package/src/date/monthpicker/MonthPickerStandalone.tsx +10 -8
- package/src/date/monthpicker/MonthSelector.tsx +1 -4
- package/src/date/monthpicker/monthpicker.stories.tsx +3 -2
- package/src/date/parts/DateInput.tsx +1 -1
- package/src/date/utils/__tests__/format-dates.test.ts +1 -1
- package/src/date/utils/__tests__/get-initial-year.test.ts +1 -1
- package/src/date/utils/__tests__/parse-dates.test.ts +2 -2
- package/src/date/utils/check-dates.ts +1 -2
- package/src/date/utils/dates-disabled.ts +1 -1
- package/src/date/utils/format-date.ts +1 -1
- package/src/date/utils/get-dates.ts +7 -5
- package/src/date/utils/get-initial-year.ts +1 -1
- package/src/date/utils/is-match.ts +6 -4
- package/src/date/utils/labels.ts +1 -0
- package/src/date/utils/locale.ts +1 -3
- package/src/date/utils/navigation.ts +1 -1
- package/src/date/utils/parse-date.ts +1 -3
- package/src/form/Textarea.tsx +34 -34
- package/src/form/combobox/Combobox.tsx +1 -1
- package/src/form/combobox/ComboboxProvider.tsx +2 -0
- package/src/form/combobox/ComboboxWrapper.tsx +0 -1
- package/src/form/combobox/FilteredOptions/FilteredOptions.tsx +131 -92
- package/src/form/combobox/FilteredOptions/filtered-options-util.ts +9 -2
- package/src/form/combobox/FilteredOptions/filteredOptionsContext.tsx +22 -3
- package/src/form/combobox/FilteredOptions/useVirtualFocus.ts +63 -45
- package/src/form/combobox/Input/Input.tsx +3 -1
- package/src/form/combobox/SelectedOptions/selectedOptionsContext.tsx +11 -1
- package/src/form/combobox/combobox.stories.tsx +36 -1
- package/src/form/combobox/combobox.test.tsx +1 -3
- package/src/form/combobox/types.ts +15 -0
- package/src/form/error-summary/ErrorSummary.tsx +15 -11
- package/src/form/error-summary/ErrorSummaryItem.tsx +10 -8
- package/src/form/error-summary/error-summary.stories.tsx +55 -1
- package/src/form/search/Search.tsx +6 -1
- package/src/form/stories/textarea.stories.tsx +37 -0
- package/src/index.ts +1 -2
- package/src/layout/bleed/Bleed.stories.tsx +13 -0
- package/src/layout/bleed/Bleed.tsx +2 -2
- package/src/layout/box/Box.stories.tsx +1 -1
- package/src/layout/sidemal-test/navno-sidemal.stories.tsx +1 -0
- package/src/layout/utilities/css.ts +3 -0
- package/src/layout/utilities/types.ts +1 -1
- package/src/overlays/index.ts +2 -0
- package/src/overlays/portal/Portal.stories.tsx +99 -0
- package/src/overlays/portal/Portal.tsx +32 -0
- package/src/tabs/TabList.tsx +2 -2
- package/src/tabs/TabPanel.tsx +2 -2
- package/src/timeline/AxisLabels.tsx +1 -1
- package/src/tooltip/Tooltip.tsx +4 -8
- package/src/util/Slot.tsx +4 -2
- package/src/util/TextareaAutoSize.tsx +16 -31
- package/src/util/types/AsChildProps.ts +37 -0
- package/src/util/types/index.ts +1 -0
- package/cjs/grid/Cell.d.ts +0 -30
- package/cjs/grid/Cell.js +0 -52
- package/cjs/grid/Cell.js.map +0 -1
- package/cjs/grid/Grid.d.ts +0 -13
- package/cjs/grid/Grid.js.map +0 -1
- package/cjs/grid/index.d.ts +0 -2
- package/cjs/grid/index.js +0 -11
- package/cjs/grid/index.js.map +0 -1
- package/cjs/layout/content-container/ContentContainer.d.ts +0 -9
- package/cjs/layout/content-container/ContentContainer.js +0 -48
- package/cjs/layout/content-container/ContentContainer.js.map +0 -1
- package/cjs/layout/content-container/index.d.ts +0 -1
- package/cjs/layout/content-container/index.js +0 -9
- package/cjs/layout/content-container/index.js.map +0 -1
- package/esm/grid/Cell.d.ts +0 -30
- package/esm/grid/Cell.js +0 -23
- package/esm/grid/Cell.js.map +0 -1
- package/esm/grid/Grid.d.ts +0 -13
- package/esm/grid/Grid.js +0 -23
- package/esm/grid/Grid.js.map +0 -1
- package/esm/grid/index.d.ts +0 -2
- package/esm/grid/index.js +0 -3
- package/esm/grid/index.js.map +0 -1
- package/esm/layout/content-container/ContentContainer.d.ts +0 -9
- package/esm/layout/content-container/ContentContainer.js +0 -19
- package/esm/layout/content-container/ContentContainer.js.map +0 -1
- package/esm/layout/content-container/index.d.ts +0 -1
- package/esm/layout/content-container/index.js +0 -2
- package/esm/layout/content-container/index.js.map +0 -1
- package/src/grid/Cell.tsx +0 -53
- package/src/grid/Grid.tsx +0 -23
- package/src/grid/grid.stories.tsx +0 -67
- package/src/grid/index.ts +0 -2
- package/src/layout/content-container/ContentContainer.tsx +0 -22
- package/src/layout/content-container/index.ts +0 -4
- package/src/layout/sidemal-test/navno-sidemal.stories.mdx +0 -29
|
@@ -1,58 +1,76 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { CheckmarkIcon, PlusIcon } from "@navikt/aksel-icons";
|
|
4
|
-
import { Loader } from "../../../loader";
|
|
5
|
-
import { BodyShort, Label } from "../../../typography";
|
|
6
|
-
import { useInputContext } from "../Input/inputContext";
|
|
7
|
-
import { useSelectedOptionsContext } from "../SelectedOptions/selectedOptionsContext";
|
|
8
|
-
import filteredOptionsUtil from "./filtered-options-util";
|
|
9
|
-
import { useFilteredOptionsContext } from "./filteredOptionsContext";
|
|
4
|
+
import { Loader } from "../../../loader/index.js";
|
|
5
|
+
import { BodyShort, Label } from "../../../typography/index.js";
|
|
6
|
+
import { useInputContext } from "../Input/inputContext.js";
|
|
7
|
+
import { useSelectedOptionsContext } from "../SelectedOptions/selectedOptionsContext.js";
|
|
8
|
+
import filteredOptionsUtil from "./filtered-options-util.js";
|
|
9
|
+
import { useFilteredOptionsContext } from "./filteredOptionsContext.js";
|
|
10
10
|
const FilteredOptions = () => {
|
|
11
|
+
var _a;
|
|
11
12
|
const { inputProps: { id }, size, value, } = useInputContext();
|
|
12
13
|
const { allowNewValues, isLoading, isListOpen, filteredOptions, setFilteredOptionsRef, isMouseLastUsedInputDevice, setIsMouseLastUsedInputDevice, isValueNew, toggleIsListOpen, activeDecendantId, virtualFocus, } = useFilteredOptionsContext();
|
|
13
|
-
const { isMultiSelect, selectedOptions, toggleOption } = useSelectedOptionsContext();
|
|
14
|
-
|
|
14
|
+
const { isMultiSelect, selectedOptions, toggleOption, maxSelected } = useSelectedOptionsContext();
|
|
15
|
+
const isDisabled = (option) => (maxSelected === null || maxSelected === void 0 ? void 0 : maxSelected.isLimitReached) && !selectedOptions.includes(option);
|
|
16
|
+
const shouldRenderNonSelectables = (maxSelected === null || maxSelected === void 0 ? void 0 : maxSelected.isLimitReached) || // Render maxSelected message
|
|
17
|
+
isLoading || // Render loading message
|
|
18
|
+
(!isLoading && filteredOptions.length === 0); // Render no hits message
|
|
19
|
+
const shouldRenderFilteredOptionsList = (allowNewValues && isValueNew && !(maxSelected === null || maxSelected === void 0 ? void 0 : maxSelected.isLimitReached)) || // Render add new option
|
|
20
|
+
filteredOptions.length > 0; // Render filtered options
|
|
21
|
+
return (React.createElement("div", { className: cl("navds-combobox__list", {
|
|
15
22
|
"navds-combobox__list--closed": !isListOpen,
|
|
16
23
|
"navds-combobox__list--with-hover": isMouseLastUsedInputDevice,
|
|
17
|
-
}), id: filteredOptionsUtil.getFilteredOptionsId(id),
|
|
18
|
-
|
|
19
|
-
React.createElement(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
24
|
+
}), id: filteredOptionsUtil.getFilteredOptionsId(id), tabIndex: -1 },
|
|
25
|
+
shouldRenderNonSelectables && (React.createElement("div", { className: "navds-combobox__list_non-selectables", role: "status" },
|
|
26
|
+
(maxSelected === null || maxSelected === void 0 ? void 0 : maxSelected.isLimitReached) && (React.createElement("div", { className: "navds-combobox__list-item--max-selected", id: filteredOptionsUtil.getMaxSelectedOptionsId(id) }, (_a = maxSelected.message) !== null && _a !== void 0 ? _a : `${selectedOptions.length} av ${maxSelected.limit} er valgt.`)),
|
|
27
|
+
isLoading && (React.createElement("div", { className: "navds-combobox__list-item--loading", id: filteredOptionsUtil.getIsLoadingId(id) },
|
|
28
|
+
React.createElement(Loader, { title: "S\u00F8ker..." }))),
|
|
29
|
+
!isLoading && filteredOptions.length === 0 && (React.createElement("div", { className: "navds-combobox__list-item--no-options", id: filteredOptionsUtil.getNoHitsId(id) }, "Ingen s\u00F8ketreff")))),
|
|
30
|
+
shouldRenderFilteredOptionsList && (React.createElement("ul", { ref: setFilteredOptionsRef, role: "listbox", className: "navds-combobox__list-options" },
|
|
31
|
+
isValueNew && !(maxSelected === null || maxSelected === void 0 ? void 0 : maxSelected.isLimitReached) && allowNewValues && (React.createElement("li", { tabIndex: -1, onMouseMove: () => {
|
|
32
|
+
if (activeDecendantId !==
|
|
33
|
+
filteredOptionsUtil.getAddNewOptionId(id)) {
|
|
34
|
+
virtualFocus.moveFocusToElement(filteredOptionsUtil.getAddNewOptionId(id));
|
|
35
|
+
setIsMouseLastUsedInputDevice(true);
|
|
36
|
+
}
|
|
37
|
+
}, onPointerUp: (event) => {
|
|
38
|
+
toggleOption(value, event);
|
|
39
|
+
if (!isMultiSelect && !selectedOptions.includes(value))
|
|
40
|
+
toggleIsListOpen(false);
|
|
41
|
+
}, id: filteredOptionsUtil.getAddNewOptionId(id), className: cl("navds-combobox__list-item navds-combobox__list-item--new-option", {
|
|
42
|
+
"navds-combobox__list-item--new-option--focus": activeDecendantId ===
|
|
43
|
+
filteredOptionsUtil.getAddNewOptionId(id),
|
|
44
|
+
}), role: "option", "aria-selected": false },
|
|
45
|
+
React.createElement(PlusIcon, { "aria-hidden": true }),
|
|
46
|
+
React.createElement(BodyShort, { size: size },
|
|
47
|
+
"Legg til",
|
|
48
|
+
" ",
|
|
49
|
+
React.createElement(Label, { as: "span", size: size },
|
|
50
|
+
"\u201C",
|
|
51
|
+
value,
|
|
52
|
+
"\u201D")))),
|
|
53
|
+
filteredOptions.map((option) => (React.createElement("li", { className: cl("navds-combobox__list-item", {
|
|
54
|
+
"navds-combobox__list-item--focus": activeDecendantId ===
|
|
55
|
+
filteredOptionsUtil.getOptionId(id, option),
|
|
56
|
+
"navds-combobox__list-item--selected": selectedOptions.includes(option),
|
|
57
|
+
}), "data-no-focus": isDisabled(option) || undefined, id: filteredOptionsUtil.getOptionId(id, option), key: option, tabIndex: -1, onMouseMove: () => {
|
|
58
|
+
if (activeDecendantId !==
|
|
59
|
+
filteredOptionsUtil.getOptionId(id, option)) {
|
|
60
|
+
virtualFocus.moveFocusToElement(filteredOptionsUtil.getOptionId(id, option));
|
|
61
|
+
setIsMouseLastUsedInputDevice(true);
|
|
62
|
+
}
|
|
63
|
+
}, onPointerUp: (event) => {
|
|
64
|
+
if (isDisabled(option)) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
toggleOption(option, event);
|
|
68
|
+
if (!isMultiSelect && !selectedOptions.includes(option)) {
|
|
69
|
+
toggleIsListOpen(false);
|
|
70
|
+
}
|
|
71
|
+
}, role: "option", "aria-selected": selectedOptions.includes(option), "aria-disabled": isDisabled(option) || undefined },
|
|
72
|
+
React.createElement(BodyShort, { size: size }, option),
|
|
73
|
+
selectedOptions.includes(option) && React.createElement(CheckmarkIcon, null))))))));
|
|
56
74
|
};
|
|
57
75
|
export default FilteredOptions;
|
|
58
76
|
//# sourceMappingURL=FilteredOptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilteredOptions.js","sourceRoot":"","sources":["../../../../src/form/combobox/FilteredOptions/FilteredOptions.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,mBAAmB,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAErE,MAAM,eAAe,GAAG,GAAG,EAAE
|
|
1
|
+
{"version":3,"file":"FilteredOptions.js","sourceRoot":"","sources":["../../../../src/form/combobox/FilteredOptions/FilteredOptions.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,mBAAmB,MAAM,yBAAy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,CAAC,WAAW,CAAC,EAAE,EAAE,MAAM,CAAC,CAC5C,CAAC;wBACF,6BAA6B,CAAC,IAAI,CAAC,CAAC;oBACtC,CAAC;gBACH,CAAC,EACD,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;oBACrB,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;wBACvB,OAAO;oBACT,CAAC;oBACD,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;oBAC5B,IAAI,CAAC,aAAa,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;wBACxD,gBAAgB,CAAC,KAAK,CAAC,CAAC;oBAC1B,CAAC;gBACH,CAAC,EACD,IAAI,EAAC,QAAQ,mBACE,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC,mBAChC,UAAU,CAAC,MAAM,CAAC,IAAI,SAAS;gBAE9C,oBAAC,SAAS,IAAC,IAAI,EAAE,IAAI,IAAG,MAAM,CAAa;gBAC1C,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,oBAAC,aAAa,OAAG,CACnD,CACN,CAAC,CACC,CACN,CACG,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -2,11 +2,12 @@ declare const _default: {
|
|
|
2
2
|
normalizeText: (text: string) => string;
|
|
3
3
|
isPartOfText: (value: any, text: any) => boolean;
|
|
4
4
|
isValueInList: (value: any, list: any) => any;
|
|
5
|
-
getMatchingValuesFromList: (value: any, list: any) => any;
|
|
5
|
+
getMatchingValuesFromList: (value: any, list: any, alwaysIncluded: any) => any;
|
|
6
6
|
getFilteredOptionsId: (comboboxId: string) => string;
|
|
7
7
|
getAddNewOptionId: (comboboxId: string) => string;
|
|
8
8
|
getOptionId: (comboboxId: string, option: string) => string;
|
|
9
9
|
getIsLoadingId: (comboboxId: string) => string;
|
|
10
10
|
getNoHitsId: (comboboxId: string) => string;
|
|
11
|
+
getMaxSelectedOptionsId: (comboboxId: string) => string;
|
|
11
12
|
};
|
|
12
13
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const normalizeText = (text) => typeof text === "string" ? text.toLocaleLowerCase().trim() : "";
|
|
2
2
|
const isPartOfText = (value, text) => normalizeText(text).startsWith(normalizeText(value !== null && value !== void 0 ? value : ""));
|
|
3
3
|
const isValueInList = (value, list) => list === null || list === void 0 ? void 0 : list.find((listItem) => normalizeText(value) === normalizeText(listItem));
|
|
4
|
-
const getMatchingValuesFromList = (value, list) => list === null || list === void 0 ? void 0 : list.filter((listItem) => isPartOfText(value, listItem));
|
|
4
|
+
const getMatchingValuesFromList = (value, list, alwaysIncluded) => list === null || list === void 0 ? void 0 : list.filter((listItem) => isPartOfText(value, listItem) || alwaysIncluded.includes(listItem));
|
|
5
5
|
const getFilteredOptionsId = (comboboxId) => `${comboboxId}-filtered-options`;
|
|
6
6
|
const getOptionId = (comboboxId, option) => `${comboboxId.toLocaleLowerCase()}-option-${option
|
|
7
7
|
.replace(" ", "-")
|
|
@@ -9,6 +9,7 @@ const getOptionId = (comboboxId, option) => `${comboboxId.toLocaleLowerCase()}-o
|
|
|
9
9
|
const getAddNewOptionId = (comboboxId) => `${comboboxId}-combobox-new-option`;
|
|
10
10
|
const getIsLoadingId = (comboboxId) => `${comboboxId}-is-loading`;
|
|
11
11
|
const getNoHitsId = (comboboxId) => `${comboboxId}-no-hits`;
|
|
12
|
+
const getMaxSelectedOptionsId = (comboboxId) => `${comboboxId}-max-selected-options`;
|
|
12
13
|
export default {
|
|
13
14
|
normalizeText,
|
|
14
15
|
isPartOfText,
|
|
@@ -19,5 +20,6 @@ export default {
|
|
|
19
20
|
getOptionId,
|
|
20
21
|
getIsLoadingId,
|
|
21
22
|
getNoHitsId,
|
|
23
|
+
getMaxSelectedOptionsId,
|
|
22
24
|
};
|
|
23
25
|
//# sourceMappingURL=filtered-options-util.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filtered-options-util.js","sourceRoot":"","sources":["../../../../src/form/combobox/FilteredOptions/filtered-options-util.ts"],"names":[],"mappings":"AAAA,MAAM,aAAa,GAAG,CAAC,IAAY,EAAU,EAAE,CAC7C,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAElE,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CACnC,aAAa,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAC,CAAC,CAAC;AAE7D,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CACpC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;AAE7E,MAAM,yBAAyB,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"filtered-options-util.js","sourceRoot":"","sources":["../../../../src/form/combobox/FilteredOptions/filtered-options-util.ts"],"names":[],"mappings":"AAAA,MAAM,aAAa,GAAG,CAAC,IAAY,EAAU,EAAE,CAC7C,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAElE,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CACnC,aAAa,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAC,CAAC,CAAC;AAE7D,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAC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
|
-
import { ComboboxProps } from "../types";
|
|
3
|
-
import { VirtualFocusType } from "./useVirtualFocus";
|
|
2
|
+
import { ComboboxProps } from "../types.js";
|
|
3
|
+
import { VirtualFocusType } from "./useVirtualFocus.js";
|
|
4
4
|
type FilteredOptionsProps = {
|
|
5
5
|
children: any;
|
|
6
6
|
value: Pick<ComboboxProps, "allowNewValues" | "filteredOptions" | "isListOpen" | "isLoading" | "options">;
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { createContext, useCallback, useContext, useMemo, useState, } from "react";
|
|
3
|
-
import { useClientLayoutEffect, usePrevious } from "../../../util/hooks";
|
|
4
|
-
import { useInputContext } from "../Input/inputContext";
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
3
|
+
import { useClientLayoutEffect, usePrevious } from "../../../util/hooks/index.js";
|
|
4
|
+
import { useInputContext } from "../Input/inputContext.js";
|
|
5
|
+
import { useSelectedOptionsContext } from "../SelectedOptions/selectedOptionsContext.js";
|
|
6
|
+
import { useCustomOptionsContext } from "../customOptionsContext.js";
|
|
7
|
+
import filteredOptionsUtils from "./filtered-options-util.js";
|
|
8
|
+
import useVirtualFocus from "./useVirtualFocus.js";
|
|
8
9
|
const FilteredOptionsContext = createContext({});
|
|
9
10
|
export const FilteredOptionsProvider = ({ children, value: props, }) => {
|
|
10
11
|
const { allowNewValues, filteredOptions: externalFilteredOptions, isListOpen: isExternalListOpen, isLoading, options, } = props;
|
|
11
12
|
const [filteredOptionsRef, setFilteredOptionsRef] = useState(null);
|
|
12
13
|
const virtualFocus = useVirtualFocus(filteredOptionsRef);
|
|
13
14
|
const { inputProps: { "aria-describedby": partialAriaDescribedBy, id }, value, searchTerm, setValue, setSearchTerm, shouldAutocomplete, } = useInputContext();
|
|
15
|
+
const { selectedOptions, maxSelected } = useSelectedOptionsContext();
|
|
14
16
|
const [isInternalListOpen, setInternalListOpen] = useState(false);
|
|
15
17
|
const { customOptions } = useCustomOptionsContext();
|
|
16
18
|
const filteredOptions = useMemo(() => {
|
|
@@ -18,8 +20,14 @@ export const FilteredOptionsProvider = ({ children, value: props, }) => {
|
|
|
18
20
|
return externalFilteredOptions;
|
|
19
21
|
}
|
|
20
22
|
const opts = [...customOptions, ...options];
|
|
21
|
-
return filteredOptionsUtils.getMatchingValuesFromList(searchTerm, opts);
|
|
22
|
-
}, [
|
|
23
|
+
return filteredOptionsUtils.getMatchingValuesFromList(searchTerm, opts, selectedOptions);
|
|
24
|
+
}, [
|
|
25
|
+
customOptions,
|
|
26
|
+
externalFilteredOptions,
|
|
27
|
+
options,
|
|
28
|
+
searchTerm,
|
|
29
|
+
selectedOptions,
|
|
30
|
+
]);
|
|
23
31
|
const previousSearchTerm = usePrevious(searchTerm);
|
|
24
32
|
const [isMouseLastUsedInputDevice, setIsMouseLastUsedInputDevice] = useState(false);
|
|
25
33
|
const filteredOptionsMap = useMemo(() => options.reduce((map, _option) => (Object.assign(Object.assign({}, map), { [filteredOptionsUtils.getOptionId(id, _option)]: _option })), {
|
|
@@ -65,10 +73,14 @@ export const FilteredOptionsProvider = ({ children, value: props, }) => {
|
|
|
65
73
|
activeOption = filteredOptionsUtils.getIsLoadingId(id);
|
|
66
74
|
}
|
|
67
75
|
}
|
|
68
|
-
|
|
76
|
+
const maybeMaxSelectedOptionsId = (maxSelected === null || maxSelected === void 0 ? void 0 : maxSelected.isLimitReached) &&
|
|
77
|
+
filteredOptionsUtils.getMaxSelectedOptionsId(id);
|
|
78
|
+
return (cl(activeOption, maybeMaxSelectedOptionsId, partialAriaDescribedBy) ||
|
|
79
|
+
undefined);
|
|
69
80
|
}, [
|
|
70
81
|
isListOpen,
|
|
71
82
|
isLoading,
|
|
83
|
+
maxSelected === null || maxSelected === void 0 ? void 0 : maxSelected.isLimitReached,
|
|
72
84
|
value,
|
|
73
85
|
partialAriaDescribedBy,
|
|
74
86
|
shouldAutocomplete,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filteredOptionsContext.js","sourceRoot":"","sources":["../../../../src/form/combobox/FilteredOptions/filteredOptionsContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAEZ,aAAa,EACb,WAAW,EACX,UAAU,EACV,OAAO,EACP,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAC3D,OAAO,eAAqC,MAAM,mBAAmB,CAAC;AAgCtE,MAAM,sBAAsB,GAAG,aAAa,CAC1C,EAAgC,CACjC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,EACtC,QAAQ,EACR,KAAK,EAAE,KAAK,GACS,EAAE,EAAE;IACzB,MAAM,EACJ,cAAc,EACd,eAAe,EAAE,uBAAuB,EACxC,UAAU,EAAE,kBAAkB,EAC9B,SAAS,EACT,OAAO,GACR,GAAG,KAAK,CAAC;IACV,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAC/C,QAAQ,CAA0B,IAAI,CAAC,CAAC;IAC1C,MAAM,YAAY,GAAG,eAAe,CAAC,kBAAkB,CAAC,CAAC;IACzD,MAAM,EACJ,UAAU,EAAE,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,EAAE,EAAE,EAC9D,KAAK,EACL,UAAU,EACV,QAAQ,EACR,aAAa,EACb,kBAAkB,GACnB,GAAG,eAAe,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"filteredOptionsContext.js","sourceRoot":"","sources":["../../../../src/form/combobox/FilteredOptions/filteredOptionsContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,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AgB;QAChB,aAAa;QACb,YAAY;QACZ,eAAe;KAChB,CAAC;IAEF,OAAO,CACL,oBAAC,sBAAsB,CAAC,QAAQ,IAAC,KAAK,EAAE,oBAAoB,IACzD,QAAQ,CACuB,CACnC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,EAAE;IAC5C,MAAM,OAAO,GAAG,UAAU,CAAC,sBAAsB,CAAC,CAAC;IACnD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,yEAAyE,CAC1E,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { Dispatch, SetStateAction } from "react";
|
|
2
1
|
export type VirtualFocusType = {
|
|
3
2
|
activeElement: HTMLElement | undefined;
|
|
4
3
|
getElementById: (id: string) => HTMLElement | undefined;
|
|
5
|
-
isFocusOnTheTop: boolean;
|
|
6
|
-
isFocusOnTheBottom: boolean;
|
|
7
|
-
setIndex: Dispatch<SetStateAction<number>>;
|
|
4
|
+
isFocusOnTheTop: () => boolean;
|
|
5
|
+
isFocusOnTheBottom: () => boolean;
|
|
8
6
|
moveFocusUp: () => void;
|
|
9
7
|
moveFocusDown: () => void;
|
|
10
8
|
moveFocusToElement: (id: string) => void;
|
|
@@ -1,40 +1,61 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
2
|
const useVirtualFocus = (containerRef) => {
|
|
3
|
-
const [
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
3
|
+
const [activeElement, setActiveElement] = useState(undefined);
|
|
4
|
+
const getListOfAllChildren = () => { var _a; return Array.from((_a = containerRef === null || containerRef === void 0 ? void 0 : containerRef.children) !== null && _a !== void 0 ? _a : []); };
|
|
5
|
+
const getElementsAbleToReceiveFocus = () => getListOfAllChildren().filter((child) => child.getAttribute("data-no-focus") !== "true");
|
|
6
|
+
const getElementById = (id) => getListOfAllChildren().find((element) => element.id === id);
|
|
7
|
+
const isFocusOnTheTop = () => activeElement
|
|
8
|
+
? getElementsAbleToReceiveFocus().indexOf(activeElement) === 0
|
|
9
|
+
: false;
|
|
10
|
+
const isFocusOnTheBottom = () => {
|
|
11
|
+
const elementsAbleToReceiveFocus = getElementsAbleToReceiveFocus();
|
|
12
|
+
return activeElement
|
|
13
|
+
? elementsAbleToReceiveFocus.indexOf(activeElement) ===
|
|
14
|
+
elementsAbleToReceiveFocus.length - 1
|
|
15
|
+
: false;
|
|
16
|
+
};
|
|
17
|
+
const _moveFocusAndScrollTo = (_element) => {
|
|
18
|
+
var _a;
|
|
19
|
+
setActiveElement(_element);
|
|
20
|
+
(_a = _element === null || _element === void 0 ? void 0 : _element.scrollIntoView) === null || _a === void 0 ? void 0 : _a.call(_element, { block: "nearest" });
|
|
21
|
+
};
|
|
22
|
+
const moveFocusUp = () => {
|
|
23
|
+
if (!activeElement) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const elementsAbleToReceiveFocus = getElementsAbleToReceiveFocus();
|
|
27
|
+
const _currentIndex = elementsAbleToReceiveFocus.indexOf(activeElement);
|
|
28
|
+
const elementAbove = elementsAbleToReceiveFocus[_currentIndex - 1];
|
|
29
|
+
if (_currentIndex === 0) {
|
|
30
|
+
setActiveElement(undefined);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
_moveFocusAndScrollTo(elementAbove);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const moveFocusDown = () => {
|
|
37
|
+
const elementsAbleToReceiveFocus = getElementsAbleToReceiveFocus();
|
|
38
|
+
if (!activeElement) {
|
|
39
|
+
_moveFocusAndScrollTo(elementsAbleToReceiveFocus[0]);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const _currentIndex = elementsAbleToReceiveFocus.indexOf(activeElement);
|
|
43
|
+
if (_currentIndex === elementsAbleToReceiveFocus.length - 1) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
_moveFocusAndScrollTo(elementsAbleToReceiveFocus[_currentIndex + 1]);
|
|
21
48
|
}
|
|
22
49
|
};
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
50
|
+
const moveFocusToTop = () => _moveFocusAndScrollTo(undefined);
|
|
51
|
+
const moveFocusToBottom = () => {
|
|
52
|
+
const elementsAbleToReceiveFocus = getElementsAbleToReceiveFocus();
|
|
53
|
+
return _moveFocusAndScrollTo(elementsAbleToReceiveFocus[elementsAbleToReceiveFocus.length - 1]);
|
|
26
54
|
};
|
|
27
|
-
const moveFocusUp = () => _moveFocusAndScrollTo(Math.max(index - 1, -1));
|
|
28
|
-
const moveFocusDown = () => _moveFocusAndScrollTo(Math.min(index + 1, elementsAbleToReceiveFocus.length - 1));
|
|
29
|
-
const moveFocusToTop = () => _moveFocusAndScrollTo(-1);
|
|
30
|
-
const moveFocusToBottom = () => _moveFocusAndScrollTo(elementsAbleToReceiveFocus.length - 1);
|
|
31
55
|
const moveFocusToElement = (id) => {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
: -1;
|
|
36
|
-
if (indexOfElement >= 0) {
|
|
37
|
-
setIndex(indexOfElement);
|
|
56
|
+
const _element = getElementsAbleToReceiveFocus().find((_focusableElement) => _focusableElement.getAttribute("id") === id);
|
|
57
|
+
if (_element) {
|
|
58
|
+
setActiveElement(_element);
|
|
38
59
|
}
|
|
39
60
|
};
|
|
40
61
|
return {
|
|
@@ -42,7 +63,6 @@ const useVirtualFocus = (containerRef) => {
|
|
|
42
63
|
getElementById,
|
|
43
64
|
isFocusOnTheTop,
|
|
44
65
|
isFocusOnTheBottom,
|
|
45
|
-
setIndex,
|
|
46
66
|
moveFocusUp,
|
|
47
67
|
moveFocusDown,
|
|
48
68
|
moveFocusToElement,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useVirtualFocus.js","sourceRoot":"","sources":["../../../../src/form/combobox/FilteredOptions/useVirtualFocus.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"useVirtualFocus.js","sourceRoot":"","sources":["../../../../src/form/combobox/FilteredOptions/useVirtualFocus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAcjC,MAAM,eAAe,GAAG,CACtB,YAAgC,EACd,EAAE;IACpB,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAChD,SAAS,CACV,CAAC;IAEF,MAAM,oBAAoB,GAAG,GAAkB,EAAE,WAC/C,OAAA,KAAK,CAAC,IAAI,CAAC,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,QAAQ,mCAAI,EAAE,CAAkB,CAAA,EAAA,CAAC;IAC5D,MAAM,6BAA6B,GAAG,GAAG,EAAE,CACzC,oBAAoB,EAAE,CAAC,MAAM,CAC3B,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,eAAe,CAAC,KAAK,MAAM,CAC1D,CAAC;IAEJ,MAAM,cAAc,GAAG,CAAC,EAAU,EAAE,EAAE,CACpC,oBAAoB,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAC9D,MAAM,eAAe,GAAG,GAAG,EAAE,CAC3B,aAAa;QACX,CAAC,CAAC,6BAA6B,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC;QAC9D,CAAC,CAAC,KAAK,CAAC;IACZ,MAAM,kBAAkB,GAAG,GAAG,EAAE;QAC9B,MAAM,0BAA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AAC;YACN,qBAAqB,CAAC,0BAA0B,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC,CAAC;QACvE,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,cAAc,GAAG,GAAG,EAAE,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAC9D,MAAM,iBAAiB,GAAG,GAAG,EAAE;QAC7B,MAAM,0BAA0B,GAAG,6BAA6B,EAAE,CAAC;QACnE,OAAO,qBAAqB,CAC1B,0BAA0B,CAAC,0BAA0B,CAAC,MAAM,GAAG,CAAC,CAAC,CAClE,CAAC;IACJ,CAAC,CAAC;IACF,MAAM,kBAAkB,GAAG,CAAC,EAAU,EAAE,EAAE;QACxC,MAAM,QAAQ,GAAG,6BAA6B,EAAE,CAAC,IAAI,CACnD,CAAC,iBAAiB,EAAE,EAAE,CAAC,iBAAiB,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,CACnE,CAAC;QACF,IAAI,QAAQ,EAAE,CAAC;YACb,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;QACL,aAAa;QACb,cAAc;QACd,eAAe;QACf,kBAAkB;QAClB,WAAW;QACX,aAAa;QACb,kBAAkB;QAClB,cAAc;QACd,iBAAiB;KAClB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -11,11 +11,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import cl from "clsx";
|
|
13
13
|
import React, { forwardRef, useCallback, } from "react";
|
|
14
|
-
import { omit } from "../../../util";
|
|
15
|
-
import filteredOptionsUtil from "../FilteredOptions/filtered-options-util";
|
|
16
|
-
import { useFilteredOptionsContext } from "../FilteredOptions/filteredOptionsContext";
|
|
17
|
-
import { useSelectedOptionsContext } from "../SelectedOptions/selectedOptionsContext";
|
|
18
|
-
import { useInputContext } from "./inputContext";
|
|
14
|
+
import { omit } from "../../../util/index.js";
|
|
15
|
+
import filteredOptionsUtil from "../FilteredOptions/filtered-options-util.js";
|
|
16
|
+
import { useFilteredOptionsContext } from "../FilteredOptions/filteredOptionsContext.js";
|
|
17
|
+
import { useSelectedOptionsContext } from "../SelectedOptions/selectedOptionsContext.js";
|
|
18
|
+
import { useInputContext } from "./inputContext.js";
|
|
19
19
|
const Input = forwardRef((_a, ref) => {
|
|
20
20
|
var { inputClassName } = _a, rest = __rest(_a, ["inputClassName"]);
|
|
21
21
|
const { clearInput, inputProps, onChange, size, value } = useInputContext();
|
|
@@ -73,9 +73,11 @@ const Input = forwardRef((_a, ref) => {
|
|
|
73
73
|
onEnter(e);
|
|
74
74
|
break;
|
|
75
75
|
case "Home":
|
|
76
|
+
toggleIsListOpen(false);
|
|
76
77
|
virtualFocus.moveFocusToTop();
|
|
77
78
|
break;
|
|
78
79
|
case "End":
|
|
80
|
+
toggleIsListOpen(true);
|
|
79
81
|
virtualFocus.moveFocusToBottom();
|
|
80
82
|
break;
|
|
81
83
|
default:
|
|
@@ -106,7 +108,7 @@ const Input = forwardRef((_a, ref) => {
|
|
|
106
108
|
// Otherwise ignore keystrokes, so it doesn't interfere with text editing
|
|
107
109
|
if (isListOpen && activeDecendantId) {
|
|
108
110
|
e.preventDefault();
|
|
109
|
-
if (virtualFocus.isFocusOnTheTop) {
|
|
111
|
+
if (virtualFocus.isFocusOnTheTop()) {
|
|
110
112
|
toggleIsListOpen(false);
|
|
111
113
|
}
|
|
112
114
|
virtualFocus.moveFocusUp();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../../src/form/combobox/Input/Input.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAGZ,UAAU,EACV,WAAW,GACZ,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,mBAAmB,M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uB,EACvB,kBAAkB,EAClB,qBAAqB,IAAI,EAAE,CAC5B,IACD,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { ChangeEventHandler } from "react";
|
|
2
|
-
import { FormFieldType } from "../../useFormField";
|
|
2
|
+
import { FormFieldType } from "../../useFormField.js";
|
|
3
3
|
interface InputContextType extends FormFieldType {
|
|
4
4
|
clearInput: (event: React.PointerEvent | React.KeyboardEvent) => void;
|
|
5
5
|
error?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { createContext, useCallback, useContext, useMemo, useRef, useState, } from "react";
|
|
2
|
-
import { useClientLayoutEffect } from "../../../util/hooks";
|
|
3
|
-
import { useFormField } from "../../useFormField";
|
|
2
|
+
import { useClientLayoutEffect } from "../../../util/hooks/index.js";
|
|
3
|
+
import { useFormField } from "../../useFormField.js";
|
|
4
4
|
const InputContext = createContext({});
|
|
5
5
|
export const InputContextProvider = ({ children, value: props }) => {
|
|
6
6
|
const { defaultValue = "", description, disabled, error, errorId, id: externalId, value: externalValue, onChange: externalOnChange, onClear, shouldAutocomplete, size, } = props;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Chips } from "../../../chips";
|
|
3
|
-
import { useInputContext } from "../Input/inputContext";
|
|
4
|
-
import { useSelectedOptionsContext } from "./selectedOptionsContext";
|
|
2
|
+
import { Chips } from "../../../chips/index.js";
|
|
3
|
+
import { useInputContext } from "../Input/inputContext.js";
|
|
4
|
+
import { useSelectedOptionsContext } from "./selectedOptionsContext.js";
|
|
5
5
|
const Option = ({ option }) => {
|
|
6
6
|
const { isMultiSelect, removeSelectedOption } = useSelectedOptionsContext();
|
|
7
7
|
const { focusInput } = useInputContext();
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { ComboboxProps } from "../types";
|
|
2
|
+
import { ComboboxProps, MaxSelected } from "../types.js";
|
|
3
3
|
type SelectedOptionsContextType = {
|
|
4
4
|
addSelectedOption: (option: string) => void;
|
|
5
5
|
isMultiSelect?: boolean;
|
|
6
6
|
removeSelectedOption: (option: string) => void;
|
|
7
7
|
prevSelectedOptions?: string[];
|
|
8
8
|
selectedOptions: string[];
|
|
9
|
+
maxSelected?: MaxSelected & {
|
|
10
|
+
isLimitReached: boolean;
|
|
11
|
+
};
|
|
9
12
|
setSelectedOptions: (any: any) => void;
|
|
10
13
|
toggleOption: (option: string, event: React.KeyboardEvent | React.PointerEvent) => void;
|
|
11
14
|
};
|
|
12
15
|
export declare const SelectedOptionsProvider: ({ children, value, }: {
|
|
13
16
|
children: any;
|
|
14
|
-
value: Pick<ComboboxProps, "allowNewValues" | "isMultiSelect" | "options" | "selectedOptions" | "onToggleSelected">;
|
|
17
|
+
value: Pick<ComboboxProps, "allowNewValues" | "isMultiSelect" | "options" | "selectedOptions" | "onToggleSelected" | "maxSelected">;
|
|
15
18
|
}) => React.JSX.Element;
|
|
16
19
|
export declare const useSelectedOptionsContext: () => SelectedOptionsContextType;
|
|
17
20
|
export {};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { createContext, useCallback, useContext, useMemo, useState, } from "react";
|
|
2
|
-
import { usePrevious } from "../../../util/hooks";
|
|
3
|
-
import { useInputContext } from "../Input/inputContext";
|
|
4
|
-
import { useCustomOptionsContext } from "../customOptionsContext";
|
|
2
|
+
import { usePrevious } from "../../../util/hooks/index.js";
|
|
3
|
+
import { useInputContext } from "../Input/inputContext.js";
|
|
4
|
+
import { useCustomOptionsContext } from "../customOptionsContext.js";
|
|
5
5
|
const SelectedOptionsContext = createContext({});
|
|
6
6
|
export const SelectedOptionsProvider = ({ children, value, }) => {
|
|
7
7
|
const { clearInput, focusInput } = useInputContext();
|
|
8
8
|
const { customOptions, removeCustomOption, addCustomOption, setCustomOptions, } = useCustomOptionsContext();
|
|
9
|
-
const { allowNewValues, isMultiSelect, selectedOptions: externalSelectedOptions, onToggleSelected, options, } = value;
|
|
9
|
+
const { allowNewValues, isMultiSelect, selectedOptions: externalSelectedOptions, onToggleSelected, options, maxSelected, } = value;
|
|
10
10
|
const [internalSelectedOptions, setSelectedOptions] = useState([]);
|
|
11
11
|
const selectedOptions = useMemo(() => externalSelectedOptions !== null && externalSelectedOptions !== void 0 ? externalSelectedOptions : [...customOptions, ...internalSelectedOptions], [customOptions, externalSelectedOptions, internalSelectedOptions]);
|
|
12
12
|
const addSelectedOption = useCallback((option) => {
|
|
@@ -64,6 +64,7 @@ export const SelectedOptionsProvider = ({ children, value, }) => {
|
|
|
64
64
|
selectedOptions,
|
|
65
65
|
]);
|
|
66
66
|
const prevSelectedOptions = usePrevious(selectedOptions);
|
|
67
|
+
const isLimitReached = !!(maxSelected === null || maxSelected === void 0 ? void 0 : maxSelected.limit) && selectedOptions.length >= maxSelected.limit;
|
|
67
68
|
const selectedOptionsState = {
|
|
68
69
|
addSelectedOption,
|
|
69
70
|
isMultiSelect,
|
|
@@ -72,6 +73,7 @@ export const SelectedOptionsProvider = ({ children, value, }) => {
|
|
|
72
73
|
selectedOptions,
|
|
73
74
|
setSelectedOptions,
|
|
74
75
|
toggleOption,
|
|
76
|
+
maxSelected: maxSelected && Object.assign(Object.assign({}, maxSelected), { isLimitReached }),
|
|
75
77
|
};
|
|
76
78
|
return (React.createElement(SelectedOptionsContext.Provider, { value: selectedOptionsState }, children));
|
|
77
79
|
};
|