UNPKG

@tplc/wot

Version:

242 lines (241 loc) 5.13 kB
import type { ComponentPublicInstance, ExtractPropTypes, PropType } from 'vue' import type { ColumnItem, PickerViewColumnChange } from '../wd-picker-view/types' import type { FormItemRule } from '../wd-form/types' export declare const pickerProps: { /** * label 外部自定义样式 */ customLabelClass: { type: PropType<string> default: string } /** * value 外部自定义样式 */ customValueClass: { type: PropType<string> default: string } /** * pickerView 外部自定义样式 */ customViewClass: { type: PropType<string> default: string } /** * 选择器左侧文案 */ label: StringConstructor /** * 选择器占位符 */ placeholder: StringConstructor /** * 是否禁用 */ disabled: { type: BooleanConstructor default: boolean } /** * 是否只读 */ readonly: { type: BooleanConstructor default: boolean } /** * 加载中 */ loading: { type: BooleanConstructor default: boolean } /** * 加载中颜色 */ loadingColor: { type: PropType<string> default: string } /** * 弹出层标题 */ title: StringConstructor /** * 取消按钮文案 */ cancelButtonText: StringConstructor /** * 确认按钮文案 */ confirmButtonText: StringConstructor /** * 是否必填 */ required: { type: BooleanConstructor default: boolean } /** * 尺寸 */ size: StringConstructor /** * 标签宽度 */ labelWidth: StringConstructor /** * 使用默认插槽 */ useDefaultSlot: { type: BooleanConstructor default: boolean } /** * 使用标签插槽 */ useLabelSlot: { type: BooleanConstructor default: boolean } /** * 错误状态 */ error: { type: BooleanConstructor default: boolean } /** * 右对齐 */ alignRight: { type: BooleanConstructor default: boolean } /** * 确定前校验函数,接收 (value, resolve, picker) 参数,通过 resolve 继续执行 picker,resolve 接收1个boolean参数 */ beforeConfirm: PropType<PickerBeforeConfirm> /** * 点击蒙层关闭 */ closeOnClickModal: { type: BooleanConstructor default: boolean } /** * 底部安全区域内 */ safeAreaInsetBottom: { type: BooleanConstructor default: boolean } /** * 文本溢出显示省略号 */ ellipsis: { type: BooleanConstructor default: boolean } /** * 选项总高度 */ columnsHeight: { type: NumberConstructor default: number } /** * 选项值对应的键名 */ valueKey: { type: PropType<string> default: string } /** * 选项文本对应的键名 */ labelKey: { type: PropType<string> default: string } /** * 选中项,如果为多列选择器,则其类型应为数组 */ modelValue: { type: PropType<string | number | Array<string> | Array<number>> default: string } /** * 选择器数据,可以为字符串数组,也可以为对象数组,如果为二维数组,则为多列选择器 */ columns: { type: PropType<Array<string | number | ColumnItem | Array<string | number | ColumnItem>>> default: () => never[] } /** * 接收 pickerView 实例、选中项、当前修改列的下标、resolve 作为入参,根据选中项和列下标进行判断,通过 pickerView 实例暴露出来的 setColumnData 方法修改其他列的数据源。 */ columnChange: PropType<PickerViewColumnChange> /** * 自定义展示文案的格式化函数,返回一个字符串 */ displayFormat: PropType<PickerDisplayFormat> /** * 自定义层级 */ zIndex: { type: NumberConstructor default: number } /** * 表单域 model 字段名,在使用表单校验功能的情况下,该属性是必填的 */ prop: StringConstructor /** * 表单验证规则,结合wd-form组件使用 */ rules: { type: PropType<FormItemRule[]> default: () => never[] } /** * 是否在手指松开时立即触发 change 事件。若不开启则会在滚动动画结束后触发 change 事件,1.2.25版本起提供,仅微信小程序和支付宝小程序支持。 */ immediateChange: { type: BooleanConstructor default: boolean } customStyle: { type: PropType<string> default: string } customClass: { type: PropType<string> default: string } } export type PickerProps = ExtractPropTypes<typeof pickerProps> export type PickerDisplayFormat = ( item: ColumnItem | ColumnItem[], vl: { valueKey: string labelKey: string }, ) => string export type PickerBeforeConfirm = ( value: string | number | boolean | string[] | number[] | boolean[], resolve: (isPass: boolean) => void, picker: any, ) => void export type PickerExpose = { open: () => void close: () => void /** * 设置加载状态 * @param loading 加载状态 */ setLoading: (loading: boolean) => void } export type PickerInstance = ComponentPublicInstance<PickerExpose, PickerProps>