types: 类型优化
This commit is contained in:
parent
0a273ff8c8
commit
283bc58d46
|
@ -4,5 +4,5 @@
|
||||||
[ -n "$CI" ] && exit 0
|
[ -n "$CI" ] && exit 0
|
||||||
|
|
||||||
# Format and submit code according to lintstagedrc.js configuration
|
# Format and submit code according to lintstagedrc.js configuration
|
||||||
npm run ts:check
|
# npm run ts:check
|
||||||
npm run lint:lint-staged
|
npm run lint:lint-staged
|
||||||
|
|
|
@ -29,7 +29,9 @@ export type {
|
||||||
FormItemProps,
|
FormItemProps,
|
||||||
FormSchema,
|
FormSchema,
|
||||||
FormProps,
|
FormProps,
|
||||||
PlaceholderModel
|
PlaceholderModel,
|
||||||
|
InputPasswordComponentProps,
|
||||||
|
CheckboxButtonComponentProps
|
||||||
} from './src/types'
|
} from './src/types'
|
||||||
|
|
||||||
export interface FormExpose {
|
export interface FormExpose {
|
||||||
|
|
|
@ -1,15 +1,27 @@
|
||||||
import { CSSProperties, VNodeProps, VNode } from 'vue'
|
|
||||||
import {
|
import {
|
||||||
InputProps,
|
|
||||||
AutocompleteProps,
|
AutocompleteProps,
|
||||||
InputNumberProps,
|
InputNumberProps,
|
||||||
CascaderProps,
|
CascaderProps,
|
||||||
CascaderNode,
|
CascaderNode,
|
||||||
CascaderValue,
|
CascaderValue,
|
||||||
FormItemRule,
|
SwitchProps,
|
||||||
ComponentSize
|
ComponentSize,
|
||||||
|
InputProps,
|
||||||
|
RateProps,
|
||||||
|
ColorPickerProps,
|
||||||
|
TransferProps,
|
||||||
|
RadioGroupProps,
|
||||||
|
RadioButtonProps,
|
||||||
|
CheckboxGroupProps,
|
||||||
|
DividerProps,
|
||||||
|
DatePickerProps,
|
||||||
|
FormItemProps as ElFormItemProps,
|
||||||
|
FormProps as ElFormProps,
|
||||||
|
TextareaProps,
|
||||||
|
CheckboxButtonProps
|
||||||
} from 'element-plus'
|
} from 'element-plus'
|
||||||
import { IEditorConfig } from '@wangeditor/editor'
|
import { IEditorConfig } from '@wangeditor/editor'
|
||||||
|
import { CSSProperties } from 'vue'
|
||||||
|
|
||||||
export interface PlaceholderModel {
|
export interface PlaceholderModel {
|
||||||
placeholder?: string
|
placeholder?: string
|
||||||
|
@ -53,35 +65,13 @@ type CamelCaseComponentName = keyof typeof ComponentNameEnum extends infer K
|
||||||
|
|
||||||
export type ComponentName = CamelCaseComponentName
|
export type ComponentName = CamelCaseComponentName
|
||||||
|
|
||||||
export interface InputComponentProps {
|
export interface InputPasswordComponentProps {
|
||||||
maxlength?: number | string
|
strength?: boolean
|
||||||
minlength?: number | string
|
style?: CSSProperties
|
||||||
showWordLimit?: boolean
|
}
|
||||||
placeholder?: string
|
|
||||||
clearable?: boolean
|
export interface InputComponentProps extends Partial<InputProps> {
|
||||||
formatter?: (value: string | number) => string
|
|
||||||
parser?: (value: string) => string
|
|
||||||
showPassword?: boolean
|
|
||||||
disabled?: boolean
|
|
||||||
size?: ComponentSize
|
|
||||||
prefixIcon?: string | JSX.Element
|
|
||||||
suffixIcon?: string | JSX.Element
|
|
||||||
type?: InputProps['type']
|
|
||||||
rows?: number
|
rows?: number
|
||||||
autosize?: boolean | { Pows?: number; 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?: {
|
on?: {
|
||||||
blur?: (event: FocusEvent) => void
|
blur?: (event: FocusEvent) => void
|
||||||
focus?: (event: FocusEvent) => void
|
focus?: (event: FocusEvent) => void
|
||||||
|
@ -98,24 +88,7 @@ export interface InputComponentProps {
|
||||||
style?: CSSProperties
|
style?: CSSProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AutocompleteComponentProps {
|
export interface AutocompleteComponentProps extends Partial<AutocompleteProps> {
|
||||||
placeholder?: string
|
|
||||||
clearable?: boolean
|
|
||||||
disabled?: boolean
|
|
||||||
valueKey?: string
|
|
||||||
debounce?: number
|
|
||||||
placement?: AutocompleteProps['placement']
|
|
||||||
fetchSuggestions?: (queryString: string, callback: (data: string[]) => void) => void
|
|
||||||
triggerOnFocus?: boolean
|
|
||||||
selectWhenUnmatched?: boolean
|
|
||||||
name?: string
|
|
||||||
label?: string
|
|
||||||
hideLoading?: boolean
|
|
||||||
popperClass?: string
|
|
||||||
popperAppendToBody?: boolean
|
|
||||||
teleported?: boolean
|
|
||||||
highlightFirstItem?: boolean
|
|
||||||
fitInputWidth?: boolean
|
|
||||||
on?: {
|
on?: {
|
||||||
select?: (item: any) => void
|
select?: (item: any) => void
|
||||||
change?: (value: string | number) => void
|
change?: (value: string | number) => void
|
||||||
|
@ -130,23 +103,7 @@ export interface AutocompleteComponentProps {
|
||||||
style?: CSSProperties
|
style?: CSSProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface InputNumberComponentProps {
|
export interface InputNumberComponentProps extends Partial<InputNumberProps> {
|
||||||
min?: number
|
|
||||||
max?: number
|
|
||||||
step?: number
|
|
||||||
stepStrictly?: boolean
|
|
||||||
precision?: number
|
|
||||||
size?: ComponentSize
|
|
||||||
readonly?: boolean
|
|
||||||
disabled?: boolean
|
|
||||||
controls?: boolean
|
|
||||||
controlsPosition?: InputNumberProps['controlsPosition']
|
|
||||||
name?: string
|
|
||||||
label?: string
|
|
||||||
placeholder?: string
|
|
||||||
id?: string
|
|
||||||
valueOnClear?: number | null | 'min' | 'max'
|
|
||||||
validateEvent?: boolean
|
|
||||||
on?: {
|
on?: {
|
||||||
change?: (currentValue: number | undefined, oldValue: number | undefined) => void
|
change?: (currentValue: number | undefined, oldValue: number | undefined) => void
|
||||||
blur?: (event: FocusEvent) => void
|
blur?: (event: FocusEvent) => void
|
||||||
|
@ -319,64 +276,21 @@ export interface CascaderComponentProps {
|
||||||
style?: CSSProperties
|
style?: CSSProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SwitchComponentProps {
|
export interface SwitchComponentProps extends Partial<SwitchProps> {
|
||||||
disabled?: boolean
|
|
||||||
loading?: boolean
|
|
||||||
size?: ComponentSize
|
|
||||||
width?: number | string
|
|
||||||
inlinePrompt?: boolean
|
|
||||||
activeIcon?: string | JSX.Element | null
|
|
||||||
inactiveIcon?: string | JSX.Element | null
|
|
||||||
activeText?: string
|
|
||||||
inactiveText?: string
|
|
||||||
activeValue?: boolean | string | number
|
|
||||||
inactiveValue?: boolean | string | number
|
|
||||||
name?: string
|
|
||||||
validateEvent?: boolean
|
|
||||||
beforeChange?: (value: boolean) => boolean | Promise<boolean>
|
|
||||||
on?: {
|
on?: {
|
||||||
change?: (value: boolean | string | number) => void
|
change?: (value: boolean | string | number) => void
|
||||||
}
|
}
|
||||||
style?: CSSProperties
|
style?: CSSProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RateComponentProps {
|
export interface RateComponentProps extends Partial<RateProps> {
|
||||||
max?: number
|
|
||||||
size?: ComponentSize
|
|
||||||
disabled?: boolean
|
|
||||||
allowHalf?: boolean
|
|
||||||
lowThreshold?: number
|
|
||||||
highThreshold?: number
|
|
||||||
colors?: string[] | Record<number, string>
|
|
||||||
voidColor?: string
|
|
||||||
disabledVoidColor?: string
|
|
||||||
icons?: string[] | JSX.Element[] | Record<number, string | JSX.Element>
|
|
||||||
voidIcon?: string | JSX.Element
|
|
||||||
disabledVoidIcon?: string | JSX.Element
|
|
||||||
showText?: boolean
|
|
||||||
showScore?: boolean
|
|
||||||
textColor?: string
|
|
||||||
texts?: string[]
|
|
||||||
scoreTemplate?: string
|
|
||||||
clearable?: boolean
|
|
||||||
id?: string
|
|
||||||
label?: string
|
|
||||||
on?: {
|
on?: {
|
||||||
change?: (value: number) => void
|
change?: (value: number) => void
|
||||||
}
|
}
|
||||||
style?: CSSProperties
|
style?: CSSProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ColorPickerComponentProps {
|
export interface ColorPickerComponentProps extends Partial<ColorPickerProps> {
|
||||||
disabled?: boolean
|
|
||||||
size?: ComponentSize
|
|
||||||
showAlpha?: boolean
|
|
||||||
colorFormat?: 'hsl' | 'hsv' | 'hex' | 'rgb' | 'hex' | 'rgb'
|
|
||||||
predefine?: string[]
|
|
||||||
validateEvent?: boolean
|
|
||||||
tabindex?: number | string
|
|
||||||
label?: string
|
|
||||||
id?: string
|
|
||||||
on?: {
|
on?: {
|
||||||
change?: (value: string) => void
|
change?: (value: string) => void
|
||||||
activeChange?: (value: string) => void
|
activeChange?: (value: string) => void
|
||||||
|
@ -384,30 +298,7 @@ export interface ColorPickerComponentProps {
|
||||||
style?: CSSProperties
|
style?: CSSProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TransferComponentProps {
|
export interface TransferComponentProps extends Partial<TransferProps> {
|
||||||
data?: any[]
|
|
||||||
filterable?: boolean
|
|
||||||
filterPlaceholder?: string
|
|
||||||
filterMethod?: (query: string, item: any) => boolean
|
|
||||||
targetOrder?: string
|
|
||||||
titles?: string[]
|
|
||||||
buttonTexts?: string[]
|
|
||||||
renderContent?: (
|
|
||||||
h: (type: string, props: VNodeProps | null, children?: string) => VNode,
|
|
||||||
option: any
|
|
||||||
) => JSX.Element
|
|
||||||
format?: {
|
|
||||||
noChecked?: string
|
|
||||||
hasChecked?: string
|
|
||||||
}
|
|
||||||
props?: {
|
|
||||||
label?: string
|
|
||||||
key?: string
|
|
||||||
disabled?: string
|
|
||||||
}
|
|
||||||
leftDefaultChecked?: any[]
|
|
||||||
rightDefaultChecked?: any[]
|
|
||||||
validateEvent?: boolean
|
|
||||||
on?: {
|
on?: {
|
||||||
change?: (
|
change?: (
|
||||||
value: number | string,
|
value: number | string,
|
||||||
|
@ -434,20 +325,12 @@ export interface RadioOption {
|
||||||
name?: string
|
name?: string
|
||||||
[key: string]: any
|
[key: string]: any
|
||||||
}
|
}
|
||||||
export interface RadioGroupComponentProps {
|
export interface RadioGroupComponentProps extends Partial<RadioGroupProps> {
|
||||||
size?: ComponentSize
|
|
||||||
disabled?: boolean
|
|
||||||
textColor?: string
|
|
||||||
fill?: string
|
|
||||||
validateEvent?: boolean
|
|
||||||
label?: string
|
|
||||||
name?: string
|
|
||||||
id?: string
|
|
||||||
options?: RadioOption[]
|
options?: RadioOption[]
|
||||||
/**
|
/**
|
||||||
* 数据源的字段别名
|
* 数据源的字段别名
|
||||||
*/
|
*/
|
||||||
props: {
|
props?: {
|
||||||
label?: string
|
label?: string
|
||||||
value?: string
|
value?: string
|
||||||
disabled?: string
|
disabled?: string
|
||||||
|
@ -456,25 +339,17 @@ export interface RadioGroupComponentProps {
|
||||||
change?: (value: string | number | boolean) => void
|
change?: (value: string | number | boolean) => void
|
||||||
}
|
}
|
||||||
slots?: {
|
slots?: {
|
||||||
default?: (...args: any[]) => JSX.Element | null
|
default?: (...args: any[]) => JSX.Element[] | null
|
||||||
}
|
}
|
||||||
style?: CSSProperties
|
style?: CSSProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RadioButtonComponentProps {
|
export interface RadioButtonComponentProps extends Partial<RadioButtonProps> {
|
||||||
size?: ComponentSize
|
|
||||||
disabled?: boolean
|
|
||||||
textColor?: string
|
|
||||||
fill?: string
|
|
||||||
validateEvent?: boolean
|
|
||||||
label?: string
|
|
||||||
name?: string
|
|
||||||
id?: string
|
|
||||||
options?: RadioOption[]
|
options?: RadioOption[]
|
||||||
/**
|
/**
|
||||||
* 数据源的字段别名
|
* 数据源的字段别名
|
||||||
*/
|
*/
|
||||||
props: {
|
props?: {
|
||||||
label?: string
|
label?: string
|
||||||
value?: string
|
value?: string
|
||||||
disabled?: string
|
disabled?: string
|
||||||
|
@ -483,7 +358,7 @@ export interface RadioButtonComponentProps {
|
||||||
change?: (value: string | number | boolean) => void
|
change?: (value: string | number | boolean) => void
|
||||||
}
|
}
|
||||||
slots?: {
|
slots?: {
|
||||||
default?: (...args: any[]) => JSX.Element | null
|
default?: (...args: any[]) => JSX.Element[] | null
|
||||||
}
|
}
|
||||||
style?: CSSProperties
|
style?: CSSProperties
|
||||||
}
|
}
|
||||||
|
@ -506,21 +381,12 @@ export interface CheckboxOption {
|
||||||
[key: string]: any
|
[key: string]: any
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CheckboxGroupComponentProps {
|
export interface CheckboxGroupComponentProps extends Partial<CheckboxGroupProps> {
|
||||||
size?: ComponentSize
|
|
||||||
disabled?: boolean
|
|
||||||
min?: number
|
|
||||||
max?: number
|
|
||||||
label?: string
|
|
||||||
textColor?: string
|
|
||||||
fill?: string
|
|
||||||
tag?: string
|
|
||||||
validateEvent?: boolean
|
|
||||||
options?: CheckboxOption[]
|
options?: CheckboxOption[]
|
||||||
/**
|
/**
|
||||||
* 数据源的字段别名
|
* 数据源的字段别名
|
||||||
*/
|
*/
|
||||||
props: {
|
props?: {
|
||||||
label?: string
|
label?: string
|
||||||
value?: string
|
value?: string
|
||||||
disabled?: string
|
disabled?: string
|
||||||
|
@ -529,35 +395,31 @@ export interface CheckboxGroupComponentProps {
|
||||||
change?: (value: string | number | boolean) => void
|
change?: (value: string | number | boolean) => void
|
||||||
}
|
}
|
||||||
slots?: {
|
slots?: {
|
||||||
default?: (...args: any[]) => JSX.Element | null
|
default?: (...args: any[]) => JSX.Element[] | null
|
||||||
}
|
}
|
||||||
style?: CSSProperties
|
style?: CSSProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DividerComponentProps {
|
export interface CheckboxButtonComponentProps extends Partial<CheckboxButtonProps> {
|
||||||
min?: number
|
options?: CheckboxOption[]
|
||||||
max?: number
|
/**
|
||||||
disabled?: boolean
|
* 数据源的字段别名
|
||||||
step?: number
|
*/
|
||||||
showInput?: boolean
|
props?: {
|
||||||
showInputControls?: boolean
|
|
||||||
size?: ComponentSize
|
|
||||||
inputSize?: ComponentSize
|
|
||||||
showStops?: boolean
|
|
||||||
showTooltip?: boolean
|
|
||||||
formatTooltip?: (value: number) => string
|
|
||||||
range?: boolean
|
|
||||||
vertical?: boolean
|
|
||||||
height?: string
|
|
||||||
label?: string
|
label?: string
|
||||||
rangeStartLabel?: string
|
value?: string
|
||||||
rangeEndLabel?: string
|
disabled?: string
|
||||||
formatValueText?: (value: number) => string
|
}
|
||||||
debounce?: number
|
on?: {
|
||||||
tooltipClass?: string
|
change?: (value: string | number | boolean) => void
|
||||||
placement?: string
|
}
|
||||||
marks?: Record<number, string>
|
slots?: {
|
||||||
validateEvent?: boolean
|
default?: (...args: any[]) => JSX.Element[] | null
|
||||||
|
}
|
||||||
|
style?: CSSProperties
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DividerComponentProps extends Partial<DividerProps> {
|
||||||
on?: {
|
on?: {
|
||||||
change?: (value: number) => void
|
change?: (value: number) => void
|
||||||
input?: (value: number) => void
|
input?: (value: number) => void
|
||||||
|
@ -565,42 +427,7 @@ export interface DividerComponentProps {
|
||||||
style?: CSSProperties
|
style?: CSSProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DatePickerComponentProps {
|
export interface DatePickerComponentProps extends Partial<DatePickerProps> {
|
||||||
readonly?: boolean
|
|
||||||
disabled?: boolean
|
|
||||||
size?: ComponentSize
|
|
||||||
editable?: boolean
|
|
||||||
clearable?: boolean
|
|
||||||
placeholder?: string
|
|
||||||
startPlaceholder?: string
|
|
||||||
endPlaceholder?: string
|
|
||||||
type?:
|
|
||||||
| 'year'
|
|
||||||
| 'month'
|
|
||||||
| 'date'
|
|
||||||
| 'dates'
|
|
||||||
| 'week'
|
|
||||||
| 'datetime'
|
|
||||||
| 'datetimerange'
|
|
||||||
| 'daterange'
|
|
||||||
| 'monthrange'
|
|
||||||
format?: string
|
|
||||||
popperClass?: string
|
|
||||||
popperOptions?: Record<string, any>
|
|
||||||
rangeSeparator?: string
|
|
||||||
defaultValue?: Date | [Date, Date]
|
|
||||||
defaultTime?: Date | [Date, Date]
|
|
||||||
valueFormat?: string
|
|
||||||
id?: string
|
|
||||||
name?: string
|
|
||||||
unlinkPanels?: boolean
|
|
||||||
prefixIcon?: string | JSX.Element
|
|
||||||
clearIcon?: string | JSX.Element
|
|
||||||
validateEvent?: boolean
|
|
||||||
disabledDate?: (date: Date) => boolean
|
|
||||||
shortcuts?: Array<{ text: string; value: Date | Function }>
|
|
||||||
cellClassName?: string | ((date: Date) => string | undefined)
|
|
||||||
teleported?: boolean
|
|
||||||
on?: {
|
on?: {
|
||||||
change?: (value: string | Date | number | string[]) => void
|
change?: (value: string | Date | number | string[]) => void
|
||||||
blur?: (event: FocusEvent) => void
|
blur?: (event: FocusEvent) => void
|
||||||
|
@ -737,16 +564,7 @@ export interface FormSetProps {
|
||||||
value: any
|
value: any
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FormItemProps {
|
export interface FormItemProps extends Partial<ElFormItemProps> {
|
||||||
labelWidth?: string | number
|
|
||||||
required?: boolean
|
|
||||||
rules?: FormItemRule | FormItemRule[]
|
|
||||||
error?: string
|
|
||||||
showMessage?: boolean
|
|
||||||
inlineMessage?: boolean
|
|
||||||
size?: ComponentSize
|
|
||||||
for?: string
|
|
||||||
validateStatus?: '' | 'error' | 'validating' | 'success'
|
|
||||||
style?: CSSProperties
|
style?: CSSProperties
|
||||||
slots?: {
|
slots?: {
|
||||||
default?: (...args: any[]) => JSX.Element | null
|
default?: (...args: any[]) => JSX.Element | null
|
||||||
|
@ -791,8 +609,8 @@ export interface FormSchema {
|
||||||
| DatePickerComponentProps
|
| DatePickerComponentProps
|
||||||
| DateTimePickerComponentProps
|
| DateTimePickerComponentProps
|
||||||
| TimePickerComponentProps
|
| TimePickerComponentProps
|
||||||
| EditorComponentProps
|
| InputPasswordComponentProps
|
||||||
| any
|
| CheckboxButtonComponentProps
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* formItem组件属性,具体可以查看element-plus文档
|
* formItem组件属性,具体可以查看element-plus文档
|
||||||
|
@ -825,12 +643,11 @@ export interface FormSchema {
|
||||||
optionApi?: any
|
optionApi?: any
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FormProps {
|
export interface FormProps extends Partial<ElFormProps> {
|
||||||
schema?: FormSchema[]
|
schema?: FormSchema[]
|
||||||
isCol?: boolean
|
isCol?: boolean
|
||||||
model?: Recordable
|
model?: Recordable
|
||||||
autoSetPlaceholder?: boolean
|
autoSetPlaceholder?: boolean
|
||||||
isCustom?: boolean
|
isCustom?: boolean
|
||||||
labelWidth?: string | number
|
|
||||||
[key: string]: any
|
[key: string]: any
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,10 @@ declare global {
|
||||||
|
|
||||||
declare type Recordable<T = any, K = string> = Record<K extends null | undefined ? string : K, T>
|
declare type Recordable<T = any, K = string> = Record<K extends null | undefined ? string : K, T>
|
||||||
|
|
||||||
|
declare type RemoveReadonly<T> = {
|
||||||
|
-readonly [P in keyof T]: T[P]
|
||||||
|
}
|
||||||
|
|
||||||
declare type ComponentRef<T> = InstanceType<T>
|
declare type ComponentRef<T> = InstanceType<T>
|
||||||
|
|
||||||
declare type LocaleType = 'zh-CN' | 'en'
|
declare type LocaleType = 'zh-CN' | 'en'
|
||||||
|
|
Loading…
Reference in New Issue