'use client'; import { createSlider } from '@gluestack-ui/core/slider/creator'; import type { VariantProps } from '@gluestack-ui/utils/nativewind-utils'; import { tva, useStyleContext, withStyleContext } from '@gluestack-ui/utils/nativewind-utils'; import { styled } from 'nativewind'; import React from 'react'; import { Pressable, View } from 'react-native'; const SCOPE = 'SLIDER'; const Root = withStyleContext(View, SCOPE); export const UISlider = createSlider({ Root: Root, Thumb: View, Track: Pressable, FilledTrack: View, ThumbInteraction: View, }); const StyledTrack = styled(UISlider.Track, { className: 'style', }); const sliderStyle = tva({ base: 'justify-center items-center data-[disabled=true]:opacity-40 data-[disabled=true]:web:pointer-events-none', variants: { orientation: { horizontal: 'w-full', vertical: 'h-full', }, isReversed: { true: '', false: '', }, }, }); const sliderThumbStyle = tva({ base: 'bg-white border border-primary ring-ring/50 absolute rounded-full shadow-sm transition-[color,box-shadow] data-[hover=true]:ring-4 data-[focus-visible=true]:ring-4 data-[focus-visible=true]:outline-hidden disabled:pointer-events-none disabled:opacity-50 web:cursor-pointer h-4 w-4', }); const sliderTrackStyle = tva({ base: 'bg-muted rounded-full overflow-hidden', parentVariants: { orientation: { horizontal: 'w-full h-1.5 flex-row', vertical: 'h-full w-1.5 flex-col-reverse', }, isReversed: { true: '', false: '', }, }, parentCompoundVariants: [ { orientation: 'horizontal', isReversed: true, class: 'flex-row-reverse', }, { orientation: 'vertical', isReversed: true, class: 'flex-col', }, ], }); const sliderFilledTrackStyle = tva({ base: 'bg-primary', parentVariants: { orientation: { horizontal: 'h-full', vertical: 'w-full', }, }, }); type ISliderProps = React.ComponentProps & VariantProps; const Slider = React.forwardRef< React.ComponentRef, ISliderProps >(function Slider( { className, orientation = 'horizontal', isReversed = false, ...props }, ref ) { return ( ); }); type ISliderThumbProps = React.ComponentProps & VariantProps; const SliderThumb = React.forwardRef< React.ComponentRef, ISliderThumbProps >(function SliderThumb({ className, ...props }, ref) { return ( ); }); type ISliderTrackProps = React.ComponentProps & VariantProps; const SliderTrack = React.forwardRef< React.ComponentRef, ISliderTrackProps >(function SliderTrack({ className, ...props }, ref) { const { orientation: parentOrientation, isReversed, } = useStyleContext(SCOPE); return ( ); }); type ISliderFilledTrackProps = React.ComponentProps< typeof UISlider.FilledTrack > & VariantProps; const SliderFilledTrack = React.forwardRef< React.ComponentRef, ISliderFilledTrackProps >(function SliderFilledTrack({ className, ...props }, ref) { const { orientation: parentOrientation } = useStyleContext(SCOPE); return ( ); }); export { Slider, SliderFilledTrack, SliderThumb, SliderTrack };