UNPKG

@tplc/wot

Version:

206 lines (205 loc) 5.74 kB
import type { ComponentPublicInstance, ExtractPropTypes, PropType } from 'vue' import type { FormItemRule } from '../wd-form/types' export type SelectPickerType = 'checkbox' | 'radio' | 'button' export type SelectPickerRemote = { action: ( search: string, params: { pageSearch: { page: number limit: number } }, ) => Promise<Record<string, any>[]> pageSize?: number isPage?: boolean } export declare const selectPickerProps: { /** 选择器左侧文案 */ label: StringConstructor /** 设置左侧标题宽度 */ labelWidth: { type: PropType<string> default: string } /** 禁用 */ disabled: { type: BooleanConstructor default: boolean } /** 只读 */ readonly: BooleanConstructor /** 选择器占位符 */ placeholder: StringConstructor /** 弹出层标题 */ title: StringConstructor /** 选择器的值靠右展示 */ alignRight: { type: BooleanConstructor default: boolean } /** 是否为错误状态,错误状态时右侧内容为红色 */ error: { type: BooleanConstructor default: boolean } /** 必填样式 */ required: { type: BooleanConstructor default: boolean } /** 使用 label 插槽时设置该选项 */ useLabelSlot: { type: BooleanConstructor default: boolean } /** 使用默认插槽时设置该选项 */ useDefaultSlot: { type: BooleanConstructor default: boolean } /** 设置选择器大小 */ size: StringConstructor /** 选中的颜色(单/复选框) */ checkedColor: StringConstructor /** 最小选中的数量(仅在复选框类型下生效,`type`类型为`checkbox`) */ min: { type: NumberConstructor default: number } /** 最大选中的数量,0 为无限数量,默认为 0(仅在复选框类型下生效,`type`类型为`checkbox`) */ max: { type: NumberConstructor default: number } /** 设置 picker 内部的选项组尺寸大小 (单/复选框) */ selectSize: StringConstructor /** 加载中 */ loading: { type: BooleanConstructor default: boolean } /** 加载的颜色,只能使用十六进制的色值写法,且不能使用缩写 */ loadingColor: { type: PropType<string> default: string } /** 点击遮罩是否关闭 */ closeOnClickModal: { type: BooleanConstructor default: boolean } /** 选中项,`type`类型为`checkbox`时,类型为 array;`type`为`radio` ,类型为 number / boolean / string */ modelValue: { type: PropType<string | number | boolean | (string | number | boolean)[]> required: true } /** 选择器数据,一维数组 */ columns: { type: PropType<Record<string, any>[]> default: () => never[] } /** 单复选选择器类型 */ type: { type: PropType<SelectPickerType> default: SelectPickerType } /** 选项对象中,value 对应的 key */ valueKey: { type: PropType<string> default: string } /** 选项对象中,展示的文本对应的 key */ labelKey: { type: PropType<string> default: string } /** 确认按钮文案 */ confirmButtonText: StringConstructor /** 自定义展示文案的格式化函数,返回一个字符串 */ displayFormat: PropType<SelectPickerDisplayFormat> /** 确定前校验函数,接收 (value, resolve) 参数,通过 resolve 继续执行 picker,resolve 接收 1 boolean 参数 */ beforeConfirm: PropType<SelectPickerBeforeConfirm> /** 弹窗层级 */ zIndex: { type: NumberConstructor default: number } /** 弹出面板是否设置底部安全距离(iphone X 类型的机型) */ safeAreaInsetBottom: { type: BooleanConstructor default: boolean } /** 可搜索(目前只支持本地搜索) */ filterable: { type: BooleanConstructor default: boolean } /** 远程搜索配置 */ remoteConfig: { type: PropType<SelectPickerRemote> } /** 搜索框占位符 */ filterPlaceholder: StringConstructor /** 是否超出隐藏 */ ellipsis: { type: BooleanConstructor default: boolean } /** 重新打开是否滚动到选中项 */ scrollIntoView: { type: BooleanConstructor default: boolean } /** 表单域 `model` 字段名,在使用表单校验功能的情况下,该属性是必填的 */ prop: StringConstructor /** 表单验证规则,结合`wd-form`组件使用 */ rules: { type: PropType<FormItemRule[]> default: () => never[] } /** 自定义内容样式类 */ customContentClass: { type: PropType<string> default: string } /** 自定义标签样式类 */ customLabelClass: { type: PropType<string> default: string } /** 自定义值样式类 */ customValueClass: { type: PropType<string> default: string } /** 是否显示确认按钮(radio类型生效),默认值为:true */ showConfirm: { type: BooleanConstructor default: boolean } /** 默认展示文案 */ defaultLabel: StringConstructor customStyle: { type: PropType<string> default: string } customClass: { type: PropType<string> default: string } } export type SelectPickerProps = ExtractPropTypes<typeof selectPickerProps> export type SelectPickerDisplayFormat = ( items: string | number | boolean | (string | number | boolean)[], columns: Record<string, any>[], ) => string export type SelectPickerBeforeConfirm = ( value: string | number | boolean | (string | number | boolean)[], resolve: (isPass: boolean) => void, ) => void export type SelectPickerExpose = { open: () => void close: () => void } export type SelectPickerInstance = ComponentPublicInstance<SelectPickerExpose, SelectPickerProps>