{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "slider",
  "type": "registry:ui",
  "title": "Slider",
  "description": "An accessible slider built on Radix UI.",
  "dependencies": [
    "@radix-ui/react-slider@^1.3.6",
    "class-variance-authority@^0.7.1"
  ],
  "registryDependencies": [
    "https://wideset.co/r/motion.json",
    "https://wideset.co/r/styles.json",
    "https://wideset.co/r/tooltip.json",
    "https://wideset.co/r/utils.json"
  ],
  "files": [
    {
      "path": "src/components/slider/Slider.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/slider/Slider.tsx",
      "content": "'use client';\n\nimport * as SliderPrimitive from '@radix-ui/react-slider';\nimport React, { useState } from 'react';\nimport { cn } from '@/lib/wideset/utils';\n\nimport type { SliderProps, SliderWithVariants } from './Slider.types';\nimport { SliderLabel } from './SliderLabel';\nimport { SliderThumb } from './SliderThumb';\n\nconst Slider = React.forwardRef<HTMLDivElement, SliderProps>(\n  (\n    {\n      className,\n      children,\n      type,\n      min = 0,\n      max = 100,\n      value,\n      defaultValue,\n      onValueChange,\n      step = 1,\n      labels,\n      showTooltipValue,\n      defaultMotion,\n      thumbAriaLabels,\n      'aria-label': ariaLabel,\n      'aria-labelledby': ariaLabelledby,\n      ...props\n    },\n    ref,\n  ) => {\n    const computedDefaultValue = defaultValue ?? (type === 'range' ? [min, max] : [min]);\n    const [internalValue, setInternalValue] = useState<number[]>(value ?? computedDefaultValue);\n\n    const currentValue = value ?? internalValue;\n\n    const handleValueChange = (newValue: number[]) => {\n      setInternalValue(newValue);\n      onValueChange?.(newValue);\n    };\n\n    const getThumbLabel = (index: number) => {\n      const own = thumbAriaLabels?.[index];\n      if (own) return own;\n      if (currentValue.length < 2) return ariaLabel;\n      // Two thumbs under one name: prefix it so each thumb is still told apart.\n      const endpoint = index === 0 ? 'Minimum' : 'Maximum';\n      return ariaLabel ? `${endpoint} ${ariaLabel}` : endpoint;\n    };\n\n    const isLeftLabelVisible = labels === 'left' || labels === 'side';\n    const isRightLabelVisible = labels === 'right' || labels === 'side';\n    const isSideLayout = labels === 'left' || labels === 'right' || labels === 'side';\n\n    return (\n      <div\n        ref={ref}\n        data-slot=\"slider\"\n        className={cn(isSideLayout && 'gap-ws-9 flex items-center', className)}\n      >\n        {isLeftLabelVisible && <SliderLabel>{min}</SliderLabel>}\n        <div className=\"w-full\">\n          <SliderPrimitive.Root\n            className={cn(\n              'h-ws-3 relative flex w-full touch-none items-center select-none',\n              // Expands the click-to-seek target to the 24px WCAG 2.5.8 minimum\n              // without adding to the layout box, which Figma pins to the track height.\n              'before:-inset-y-ws-6 before:absolute before:inset-x-0 before:content-[\"\"]',\n            )}\n            min={min}\n            max={max}\n            value={value}\n            defaultValue={computedDefaultValue}\n            onValueChange={handleValueChange}\n            step={step}\n            {...props}\n          >\n            <SliderPrimitive.Track className=\"rounded-ws-control-full bg-ws-static-alpha-strong h-ws-3 relative w-full grow overflow-hidden\">\n              <SliderPrimitive.Range\n                className={cn(\n                  'absolute h-full',\n                  props.disabled\n                    ? 'bg-ws-dynamic-primary-disabled'\n                    : 'bg-ws-dynamic-primary-default',\n                )}\n              />\n            </SliderPrimitive.Track>\n            {currentValue.map((thumbValue, index) => (\n              <SliderThumb\n                key={index}\n                value={thumbValue}\n                showTooltipValue={showTooltipValue}\n                aria-label={getThumbLabel(index)}\n                aria-labelledby={ariaLabelledby}\n                defaultMotion={defaultMotion}\n              />\n            ))}\n            {children}\n          </SliderPrimitive.Root>\n          {labels === 'bottom' && (\n            <div className=\"pt-ws-8 flex justify-between\">\n              <SliderLabel>{min}</SliderLabel>\n              <SliderLabel>{max}</SliderLabel>\n            </div>\n          )}\n        </div>\n        {isRightLabelVisible && <SliderLabel>{max}</SliderLabel>}\n      </div>\n    );\n  },\n) as SliderWithVariants;\n\nSlider.displayName = 'Slider';\nSlider.Label = SliderLabel;\n\nexport { Slider };\n"
    },
    {
      "path": "src/components/slider/Slider.types.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/slider/Slider.types.ts",
      "content": "import type * as SliderPrimitive from '@radix-ui/react-slider';\nimport type React from 'react';\n\nimport type { MotionProps } from '@/lib/wideset/motion/Motion.types';\nimport type { SliderLabel } from './SliderLabel';\n\n/** The text label associated with `Slider`. */\nexport type SliderLabelProps = React.HTMLAttributes<HTMLSpanElement>;\n\nexport type SliderTooltipPosition = 'top' | 'right' | 'bottom' | 'left';\n\nexport type ShowTooltipValue = boolean | SliderTooltipPosition;\n\n/** A draggable thumb with an optional value tooltip. */\nexport type SliderThumbProps = MotionProps &\n  Pick<React.AriaAttributes, 'aria-label' | 'aria-labelledby'> & {\n    /** Numeric value displayed in this thumb tooltip. */\n    value?: number;\n    /** Show tooltip with current value */\n    showTooltipValue?: ShowTooltipValue;\n  };\n\n/** A single value or range selected along a track. */\nexport type SliderProps = React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root> &\n  MotionProps & {\n    /** @deprecated The value's length sets the number of thumbs. */\n    type?: 'single' | 'range';\n    /** @deprecated Compose `Slider.Label` next to the slider. */\n    labels?: 'left' | 'right' | 'side' | 'bottom';\n    /** Show tooltip with current value */\n    showTooltipValue?: ShowTooltipValue;\n    /** Accessible name of the thumbs. A range prefixes it with `Minimum` / `Maximum` per thumb. */\n    'aria-label'?: string;\n    /** Id of the label that names the thumbs. */\n    'aria-labelledby'?: string;\n    /** Accessible name per thumb, in order, e.g. `['Minimum price', 'Maximum price']`. */\n    thumbAriaLabels?: string[];\n    /** Content rendered inside the slider, after the thumbs. */\n    children?: React.ReactNode;\n  };\n\nexport type SliderWithVariants = React.ForwardRefExoticComponent<\n  React.PropsWithoutRef<SliderProps> & React.RefAttributes<HTMLDivElement>\n> & {\n  Label: typeof SliderLabel;\n};\n"
    },
    {
      "path": "src/components/slider/Slider.variants.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/slider/Slider.variants.ts",
      "content": "import { cva } from 'class-variance-authority';\n\nimport { hoverTintMotion } from '@/lib/wideset/motion/recipes';\n\nexport const sliderThumbMotionVariants = cva('', {\n  variants: {\n    enabled: { true: hoverTintMotion, false: '' },\n  },\n  defaultVariants: { enabled: true },\n});\n"
    },
    {
      "path": "src/components/slider/SliderLabel.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/slider/SliderLabel.tsx",
      "content": "'use client';\n\nimport * as React from 'react';\nimport { cn } from '@/lib/wideset/utils';\n\nimport type { SliderLabelProps } from './Slider.types';\n\nexport const SliderLabel = React.forwardRef<HTMLSpanElement, SliderLabelProps>(\n  ({ children, className, ...props }, ref) => {\n    return (\n      <span\n        ref={ref}\n        className={cn('text-ws-static-subtle typography-number-sm', className)}\n        data-slot=\"slider-label\"\n        {...props}\n      >\n        {children}\n      </span>\n    );\n  },\n);\n\nSliderLabel.displayName = 'Slider.Label';\n"
    },
    {
      "path": "src/components/slider/SliderThumb.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/slider/SliderThumb.tsx",
      "content": "'use client';\n\nimport * as SliderPrimitive from '@radix-ui/react-slider';\nimport { type PointerEvent, useId, useRef, useState } from 'react';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { useDefaultMotion } from '@/lib/wideset/motion/MotionProvider';\nimport { Tooltip } from '../tooltip/Tooltip';\nimport type { SliderThumbProps, SliderTooltipPosition } from './Slider.types';\nimport { sliderThumbMotionVariants } from './Slider.variants';\n\n// Figma draws the control as a 19x12 frame with a 2px OUTSIDE stroke, so the outer\n// contour is 23x16 with radius 6 + 2 = 8. CSS radius describes the outer contour, so\n// rounded-ws-control-lg (8px) is what reproduces it — it also leaves the inner edge at\n// 8 - 2 = 6px, matching the frame's own cornerRadius.\nconst thumbClassName = cn(\n  'group shadow-ws-controls-control rounded-ws-control-lg h-ws-9 px-ws-4 py-ws-2 flex w-[23px] items-center justify-center',\n  'border-ws-dynamic-primary-default bg-ws-static-foreground border-2',\n  'hover:border-ws-dynamic-primary-hover active:border-ws-dynamic-primary-strong-default',\n  'cursor-pointer outline-2 outline-offset-2 outline-transparent',\n  'data-disabled:border-ws-dynamic-secondary-default data-disabled:pointer-events-none',\n);\n\nconst focusVisibleClassName =\n  'border-ws-dynamic-primary-strong-default outline-ws-dynamic-primary-strong-default select-none';\n\n// Mirrors Figma's `Lines` frame: 7x4, three 1x4 lines separated by 2px.\n// Drawn as one crispEdges SVG rather than three 1px boxes — independently rasterized\n// hairlines land on different subpixel offsets under browser zoom or a 1x display and\n// then render at visibly different thicknesses.\nconst ThumbDots = () => (\n  <svg\n    aria-hidden\n    width={7}\n    height={4}\n    viewBox=\"0 0 7 4\"\n    shapeRendering=\"crispEdges\"\n    className=\"fill-[var(--ws-dynamic-stroke-primary-default)] group-data-disabled:hidden\"\n  >\n    {[0, 3, 6].map((x) => (\n      <rect key={x} x={x} y={0} width={1} height={4} />\n    ))}\n  </svg>\n);\n\nconst getTooltipSide = (\n  showTooltipValue: SliderThumbProps['showTooltipValue'],\n): SliderTooltipPosition => (typeof showTooltipValue === 'string' ? showTooltipValue : 'top');\n\nexport const SliderThumb = ({\n  value,\n  showTooltipValue,\n  defaultMotion,\n  'aria-label': ariaLabel,\n  'aria-labelledby': ariaLabelledby,\n}: SliderThumbProps) => {\n  const motion = useDefaultMotion(defaultMotion);\n  const thumbId = useId();\n  const labelledBy = ariaLabelledby && ariaLabel ? `${ariaLabelledby} ${thumbId}` : ariaLabelledby;\n  const [isDragging, setIsDragging] = useState(false);\n  const [isFocused, setIsFocused] = useState(false);\n  const [isFocusVisible, setIsFocusVisible] = useState(false);\n  const isPointerFocusRef = useRef(false);\n\n  const handlePointerDown = (e: PointerEvent<HTMLSpanElement>) => {\n    e.currentTarget.setPointerCapture(e.pointerId);\n    setIsDragging(true);\n    isPointerFocusRef.current = true;\n  };\n\n  const handleFocus = () => {\n    setIsFocused(true);\n    setIsFocusVisible(!isPointerFocusRef.current);\n  };\n\n  const handleBlur = () => {\n    setIsFocused(false);\n    setIsFocusVisible(false);\n    isPointerFocusRef.current = false;\n  };\n\n  const className = cn(\n    thumbClassName,\n    sliderThumbMotionVariants({ enabled: motion }),\n    isFocusVisible && focusVisibleClassName,\n  );\n\n  const thumb = (\n    <SliderPrimitive.Thumb\n      className={className}\n      id={labelledBy === ariaLabelledby ? undefined : thumbId}\n      data-slot=\"slider-thumb\"\n      aria-label={ariaLabel}\n      aria-labelledby={labelledBy}\n      onPointerDown={\n        showTooltipValue ? handlePointerDown : () => (isPointerFocusRef.current = true)\n      }\n      onLostPointerCapture={showTooltipValue ? () => setIsDragging(false) : undefined}\n      onFocus={handleFocus}\n      onBlur={handleBlur}\n    >\n      <ThumbDots />\n    </SliderPrimitive.Thumb>\n  );\n\n  if (!showTooltipValue) {\n    return thumb;\n  }\n\n  return (\n    <Tooltip\n      open={isDragging || isFocused}\n      arrow={false}\n      variant=\"inverse\"\n      delayDuration={0}\n      defaultMotion={motion}\n    >\n      <Tooltip.Trigger asChild>{thumb}</Tooltip.Trigger>\n      <Tooltip.Content side={getTooltipSide(showTooltipValue)} className=\"m-ws-2 px-ws-3 py-ws-2\">\n        <Tooltip.Label>{value}</Tooltip.Label>\n      </Tooltip.Content>\n    </Tooltip>\n  );\n};\n\nSliderThumb.displayName = 'Slider.Thumb';\n"
    }
  ],
  "meta": {
    "version": "1.0.0",
    "commit": "8bb3627"
  }
}
