refactor: tree-select

pull/4577/head
tangjinzhou 2021-08-20 21:50:41 +08:00
parent 415c2888c4
commit 15ca5f0787
2 changed files with 5 additions and 31 deletions

View File

@ -22,32 +22,6 @@ interface TreeEventInfo {
checked?: boolean; checked?: boolean;
} }
export interface OptionListProps<OptionsType extends object[]> {
prefixCls: string;
id: string;
options: OptionsType;
flattenOptions: FlattenDataNode[];
height: number;
itemHeight: number;
virtual?: boolean;
values: Set<RawValueType>;
multiple: boolean;
open: boolean;
defaultActiveFirstOption?: boolean;
notFoundContent?: any;
menuItemSelectedIcon?: any;
childrenAsData: boolean;
searchValue: string;
onSelect: (value: RawValueType, option: { selected: boolean }) => void;
onToggleOpen: (open?: boolean) => void;
/** Tell Select that some value is now active to make accessibility work */
onActiveValue: (value: RawValueType, index: number) => void;
onScroll: UIEvent;
onMouseenter: () => void;
}
type ReviseRefOptionListProps = Omit<RefOptionListProps, 'scrollTo'> & { scrollTo: ScrollTo }; type ReviseRefOptionListProps = Omit<RefOptionListProps, 'scrollTo'> & { scrollTo: ScrollTo };
export default defineComponent({ export default defineComponent({

View File

@ -3,11 +3,11 @@ import type { DataNode } from '../tree';
import PropTypes from '../_util/vue-types'; import PropTypes from '../_util/vue-types';
import type { FlattenDataNode, RawValueType } from './interface'; import type { FlattenDataNode, RawValueType } from './interface';
export function optionListProps<OptionsType extends object[]>() { export function optionListProps<OptionsType>() {
return { return {
prefixCls: String, prefixCls: String,
id: String, id: String,
options: { type: Array as PropType<unknown> as PropType<OptionsType> }, options: { type: Array as PropType<OptionsType[]> },
flattenOptions: { type: Array as PropType<FlattenDataNode[]> }, flattenOptions: { type: Array as PropType<FlattenDataNode[]> },
height: Number, height: Number,
itemHeight: Number, itemHeight: Number,
@ -33,9 +33,9 @@ export function optionListProps<OptionsType extends object[]>() {
}; };
} }
class Helper<T extends object[]> { class Helper<T> {
Return = optionListProps<T>(); Return = optionListProps<T>();
} }
type FuncReturnType<T extends object[]> = Helper<T>['Return']; type FuncReturnType<T> = Helper<T>['Return'];
export type OptionListProps = Partial<ExtractPropTypes<FuncReturnType<DataNode[]>>>; export type OptionListProps = Partial<ExtractPropTypes<FuncReturnType<DataNode>>>;