UNPKG

bsl

Version:

基于React的框架和UI组件

26 lines (19 loc) 720 B
import BSL from '../../typings'; import Helper, { Options } from '../Form/Helper'; import { Value } from './Item'; class PickerHelper extends Helper<Value[]> { constructor(options?: Options<Value[]>) { super(options); this.value = options?.defaultValue || []; } protected value: Value[]; public state: BSL.RequestState = 'undefined'; public onChange = (value: Value[]) => { const isEmpty = value.length === 0 || (value[0] && (value[0].value === undefined || value[0].value === null)); this.state = isEmpty && this.required ? 'empty' : 'complete'; this.value = value; this.update(); return this.state === 'complete'; } } export default PickerHelper;