diff --git a/components/align/Align.vue b/components/align/Align.vue index 52204ae90..c4dfb3084 100644 --- a/components/align/Align.vue +++ b/components/align/Align.vue @@ -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 () { diff --git a/components/align/index.js b/components/align/index.js index b1cce23fe..b22fd6f2e 100644 --- a/components/align/index.js +++ b/components/align/index.js @@ -1,3 +1,3 @@ -// export this package's api +// based on vc-align 2.3.6 import Align from './Align' export default Align diff --git a/components/vc-dialog/index.js b/components/vc-dialog/index.js index d545f04b4..54140e43a 100644 --- a/components/vc-dialog/index.js +++ b/components/vc-dialog/index.js @@ -1,2 +1,3 @@ +// based on vc-dialog 7.1.3 import DialogWrap from './DialogWrap' export default DialogWrap diff --git a/components/vc-select/Select.vue b/components/vc-select/Select.vue index 91e2b3bf4..458e35a3f 100644 --- a/components/vc-select/Select.vue +++ b/components/vc-select/Select.vue @@ -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) { diff --git a/components/vc-select/index.js b/components/vc-select/index.js index a0f66de83..5d4ba95bb 100644 --- a/components/vc-select/index.js +++ b/components/vc-select/index.js @@ -1,3 +1,4 @@ +// based on vc-select 7.7.5 import Select from './Select' import Option from './Option' import { SelectPropTypes } from './PropTypes'