[Refactor] Extract 'FormItem' and 'SettingItem' (#1619)

* Extract SettingItem component

* Extract GeneralSettingItem

* Rename to FormItem

* nit

* nit
This commit is contained in:
Chenlei Hu
2024-11-20 15:10:17 -05:00
committed by GitHub
parent 4f3693e322
commit f34d50da3d
5 changed files with 152 additions and 102 deletions

View File

@@ -29,15 +29,10 @@ export interface Setting {
render: () => HTMLElement
}
export interface SettingParams {
export interface SettingParams extends FormItem {
id: keyof Settings
name: string
type: SettingInputType | SettingCustomRenderer
defaultValue: any
onChange?: (newValue: any, oldValue?: any) => void
attrs?: any
tooltip?: string
options?: Array<string | SettingOption> | ((value: any) => SettingOption[])
// By default category is id.split('.'). However, changing id to assign
// new category has poor backward compatibility. Use this field to overwrite
// default category from id.
@@ -52,3 +47,14 @@ export interface SettingParams {
// Version of the setting when it was last modified
versionModified?: string
}
/**
* The base form item for rendering in a form.
*/
export interface FormItem {
name: string
type: SettingInputType | SettingCustomRenderer
tooltip?: string
attrs?: Record<string, any>
options?: Array<string | SettingOption> | ((value: any) => SettingOption[])
}