UNPKG

@uva-glass/component-library

Version:

React components UvA

53 lines (52 loc) 1.76 kB
import { jsxs as u, jsx as i } from "react/jsx-runtime"; import { useState as h } from "react"; import { c as m } from "../../clsx-OuTLNxxd.js"; import { RadioButton as k } from "../RadioButton/RadioButton.js"; import '../../assets/RadioGroup.css';const r = { "radio-group__wrapper": "_radio-group__wrapper_1khqv_1", "radio-group__header": "_radio-group__header_1khqv_7", "radio-group": "_radio-group_1khqv_1", "radio-group__option": "_radio-group__option_1khqv_21", "radio-group__option--disabled": "_radio-group__option--disabled_1khqv_36" }, x = ({ label: d, options: t, onChange: n, disabled: _ }) => { const [s, c] = h(null), p = (o) => { _ || (c(o), n(o)); }; return /* @__PURE__ */ u("div", { className: r["radio-group__wrapper"], children: [ /* @__PURE__ */ i("h2", { className: r["radio-group__header"], children: d }), /* @__PURE__ */ i("div", { className: r["radio-group"], children: t.map(({ id: o, descriptionLabel: g, titleLabel: l, value: e }) => /* @__PURE__ */ i( "div", { className: m(r["radio-group__option"], { [r["radio-group__option--disabled"]]: _ }), onClick: () => p(e), onKeyDown: (a) => { (a.key === "Enter" || a.key === " ") && p(e); }, role: "presentation", children: /* @__PURE__ */ i( k, { id: o, label: l, description: g, name: d, onChange: (a) => { p(a.target.value); }, value: e, checked: s === e, disabled: _, gap: "large" } ) }, o )) }) ] }); }; export { x as RadioGroup }; //# sourceMappingURL=RadioGroup.js.map