Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ type AutocompleteMenuProps<T> = {
minLength?: number | null;
inputValue?: string;
className?: string;
optionsLimit?: number;
limitationText?: string;
} & AutocompleteOptionsProps<T>;

export const AutocompleteMenu = forwardRef(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,17 @@
padding: 8px 12px;
text-align: center;
}

.limitation-item {
pointer-events: none;
min-height: 36px;
padding: 4px 12px;
cursor: pointer;
box-sizing: border-box;
color: var(--rp-ui-color-text-secondary);
align-items: center;
text-align: center;
width: 100%;
font-family: var(--rp-ui-base-font-family);
font-size: 13px;
}
9 changes: 9 additions & 0 deletions src/components/autocompletes/common/autocompleteOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export interface AutocompleteOptionsProps<T> {
customNoMatchesMessage?: string;
getUniqKey?: (item: T) => string;
newItemButtonText: string;
limitationText?: string;
optionsLimit?: number;
}

export const AutocompleteOptions = <T,>(props: AutocompleteOptionsProps<T>) => {
Expand All @@ -65,6 +67,8 @@ export const AutocompleteOptions = <T,>(props: AutocompleteOptionsProps<T>) => {
getUniqKey,
getItemProps,
parseValueToString,
limitationText = 'Too many results. Type to search',
optionsLimit = 0,
} = props;

const filterStaticOptions = useCallback(() => {
Expand Down Expand Up @@ -159,6 +163,11 @@ export const AutocompleteOptions = <T,>(props: AutocompleteOptionsProps<T>) => {
<div className={cx({ container: options.length })}>
<Scrollbars autoHeight autoHeightMax={216} hideTracksWhenNotNeeded>
{!isEmpty(availableOptions) ? renderItems(availableOptions) : renderEmptyList()}
{availableOptions?.length > optionsLimit && optionsLimit > 0 && limitationText ? (
<li className={cx('limitation-item')} aria-hidden="true">
{limitationText}
</li>
) : null}
</Scrollbars>
{!createWithoutConfirmation && renderNewItem(availableOptions)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ export interface MultipleAutocompleteProps<T> {
selectedItemSingleLine?: boolean;
selectedItemClassName?: string;
selectedItemTextClassName?: string;
optionsLimit?: number;
limitationText?: string;
}

export const MultipleAutocomplete = <T,>(componentsProps: MultipleAutocompleteProps<T>) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ export interface SingleAutocompleteProps<T> {
customEmptyListMessage?: string;
customNoMatchesMessage?: string;
newItemButtonText?: string;
optionsLimit?: number;
limitationText?: string;
}

export const SingleAutocomplete = <T,>(componentProps: SingleAutocompleteProps<T>) => {
Expand Down
Loading