()
| 29 | const CarouselContext = React.createContext<CarouselContextProps | null>(null); |
| 30 | |
| 31 | function useCarousel() { |
| 32 | const context = React.useContext(CarouselContext); |
| 33 | |
| 34 | if (!context) { |
| 35 | throw new Error("useCarousel must be used within a <Carousel />"); |
| 36 | } |
| 37 | |
| 38 | return context; |
| 39 | } |
| 40 | |
| 41 | const Carousel = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement> & CarouselProps>( |
| 42 | ({ orientation = "horizontal", opts, setApi, plugins, className, children, ...props }, ref) => { |