import { Carousel as ArkCarousel } from "@ark-ui/react/carousel"; import { injectComponentStyle } from "@bysages/core/styling"; import type { CSSProperties } from "react"; import type { ComponentProps } from "react"; import { iconNode } from "../../internal/icon"; import { useElementId } from "../../internal/id"; /** Ark's Carousel, dressed in the paper-and-ink system: slides ride in one * hairline-clipped lane, the triggers are quiet outline controls, and the * current indicator alone carries the ink. The API is Ark's own — Root, * Control, PrevTrigger, NextTrigger, ItemGroup, Item, IndicatorGroup, * Indicator, AutoplayTrigger, ProgressText. */ function CarouselRoot(props: ComponentProps) { injectComponentStyle("carousel"); const id = useElementId("carousel", props); return ; } type CarouselSlide = string | { label: string }; type CarouselFacadeProps = { value?: number; defaultValue?: number; items: CarouselSlide[]; spacing?: string; label?: string; className?: string; style?: CSSProperties; onValueChange?: (page: number) => void; }; /** The complete carousel behind a slide list: arrows, progress, items, and * indicators use the common lane. Custom slides remain anatomy work. */ function CarouselFacade(props: CarouselFacadeProps) { const { value, defaultValue, items, spacing, label, className, style, onValueChange } = props; const slides = items.map((item) => (typeof item === "string" ? item : item.label)); return ( onValueChange?.(event.page)} > {iconNode("chevron-left")} {iconNode("chevron-right")} {slides.map((slide, index) => ( {slide} ))} {slides.map((_, index) => ( ))} ); } export const Carousel: typeof CarouselFacade & Omit & { Root: typeof CarouselRoot } = Object.assign(CarouselFacade, { ...ArkCarousel, Root: CarouselRoot, }) as typeof CarouselFacade & Omit & { Root: typeof CarouselRoot };