fix
parent
a710e5a1ce
commit
257a050ba9
|
@ -36,6 +36,7 @@ export default {
|
||||||
monitorBufferTime: PropTypes.number.def(50),
|
monitorBufferTime: PropTypes.number.def(50),
|
||||||
monitorWindowResize: PropTypes.bool.def(false),
|
monitorWindowResize: PropTypes.bool.def(false),
|
||||||
disabled: PropTypes.bool.def(false),
|
disabled: PropTypes.bool.def(false),
|
||||||
|
visible: PropTypes.bool.def(false),
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
this.aligned = false
|
this.aligned = false
|
||||||
|
@ -55,8 +56,8 @@ export default {
|
||||||
const prevProps = this.prevProps
|
const prevProps = this.prevProps
|
||||||
const props = this.$props
|
const props = this.$props
|
||||||
let reAlign = false
|
let reAlign = false
|
||||||
if (!props.disabled) {
|
if (!props.disabled && this.visible) {
|
||||||
if (prevProps.disabled || !isEqual(prevProps.align, props.align)) {
|
if (prevProps.disabled || prevProps.align !== props.align) {
|
||||||
reAlign = true
|
reAlign = true
|
||||||
} else {
|
} else {
|
||||||
const lastTarget = prevProps.target()
|
const lastTarget = prevProps.target()
|
||||||
|
|
|
@ -129,10 +129,13 @@ export default {
|
||||||
const transitionEvent = {
|
const transitionEvent = {
|
||||||
beforeEnter: (el) => {
|
beforeEnter: (el) => {
|
||||||
el.style.display = el.__vOriginalDisplay
|
el.style.display = el.__vOriginalDisplay
|
||||||
this.$refs.alignInstance.forceAlign()
|
// this.$refs.alignInstance.forceAlign()
|
||||||
},
|
},
|
||||||
enter: (el, done) => {
|
enter: (el, done) => {
|
||||||
|
// align updated后执行动画
|
||||||
|
this.$nextTick(() => {
|
||||||
animate(el, `${transitionName}-enter`, done)
|
animate(el, `${transitionName}-enter`, done)
|
||||||
|
})
|
||||||
},
|
},
|
||||||
leave: (el, done) => {
|
leave: (el, done) => {
|
||||||
animate(el, `${transitionName}-leave`, done)
|
animate(el, `${transitionName}-leave`, done)
|
||||||
|
@ -169,6 +172,7 @@ export default {
|
||||||
monitorWindowResize
|
monitorWindowResize
|
||||||
align={align}
|
align={align}
|
||||||
onAlign={this.onAlign}
|
onAlign={this.onAlign}
|
||||||
|
visible={visible}
|
||||||
>
|
>
|
||||||
<PopupInner
|
<PopupInner
|
||||||
{...popupInnerProps}
|
{...popupInnerProps}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import classes from 'component-classes'
|
||||||
import { Item as MenuItem, ItemGroup as MenuItemGroup } from '../vc-menu'
|
import { Item as MenuItem, ItemGroup as MenuItemGroup } from '../vc-menu'
|
||||||
import warning from 'warning'
|
import warning from 'warning'
|
||||||
import Option from './Option'
|
import Option from './Option'
|
||||||
import { hasProp, getSlotOptions } from '../_util/props-util'
|
import { hasProp, getSlotOptions, getKey } from '../_util/props-util'
|
||||||
import getTransitionProps from '../_util/getTransitionProps'
|
import getTransitionProps from '../_util/getTransitionProps'
|
||||||
import { cloneElement, getClass, getPropsData, getValueByProp as getValue, getEvents } from '../_util/vnode'
|
import { cloneElement, getClass, getPropsData, getValueByProp as getValue, getEvents } from '../_util/vnode'
|
||||||
import BaseMixin from '../_util/BaseMixin'
|
import BaseMixin from '../_util/BaseMixin'
|
||||||
|
@ -98,6 +98,7 @@ export default {
|
||||||
if (sValue.length > 0) {
|
if (sValue.length > 0) {
|
||||||
this._valueOptions = this.getOptionsByValue(sValue)
|
this._valueOptions = this.getOptionsByValue(sValue)
|
||||||
}
|
}
|
||||||
|
console.log(sValue)
|
||||||
return {
|
return {
|
||||||
sValue,
|
sValue,
|
||||||
inputValue,
|
inputValue,
|
||||||
|
@ -166,11 +167,23 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
updateLabelAndTitleMap () {
|
updateLabelAndTitleMap (children = []) {
|
||||||
const labelMap = {}
|
this.titleMap = {}
|
||||||
const titleMap = {}
|
this.updateTitleMap(this.$slots.default)
|
||||||
this.labelMap = labelMap
|
},
|
||||||
this.titleMap = titleMap
|
updateTitleMap (children = []) {
|
||||||
|
children.forEach(child => {
|
||||||
|
if (!child) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (getSlotOptions(child).isSelectOptGroup) {
|
||||||
|
this.updateTitleMap(child.componentOptions.children)
|
||||||
|
} else {
|
||||||
|
const key = getValuePropValue(child)
|
||||||
|
this.titleMap[key] = getValue(child, 'title')
|
||||||
|
this.labelMap[key] = this.getLabelFromOption(child)
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
updateState () {
|
updateState () {
|
||||||
const { combobox, $slots } = this
|
const { combobox, $slots } = this
|
||||||
|
|
|
@ -6,7 +6,7 @@ export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
destroy: false,
|
destroy: false,
|
||||||
value: '01',
|
value: 'hello',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -58,7 +58,7 @@ export default {
|
||||||
firstActiveValue='2'
|
firstActiveValue='2'
|
||||||
backfill
|
backfill
|
||||||
>
|
>
|
||||||
<Option value='01' text='jack' title='jack'>
|
<Option key='hello' text='jack' title='jack'>
|
||||||
<b
|
<b
|
||||||
style={{
|
style={{
|
||||||
color: 'red',
|
color: 'red',
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
<script>
|
||||||
|
import Select, { Option } from '../index'
|
||||||
|
import '../assets/index.less'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
disabled: false,
|
||||||
|
value: ['name2', 'name3'],
|
||||||
|
maxTagCount: undefined,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
onChange (value, option) {
|
||||||
|
console.log(`changed ${value}`, option)
|
||||||
|
this.value = value
|
||||||
|
},
|
||||||
|
|
||||||
|
onSelect (value, option) {
|
||||||
|
console.log(`selected ${value}`, option.props)
|
||||||
|
},
|
||||||
|
|
||||||
|
onDeselect (value, option) {
|
||||||
|
console.log(`deselected ${value}`, option)
|
||||||
|
},
|
||||||
|
|
||||||
|
toggleDisabled () {
|
||||||
|
this.disabled = !this.disabled
|
||||||
|
},
|
||||||
|
|
||||||
|
toggleMaxTagCount (count) {
|
||||||
|
this.maxTagCount = count
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const children = []
|
||||||
|
for (let i = 10; i < 36; i++) {
|
||||||
|
children.push(<Option key={i.toString(36) + i} test={i}>{i.toString(36) + i}</Option>)
|
||||||
|
}
|
||||||
|
return (<div>
|
||||||
|
<h2>tags select(scroll the menu)</h2>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<Select
|
||||||
|
placeholder='placeholder'
|
||||||
|
tags
|
||||||
|
dropdownMenuStyle={{ maxHeight: '200px' }}
|
||||||
|
style={{ width: '500px' }}
|
||||||
|
disabled={this.disabled}
|
||||||
|
maxTagCount={this.maxTagCount}
|
||||||
|
maxTagTextLength={10}
|
||||||
|
value={this.value}
|
||||||
|
onChange={this.onChange}
|
||||||
|
onSelect={this.onSelect}
|
||||||
|
onDeselect={this.onDeselect}
|
||||||
|
tokenSeparators={[' ', ',']}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
<p>
|
||||||
|
<button onClick={this.toggleDisabled}>toggle disabled</button>
|
||||||
|
<button onClick={() => this.toggleMaxTagCount(0)}>toggle maxTagCount (0)</button>
|
||||||
|
<button onClick={() => this.toggleMaxTagCount(1)}>toggle maxTagCount (1)</button>
|
||||||
|
</p>
|
||||||
|
</div>)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -1,4 +1,5 @@
|
||||||
import { getPropsData, getSlotOptions, getKey, getAttrs } from '../_util/props-util'
|
import { getPropsData, getSlotOptions, getKey, getAttrs } from '../_util/props-util'
|
||||||
|
import { cloneVNodes } from '../_util/vnode'
|
||||||
export function getValuePropValue (child) {
|
export function getValuePropValue (child) {
|
||||||
const props = getPropsData(child)
|
const props = getPropsData(child)
|
||||||
if ('value' in props) {
|
if ('value' in props) {
|
||||||
|
@ -21,9 +22,9 @@ export function getPropValue (child, prop) {
|
||||||
}
|
}
|
||||||
if (prop === 'children') {
|
if (prop === 'children') {
|
||||||
if (child.$slots) {
|
if (child.$slots) {
|
||||||
return child.$slots.default
|
return cloneVNodes(child.$slots.default, true)
|
||||||
} else {
|
} else {
|
||||||
return child.componentOptions.children
|
return cloneVNodes(child.componentOptions.children, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const data = getPropsData(child)
|
const data = getPropsData(child)
|
||||||
|
|
|
@ -3,7 +3,7 @@ const AsyncComp = () => {
|
||||||
const hashs = window.location.hash.split('/')
|
const hashs = window.location.hash.split('/')
|
||||||
const d = hashs[hashs.length - 1]
|
const d = hashs[hashs.length - 1]
|
||||||
return {
|
return {
|
||||||
component: import(`../components/vc-select/demo/${d}.vue`),
|
component: import(`../components/vc-select/demo/single.vue`),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export default [
|
export default [
|
||||||
|
|
Loading…
Reference in New Issue