import React from 'react'; export interface IFormControl extends React.HTMLProps { as?: 'input' | 'select' | 'textarea'; className?: string; defaultValue?: string; disabled?: boolean; feedback?: string; id?: string; label?: string; min?: any; minLength?: any; max?: any; maxLength?: any; name?: string; pattern?: string; placeholder?: string; readOnly?: boolean; required?: boolean; rows?: any; size?: 'sm' | 'lg' | any; style?: React.CSSProperties; type?: string; value?: string; onBlur?(e: any): void; onChange?(e: any): void; onInput?(e: any): void; onFocus?(e: any): void; onKeyUp?(e: any): void; onKeyDown?(e: any): void; onKeyPress?(e: any): void; [x: string]: any; } export type RefFormControls = HTMLInputElement & HTMLSelectElement & HTMLTextAreaElement; export const FormControl = React.forwardRef((props, ref) => { const { as = 'input', className = '', disabled = false, defaultValue, feedback, id, label, min, max, minLength, maxLength, name, pattern, placeholder, required, readOnly = false, rows, size, style, type, value, onBlur, onChange, onFocus, onInput, onKeyUp, onKeyDown, onKeyPress, ...otherProps } = props; function addClassNames() { let classList = 'b-form-control'; if (size) { classList = `${classList} b-form-control-${size}`; } if (className.length) { classList = `${classList} ${className}`; } return classList; } function addInputType(propInputType: string) { if (propInputType) { return propInputType; } else { return 'text'; } } let control = null; switch (as) { case 'select': control = ( ); break; case 'textarea': control = (