import PropTypes from '../../../../_util/vue-types';
import { createRef } from '../../util';
import generateSelector, { selectorPropTypes } from '../../Base/BaseSelector';
import SearchInput from '../../SearchInput';
import Selection from './Selection';
import { getComponentFromProp } from '../../../../_util/props-util';
import getTransitionProps from '../../../../_util/getTransitionProps';
import BaseMixin from '../../../../_util/BaseMixin';
const TREE_SELECT_EMPTY_VALUE_KEY = 'RC_TREE_SELECT_EMPTY_VALUE_KEY';
const Selector = generateSelector('multiple');
// export const multipleSelectorContextTypes = {
// onMultipleSelectorRemove: PropTypes.func.isRequired,
// }
const MultipleSelector = {
mixins: [BaseMixin],
props: {
...selectorPropTypes(),
...SearchInput.props,
selectorValueList: PropTypes.array,
disabled: PropTypes.bool,
searchValue: PropTypes.string,
labelInValue: PropTypes.bool,
maxTagCount: PropTypes.number,
maxTagPlaceholder: PropTypes.oneOfType([PropTypes.any, PropTypes.func]),
// onChoiceAnimationLeave: PropTypes.func,
},
inject: {
vcTreeSelect: { default: () => ({}) },
},
created() {
this.inputRef = createRef();
},
methods: {
onPlaceholderClick() {
this.inputRef.current.focus();
},
focus() {
this.inputRef.current.focus();
},
blur() {
this.inputRef.current.blur();
},
_renderPlaceholder() {
const {
prefixCls,
placeholder,
searchPlaceholder,
searchValue,
selectorValueList,
} = this.$props;
const currentPlaceholder = placeholder || searchPlaceholder;
if (!currentPlaceholder) return null;
const hidden = searchValue || selectorValueList.length;
// [Legacy] Not remove the placeholder
return (
{currentPlaceholder}
);
},
onChoiceAnimationLeave(...args) {
this.__emit('choiceAnimationLeave', ...args);
},
renderSelection() {
const {
selectorValueList,
choiceTransitionName,
prefixCls,
labelInValue,
maxTagCount,
} = this.$props;
const {
vcTreeSelect: { onMultipleSelectorRemove },
$listeners,
$slots,
} = this;
// Check if `maxTagCount` is set
let myValueList = selectorValueList;
if (maxTagCount >= 0) {
myValueList = selectorValueList.slice(0, maxTagCount);
}
// Selector node list
const selectedValueNodes = myValueList.map(({ label, value }) => (