♻️(react) improve props propagation

Before we had to edit input components using Field when adding new props
to the latter.
This commit is contained in:
Nathan Vasse
2023-08-30 11:40:35 +02:00
committed by NathanVss
parent b530e966ae
commit 051c79fd6f
5 changed files with 16 additions and 84 deletions

View File

@@ -12,14 +12,14 @@ export type RadioProps = InputHTMLAttributes<HTMLInputElement> &
};
export const Radio = forwardRef<HTMLInputElement, RadioProps>(
({ label, text, textItems, state, ...props }: RadioProps, ref) => {
({ label, ...props }: RadioProps, ref) => {
return (
<label
className={classNames("c__checkbox", "c__radio", {
"c__checkbox--disabled": props.disabled,
})}
>
<Field text={text} compact={true} state={state} textItems={textItems}>
<Field compact={true} {...props}>
<div className="c__checkbox__container">
<input type="radio" {...props} ref={ref} />
{label && <div className="c__checkbox__label">{label}</div>}
@@ -32,20 +32,14 @@ export const Radio = forwardRef<HTMLInputElement, RadioProps>(
export const RadioGroup = ({
children,
state,
text,
textItems,
rightText,
style,
...props
}: PropsWithChildren & FieldProps & { style?: React.CSSProperties }) => {
return (
<Field
className="c__radio__group c__checkbox__group"
state={state}
text={text}
textItems={textItems}
rightText={rightText}
compact={true}
{...props}
>
<div className="c__checkbox__group__list" style={style}>
{children}