import React, { forwardRef } from "react";
import { BodyShort } from "../../typography/index.js";
import { omit, useId } from "../../utils-external/index.js";
import { cl } from "../../utils/helpers/index.js";
import { RadioInput } from "./radio-input/RadioInput.js";
import { useRadio } from "./useRadio.js";
export const Radio = forwardRef((props, forwardedRef) => {
    const { inputProps, size, hasError, readOnly } = useRadio(props);
    const descriptionId = useId();
    const { className, description, children } = props;
    return (React.createElement("div", { className: cl(className, "aksel-radio", `aksel-radio--${size}`, {
            "aksel-radio--error": hasError,
            "aksel-radio--disabled": inputProps.disabled,
            "aksel-radio--readonly": readOnly,
        }), "data-color": hasError ? "danger" : props["data-color"] },
        React.createElement(RadioInput, Object.assign({ ref: forwardedRef }, omit(props, [
            "children",
            "size",
            "description",
            "readOnly",
            "className",
        ]), omit(inputProps, ["aria-invalid", "aria-describedby"]), { "aria-describedby": cl(inputProps["aria-describedby"], {
                [descriptionId]: description,
            }) || undefined, standalone: false })),
        React.createElement(BodyShort, { as: "label", htmlFor: inputProps.id, className: "aksel-radio__label", size: size }, children),
        description && (React.createElement(BodyShort, { id: descriptionId, size: size, className: "aksel-form-field__subdescription aksel-radio__description" }, description))));
});
export default Radio;
//# sourceMappingURL=Radio.js.map