'use client' import { ark } from '@ark-ui/react/factory' import { Slider, useSliderContext } from '@ark-ui/react/slider' import type React from 'react' import { type ComponentProps, forwardRef, createContext, useContext } from 'react' import { slider } from 'styled-system/recipes' import type { RecipeVariantProps } from 'styled-system/types/recipe' // Create StyleContext for child components type SliderVariantProps = RecipeVariantProps const StyleContextInternal = createContext | null>(null) // Custom Root component that applies Panda styles while passing all props to Ark UI export const Root = forwardRef & SliderVariantProps & { colorPalette?: string }>( function SliderRoot(props, ref) { const { orientation, size, variant, colorPalette, className, ...arkProps } = props // Generate Panda CSS classes using the recipe const styles = slider({ orientation, size, variant }) // Build className with color palette and custom classes const colorPaletteClass = colorPalette ? `color-palette_${colorPalette}` : '' const combinedClassName = [styles.root, colorPaletteClass, className].filter(Boolean).join(' ') // Pass ALL props including orientation to Ark UI, and add Panda CSS classes return ( ) } ) // Create typed wrapper for each component const createStyledComponent = ( Component: typeof Slider.Control, slot: keyof ReturnType, displayName: string ) => { const StyledComponent = forwardRef>((props, ref) => { const styles = useContext(StyleContextInternal) const slotClass = styles?.[slot] const { className, ...rest } = props return }) StyledComponent.displayName = displayName return StyledComponent } export const Control = createStyledComponent(Slider.Control, 'control', 'Control') export const Track = createStyledComponent(Slider.Track, 'track', 'Track') export const Range = createStyledComponent(Slider.Range, 'range', 'Range') export const Thumb = forwardRef>((props, ref) => { const styles = useContext(StyleContextInternal) const slotClass = styles?.thumb const { className, ...rest } = props return }) Thumb.displayName = 'Thumb' // eslint-disable-next-line no-undef export const Label = forwardRef>((props, ref) => { const styles = useContext(StyleContextInternal) const slotClass = styles?.label const { className, ...rest } = props return }) Label.displayName = 'Label' export const ValueText = forwardRef>((props, ref) => { const styles = useContext(StyleContextInternal) const slotClass = styles?.valueText const { className, ...rest } = props return }) ValueText.displayName = 'ValueText' // eslint-disable-next-line no-undef export const Marker = forwardRef>((props, ref) => { const styles = useContext(StyleContextInternal) const slotClass = styles?.marker const { className, ...rest } = props return }) Marker.displayName = 'Marker' export const MarkerGroup = forwardRef>((props, ref) => { const styles = useContext(StyleContextInternal) const slotClass = styles?.markerGroup const { className, ...rest } = props return }) MarkerGroup.displayName = 'MarkerGroup' export const MarkerIndicator = forwardRef>((props, ref) => { const styles = useContext(StyleContextInternal) const slotClass = styles?.markerIndicator const { className, ...rest } = props return }) MarkerIndicator.displayName = 'MarkerIndicator' export const DraggingIndicator = forwardRef>((props, ref) => { const styles = useContext(StyleContextInternal) const slotClass = styles?.draggingIndicator const { className, ...rest } = props return }) DraggingIndicator.displayName = 'DraggingIndicator' export const HiddenInput = Slider.HiddenInput export { SliderContext as Context } from '@ark-ui/react/slider' export type RootProps = ComponentProps export type MarkerGroupProps = ComponentProps export type ThumbProps = ComponentProps export interface MarksProps extends MarkerGroupProps { marks?: Array | undefined } export const Marks = forwardRef(function Marks(props, ref) { const { marks, ...rest } = props if (!marks?.length) return null return ( {marks.map((mark, index) => { const value = typeof mark === 'number' ? mark : mark.value const label = typeof mark === 'number' ? undefined : mark.label return ( {label != null && {label}} ) })} ) }) export const Thumbs = (props: Omit) => { const slider = useSliderContext() return slider.value.map((_, index) => ( )) }