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';
|
|
|
|
|
2021-08-20 13:50:41 +00:00
|
|
|
export function optionListProps<OptionsType>() {
|
2021-08-20 13:39:59 +00:00
|
|
|
return {
|
|
|
|
prefixCls: String,
|
|
|
|
id: String,
|
2021-08-20 13:50:41 +00:00
|
|
|
options: { type: Array as PropType<OptionsType[]> },
|
2021-08-20 13:39:59 +00:00
|
|
|
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> },
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-08-20 13:50:41 +00:00
|
|
|
class Helper<T> {
|
2021-08-20 13:39:59 +00:00
|
|
|
Return = optionListProps<T>();
|
|
|
|
}
|
2021-08-20 13:50:41 +00:00
|
|
|
type FuncReturnType<T> = Helper<T>['Return'];
|
2021-08-20 13:39:59 +00:00
|
|
|
|
2021-08-20 13:50:41 +00:00
|
|
|
export type OptionListProps = Partial<ExtractPropTypes<FuncReturnType<DataNode>>>;
|