2018-04-06 16:20:45 +00:00
|
|
|
import PropTypes from '../_util/vue-types'
|
|
|
|
import classNames from 'classnames'
|
|
|
|
import Lazyload from '../vc-lazy-load'
|
|
|
|
import Checkbox from '../checkbox'
|
|
|
|
|
|
|
|
function noop () {
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
renderedText: PropTypes.any,
|
|
|
|
renderedEl: PropTypes.any,
|
|
|
|
item: PropTypes.any,
|
|
|
|
lazy: PropTypes.oneOfType([
|
|
|
|
PropTypes.bool,
|
|
|
|
PropTypes.object,
|
|
|
|
]),
|
|
|
|
checked: PropTypes.bool,
|
|
|
|
prefixCls: PropTypes.string,
|
2018-12-05 12:00:13 +00:00
|
|
|
disabled: PropTypes.bool,
|
2018-04-06 16:20:45 +00:00
|
|
|
},
|
|
|
|
name: 'Item',
|
|
|
|
render () {
|
2018-12-05 12:00:13 +00:00
|
|
|
const {
|
|
|
|
renderedText, renderedEl, item, lazy,
|
|
|
|
checked, disabled, prefixCls,
|
|
|
|
} = this.$props
|
2018-04-06 16:20:45 +00:00
|
|
|
|
|
|
|
const className = classNames({
|
|
|
|
[`${prefixCls}-content-item`]: true,
|
2018-12-05 12:00:13 +00:00
|
|
|
[`${prefixCls}-content-item-disabled`]: disabled || item.disabled,
|
2018-04-06 16:20:45 +00:00
|
|
|
})
|
|
|
|
|
2018-12-05 12:00:13 +00:00
|
|
|
let title
|
|
|
|
if (typeof renderedText === 'string' || typeof renderedText === 'number') {
|
|
|
|
title = String(renderedText)
|
|
|
|
}
|
|
|
|
|
2018-04-06 16:20:45 +00:00
|
|
|
const listItem = (
|
|
|
|
<li
|
|
|
|
class={className}
|
2018-12-05 12:00:13 +00:00
|
|
|
title={title}
|
|
|
|
onClick={(disabled || item.disabled) ? noop : () => {
|
2018-04-06 16:20:45 +00:00
|
|
|
this.$emit('click', item)
|
|
|
|
}}
|
|
|
|
>
|
2018-12-05 12:00:13 +00:00
|
|
|
<Checkbox checked={checked} disabled={disabled || item.disabled} />
|
2018-04-06 16:20:45 +00:00
|
|
|
<span>{renderedEl}</span>
|
|
|
|
</li>
|
|
|
|
)
|
|
|
|
let children = null
|
|
|
|
if (lazy) {
|
|
|
|
const lazyProps = {
|
|
|
|
props: {
|
|
|
|
height: 32,
|
|
|
|
offset: 500,
|
|
|
|
throttle: 0,
|
|
|
|
debounce: false,
|
|
|
|
...lazy,
|
2018-09-05 13:28:54 +00:00
|
|
|
_propsSymbol: Symbol(),
|
2018-04-06 16:20:45 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
children = <Lazyload {...lazyProps}>{listItem}</Lazyload>
|
|
|
|
} else {
|
|
|
|
children = listItem
|
|
|
|
}
|
|
|
|
return children
|
|
|
|
},
|
|
|
|
}
|