@szum-tech/design-system
Version:
Szum-Tech design system with tailwindcss support
3 lines (2 loc) • 4.29 kB
JavaScript
"use client";
'use strict';var chunkVJOV24EO_cjs=require('../../chunk-VJOV24EO.cjs');require('../../chunk-FC6LMBMW.cjs'),require('../../chunk-MZSK7XYX.cjs');var chunkD5PAWOAZ_cjs=require('../../chunk-D5PAWOAZ.cjs'),a=require('react'),I=require('embla-carousel-react'),classVarianceAuthority=require('class-variance-authority'),jsxRuntime=require('react/jsx-runtime'),lucideReact=require('lucide-react');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var a__namespace=/*#__PURE__*/_interopNamespace(a);var I__default=/*#__PURE__*/_interopDefault(I);var v=a__namespace.createContext(null);function l(){let e=a__namespace.useContext(v);if(!e)throw new Error("useCarousel must be used within a <Carousel />");return e}var d=classVarianceAuthority.cva("relative",{variants:{orientation:{horizontal:"",vertical:""}},defaultVariants:{orientation:"horizontal"}}),R=classVarianceAuthority.cva("flex",{variants:{orientation:{horizontal:"-ml-4",vertical:"-mt-4 flex-col"}},defaultVariants:{orientation:"horizontal"}}),b=classVarianceAuthority.cva("min-w-0 shrink-0 grow-0 basis-full",{variants:{orientation:{horizontal:"pl-4",vertical:"pt-4"}},defaultVariants:{orientation:"horizontal"}});function G({orientation:e="horizontal",opts:t,setApi:r,plugins:n,className:u,children:c,...m}){let[S,o]=I__default.default({...t,axis:e==="horizontal"?"x":"y"},n),[g,w]=a__namespace.useState(false),[E,k]=a__namespace.useState(false),i=a__namespace.useCallback(s=>{s&&(w(s.canScrollPrev()),k(s.canScrollNext()));},[]),x=a__namespace.useCallback(()=>{o?.scrollPrev();},[o]),P=a__namespace.useCallback(()=>{o?.scrollNext();},[o]),A=a__namespace.useCallback(s=>{s.key==="ArrowLeft"?(s.preventDefault(),x()):s.key==="ArrowRight"&&(s.preventDefault(),P());},[x,P]);return a__namespace.useEffect(()=>{!o||!r||r(o);},[o,r]),a__namespace.useEffect(()=>{if(o)return i(o),o.on("reInit",i),o.on("select",i),()=>{o?.off("reInit",i),o?.off("select",i);}},[o,i]),jsxRuntime.jsx(v.Provider,{value:{carouselRef:S,api:o,opts:t,orientation:e||(t?.axis==="y"?"vertical":"horizontal"),scrollPrev:x,scrollNext:P,canScrollPrev:g,canScrollNext:E},children:jsxRuntime.jsx("div",{onKeyDownCapture:A,className:d({orientation:e,className:u}),role:"region","aria-roledescription":"carousel","data-slot":"carousel",...m,children:c})})}function Y({className:e,...t}){let{carouselRef:r,orientation:n}=l();return jsxRuntime.jsx("div",{ref:r,className:"overflow-hidden","data-slot":"carousel-content",children:jsxRuntime.jsx("div",{className:R({orientation:n,className:e}),...t})})}function eo({className:e,...t}){let{orientation:r}=l();return jsxRuntime.jsx("div",{role:"group","aria-roledescription":"slide","data-slot":"carousel-item",className:chunkD5PAWOAZ_cjs.a(b({orientation:r,className:e})),...t})}function io({className:e,variant:t="outline",size:r="icon",...n}){let{orientation:u,scrollPrev:c,canScrollPrev:m}=l();return jsxRuntime.jsxs(chunkVJOV24EO_cjs.a,{"data-slot":"carousel-previous",variant:t,size:r,className:chunkD5PAWOAZ_cjs.a("absolute size-8 rounded-full",u==="horizontal"?"top-1/2 -left-12 -translate-y-1/2":"-top-12 left-1/2 -translate-x-1/2 rotate-90",e),disabled:!m,onClick:c,...n,children:[jsxRuntime.jsx(lucideReact.ArrowLeft,{}),jsxRuntime.jsx("span",{className:"sr-only",children:"Previous slide"})]})}function xo({className:e,variant:t="outline",size:r="icon",...n}){let{orientation:u,scrollNext:c,canScrollNext:m}=l();return jsxRuntime.jsxs(chunkVJOV24EO_cjs.a,{"data-slot":"carousel-next",variant:t,size:r,className:chunkD5PAWOAZ_cjs.a("absolute size-8 rounded-full",u==="horizontal"?"top-1/2 -right-12 -translate-y-1/2":"-bottom-12 left-1/2 -translate-x-1/2 rotate-90",e),disabled:!m,onClick:c,...n,children:[jsxRuntime.jsx(lucideReact.ArrowRight,{}),jsxRuntime.jsx("span",{className:"sr-only",children:"Next slide"})]})}exports.Carousel=G;exports.CarouselContent=Y;exports.CarouselContext=v;exports.CarouselItem=eo;exports.CarouselNext=xo;exports.CarouselPrevious=io;exports.useCarousel=l;