UNPKG

@snowball-tech/fractal

Version:

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

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