UNPKG

shelving

Version:

Toolkit for using data in JavaScript.

11 lines (10 loc) 960 B
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { notNullish } from "../../util/null.js"; import { getFlexClass } from "../style/Flex.js"; import { getClass } from "../util/css.js"; import { LABEL_INPUT_CLASS, PLACEHOLDER_CLASS, RADIO_CLASS } from "./Input.js"; /** A single `<input type="radio">` in a `<label>` wrapper styled as an `<Input>` */ export function RadioInput({ name, title, placeholder = title || "Choose", required = false, disabled = false, message = "", value = false, onValue, children, ...props }) { const hasChildren = notNullish(children); return (_jsxs("label", { className: getClass(LABEL_INPUT_CLASS, getFlexClass(props), hasChildren && PLACEHOLDER_CLASS), children: [_jsx("input", { className: RADIO_CLASS, type: "radio", name: name, defaultChecked: value, onChange: () => onValue(true), disabled: disabled, required: required, "aria-invalid": !!message }), hasChildren ? children : placeholder] })); }