retro-react
Version:
A React component library for building retro-style websites
2 lines (1 loc) • 1.19 kB
JavaScript
import{__rest as e}from"../../_virtual/_tslib.js";import{forwardRef as a,useState as d,Children as i,isValidElement as r,cloneElement as s}from"react";import{jsx as o,jsxs as l}from"../../node_modules/@theme-ui/core/jsx-runtime/dist/theme-ui-core-jsx-runtime.esm.js";import{RadioGroup as t,Radio as c,RadioLabel as n,RadioWrapper as m}from"./Radio.styled.js";const u=a(((a,l)=>{var{id:c,className:n,children:m,defaultValue:u,disabled:p=!1,sx:v,onChange:b}=a,f=e(a,["id","className","children","defaultValue","disabled","sx","onChange"]);const[j,g]=d(u),x=i.map(m,(e=>r(e)&&e.type===h?s(e,{checked:e.props.value===j,onChange:()=>{return a=e.props.value,g(a),void(b&&b(a));var a},disabled:p}):e));return o(t,Object.assign({disabled:p},f,{sx:v,ref:l},{children:x}),void 0)}));u.displayName="RadioGroup";const h=a(((a,d)=>{var{label:i="",checked:r,name:s}=a,t=e(a,["label","checked","name"]);return l(m,{children:[o(c,Object.assign({id:`${s}-${t.value}`,type:"radio",checked:r,ref:d,role:"radio","aria-checked":r,"aria-disabled":t.disabled},t),void 0),i&&o(n,Object.assign({htmlFor:`${s}-${t.value}`},{children:i}),void 0)]},void 0)}));h.displayName="Radio";export{h as Radio,u as RadioGroup};