update vc-xxx
parent
66a271d93a
commit
d38b1bc595
|
@ -4,6 +4,8 @@ import align from 'dom-align'
|
|||
import addEventListener from '../_util/Dom/addEventListener'
|
||||
import { cloneElement } from '../_util/vnode.js'
|
||||
import isWindow from './isWindow'
|
||||
import clonedeep from 'lodash.clonedeep'
|
||||
import shallowequal from 'shallowequal'
|
||||
function noop () {
|
||||
}
|
||||
|
||||
|
@ -59,7 +61,7 @@ export default {
|
|||
const props = this.$props
|
||||
let reAlign = false
|
||||
if (!props.disabled && this.visible) {
|
||||
if (prevProps.disabled || prevProps.align !== props.align) {
|
||||
if (prevProps.disabled || !shallowequal(prevProps.align, props.align)) {
|
||||
reAlign = true
|
||||
} else {
|
||||
const lastTarget = prevProps.target()
|
||||
|
@ -81,7 +83,7 @@ export default {
|
|||
} else {
|
||||
this.stopMonitorWindowResize()
|
||||
}
|
||||
this.prevProps = { ...this.$props }
|
||||
this.prevProps = { ...this.$props, align: clonedeep(this.$props.align) }
|
||||
})
|
||||
},
|
||||
beforeDestroy () {
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
// export this package's api
|
||||
// based on vc-align 2.3.6
|
||||
import Align from './Align'
|
||||
export default Align
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
// based on vc-dialog 7.1.3
|
||||
import DialogWrap from './DialogWrap'
|
||||
export default DialogWrap
|
||||
|
|
|
@ -66,6 +66,7 @@ export default {
|
|||
backfill: PropTypes.bool.def(false),
|
||||
showAction: SelectPropTypes.showAction.def(['click']),
|
||||
combobox: PropTypes.bool.def(false),
|
||||
tokenSeparators: PropTypes.arrayOf(PropTypes.string).def([]),
|
||||
// onChange: noop,
|
||||
// onFocus: noop,
|
||||
// onBlur: noop,
|
||||
|
@ -226,10 +227,10 @@ export default {
|
|||
const val = event.target.value
|
||||
if (
|
||||
isMultipleOrTags(this.$props) &&
|
||||
tokenSeparators &&
|
||||
tokenSeparators.length &&
|
||||
includesSeparators(val, tokenSeparators)
|
||||
) {
|
||||
const nextValue = this.tokenize(val)
|
||||
const nextValue = this.getValueByInput(val)
|
||||
this.fireChange(nextValue)
|
||||
this.setOpenState(false, true)
|
||||
this.setInputValue('', false)
|
||||
|
@ -691,6 +692,8 @@ export default {
|
|||
}
|
||||
} else if (isMultipleOrTags(props) && inputValue) {
|
||||
this.inputValue = this.getInputDOMNode().value = ''
|
||||
sValue = this.getValueByInput(inputValue)
|
||||
this.fireChange(sValue)
|
||||
}
|
||||
this.$emit('blur', this.getVLForOnChange(sValue))
|
||||
this.setOpenState(false)
|
||||
|
@ -808,6 +811,29 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
getValueByInput (string) {
|
||||
const { multiple, tokenSeparators, $slots } = this
|
||||
let nextValue = this.sValue
|
||||
splitBySeparators(string, tokenSeparators).forEach(label => {
|
||||
const selectedValue = { key: label, label }
|
||||
if (findIndexInValueByLabel(nextValue, label) === -1) {
|
||||
if (multiple) {
|
||||
const value = this.getValueByLabel($slots.default, label)
|
||||
if (value) {
|
||||
selectedValue.key = value
|
||||
nextValue = nextValue.concat(selectedValue)
|
||||
}
|
||||
} else {
|
||||
nextValue = nextValue.concat(selectedValue)
|
||||
}
|
||||
}
|
||||
this.fireSelect({
|
||||
key: label,
|
||||
label,
|
||||
})
|
||||
})
|
||||
return nextValue
|
||||
},
|
||||
|
||||
focus () {
|
||||
if (isSingleMode(this.$props)) {
|
||||
|
@ -1024,30 +1050,6 @@ export default {
|
|||
})
|
||||
},
|
||||
|
||||
tokenize (string) {
|
||||
const { multiple, tokenSeparators, $slots } = this
|
||||
let nextValue = this.sValue
|
||||
splitBySeparators(string, tokenSeparators).forEach(label => {
|
||||
const selectedValue = { key: label, label }
|
||||
if (findIndexInValueByLabel(nextValue, label) === -1) {
|
||||
if (multiple) {
|
||||
const value = this.getValueByLabel($slots.default, label)
|
||||
if (value) {
|
||||
selectedValue.key = value
|
||||
nextValue = nextValue.concat(selectedValue)
|
||||
}
|
||||
} else {
|
||||
nextValue = nextValue.concat(selectedValue)
|
||||
}
|
||||
}
|
||||
this.fireSelect({
|
||||
key: label,
|
||||
label,
|
||||
})
|
||||
})
|
||||
return nextValue
|
||||
},
|
||||
|
||||
getOptionsAndOpenStatus () {
|
||||
let sOpen = this.sOpen
|
||||
if (this.skipAdjustOpen) {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// based on vc-select 7.7.5
|
||||
import Select from './Select'
|
||||
import Option from './Option'
|
||||
import { SelectPropTypes } from './PropTypes'
|
||||
|
|
Loading…
Reference in New Issue