import React, { Fragment, useState } from 'react'; import { Field as FinalField } from 'react-final-form'; import { Picker } from './index'; // import { IPickerProps } from "bondsports-utils/types"; export interface IOption { label: string; value: string | number; } export interface IPickerProps { label: string; info?: string; sizer: 'M' | 'S'; options: IOption[]; selected?: (string | number)[]; setSelected?: (v: any) => void; } export interface IFormProps extends IPickerProps { name: string; onClear?: (val: string) => void; required?: boolean; onSelecting: (val1: string, val2: string | (string | number)[]) => void; } export const FormPicker = ({ onClear = (val: string) => {}, ...props }: IFormProps & React.InputHTMLAttributes) => { const clear = () => onClear(props.name); // const [value, setValue] = useState<(string | number)[]>([]); const onSelect = (val: (string | number)[]) => { // setValue(val); props.onSelecting(props.name, val); }; return ( { if (props.required) { if (!val) { let errors = {}; errors[props.name] = 'required'; return errors; } } return undefined; }} displayEmpty > {({ input, meta }) => { const newProps = { ...props }; return ( {/* */} ); }} ); };