import { getState } from 'bsl-core/components/Choice'; import Helper, { Options } from 'bsl-core/components/Form/Helper'; import BSL from 'bsl-core/typings'; import { Value } from './export'; import{ dispatchUpdate } from 'bsl-mp/app/Form/Helper'; class ChoiceHelper extends Helper { constructor(options?: Options) { super(options); this.value = options?.defaultValue || []; } public value: T[]; public state: BSL.RequestState = 'undefined'; public onChange = (value: T[]) => { this.state = getState(value, this.required); this.value = value; dispatchUpdate(this); return this.state === 'complete'; } public clear = () => { this.onChange([]); } } export { Value }; export default ChoiceHelper;