feat: SearchableSelect (#518)

Co-authored-by: Ven <vendicated@riseup.net>
This commit is contained in:
Lewis Crichton 2023-02-27 23:48:58 +00:00 committed by GitHub
parent cb507babaa
commit d6f9068695
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 0 deletions

View file

@ -45,6 +45,10 @@ export const Text = waitForComponent<t.Text>("Text", m => {
return (s.length < 1500 && s.includes("data-text-variant") && s.includes("always-white"));
});
export const Select = waitForComponent<t.Select>("Select", filters.byCode("optionClassName", "popoutPosition", "autoFocus", "maxVisibleItems"));
const searchableSelectFilter = filters.byCode("autoFocus", ".Messages.SELECT");
export const SearchableSelect = waitForComponent<t.SearchableSelect>("SearchableSelect", m =>
m.render && searchableSelectFilter(m.render)
);
export const Slider = waitForComponent<t.Slider>("Slider", filters.byCode("closestMarkerIndex", "stickToMarkers"));
export const Flex = waitForComponent<t.Flex>("Flex", ["Justify", "Align", "Wrap"]);

View file

@ -235,6 +235,49 @@ export type Select = ComponentType<PropsWithChildren<{
"aria-labelledby"?: boolean;
}>>;
export type SearchableSelect = ComponentType<PropsWithChildren<{
placeholder?: string;
options: ReadonlyArray<SelectOption>; // TODO
value?: SelectOption;
/**
* - 0 ~ Filled
* - 1 ~ Custom
*/
look?: 0 | 1;
className?: string;
popoutClassName?: string;
wrapperClassName?: string;
popoutPosition?: "top" | "left" | "right" | "bottom" | "center" | "window_center";
optionClassName?: string;
autoFocus?: boolean;
isDisabled?: boolean;
clearable?: boolean;
closeOnSelect?: boolean;
clearOnSelect?: boolean;
multi?: boolean;
onChange(value: any): void;
onSearchChange?(value: string): void;
onClose?(): void;
onOpen?(): void;
onBlur?(): void;
renderOptionPrefix?(option: SelectOption): ReactNode;
renderOptionSuffix?(option: SelectOption): ReactNode;
filter?(option: SelectOption[], query: string): SelectOption[];
centerCaret?: boolean;
debounceTime?: number;
maxVisibleItems?: number;
popoutWidth?: number;
"aria-labelledby"?: boolean;
}>>;
export type Slider = ComponentType<PropsWithChildren<{
initialValue: number;
defaultValue?: number;