From 051c79fd6f05dc852c3f97b1691947a51ec03c0d Mon Sep 17 00:00:00 2001 From: Nathan Vasse Date: Wed, 30 Aug 2023 11:40:35 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F(react)=20improve=20props=20p?= =?UTF-8?q?ropagation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before we had to edit input components using Field when adding new props to the latter. --- .../src/components/Forms/Checkbox/index.tsx | 33 +++---------------- .../src/components/Forms/Input/index.tsx | 17 ++-------- .../src/components/Forms/Radio/index.tsx | 14 +++----- .../components/Forms/Select/mono-common.tsx | 13 ++------ .../src/components/Forms/Switch/index.tsx | 23 ++----------- 5 files changed, 16 insertions(+), 84 deletions(-) diff --git a/packages/react/src/components/Forms/Checkbox/index.tsx b/packages/react/src/components/Forms/Checkbox/index.tsx index 11414b1..5074cbe 100644 --- a/packages/react/src/components/Forms/Checkbox/index.tsx +++ b/packages/react/src/components/Forms/Checkbox/index.tsx @@ -17,17 +17,7 @@ export type CheckboxProps = InputHTMLAttributes & export const Checkbox = forwardRef( ( - { - indeterminate, - className = "", - checked, - label, - text, - textItems, - rightText, - state, - ...props - }: CheckboxProps, + { indeterminate, className = "", checked, label, ...props }: CheckboxProps, ref, ) => { const inputRef = useRef(); @@ -49,13 +39,7 @@ export const Checkbox = forwardRef( "c__checkbox--disabled": props.disabled, })} > - +
( export const CheckboxGroup = ({ children, - state, - text, - textItems, - rightText, + ...props }: PropsWithChildren & FieldProps) => { return ( - +
{children}
); diff --git a/packages/react/src/components/Forms/Input/index.tsx b/packages/react/src/components/Forms/Input/index.tsx index 5698345..e1c9697 100644 --- a/packages/react/src/components/Forms/Input/index.tsx +++ b/packages/react/src/components/Forms/Input/index.tsx @@ -29,11 +29,6 @@ export const Input = forwardRef( id, icon, rightIcon, - state = "default", - text, - textItems, - rightText, - fullWidth, charCounter, charCounterMax, ...props @@ -51,7 +46,7 @@ export const Input = forwardRef( const idToUse = useRef(id || randomString()); const rightTextToUse = charCounter ? `${value.toString().length}/${charCounterMax}` - : rightText; + : props.rightText; const updateLabel = () => { if (inputFocus) { @@ -74,20 +69,14 @@ export const Input = forwardRef( }, [props.value]); return ( - + {/* We disabled linting for this specific line because we consider that the onClick props is only used for */} {/* mouse users, so this do not engender any issue for accessibility. */} {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}
& }; export const Radio = forwardRef( - ({ label, text, textItems, state, ...props }: RadioProps, ref) => { + ({ label, ...props }: RadioProps, ref) => { return (