diff options
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; }; |
