feat: add Object Edit form (#2090)

Closes #1910
This commit is contained in:
Thaïs
2023-10-17 21:03:59 +02:00
committed by GitHub
parent 54735c4880
commit 8894c52202
7 changed files with 103 additions and 11 deletions

View File

@ -13,6 +13,7 @@ import { InputHotkeyScope } from '../types/InputHotkeyScope';
const MAX_ROWS = 5;
export enum AutosizeTextInputVariant {
Default = 'default',
Icon = 'icon',
Button = 'button',
}
@ -24,6 +25,7 @@ type AutosizeTextInputProps = {
onFocus?: () => void;
variant?: AutosizeTextInputVariant;
buttonTitle?: string;
value?: string;
};
const StyledContainer = styled.div`
@ -112,14 +114,15 @@ export const AutosizeTextInput = ({
onValidate,
minRows = 1,
onFocus,
variant = AutosizeTextInputVariant.Icon,
variant = AutosizeTextInputVariant.Default,
buttonTitle,
value = '',
}: AutosizeTextInputProps) => {
const [isFocused, setIsFocused] = useState(false);
const [isHidden, setIsHidden] = useState(
variant === AutosizeTextInputVariant.Button,
);
const [text, setText] = useState('');
const [text, setText] = useState(value);
const isSendButtonDisabled = !text;
const words = text.split(/\s|\n/).filter((word) => word).length;

View File

@ -23,6 +23,7 @@ type TextInputComponentProps = Omit<
InputHTMLAttributes<HTMLInputElement>,
'onChange'
> & {
className?: string;
label?: string;
onChange?: (text: string) => void;
fullWidth?: boolean;
@ -103,6 +104,7 @@ const INPUT_TYPE_PASSWORD = 'password';
const TextInputComponent = (
{
className,
label,
value,
onChange,
@ -160,7 +162,7 @@ const TextInputComponent = (
};
return (
<StyledContainer fullWidth={fullWidth ?? false}>
<StyledContainer className={className} fullWidth={fullWidth ?? false}>
{label && <StyledLabel>{label + (required ? '*' : '')}</StyledLabel>}
<StyledInputContainer>
<StyledInput