@snowball-tech/fractal
Version:
Fractal's (Snowball's design system) React component library based on RadixUI and PandaCSS
3 lines • 3.08 kB
JavaScript
'use client';
import{a as S}from"./chunk-4T67RILQ.js";import{a as o}from"./chunk-FJXP7YHG.js";import{c as $}from"./chunk-LYTTDLE2.js";import{a as R}from"./chunk-AOLTZ2WJ.js";import{b as e}from"./chunk-CMFNILWJ.js";import{a as T,b as L}from"./chunk-XYM7TA65.js";import*as F from"@radix-ui/react-toolbar";import{forwardRef as U,useContext as X}from"react";import x from"lodash/fp/isEmpty";import a from"lodash/fp/isFunction";import Y from"lodash/fp/isString";import H from"lodash/fp/omit";import{jsx as _,jsxs as q}from"react/jsx-runtime";var D=U(({active:p=!1,children:h,disabled:b=!1,fullWidth:E=!1,href:w,icon:v,iconOnly:r=!1,iconPosition:l="left",label:u,onClick:n,target:B,type:j="button",underlined:y,...t},k)=>{let m=!!v,N=!!h;!N&&!u&&console.warn("You must provide a `label` or `children` to the `ToolbarButton` component");let{disabled:A}=X(S),s=b||A,I=i=>{if(a(t.onTouchStart)){t.onTouchStart(i);return}"ontouchstart"in document.documentElement&&a(n)&&n(i)},G=i=>{a(t.onTouchEnd)&&t.onTouchEnd(i),"ontouchstart"in document.documentElement&&!a(t.onTouchStart)&&a(n)&&i.preventDefault()},d=!x(w),g=L(`${e}-${o}__button`,d?`${e}-${o}__button__link`:"",d||y===!1?"no-underline":"","flex h-3 max-h-3 min-h-3 max-w-full items-center justify-center gap-1 rounded-xs bg-transparent p-0 text-left outline-none transition-colors duration-300 ease-out active:transition-none",E&&!r?`${e}-${o}__button--full-width w-full`:"",p&&!s?"text-dark":s?"text-disabled":"text-placeholder",b?`${e}-${o}__button--disabled cursor-not-allowed`:"cursor-pointer hover:bg-decorative-pink-90 hover:text-dark",m?`${e}-${o}__button--with-addendum ${e}-${o}__button--with-addendum-${l==="left"?"prefix":"suffix"}`:"",r?`${e}-${o}__button--icon-only px-half`:E?"":"w-fit",r?"":m?l==="left"?"pl-half pr-1":"pl-1 pr-half":"px-1",t.className),f=_("div",{className:T(`${e}-${o}__button__icon`,`${e}-${o}__button__icon--${l}`,"mt-0 flex h-3 w-3 items-center [&>svg]:h-3",d?`${e}-${o}__button__link__icon--${l}`:""),children:v}),M=q(R,{className:T(`${e}-${o}__button__label`,d?`${e}-${o}__button__link__label`:"","flex max-h-full max-w-full flex-1 items-center justify-center gap-half overflow-hidden text-ellipsis whitespace-nowrap pt-0 text-center align-middle",y===!1?"no-underline":d?"underline":"",s?`${e}-${o}__button__label--disabled cursor-not-allowed`:"cursor-pointer"),element:"div",variant:p?"body-1-median":"body-1",children:[m&&l==="left"&&f,r?!1:N?h:_("div",{className:"min-w-0 truncate",children:u}),m&&l==="right"&&f]}),c=Y(u)?u:x(u)?$(h):$(u);return d?_("a",{...t.id===void 0?{}:{id:t.id},"aria-label":c,className:g,href:w,...x(B)?{}:{target:B},title:c,...!b&&a(n)?{onClick:n}:{},...H(["className","id"],t),children:r?f:M}):_(F.Button,{...t.id===void 0?{}:{id:t.id},ref:k,"aria-label":c,className:g,...t.dir===void 0?{}:{dir:t.dir},disabled:s,title:c,type:j,onTouchEnd:G,onTouchStart:I,...a(n)?{onClick:n}:{},...H(["className","dir","id","onTouchEnd","onTouchStart"],t),children:r?f:M})});D.displayName="ToolbarButton";var et=D;export{D as a,et as b};
//# sourceMappingURL=chunk-JDQUYD4B.js.map