ant-design-vue/components/vc-tree-select/props.ts

42 lines
1.6 KiB
TypeScript
Raw Normal View History

2021-08-20 13:39:59 +00:00
import type { ExtractPropTypes, PropType } from 'vue';
import type { DataNode } from '../tree';
import PropTypes from '../_util/vue-types';
import type { FlattenDataNode, RawValueType } from './interface';
export function optionListProps<OptionsType extends object[]>() {
return {
prefixCls: String,
id: String,
options: { type: Array as PropType<unknown> as PropType<OptionsType> },
flattenOptions: { type: Array as PropType<FlattenDataNode[]> },
height: Number,
itemHeight: Number,
virtual: { type: Boolean, default: undefined },
values: { type: Set as PropType<Set<RawValueType>> },
multiple: { type: Boolean, default: undefined },
open: { type: Boolean, default: undefined },
defaultActiveFirstOption: { type: Boolean, default: undefined },
notFoundContent: PropTypes.any,
menuItemSelectedIcon: PropTypes.any,
childrenAsData: { type: Boolean, default: undefined },
searchValue: String,
onSelect: {
type: Function as PropType<(value: RawValueType, option: { selected: boolean }) => void>,
},
onToggleOpen: { type: Function as PropType<(open?: boolean) => void> },
/** Tell Select that some value is now active to make accessibility work */
onActiveValue: { type: Function as PropType<(value: RawValueType, index: number) => void> },
onScroll: { type: Function as PropType<(e: UIEvent) => void> },
onMouseenter: { type: Function as PropType<() => void> },
};
}
class Helper<T extends object[]> {
Return = optionListProps<T>();
}
type FuncReturnType<T extends object[]> = Helper<T>['Return'];
export type OptionListProps = Partial<ExtractPropTypes<FuncReturnType<DataNode[]>>>;