UNPKG

@snowball-tech/fractal

Version:

Fractal's (Snowball's design system) React component library based on RadixUI and PandaCSS

3 lines 2.45 kB
'use client'; import{a as R}from"./chunk-KLG6EM6H.js";import{a as o}from"./chunk-I3RVF3DK.js";import{a as n}from"./chunk-HTOKQYVM.js";import{b as e}from"./chunk-CMFNILWJ.js";import{a,b as h}from"./chunk-XYM7TA65.js";import{composeRefs as q}from"@radix-ui/react-compose-refs";import{Label as B}from"@radix-ui/react-label";import*as d from"@radix-ui/react-radio-group";import{UilCheck as P}from"@tooni/iconscout-unicons-react";import{forwardRef as H,useContext as F,useId as D,useRef as U}from"react";import j from"lodash/fp/isEmpty";import A from"lodash/fp/omit";import{jsx as r,jsxs as G}from"react/jsx-runtime";var x=H(({children:s,condensed:g=!1,disabled:y=!1,fullWidth:w=!1,id:$,label:l,labelAsDiv:I=!1,value:_,...m},v)=>{let u=!!s;!u&&j(l)&&console.warn("You must provide a `label` or `children` to the `InputRadio` component");let C={primary:"bg-white shadow-subtle border-1 border-normal",secondary:"bg-white border-1 border-normal",tertiary:"bg-transparent"},p=D(),f=($??p)||p,k=U(null),E=q(v,k),N=b=>{b.target&&b.target.blur()},{condensed:T,disabled:L,required:i=!1,variant:c}=F(R),t=y||L,M=g||T;return G(n,{className:h(`${e}-${o}`,`${e}-${o}--${c}`,"group/radio","flex w-full max-w-full cursor-default rounded-sm",C[c],t?`${e}-${o}--disabled text-disabled`:"text-dark",w?`${e}-${o}--full-width`:"sm:w-fit",i?`${e}-${o}--required`:"",m.className),element:"div",children:[r(d.Item,{id:f,ref:E,className:a(`${e}-${o}__radio`,"self mt-half h-full min-h-6 flex-grow-0 rounded-xs border-none bg-unset px-unset py-unset focus-visible:outline-none",t?"cursor-not-allowed":"cursor-pointer [&>:first-child]:data-state-checked:bg-primary group-hover/radio:[&>:first-child]:data-state-unchecked:bg-highlight"),disabled:t,required:i,value:_,onClick:N,...A(["className"],m),children:r("div",{className:a(`${e}-${o}__radio__mark`,"mx-2 flex h-3 max-h-3 min-h-3 w-3 min-w-3 max-w-3 items-center justify-center rounded-full border-2 pt-half",t?"border-disabled bg-transparent":"border-normal"),children:r(d.Indicator,{children:r(P,{})})})}),r(B,{asChild:!0,className:a(`${e}-${o}__radio__label`,"flex-1 overflow-auto break-words py-2 pr-2",M?"py-1":"py-2",t?"cursor-not-allowed":"cursor-pointer",i?`${e}-${o}__label--required after:text-feedback-danger-50 after:content-required`:""),htmlFor:f,children:r(n,{element:I?"div":"label",children:u?s:l})})]})});x.displayName="InputRadio";var oe=x;export{x as a,oe as b}; //# sourceMappingURL=chunk-4PQMI4I3.js.map