@squirrel-cloud/ui-vue
Version:
松鼠的坚果屋前端VUE框架
148 lines (125 loc) • 2.14 kB
TypeScript
import type { InputProps, TextareaProps } from '../props'
import type { Arrayable, Promiseable, TriggerType } from '.'
/**
* 表单验证规则
*/
export declare interface FormRule {
/**
* 匹配表达式
*/
pattern?: RegExp
/**
* 表达式不匹配时提示语
*/
patternText?: string
/**
* 是否为必填字段
*/
required?: boolean
/**
* 必填不匹配时提示语
*/
requiredText?: string
/**
* 响应触发类型
*/
trigger?: Arrayable<TriggerType>
/**
* 验证方法
*/
validateFunc?: (
value: unknown,
signal: AbortSignal,
trigger?: TriggerType,
) => Promiseable<string | boolean | undefined>
}
/**
* 表单基础配置
*/
export declare interface FormConfigBase {
/**
* 验证规则
*/
rule?: FormRule
/**
* 标签内容
*/
label?: string
/**
* 标签宽度
*/
labelWidth?: string
/**
* 无标签时是否显示标签
*/
showLabel?: boolean
/**
* 表单项类名
*/
itemClass?: Arrayable<string>
/**
* 表单关联的步骤
*/
step?: Arrayable<number>
/**
* 字段名称
*/
name: string
/**
* 绑定数据项
*/
binding: string
}
/**
* 输入框表单项配置
*/
export declare interface FormConfigInput extends FormConfigBase {
/**
* 类型
*/
type: 'input'
/**
* 输入框配置
*/
props?: Omit<InputProps, 'name' | 'status' | 'showStatusIcon' | 'loading'>
}
/**
* 文本域表单项配置
*/
export declare interface FormConfigTextarea extends FormConfigBase {
/**
* 类型
*/
type: 'textarea'
/**
* 文本域配置
*/
props?: Omit<TextareaProps, 'name' | 'status'>
}
/**
* 自定义表单项排除键
*/
declare type CustomExcludeKeys = 'name' | 'binding' | 'rule'
/**
* 自定义表单项配置
*/
export declare type FormConfigCustom = Omit<
FormConfigBase,
CustomExcludeKeys
> & {
/**
* 类型
*/
type: 'custom'
/**
* 插槽名称
*/
slot: string
}
/**
* 表单项配置
*/
export declare type FormConfig =
| FormConfigCustom
| FormConfigTextarea
| FormConfigInput