stofli-ui
Version:
Biblioteca moderna de componentes UI para React con Tailwind CSS y Framer Motion
4 lines (3 loc) • 6.3 kB
JavaScript
'use client';
;var e=require("react/jsx-runtime"),r=require("react"),t=require("framer-motion"),i=require("lucide-react"),n=require("clsx"),a=require("tailwind-merge"),o=function(){return o=Object.assign||function(e){for(var r,t=1,i=arguments.length;t<i;t++)for(var n in r=arguments[t])Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n]);return e},o.apply(this,arguments)};function l(e,r,t){if(t||2===arguments.length)for(var i,n=0,a=r.length;n<a;n++)!i&&n in r||(i||(i=Array.prototype.slice.call(r,0,n)),i[n]=r[n]);return e.concat(i||Array.prototype.slice.call(r))}function s(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return a.twMerge(n.clsx(e))}"function"==typeof SuppressedError&&SuppressedError;var d=r.forwardRef((function(n,a){var d=n.children,c=n.className,u=void 0===c?"":c,g=n.variant,p=void 0===g?"default":g,h=n.size,b=void 0===h?"md":h,f=n.radius,m=void 0===f?"md":f,v=n.fullWidth,x=void 0!==v&&v,y=n.withRing,k=void 0!==y&&y,w=n.isLoading,z=void 0!==w&&w,N=n.leftIcon,j=n.rightIcon,C=n.withArrow,O=void 0!==C&&C,I=n.withRipple,R=void 0===I||I,q=n.rippleColor,A=n.rippleClassName,E=void 0===A?"":A,L=n.loaderClassName,P=void 0===L?"":L,S=n.leftIconClassName,T=void 0===S?"":S,M=n.rightIconClassName,W=void 0===M?"":M,B=n.contentClassName,D=void 0===B?"":B,F=n.arrowClassName,X=void 0===F?"":F,Y=n.disabled,G=n.onClick,H=n.loadingText,J=void 0===H?"Cargando...":H,K=n.ariaLabel,Q=n.type,U=void 0===Q?"button":Q,V=function(e,r){var t={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&r.indexOf(i)<0&&(t[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(e);n<i.length;n++)r.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(t[i[n]]=e[i[n]])}return t}(n,["children","className","variant","size","radius","fullWidth","withRing","isLoading","leftIcon","rightIcon","withArrow","withRipple","rippleColor","rippleClassName","loaderClassName","leftIconClassName","rightIconClassName","contentClassName","arrowClassName","disabled","onClick","loadingText","ariaLabel","type"]),Z=r.useState([]),$=Z[0],_=Z[1],ee=r.useRef(0),re=r.useRef(null),te=Y||z,ie=r.useId(),ne="loader-".concat(ie.replace(/:/g,""));r.useEffect((function(){if($.length>0){var e=setTimeout((function(){$.length>10?_((function(e){return e.slice(Math.floor(e.length/2))})):_([])}),800);return function(){return clearTimeout(e)}}}),[$]);var ae=s("inline-flex items-center justify-center font-medium transition-colors duration-200","link"!==p&&"ghost"!==p&&"active:shadow-inner","focus:outline-none focus:ring-0","link"!==p&&"ghost"!==p&&"focus-visible:ring-2 focus-visible:ring-offset-2","disabled:opacity-50 disabled:cursor-not-allowed",{default:"bg-zinc-600 text-neutral-50 dark:bg-zinc-800 dark:text-neutral-200 hover:bg-zinc-700 dark:hover:bg-zinc-600 focus:ring-zinc-500",primary:"bg-blue-600 text-white dark:bg-blue-800 hover:bg-blue-700 dark:hover:bg-blue-500 focus:ring-blue-400",secondary:"bg-purple-600 text-white dark:bg-purple-800 hover:bg-purple-700 dark:hover:bg-purple-500 focus:ring-purple-400",success:"bg-green-600 text-white dark:bg-green-800 hover:bg-green-700 dark:hover:bg-green-500 focus:ring-green-400",warning:"bg-amber-600 text-white dark:bg-amber-800 hover:bg-amber-700 dark:hover:bg-amber-500 focus:ring-amber-400",danger:"bg-red-600 text-white dark:bg-red-800 hover:bg-red-700 dark:hover:bg-red-500 focus:ring-red-400",outline:"bg-transparent border-2 border-zinc-300 hover:bg-zinc-100 dark:border-zinc-600 dark:hover:bg-zinc-800 text-neutral-900 dark:text-neutral-100",ghost:"bg-transparent border-0 hover:bg-zinc-100 dark:hover:bg-zinc-800 text-neutral-900 dark:text-neutral-100",link:"bg-transparent border-0 underline-offset-4 hover:underline text-neutral-900 dark:text-neutral-100 hover:bg-transparent dark:hover:bg-transparent p-0 h-auto"}[p],{xs:"text-xs px-2.5 py-1.5",sm:"text-sm px-3 py-2",md:"text-sm px-4 py-2",lg:"text-base px-5 py-2.5",xl:"text-lg px-6 py-3",icon:"p-2"}[b],{none:"rounded-none",sm:"rounded-[0.25rem]",md:"rounded-[0.375rem]",lg:"rounded-lg",full:"rounded-full"}[m],x&&"w-full",k&&"link"!==p&&"ghost"!==p&&"ring-1 ring-black ring-opacity-5 dark:ring-white dark:ring-opacity-10","relative overflow-hidden",O&&"group",u),oe=Object.fromEntries(Object.entries(V).filter((function(e){return!e[0].startsWith("onDrag")}))),le=s("absolute rounded-full pointer-events-none",!q&&("outline"===p||"ghost"===p||"link"===p?"bg-zinc-500 dark:bg-zinc-200 opacity-15":"bg-white dark:bg-zinc-200 opacity-35"));return e.jsxs(t.motion.button,o({ref:function(e){"function"==typeof a?a(e):a&&(a.current=e),re.current=e},className:ae,whileTap:te||"link"===p||"ghost"===p?void 0:{scale:.97},transition:{duration:.08},disabled:te,onClick:function(e){if(!te&&R){var r=re.current;if(r){var t=r.getBoundingClientRect(),i=e.clientX-t.left,n=e.clientY-t.top,a=2*Math.max(t.width,t.height),o={id:ee.current,x:i,y:n,size:a};ee.current+=1,_((function(e){return l(l([],e,!0),[o],!1)}))}}G&&G(e)},type:U,role:"button","aria-disabled":te,"aria-label":z?J:K||("string"==typeof d?d:void 0),"aria-busy":z,"aria-live":z?"polite":void 0},oe,{children:[e.jsx(t.AnimatePresence,{children:R&&$.map((function(r){return e.jsx(t.motion.span,{className:s(le,E),style:{left:r.x-r.size/2,top:r.y-r.size/2,width:r.size,height:r.size,backgroundColor:q,opacity:q?.25:void 0},initial:{opacity:q||"outline"===p||"ghost"===p||"link"===p?.25:.35,scale:0,zIndex:1},animate:{opacity:0,scale:1},exit:{opacity:0},transition:{duration:.75,ease:"easeOut"},"aria-hidden":"true"},r.id)}))}),z&&e.jsxs(e.Fragment,{children:[e.jsx(i.Loader2,{className:s("mr-2 h-4 w-4 animate-spin",P),"aria-hidden":"true"}),e.jsx("span",{className:"sr-only",role:"status",id:ne,children:J})]}),!z&&N&&e.jsx("span",{className:s("mr-2 relative z-10",T),"aria-hidden":"true",children:N}),e.jsx("span",{className:s("relative z-10",(O||j)&&"mr-1",D),children:d}),!z&&O&&e.jsx("span",{className:s("ml-1 relative z-10 transition-transform duration-200 group-hover:translate-x-1",X),"aria-hidden":"true",children:e.jsx(i.ArrowRight,{className:"h-4 w-4"})}),!z&&j&&!O&&e.jsx("span",{className:s("ml-2 relative z-10",W),"aria-hidden":"true",children:j})]}))}));d.displayName="Button",module.exports=d;
//# sourceMappingURL=index.js.map