diff --git a/components/common/InputTableField/index.scss b/components/common/InputTableField/index.scss index 94544da9..e232dbfb 100644 --- a/components/common/InputTableField/index.scss +++ b/components/common/InputTableField/index.scss @@ -1,4 +1,3 @@ -.InputField.TableField .Input { +.InputField.TableField .Input[type='number'] { text-align: right; - width: $unit-8x; } diff --git a/components/common/InputTableField/index.tsx b/components/common/InputTableField/index.tsx index 26fdac25..a043d7ed 100644 --- a/components/common/InputTableField/index.tsx +++ b/components/common/InputTableField/index.tsx @@ -3,50 +3,60 @@ import Input from '~components/common/Input' import TableField from '~components/common/TableField' import './index.scss' +import classNames from 'classnames' -interface Props { - name: string +interface Props + extends React.DetailedHTMLProps< + React.InputHTMLAttributes, + HTMLInputElement + > { label: string description?: string - placeholder?: string - value?: number - className?: string imageAlt?: string imageClass?: string imageSrc?: string[] - onValueChange: (value: number) => void + onValueChange: (value?: string) => void } -const InputTableField = (props: Props) => { - const [value, setValue] = useState(0) +const InputTableField = ({ + label, + description, + imageAlt, + imageClass, + imageSrc, + ...props +}: Props) => { + const [inputValue, setInputValue] = useState('') useEffect(() => { - if (props.value) setValue(props.value) + if (props.value) setInputValue(`${props.value}`) }, [props.value]) useEffect(() => { - props.onValueChange(value) - }, [value]) + props.onValueChange(inputValue) + }, [inputValue]) function onInputChange(event: React.ChangeEvent) { - setValue(parseInt(event.currentTarget?.value)) + setInputValue(`${parseInt(event.currentTarget?.value)}`) } return (