2019-01-12 11:33:27 +08:00
|
|
|
|
import KeyCode from '../_util/KeyCode';
|
|
|
|
|
import PropTypes from '../_util/vue-types';
|
|
|
|
|
import classnames from 'classnames';
|
|
|
|
|
import classes from 'component-classes';
|
|
|
|
|
import { Item as MenuItem, ItemGroup as MenuItemGroup } from '../vc-menu';
|
|
|
|
|
import warning from 'warning';
|
|
|
|
|
import Vue from 'vue';
|
|
|
|
|
import Option from './Option';
|
|
|
|
|
import OptGroup from './OptGroup';
|
|
|
|
|
import {
|
|
|
|
|
hasProp,
|
|
|
|
|
getSlotOptions,
|
|
|
|
|
getPropsData,
|
|
|
|
|
getValueByProp as getValue,
|
|
|
|
|
getComponentFromProp,
|
|
|
|
|
getEvents,
|
|
|
|
|
getClass,
|
|
|
|
|
getStyle,
|
|
|
|
|
getAttrs,
|
|
|
|
|
getOptionProps,
|
|
|
|
|
getSlots,
|
|
|
|
|
} from '../_util/props-util';
|
|
|
|
|
import getTransitionProps from '../_util/getTransitionProps';
|
|
|
|
|
import { cloneElement } from '../_util/vnode';
|
|
|
|
|
import BaseMixin from '../_util/BaseMixin';
|
|
|
|
|
import proxyComponent from '../_util/proxyComponent';
|
|
|
|
|
import ref from 'vue-ref';
|
|
|
|
|
import SelectTrigger from './SelectTrigger';
|
2018-02-07 18:56:58 +08:00
|
|
|
|
import {
|
2019-01-04 23:00:09 +08:00
|
|
|
|
defaultFilterFn,
|
|
|
|
|
findFirstMenuItem,
|
|
|
|
|
findIndexInValueBySingleValue,
|
|
|
|
|
generateUUID,
|
|
|
|
|
getLabelFromPropsValue,
|
|
|
|
|
getMapKey,
|
2018-02-07 18:56:58 +08:00
|
|
|
|
getPropValue,
|
|
|
|
|
getValuePropValue,
|
2019-01-04 23:00:09 +08:00
|
|
|
|
includesSeparators,
|
2018-02-07 18:56:58 +08:00
|
|
|
|
isCombobox,
|
|
|
|
|
isMultipleOrTags,
|
|
|
|
|
isMultipleOrTagsOrCombobox,
|
|
|
|
|
isSingleMode,
|
2019-01-04 23:00:09 +08:00
|
|
|
|
preventDefaultEvent,
|
|
|
|
|
saveRef,
|
|
|
|
|
splitBySeparators,
|
2018-02-07 18:56:58 +08:00
|
|
|
|
toArray,
|
2019-01-04 23:00:09 +08:00
|
|
|
|
toTitle,
|
2018-02-07 18:56:58 +08:00
|
|
|
|
UNSELECTABLE_ATTRIBUTE,
|
|
|
|
|
UNSELECTABLE_STYLE,
|
|
|
|
|
validateOptionValue,
|
2019-01-12 11:33:27 +08:00
|
|
|
|
} from './util';
|
|
|
|
|
import { SelectPropTypes } from './PropTypes';
|
2019-08-14 18:41:49 +08:00
|
|
|
|
import contains from '../_util/Dom/contains';
|
2019-09-28 18:00:24 +08:00
|
|
|
|
import { isIE, isEdge } from '../_util/env';
|
2018-02-07 18:56:58 +08:00
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
Vue.use(ref, { name: 'ant-ref' });
|
|
|
|
|
const SELECT_EMPTY_VALUE_KEY = 'RC_SELECT_EMPTY_VALUE_KEY';
|
2018-11-09 14:23:19 +08:00
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const noop = () => null;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
function chaining(...fns) {
|
|
|
|
|
return function(...args) {
|
|
|
|
|
// eslint-disable-line
|
2018-02-07 18:56:58 +08:00
|
|
|
|
// eslint-disable-line
|
|
|
|
|
for (let i = 0; i < fns.length; i++) {
|
|
|
|
|
if (fns[i] && typeof fns[i] === 'function') {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
fns[i].apply(chaining, args);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
};
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2018-09-05 21:28:54 +08:00
|
|
|
|
const Select = {
|
2018-05-06 20:37:39 +08:00
|
|
|
|
inheritAttrs: false,
|
2019-01-04 23:00:09 +08:00
|
|
|
|
Option,
|
|
|
|
|
OptGroup,
|
2018-02-07 18:56:58 +08:00
|
|
|
|
name: 'Select',
|
|
|
|
|
mixins: [BaseMixin],
|
|
|
|
|
props: {
|
|
|
|
|
...SelectPropTypes,
|
|
|
|
|
prefixCls: SelectPropTypes.prefixCls.def('rc-select'),
|
|
|
|
|
defaultOpen: PropTypes.bool.def(false),
|
|
|
|
|
labelInValue: SelectPropTypes.labelInValue.def(false),
|
|
|
|
|
defaultActiveFirstOption: SelectPropTypes.defaultActiveFirstOption.def(true),
|
|
|
|
|
showSearch: SelectPropTypes.showSearch.def(true),
|
|
|
|
|
allowClear: SelectPropTypes.allowClear.def(false),
|
|
|
|
|
placeholder: SelectPropTypes.placeholder.def(''),
|
2019-03-04 15:45:21 +08:00
|
|
|
|
// showArrow: SelectPropTypes.showArrow.def(true),
|
2018-02-07 18:56:58 +08:00
|
|
|
|
dropdownMatchSelectWidth: PropTypes.bool.def(true),
|
|
|
|
|
dropdownStyle: SelectPropTypes.dropdownStyle.def({}),
|
|
|
|
|
dropdownMenuStyle: PropTypes.object.def({}),
|
|
|
|
|
optionFilterProp: SelectPropTypes.optionFilterProp.def('value'),
|
|
|
|
|
optionLabelProp: SelectPropTypes.optionLabelProp.def('value'),
|
2018-02-11 18:04:31 +08:00
|
|
|
|
notFoundContent: PropTypes.any.def('Not Found'),
|
2018-02-07 18:56:58 +08:00
|
|
|
|
backfill: PropTypes.bool.def(false),
|
|
|
|
|
showAction: SelectPropTypes.showAction.def(['click']),
|
2018-02-07 23:03:47 +08:00
|
|
|
|
combobox: PropTypes.bool.def(false),
|
2018-03-14 10:36:52 +08:00
|
|
|
|
tokenSeparators: PropTypes.arrayOf(PropTypes.string).def([]),
|
2018-09-05 21:28:54 +08:00
|
|
|
|
autoClearSearchValue: PropTypes.bool.def(true),
|
2019-01-04 23:00:09 +08:00
|
|
|
|
tabIndex: PropTypes.any.def(0),
|
|
|
|
|
dropdownRender: PropTypes.func.def(menu => menu),
|
2018-02-07 18:56:58 +08:00
|
|
|
|
// onChange: noop,
|
|
|
|
|
// onFocus: noop,
|
|
|
|
|
// onBlur: noop,
|
|
|
|
|
// onSelect: noop,
|
|
|
|
|
// onSearch: noop,
|
|
|
|
|
// onDeselect: noop,
|
|
|
|
|
// onInputKeydown: noop,
|
|
|
|
|
},
|
2018-02-25 16:48:19 +08:00
|
|
|
|
model: {
|
|
|
|
|
prop: 'value',
|
|
|
|
|
event: 'change',
|
|
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
|
created() {
|
|
|
|
|
this.saveInputRef = saveRef(this, 'inputRef');
|
|
|
|
|
this.saveInputMirrorRef = saveRef(this, 'inputMirrorRef');
|
|
|
|
|
this.saveTopCtrlRef = saveRef(this, 'topCtrlRef');
|
|
|
|
|
this.saveSelectTriggerRef = saveRef(this, 'selectTriggerRef');
|
|
|
|
|
this.saveRootRef = saveRef(this, 'rootRef');
|
|
|
|
|
this.saveSelectionRef = saveRef(this, 'selectionRef');
|
|
|
|
|
this._focused = false;
|
|
|
|
|
this._mouseDown = false;
|
|
|
|
|
this._options = [];
|
2019-03-04 15:45:21 +08:00
|
|
|
|
this._empty = false;
|
2018-09-05 21:28:54 +08:00
|
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
|
data() {
|
|
|
|
|
const props = getOptionProps(this);
|
|
|
|
|
const optionsInfo = this.getOptionsInfoFromProps(props);
|
2018-09-05 21:28:54 +08:00
|
|
|
|
warning(
|
|
|
|
|
this.__propsSymbol__,
|
2019-01-12 11:33:27 +08:00
|
|
|
|
'Replace slots.default with props.children and pass props.__propsSymbol__',
|
|
|
|
|
);
|
2018-12-25 12:00:39 +08:00
|
|
|
|
const state = {
|
2018-09-05 21:28:54 +08:00
|
|
|
|
_value: this.getValueFromProps(props, true), // true: use default value
|
2019-01-12 11:33:27 +08:00
|
|
|
|
_inputValue: props.combobox
|
|
|
|
|
? this.getInputValueForCombobox(
|
|
|
|
|
props,
|
|
|
|
|
optionsInfo,
|
|
|
|
|
true, // use default value
|
|
|
|
|
)
|
|
|
|
|
: '',
|
2018-09-05 21:28:54 +08:00
|
|
|
|
_open: props.defaultOpen,
|
|
|
|
|
_optionsInfo: optionsInfo,
|
2019-01-04 23:00:09 +08:00
|
|
|
|
_backfillValue: '',
|
2018-09-05 21:28:54 +08:00
|
|
|
|
// a flag for aviod redundant getOptionsInfoFromProps call
|
|
|
|
|
_skipBuildOptionsInfo: true,
|
2019-01-08 23:03:13 +08:00
|
|
|
|
_ariaId: generateUUID(),
|
2019-01-12 11:33:27 +08:00
|
|
|
|
};
|
2018-12-25 12:00:39 +08:00
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
...this.getDerivedStateFromProps(props, state),
|
2019-01-12 11:33:27 +08:00
|
|
|
|
};
|
2018-09-05 21:28:54 +08:00
|
|
|
|
},
|
2018-02-22 22:09:03 +08:00
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
mounted() {
|
2018-02-07 18:56:58 +08:00
|
|
|
|
this.$nextTick(() => {
|
2019-03-04 15:45:21 +08:00
|
|
|
|
// when defaultOpen is true, we should auto focus search input
|
|
|
|
|
// https://github.com/ant-design/ant-design/issues/14254
|
2019-05-28 11:37:38 +08:00
|
|
|
|
if (this.autoFocus || this._open) {
|
2019-03-04 15:45:21 +08:00
|
|
|
|
this.focus();
|
|
|
|
|
}
|
2019-06-30 21:56:24 +08:00
|
|
|
|
// this.setState({
|
|
|
|
|
// _ariaId: generateUUID(),
|
|
|
|
|
// });
|
2019-01-12 11:33:27 +08:00
|
|
|
|
});
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
2018-02-07 23:03:47 +08:00
|
|
|
|
watch: {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
__propsSymbol__() {
|
|
|
|
|
Object.assign(this.$data, this.getDerivedStateFromProps(getOptionProps(this), this.$data));
|
2018-02-07 23:03:47 +08:00
|
|
|
|
},
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
|
updated() {
|
2018-02-07 18:56:58 +08:00
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
if (isMultipleOrTags(this.$props)) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const inputNode = this.getInputDOMNode();
|
|
|
|
|
const mirrorNode = this.getInputMirrorDOMNode();
|
2019-08-20 10:39:05 +08:00
|
|
|
|
if (inputNode && inputNode.value && mirrorNode) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
inputNode.style.width = '';
|
|
|
|
|
inputNode.style.width = `${mirrorNode.clientWidth + 10}px`;
|
2019-01-04 23:00:09 +08:00
|
|
|
|
} else if (inputNode) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
inputNode.style.width = '';
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.forcePopupAlign();
|
|
|
|
|
});
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
|
beforeDestroy() {
|
|
|
|
|
this.clearFocusTime();
|
|
|
|
|
this.clearBlurTime();
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (this.dropdownContainer) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
document.body.removeChild(this.dropdownContainer);
|
|
|
|
|
this.dropdownContainer = null;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
getDerivedStateFromProps(nextProps, prevState) {
|
2018-09-05 21:28:54 +08:00
|
|
|
|
const optionsInfo = prevState._skipBuildOptionsInfo
|
|
|
|
|
? prevState._optionsInfo
|
2019-01-12 11:33:27 +08:00
|
|
|
|
: this.getOptionsInfoFromProps(nextProps, prevState);
|
2018-02-23 11:28:43 +08:00
|
|
|
|
|
2018-09-05 21:28:54 +08:00
|
|
|
|
const newState = {
|
|
|
|
|
_optionsInfo: optionsInfo,
|
|
|
|
|
_skipBuildOptionsInfo: false,
|
2019-01-12 11:33:27 +08:00
|
|
|
|
};
|
2018-09-05 21:28:54 +08:00
|
|
|
|
|
|
|
|
|
if ('open' in nextProps) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
newState._open = nextProps.open;
|
2018-09-05 21:28:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ('value' in nextProps) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const value = this.getValueFromProps(nextProps);
|
|
|
|
|
newState._value = value;
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (nextProps.combobox) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
newState._inputValue = this.getInputValueForCombobox(nextProps, optionsInfo);
|
2018-02-22 17:19:47 +08:00
|
|
|
|
}
|
2018-09-05 21:28:54 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return newState;
|
2018-02-22 15:09:03 +08:00
|
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
|
getOptionsFromChildren(children = [], options = []) {
|
2019-01-04 23:00:09 +08:00
|
|
|
|
children.forEach(child => {
|
|
|
|
|
if (!child.data || child.data.slot !== undefined) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return;
|
2019-01-04 23:00:09 +08:00
|
|
|
|
}
|
|
|
|
|
if (getSlotOptions(child).isSelectOptGroup) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.getOptionsFromChildren(child.componentOptions.children, options);
|
2019-01-04 23:00:09 +08:00
|
|
|
|
} else {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
options.push(child);
|
2019-01-04 23:00:09 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
});
|
|
|
|
|
return options;
|
2019-01-04 23:00:09 +08:00
|
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
|
getInputValueForCombobox(props, optionsInfo, useDefaultValue) {
|
|
|
|
|
let value = [];
|
2019-01-04 23:00:09 +08:00
|
|
|
|
if ('value' in props && !useDefaultValue) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
value = toArray(props.value);
|
2019-01-04 23:00:09 +08:00
|
|
|
|
}
|
|
|
|
|
if ('defaultValue' in props && useDefaultValue) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
value = toArray(props.defaultValue);
|
2019-01-04 23:00:09 +08:00
|
|
|
|
}
|
|
|
|
|
if (value.length) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
value = value[0];
|
2019-01-04 23:00:09 +08:00
|
|
|
|
} else {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return '';
|
2019-01-04 23:00:09 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
let label = value;
|
2019-01-04 23:00:09 +08:00
|
|
|
|
if (props.labelInValue) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
label = value.label;
|
2019-01-04 23:00:09 +08:00
|
|
|
|
} else if (optionsInfo[getMapKey(value)]) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
label = optionsInfo[getMapKey(value)].label;
|
2019-01-04 23:00:09 +08:00
|
|
|
|
}
|
|
|
|
|
if (label === undefined) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
label = '';
|
2019-01-04 23:00:09 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return label;
|
2019-01-04 23:00:09 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
getLabelFromOption(props, option) {
|
|
|
|
|
return getPropValue(option, props.optionLabelProp);
|
2019-01-04 23:00:09 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
getOptionsInfoFromProps(props, preState) {
|
|
|
|
|
const options = this.getOptionsFromChildren(this.$props.children);
|
|
|
|
|
const optionsInfo = {};
|
|
|
|
|
options.forEach(option => {
|
|
|
|
|
const singleValue = getValuePropValue(option);
|
2019-01-04 23:00:09 +08:00
|
|
|
|
optionsInfo[getMapKey(singleValue)] = {
|
|
|
|
|
option,
|
|
|
|
|
value: singleValue,
|
|
|
|
|
label: this.getLabelFromOption(props, option),
|
|
|
|
|
title: getValue(option, 'title'),
|
2019-03-04 15:45:21 +08:00
|
|
|
|
disabled: getValue(option, 'disabled'),
|
2019-01-12 11:33:27 +08:00
|
|
|
|
};
|
|
|
|
|
});
|
2019-01-04 23:00:09 +08:00
|
|
|
|
if (preState) {
|
|
|
|
|
// keep option info in pre state value.
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const oldOptionsInfo = preState._optionsInfo;
|
|
|
|
|
const value = preState._value;
|
2019-01-04 23:00:09 +08:00
|
|
|
|
if (value) {
|
|
|
|
|
value.forEach(v => {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const key = getMapKey(v);
|
2019-01-04 23:00:09 +08:00
|
|
|
|
if (!optionsInfo[key] && oldOptionsInfo[key] !== undefined) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
optionsInfo[key] = oldOptionsInfo[key];
|
2019-01-04 23:00:09 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
});
|
2019-01-04 23:00:09 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return optionsInfo;
|
2019-01-04 23:00:09 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
getValueFromProps(props, useDefaultValue) {
|
|
|
|
|
let value = [];
|
2019-01-04 23:00:09 +08:00
|
|
|
|
if ('value' in props && !useDefaultValue) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
value = toArray(props.value);
|
2019-01-04 23:00:09 +08:00
|
|
|
|
}
|
|
|
|
|
if ('defaultValue' in props && useDefaultValue) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
value = toArray(props.defaultValue);
|
2019-01-04 23:00:09 +08:00
|
|
|
|
}
|
|
|
|
|
if (props.labelInValue) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
value = value.map(v => {
|
|
|
|
|
return v.key;
|
|
|
|
|
});
|
2019-01-04 23:00:09 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return value;
|
2019-01-04 23:00:09 +08:00
|
|
|
|
},
|
2018-11-09 14:23:19 +08:00
|
|
|
|
|
2019-11-15 18:21:50 +08:00
|
|
|
|
onInputChange(e) {
|
|
|
|
|
const { value: val, composing } = e.target;
|
|
|
|
|
const { _inputValue = '' } = this;
|
|
|
|
|
if (composing || _inputValue === val) return;
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const { tokenSeparators } = this.$props;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (
|
|
|
|
|
isMultipleOrTags(this.$props) &&
|
2019-01-12 11:33:27 +08:00
|
|
|
|
tokenSeparators.length &&
|
|
|
|
|
includesSeparators(val, tokenSeparators)
|
2018-02-07 18:56:58 +08:00
|
|
|
|
) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const nextValue = this.getValueByInput(val);
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (nextValue !== undefined) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.fireChange(nextValue);
|
2018-09-05 21:28:54 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.setOpenState(false, true);
|
|
|
|
|
this.setInputValue('', false);
|
|
|
|
|
return;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.setInputValue(val);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
this.setState({
|
2018-09-05 21:28:54 +08:00
|
|
|
|
_open: true,
|
2019-01-12 11:33:27 +08:00
|
|
|
|
});
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (isCombobox(this.$props)) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.fireChange([val]);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
onDropdownVisibleChange(open) {
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (open && !this._focused) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.clearBlurTime();
|
|
|
|
|
this.timeoutFocus();
|
|
|
|
|
this._focused = true;
|
|
|
|
|
this.updateFocusClassName();
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.setOpenState(open);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// combobox ignore
|
2019-01-12 11:33:27 +08:00
|
|
|
|
onKeyDown(event) {
|
|
|
|
|
const { _open: open } = this.$data;
|
|
|
|
|
const { disabled } = this.$props;
|
2018-11-09 14:23:19 +08:00
|
|
|
|
if (disabled) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const keyCode = event.keyCode;
|
2018-11-09 14:23:19 +08:00
|
|
|
|
if (open && !this.getInputDOMNode()) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.onInputKeydown(event);
|
|
|
|
|
} else if (keyCode === KeyCode.ENTER || keyCode === KeyCode.DOWN) {
|
2019-08-30 18:48:51 +08:00
|
|
|
|
// vue state是同步更新,onKeyDown在onMenuSelect后会再次调用,单选时不在调用setOpenState
|
|
|
|
|
// https://github.com/vueComponent/ant-design-vue/issues/1142
|
|
|
|
|
if (keyCode === KeyCode.ENTER && !isMultipleOrTags(this.$props)) {
|
|
|
|
|
this.maybeFocus(true);
|
|
|
|
|
} else if (!open) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.setOpenState(true);
|
2018-09-05 21:28:54 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
event.preventDefault();
|
2018-11-09 14:23:19 +08:00
|
|
|
|
} else if (keyCode === KeyCode.SPACE) {
|
|
|
|
|
// Not block space if popup is shown
|
|
|
|
|
if (!open) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.setOpenState(true);
|
|
|
|
|
event.preventDefault();
|
2018-11-09 14:23:19 +08:00
|
|
|
|
}
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
onInputKeydown(event) {
|
|
|
|
|
const props = this.$props;
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (props.disabled) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const state = this.$data;
|
2019-03-04 15:45:21 +08:00
|
|
|
|
const isRealOpen = this.getRealOpenState(state);
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const keyCode = event.keyCode;
|
|
|
|
|
if (isMultipleOrTags(props) && !event.target.value && keyCode === KeyCode.BACKSPACE) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
const { _value: value } = state;
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (value.length) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.removeSelected(value[value.length - 1]);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
if (keyCode === KeyCode.DOWN) {
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (!state._open) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.openIfHasChildren();
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
return;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2018-09-05 21:28:54 +08:00
|
|
|
|
} else if (keyCode === KeyCode.ENTER && state._open) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
// Aviod trigger form submit when select item
|
|
|
|
|
// https://github.com/ant-design/ant-design/issues/10861
|
2019-03-04 15:45:21 +08:00
|
|
|
|
// https://github.com/ant-design/ant-design/issues/14544
|
|
|
|
|
if (isRealOpen || !props.combobox) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
}
|
2018-02-07 18:56:58 +08:00
|
|
|
|
} else if (keyCode === KeyCode.ESC) {
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (state._open) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.setOpenState(false);
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
event.stopPropagation();
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-03-04 15:45:21 +08:00
|
|
|
|
if (isRealOpen && this.selectTriggerRef) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const menu = this.selectTriggerRef.getInnerMenu();
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (menu && menu.onKeyDown(event, this.handleBackfill)) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
event.preventDefault();
|
|
|
|
|
event.stopPropagation();
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
onMenuSelect({ item }) {
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (!item) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return;
|
2018-09-05 21:28:54 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
let value = this.$data._value;
|
|
|
|
|
const props = this.$props;
|
|
|
|
|
const selectedValue = getValuePropValue(item);
|
|
|
|
|
const lastValue = value[value.length - 1];
|
|
|
|
|
this.fireSelect(selectedValue);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (isMultipleOrTags(props)) {
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (findIndexInValueBySingleValue(value, selectedValue) !== -1) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
value = value.concat([selectedValue]);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
} else {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
if (
|
2019-03-04 15:45:21 +08:00
|
|
|
|
!isCombobox(props) &&
|
2019-01-12 11:33:27 +08:00
|
|
|
|
lastValue !== undefined &&
|
|
|
|
|
lastValue === selectedValue &&
|
|
|
|
|
selectedValue !== this.$data._backfillValue
|
|
|
|
|
) {
|
|
|
|
|
this.setOpenState(false, true);
|
|
|
|
|
return;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
value = [selectedValue];
|
|
|
|
|
this.setOpenState(false, true);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.fireChange(value);
|
|
|
|
|
const inputValue = isCombobox(props) ? getPropValue(item, props.optionLabelProp) : '';
|
2019-01-04 23:00:09 +08:00
|
|
|
|
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (props.autoClearSearchValue) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.setInputValue(inputValue, false);
|
2018-09-05 21:28:54 +08:00
|
|
|
|
}
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
onMenuDeselect({ item, domEvent }) {
|
2018-11-09 14:23:19 +08:00
|
|
|
|
if (domEvent.type === 'keydown' && domEvent.keyCode === KeyCode.ENTER) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.removeSelected(getValuePropValue(item));
|
|
|
|
|
return;
|
2018-11-09 14:23:19 +08:00
|
|
|
|
}
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (domEvent.type === 'click') {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.removeSelected(getValuePropValue(item));
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (this.autoClearSearchValue) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.setInputValue('', false);
|
2018-09-05 21:28:54 +08:00
|
|
|
|
}
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
onArrowClick(e) {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
e.preventDefault();
|
2019-09-27 18:44:11 +08:00
|
|
|
|
this.clearBlurTime();
|
2018-02-09 18:42:19 +08:00
|
|
|
|
if (!this.disabled) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.setOpenState(!this.$data._open, !this.$data._open);
|
2018-02-09 18:42:19 +08:00
|
|
|
|
}
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-02-01 17:23:00 +08:00
|
|
|
|
onPlaceholderClick() {
|
2019-01-04 23:00:09 +08:00
|
|
|
|
if (this.getInputDOMNode() && this.getInputDOMNode()) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.getInputDOMNode().focus();
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
onPopupFocus() {
|
|
|
|
|
// fix ie scrollbar, focus element again
|
|
|
|
|
this.maybeFocus(true, true);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
onClearSelection(event) {
|
|
|
|
|
const props = this.$props;
|
|
|
|
|
const state = this.$data;
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (props.disabled) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const { _inputValue: inputValue, _value: value } = state;
|
|
|
|
|
event.stopPropagation();
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (inputValue || value.length) {
|
|
|
|
|
if (value.length) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.fireChange([]);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.setOpenState(false, true);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (inputValue) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.setInputValue('');
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
onChoiceAnimationLeave() {
|
|
|
|
|
this.forcePopupAlign();
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
2018-09-05 21:28:54 +08:00
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
getOptionInfoBySingleValue(value, optionsInfo) {
|
|
|
|
|
let info;
|
|
|
|
|
optionsInfo = optionsInfo || this.$data._optionsInfo;
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (optionsInfo[getMapKey(value)]) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
info = optionsInfo[getMapKey(value)];
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (info) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return info;
|
2018-09-05 21:28:54 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
let defaultLabel = value;
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (this.$props.labelInValue) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const label = getLabelFromPropsValue(this.$props.value, value);
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (label !== undefined) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
defaultLabel = label;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2018-09-05 21:28:54 +08:00
|
|
|
|
}
|
|
|
|
|
const defaultInfo = {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
option: (
|
|
|
|
|
<Option value={value} key={value}>
|
|
|
|
|
{value}
|
|
|
|
|
</Option>
|
|
|
|
|
),
|
2018-09-05 21:28:54 +08:00
|
|
|
|
value,
|
|
|
|
|
label: defaultLabel,
|
2019-01-12 11:33:27 +08:00
|
|
|
|
};
|
|
|
|
|
return defaultInfo;
|
2018-09-05 21:28:54 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
getOptionBySingleValue(value) {
|
|
|
|
|
const { option } = this.getOptionInfoBySingleValue(value);
|
|
|
|
|
return option;
|
2018-09-05 21:28:54 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
getOptionsBySingleValue(values) {
|
2018-09-05 21:28:54 +08:00
|
|
|
|
return values.map(value => {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return this.getOptionBySingleValue(value);
|
|
|
|
|
});
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
2018-11-09 14:23:19 +08:00
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
getValueByLabel(label) {
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (label === undefined) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return null;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
let value = null;
|
2018-09-05 21:28:54 +08:00
|
|
|
|
Object.keys(this.$data._optionsInfo).forEach(key => {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const info = this.$data._optionsInfo[key];
|
2019-03-04 15:45:21 +08:00
|
|
|
|
const { disabled } = info;
|
|
|
|
|
if (disabled) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const oldLable = toArray(info.label);
|
2019-01-04 23:00:09 +08:00
|
|
|
|
if (oldLable && oldLable.join('') === label) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
value = info.value;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
});
|
|
|
|
|
return value;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
2018-11-09 14:23:19 +08:00
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
getVLBySingleValue(value) {
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (this.$props.labelInValue) {
|
|
|
|
|
return {
|
|
|
|
|
key: value,
|
|
|
|
|
label: this.getLabelBySingleValue(value),
|
2019-01-12 11:33:27 +08:00
|
|
|
|
};
|
2018-02-24 20:54:55 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return value;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
getVLForOnChange(vlsS) {
|
|
|
|
|
let vls = vlsS;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (vls !== undefined) {
|
|
|
|
|
if (!this.labelInValue) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
vls = vls.map(v => v);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
} else {
|
2018-09-05 21:28:54 +08:00
|
|
|
|
vls = vls.map(vl => ({
|
|
|
|
|
key: vl,
|
|
|
|
|
label: this.getLabelBySingleValue(vl),
|
2019-01-12 11:33:27 +08:00
|
|
|
|
}));
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return isMultipleOrTags(this.$props) ? vls : vls[0];
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return vls;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
getLabelBySingleValue(value, optionsInfo) {
|
|
|
|
|
const { label } = this.getOptionInfoBySingleValue(value, optionsInfo);
|
|
|
|
|
return label;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
getDropdownContainer() {
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (!this.dropdownContainer) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.dropdownContainer = document.createElement('div');
|
|
|
|
|
document.body.appendChild(this.dropdownContainer);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return this.dropdownContainer;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
getPlaceholderElement() {
|
|
|
|
|
const { $props: props, $data: state } = this;
|
|
|
|
|
let hidden = false;
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (state._inputValue) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
hidden = true;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const value = state._value;
|
2019-01-04 23:00:09 +08:00
|
|
|
|
if (value.length) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
hidden = true;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-04 23:00:09 +08:00
|
|
|
|
if (isCombobox(props) && value.length === 1 && (state._value && !state._value[0])) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
hidden = false;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const placeholder = props.placeholder;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (placeholder) {
|
2018-02-07 23:03:47 +08:00
|
|
|
|
const p = {
|
|
|
|
|
on: {
|
|
|
|
|
mousedown: preventDefaultEvent,
|
|
|
|
|
click: this.onPlaceholderClick,
|
|
|
|
|
},
|
|
|
|
|
attrs: UNSELECTABLE_ATTRIBUTE,
|
|
|
|
|
style: {
|
|
|
|
|
display: hidden ? 'none' : 'block',
|
|
|
|
|
...UNSELECTABLE_STYLE,
|
|
|
|
|
},
|
2018-09-05 21:28:54 +08:00
|
|
|
|
class: `${props.prefixCls}-selection__placeholder`,
|
2019-01-12 11:33:27 +08:00
|
|
|
|
};
|
|
|
|
|
return <div {...p}>{placeholder}</div>;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return null;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
|
inputClick(e) {
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (this.$data._open) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.clearBlurTime();
|
|
|
|
|
e.stopPropagation();
|
2018-02-26 22:19:48 +08:00
|
|
|
|
} else {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this._focused = false;
|
2018-02-08 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2019-07-30 19:51:49 +08:00
|
|
|
|
inputBlur(e) {
|
2019-08-14 18:41:49 +08:00
|
|
|
|
const target = e.relatedTarget || document.activeElement;
|
2019-09-28 18:00:24 +08:00
|
|
|
|
|
|
|
|
|
// https://github.com/vueComponent/ant-design-vue/issues/999
|
|
|
|
|
// https://github.com/vueComponent/ant-design-vue/issues/1223
|
2019-07-30 19:51:49 +08:00
|
|
|
|
if (
|
2019-09-28 18:00:24 +08:00
|
|
|
|
(isIE || isEdge) &&
|
|
|
|
|
(e.relatedTarget === this.$refs.arrow ||
|
|
|
|
|
(target &&
|
|
|
|
|
this.selectTriggerRef &&
|
|
|
|
|
this.selectTriggerRef.getInnerMenu() &&
|
|
|
|
|
this.selectTriggerRef.getInnerMenu().$el === target) ||
|
|
|
|
|
contains(e.target, target))
|
2019-07-30 19:51:49 +08:00
|
|
|
|
) {
|
|
|
|
|
e.target.focus();
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.clearBlurTime();
|
2018-02-11 18:04:31 +08:00
|
|
|
|
if (this.disabled) {
|
2019-07-30 19:51:49 +08:00
|
|
|
|
e.preventDefault();
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return;
|
2018-02-11 18:04:31 +08:00
|
|
|
|
}
|
2018-02-08 21:58:43 +08:00
|
|
|
|
this.blurTimer = setTimeout(() => {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this._focused = false;
|
|
|
|
|
this.updateFocusClassName();
|
|
|
|
|
const props = this.$props;
|
|
|
|
|
let { _value: value } = this.$data;
|
|
|
|
|
const { _inputValue: inputValue } = this.$data;
|
2018-02-11 18:04:31 +08:00
|
|
|
|
if (
|
|
|
|
|
isSingleMode(props) &&
|
2019-01-12 11:33:27 +08:00
|
|
|
|
props.showSearch &&
|
|
|
|
|
inputValue &&
|
|
|
|
|
props.defaultActiveFirstOption
|
2018-02-11 18:04:31 +08:00
|
|
|
|
) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const options = this._options || [];
|
2018-02-11 18:04:31 +08:00
|
|
|
|
if (options.length) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const firstOption = findFirstMenuItem(options);
|
2018-02-11 18:04:31 +08:00
|
|
|
|
if (firstOption) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
value = [getValuePropValue(firstOption)];
|
|
|
|
|
this.fireChange(value);
|
2018-02-11 18:04:31 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (isMultipleOrTags(props) && inputValue) {
|
2018-11-09 14:23:19 +08:00
|
|
|
|
if (this._mouseDown) {
|
|
|
|
|
// need update dropmenu when not blur
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.setInputValue('');
|
2018-11-09 14:23:19 +08:00
|
|
|
|
} else {
|
|
|
|
|
// why not use setState?
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.$data._inputValue = '';
|
2019-06-30 21:56:24 +08:00
|
|
|
|
if (this.getInputDOMNode && this.getInputDOMNode()) {
|
|
|
|
|
this.getInputDOMNode().value = '';
|
|
|
|
|
}
|
2018-11-09 14:23:19 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const tmpValue = this.getValueByInput(inputValue);
|
2019-01-04 23:00:09 +08:00
|
|
|
|
if (tmpValue !== undefined) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
value = tmpValue;
|
|
|
|
|
this.fireChange(value);
|
2018-09-05 21:28:54 +08:00
|
|
|
|
}
|
2018-02-08 21:58:43 +08:00
|
|
|
|
}
|
2018-11-09 14:23:19 +08:00
|
|
|
|
// if click the rest space of Select in multiple mode
|
|
|
|
|
if (isMultipleOrTags(props) && this._mouseDown) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.maybeFocus(true, true);
|
|
|
|
|
this._mouseDown = false;
|
|
|
|
|
return;
|
2018-11-09 14:23:19 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.setOpenState(false);
|
|
|
|
|
this.$emit('blur', this.getVLForOnChange(value));
|
2019-09-27 18:44:11 +08:00
|
|
|
|
}, 200);
|
2018-02-08 18:56:58 +08:00
|
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
|
inputFocus(e) {
|
2018-11-09 14:23:19 +08:00
|
|
|
|
if (this.$props.disabled) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
e.preventDefault();
|
|
|
|
|
return;
|
2018-11-09 14:23:19 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.clearBlurTime();
|
|
|
|
|
if (!isMultipleOrTagsOrCombobox(this.$props) && e.target === this.getInputDOMNode()) {
|
|
|
|
|
return;
|
2018-11-09 14:23:19 +08:00
|
|
|
|
}
|
|
|
|
|
if (this._focused) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return;
|
2018-11-09 14:23:19 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this._focused = true;
|
|
|
|
|
this.updateFocusClassName();
|
2018-11-09 14:23:19 +08:00
|
|
|
|
// only effect multiple or tag mode
|
|
|
|
|
if (!isMultipleOrTags(this.$props) || !this._mouseDown) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.timeoutFocus();
|
2018-11-09 14:23:19 +08:00
|
|
|
|
}
|
2018-02-09 18:42:19 +08:00
|
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
|
_getInputElement() {
|
|
|
|
|
const props = this.$props;
|
|
|
|
|
const { _inputValue: inputValue } = this.$data;
|
|
|
|
|
const attrs = getAttrs(this);
|
2019-11-14 19:19:24 +08:00
|
|
|
|
const defaultInput = (
|
|
|
|
|
<input
|
|
|
|
|
{...{
|
|
|
|
|
directives: [
|
|
|
|
|
{
|
|
|
|
|
name: 'ant-input',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}}
|
|
|
|
|
id={attrs.id}
|
|
|
|
|
autoComplete="off"
|
|
|
|
|
/>
|
|
|
|
|
);
|
2019-01-04 23:00:09 +08:00
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const inputElement = props.getInputElement ? props.getInputElement() : defaultInput;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
const inputCls = classnames(getClass(inputElement), {
|
|
|
|
|
[`${props.prefixCls}-search__field`]: true,
|
2019-01-12 11:33:27 +08:00
|
|
|
|
});
|
|
|
|
|
const inputEvents = getEvents(inputElement);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
// https://github.com/ant-design/ant-design/issues/4992#issuecomment-281542159
|
|
|
|
|
// Add space to the end of the inputValue as the width measurement tolerance
|
2019-01-12 11:33:27 +08:00
|
|
|
|
inputElement.data = inputElement.data || {};
|
2018-02-07 18:56:58 +08:00
|
|
|
|
return (
|
2018-03-01 12:34:31 +08:00
|
|
|
|
<div class={`${props.prefixCls}-search__field__wrap`} onClick={this.inputClick}>
|
2018-02-07 18:56:58 +08:00
|
|
|
|
{cloneElement(inputElement, {
|
2018-02-28 19:07:04 +08:00
|
|
|
|
props: {
|
|
|
|
|
disabled: props.disabled,
|
2018-09-05 21:28:54 +08:00
|
|
|
|
value: inputValue,
|
2018-02-28 19:07:04 +08:00
|
|
|
|
},
|
2018-02-08 18:56:58 +08:00
|
|
|
|
attrs: {
|
2018-02-09 18:42:19 +08:00
|
|
|
|
...(inputElement.data.attrs || {}),
|
2018-02-07 18:56:58 +08:00
|
|
|
|
disabled: props.disabled,
|
2018-09-05 21:28:54 +08:00
|
|
|
|
value: inputValue,
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
2018-02-09 18:42:19 +08:00
|
|
|
|
domProps: {
|
2018-09-05 21:28:54 +08:00
|
|
|
|
value: inputValue,
|
2018-02-09 18:42:19 +08:00
|
|
|
|
},
|
2018-02-07 18:56:58 +08:00
|
|
|
|
class: inputCls,
|
2019-01-12 11:33:27 +08:00
|
|
|
|
directives: [
|
|
|
|
|
{
|
|
|
|
|
name: 'ant-ref',
|
|
|
|
|
value: this.saveInputRef,
|
|
|
|
|
},
|
|
|
|
|
],
|
2018-02-07 18:56:58 +08:00
|
|
|
|
on: {
|
2018-02-07 23:03:47 +08:00
|
|
|
|
input: this.onInputChange,
|
|
|
|
|
keydown: chaining(
|
2018-02-07 18:56:58 +08:00
|
|
|
|
this.onInputKeydown,
|
2018-02-28 23:30:40 +08:00
|
|
|
|
inputEvents.keydown,
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.$listeners.inputKeydown,
|
2018-02-08 18:56:58 +08:00
|
|
|
|
),
|
2019-01-12 11:33:27 +08:00
|
|
|
|
focus: chaining(this.inputFocus, inputEvents.focus),
|
|
|
|
|
blur: chaining(this.inputBlur, inputEvents.blur),
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
|
|
|
|
})}
|
|
|
|
|
<span
|
2019-01-12 11:33:27 +08:00
|
|
|
|
{...{
|
|
|
|
|
directives: [
|
|
|
|
|
{
|
|
|
|
|
name: 'ant-ref',
|
|
|
|
|
value: this.saveInputMirrorRef,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}}
|
2018-09-05 21:28:54 +08:00
|
|
|
|
// ref='inputMirrorRef'
|
2018-02-07 18:56:58 +08:00
|
|
|
|
class={`${props.prefixCls}-search__field__mirror`}
|
|
|
|
|
>
|
2018-09-05 21:28:54 +08:00
|
|
|
|
{inputValue}
|
2018-02-07 18:56:58 +08:00
|
|
|
|
</span>
|
|
|
|
|
</div>
|
2019-01-12 11:33:27 +08:00
|
|
|
|
);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
getInputDOMNode() {
|
2018-09-05 21:28:54 +08:00
|
|
|
|
return this.topCtrlRef
|
|
|
|
|
? this.topCtrlRef.querySelector('input,textarea,div[contentEditable]')
|
2019-01-12 11:33:27 +08:00
|
|
|
|
: this.inputRef;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
getInputMirrorDOMNode() {
|
|
|
|
|
return this.inputMirrorRef;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
getPopupDOMNode() {
|
2019-01-04 23:00:09 +08:00
|
|
|
|
if (this.selectTriggerRef) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return this.selectTriggerRef.getPopupDOMNode();
|
2019-01-04 23:00:09 +08:00
|
|
|
|
}
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
getPopupMenuComponent() {
|
2019-01-04 23:00:09 +08:00
|
|
|
|
if (this.selectTriggerRef) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return this.selectTriggerRef.getInnerMenu();
|
2019-01-04 23:00:09 +08:00
|
|
|
|
}
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
setOpenState(open, needFocus) {
|
|
|
|
|
const { $props: props, $data: state } = this;
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (state._open === open) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.maybeFocus(open, !!needFocus);
|
|
|
|
|
return;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.__emit('dropdownVisibleChange', open);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
const nextState = {
|
2018-09-05 21:28:54 +08:00
|
|
|
|
_open: open,
|
2019-01-04 23:00:09 +08:00
|
|
|
|
_backfillValue: '',
|
2019-01-12 11:33:27 +08:00
|
|
|
|
};
|
2018-02-07 18:56:58 +08:00
|
|
|
|
// clear search input value when open is false in singleMode.
|
|
|
|
|
if (!open && isSingleMode(props) && props.showSearch) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.setInputValue('', false);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
if (!open) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.maybeFocus(open, !!needFocus);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
this.setState(nextState, () => {
|
|
|
|
|
if (open) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.maybeFocus(open, !!needFocus);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
});
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
setInputValue(inputValue, fireSearch = true) {
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (inputValue !== this.$data._inputValue) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.setState(
|
|
|
|
|
{
|
|
|
|
|
_inputValue: inputValue,
|
|
|
|
|
},
|
|
|
|
|
this.forcePopupAlign,
|
|
|
|
|
);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (fireSearch) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.$emit('search', inputValue);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
|
getValueByInput(str) {
|
|
|
|
|
const { multiple, tokenSeparators } = this.$props;
|
|
|
|
|
let nextValue = this.$data._value;
|
|
|
|
|
let hasNewValue = false;
|
2019-01-04 23:00:09 +08:00
|
|
|
|
splitBySeparators(str, tokenSeparators).forEach(label => {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const selectedValue = [label];
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (multiple) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const value = this.getValueByLabel(label);
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (value && findIndexInValueBySingleValue(nextValue, value) === -1) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
nextValue = nextValue.concat(value);
|
|
|
|
|
hasNewValue = true;
|
|
|
|
|
this.fireSelect(value);
|
2018-09-05 21:28:54 +08:00
|
|
|
|
}
|
2019-01-04 23:00:09 +08:00
|
|
|
|
} else if (findIndexInValueBySingleValue(nextValue, label) === -1) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
nextValue = nextValue.concat(selectedValue);
|
|
|
|
|
hasNewValue = true;
|
|
|
|
|
this.fireSelect(label);
|
2018-03-14 10:36:52 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
});
|
|
|
|
|
return hasNewValue ? nextValue : undefined;
|
2018-03-14 10:36:52 +08:00
|
|
|
|
},
|
2018-02-07 18:56:58 +08:00
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
getRealOpenState(state) {
|
|
|
|
|
const { open: _open } = this.$props;
|
2018-11-09 14:23:19 +08:00
|
|
|
|
if (typeof _open === 'boolean') {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return _open;
|
2018-11-09 14:23:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
let open = (state || this.$data)._open;
|
|
|
|
|
const options = this._options || [];
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (isMultipleOrTagsOrCombobox(this.$props) || !this.$props.showSearch) {
|
|
|
|
|
if (open && !options.length) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
open = false;
|
2018-09-05 21:28:54 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return open;
|
2018-09-05 21:28:54 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
focus() {
|
2019-01-04 23:00:09 +08:00
|
|
|
|
if (isSingleMode(this.$props) && this.selectionRef) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.selectionRef.focus();
|
2019-01-04 23:00:09 +08:00
|
|
|
|
} else if (this.getInputDOMNode()) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.getInputDOMNode().focus();
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
blur() {
|
2019-01-04 23:00:09 +08:00
|
|
|
|
if (isSingleMode(this.$props) && this.selectionRef) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.selectionRef.blur();
|
2019-01-04 23:00:09 +08:00
|
|
|
|
} else if (this.getInputDOMNode()) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.getInputDOMNode().blur();
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
|
markMouseDown() {
|
|
|
|
|
this._mouseDown = true;
|
2018-11-09 14:23:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
markMouseLeave() {
|
|
|
|
|
this._mouseDown = false;
|
2018-11-09 14:23:19 +08:00
|
|
|
|
},
|
2018-02-07 18:56:58 +08:00
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
handleBackfill(item) {
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (!this.backfill || !(isSingleMode(this.$props) || isCombobox(this.$props))) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const key = getValuePropValue(item);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
|
|
|
|
|
if (isCombobox(this.$props)) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.setInputValue(key, false);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.setState({
|
2018-09-05 21:28:54 +08:00
|
|
|
|
_value: [key],
|
|
|
|
|
_backfillValue: key,
|
2019-01-12 11:33:27 +08:00
|
|
|
|
});
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
_filterOption(input, child, defaultFilter = defaultFilterFn) {
|
|
|
|
|
const { _value: value, _backfillValue: backfillValue } = this.$data;
|
|
|
|
|
const lastValue = value[value.length - 1];
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (!input || (lastValue && lastValue === backfillValue)) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return true;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
let filterFn = this.$props.filterOption;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (hasProp(this, 'filterOption')) {
|
2019-01-04 23:00:09 +08:00
|
|
|
|
if (filterFn === true) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
filterFn = defaultFilter.bind(this);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
} else {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
filterFn = defaultFilter.bind(this);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
if (!filterFn) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return true;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
} else if (typeof filterFn === 'function') {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return filterFn.call(this, input, child);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
} else if (getValue(child, 'disabled')) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return false;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return true;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
timeoutFocus() {
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (this.focusTimer) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.clearFocusTime();
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-04 23:00:09 +08:00
|
|
|
|
this.focusTimer = window.setTimeout(() => {
|
2018-11-09 14:23:19 +08:00
|
|
|
|
// this._focused = true
|
|
|
|
|
// this.updateFocusClassName()
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.$emit('focus');
|
|
|
|
|
}, 10);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
clearFocusTime() {
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (this.focusTimer) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
clearTimeout(this.focusTimer);
|
|
|
|
|
this.focusTimer = null;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
clearBlurTime() {
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (this.blurTimer) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
clearTimeout(this.blurTimer);
|
|
|
|
|
this.blurTimer = null;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
updateFocusClassName() {
|
|
|
|
|
const { rootRef, prefixCls } = this;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
// avoid setState and its side effect
|
|
|
|
|
if (this._focused) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
classes(rootRef).add(`${prefixCls}-focused`);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
} else {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
classes(rootRef).remove(`${prefixCls}-focused`);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
maybeFocus(open, needFocus) {
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (needFocus || open) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const input = this.getInputDOMNode();
|
|
|
|
|
const { activeElement } = document;
|
2018-02-07 23:03:47 +08:00
|
|
|
|
if (input && (open || isMultipleOrTagsOrCombobox(this.$props))) {
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (activeElement !== input) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
input.focus();
|
|
|
|
|
this._focused = true;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-04 23:00:09 +08:00
|
|
|
|
} else if (activeElement !== this.selectionRef && this.selectionRef) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.selectionRef.focus();
|
|
|
|
|
this._focused = true;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
removeSelected(selectedKey, e) {
|
|
|
|
|
const props = this.$props;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (props.disabled || this.isChildDisabled(selectedKey)) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2018-09-05 21:28:54 +08:00
|
|
|
|
// Do not trigger Trigger popup
|
|
|
|
|
if (e && e.stopPropagation) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
e.stopPropagation();
|
2018-09-05 21:28:54 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const oldValue = this.$data._value;
|
2019-01-04 23:00:09 +08:00
|
|
|
|
const value = oldValue.filter(singleValue => {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return singleValue !== selectedKey;
|
|
|
|
|
});
|
|
|
|
|
const canMultiple = isMultipleOrTags(props);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
|
|
|
|
|
if (canMultiple) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
let event = selectedKey;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (props.labelInValue) {
|
|
|
|
|
event = {
|
|
|
|
|
key: selectedKey,
|
2018-09-05 21:28:54 +08:00
|
|
|
|
label: this.getLabelBySingleValue(selectedKey),
|
2019-01-12 11:33:27 +08:00
|
|
|
|
};
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.$emit('deselect', event, this.getOptionBySingleValue(selectedKey));
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.fireChange(value);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
openIfHasChildren() {
|
|
|
|
|
const { $props } = this;
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (($props.children && $props.children.length) || isSingleMode($props)) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.setOpenState(true);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
|
fireSelect(value) {
|
|
|
|
|
this.$emit('select', this.getVLBySingleValue(value), this.getOptionBySingleValue(value));
|
2018-02-12 11:47:57 +08:00
|
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
|
fireChange(value) {
|
2018-02-12 18:10:51 +08:00
|
|
|
|
if (!hasProp(this, 'value')) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.setState(
|
|
|
|
|
{
|
|
|
|
|
_value: value,
|
|
|
|
|
},
|
|
|
|
|
this.forcePopupAlign,
|
|
|
|
|
);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const vls = this.getVLForOnChange(value);
|
|
|
|
|
const options = this.getOptionsBySingleValue(value);
|
|
|
|
|
this._valueOptions = options;
|
|
|
|
|
this.$emit('change', vls, isMultipleOrTags(this.$props) ? options : options[0]);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
isChildDisabled(key) {
|
2018-09-05 21:28:54 +08:00
|
|
|
|
return (this.$props.children || []).some(child => {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const childValue = getValuePropValue(child);
|
|
|
|
|
return childValue === key && getValue(child, 'disabled');
|
|
|
|
|
});
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
|
forcePopupAlign() {
|
2018-11-09 14:23:19 +08:00
|
|
|
|
if (!this.$data._open) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return;
|
2018-11-09 14:23:19 +08:00
|
|
|
|
}
|
2019-01-04 23:00:09 +08:00
|
|
|
|
if (this.selectTriggerRef && this.selectTriggerRef.triggerRef) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.selectTriggerRef.triggerRef.forcePopupAlign();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
renderFilterOptions() {
|
|
|
|
|
const { _inputValue: inputValue } = this.$data;
|
|
|
|
|
const { children, tags, filterOption, notFoundContent } = this.$props;
|
|
|
|
|
const menuItems = [];
|
|
|
|
|
const childrenKeys = [];
|
2019-03-04 15:45:21 +08:00
|
|
|
|
let empty = false;
|
2019-01-12 11:33:27 +08:00
|
|
|
|
let options = this.renderFilterOptionsFromChildren(children, childrenKeys, menuItems);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (tags) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
// tags value must be string
|
|
|
|
|
let value = this.$data._value;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
value = value.filter(singleValue => {
|
|
|
|
|
return (
|
2018-09-05 21:28:54 +08:00
|
|
|
|
childrenKeys.indexOf(singleValue) === -1 &&
|
2019-01-12 11:33:27 +08:00
|
|
|
|
(!inputValue || String(singleValue).indexOf(String(inputValue)) > -1)
|
|
|
|
|
);
|
|
|
|
|
});
|
2019-03-04 15:45:21 +08:00
|
|
|
|
|
|
|
|
|
// sort by length
|
|
|
|
|
value.sort((val1, val2) => {
|
|
|
|
|
return val1.length - val2.length;
|
|
|
|
|
});
|
|
|
|
|
|
2018-02-07 18:56:58 +08:00
|
|
|
|
value.forEach(singleValue => {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const key = singleValue;
|
2019-03-16 09:14:55 +08:00
|
|
|
|
const attrs = {
|
|
|
|
|
...UNSELECTABLE_ATTRIBUTE,
|
|
|
|
|
role: 'option',
|
|
|
|
|
};
|
2018-02-07 18:56:58 +08:00
|
|
|
|
const menuItem = (
|
2019-03-16 09:14:55 +08:00
|
|
|
|
<MenuItem style={UNSELECTABLE_STYLE} {...{ attrs }} value={key} key={key}>
|
2018-02-07 18:56:58 +08:00
|
|
|
|
{key}
|
|
|
|
|
</MenuItem>
|
2019-01-12 11:33:27 +08:00
|
|
|
|
);
|
|
|
|
|
options.push(menuItem);
|
|
|
|
|
menuItems.push(menuItem);
|
|
|
|
|
});
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (inputValue) {
|
|
|
|
|
const notFindInputItem = menuItems.every(option => {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
// this.filterOption return true has two meaning,
|
|
|
|
|
// 1, some one exists after filtering
|
|
|
|
|
// 2, filterOption is set to false
|
|
|
|
|
// condition 2 does not mean the option has same value with inputValue
|
|
|
|
|
const filterFn = () => getValuePropValue(option) === inputValue;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (filterOption !== false) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return !this._filterOption(inputValue, option, filterFn);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return !filterFn();
|
|
|
|
|
});
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (notFindInputItem) {
|
2018-02-07 23:03:47 +08:00
|
|
|
|
const p = {
|
|
|
|
|
attrs: UNSELECTABLE_ATTRIBUTE,
|
|
|
|
|
key: inputValue,
|
|
|
|
|
props: {
|
|
|
|
|
value: inputValue,
|
2018-09-05 21:28:54 +08:00
|
|
|
|
role: 'option',
|
2018-02-07 23:03:47 +08:00
|
|
|
|
},
|
|
|
|
|
style: UNSELECTABLE_STYLE,
|
2019-01-12 11:33:27 +08:00
|
|
|
|
};
|
|
|
|
|
options.unshift(<MenuItem {...p}>{inputValue}</MenuItem>);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!options.length && notFoundContent) {
|
2019-03-04 15:45:21 +08:00
|
|
|
|
empty = true;
|
2018-02-07 23:03:47 +08:00
|
|
|
|
const p = {
|
|
|
|
|
attrs: UNSELECTABLE_ATTRIBUTE,
|
|
|
|
|
key: 'NOT_FOUND',
|
|
|
|
|
props: {
|
|
|
|
|
value: 'NOT_FOUND',
|
|
|
|
|
disabled: true,
|
2018-09-05 21:28:54 +08:00
|
|
|
|
role: 'option',
|
2018-02-07 23:03:47 +08:00
|
|
|
|
},
|
|
|
|
|
style: UNSELECTABLE_STYLE,
|
2019-01-12 11:33:27 +08:00
|
|
|
|
};
|
|
|
|
|
options = [<MenuItem {...p}>{notFoundContent}</MenuItem>];
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-05-28 11:37:38 +08:00
|
|
|
|
return { empty, options };
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
renderFilterOptionsFromChildren(children = [], childrenKeys, menuItems) {
|
|
|
|
|
const sel = [];
|
|
|
|
|
const props = this.$props;
|
|
|
|
|
const { _inputValue: inputValue } = this.$data;
|
|
|
|
|
const tags = props.tags;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
children.forEach(child => {
|
2018-02-24 19:53:21 +08:00
|
|
|
|
if (!child.data || child.data.slot !== undefined) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
if (getSlotOptions(child).isSelectOptGroup) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
let label = getComponentFromProp(child, 'label');
|
|
|
|
|
let key = child.key;
|
2019-01-04 23:00:09 +08:00
|
|
|
|
if (!key && typeof label === 'string') {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
key = label;
|
2019-01-04 23:00:09 +08:00
|
|
|
|
} else if (!label && key) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
label = key;
|
2019-01-04 23:00:09 +08:00
|
|
|
|
}
|
2019-08-07 21:56:30 +08:00
|
|
|
|
let childChildren = getSlots(child).default;
|
|
|
|
|
childChildren = typeof childChildren === 'function' ? childChildren() : childChildren;
|
2019-01-04 23:00:09 +08:00
|
|
|
|
// Match option group label
|
|
|
|
|
if (inputValue && this._filterOption(inputValue, child)) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const innerItems = childChildren.map(subChild => {
|
|
|
|
|
const childValueSub = getValuePropValue(subChild) || subChild.key;
|
|
|
|
|
return (
|
|
|
|
|
<MenuItem key={childValueSub} value={childValueSub} {...subChild.data}>
|
|
|
|
|
{subChild.componentOptions.children}
|
|
|
|
|
</MenuItem>
|
|
|
|
|
);
|
|
|
|
|
});
|
2019-01-04 23:00:09 +08:00
|
|
|
|
|
2018-02-07 18:56:58 +08:00
|
|
|
|
sel.push(
|
2019-01-12 11:33:27 +08:00
|
|
|
|
<MenuItemGroup key={key} title={label} class={getClass(child)}>
|
2018-02-07 18:56:58 +08:00
|
|
|
|
{innerItems}
|
2019-01-04 23:00:09 +08:00
|
|
|
|
</MenuItemGroup>,
|
2019-01-12 11:33:27 +08:00
|
|
|
|
);
|
2019-01-04 23:00:09 +08:00
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
// Not match
|
2019-01-04 23:00:09 +08:00
|
|
|
|
} else {
|
|
|
|
|
const innerItems = this.renderFilterOptionsFromChildren(
|
|
|
|
|
childChildren,
|
|
|
|
|
childrenKeys,
|
|
|
|
|
menuItems,
|
2019-01-12 11:33:27 +08:00
|
|
|
|
);
|
2019-01-04 23:00:09 +08:00
|
|
|
|
if (innerItems.length) {
|
|
|
|
|
sel.push(
|
|
|
|
|
<MenuItemGroup key={key} title={label} {...child.data}>
|
|
|
|
|
{innerItems}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
</MenuItemGroup>,
|
|
|
|
|
);
|
2019-01-04 23:00:09 +08:00
|
|
|
|
}
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-04 23:00:09 +08:00
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
warning(
|
2018-02-07 23:03:47 +08:00
|
|
|
|
getSlotOptions(child).isSelectOption,
|
2018-02-07 18:56:58 +08:00
|
|
|
|
'the children of `Select` should be `Select.Option` or `Select.OptGroup`, ' +
|
2019-01-12 11:33:27 +08:00
|
|
|
|
`instead of \`${getSlotOptions(child).name || getSlotOptions(child)}\`.`,
|
|
|
|
|
);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const childValue = getValuePropValue(child);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
validateOptionValue(childValue, this.$props);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (this._filterOption(inputValue, child)) {
|
2018-02-07 23:03:47 +08:00
|
|
|
|
const p = {
|
2018-09-05 21:28:54 +08:00
|
|
|
|
attrs: {
|
|
|
|
|
...UNSELECTABLE_ATTRIBUTE,
|
|
|
|
|
...getAttrs(child),
|
|
|
|
|
},
|
2018-02-07 23:03:47 +08:00
|
|
|
|
key: childValue,
|
|
|
|
|
props: {
|
|
|
|
|
value: childValue,
|
|
|
|
|
...getPropsData(child),
|
2018-09-05 21:28:54 +08:00
|
|
|
|
role: 'option',
|
2018-02-07 23:03:47 +08:00
|
|
|
|
},
|
|
|
|
|
style: UNSELECTABLE_STYLE,
|
|
|
|
|
on: getEvents(child),
|
2018-02-28 19:07:04 +08:00
|
|
|
|
class: getClass(child),
|
2019-01-12 11:33:27 +08:00
|
|
|
|
};
|
|
|
|
|
const menuItem = <MenuItem {...p}>{child.componentOptions.children}</MenuItem>;
|
|
|
|
|
sel.push(menuItem);
|
|
|
|
|
menuItems.push(menuItem);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (tags) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
childrenKeys.push(childValue);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
});
|
2018-02-07 18:56:58 +08:00
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return sel;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
renderTopControlNode() {
|
|
|
|
|
const { $props: props } = this;
|
|
|
|
|
const { _value: value, _inputValue: inputValue, _open: open } = this.$data;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
const {
|
|
|
|
|
choiceTransitionName,
|
|
|
|
|
prefixCls,
|
|
|
|
|
maxTagTextLength,
|
|
|
|
|
maxTagCount,
|
|
|
|
|
maxTagPlaceholder,
|
|
|
|
|
showSearch,
|
2019-01-12 11:33:27 +08:00
|
|
|
|
} = props;
|
|
|
|
|
const removeIcon = getComponentFromProp(this, 'removeIcon');
|
|
|
|
|
const className = `${prefixCls}-selection__rendered`;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
// search input is inside topControlNode in single, multiple & combobox. 2016/04/13
|
2019-01-12 11:33:27 +08:00
|
|
|
|
let innerNode = null;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (isSingleMode(props)) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
let selectedValue = null;
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (value.length) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
let showSelectedValue = false;
|
|
|
|
|
let opacity = 1;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (!showSearch) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
showSelectedValue = true;
|
2018-11-09 14:23:19 +08:00
|
|
|
|
} else if (open) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
showSelectedValue = !inputValue;
|
2018-11-09 14:23:19 +08:00
|
|
|
|
if (showSelectedValue) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
opacity = 0.4;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2018-11-09 14:23:19 +08:00
|
|
|
|
} else {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
showSelectedValue = true;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const singleValue = value[0];
|
|
|
|
|
const { label, title } = this.getOptionInfoBySingleValue(singleValue);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
selectedValue = (
|
|
|
|
|
<div
|
2019-01-12 11:33:27 +08:00
|
|
|
|
key="value"
|
2018-02-07 18:56:58 +08:00
|
|
|
|
class={`${prefixCls}-selection-selected-value`}
|
2018-09-05 21:28:54 +08:00
|
|
|
|
title={toTitle(title || label)}
|
2018-02-07 18:56:58 +08:00
|
|
|
|
style={{
|
|
|
|
|
display: showSelectedValue ? 'block' : 'none',
|
|
|
|
|
opacity,
|
|
|
|
|
}}
|
|
|
|
|
>
|
2018-09-05 21:28:54 +08:00
|
|
|
|
{label}
|
2018-02-07 18:56:58 +08:00
|
|
|
|
</div>
|
2019-01-12 11:33:27 +08:00
|
|
|
|
);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
if (!showSearch) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
innerNode = [selectedValue];
|
2018-02-07 18:56:58 +08:00
|
|
|
|
} else {
|
|
|
|
|
innerNode = [
|
|
|
|
|
selectedValue,
|
|
|
|
|
<div
|
|
|
|
|
class={`${prefixCls}-search ${prefixCls}-search--inline`}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
key="input"
|
2018-02-07 18:56:58 +08:00
|
|
|
|
style={{
|
2018-09-05 21:28:54 +08:00
|
|
|
|
display: open ? 'block' : 'none',
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{this._getInputElement()}
|
|
|
|
|
</div>,
|
2019-01-12 11:33:27 +08:00
|
|
|
|
];
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
} else {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
let selectedValueNodes = [];
|
|
|
|
|
let limitedCountValue = value;
|
|
|
|
|
let maxTagPlaceholderEl;
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (maxTagCount !== undefined && value.length > maxTagCount) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
limitedCountValue = limitedCountValue.slice(0, maxTagCount);
|
|
|
|
|
const omittedValues = this.getVLForOnChange(value.slice(maxTagCount, value.length));
|
|
|
|
|
let content = `+ ${value.length - maxTagCount} ...`;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (maxTagPlaceholder) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
content =
|
|
|
|
|
typeof maxTagPlaceholder === 'function'
|
|
|
|
|
? maxTagPlaceholder(omittedValues)
|
|
|
|
|
: maxTagPlaceholder;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-03-16 09:14:55 +08:00
|
|
|
|
const attrs = {
|
|
|
|
|
...UNSELECTABLE_ATTRIBUTE,
|
|
|
|
|
role: 'presentation',
|
|
|
|
|
title: toTitle(content),
|
|
|
|
|
};
|
2019-01-12 11:33:27 +08:00
|
|
|
|
maxTagPlaceholderEl = (
|
|
|
|
|
<li
|
|
|
|
|
style={UNSELECTABLE_STYLE}
|
2019-03-16 09:14:55 +08:00
|
|
|
|
{...{ attrs }}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
onMousedown={preventDefaultEvent}
|
|
|
|
|
class={`${prefixCls}-selection__choice ${prefixCls}-selection__choice__disabled`}
|
|
|
|
|
key="maxTagPlaceholder"
|
|
|
|
|
>
|
|
|
|
|
<div class={`${prefixCls}-selection__choice__content`}>{content}</div>
|
|
|
|
|
</li>
|
|
|
|
|
);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
if (isMultipleOrTags(props)) {
|
|
|
|
|
selectedValueNodes = limitedCountValue.map(singleValue => {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const info = this.getOptionInfoBySingleValue(singleValue);
|
|
|
|
|
let content = info.label;
|
|
|
|
|
const title = info.title || content;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (
|
|
|
|
|
maxTagTextLength &&
|
2019-01-12 11:33:27 +08:00
|
|
|
|
typeof content === 'string' &&
|
|
|
|
|
content.length > maxTagTextLength
|
2018-02-07 18:56:58 +08:00
|
|
|
|
) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
content = `${content.slice(0, maxTagTextLength)}...`;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const disabled = this.isChildDisabled(singleValue);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
const choiceClassName = disabled
|
|
|
|
|
? `${prefixCls}-selection__choice ${prefixCls}-selection__choice__disabled`
|
2019-01-12 11:33:27 +08:00
|
|
|
|
: `${prefixCls}-selection__choice`;
|
2019-03-16 09:14:55 +08:00
|
|
|
|
// attrs 放在一起,避免动态title混乱问题,很奇怪的问题 https://github.com/vueComponent/ant-design-vue/issues/588
|
|
|
|
|
const attrs = {
|
|
|
|
|
...UNSELECTABLE_ATTRIBUTE,
|
|
|
|
|
role: 'presentation',
|
|
|
|
|
title: toTitle(title),
|
|
|
|
|
};
|
2018-02-07 18:56:58 +08:00
|
|
|
|
return (
|
|
|
|
|
<li
|
|
|
|
|
style={UNSELECTABLE_STYLE}
|
2019-03-16 09:14:55 +08:00
|
|
|
|
{...{ attrs }}
|
2018-02-07 18:56:58 +08:00
|
|
|
|
onMousedown={preventDefaultEvent}
|
|
|
|
|
class={choiceClassName}
|
2018-11-09 14:23:19 +08:00
|
|
|
|
key={singleValue || SELECT_EMPTY_VALUE_KEY}
|
2018-02-07 18:56:58 +08:00
|
|
|
|
>
|
2019-01-12 11:33:27 +08:00
|
|
|
|
<div class={`${prefixCls}-selection__choice__content`}>{content}</div>
|
2018-02-07 18:56:58 +08:00
|
|
|
|
{disabled ? null : (
|
|
|
|
|
<span
|
2019-01-12 11:33:27 +08:00
|
|
|
|
onClick={event => {
|
|
|
|
|
this.removeSelected(singleValue, event);
|
2018-09-05 21:28:54 +08:00
|
|
|
|
}}
|
2018-11-09 14:23:19 +08:00
|
|
|
|
class={`${prefixCls}-selection__choice__remove`}
|
|
|
|
|
>
|
|
|
|
|
{removeIcon || <i class={`${prefixCls}-selection__choice__remove-icon`}>×</i>}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
</span>
|
|
|
|
|
)}
|
2018-02-07 18:56:58 +08:00
|
|
|
|
</li>
|
2019-01-12 11:33:27 +08:00
|
|
|
|
);
|
|
|
|
|
});
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
if (maxTagPlaceholderEl) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
selectedValueNodes.push(maxTagPlaceholderEl);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
selectedValueNodes.push(
|
2019-01-12 11:33:27 +08:00
|
|
|
|
<li class={`${prefixCls}-search ${prefixCls}-search--inline`} key="__input">
|
2018-02-07 18:56:58 +08:00
|
|
|
|
{this._getInputElement()}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
</li>,
|
|
|
|
|
);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
|
|
|
|
|
if (isMultipleOrTags(props) && choiceTransitionName) {
|
|
|
|
|
const transitionProps = getTransitionProps(choiceTransitionName, {
|
|
|
|
|
tag: 'ul',
|
2018-02-12 18:10:51 +08:00
|
|
|
|
afterLeave: this.onChoiceAnimationLeave,
|
2019-01-12 11:33:27 +08:00
|
|
|
|
});
|
2018-02-07 18:56:58 +08:00
|
|
|
|
innerNode = (
|
2019-01-12 11:33:27 +08:00
|
|
|
|
<transition-group {...transitionProps}>{selectedValueNodes}</transition-group>
|
|
|
|
|
);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
} else {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
innerNode = <ul>{selectedValueNodes}</ul>;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return (
|
2018-09-05 21:28:54 +08:00
|
|
|
|
<div
|
|
|
|
|
class={className}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
{...{
|
|
|
|
|
directives: [
|
|
|
|
|
{
|
|
|
|
|
name: 'ant-ref',
|
|
|
|
|
value: this.saveTopCtrlRef,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}}
|
2018-09-05 21:28:54 +08:00
|
|
|
|
onClick={this.topCtrlContainerClick}
|
|
|
|
|
>
|
2018-02-07 18:56:58 +08:00
|
|
|
|
{this.getPlaceholderElement()}
|
|
|
|
|
{innerNode}
|
|
|
|
|
</div>
|
2019-01-12 11:33:27 +08:00
|
|
|
|
);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
|
renderArrow(multiple) {
|
2019-03-04 15:45:21 +08:00
|
|
|
|
// showArrow : Set to true if not multiple by default but keep set value.
|
|
|
|
|
const { showArrow = !multiple, loading, prefixCls } = this.$props;
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const inputIcon = getComponentFromProp(this, 'inputIcon');
|
2019-05-28 11:37:38 +08:00
|
|
|
|
if (!showArrow && !loading) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return null;
|
2019-01-04 23:00:09 +08:00
|
|
|
|
}
|
|
|
|
|
// if loading have loading icon
|
|
|
|
|
const defaultIcon = loading ? (
|
|
|
|
|
<i class={`${prefixCls}-arrow-loading`} />
|
|
|
|
|
) : (
|
|
|
|
|
<i class={`${prefixCls}-arrow-icon`} />
|
2019-01-12 11:33:27 +08:00
|
|
|
|
);
|
2019-01-04 23:00:09 +08:00
|
|
|
|
return (
|
|
|
|
|
<span
|
2019-01-12 11:33:27 +08:00
|
|
|
|
key="arrow"
|
2019-01-04 23:00:09 +08:00
|
|
|
|
class={`${prefixCls}-arrow`}
|
|
|
|
|
style={UNSELECTABLE_STYLE}
|
|
|
|
|
{...{ attrs: UNSELECTABLE_ATTRIBUTE }}
|
|
|
|
|
onClick={this.onArrowClick}
|
2019-09-27 18:44:11 +08:00
|
|
|
|
ref="arrow"
|
2019-01-04 23:00:09 +08:00
|
|
|
|
>
|
|
|
|
|
{inputIcon || defaultIcon}
|
|
|
|
|
</span>
|
2019-01-12 11:33:27 +08:00
|
|
|
|
);
|
2019-01-04 23:00:09 +08:00
|
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
|
topCtrlContainerClick(e) {
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (this.$data._open && !isSingleMode(this.$props)) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
e.stopPropagation();
|
2018-02-12 14:45:26 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
|
renderClear() {
|
|
|
|
|
const { prefixCls, allowClear } = this.$props;
|
|
|
|
|
const { _value: value, _inputValue: inputValue } = this.$data;
|
|
|
|
|
const clearIcon = getComponentFromProp(this, 'clearIcon');
|
2018-02-07 18:56:58 +08:00
|
|
|
|
const clear = (
|
|
|
|
|
<span
|
2019-01-12 11:33:27 +08:00
|
|
|
|
key="clear"
|
2018-11-09 14:23:19 +08:00
|
|
|
|
class={`${prefixCls}-selection__clear`}
|
2018-02-07 18:56:58 +08:00
|
|
|
|
onMousedown={preventDefaultEvent}
|
|
|
|
|
style={UNSELECTABLE_STYLE}
|
2019-01-05 16:22:25 +08:00
|
|
|
|
{...{ attrs: UNSELECTABLE_ATTRIBUTE }}
|
2018-02-07 18:56:58 +08:00
|
|
|
|
onClick={this.onClearSelection}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
>
|
|
|
|
|
{clearIcon || <i class={`${prefixCls}-selection__clear-icon`}>×</i>}
|
|
|
|
|
</span>
|
|
|
|
|
);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
if (!allowClear) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return null;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
|
|
|
|
if (isCombobox(this.$props)) {
|
|
|
|
|
if (inputValue) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return clear;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return null;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (inputValue || value.length) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return clear;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return null;
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
2018-11-09 14:23:19 +08:00
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
selectionRefClick(e) {
|
2019-07-30 19:51:49 +08:00
|
|
|
|
//e.stopPropagation();
|
2018-02-09 18:42:19 +08:00
|
|
|
|
if (!this.disabled) {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const input = this.getInputDOMNode();
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (this._focused && this.$data._open) {
|
2019-07-30 19:51:49 +08:00
|
|
|
|
// this._focused = false;
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.setOpenState(false, false);
|
|
|
|
|
input && input.blur();
|
2018-02-09 18:42:19 +08:00
|
|
|
|
} else {
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.clearBlurTime();
|
2019-07-30 19:51:49 +08:00
|
|
|
|
//this._focused = true;
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this.setOpenState(true, true);
|
|
|
|
|
input && input.focus();
|
2018-02-09 18:42:19 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2019-07-30 19:51:49 +08:00
|
|
|
|
selectionRefFocus(e) {
|
|
|
|
|
if (this._focused || this.disabled || isMultipleOrTagsOrCombobox(this.$props)) {
|
|
|
|
|
e.preventDefault();
|
2019-01-12 11:33:27 +08:00
|
|
|
|
return;
|
2018-02-11 18:50:23 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
this._focused = true;
|
|
|
|
|
this.updateFocusClassName();
|
|
|
|
|
this.$emit('focus');
|
2018-02-11 18:50:23 +08:00
|
|
|
|
},
|
2019-07-30 19:51:49 +08:00
|
|
|
|
selectionRefBlur(e) {
|
|
|
|
|
if (isMultipleOrTagsOrCombobox(this.$props)) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.inputBlur(e);
|
2018-02-26 18:44:06 +08:00
|
|
|
|
},
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
|
render() {
|
|
|
|
|
const props = this.$props;
|
|
|
|
|
const multiple = isMultipleOrTags(props);
|
2019-03-04 15:45:21 +08:00
|
|
|
|
// Default set showArrow to true if not set (not set directly in defaultProps to handle multiple case)
|
|
|
|
|
const { showArrow = true } = props;
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const state = this.$data;
|
2019-03-04 15:45:21 +08:00
|
|
|
|
const { disabled, prefixCls, loading } = props;
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const ctrlNode = this.renderTopControlNode();
|
|
|
|
|
const { _open: open, _inputValue: inputValue, _value: value } = this.$data;
|
2018-09-05 21:28:54 +08:00
|
|
|
|
if (open) {
|
2019-03-04 15:45:21 +08:00
|
|
|
|
const filterOptions = this.renderFilterOptions();
|
|
|
|
|
this._empty = filterOptions.empty;
|
|
|
|
|
this._options = filterOptions.options;
|
2018-09-05 21:28:54 +08:00
|
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const realOpen = this.getRealOpenState();
|
2019-03-04 15:45:21 +08:00
|
|
|
|
const empty = this._empty;
|
2019-01-12 11:33:27 +08:00
|
|
|
|
const options = this._options || [];
|
|
|
|
|
const { $listeners } = this;
|
|
|
|
|
const { mouseenter = noop, mouseleave = noop, popupScroll = noop } = $listeners;
|
2018-02-11 18:04:31 +08:00
|
|
|
|
const selectionProps = {
|
|
|
|
|
props: {},
|
|
|
|
|
attrs: {
|
|
|
|
|
role: 'combobox',
|
|
|
|
|
'aria-autocomplete': 'list',
|
|
|
|
|
'aria-haspopup': 'true',
|
2018-09-05 21:28:54 +08:00
|
|
|
|
'aria-expanded': realOpen,
|
2019-01-08 23:03:13 +08:00
|
|
|
|
'aria-controls': this.$data._ariaId,
|
2018-02-11 18:04:31 +08:00
|
|
|
|
},
|
|
|
|
|
on: {
|
2019-07-30 19:51:49 +08:00
|
|
|
|
// click: this.selectionRefClick,
|
2018-02-11 18:04:31 +08:00
|
|
|
|
},
|
|
|
|
|
class: `${prefixCls}-selection ${prefixCls}-selection--${multiple ? 'multiple' : 'single'}`,
|
2019-07-30 19:51:49 +08:00
|
|
|
|
// directives: [
|
|
|
|
|
// {
|
|
|
|
|
// name: 'ant-ref',
|
|
|
|
|
// value: this.saveSelectionRef,
|
|
|
|
|
// },
|
|
|
|
|
// ],
|
2018-02-11 18:04:31 +08:00
|
|
|
|
key: 'selection',
|
2019-01-12 11:33:27 +08:00
|
|
|
|
};
|
2019-08-14 18:41:49 +08:00
|
|
|
|
//if (!isMultipleOrTagsOrCombobox(props)) {
|
2019-08-15 22:24:53 +08:00
|
|
|
|
// selectionProps.on.keydown = this.onKeyDown;
|
|
|
|
|
// selectionProps.on.focus = this.selectionRefFocus;
|
|
|
|
|
// selectionProps.on.blur = this.selectionRefBlur;
|
|
|
|
|
// selectionProps.attrs.tabIndex = props.disabled ? -1 : props.tabIndex;
|
2019-08-14 18:41:49 +08:00
|
|
|
|
//}
|
2018-02-07 18:56:58 +08:00
|
|
|
|
const rootCls = {
|
2018-02-26 18:44:06 +08:00
|
|
|
|
[prefixCls]: true,
|
2018-09-05 21:28:54 +08:00
|
|
|
|
[`${prefixCls}-open`]: open,
|
|
|
|
|
[`${prefixCls}-focused`]: open || !!this._focused,
|
2018-02-07 18:56:58 +08:00
|
|
|
|
[`${prefixCls}-combobox`]: isCombobox(props),
|
|
|
|
|
[`${prefixCls}-disabled`]: disabled,
|
|
|
|
|
[`${prefixCls}-enabled`]: !disabled,
|
|
|
|
|
[`${prefixCls}-allow-clear`]: !!props.allowClear,
|
2019-03-04 15:45:21 +08:00
|
|
|
|
[`${prefixCls}-no-arrow`]: !showArrow,
|
|
|
|
|
[`${prefixCls}-loading`]: !!loading,
|
2019-01-12 11:33:27 +08:00
|
|
|
|
};
|
2018-02-07 18:56:58 +08:00
|
|
|
|
return (
|
|
|
|
|
<SelectTrigger
|
|
|
|
|
dropdownAlign={props.dropdownAlign}
|
2018-02-28 19:07:04 +08:00
|
|
|
|
dropdownClassName={props.dropdownClassName}
|
2018-02-07 18:56:58 +08:00
|
|
|
|
dropdownMatchSelectWidth={props.dropdownMatchSelectWidth}
|
|
|
|
|
defaultActiveFirstOption={props.defaultActiveFirstOption}
|
|
|
|
|
dropdownMenuStyle={props.dropdownMenuStyle}
|
|
|
|
|
transitionName={props.transitionName}
|
|
|
|
|
animation={props.animation}
|
|
|
|
|
prefixCls={props.prefixCls}
|
|
|
|
|
dropdownStyle={props.dropdownStyle}
|
|
|
|
|
combobox={props.combobox}
|
|
|
|
|
showSearch={props.showSearch}
|
2018-09-05 21:28:54 +08:00
|
|
|
|
options={options}
|
2019-03-04 15:45:21 +08:00
|
|
|
|
empty={empty}
|
2018-02-07 18:56:58 +08:00
|
|
|
|
multiple={multiple}
|
|
|
|
|
disabled={disabled}
|
2018-09-05 21:28:54 +08:00
|
|
|
|
visible={realOpen}
|
2018-02-07 18:56:58 +08:00
|
|
|
|
inputValue={inputValue}
|
2018-09-05 21:28:54 +08:00
|
|
|
|
value={value}
|
|
|
|
|
backfillValue={state._backfillValue}
|
2018-02-07 18:56:58 +08:00
|
|
|
|
firstActiveValue={props.firstActiveValue}
|
|
|
|
|
onDropdownVisibleChange={this.onDropdownVisibleChange}
|
|
|
|
|
getPopupContainer={props.getPopupContainer}
|
|
|
|
|
onMenuSelect={this.onMenuSelect}
|
|
|
|
|
onMenuDeselect={this.onMenuDeselect}
|
|
|
|
|
onPopupScroll={popupScroll}
|
|
|
|
|
onPopupFocus={this.onPopupFocus}
|
|
|
|
|
onMouseenter={mouseenter}
|
|
|
|
|
onMouseleave={mouseleave}
|
|
|
|
|
showAction={props.showAction}
|
2018-11-09 14:23:19 +08:00
|
|
|
|
menuItemSelectedIcon={getComponentFromProp(this, 'menuItemSelectedIcon')}
|
2019-01-12 11:33:27 +08:00
|
|
|
|
{...{
|
|
|
|
|
directives: [
|
|
|
|
|
{
|
|
|
|
|
name: 'ant-ref',
|
|
|
|
|
value: this.saveSelectTriggerRef,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}}
|
2019-01-04 23:00:09 +08:00
|
|
|
|
dropdownRender={props.dropdownRender}
|
2019-01-08 23:03:13 +08:00
|
|
|
|
ariaId={this.$data._ariaId}
|
2018-02-07 18:56:58 +08:00
|
|
|
|
>
|
|
|
|
|
<div
|
2019-01-12 11:33:27 +08:00
|
|
|
|
{...{
|
|
|
|
|
directives: [
|
|
|
|
|
{
|
|
|
|
|
name: 'ant-ref',
|
2019-07-30 19:51:49 +08:00
|
|
|
|
value: chaining(this.saveRootRef, this.saveSelectionRef),
|
2019-01-12 11:33:27 +08:00
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}}
|
2018-05-06 20:37:39 +08:00
|
|
|
|
style={getStyle(this)}
|
2018-02-12 11:47:57 +08:00
|
|
|
|
class={classnames(rootCls)}
|
2018-11-09 14:23:19 +08:00
|
|
|
|
onMousedown={this.markMouseDown}
|
|
|
|
|
onMouseup={this.markMouseLeave}
|
|
|
|
|
onMouseout={this.markMouseLeave}
|
2019-08-14 18:41:49 +08:00
|
|
|
|
tabIndex={props.disabled ? -1 : props.tabIndex}
|
2019-07-30 19:51:49 +08:00
|
|
|
|
onBlur={this.selectionRefBlur}
|
|
|
|
|
onFocus={this.selectionRefFocus}
|
|
|
|
|
onClick={this.selectionRefClick}
|
2019-08-14 18:41:49 +08:00
|
|
|
|
onKeydown={isMultipleOrTagsOrCombobox(props) ? noop : this.onKeyDown}
|
2018-02-07 18:56:58 +08:00
|
|
|
|
>
|
2018-02-11 18:04:31 +08:00
|
|
|
|
<div {...selectionProps}>
|
2018-02-07 18:56:58 +08:00
|
|
|
|
{ctrlNode}
|
|
|
|
|
{this.renderClear()}
|
2019-01-04 23:00:09 +08:00
|
|
|
|
{this.renderArrow(!!multiple)}
|
2018-02-07 18:56:58 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</SelectTrigger>
|
2019-01-12 11:33:27 +08:00
|
|
|
|
);
|
2018-02-07 18:56:58 +08:00
|
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
|
};
|
|
|
|
|
export { Select };
|
|
|
|
|
export default proxyComponent(Select);
|