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