mirror of
https://github.com/hanzoai/shadcn.git
synced 2026-11-03 03:18:52 +00:00
Squash merge of shadcn-ui/ui main branch into hanzo/ui, bringing in: - [email protected] through [email protected] releases - New apps/v4 directory structure - Registry system improvements and MCP server - Framework support (Vue, Svelte, React Native) - New templates (vite-app, monorepo-next, laravel) - Zod 4 compatibility (scoped override for zod@>4) - Test fixture corrections for alias resolution All 867 merge conflicts resolved preserving Hanzo customizations. 1020/1020 shadcn tests pass.
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
"use client"
|
|
|
|
import * as React from "react"
|
|
import { Slider as SliderPrimitive } from "radix-ui"
|
|
|
|
import { cn } from "@/registry/bases/radix/lib/utils"
|
|
|
|
function Slider({
|
|
className,
|
|
defaultValue,
|
|
value,
|
|
min = 0,
|
|
max = 100,
|
|
...props
|
|
}: React.ComponentProps<typeof SliderPrimitive.Root>) {
|
|
const _values = React.useMemo(
|
|
() =>
|
|
Array.isArray(value)
|
|
? value
|
|
: Array.isArray(defaultValue)
|
|
? defaultValue
|
|
: [min, max],
|
|
[value, defaultValue, min, max]
|
|
)
|
|
|
|
return (
|
|
<SliderPrimitive.Root
|
|
data-slot="slider"
|
|
defaultValue={defaultValue}
|
|
value={value}
|
|
min={min}
|
|
max={max}
|
|
className={cn(
|
|
"cn-slider relative flex w-full touch-none items-center select-none data-disabled:opacity-50 data-vertical:h-full data-vertical:w-auto data-vertical:flex-col",
|
|
className
|
|
)}
|
|
{...props}
|
|
>
|
|
<SliderPrimitive.Track
|
|
data-slot="slider-track"
|
|
className="cn-slider-track relative grow overflow-hidden data-horizontal:w-full data-vertical:h-full"
|
|
>
|
|
<SliderPrimitive.Range
|
|
data-slot="slider-range"
|
|
className="cn-slider-range absolute select-none data-horizontal:h-full data-vertical:w-full"
|
|
/>
|
|
</SliderPrimitive.Track>
|
|
{Array.from({ length: _values.length }, (_, index) => (
|
|
<SliderPrimitive.Thumb
|
|
data-slot="slider-thumb"
|
|
key={index}
|
|
className="cn-slider-thumb block shrink-0 select-none disabled:pointer-events-none disabled:opacity-50"
|
|
/>
|
|
))}
|
|
</SliderPrimitive.Root>
|
|
)
|
|
}
|
|
|
|
export { Slider }
|