UNPKG

@snowball-tech/fractal

Version:

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

3 lines 2.44 kB
'use client'; import{a as r,c as x}from"./chunk-AXQXUWJ6.js";import{a as h}from"./chunk-HTOKQYVM.js";import{b as e}from"./chunk-CMFNILWJ.js";import{a as c,b as g}from"./chunk-XYM7TA65.js";import{composeRefs as E}from"@radix-ui/react-compose-refs";import*as w from"@radix-ui/react-toggle";import{forwardRef as _,useRef as F}from"react";import b from"lodash/fp/isEmpty";import A from"lodash/fp/isFunction";import B from"lodash/fp/omit";import{jsx as M,jsxs as q}from"react/jsx-runtime";var C={primary:"bg-white text-dark aria-not-pressed:shadow-subtle aria-not-pressed:hover:shadow-brutal aria-not-pressed:focus:shadow-brutal aria-not-pressed:active:shadow-none border-1 border-normal aria-not-pressed:active:-translate-x-quarter aria-not-pressed:active:translate-y-half aria-not-pressed:hover:translate-x-0 aria-not-pressed:hover:-translate-y-quarter aria-not-pressed:focus:translate-x-0 aria-not-pressed:focus:-translate-y-quarter aria-pressed:bg-secondary aria-pressed:text-light"},L={primary:"bg-white text-disabled shadow-none border-1 border-disabled aria-pressed:bg-secondary aria-pressed:text-disabled"},$=_(({children:l,defaultToggled:i,disabled:t=!1,fullWidth:y=!1,icon:d,iconOnly:s=!1,label:o,labelAsDiv:T=!1,onToggle:m,toggled:p,variant:n=x,...a},R)=>{let f=!!l;!f&&b(o)&&console.warn("You must provide a `label` or `children` to the `Toggle` component");let u=F(null),v=E(R,u),N=P=>{u?.current?.blur(),A(m)&&m(P)};return q(w.Root,{...a.id===void 0?{}:{id:a.id},ref:v,"aria-label":o,className:g(`${e}-${r}`,`${e}-${r}--${n}`,"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",t?`${e}-${r}--disabled cursor-not-allowed ${L[n]}`:`cursor-pointer ${C[n]}`,y&&!s?`${e}-${r}--full-width w-full`:"w-fit",b(d)?"":`${e}-${r}--addendum ${e}-${r}--addendum--prefix`,s?`${e}-${r}--icon-only w-6 p-1`:"px-3 py-1",a.className),...i===void 0?{}:{defaultPressed:i},disabled:t,title:o,...p===void 0?{}:{pressed:p},onPressedChange:N,...B(["className","id"],a),children:[d,!s&&M(h,{className:c(`${e}-${r}__label`,"max-h-full max-w-full flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-center align-middle",t?`${e}-${r}__label--disabled cursor-not-allowed`:"cursor-pointer"),element:T?"div":"label",children:f?l:o})]})});$.displayName="Toggle";var z=$;export{C as a,L as b,$ as c,z as d}; //# sourceMappingURL=chunk-2OSZMMIK.js.map