@snowball-tech/fractal
Version:
Fractal's (Snowball's design system) React component library based on RadixUI and PandaCSS
3 lines • 2.58 kB
JavaScript
'use client';
import{a as g,b}from"./chunk-2OSZMMIK.js";import{a}from"./chunk-U4NRZEUB.js";import{a as x}from"./chunk-XU2TT2NF.js";import{a as h}from"./chunk-HTOKQYVM.js";import{b as e}from"./chunk-CMFNILWJ.js";import{a as f,b as p}from"./chunk-XYM7TA65.js";import{composeRefs as B}from"@radix-ui/react-compose-refs";import*as k from"@radix-ui/react-toggle-group";import{forwardRef as V,useContext as _,useRef as F}from"react";import $ from"lodash/fp/isEmpty";import w from"lodash/fp/isFunction";import H from"lodash/fp/omit";import{jsx as L,jsxs as q}from"react/jsx-runtime";var y=V(({children:s,disabled:T=!1,fullWidth:v=!1,icon:n,iconOnly:l=!1,label:o,labelAsDiv:C=!1,onToggle:d,value:N,...t},G)=>{let c=!!s;!c&&$(o)&&console.warn("You must provide a `label` or `children` to the `ToggleGroupItem` component");let u=F(null),R=B(G,u),I={primary:"bg-white text-dark aria-unchecked:shadow-subtle aria-unchecked:hover:shadow-brutal aria-unchecked:focus:shadow-brutal aria-unchecked:active:shadow-none border-1 border-normal aria-unchecked:active:-translate-x-quarter aria-unchecked:active:translate-y-half aria-unchecked:hover:translate-x-0 aria-unchecked:hover:-translate-y-quarter aria-unchecked:focus:translate-x-0 aria-unchecked:focus:-translate-y-quarter aria-checked:bg-secondary aria-checked:text-light"},E={primary:"bg-white text-disabled shadow-none border-1 border-disabled aria-checked:bg-secondary aria-checked:text-disabled"},{disabled:M,variant:r}=_(x),P=m=>{u?.current?.blur(),w(d)&&d(m.currentTarget.attributes.getNamedItem("aria-checked")?.value==="true"),w(t.onClick)&&t.onClick(m)},i=T||M;return q(k.Item,{...t.id===void 0?{}:{id:t.id},ref:R,"aria-label":o,className:p(`${e}-${a}`,`${e}-${a}--${r}`,"flex h-6 max-h-6 max-w-full items-center justify-center gap-2 rounded-full text-left outline-none transition-colors duration-300 ease-out active:transition-none",i?`${e}-${a}--disabled cursor-not-allowed ${E[r]} ${b[r]}`:`cursor-pointer ${I[r]} ${g[r]}`,v&&!l?`${e}-${a}--full-width w-full`:"w-fit",$(n)?"":`${e}-${a}--addendum ${e}-${a}--addendum--prefix`,l?`${e}-${a}--icon-only w-6 p-1`:"px-3 py-1",t.className),disabled:i,title:o,value:N,onClick:P,...H(["className","id","onClick"],t),children:[n,!l&&L(h,{className:f(`${e}-${a}__label`,"max-h-full max-w-full flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-center align-middle",i?`${e}-${a}__label--disabled cursor-not-allowed`:"cursor-pointer"),element:C?"div":"label",children:c?s:o})]})});y.displayName="ToggleGroupItem";var W=y;export{y as a,W as b};
//# sourceMappingURL=chunk-MV7SU7M2.js.map