import './InputWithLabel.styles.scss'; import { Button, Input, Typography } from 'antd'; import cx from 'classnames'; import { X } from 'lucide-react'; import { useState } from 'react'; function InputWithLabel({ label, initialValue, placeholder, type, onClose, labelAfter, onChange, className, closeIcon, }: { label: string; initialValue?: string | number; placeholder: string; type?: string; onClose?: () => void; labelAfter?: boolean; onChange: (value: string) => void; className?: string; closeIcon?: React.ReactNode; }): JSX.Element { const [inputValue, setInputValue] = useState( initialValue ? initialValue.toString() : '', ); const handleChange = (e: React.ChangeEvent): void => { setInputValue(e.target.value); onChange?.(e.target.value); }; return (
{!labelAfter && {label}} {labelAfter && {label}} {onClose && (
); } InputWithLabel.defaultProps = { type: 'text', onClose: undefined, labelAfter: false, initialValue: undefined, className: undefined, closeIcon: undefined, }; export default InputWithLabel;