aboutsummaryrefslogtreecommitdiff
path: root/src/webpack/common
diff options
context:
space:
mode:
authorLewis Crichton <lewi@lewisakura.moe>2023-02-27 23:48:58 +0000
committerGitHub <noreply@github.com>2023-02-28 00:48:58 +0100
commitd6f90686958d41c0f4603f6a7ca07ce3a3c09441 (patch)
tree0ff55cdc64a3ab58e0688d021d5ab0055d87fe02 /src/webpack/common
parentcb507babaad57d71cb34c9108c625454c6adbafd (diff)
downloadVencord-d6f90686958d41c0f4603f6a7ca07ce3a3c09441.tar.gz
Vencord-d6f90686958d41c0f4603f6a7ca07ce3a3c09441.tar.bz2
Vencord-d6f90686958d41c0f4603f6a7ca07ce3a3c09441.zip
feat: SearchableSelect (#518)
Co-authored-by: Ven <vendicated@riseup.net>
Diffstat (limited to 'src/webpack/common')
-rw-r--r--src/webpack/common/components.ts4
-rw-r--r--src/webpack/common/types/components.d.ts43
2 files changed, 47 insertions, 0 deletions
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<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"]);
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<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;