chore: migrated prop type definition into a types declaration file for components. other components prop types will live here

This commit is contained in:
utin-francis-peter
2024-07-03 11:49:49 +01:00
parent 15b0e321bd
commit 0a533b64e1
2 changed files with 25 additions and 15 deletions

View File

@@ -1,18 +1,5 @@
import React, { useEffect, useRef } from 'react';
type Props = {
value: string | string[] | number;
isAutoFocused: boolean;
id?: string;
maxLength?: number;
name?: string;
placeholder?: string;
className?: string;
children?: React.ReactElement;
onChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
onPaste?: (e: React.ClipboardEvent<HTMLTextAreaElement>) => void;
onKeyDown?: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void;
};
import { TextAreaProps } from './types';
const TextArea = ({
value,
@@ -26,7 +13,7 @@ const TextArea = ({
onChange,
onPaste,
onKeyDown,
}: Props) => {
}: TextAreaProps) => {
const textAreaRef = useRef<HTMLTextAreaElement>(null);
useEffect(() => {

View File

@@ -0,0 +1,23 @@
export type TextAreaProps = {
value: string | string[] | number;
isAutoFocused: boolean;
id?: string;
maxLength?: number;
name?: string;
placeholder?: string;
className?: string;
children?: React.ReactElement;
onChange: (
e: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>,
) => void;
onPaste?: (
e: React.ClipboardEvent<HTMLTextAreaElement | HTMLInputElement>,
) => void;
onKeyDown?: (
e: React.KeyboardEvent<HTMLTextAreaElement | HTMLInputElement>,
) => void;
};
export type InputProps = TextAreaProps & {
type: 'text' | 'number';
};