gohttpdUi/src/types/components.d.ts

111 lines
2.9 KiB
TypeScript
Raw Normal View History

2023-04-26 17:49:30 +08:00
import { CSSProperties } from 'vue'
import { InputProps } from 'element-plus'
export enum ComponentNameEnum {
RADIO = 'Radio',
RADIO_BUTTON = 'RadioButton',
CHECKBOX = 'Checkbox',
CHECKBOX_BUTTON = 'CheckboxButton',
INPUT = 'Input',
AUTOCOMPLETE = 'Autocomplete',
INPUT_NUMBER = 'InputNumber',
SELECT = 'Select',
CASCADER = 'Cascader',
SWITCH = 'Switch',
SLIDER = 'Slider',
TIME_PICKER = 'TimePicker',
DATE_PICKER = 'DatePicker',
RATE = 'Rate',
COLOR_PICKER = 'ColorPicker',
TRANSFER = 'Transfer',
DIVIDER = 'Divider',
TIME_SELECT = 'TimeSelect',
SELECT_V2 = 'SelectV2',
INPUT_PASSWORD = 'InputPassword',
EDITOR = 'Editor'
}
export interface InputComponentProps {
value?: string | number
maxlength?: number | string
minlength?: number | string
showWordLimit?: boolean
placeholder?: string
clearable?: boolean
formatter?: (value: string | number) => string
parser?: (value: string) => string
showPassword?: boolean
disabled?: boolean
size?: InputProps['size']
prefixIcon?: string | JSX.Element | (<T>(data: T | any) => string | JSX.Element)
suffixIcon?: string | JSX.Element | (<T>(data: T | any) => string | JSX.Element)
rows?: number
autosize?: boolean | { Pows?: numer; maxRows?: number }
autocomplete?: string
name?: string
readonly?: boolean
max?: number | string
min?: number | string
step?: number | string
resize?: InputProps['resize']
autofocus?: boolean
form?: string
label?: string
tabindex?: string | number
validateEvent?: boolean
inputStyle?: string | CSSProperties | CSSProperties[] | string[]
on?: {
blur?: (event: FocusEvent) => void
focus?: (event: FocusEvent) => void
change?: (value: string | number) => void
clear?: () => void
input?: (value: string | number) => void
}
slots?: {
prefix?: JSX.Element | (<T>(data: T | any) => JSX.Element)
suffix?: JSX.Element | (<T>(data: T | any) => JSX.Element)
prepend?: JSX.Element | (<T>(data: T | any) => JSX.Element)
append?: JSX.Element | (<T>(data: T | any) => JSX.Element)
}
}
type CamelCaseComponentName = keyof typeof ComponentNameEnum extends infer K
? K extends string
? K extends `${infer A}_${infer B}`
? `${Capitalize<Lowercase<A>>}${Capitalize<Lowercase<B>>}`
: Capitalize<Lowercase<K>>
: never
: never
export type ComponentName = CamelCaseComponentName
export interface ColProps {
2022-10-09 17:12:03 +08:00
span?: number
xs?: number
sm?: number
md?: number
lg?: number
xl?: number
tag?: string
}
2023-04-26 17:49:30 +08:00
export interface ComponentOptions extends Recordable {
2022-10-09 17:12:03 +08:00
label?: string
value?: FormValueType
disabled?: boolean
key?: string | number
children?: ComponentOptions[]
options?: ComponentOptions[]
2023-04-26 17:49:30 +08:00
}
2022-10-09 17:12:03 +08:00
2023-04-26 17:49:30 +08:00
export interface ComponentOptionsAlias {
2022-10-09 17:12:03 +08:00
labelField?: string
valueField?: string
}
2023-04-26 17:49:30 +08:00
export interface ComponentProps extends Recordable {
2022-10-09 17:12:03 +08:00
optionsAlias?: ComponentOptionsAlias
options?: ComponentOptions[]
optionsSlot?: boolean
2023-04-26 17:49:30 +08:00
}