diff options
author | megumin <megumin.bakaretsurie@gmail.com> | 2022-10-26 22:42:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-26 23:42:26 +0200 |
commit | 13882b5732ef14f6535c32f4c6840081d677e0f7 (patch) | |
tree | 4e6c5e8fad597c9d35cc6cb06c2c60b1fac648c3 /src/utils | |
parent | 49e72bab329bfd589bf921a490ae2379a59bae1c (diff) | |
download | Vencord-13882b5732ef14f6535c32f4c6840081d677e0f7.tar.gz Vencord-13882b5732ef14f6535c32f4c6840081d677e0f7.tar.bz2 Vencord-13882b5732ef14f6535c32f4c6840081d677e0f7.zip |
feat: custom components in settings (#165)
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/types.ts | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/utils/types.ts b/src/utils/types.ts index 41dd0c1..689baa7 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -96,6 +96,7 @@ export enum OptionType { BOOLEAN, SELECT, SLIDER, + COMPONENT, } export type PluginOptionsItem = @@ -103,7 +104,8 @@ export type PluginOptionsItem = | PluginOptionNumber | PluginOptionBoolean | PluginOptionSelect - | PluginOptionSlider; + | PluginOptionSlider + | PluginOptionComponent; export interface PluginOptionBase { description: string; @@ -176,7 +178,32 @@ export interface PluginOptionSlider extends PluginOptionBase { /** * Prevents the user from saving settings if this is false or a string */ - isValid?(value: number): number; + isValid?(value: number): boolean | string; +} + +interface IPluginOptionComponentProps { + /** + * Run this when the value changes. + * + * NOTE: The user will still need to click save to apply these changes. + */ + setValue(newValue: any): void; + /** + * Set to true to prevent the user from saving. + * + * NOTE: This will not show the error to the user. It will only stop them saving. + * Make sure to show the error in your component. + */ + setError(error: boolean): void; + /** + * The options object + */ + option: PluginOptionComponent; +} + +export interface PluginOptionComponent extends PluginOptionBase { + type: OptionType.COMPONENT; + component: (props: IPluginOptionComponentProps) => JSX.Element; } export type IpcRes<V = any> = { ok: true; value: V; } | { ok: false, error: any; }; |