import { Slider as ChakraSlider, For, HStack } from "@chakra-ui/react"; import * as React from "react"; export interface SliderProps extends ChakraSlider.RootProps { marks?: Array; label?: React.ReactNode; showValue?: boolean; thumb?: React.ReactNode; } export const Slider = React.forwardRef( function Slider(props, ref) { const { marks: marksProp, label, showValue, thumb, ...rest } = props; const value = props.defaultValue ?? props.value; const marks = marksProp?.map((mark) => { if (typeof mark === "number") return { value: mark, label: undefined }; return mark; }); const hasMarkLabel = !!marks?.some((mark) => mark.label); return ( {label && !showValue && ( {label} )} {label && showValue && ( {label} )} ); }, ); function SliderThumbs(props: { value?: number[]; thumb?: React.ReactNode }) { const { value, thumb } = props; return ( {(_, index) => ( {thumb} )} ); } interface SliderMarksProps { marks?: Array; } const SliderMarks = React.forwardRef( function SliderMarks(props, ref) { const { marks } = 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} ); })} ); }, );