Files
vue-element-plus-admin/src/types/componentType.d.ts
2022-01-05 17:02:25 +08:00

124 lines
2.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { CSSProperties } from 'vue'
declare global {
// Form types start
declare type ComponentName =
| 'Radio'
| 'RadioButton'
| 'Checkbox'
| 'CheckboxButton'
| 'Input'
| 'Autocomplete'
| 'InputNumber'
| 'Select'
| 'Cascader'
| 'Switch'
| 'Slider'
| 'TimePicker'
| 'DatePicker'
| 'Rate'
| 'ColorPicker'
| 'Transfer'
| 'Divider'
| 'TimeSelect'
| 'SelectV2'
| 'InputPassword'
type ColProps = {
span?: number
xs?: number
sm?: number
md?: number
lg?: number
xl?: number
tag?: string
}
declare type FormValueTypes = string | number | string[] | number[] | boolean | undefined | null
// declare interface FormItemRule extends RuleItem {
// trigger?: string
// }
// declare type FormRulesMap<T extends string = string> = Partial<
// Record<T, FormItemRule | FormItemRule[]>
// >
declare type FormItemProps = {
labelWidth?: string | number
required?: boolean
rules?: Recordable
error?: string
showMessage?: boolean
inlineMessage?: boolean
style?: CSSProperties
}
declare type ComponentOptions = {
label?: string
value?: FormValueTypes
disabled?: boolean
key?: string | number
children?: ComponentOptions[]
options?: ComponentOptions[]
} & Recordable
declare type ComponentOptionsAlias = {
labelField?: string
valueField?: string
}
declare type ComponentProps = {
optionsAlias?: ComponentOptionsAlias
options?: ComponentOptions[]
optionsSlot?: boolean
} & Recordable
declare type FormSchema = {
// 唯一值
field: string
// 标题
label?: string
// col组件属性
colProps?: ColProps
// 表单组件属性slots对应的是表单组件的插槽规则${field}-xxx具体可以查看element-plus文档
componentProps?: { slots?: Recordable } & ComponentProps
// formItem组件属性
formItemProps?: FormItemProps
// 渲染的组件
component?: ComponentName
// 初始值
value?: FormValueTypes
// 是否隐藏
hidden?: boolean
}
// Form types end
// ConfigGlobal types start
declare interface ConfigGlobalTypes {
size?: ElememtPlusSzie
}
// ConfigGlobal types end
// Icon type start
declare interface IconTypes {
size?: number
color?: string
icon: string
}
// Icon type end
// LocaleDropdown type start
declare interface Language {
el: Recordable
name: string
}
declare interface LocaleDropdownType {
lang: LocaleType
name?: string
elLocale?: Language
}
// LocaleDropdown type end
}