|
|
@ -53,7 +53,7 @@ const CascaderProps = {
|
|
|
|
disabled: PropTypes.bool.def(false),
|
|
|
|
disabled: PropTypes.bool.def(false),
|
|
|
|
/** 是否支持清除*/
|
|
|
|
/** 是否支持清除*/
|
|
|
|
allowClear: PropTypes.bool.def(true),
|
|
|
|
allowClear: PropTypes.bool.def(true),
|
|
|
|
showSearch: PropTypes.oneOfType([PropTypes.bool, ShowSearchType]),
|
|
|
|
showSearch: PropTypes.oneOfType([Boolean, ShowSearchType]),
|
|
|
|
notFoundContent: PropTypes.any.def('Not Found'),
|
|
|
|
notFoundContent: PropTypes.any.def('Not Found'),
|
|
|
|
loadData: PropTypes.func,
|
|
|
|
loadData: PropTypes.func,
|
|
|
|
/** 次级菜单的展开方式,可选 'click' 和 'hover' */
|
|
|
|
/** 次级菜单的展开方式,可选 'click' 和 'hover' */
|
|
|
@ -66,6 +66,7 @@ const CascaderProps = {
|
|
|
|
inputPrefixCls: PropTypes.string.def('ant-input'),
|
|
|
|
inputPrefixCls: PropTypes.string.def('ant-input'),
|
|
|
|
getPopupContainer: PropTypes.func,
|
|
|
|
getPopupContainer: PropTypes.func,
|
|
|
|
popupVisible: PropTypes.bool,
|
|
|
|
popupVisible: PropTypes.bool,
|
|
|
|
|
|
|
|
autoFocus: PropTypes.bool,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function defaultFilterOption (inputValue, path) {
|
|
|
|
function defaultFilterOption (inputValue, path) {
|
|
|
@ -102,6 +103,13 @@ export default {
|
|
|
|
flattenOptions: showSearch && flattenTree(options, changeOnSelect),
|
|
|
|
flattenOptions: showSearch && flattenTree(options, changeOnSelect),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted () {
|
|
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
|
|
if (this.autoFocus && !this.showSearch && !this.disabled) {
|
|
|
|
|
|
|
|
this.$refs.picker.focus()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
watch: {
|
|
|
|
value (val) {
|
|
|
|
value (val) {
|
|
|
|
this.setState({ sValue: val || [] })
|
|
|
|
this.setState({ sValue: val || [] })
|
|
|
@ -119,7 +127,7 @@ export default {
|
|
|
|
highlightKeyword (str, keyword, prefixCls) {
|
|
|
|
highlightKeyword (str, keyword, prefixCls) {
|
|
|
|
return str.split(keyword)
|
|
|
|
return str.split(keyword)
|
|
|
|
.map((node, index) => index === 0 ? node : [
|
|
|
|
.map((node, index) => index === 0 ? node : [
|
|
|
|
<span class={`${prefixCls}-menu-item-keyword`} key='seperator'>{keyword}</span>,
|
|
|
|
<span class={`${prefixCls}-menu-item-keyword`}>{keyword}</span>,
|
|
|
|
node,
|
|
|
|
node,
|
|
|
|
])
|
|
|
|
])
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -152,11 +160,15 @@ export default {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.$emit('popupVisibleChange', popupVisible)
|
|
|
|
this.$emit('popupVisibleChange', popupVisible)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
handleInputFocus (e) {
|
|
|
|
|
|
|
|
this.$emit('focus', e)
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
handleInputBlur () {
|
|
|
|
handleInputBlur (e) {
|
|
|
|
this.setState({
|
|
|
|
this.setState({
|
|
|
|
inputFocused: false,
|
|
|
|
inputFocused: false,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
this.$emit('blur', e)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
handleInputClick (e) {
|
|
|
|
handleInputClick (e) {
|
|
|
@ -164,7 +176,7 @@ export default {
|
|
|
|
// Prevent `Trigger` behaviour.
|
|
|
|
// Prevent `Trigger` behaviour.
|
|
|
|
if (inputFocused || sPopupVisible) {
|
|
|
|
if (inputFocused || sPopupVisible) {
|
|
|
|
e.stopPropagation()
|
|
|
|
e.stopPropagation()
|
|
|
|
e.nativeEvent.stopImmediatePropagation()
|
|
|
|
e.nativeEvent && e.nativeEvent.stopImmediatePropagation()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
@ -249,16 +261,24 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
focus () {
|
|
|
|
focus () {
|
|
|
|
this.$refs.input.focus()
|
|
|
|
if (this.showSearch) {
|
|
|
|
|
|
|
|
this.$refs.input.focus()
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
this.$refs.picker.focus()
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
blur () {
|
|
|
|
blur () {
|
|
|
|
this.$refs.input.blur()
|
|
|
|
if (this.showSearch) {
|
|
|
|
|
|
|
|
this.$refs.input.blur()
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
this.$refs.picker.blur()
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
render () {
|
|
|
|
render () {
|
|
|
|
const { $slots, sValue: value, sPopupVisible, inputValue } = this
|
|
|
|
const { $slots, sValue: value, sPopupVisible, inputValue, $listeners } = this
|
|
|
|
const props = getOptionProps(this)
|
|
|
|
const props = getOptionProps(this)
|
|
|
|
const {
|
|
|
|
const {
|
|
|
|
prefixCls, inputPrefixCls, placeholder, size, disabled,
|
|
|
|
prefixCls, inputPrefixCls, placeholder, size, disabled,
|
|
|
@ -329,6 +349,7 @@ export default {
|
|
|
|
if (resultListMatchInputWidth && inputValue && this.input) {
|
|
|
|
if (resultListMatchInputWidth && inputValue && this.input) {
|
|
|
|
dropdownMenuColumnStyle.width = this.input.input.offsetWidth
|
|
|
|
dropdownMenuColumnStyle.width = this.input.input.offsetWidth
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// showSearch时,focus、blur在input上触发,反之在ref='picker'上触发
|
|
|
|
const inputProps = {
|
|
|
|
const inputProps = {
|
|
|
|
props: {
|
|
|
|
props: {
|
|
|
|
...tempInputProps,
|
|
|
|
...tempInputProps,
|
|
|
@ -342,6 +363,7 @@ export default {
|
|
|
|
class: `${prefixCls}-input ${sizeCls}`,
|
|
|
|
class: `${prefixCls}-input ${sizeCls}`,
|
|
|
|
ref: 'input',
|
|
|
|
ref: 'input',
|
|
|
|
on: {
|
|
|
|
on: {
|
|
|
|
|
|
|
|
focus: showSearch ? this.handleInputFocus : noop,
|
|
|
|
click: showSearch ? this.handleInputClick : noop,
|
|
|
|
click: showSearch ? this.handleInputClick : noop,
|
|
|
|
blur: showSearch ? this.handleInputBlur : noop,
|
|
|
|
blur: showSearch ? this.handleInputBlur : noop,
|
|
|
|
keydown: this.handleKeyDown,
|
|
|
|
keydown: this.handleKeyDown,
|
|
|
@ -354,6 +376,7 @@ export default {
|
|
|
|
<span
|
|
|
|
<span
|
|
|
|
class={pickerCls}
|
|
|
|
class={pickerCls}
|
|
|
|
style={getStyle(this)}
|
|
|
|
style={getStyle(this)}
|
|
|
|
|
|
|
|
ref='picker'
|
|
|
|
>
|
|
|
|
>
|
|
|
|
{ showSearch ? <span class={`${prefixCls}-picker-label`}>
|
|
|
|
{ showSearch ? <span class={`${prefixCls}-picker-label`}>
|
|
|
|
{this.getLabel()}
|
|
|
|
{this.getLabel()}
|
|
|
@ -375,6 +398,7 @@ export default {
|
|
|
|
dropdownMenuColumnStyle: dropdownMenuColumnStyle,
|
|
|
|
dropdownMenuColumnStyle: dropdownMenuColumnStyle,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
on: {
|
|
|
|
on: {
|
|
|
|
|
|
|
|
...$listeners,
|
|
|
|
popupVisibleChange: this.handlePopupVisibleChange,
|
|
|
|
popupVisibleChange: this.handlePopupVisibleChange,
|
|
|
|
change: this.handleChange,
|
|
|
|
change: this.handleChange,
|
|
|
|
},
|
|
|
|
},
|
|
|
|