@snowball-tech/fractal
Version:
Fractal's (Snowball's design system) React component library based on RadixUI and PandaCSS
3 lines • 2.83 kB
JavaScript
'use client';
import{a as r,c as w}from"./chunk-EEZZA3BT.js";import{c as p}from"./chunk-LYTTDLE2.js";import{a as h}from"./chunk-AOLTZ2WJ.js";import{b as e}from"./chunk-CMFNILWJ.js";import{a as b,b as x}from"./chunk-XYM7TA65.js";import*as T from"@radix-ui/react-toggle";import{forwardRef as B,useImperativeHandle as H,useRef as M}from"react";import y from"lodash/fp/isEmpty";import _ from"lodash/fp/isFunction";import $ from"lodash/fp/isString";import F from"lodash/fp/omit";import{jsx as q,jsxs as I}from"react/jsx-runtime";var A={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",secondary:"bg-white text-dark aria-not-pressed:hover:bg-primary aria-not-pressed:focus:bg-primary border-1 border-normal aria-pressed:bg-secondary aria-pressed:text-light"},C={primary:"bg-white text-disabled shadow-none border-1 border-disabled aria-pressed:bg-secondary aria-pressed:text-disabled",secondary:"bg-white text-disabled shadow-none border-1 border-disabled aria-pressed:bg-secondary aria-pressed:text-disabled"},R=B(({children:a,defaultToggled:m,disabled:s=!1,fullWidth:v=!1,icon:u,iconOnly:n=!1,label:t,labelElement:E,onToggle:f,toggled:c,variant:d=w,...o},N)=>{let i=!!a;!i&&!t&&console.warn("You must provide a `label` or `children` to the `Toggle` component");let l=M(null);H(N,()=>l.current);let P=L=>{l?.current?.blur(),_(f)&&f(L)},g=$(t)?t:y(t)?p(a):p(t);return I(T.Root,{...o.id===void 0?{}:{id:o.id},ref:l,"aria-label":g,className:x(`${e}-${r}`,`${e}-${r}--${d}`,"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",s?`${e}-${r}--disabled cursor-not-allowed ${C[d]}`:`cursor-pointer ${A[d]}`,v&&!n?`${e}-${r}--full-width w-full`:"w-fit",y(u)?"":`${e}-${r}--addendum ${e}-${r}--addendum--prefix`,n?`${e}-${r}--icon-only w-6 p-1`:"px-3 py-1",o.className),...m===void 0?{}:{defaultPressed:m},disabled:s,title:g,...c===void 0?{}:{pressed:c},onPressedChange:P,...F(["className","id"],o),children:[u,!n&&q(h,{className:b(`${e}-${r}__label`,"max-h-full max-w-full flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-center align-middle",s?`${e}-${r}__label--disabled cursor-not-allowed`:"cursor-pointer"),element:E||($(i?a:t)?"label":"div"),children:i?a:t})]})});R.displayName="Toggle";var K=R;export{A as a,C as b,R as c,K as d};
//# sourceMappingURL=chunk-SRQRK5M7.js.map