@daysnap/horn-ui
Version:
hron ui
42 lines (35 loc) • 1.11 kB
text/typescript
import type { Numeric } from 'vant/lib/utils'
import type { ExtractPropTypes, PropType } from 'vue'
import { makeStringProp, makeBooleanProp, type Looser } from '../utils'
//TODO 类型需限制加推断
export type OptionItem = Looser<{
label: Numeric
value: Numeric
noNext?: boolean
}>
export type AnchorOptionItem = Looser<{
anchor: string
children: OptionItem[]
}>
export type CascadeOptions = Array<OptionItem | AnchorOptionItem>
export type PromiseOption = (option?: OptionItem) => Promise<CascadeOptions> | CascadeOptions
export const horCascadePopupProps = {
title: makeStringProp('请选择'),
options: {
type: [Array, Function] as PropType<CascadeOptions | PromiseOption>,
default: () => [],
},
hideIndexbar: makeBooleanProp(false),
search: {
type: [Boolean, Function],
default: false,
},
keyword: makeStringProp(''),
next: {
type: Object as PropType<any>,
default: () => ({}),
},
}
export type HorCascadePopupProps = Omit<ExtractPropTypes<typeof horCascadePopupProps>, 'next'> & {
next: Partial<ExtractPropTypes<typeof horCascadePopupProps>>
}