From d6f90686958d41c0f4603f6a7ca07ce3a3c09441 Mon Sep 17 00:00:00 2001 From: Lewis Crichton Date: Mon, 27 Feb 2023 23:48:58 +0000 Subject: feat: SearchableSelect (#518) Co-authored-by: Ven --- src/webpack/common/components.ts | 4 +++ src/webpack/common/types/components.d.ts | 43 ++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) (limited to 'src/webpack/common') diff --git a/src/webpack/common/components.ts b/src/webpack/common/components.ts index 0b229ed..63511a7 100644 --- a/src/webpack/common/components.ts +++ b/src/webpack/common/components.ts @@ -45,6 +45,10 @@ export const Text = waitForComponent("Text", m => { return (s.length < 1500 && s.includes("data-text-variant") && s.includes("always-white")); }); export const Select = waitForComponent("Select", filters.byCode("optionClassName", "popoutPosition", "autoFocus", "maxVisibleItems")); +const searchableSelectFilter = filters.byCode("autoFocus", ".Messages.SELECT"); +export const SearchableSelect = waitForComponent("SearchableSelect", m => + m.render && searchableSelectFilter(m.render) +); export const Slider = waitForComponent("Slider", filters.byCode("closestMarkerIndex", "stickToMarkers")); export const Flex = waitForComponent("Flex", ["Justify", "Align", "Wrap"]); diff --git a/src/webpack/common/types/components.d.ts b/src/webpack/common/types/components.d.ts index 127b7c6..4dfa7dc 100644 --- a/src/webpack/common/types/components.d.ts +++ b/src/webpack/common/types/components.d.ts @@ -235,6 +235,49 @@ export type Select = ComponentType>; +export type SearchableSelect = ComponentType; // 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