update vc-xxx

pull/165/head
tangjinzhou 2018-03-14 10:36:52 +08:00
parent 66a271d93a
commit d38b1bc595
5 changed files with 35 additions and 29 deletions

View File

@ -4,6 +4,8 @@ import align from 'dom-align'
import addEventListener from '../_util/Dom/addEventListener' import addEventListener from '../_util/Dom/addEventListener'
import { cloneElement } from '../_util/vnode.js' import { cloneElement } from '../_util/vnode.js'
import isWindow from './isWindow' import isWindow from './isWindow'
import clonedeep from 'lodash.clonedeep'
import shallowequal from 'shallowequal'
function noop () { function noop () {
} }
@ -59,7 +61,7 @@ export default {
const props = this.$props const props = this.$props
let reAlign = false let reAlign = false
if (!props.disabled && this.visible) { if (!props.disabled && this.visible) {
if (prevProps.disabled || prevProps.align !== props.align) { if (prevProps.disabled || !shallowequal(prevProps.align, props.align)) {
reAlign = true reAlign = true
} else { } else {
const lastTarget = prevProps.target() const lastTarget = prevProps.target()
@ -81,7 +83,7 @@ export default {
} else { } else {
this.stopMonitorWindowResize() this.stopMonitorWindowResize()
} }
this.prevProps = { ...this.$props } this.prevProps = { ...this.$props, align: clonedeep(this.$props.align) }
}) })
}, },
beforeDestroy () { beforeDestroy () {

View File

@ -1,3 +1,3 @@
// export this package's api // based on vc-align 2.3.6
import Align from './Align' import Align from './Align'
export default Align export default Align

View File

@ -1,2 +1,3 @@
// based on vc-dialog 7.1.3
import DialogWrap from './DialogWrap' import DialogWrap from './DialogWrap'
export default DialogWrap export default DialogWrap

View File

@ -66,6 +66,7 @@ export default {
backfill: PropTypes.bool.def(false), backfill: PropTypes.bool.def(false),
showAction: SelectPropTypes.showAction.def(['click']), showAction: SelectPropTypes.showAction.def(['click']),
combobox: PropTypes.bool.def(false), combobox: PropTypes.bool.def(false),
tokenSeparators: PropTypes.arrayOf(PropTypes.string).def([]),
// onChange: noop, // onChange: noop,
// onFocus: noop, // onFocus: noop,
// onBlur: noop, // onBlur: noop,
@ -226,10 +227,10 @@ export default {
const val = event.target.value const val = event.target.value
if ( if (
isMultipleOrTags(this.$props) && isMultipleOrTags(this.$props) &&
tokenSeparators && tokenSeparators.length &&
includesSeparators(val, tokenSeparators) includesSeparators(val, tokenSeparators)
) { ) {
const nextValue = this.tokenize(val) const nextValue = this.getValueByInput(val)
this.fireChange(nextValue) this.fireChange(nextValue)
this.setOpenState(false, true) this.setOpenState(false, true)
this.setInputValue('', false) this.setInputValue('', false)
@ -691,6 +692,8 @@ export default {
} }
} else if (isMultipleOrTags(props) && inputValue) { } else if (isMultipleOrTags(props) && inputValue) {
this.inputValue = this.getInputDOMNode().value = '' this.inputValue = this.getInputDOMNode().value = ''
sValue = this.getValueByInput(inputValue)
this.fireChange(sValue)
} }
this.$emit('blur', this.getVLForOnChange(sValue)) this.$emit('blur', this.getVLForOnChange(sValue))
this.setOpenState(false) 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 () { focus () {
if (isSingleMode(this.$props)) { 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 () { getOptionsAndOpenStatus () {
let sOpen = this.sOpen let sOpen = this.sOpen
if (this.skipAdjustOpen) { if (this.skipAdjustOpen) {

View File

@ -1,3 +1,4 @@
// based on vc-select 7.7.5
import Select from './Select' import Select from './Select'
import Option from './Option' import Option from './Option'
import { SelectPropTypes } from './PropTypes' import { SelectPropTypes } from './PropTypes'