Generated types for the react package were broken because they were still using absolute imports which cannot work in standalone .d.ts files because they cannot rely on the local baseUrl compiler option. Thus, we introduced an alias that we are able to reliably replace during type generation.
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import React, { InputHTMLAttributes, PropsWithChildren } from "react";
|
|
import classNames from "classnames";
|
|
import { Field, FieldProps } from ":/components/Forms/Field";
|
|
|
|
type Props = InputHTMLAttributes<HTMLInputElement> &
|
|
FieldProps & {
|
|
label?: string;
|
|
};
|
|
|
|
export const Radio = ({ label, text, state, ...props }: Props) => {
|
|
return (
|
|
<label
|
|
className={classNames("c__checkbox", "c__radio", {
|
|
"c__checkbox--disabled": props.disabled,
|
|
})}
|
|
>
|
|
<Field text={text} compact={true} state={state}>
|
|
<div className="c__checkbox__container">
|
|
<input type="radio" {...props} />
|
|
{label && <div className="c__checkbox__label">{label}</div>}
|
|
</div>
|
|
</Field>
|
|
</label>
|
|
);
|
|
};
|
|
|
|
export const RadioGroup = ({
|
|
children,
|
|
state,
|
|
text,
|
|
rightText,
|
|
}: PropsWithChildren & FieldProps) => {
|
|
return (
|
|
<Field
|
|
className="c__radio__group c__checkbox__group"
|
|
state={state}
|
|
text={text}
|
|
rightText={rightText}
|
|
compact={true}
|
|
>
|
|
<div className="c__checkbox__group__list">{children}</div>
|
|
</Field>
|
|
);
|
|
};
|