Annotate settings.ts (#134)

* Annotate settings.ts

* nit
This commit is contained in:
Chenlei Hu
2024-07-16 11:21:23 -04:00
committed by GitHub
parent e216fa82c5
commit 13cda7de41
4 changed files with 53 additions and 41 deletions

39
src/types/settingTypes.ts Normal file
View File

@@ -0,0 +1,39 @@
export type StorageLocation = "browser" | "server";
export type SettingInputType =
| "boolean"
| "number"
| "slider"
| "combo"
| "text"
| "hidden";
export type SettingCustomRenderer = (
name: string,
setter: (v: any) => void,
value: any,
attrs: any
) => HTMLElement;
export interface SettingOption {
text: string;
value?: string;
}
export interface Setting {
id: string;
onChange?: (value: any, oldValue?: any) => void;
name: string;
render: () => HTMLElement;
}
export interface SettingParams {
id: string;
name: string;
type: SettingInputType | SettingCustomRenderer;
defaultValue: any;
onChange?: (newValue: any, oldValue?: any) => void;
attrs?: any;
tooltip?: string;
options?: Array<string | SettingOption> | ((value: any) => SettingOption[]);
}