UNPKG

936 BTypeScriptView Raw
1import React, { Component } from 'react'
2import { SsSelectPropsType } from '../utils/PropTypes'
3import ErrorTip from './helper/ErrorTip'
4import MultiSelectView from './SSMultiSelectView'
5import getFieldDecorator from '../utils/getFieldDecorator'
6
7export default class SsMultiSelect extends Component<SsSelectPropsType, {}> {
8 private fieldDecorator: any
9 static defaultProps = {
10 required: false,
11 placeholder: '请输入',
12 }
13
14 componentWillMount() {
15 const { form, id, initialValue, rules } = this.props
16 this.fieldDecorator = getFieldDecorator(form, id, initialValue && [initialValue], rules)
17 }
18
19 render() {
20 const { label, required, form, id, onChange, options } = this.props
21 return (
22 <ErrorTip error={form.getFieldError(id)}>
23 {this.fieldDecorator(
24 <MultiSelectView label={label} required={required} onChange={onChange} options={options} />
25 )}
26 </ErrorTip>
27 )
28 }
29}