import type { ExtractPropTypes, PropType } from 'vue'; import type { DataNode, ChangeEventExtra, DefaultValueType, FieldNames, FlattenDataNode, LabelValueType, LegacyDataNode, RawValueType, SimpleModeConfig, } from './interface'; import { selectBaseProps } from '../vc-select'; import type { FilterFunc } from '../vc-select/interface/generator'; import omit from '../_util/omit'; import type { Key } from '../_util/type'; import PropTypes from '../_util/vue-types'; import type { CheckedStrategy } from './utils/strategyUtil'; export function optionListProps() { return { prefixCls: String, id: String, options: { type: Array as PropType }, flattenOptions: { type: Array as PropType }, height: Number, itemHeight: Number, virtual: { type: Boolean, default: undefined }, values: { type: Set as PropType> }, 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> }, }; } export function treeSelectProps() { const selectProps = omit(selectBaseProps(), [ 'onChange', 'mode', 'menuItemSelectedIcon', 'dropdownAlign', 'backfill', 'getInputElement', 'optionLabelProp', 'tokenSeparators', 'filterOption', ]); return { ...selectProps, multiple: { type: Boolean, default: undefined }, showArrow: { type: Boolean, default: undefined }, showSearch: { type: Boolean, default: undefined }, open: { type: Boolean, default: undefined }, defaultOpen: { type: Boolean, default: undefined }, value: { type: [String, Number, Object, Array] as PropType }, defaultValue: { type: [String, Number, Object, Array] as PropType }, disabled: { type: Boolean, default: undefined }, placeholder: PropTypes.any, /** @deprecated Use `searchValue` instead */ inputValue: String, searchValue: String, autoClearSearchValue: { type: Boolean, default: undefined }, maxTagPlaceholder: { type: Function as PropType<(omittedValues: LabelValueType[]) => any> }, fieldNames: { type: Object as PropType }, loadData: { type: Function as PropType<(dataNode: LegacyDataNode) => Promise> }, treeNodeFilterProp: String, treeNodeLabelProp: String, treeDataSimpleMode: { type: [Boolean, Object] as PropType, default: undefined, }, treeExpandedKeys: { type: Array as PropType }, treeDefaultExpandedKeys: { type: Array as PropType }, treeLoadedKeys: { type: Array as PropType }, treeCheckable: { type: Boolean, default: undefined }, treeCheckStrictly: { type: Boolean, default: undefined }, showCheckedStrategy: { type: String as PropType }, treeDefaultExpandAll: { type: Boolean, default: undefined }, treeData: { type: Array as PropType }, treeLine: { type: Boolean, default: undefined }, treeIcon: PropTypes.any, showTreeIcon: { type: Boolean, default: undefined }, switcherIcon: PropTypes.any, treeMotion: PropTypes.any, children: Array, filterTreeNode: { type: [Boolean, Function] as PropType>, default: undefined, }, dropdownPopupAlign: PropTypes.any, // Event onSearch: { type: Function as PropType<(value: string) => void> }, onChange: { type: Function as PropType< (value: ValueType, labelList: any[], extra: ChangeEventExtra) => void >, }, onTreeExpand: { type: Function as PropType<(expandedKeys: Key[]) => void> }, onTreeLoad: { type: Function as PropType<(loadedKeys: Key[]) => void> }, onDropdownVisibleChange: { type: Function as PropType<(open: boolean) => void> }, // Legacy /** `searchPlaceholder` has been removed since search box has been merged into input box */ searchPlaceholder: PropTypes.any, /** @private This is not standard API since we only used in `rc-cascader`. Do not use in your production */ labelRender: { type: Function as PropType<(entity: FlattenDataNode) => any> }, }; } class Helper { ReturnOptionListProps = optionListProps(); ReturnTreeSelectProps = treeSelectProps(); } export type OptionListProps = Partial['ReturnOptionListProps']>>; export type TreeSelectProps = Partial< ExtractPropTypes['ReturnTreeSelectProps']> >;