@algolia/satellite 1.0.0-beta.164 → 1.0.0-beta.165
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/AnnouncementBadge/AnnouncementBadge.d.ts +3 -3
- package/cjs/AnnouncementBadge/AnnouncementBadge.js +4 -6
- package/cjs/AnnouncementBadge/index.js +2 -2
- package/cjs/AutoComplete/AutoComplete.d.ts +3 -49
- package/cjs/AutoComplete/AutoComplete.js +347 -516
- package/cjs/AutoComplete/AutoComplete.tailwind.d.ts +1 -1
- package/cjs/AutoComplete/components/AutoCompleteEmptyState.js +2 -4
- package/cjs/AutoComplete/components/AutocompleteContext.d.ts +5 -0
- package/cjs/AutoComplete/components/AutocompleteContext.js +19 -0
- package/cjs/AutoComplete/components/DefaultOptionItem.d.ts +2 -2
- package/cjs/AutoComplete/components/DefaultOptionItem.js +4 -5
- package/cjs/AutoComplete/index.d.ts +1 -0
- package/cjs/AutoComplete/index.js +14 -2
- package/cjs/AutoComplete/types.d.ts +1 -1
- package/cjs/AutoComplete/utils.d.ts +3 -0
- package/cjs/AutoComplete/utils.js +36 -6
- package/cjs/Avatars/ApplicationAvatar.js +2 -4
- package/cjs/Avatars/UserAvatar.js +4 -6
- package/cjs/Avatars/index.js +2 -2
- package/cjs/Avatars/utils.js +9 -13
- package/cjs/Badge/Badge.d.ts +0 -2
- package/cjs/Badge/Badge.js +4 -6
- package/cjs/Badge/index.js +2 -2
- package/cjs/Banners/Alert/Alert.d.ts +2 -2
- package/cjs/Banners/Alert/Alert.js +2 -4
- package/cjs/Banners/Alert/index.js +2 -2
- package/cjs/Banners/BigBertha/BigBertha.js +2 -4
- package/cjs/Banners/BigBertha/index.js +2 -2
- package/cjs/Banners/Promote/Promote.d.ts +0 -6
- package/cjs/Banners/Promote/Promote.js +2 -10
- package/cjs/Banners/Promote/index.js +2 -2
- package/cjs/Button/Button.js +4 -6
- package/cjs/Button/Button.tailwind.d.ts +1 -1
- package/cjs/Button/Button.tailwind.js +1 -1
- package/cjs/Button/ButtonGroup.d.ts +1 -1
- package/cjs/Button/ButtonGroup.js +2 -4
- package/cjs/Button/IconButton.d.ts +5 -0
- package/cjs/Button/IconButton.js +9 -6
- package/cjs/Button/PolymorphicButton.js +5 -6
- package/cjs/Button/PolymorphicIconButton.d.ts +5 -1
- package/cjs/Button/PolymorphicIconButton.js +12 -12
- package/cjs/Button/index.js +2 -2
- package/cjs/Button/styles.d.ts +1 -1
- package/cjs/Button/styles.js +8 -9
- package/cjs/Button/types.d.ts +3 -2
- package/cjs/Card/Card.d.ts +1 -1
- package/cjs/Card/Card.js +4 -6
- package/cjs/Card/Card.tailwind.d.ts +1 -1
- package/cjs/Card/components/CardHeader.js +4 -6
- package/cjs/Card/components/CardTitle.js +4 -6
- package/cjs/Card/index.js +2 -2
- package/cjs/Checkbox/Checkbox.d.ts +3 -3
- package/cjs/Checkbox/Checkbox.js +6 -8
- package/cjs/Checkbox/Checkbox.tailwind.d.ts +1 -1
- package/cjs/Checkbox/Checkbox.tailwind.js +5 -0
- package/cjs/Checkbox/index.js +2 -2
- package/cjs/ClickAwayContainer/ClickAwayContainer.js +5 -9
- package/cjs/DatePicker/DatePicker/DatePicker.d.ts +1 -1
- package/cjs/DatePicker/DatePicker/DatePicker.js +11 -12
- package/cjs/DatePicker/DatePicker/datePickerReducer.js +8 -11
- package/cjs/DatePicker/DatePicker/index.js +2 -2
- package/cjs/DatePicker/DatePicker.tailwind.d.ts +1 -1
- package/cjs/DatePicker/DateRangePicker/DateRangePicker.js +5 -7
- package/cjs/DatePicker/DateRangePicker/DateRangePickerDisplay.js +1 -2
- package/cjs/DatePicker/DateRangePicker/dateRangePickerReducer.js +8 -11
- package/cjs/DatePicker/DateRangePicker/dateRangePickerTimeRange.js +4 -7
- package/cjs/DatePicker/DateRangePicker/index.js +2 -2
- package/cjs/DatePicker/components/Calendar.js +3 -4
- package/cjs/DatePicker/components/Display.js +1 -2
- package/cjs/DatePicker/components/Footer.js +1 -2
- package/cjs/DatePicker/components/FooterActions.js +1 -2
- package/cjs/DatePicker/components/Modal.js +4 -6
- package/cjs/DatePicker/components/NavBar.js +3 -4
- package/cjs/DatePicker/components/SidePanel.js +1 -2
- package/cjs/DatePicker/index.d.ts +0 -1
- package/cjs/DatePicker/index.js +2 -17
- package/cjs/DatePicker/utils.js +3 -5
- package/cjs/Dropdown/Dropdown.js +5 -8
- package/cjs/Dropdown/DropdownButton.js +4 -6
- package/cjs/Dropdown/DropdownContext.js +3 -6
- package/cjs/Dropdown/components/DropdownButtonItem.d.ts +1 -1
- package/cjs/Dropdown/components/DropdownButtonItem.js +4 -6
- package/cjs/Dropdown/components/DropdownCollapsibleItem/DropdownCollapsibleItem.js +3 -5
- package/cjs/Dropdown/components/DropdownCollapsibleItem/DropdownCollapsibleItemsGroup.js +2 -3
- package/cjs/Dropdown/components/DropdownCollapsibleItem/DropdownCollapsibleItemsGroupContext.js +3 -5
- package/cjs/Dropdown/components/DropdownCollapsibleItem/DropdownCollapsibleItemsMultiGroup.js +2 -3
- package/cjs/Dropdown/components/DropdownCollapsibleItem/DropdownCollapsibleItemsSingleGroup.js +2 -3
- package/cjs/Dropdown/components/DropdownDivider.js +2 -4
- package/cjs/Dropdown/components/DropdownFooterItem.d.ts +1 -0
- package/cjs/Dropdown/components/DropdownFooterItem.js +4 -6
- package/cjs/Dropdown/components/DropdownLinkItem.js +4 -6
- package/cjs/Dropdown/components/DropdownRadioItem.js +4 -6
- package/cjs/Dropdown/components/DropdownTitle.js +4 -6
- package/cjs/Dropdown/components/DropdownToggleItem.js +4 -6
- package/cjs/Dropdown/index.js +2 -2
- package/cjs/Dropdown/useDropdownItemProps.js +4 -6
- package/cjs/Dropzone/Dropzone.js +6 -8
- package/cjs/Dropzone/index.js +2 -2
- package/cjs/EmptyState/EmptyState.js +26 -28
- package/cjs/EmptyState/EmptyState.tailwind.d.ts +1 -1
- package/cjs/EmptyState/index.js +2 -2
- package/cjs/EmptyState/types.d.ts +8 -23
- package/cjs/Field/Field.d.ts +0 -1
- package/cjs/Field/Field.js +4 -6
- package/cjs/Field/FieldStateContext.js +3 -6
- package/cjs/Field/index.js +2 -2
- package/cjs/Field/useFieldState.js +4 -6
- package/cjs/Flag/Flag.js +5 -7
- package/cjs/Flag/Flag.tailwind.d.ts +1 -1
- package/cjs/Flag/Flags.js +8 -9
- package/cjs/Flag/index.js +2 -2
- package/cjs/FlexGrid/FlexGrid.d.ts +1 -12
- package/cjs/FlexGrid/FlexGrid.js +2 -4
- package/cjs/FlexGrid/FlexGrid.tailwind.d.ts +1 -1
- package/cjs/FlexGrid/FlexGrid.tailwind.js +2 -2
- package/cjs/FlexGrid/index.js +2 -2
- package/cjs/HelpUnderline/HelpUnderline.js +4 -6
- package/cjs/HelpUnderline/HelpUnderline.tailwind.d.ts +1 -1
- package/cjs/HelpUnderline/index.js +2 -2
- package/cjs/Input/Input.d.ts +4 -1
- package/cjs/Input/Input.js +8 -10
- package/cjs/Input/Input.tailwind.d.ts +1 -1
- package/cjs/Input/index.js +2 -2
- package/cjs/Insert/Insert.js +2 -4
- package/cjs/Insert/index.js +2 -2
- package/cjs/InstantSearch/InstantSearch.tailwind.d.ts +1 -1
- package/cjs/KeyboardKey/KeyboardKey.js +2 -3
- package/cjs/KeyboardKey/KeyboardKey.tailwind.d.ts +1 -1
- package/cjs/Link/BaseLink.js +4 -6
- package/cjs/Link/ButtonLink.js +4 -6
- package/cjs/Link/IconButtonLink.js +4 -6
- package/cjs/Link/Link.d.ts +2 -2
- package/cjs/Link/Link.js +4 -6
- package/cjs/Link/index.js +2 -2
- package/cjs/Medallion/Medallion.d.ts +1 -0
- package/cjs/Medallion/Medallion.js +2 -4
- package/cjs/Medallion/Medallion.tailwind.d.ts +1 -1
- package/cjs/Medallion/index.js +2 -2
- package/cjs/Modal/Modal.js +12 -13
- package/cjs/Modal/Modal.tailwind.d.ts +1 -1
- package/cjs/Modal/components/ModalFooter.js +4 -6
- package/cjs/Modal/components/ModalSection.js +2 -4
- package/cjs/Modal/index.js +2 -2
- package/cjs/Pagination/CompactPagination/CompactPagination.js +6 -10
- package/cjs/Pagination/CompactPagination/index.js +2 -2
- package/cjs/Pagination/DotPagination/DotPagination.js +5 -7
- package/cjs/Pagination/DotPagination/index.js +2 -2
- package/cjs/Pagination/Pagination/Pagination.js +6 -8
- package/cjs/Pagination/Pagination/index.js +2 -2
- package/cjs/Pagination/index.js +2 -2
- package/cjs/Popover/Popover.d.ts +5 -0
- package/cjs/Popover/Popover.js +137 -0
- package/cjs/Popover/index.d.ts +3 -0
- package/cjs/Popover/index.js +36 -0
- package/cjs/Popover/types.d.ts +74 -0
- package/cjs/Popover/types.js +5 -0
- package/cjs/ProgressBar/ProgressBar.js +6 -7
- package/cjs/ProgressBar/ProgressBar.tailwind.d.ts +1 -1
- package/cjs/ProgressBar/index.js +2 -2
- package/cjs/ProgressSpinner/ProgressSpinner.js +4 -6
- package/cjs/ProgressSpinner/ProgressSpinner.tailwind.d.ts +1 -1
- package/cjs/ProgressSpinner/ProgressSpinner.tailwind.js +8 -0
- package/cjs/ProgressSpinner/index.js +2 -2
- package/cjs/RadioGroup/RadioButton.d.ts +1 -1
- package/cjs/RadioGroup/RadioButton.js +4 -6
- package/cjs/RadioGroup/RadioButton.tailwind.d.ts +1 -1
- package/cjs/RadioGroup/RadioButton.tailwind.js +3 -0
- package/cjs/RadioGroup/RadioGroup.d.ts +1 -0
- package/cjs/RadioGroup/RadioGroup.js +3 -6
- package/cjs/RadioGroup/RadiogroupContext.d.ts +1 -4
- package/cjs/RadioGroup/RadiogroupContext.js +3 -5
- package/cjs/RadioGroup/index.js +2 -2
- package/cjs/RangeSlider/RangeSlider.d.ts +2 -0
- package/cjs/RangeSlider/RangeSlider.js +4 -6
- package/cjs/RangeSlider/index.js +2 -2
- package/cjs/Satellite/Satellite.js +5 -7
- package/cjs/Satellite/SatelliteContext.js +5 -8
- package/cjs/Satellite/SatelliteRouter.js +2 -4
- package/cjs/Satellite/index.js +2 -2
- package/cjs/Satellite/locale.d.ts +2 -0
- package/cjs/Satellite/locale.js +2 -3
- package/cjs/Satellite/useCreatePortal.js +2 -3
- package/cjs/ScrollIndicator/ScrollIndicator.js +2 -4
- package/cjs/ScrollIndicator/ScrollIndicator.tailwind.d.ts +1 -1
- package/cjs/ScrollIndicator/index.js +2 -2
- package/cjs/Select/Select.js +4 -6
- package/cjs/Select/Select.tailwind.d.ts +1 -1
- package/cjs/Select/index.js +2 -2
- package/cjs/Separator/Separator.d.ts +1 -0
- package/cjs/Separator/Separator.js +21 -11
- package/cjs/Separator/Separator.tailwind.d.ts +1 -1
- package/cjs/Separator/Separator.tailwind.js +31 -2
- package/cjs/Separator/index.js +2 -2
- package/cjs/Sidebar/Sidebar.d.ts +1 -0
- package/cjs/Sidebar/Sidebar.js +4 -5
- package/cjs/Sidebar/SidebarButtonLink.js +4 -5
- package/cjs/Sidebar/SidebarContext.js +3 -5
- package/cjs/Sidebar/SidebarHeader.d.ts +1 -0
- package/cjs/Sidebar/SidebarHeader.js +2 -3
- package/cjs/Sidebar/SidebarHeading.d.ts +1 -0
- package/cjs/Sidebar/SidebarHeading.js +2 -3
- package/cjs/Sidebar/SidebarLink.js +4 -5
- package/cjs/Sidebar/SidebarLinksGroup/ActiveLinkIndicator.d.ts +1 -0
- package/cjs/Sidebar/SidebarLinksGroup/ActiveLinkIndicator.js +3 -4
- package/cjs/Sidebar/SidebarLinksGroup/SidebarGroupLink.js +4 -5
- package/cjs/Sidebar/SidebarLinksGroup/SidebarLinksGroup.d.ts +1 -0
- package/cjs/Sidebar/SidebarLinksGroup/SidebarLinksGroup.js +6 -7
- package/cjs/Sidebar/SidebarNav.d.ts +1 -0
- package/cjs/Sidebar/SidebarNav.js +2 -3
- package/cjs/Switch/Switch.d.ts +1 -0
- package/cjs/Switch/Switch.js +5 -5
- package/cjs/Switch/Switch.tailwind.d.ts +1 -1
- package/cjs/Switch/SwitchOption.js +5 -7
- package/cjs/Switch/index.js +2 -2
- package/cjs/Switch/utils.js +5 -9
- package/cjs/Tables/DataTable/DataTable.d.ts +8 -1
- package/cjs/Tables/DataTable/DataTable.js +6 -8
- package/cjs/Tables/DataTable/DataTable.tailwind.d.ts +1 -1
- package/cjs/Tables/DataTable/components/Body.js +4 -6
- package/cjs/Tables/DataTable/components/Footer.js +6 -8
- package/cjs/Tables/DataTable/components/Header.js +2 -4
- package/cjs/Tables/DataTable/components/HeaderCell.js +6 -8
- package/cjs/Tables/DataTable/components/Loader.d.ts +1 -0
- package/cjs/Tables/DataTable/components/Loader.js +3 -5
- package/cjs/Tables/DataTable/index.js +2 -2
- package/cjs/Tables/DataTable/types.d.ts +14 -0
- package/cjs/Tables/DataTable/utils.js +4 -7
- package/cjs/Tables/Table/Table.js +4 -6
- package/cjs/Tables/Table/Table.tailwind.d.ts +1 -1
- package/cjs/Tables/Table/components/TableFooter.js +2 -4
- package/cjs/Tables/Table/index.js +2 -2
- package/cjs/Tables/index.js +2 -2
- package/cjs/Tabs/ContentTabs.js +2 -4
- package/cjs/Tabs/LinkTabs.js +3 -6
- package/cjs/Tabs/Tabs.tailwind.d.ts +1 -1
- package/cjs/Tabs/Tabs.tailwind.js +20 -1
- package/cjs/Tabs/components/LinkTab.js +12 -14
- package/cjs/Tabs/index.js +2 -2
- package/cjs/Tabs/types.d.ts +0 -1
- package/cjs/Tabs/utils.js +2 -3
- package/cjs/Tag/Tag.d.ts +7 -17
- package/cjs/Tag/Tag.js +16 -12
- package/cjs/Tag/Tag.tailwind.d.ts +1 -1
- package/cjs/Tag/index.js +2 -2
- package/cjs/TextArea/TextArea.js +4 -6
- package/cjs/TextArea/TextArea.tailwind.d.ts +1 -1
- package/cjs/TextArea/index.js +2 -2
- package/cjs/TextWrap/TextWrap.js +4 -6
- package/cjs/TextWrap/index.js +2 -2
- package/cjs/Toggle/Toggle.d.ts +6 -2
- package/cjs/Toggle/Toggle.js +26 -13
- package/cjs/Toggle/Toggle.tailwind.d.ts +1 -1
- package/cjs/Toggle/Toggle.tailwind.js +18 -6
- package/cjs/Toggle/index.js +2 -2
- package/cjs/Tooltip/OverflowTooltipWrapper.js +4 -5
- package/cjs/Tooltip/Tooltip.d.ts +1 -1
- package/cjs/Tooltip/Tooltip.js +4 -6
- package/cjs/Tooltip/Tooltip.tailwind.d.ts +1 -1
- package/cjs/Tooltip/Tooltip.tailwind.js +1 -91
- package/cjs/Tooltip/TooltipWrapper.d.ts +2 -2
- package/cjs/Tooltip/TooltipWrapper.js +7 -8
- package/cjs/Tooltip/index.js +2 -2
- package/cjs/Tooltip/types.d.ts +15 -15
- package/cjs/Tooltip/utils.js +2 -3
- package/cjs/Typography/Typography.tailwind.d.ts +1 -1
- package/cjs/Typography/Typography.tailwind.js +2 -2
- package/cjs/UserContent/UserContent.d.ts +1 -0
- package/cjs/UserContent/UserContent.js +2 -4
- package/cjs/UserContent/UserContent.tailwind.d.ts +1 -1
- package/cjs/UserContent/UserContent.tailwind.js +2 -2
- package/cjs/styles/base.tailwind.d.ts +1 -1
- package/cjs/styles/helpers/makePurgeCssExtractor.js +1 -1
- package/cjs/styles/tailwind.config.js +3 -3
- package/cjs/styles/zIndexes.d.ts +1 -0
- package/cjs/styles/zIndexes.js +4 -3
- package/cjs/types.d.ts +2 -3
- package/cjs/utilities/overlay.tailwind.d.ts +5 -0
- package/cjs/utilities/overlay.tailwind.js +107 -0
- package/cjs/utilities/utilities.tailwind.d.ts +1 -1
- package/cjs/utils/genericChangeHandler.js +1 -2
- package/cjs/utils/hashCode.js +2 -4
- package/cjs/utils/isCssPropertySupported.d.ts +1 -1
- package/cjs/utils/isCssPropertySupported.js +1 -2
- package/cjs/utils/isNil.js +2 -4
- package/cjs/utils/isReactText.js +2 -3
- package/cjs/utils/isRenderedChild.js +1 -2
- package/cjs/utils/matchLocation.js +1 -2
- package/cjs/utils/onlyText.js +1 -2
- package/cjs/utils/parseUrl.js +2 -4
- package/cjs/utils/pluralize.js +1 -2
- package/cjs/utils/prefersReducedMotion.d.ts +6 -0
- package/cjs/utils/prefersReducedMotion.js +12 -0
- package/cjs/utils/range.js +1 -2
- package/cjs/utils/toSentenceCase.js +2 -4
- package/cjs/utils/uniqBy.js +1 -2
- package/cjs/utils/uniqueId.js +1 -2
- package/cjs/utils/useForwardedRef.js +1 -2
- package/cjs/utils/useLinkProps.js +2 -4
- package/cjs/utils/useTriggerInputChange.js +1 -2
- package/esm/AnnouncementBadge/AnnouncementBadge.d.ts +3 -3
- package/esm/AnnouncementBadge/AnnouncementBadge.js +2 -2
- package/esm/AutoComplete/AutoComplete.d.ts +3 -49
- package/esm/AutoComplete/AutoComplete.js +350 -517
- package/esm/AutoComplete/AutoComplete.tailwind.d.ts +1 -1
- package/esm/AutoComplete/components/AutocompleteContext.d.ts +5 -0
- package/esm/AutoComplete/components/AutocompleteContext.js +13 -0
- package/esm/AutoComplete/components/DefaultOptionItem.d.ts +2 -2
- package/esm/AutoComplete/components/DefaultOptionItem.js +2 -2
- package/esm/AutoComplete/index.d.ts +1 -0
- package/esm/AutoComplete/index.js +1 -0
- package/esm/AutoComplete/types.d.ts +1 -1
- package/esm/AutoComplete/utils.d.ts +3 -0
- package/esm/AutoComplete/utils.js +31 -1
- package/esm/Avatars/UserAvatar.js +2 -2
- package/esm/Avatars/utils.js +2 -2
- package/esm/Badge/Badge.d.ts +0 -2
- package/esm/Badge/Badge.js +2 -2
- package/esm/Banners/Alert/Alert.d.ts +2 -2
- package/esm/Banners/Promote/Promote.d.ts +0 -6
- package/esm/Banners/Promote/Promote.js +0 -6
- package/esm/Button/Button.js +2 -2
- package/esm/Button/Button.tailwind.d.ts +1 -1
- package/esm/Button/Button.tailwind.js +1 -1
- package/esm/Button/ButtonGroup.d.ts +1 -1
- package/esm/Button/IconButton.d.ts +5 -0
- package/esm/Button/IconButton.js +7 -2
- package/esm/Button/PolymorphicButton.js +2 -2
- package/esm/Button/PolymorphicIconButton.d.ts +5 -1
- package/esm/Button/PolymorphicIconButton.js +11 -10
- package/esm/Button/styles.d.ts +1 -1
- package/esm/Button/styles.js +3 -0
- package/esm/Button/types.d.ts +3 -2
- package/esm/Card/Card.d.ts +1 -1
- package/esm/Card/Card.js +2 -2
- package/esm/Card/Card.tailwind.d.ts +1 -1
- package/esm/Card/components/CardHeader.js +2 -2
- package/esm/Card/components/CardTitle.js +2 -2
- package/esm/Checkbox/Checkbox.d.ts +3 -3
- package/esm/Checkbox/Checkbox.js +4 -4
- package/esm/Checkbox/Checkbox.tailwind.d.ts +1 -1
- package/esm/Checkbox/Checkbox.tailwind.js +5 -0
- package/esm/ClickAwayContainer/ClickAwayContainer.js +1 -1
- package/esm/DatePicker/DatePicker/DatePicker.d.ts +1 -1
- package/esm/DatePicker/DatePicker/DatePicker.js +9 -9
- package/esm/DatePicker/DatePicker/datePickerReducer.js +5 -5
- package/esm/DatePicker/DatePicker.tailwind.d.ts +1 -1
- package/esm/DatePicker/DateRangePicker/DateRangePicker.js +3 -3
- package/esm/DatePicker/DateRangePicker/dateRangePickerReducer.js +5 -5
- package/esm/DatePicker/components/Calendar.js +2 -2
- package/esm/DatePicker/components/Modal.js +2 -2
- package/esm/DatePicker/components/NavBar.js +2 -2
- package/esm/DatePicker/index.d.ts +0 -1
- package/esm/DatePicker/index.js +0 -1
- package/esm/Dropdown/Dropdown.js +2 -2
- package/esm/Dropdown/DropdownButton.js +2 -2
- package/esm/Dropdown/components/DropdownButtonItem.d.ts +1 -1
- package/esm/Dropdown/components/DropdownButtonItem.js +2 -2
- package/esm/Dropdown/components/DropdownCollapsibleItem/DropdownCollapsibleItem.js +1 -1
- package/esm/Dropdown/components/DropdownFooterItem.d.ts +1 -0
- package/esm/Dropdown/components/DropdownFooterItem.js +2 -2
- package/esm/Dropdown/components/DropdownLinkItem.js +2 -2
- package/esm/Dropdown/components/DropdownRadioItem.js +2 -2
- package/esm/Dropdown/components/DropdownTitle.js +2 -2
- package/esm/Dropdown/components/DropdownToggleItem.js +2 -2
- package/esm/Dropdown/useDropdownItemProps.js +2 -2
- package/esm/Dropzone/Dropzone.js +4 -4
- package/esm/EmptyState/EmptyState.js +24 -24
- package/esm/EmptyState/EmptyState.tailwind.d.ts +1 -1
- package/esm/EmptyState/types.d.ts +8 -23
- package/esm/Field/Field.d.ts +0 -1
- package/esm/Flag/Flag.js +3 -3
- package/esm/Flag/Flag.tailwind.d.ts +1 -1
- package/esm/Flag/Flags.js +6 -5
- package/esm/FlexGrid/FlexGrid.d.ts +1 -12
- package/esm/FlexGrid/FlexGrid.tailwind.d.ts +1 -1
- package/esm/FlexGrid/FlexGrid.tailwind.js +2 -2
- package/esm/HelpUnderline/HelpUnderline.js +2 -2
- package/esm/HelpUnderline/HelpUnderline.tailwind.d.ts +1 -1
- package/esm/Input/Input.d.ts +4 -1
- package/esm/Input/Input.js +6 -6
- package/esm/Input/Input.tailwind.d.ts +1 -1
- package/esm/InstantSearch/InstantSearch.tailwind.d.ts +1 -1
- package/esm/KeyboardKey/KeyboardKey.tailwind.d.ts +1 -1
- package/esm/Link/BaseLink.js +2 -2
- package/esm/Link/ButtonLink.js +2 -2
- package/esm/Link/IconButtonLink.js +2 -2
- package/esm/Link/Link.d.ts +2 -2
- package/esm/Link/Link.js +2 -2
- package/esm/Medallion/Medallion.d.ts +1 -0
- package/esm/Medallion/Medallion.tailwind.d.ts +1 -1
- package/esm/Modal/Modal.js +8 -7
- package/esm/Modal/Modal.tailwind.d.ts +1 -1
- package/esm/Modal/components/ModalFooter.js +2 -2
- package/esm/Pagination/CompactPagination/CompactPagination.js +2 -2
- package/esm/Pagination/DotPagination/DotPagination.js +3 -3
- package/esm/Pagination/Pagination/Pagination.js +2 -2
- package/esm/Popover/Popover.d.ts +5 -0
- package/esm/Popover/Popover.js +129 -0
- package/esm/Popover/index.d.ts +3 -0
- package/esm/Popover/index.js +3 -0
- package/esm/Popover/types.d.ts +74 -0
- package/esm/Popover/types.js +1 -0
- package/esm/ProgressBar/ProgressBar.js +4 -3
- package/esm/ProgressBar/ProgressBar.tailwind.d.ts +1 -1
- package/esm/ProgressSpinner/ProgressSpinner.js +2 -2
- package/esm/ProgressSpinner/ProgressSpinner.tailwind.d.ts +1 -1
- package/esm/ProgressSpinner/ProgressSpinner.tailwind.js +8 -0
- package/esm/RadioGroup/RadioButton.d.ts +1 -1
- package/esm/RadioGroup/RadioButton.js +2 -2
- package/esm/RadioGroup/RadioButton.tailwind.d.ts +1 -1
- package/esm/RadioGroup/RadioButton.tailwind.js +3 -0
- package/esm/RadioGroup/RadioGroup.d.ts +1 -0
- package/esm/RadioGroup/RadiogroupContext.d.ts +1 -4
- package/esm/RangeSlider/RangeSlider.d.ts +2 -0
- package/esm/RangeSlider/RangeSlider.js +2 -2
- package/esm/Satellite/Satellite.js +4 -4
- package/esm/Satellite/SatelliteContext.js +2 -2
- package/esm/Satellite/locale.d.ts +2 -0
- package/esm/ScrollIndicator/ScrollIndicator.tailwind.d.ts +1 -1
- package/esm/Select/Select.js +2 -2
- package/esm/Select/Select.tailwind.d.ts +1 -1
- package/esm/Separator/Separator.d.ts +1 -0
- package/esm/Separator/Separator.js +17 -5
- package/esm/Separator/Separator.tailwind.d.ts +1 -1
- package/esm/Separator/Separator.tailwind.js +31 -2
- package/esm/Sidebar/Sidebar.d.ts +1 -0
- package/esm/Sidebar/Sidebar.js +2 -2
- package/esm/Sidebar/SidebarButtonLink.js +2 -2
- package/esm/Sidebar/SidebarHeader.d.ts +1 -0
- package/esm/Sidebar/SidebarHeading.d.ts +1 -0
- package/esm/Sidebar/SidebarLink.js +2 -2
- package/esm/Sidebar/SidebarLinksGroup/ActiveLinkIndicator.d.ts +1 -0
- package/esm/Sidebar/SidebarLinksGroup/ActiveLinkIndicator.js +1 -1
- package/esm/Sidebar/SidebarLinksGroup/SidebarGroupLink.js +2 -2
- package/esm/Sidebar/SidebarLinksGroup/SidebarLinksGroup.d.ts +1 -0
- package/esm/Sidebar/SidebarLinksGroup/SidebarLinksGroup.js +4 -4
- package/esm/Sidebar/SidebarNav.d.ts +1 -0
- package/esm/Switch/Switch.d.ts +1 -0
- package/esm/Switch/Switch.js +3 -1
- package/esm/Switch/Switch.tailwind.d.ts +1 -1
- package/esm/Switch/SwitchOption.js +3 -3
- package/esm/Tables/DataTable/DataTable.d.ts +8 -1
- package/esm/Tables/DataTable/DataTable.js +4 -4
- package/esm/Tables/DataTable/DataTable.tailwind.d.ts +1 -1
- package/esm/Tables/DataTable/components/Body.js +2 -2
- package/esm/Tables/DataTable/components/Footer.js +2 -2
- package/esm/Tables/DataTable/components/HeaderCell.js +4 -4
- package/esm/Tables/DataTable/components/Loader.d.ts +1 -0
- package/esm/Tables/DataTable/components/Loader.js +1 -1
- package/esm/Tables/DataTable/types.d.ts +14 -0
- package/esm/Tables/Table/Table.js +2 -2
- package/esm/Tables/Table/Table.tailwind.d.ts +1 -1
- package/esm/Tabs/Tabs.tailwind.d.ts +1 -1
- package/esm/Tabs/Tabs.tailwind.js +20 -1
- package/esm/Tabs/components/LinkTab.js +10 -10
- package/esm/Tabs/types.d.ts +0 -1
- package/esm/Tag/Tag.d.ts +7 -17
- package/esm/Tag/Tag.js +14 -8
- package/esm/Tag/Tag.tailwind.d.ts +1 -1
- package/esm/TextArea/TextArea.js +2 -2
- package/esm/TextArea/TextArea.tailwind.d.ts +1 -1
- package/esm/TextWrap/TextWrap.js +2 -2
- package/esm/Toggle/Toggle.d.ts +6 -2
- package/esm/Toggle/Toggle.js +24 -9
- package/esm/Toggle/Toggle.tailwind.d.ts +1 -1
- package/esm/Toggle/Toggle.tailwind.js +18 -6
- package/esm/Tooltip/OverflowTooltipWrapper.js +2 -2
- package/esm/Tooltip/Tooltip.d.ts +1 -1
- package/esm/Tooltip/Tooltip.js +2 -2
- package/esm/Tooltip/Tooltip.tailwind.d.ts +1 -1
- package/esm/Tooltip/Tooltip.tailwind.js +1 -90
- package/esm/Tooltip/TooltipWrapper.d.ts +2 -2
- package/esm/Tooltip/TooltipWrapper.js +3 -3
- package/esm/Tooltip/types.d.ts +15 -15
- package/esm/Typography/Typography.tailwind.d.ts +1 -1
- package/esm/Typography/Typography.tailwind.js +2 -2
- package/esm/UserContent/UserContent.d.ts +1 -0
- package/esm/UserContent/UserContent.tailwind.d.ts +1 -1
- package/esm/UserContent/UserContent.tailwind.js +2 -2
- package/esm/styles/base.tailwind.d.ts +1 -1
- package/esm/styles/helpers/makePurgeCssExtractor.js +1 -1
- package/esm/styles/tailwind.config.js +3 -3
- package/esm/styles/zIndexes.d.ts +1 -0
- package/esm/styles/zIndexes.js +4 -3
- package/esm/types.d.ts +2 -3
- package/esm/utilities/overlay.tailwind.d.ts +5 -0
- package/esm/utilities/overlay.tailwind.js +106 -0
- package/esm/utilities/utilities.tailwind.d.ts +1 -1
- package/esm/utils/isCssPropertySupported.d.ts +1 -1
- package/esm/utils/prefersReducedMotion.d.ts +6 -0
- package/esm/utils/prefersReducedMotion.js +6 -0
- package/package.json +9 -7
- package/satellite.min.css +1 -1
- package/scss/variables.scss +4 -3
@@ -8,109 +8,40 @@ exports["default"] = exports.AutoComplete = void 0;
|
|
8
8
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
9
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
11
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
12
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
13
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
14
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
15
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
16
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
17
11
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
18
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
19
12
|
var _clsx = _interopRequireDefault(require("clsx"));
|
20
|
-
var _downshift =
|
13
|
+
var _downshift = require("downshift");
|
21
14
|
var _react = require("react");
|
22
|
-
var _reactDom = require("react-dom");
|
23
15
|
var _reactFeather = require("react-feather");
|
24
16
|
var _reactPopper = require("react-popper");
|
25
|
-
var
|
26
|
-
var _Card =
|
17
|
+
var _useMeasure3 = _interopRequireDefault(require("react-use/lib/useMeasure"));
|
18
|
+
var _Card = require("../Card");
|
27
19
|
var _ClickAwayContainer = require("../ClickAwayContainer");
|
28
|
-
var
|
20
|
+
var _Field = require("../Field");
|
29
21
|
var _Satellite = require("../Satellite");
|
30
22
|
var _ScrollIndicator = _interopRequireDefault(require("../ScrollIndicator"));
|
31
23
|
var _satellitePrefixer = _interopRequireDefault(require("../styles/helpers/satellitePrefixer"));
|
32
24
|
var _Tag = _interopRequireDefault(require("../Tag"));
|
33
25
|
var _uniqBy = _interopRequireDefault(require("../utils/uniqBy"));
|
26
|
+
var _AutocompleteContext = require("./components/AutocompleteContext");
|
34
27
|
var _AutoCompleteEmptyState = _interopRequireDefault(require("./components/AutoCompleteEmptyState"));
|
35
|
-
var _DefaultOptionItem =
|
28
|
+
var _DefaultOptionItem = require("./components/DefaultOptionItem");
|
36
29
|
var _utils = require("./utils");
|
37
30
|
var _jsxRuntime = require("react/jsx-runtime");
|
38
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17;
|
39
|
-
var
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
function optionToString(option) {
|
49
|
-
return option ? option.label : "";
|
50
|
-
}
|
51
|
-
function makeNeedles(itemValue) {
|
52
|
-
return itemValue.toLowerCase().trim().split(/\s+/);
|
53
|
-
}
|
54
|
-
function needlesMatch(needles, option) {
|
55
|
-
var labels = (option.metadata || []).concat(option.label);
|
56
|
-
return needles.every(function (needle) {
|
57
|
-
return labels.some(function (label) {
|
58
|
-
return String(label || "").trim().toLowerCase().includes(needle);
|
59
|
-
});
|
60
|
-
});
|
61
|
-
}
|
62
|
-
function filter(options, selectedItems, itemValue) {
|
63
|
-
var needles = makeNeedles(itemValue);
|
64
|
-
var selectedValues = selectedItems.map(function (option) {
|
65
|
-
return option.value;
|
66
|
-
});
|
67
|
-
var results = [];
|
68
|
-
var _iterator = _createForOfIteratorHelper(options),
|
69
|
-
_step;
|
70
|
-
try {
|
71
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
72
|
-
var option = _step.value;
|
73
|
-
if (selectedValues.includes(option.value)) {
|
74
|
-
continue;
|
75
|
-
} else if (option.bypassNeedleMatch || needlesMatch(needles, option)) {
|
76
|
-
results.push(option);
|
77
|
-
}
|
78
|
-
}
|
79
|
-
} catch (err) {
|
80
|
-
_iterator.e(err);
|
81
|
-
} finally {
|
82
|
-
_iterator.f();
|
83
|
-
}
|
84
|
-
return results;
|
85
|
-
}
|
86
|
-
function inputValueFromProps(props) {
|
87
|
-
if (props.inputValue !== undefined) {
|
88
|
-
return props.inputValue;
|
89
|
-
}
|
90
|
-
return !(0, _utils.isAutoCompleteMultiProps)(props) && props.value ? optionToString(props.value) : "";
|
91
|
-
}
|
92
|
-
var MENU_POPPER_MODFIERS = [{
|
93
|
-
name: "offset",
|
94
|
-
options: {
|
95
|
-
offset: [0, 8]
|
96
|
-
}
|
97
|
-
}];
|
98
|
-
/** @ignore */
|
99
|
-
var DefaultEmptyState = function DefaultEmptyState(_ref) {
|
100
|
-
var emptyStateTitle = _ref.emptyStateTitle;
|
101
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_AutoCompleteEmptyState["default"], {
|
102
|
-
title: emptyStateTitle
|
103
|
-
});
|
104
|
-
};
|
105
|
-
var DefaultOption = function DefaultOption(_ref2) {
|
106
|
-
var optionItemPrefix = _ref2.optionItemPrefix,
|
107
|
-
props = (0, _objectWithoutProperties2["default"])(_ref2, _excluded);
|
108
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_DefaultOptionItem["default"], _objectSpread(_objectSpread({}, props), {}, {
|
109
|
-
locale: {
|
110
|
-
optionItemPrefix: optionItemPrefix !== null && optionItemPrefix !== void 0 ? optionItemPrefix : _utils.DEFAULT_AUTOCOMPLETE_LOCALE.optionItemPrefix
|
31
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25, _templateObject26, _templateObject27, _templateObject28;
|
32
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
33
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
34
|
+
var MENU_POPPER_OPTIONS = {
|
35
|
+
strategy: "fixed",
|
36
|
+
placement: "bottom-start",
|
37
|
+
modifiers: [{
|
38
|
+
name: "offset",
|
39
|
+
options: {
|
40
|
+
offset: [0, 8]
|
111
41
|
}
|
112
|
-
}
|
42
|
+
}]
|
113
43
|
};
|
44
|
+
var SHOW_ALL_ITEMS_ID = "__stl_extra_results_option__";
|
114
45
|
|
115
46
|
/**
|
116
47
|
* Autocomplete is a search-as-you-type function that matches what a person types, usually the beginning of a word, or a prefix, with a word list. Not to be confused with auto-suggestion that predicts the end of a query.
|
@@ -128,466 +59,366 @@ var DefaultOption = function DefaultOption(_ref2) {
|
|
128
59
|
* - Provide matching results quickly
|
129
60
|
* - Style different data
|
130
61
|
*/
|
131
|
-
var AutoComplete =
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
62
|
+
var AutoComplete = exports.AutoComplete = function AutoComplete(_ref) {
|
63
|
+
var localeProp = _ref.locale,
|
64
|
+
id = _ref.id,
|
65
|
+
name = _ref.name,
|
66
|
+
placeholder = _ref.placeholder,
|
67
|
+
autoFocus = _ref.autoFocus,
|
68
|
+
inputValueProp = _ref.inputValue,
|
69
|
+
onTextChange = _ref.onTextChange,
|
70
|
+
_onFocus = _ref.onFocus,
|
71
|
+
_onBlur = _ref.onBlur,
|
72
|
+
disabled = _ref.disabled,
|
73
|
+
clearable = _ref.clearable,
|
74
|
+
renderValueTemplate = _ref.renderValueTemplate,
|
75
|
+
noWrap = _ref.noWrap,
|
76
|
+
separatorKeys = _ref.separatorKeys,
|
77
|
+
multiple = _ref.multiple,
|
78
|
+
value = _ref.value,
|
79
|
+
selectOnBlur = _ref.selectOnBlur,
|
80
|
+
onChange = _ref.onChange,
|
81
|
+
options = _ref.options,
|
82
|
+
optionItemComponent = _ref.optionItemComponent,
|
83
|
+
creatable = _ref.creatable,
|
84
|
+
_ref$createFromInputV = _ref.createFromInputValue,
|
85
|
+
createFromInputValue = _ref$createFromInputV === void 0 ? _utils.defaultCreateFromInputValue : _ref$createFromInputV,
|
86
|
+
emptyState = _ref.emptyState,
|
87
|
+
_ref$maxResults = _ref.maxResults,
|
88
|
+
maxItems = _ref$maxResults === void 0 ? 7 : _ref$maxResults,
|
89
|
+
menuFooter = _ref.menuFooter,
|
90
|
+
menuSize = _ref.menuSize,
|
91
|
+
variant = _ref.variant,
|
92
|
+
Icon = _ref.icon,
|
93
|
+
endItem = _ref.endItem,
|
94
|
+
className = _ref.className,
|
95
|
+
menuClassName = _ref.menuClassName,
|
96
|
+
valuesClassName = _ref.valuesClassName;
|
97
|
+
var createPortal = (0, _Satellite.useCreatePortal)();
|
98
|
+
var _useFieldState = (0, _Field.useFieldState)(),
|
99
|
+
status = _useFieldState.status;
|
100
|
+
var localeContext = (0, _Satellite.useLocale)("autoComplete");
|
101
|
+
var locale = (0, _react.useMemo)(function () {
|
102
|
+
return _objectSpread(_objectSpread(_objectSpread({}, _utils.DEFAULT_AUTOCOMPLETE_LOCALE), localeContext), localeProp);
|
103
|
+
}, [localeContext, localeProp]);
|
104
|
+
var inputRef = (0, _react.useRef)(null);
|
105
|
+
var _useState = (0, _react.useState)(false),
|
106
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
107
|
+
inputFocused = _useState2[0],
|
108
|
+
setInputFocused = _useState2[1];
|
109
|
+
var _useState3 = (0, _react.useState)(function () {
|
110
|
+
return (inputValueProp !== null && inputValueProp !== void 0 ? inputValueProp : multiple) ? "" : value ? (0, _utils.optionToString)(value) : "";
|
111
|
+
}),
|
112
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
113
|
+
internalInputValue = _useState4[0],
|
114
|
+
setInternalInputValue = _useState4[1];
|
115
|
+
var inputValue = inputValueProp !== null && inputValueProp !== void 0 ? inputValueProp : internalInputValue;
|
116
|
+
var _useState5 = (0, _react.useState)(null),
|
117
|
+
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
118
|
+
containerElement = _useState6[0],
|
119
|
+
setContainerElement = _useState6[1];
|
120
|
+
var _useMeasure = (0, _useMeasure3["default"])(),
|
121
|
+
_useMeasure2 = (0, _slicedToArray2["default"])(_useMeasure, 2),
|
122
|
+
setContainerMeasureRef = _useMeasure2[0],
|
123
|
+
containerWidth = _useMeasure2[1].width;
|
124
|
+
var menuRef = (0, _react.useRef)(null);
|
125
|
+
var menuPopper = (0, _reactPopper.usePopper)(containerElement, menuRef.current, MENU_POPPER_OPTIONS);
|
126
|
+
var _useState7 = (0, _react.useState)(false),
|
127
|
+
_useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
|
128
|
+
showAllItems = _useState8[0],
|
129
|
+
setShowAllItems = _useState8[1];
|
130
|
+
var selectedItems = (0, _react.useMemo)(function () {
|
131
|
+
return !value ? [] : Array.isArray(value) ? value : [value];
|
132
|
+
}, [value]);
|
133
|
+
var items = (0, _react.useMemo)(function () {
|
134
|
+
var results = (0, _utils.filter)(options !== null && options !== void 0 ? options : [], multiple ? selectedItems : [], inputValue);
|
135
|
+
var emptyInputValue = !inputValue || inputValue.trim().length === 0;
|
136
|
+
if (creatable && !emptyInputValue) {
|
137
|
+
results.unshift.apply(results, (0, _toConsumableArray2["default"])(createFromInputValue(options, inputValue)));
|
139
138
|
}
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "inputContainerRef", null);
|
147
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "inputRef", null);
|
148
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "menuWrapperRef", null);
|
149
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleClearClick", function () {
|
150
|
-
return _this.setState({
|
151
|
-
inputValue: ""
|
152
|
-
}, function () {
|
153
|
-
return _this.props.onChange(null);
|
139
|
+
if (!showAllItems && results.length > maxItems) {
|
140
|
+
var extraResults = results.length - maxItems;
|
141
|
+
var label = locale.showMoreButton(extraResults);
|
142
|
+
results.splice(maxItems, results.length, {
|
143
|
+
value: SHOW_ALL_ITEMS_ID,
|
144
|
+
label: label
|
154
145
|
});
|
155
|
-
}
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
newInputValue = (0, _utils.isAutoCompleteMultiProps)(_this.props) ? "" : optionToString(_this.props.value);
|
170
|
-
selectItemAtIndex(highlightedIndex);
|
171
|
-
} else if ((0, _utils.isAutoCompleteMultiProps)(_this.props)) {
|
172
|
-
newInputValue = inputValue;
|
173
|
-
} else {
|
174
|
-
newInputValue = optionToString(_this.props.value);
|
175
|
-
}
|
176
|
-
if (onBlur) {
|
177
|
-
onBlur(evt);
|
178
|
-
}
|
179
|
-
_this.setState({
|
180
|
-
inputValue: newInputValue || "",
|
181
|
-
inputFocused: false,
|
182
|
-
showAllResults: false
|
183
|
-
});
|
184
|
-
};
|
185
|
-
});
|
186
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleInputChange", function (evt) {
|
187
|
-
var inputValue = evt.target.value;
|
188
|
-
_this.setState({
|
189
|
-
inputValue: inputValue
|
190
|
-
});
|
191
|
-
if (_this.props.onTextChange) {
|
192
|
-
_this.props.onTextChange(inputValue);
|
193
|
-
}
|
194
|
-
if (!_this.props.multiple && _this.props.value && !inputValue) {
|
195
|
-
_this.props.onChange(null);
|
196
|
-
}
|
197
|
-
});
|
198
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleInputContainerRefUpdate", function (el) {
|
199
|
-
_this.inputContainerRef = el;
|
200
|
-
if (el) {
|
201
|
-
_this.updateInputWidth();
|
202
|
-
}
|
203
|
-
});
|
204
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "updateInputWidth", function () {
|
205
|
-
var _this$inputContainerR, _this$inputContainerR2;
|
206
|
-
var inputWidth = _this.state.inputWidth;
|
207
|
-
var newInputWidth = (_this$inputContainerR = (_this$inputContainerR2 = _this.inputContainerRef) === null || _this$inputContainerR2 === void 0 ? void 0 : _this$inputContainerR2.getBoundingClientRect().width) !== null && _this$inputContainerR !== void 0 ? _this$inputContainerR : inputWidth;
|
208
|
-
if (newInputWidth !== inputWidth) {
|
209
|
-
_this.setState({
|
210
|
-
inputWidth: newInputWidth
|
211
|
-
});
|
212
|
-
}
|
213
|
-
});
|
214
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleKeyDown", function (state) {
|
215
|
-
return function (evt) {
|
216
|
-
if (!(0, _utils.isAutoCompleteMultiProps)(_this.props)) return;
|
217
|
-
var _this$props2 = _this.props,
|
218
|
-
_this$props2$value = _this$props2.value,
|
219
|
-
value = _this$props2$value === void 0 ? [] : _this$props2$value,
|
220
|
-
_this$props2$separato = _this$props2.separatorKeys,
|
221
|
-
separatorKeys = _this$props2$separato === void 0 ? AutoComplete.defaultProps.separatorKeys : _this$props2$separato,
|
222
|
-
creatable = _this$props2.creatable,
|
223
|
-
_this$props2$createFr = _this$props2.createFromInputValue,
|
224
|
-
createFromInputValue = _this$props2$createFr === void 0 ? AutoComplete.defaultProps.createFromInputValue : _this$props2$createFr,
|
225
|
-
options = _this$props2.options,
|
226
|
-
onChange = _this$props2.onChange;
|
227
|
-
var inputValue = state.inputValue || "";
|
228
|
-
var canCreate = creatable && inputValue.trim().length > 0;
|
229
|
-
if (evt.key === "Backspace" && !inputValue.length) {
|
230
|
-
onChange(value.slice(0, -1));
|
231
|
-
} else if (canCreate && separatorKeys.includes(evt.key)) {
|
232
|
-
evt.preventDefault();
|
233
|
-
var _createFromInputValue = createFromInputValue(options, inputValue),
|
234
|
-
_createFromInputValue2 = (0, _slicedToArray2["default"])(_createFromInputValue, 1),
|
235
|
-
newOption = _createFromInputValue2[0];
|
236
|
-
if (newOption && !newOption.disabled) {
|
237
|
-
state.selectItem(newOption);
|
238
|
-
}
|
239
|
-
}
|
240
|
-
};
|
241
|
-
});
|
242
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleChange", function (option) {
|
243
|
-
if (option.disabled) return;
|
244
|
-
option = option ? _objectSpread(_objectSpread({}, option), {}, {
|
245
|
-
"new": undefined
|
246
|
-
}) : option;
|
247
|
-
if ((0, _utils.isAutoCompleteMultiProps)(_this.props)) {
|
248
|
-
var arrayValue = Array.isArray(_this.props.value) ? _this.props.value : [];
|
249
|
-
var newValue = (0, _uniqBy["default"])([].concat((0, _toConsumableArray2["default"])(arrayValue), [option]), function (o) {
|
250
|
-
return o.value;
|
251
|
-
});
|
252
|
-
_this.props.onChange(newValue);
|
253
|
-
_this.setState({
|
254
|
-
inputValue: "",
|
255
|
-
showAllResults: false
|
256
|
-
});
|
146
|
+
}
|
147
|
+
return results;
|
148
|
+
}, [creatable, createFromInputValue, inputValue, locale, maxItems, multiple, options, selectedItems, showAllItems]);
|
149
|
+
var hasValue = !!selectedItems.length;
|
150
|
+
var showClearButton = !disabled && clearable && hasValue;
|
151
|
+
var multipleSelection = (0, _downshift.useMultipleSelection)({
|
152
|
+
selectedItems: selectedItems,
|
153
|
+
onSelectedItemsChange: function onSelectedItemsChange(changes) {
|
154
|
+
if (typeof changes.selectedItems === "undefined") {
|
155
|
+
onChange(null);
|
156
|
+
} else if (multiple) {
|
157
|
+
onChange((0, _uniqBy["default"])(changes.selectedItems, function (i) {
|
158
|
+
return i.value;
|
159
|
+
}));
|
257
160
|
} else {
|
258
|
-
|
259
|
-
|
260
|
-
inputValue: option ? option.label : "",
|
261
|
-
showAllResults: false
|
262
|
-
});
|
161
|
+
var _changes$selectedItem;
|
162
|
+
onChange((_changes$selectedItem = changes.selectedItems[0]) !== null && _changes$selectedItem !== void 0 ? _changes$selectedItem : null);
|
263
163
|
}
|
264
|
-
}
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
if (!(0, _utils.isAutoCompleteMultiProps)(_this.props)) return;
|
274
|
-
var currentOptions = _this.props.value || [];
|
275
|
-
var newOptions = currentOptions.filter(function (option) {
|
276
|
-
return option.value !== removedOption.value;
|
164
|
+
}
|
165
|
+
});
|
166
|
+
var combobox = (0, _downshift.useCombobox)({
|
167
|
+
items: items,
|
168
|
+
itemToString: _utils.optionToString,
|
169
|
+
scrollIntoView: function scrollIntoView(node) {
|
170
|
+
var _node$scrollIntoView;
|
171
|
+
return node === null || node === void 0 || (_node$scrollIntoView = node.scrollIntoView) === null || _node$scrollIntoView === void 0 ? void 0 : _node$scrollIntoView.call(node, {
|
172
|
+
block: "nearest"
|
277
173
|
});
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
174
|
+
},
|
175
|
+
defaultHighlightedIndex: 0,
|
176
|
+
getA11yStatusMessage: function getA11yStatusMessage(_ref2) {
|
177
|
+
var isOpen = _ref2.isOpen,
|
178
|
+
resultCount = _ref2.resultCount,
|
179
|
+
previousResultCount = _ref2.previousResultCount;
|
180
|
+
if (!isOpen) {
|
282
181
|
return "";
|
283
182
|
}
|
284
|
-
if (!
|
285
|
-
return
|
183
|
+
if (!resultCount) {
|
184
|
+
return locale.emptyStateTitle;
|
286
185
|
}
|
287
|
-
if (
|
288
|
-
return
|
186
|
+
if (resultCount !== previousResultCount) {
|
187
|
+
return locale.itemsAvailable(resultCount);
|
289
188
|
}
|
290
189
|
return "";
|
291
|
-
}
|
292
|
-
|
293
|
-
var
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
id: id,
|
321
|
-
name: name,
|
322
|
-
disabled: disabled,
|
323
|
-
className: inputClassName,
|
324
|
-
type: "text",
|
325
|
-
placeholder: hasValue ? undefined : placeholder,
|
326
|
-
ref: function ref(input) {
|
327
|
-
return _this.inputRef = input;
|
328
|
-
},
|
329
|
-
onChange: _this.handleInputChange,
|
330
|
-
onFocus: function onFocus(evt) {
|
331
|
-
_onFocus === null || _onFocus === void 0 ? void 0 : _onFocus(evt);
|
332
|
-
if (evt.defaultPrevented) {
|
333
|
-
return;
|
190
|
+
},
|
191
|
+
getA11ySelectionMessage: function getA11ySelectionMessage(_ref3) {
|
192
|
+
var selectedItem = _ref3.selectedItem;
|
193
|
+
return locale.selectionMessage((0, _utils.optionToString)(selectedItem), selectedItem);
|
194
|
+
},
|
195
|
+
selectedItem: null,
|
196
|
+
inputValue: inputValue,
|
197
|
+
onStateChange: function onStateChange(changes) {
|
198
|
+
switch (changes.type) {
|
199
|
+
case _downshift.useCombobox.stateChangeTypes.InputBlur:
|
200
|
+
case _downshift.useCombobox.stateChangeTypes.InputKeyDownEnter:
|
201
|
+
case _downshift.useCombobox.stateChangeTypes.ItemClick:
|
202
|
+
{
|
203
|
+
var selectedItem = selectOnBlur && changes.type === _downshift.useCombobox.stateChangeTypes.InputBlur && combobox.highlightedIndex >= 0 ? items[combobox.highlightedIndex] : changes.selectedItem;
|
204
|
+
if (!selectedItem || selectedItem.disabled) return;
|
205
|
+
if (changes.type !== _downshift.useCombobox.stateChangeTypes.InputBlur && selectedItem.value === SHOW_ALL_ITEMS_ID) {
|
206
|
+
setShowAllItems(true);
|
207
|
+
combobox.openMenu();
|
208
|
+
combobox.setHighlightedIndex(maxItems);
|
209
|
+
} else if (multiple) {
|
210
|
+
multipleSelection.addSelectedItem(selectedItem);
|
211
|
+
combobox.setInputValue("");
|
212
|
+
setShowAllItems(false);
|
213
|
+
} else {
|
214
|
+
multipleSelection.setSelectedItems([selectedItem]);
|
215
|
+
combobox.setInputValue((0, _utils.optionToString)(selectedItem));
|
216
|
+
setShowAllItems(false);
|
217
|
+
}
|
218
|
+
break;
|
334
219
|
}
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
220
|
+
case _downshift.useCombobox.stateChangeTypes.FunctionSetInputValue:
|
221
|
+
case _downshift.useCombobox.stateChangeTypes.InputChange:
|
222
|
+
{
|
223
|
+
var _changes$inputValue, _menuPopper$update;
|
224
|
+
var newInputValue = (_changes$inputValue = changes.inputValue) !== null && _changes$inputValue !== void 0 ? _changes$inputValue : "";
|
225
|
+
setInternalInputValue(newInputValue);
|
226
|
+
onTextChange === null || onTextChange === void 0 || onTextChange(newInputValue);
|
227
|
+
if (!multiple && value && !newInputValue) {
|
228
|
+
multipleSelection.setSelectedItems([]);
|
229
|
+
}
|
230
|
+
(_menuPopper$update = menuPopper.update) === null || _menuPopper$update === void 0 || _menuPopper$update.call(menuPopper);
|
231
|
+
break;
|
232
|
+
}
|
233
|
+
case _downshift.useCombobox.stateChangeTypes.InputKeyDownEscape:
|
234
|
+
{
|
235
|
+
if (!combobox.isOpen) {
|
236
|
+
combobox.setInputValue("");
|
237
|
+
multipleSelection.setSelectedItems([]);
|
238
|
+
}
|
239
|
+
break;
|
240
|
+
}
|
241
|
+
}
|
242
|
+
},
|
243
|
+
isItemDisabled: function isItemDisabled(item) {
|
244
|
+
return Boolean(item.disabled);
|
245
|
+
}
|
246
|
+
});
|
247
|
+
var inputProps = combobox.getInputProps(multipleSelection.getDropdownProps({
|
248
|
+
ref: inputRef,
|
249
|
+
autoFocus: autoFocus,
|
250
|
+
disabled: disabled,
|
251
|
+
// We need to make sure to define event handlers here so that they can be composed properly
|
252
|
+
onFocus: function onFocus(evt) {
|
253
|
+
var _menuPopper$update2;
|
254
|
+
_onFocus === null || _onFocus === void 0 || _onFocus(evt);
|
255
|
+
if (evt.defaultPrevented) return;
|
256
|
+
setInputFocused(true);
|
257
|
+
(_menuPopper$update2 = menuPopper.update) === null || _menuPopper$update2 === void 0 || _menuPopper$update2.call(menuPopper);
|
258
|
+
},
|
259
|
+
onBlur: function onBlur(evt) {
|
260
|
+
_onBlur === null || _onBlur === void 0 || _onBlur(evt);
|
261
|
+
setInputFocused(false);
|
262
|
+
},
|
263
|
+
onKeyDown: function onKeyDown(evt) {
|
264
|
+
if (combobox.isOpen && ["ArrowLeft", "ArrowRight"].includes(evt.key)) {
|
265
|
+
// @ts-expect-error
|
266
|
+
evt.nativeEvent.preventDownshiftDefault = true;
|
267
|
+
}
|
268
|
+
if (multiple && creatable && inputValue.trim().length > 0 && separatorKeys !== null && separatorKeys !== void 0 && separatorKeys.includes(evt.key)) {
|
269
|
+
evt.preventDefault();
|
270
|
+
var _createFromInputValue = createFromInputValue(options, inputValue),
|
271
|
+
_createFromInputValue2 = (0, _slicedToArray2["default"])(_createFromInputValue, 1),
|
272
|
+
newOption = _createFromInputValue2[0];
|
273
|
+
if (newOption && !newOption.disabled) {
|
274
|
+
multipleSelection.addSelectedItem(newOption);
|
275
|
+
combobox.setInputValue("");
|
276
|
+
}
|
277
|
+
}
|
278
|
+
}
|
279
|
+
}));
|
280
|
+
(0, _react.useEffect)(function () {
|
281
|
+
if (!combobox.isOpen) return;
|
282
|
+
if (items.length === 0 && combobox.highlightedIndex >= 0) {
|
283
|
+
combobox.setHighlightedIndex(-1);
|
284
|
+
} else if (items.length > 0 && combobox.highlightedIndex < 0) {
|
285
|
+
combobox.setHighlightedIndex(0);
|
286
|
+
}
|
287
|
+
}, [combobox, items.length]);
|
288
|
+
var shouldRenderCustomTemplate = Boolean(!multiple && !inputFocused && value && renderValueTemplate);
|
289
|
+
var shouldShowDefaultEmptyState = emptyState === undefined && !!inputValue.length;
|
290
|
+
var shouldShowEmptyState = !!emptyState;
|
291
|
+
var hideMenu = !combobox.isOpen || items.length === 0 && !shouldShowEmptyState && !shouldShowDefaultEmptyState;
|
292
|
+
var OptionItem = (0, _react.useMemo)(function () {
|
293
|
+
return optionItemComponent !== null && optionItemComponent !== void 0 ? optionItemComponent : function (props) {
|
294
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_DefaultOptionItem.DefaultOptionItem, _objectSpread(_objectSpread({}, props), {}, {
|
295
|
+
locale: locale
|
296
|
+
}));
|
297
|
+
};
|
298
|
+
}, [optionItemComponent, locale]);
|
299
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_AutocompleteContext.AutocompleteProvider, {
|
300
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
301
|
+
className: (0, _clsx["default"])((0, _satellitePrefixer["default"])(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["flex"]))), className),
|
302
|
+
ref: function ref(el) {
|
303
|
+
setContainerElement(el);
|
304
|
+
// @ts-expect-error
|
305
|
+
setContainerMeasureRef(el);
|
306
|
+
},
|
307
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
308
|
+
className: (0, _clsx["default"])((0, _satellitePrefixer["default"])(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["autocomplete-container"]))), variant === "large" && (0, _satellitePrefixer["default"])(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["autocomplete-large py-1"]))), inputFocused && (0, _satellitePrefixer["default"])(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["autocomplete-focused"]))), disabled && (0, _satellitePrefixer["default"])(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["autocomplete-disabled"]))), status === "invalid" && (0, _satellitePrefixer["default"])(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["autocomplete-invalid"]))), noWrap && (0, _satellitePrefixer["default"])(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["autocomplete-nowrap"])))),
|
309
|
+
onClick: function onClick() {
|
310
|
+
var _inputRef$current;
|
311
|
+
return (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
|
344
312
|
},
|
345
|
-
onBlur: _this.handleInputBlur(autocompleteHelpers),
|
346
|
-
onKeyDown: _this.handleKeyDown(autocompleteHelpers),
|
347
|
-
autoComplete: "off",
|
348
|
-
autoFocus: autoFocus
|
349
|
-
});
|
350
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
351
|
-
className: inputContainerClassName,
|
352
|
-
onClick: _this.handleFakeInputClick,
|
353
|
-
ref: _this.handleInputContainerRefUpdate,
|
354
313
|
children: [Icon && /*#__PURE__*/(0, _jsxRuntime.jsx)(Icon, {
|
355
|
-
className: (0, _satellitePrefixer["default"])(
|
314
|
+
className: (0, _clsx["default"])((0, _satellitePrefixer["default"])(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["mr-4 shrink-0"]))), (0, _satellitePrefixer["default"])(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["", ""])), disabled ? "text-grey-200" : inputFocused ? "text-accent-600" : "text-grey-500")),
|
356
315
|
size: "1rem"
|
357
316
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
358
|
-
className: (0, _clsx["default"])((0, _satellitePrefixer["default"])(
|
359
|
-
children: [multiple &&
|
360
|
-
return renderValueTemplate ?
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
317
|
+
className: (0, _clsx["default"])((0, _satellitePrefixer["default"])(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2["default"])(["flex items-center flex-1 max-h-full"]))), !noWrap && (0, _satellitePrefixer["default"])(_templateObject11 || (_templateObject11 = (0, _taggedTemplateLiteral2["default"])(["flex-wrap overflow-y-scroll no-scrollbar"]))), multiple && (0, _satellitePrefixer["default"])(_templateObject12 || (_templateObject12 = (0, _taggedTemplateLiteral2["default"])(["-ml-1"]))), valuesClassName),
|
318
|
+
children: [multiple && selectedItems.map(function (option, index) {
|
319
|
+
return renderValueTemplate ? /*#__PURE__*/(0, _jsxRuntime.jsx)("span", _objectSpread(_objectSpread({}, multipleSelection.getSelectedItemProps({
|
320
|
+
selectedItem: option,
|
321
|
+
index: index
|
322
|
+
})), {}, {
|
323
|
+
children: renderValueTemplate({
|
324
|
+
option: option,
|
325
|
+
editable: !disabled
|
326
|
+
})
|
327
|
+
}), String(option.value)) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tag["default"], _objectSpread(_objectSpread({
|
328
|
+
onRemove: disabled ? undefined : function (evt) {
|
329
|
+
evt.stopPropagation();
|
330
|
+
multipleSelection.removeSelectedItem(option);
|
367
331
|
},
|
368
|
-
className: (0, _satellitePrefixer["default"])(
|
332
|
+
className: (0, _satellitePrefixer["default"])(_templateObject13 || (_templateObject13 = (0, _taggedTemplateLiteral2["default"])(["m-1 max-w-48 ", ""])), disabled && "opacity-50")
|
333
|
+
}, multipleSelection.getSelectedItemProps({
|
334
|
+
selectedItem: option,
|
335
|
+
index: index
|
336
|
+
})), {}, {
|
369
337
|
children: option.label
|
370
|
-
}, String(option.value));
|
338
|
+
}), String(option.value));
|
371
339
|
}), shouldRenderCustomTemplate && renderValueTemplate({
|
372
340
|
option: value,
|
373
|
-
key: String(value),
|
374
341
|
editable: !disabled
|
375
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", _objectSpread(_objectSpread({
|
342
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", _objectSpread(_objectSpread({
|
376
343
|
"data-lpignore": true
|
344
|
+
}, inputProps), {}, {
|
345
|
+
id: id,
|
346
|
+
name: name,
|
347
|
+
type: "text",
|
348
|
+
placeholder: hasValue ? "" : placeholder,
|
349
|
+
autoComplete: "off",
|
350
|
+
className: (0, _clsx["default"])((0, _satellitePrefixer["default"])(_templateObject14 || (_templateObject14 = (0, _taggedTemplateLiteral2["default"])(["autocomplete-input py-1.5"]))), multiple && (0, _satellitePrefixer["default"])(_templateObject15 || (_templateObject15 = (0, _taggedTemplateLiteral2["default"])(["ml-1"]))), shouldRenderCustomTemplate && hasValue && (0, _satellitePrefixer["default"])(_templateObject16 || (_templateObject16 = (0, _taggedTemplateLiteral2["default"])(["h-0 w-0 opacity-0"]))))
|
377
351
|
}))]
|
378
|
-
}), (showClearButton ||
|
379
|
-
className: (0, _clsx["default"])(showClearButton && endItem && (0, _satellitePrefixer["default"])(
|
352
|
+
}), Boolean(showClearButton || endItem) && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
353
|
+
className: (0, _clsx["default"])(showClearButton && endItem && (0, _satellitePrefixer["default"])(_templateObject17 || (_templateObject17 = (0, _taggedTemplateLiteral2["default"])(["my-2 flex self-end space-x-4"])))),
|
380
354
|
children: [!!endItem && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
381
|
-
className: (0, _satellitePrefixer["default"])(
|
355
|
+
className: (0, _satellitePrefixer["default"])(_templateObject18 || (_templateObject18 = (0, _taggedTemplateLiteral2["default"])(["text-grey-700 my-auto"]))),
|
382
356
|
children: endItem
|
383
357
|
}), showClearButton && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
384
358
|
type: "button",
|
385
|
-
className: (0, _satellitePrefixer["default"])(
|
386
|
-
onClick:
|
387
|
-
|
359
|
+
className: (0, _satellitePrefixer["default"])(_templateObject19 || (_templateObject19 = (0, _taggedTemplateLiteral2["default"])(["w-6 h-6 flex items-center justify-center text-grey-500"]))),
|
360
|
+
onClick: function onClick(evt) {
|
361
|
+
evt.stopPropagation();
|
362
|
+
combobox.setInputValue("");
|
363
|
+
multipleSelection.setSelectedItems([]);
|
364
|
+
},
|
365
|
+
"aria-label": locale.clearInputButton,
|
388
366
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFeather.X, {
|
389
367
|
size: ".75rem"
|
390
368
|
})
|
391
369
|
})]
|
392
370
|
})]
|
393
|
-
})
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
_this$props4$emptySta = _this$props4.emptyState,
|
410
|
-
emptyState = _this$props4$emptySta === void 0 ? defaultEmptyState : _this$props4$emptySta,
|
411
|
-
_this$props4$maxResul = _this$props4.maxResults,
|
412
|
-
maxResults = _this$props4$maxResul === void 0 ? AutoComplete.defaultProps.maxResults : _this$props4$maxResul,
|
413
|
-
_this$props4$multiple = _this$props4.multiple,
|
414
|
-
multiple = _this$props4$multiple === void 0 ? AutoComplete.defaultProps.multiple : _this$props4$multiple,
|
415
|
-
_this$props4$optionIt = _this$props4.optionItemComponent,
|
416
|
-
OptionItem = _this$props4$optionIt === void 0 ? AutoComplete.defaultProps.optionItemComponent : _this$props4$optionIt;
|
417
|
-
var _this$state = _this.state,
|
418
|
-
inputWidth = _this$state.inputWidth,
|
419
|
-
showAllResults = _this$state.showAllResults;
|
420
|
-
var dropdownStyle = inputWidth ? {
|
421
|
-
minWidth: inputWidth,
|
422
|
-
maxWidth: "42vw"
|
423
|
-
} : undefined;
|
424
|
-
var optionItemProps = {
|
425
|
-
multiple: multiple,
|
426
|
-
inputValue: inputValue || ""
|
427
|
-
};
|
428
|
-
var extraResults = results.length - maxResults;
|
429
|
-
var shouldShowDefaultEmptyState = emptyState === defaultEmptyState && results.length === 0 && !!(inputValue !== null && inputValue !== void 0 && inputValue.length);
|
430
|
-
var shouldShowEmptyState = emptyState !== defaultEmptyState && !!emptyState && results.length === 0;
|
431
|
-
var showResults = results.length > 0;
|
432
|
-
if (!isOpen || !showResults && !shouldShowEmptyState && !shouldShowDefaultEmptyState) {
|
433
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("ul", _objectSpread(_objectSpread({}, getMenuProps()), {}, {
|
434
|
-
className: (0, _satellitePrefixer["default"])(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["hidden h-0"])))
|
435
|
-
}));
|
436
|
-
}
|
437
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactPopper.Popper, {
|
438
|
-
placement: "bottom-start",
|
439
|
-
strategy: "fixed",
|
440
|
-
referenceElement: (_this$inputContainerR3 = _this.inputContainerRef) !== null && _this$inputContainerR3 !== void 0 ? _this$inputContainerR3 : undefined,
|
441
|
-
modifiers: MENU_POPPER_MODFIERS,
|
442
|
-
innerRef: function innerRef(wrapperEl) {
|
443
|
-
return _this.menuWrapperRef = wrapperEl;
|
444
|
-
},
|
445
|
-
children: function children(popper) {
|
446
|
-
var _getMenuProps = getMenuProps({
|
447
|
-
ref: popper.ref
|
448
|
-
}),
|
449
|
-
menuRef = _getMenuProps.ref,
|
450
|
-
menuProps = (0, _objectWithoutProperties2["default"])(_getMenuProps, _excluded2);
|
451
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ClickAwayContainer.ClickAwayContainer, {
|
452
|
-
element: _this.menuWrapperRef,
|
371
|
+
}), createPortal( /*#__PURE__*/(0, _jsxRuntime.jsx)(_ClickAwayContainer.ClickAwayContainer, {
|
372
|
+
element: menuRef.current,
|
373
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Card.Card, _objectSpread(_objectSpread({}, menuPopper.attributes), {}, {
|
374
|
+
className: (0, _clsx["default"])((0, _satellitePrefixer["default"])(_templateObject20 || (_templateObject20 = (0, _taggedTemplateLiteral2["default"])(["z-dropdown"]))), menuClassName),
|
375
|
+
style: _objectSpread(_objectSpread(_objectSpread({}, menuPopper.styles.popper), hideMenu && {
|
376
|
+
display: "none"
|
377
|
+
}), {}, {
|
378
|
+
minWidth: containerWidth,
|
379
|
+
maxWidth: "42vw"
|
380
|
+
}),
|
381
|
+
ref: menuRef,
|
382
|
+
elevation: "300",
|
383
|
+
fullBleed: true,
|
384
|
+
children: [items.length === 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, combobox.getMenuProps({
|
385
|
+
className: (0, _satellitePrefixer["default"])(_templateObject21 || (_templateObject21 = (0, _taggedTemplateLiteral2["default"])(["min-h-10"])))
|
386
|
+
})), {}, {
|
453
387
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
* anything else:
|
460
|
-
* https://github.com/downshift-js/downshift/blob/3fb0ed21278c5f1d0a077ed9b1d0dfd55a75c71b/src/downshift.js#L951
|
461
|
-
*/
|
462
|
-
ref: menuRef,
|
463
|
-
className: (0, _clsx["default"])((0, _satellitePrefixer["default"])(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2["default"])(["z-dropdown"]))), menuClassName),
|
464
|
-
style: _objectSpread(_objectSpread({}, popper.style), dropdownStyle),
|
465
|
-
"data-popper-placement": popper.placement,
|
466
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Card["default"], {
|
467
|
-
fullBleed: true,
|
468
|
-
elevation: "300",
|
469
|
-
children: [results.length === 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, menuProps), {}, {
|
470
|
-
className: (0, _satellitePrefixer["default"])(_templateObject11 || (_templateObject11 = (0, _taggedTemplateLiteral2["default"])(["min-h-10"]))),
|
471
|
-
children: emptyState
|
472
|
-
})) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScrollIndicator["default"], {
|
473
|
-
className: menuSize === "large" ? (0, _satellitePrefixer["default"])(_templateObject12 || (_templateObject12 = (0, _taggedTemplateLiteral2["default"])(["max-h-96"]))) : (0, _satellitePrefixer["default"])(_templateObject13 || (_templateObject13 = (0, _taggedTemplateLiteral2["default"])(["max-h-64"]))),
|
474
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("ul", _objectSpread(_objectSpread({}, menuProps), {}, {
|
475
|
-
children: [results.slice(0, showAllResults ? Number.MAX_SAFE_INTEGER : maxResults).map(function (result, index) {
|
476
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("li", _objectSpread(_objectSpread({}, getItemProps({
|
477
|
-
item: result,
|
478
|
-
disabled: result.disabled,
|
479
|
-
className: (0, _satellitePrefixer["default"])(_templateObject14 || (_templateObject14 = (0, _taggedTemplateLiteral2["default"])(["\n autocomplete-result\n flex items-center min-h-10 px-4 cursor-pointer\n ", "\n ", "\n "])), index === highlightedIndex && "bg-grey-100", result.disabled && "cursor-not-allowed")
|
480
|
-
})), {}, {
|
481
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(OptionItem, _objectSpread(_objectSpread({}, optionItemProps), {}, {
|
482
|
-
highlighted: index === highlightedIndex,
|
483
|
-
option: result,
|
484
|
-
optionItemPrefix: _this.locale.optionItemPrefix
|
485
|
-
}))
|
486
|
-
}), result.value);
|
487
|
-
}), extraResults > 0 && !showAllResults && /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
|
488
|
-
className: (0, _satellitePrefixer["default"])(_templateObject15 || (_templateObject15 = (0, _taggedTemplateLiteral2["default"])(["p-2 text-right"]))),
|
489
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button["default"], {
|
490
|
-
variant: "subtle",
|
491
|
-
size: "small",
|
492
|
-
onMouseDown: _this.handleShowAllResults,
|
493
|
-
children: _this.locale.showMoreButton(extraResults)
|
494
|
-
})
|
495
|
-
})]
|
496
|
-
}))
|
497
|
-
}), !!menuFooter && /*#__PURE__*/(0, _jsxRuntime.jsx)("footer", {
|
498
|
-
className: (0, _satellitePrefixer["default"])(_templateObject16 || (_templateObject16 = (0, _taggedTemplateLiteral2["default"])(["flex items-center justify-center min-h-12 p-4 bg-grey-100 border-t border-grey-200 text-grey-600"]))),
|
499
|
-
children: menuFooter
|
500
|
-
})]
|
388
|
+
role: "option",
|
389
|
+
"aria-disabled": "true",
|
390
|
+
"aria-selected": "false",
|
391
|
+
children: emptyState !== null && emptyState !== void 0 ? emptyState : /*#__PURE__*/(0, _jsxRuntime.jsx)(_AutoCompleteEmptyState["default"], {
|
392
|
+
title: locale.emptyStateTitle
|
501
393
|
})
|
502
394
|
})
|
503
|
-
})
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
// (which should only happen when this.props.multiple === false)
|
534
|
-
if (this.props.multiple) return;
|
535
|
-
var prevPropsInputValue = inputValueFromProps(prevProps);
|
536
|
-
var propsInputValue = inputValueFromProps(this.props);
|
537
|
-
var shouldUpdateInputValueFromProps = prevPropsInputValue !== propsInputValue && this.state.inputValue !== propsInputValue;
|
538
|
-
if (shouldUpdateInputValueFromProps) {
|
539
|
-
this.setState({
|
540
|
-
inputValue: propsInputValue
|
541
|
-
});
|
542
|
-
}
|
543
|
-
}
|
544
|
-
}, {
|
545
|
-
key: "locale",
|
546
|
-
get: function get() {
|
547
|
-
return _objectSpread(_objectSpread(_objectSpread({}, _utils.DEFAULT_AUTOCOMPLETE_LOCALE), this.context["locales"]), this.props.locale);
|
548
|
-
}
|
549
|
-
}, {
|
550
|
-
key: "render",
|
551
|
-
value: function render() {
|
552
|
-
var _this2 = this;
|
553
|
-
var inputValue = (this.props.inputValue !== undefined ? this.props.inputValue : this.state.inputValue) || "";
|
554
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_FieldStateContext.FieldStateContext.Consumer, {
|
555
|
-
children: function children(fieldState) {
|
556
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_downshift["default"], {
|
557
|
-
inputValue: inputValue
|
558
|
-
/*
|
559
|
-
* See https://github.com/algolia/AlgoliaWeb/issues/9045
|
560
|
-
* See multi-select example
|
561
|
-
* https://github.com/downshift-js/downshift#examples
|
562
|
-
* https://codesandbox.io/s/github/kentcdodds/downshift-examples/tree/master/?module=/src/ordered-examples/04-multi-select.js&moduleview=1&file=/src/ordered-examples/04-multi-select.js:2482-2509
|
563
|
-
*/,
|
564
|
-
selectedItem: null,
|
565
|
-
getA11yStatusMessage: _this2.getA11yStatusMessage,
|
566
|
-
onChange: _this2.handleChange,
|
567
|
-
itemToString: optionToString,
|
568
|
-
defaultHighlightedIndex: 0,
|
569
|
-
children: function children(autocompleteHelpers) {
|
570
|
-
return _this2.renderSelect(autocompleteHelpers, fieldState);
|
571
|
-
}
|
572
|
-
});
|
573
|
-
}
|
574
|
-
});
|
575
|
-
}
|
576
|
-
}]);
|
577
|
-
return AutoComplete;
|
578
|
-
}(_react.Component);
|
579
|
-
exports.AutoComplete = AutoComplete;
|
580
|
-
(0, _defineProperty2["default"])(AutoComplete, "contextType", _Satellite.SatelliteContext);
|
581
|
-
(0, _defineProperty2["default"])(AutoComplete, "defaultProps", {
|
582
|
-
clearable: false,
|
583
|
-
creatable: false,
|
584
|
-
multiple: false,
|
585
|
-
maxResults: 7,
|
586
|
-
createFromInputValue: _utils.defaultCreateFromInputValue,
|
587
|
-
options: [],
|
588
|
-
separatorKeys: [],
|
589
|
-
optionItemComponent: DefaultOption,
|
590
|
-
noWrap: false
|
591
|
-
});
|
592
|
-
var _default = AutoComplete;
|
593
|
-
exports["default"] = _default;
|
395
|
+
})) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScrollIndicator["default"], {
|
396
|
+
className: menuSize === "large" ? (0, _satellitePrefixer["default"])(_templateObject22 || (_templateObject22 = (0, _taggedTemplateLiteral2["default"])(["max-h-96"]))) : (0, _satellitePrefixer["default"])(_templateObject23 || (_templateObject23 = (0, _taggedTemplateLiteral2["default"])(["max-h-64"]))),
|
397
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("ul", _objectSpread(_objectSpread({}, combobox.getMenuProps()), {}, {
|
398
|
+
children: items.map(function (item, index) {
|
399
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("li", _objectSpread(_objectSpread({}, combobox.getItemProps({
|
400
|
+
item: item,
|
401
|
+
className: (0, _clsx["default"])((0, _satellitePrefixer["default"])(_templateObject24 || (_templateObject24 = (0, _taggedTemplateLiteral2["default"])(["autocomplete-result flex items-center min-h-10 px-4 cursor-pointer"]))), index === combobox.highlightedIndex && (0, _satellitePrefixer["default"])(_templateObject25 || (_templateObject25 = (0, _taggedTemplateLiteral2["default"])(["bg-grey-100"]))), item.disabled && (0, _satellitePrefixer["default"])(_templateObject26 || (_templateObject26 = (0, _taggedTemplateLiteral2["default"])(["cursor-not-allowed"]))))
|
402
|
+
})), {}, {
|
403
|
+
children: item.value === SHOW_ALL_ITEMS_ID ? /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
404
|
+
className: (0, _satellitePrefixer["default"])(_templateObject27 || (_templateObject27 = (0, _taggedTemplateLiteral2["default"])(["w-full py-2 truncate text-center text-grey-900"]))),
|
405
|
+
children: item.label
|
406
|
+
}, item.value) : /*#__PURE__*/(0, _jsxRuntime.jsx)(OptionItem, {
|
407
|
+
multiple: Boolean(multiple),
|
408
|
+
inputValue: inputValue,
|
409
|
+
highlighted: index === combobox.highlightedIndex,
|
410
|
+
option: item
|
411
|
+
})
|
412
|
+
}), String(item.value));
|
413
|
+
})
|
414
|
+
}))
|
415
|
+
}), !!menuFooter && /*#__PURE__*/(0, _jsxRuntime.jsx)("footer", {
|
416
|
+
className: (0, _satellitePrefixer["default"])(_templateObject28 || (_templateObject28 = (0, _taggedTemplateLiteral2["default"])(["flex items-center justify-center min-h-12 p-4 bg-grey-100 border-t border-grey-200 text-grey-600"]))),
|
417
|
+
children: menuFooter
|
418
|
+
})]
|
419
|
+
}))
|
420
|
+
}))]
|
421
|
+
})
|
422
|
+
});
|
423
|
+
};
|
424
|
+
var _default = exports["default"] = AutoComplete;
|