|
@@ -167,12 +167,17 @@ export const Slider = React.forwardRef<SliderDerivedElement, SliderProps>(({ |
|
|
tickMarkLabel.style.writingMode = 'sideways-lr'; |
|
|
tickMarkLabel.style.writingMode = 'sideways-lr'; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
console.log(tickMarkWrapper); |
|
|
|
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
}, [ref, orient, browser]); |
|
|
}, [ref, orient, browser]); |
|
|
|
|
|
|
|
|
const block = typeof length === 'string' && length.trim() === '100%'; |
|
|
const block = typeof length === 'string' && length.trim() === '100%'; |
|
|
|
|
|
const minValue = Number(min); |
|
|
|
|
|
const maxValue = Number(max); |
|
|
|
|
|
|
|
|
|
|
|
if (minValue >= maxValue) { |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<> |
|
|
<> |
|
@@ -194,7 +199,6 @@ export const Slider = React.forwardRef<SliderDerivedElement, SliderProps>(({ |
|
|
orient !== 'vertical' && 'inline-block min-h-[1rem]', |
|
|
orient !== 'vertical' && 'inline-block min-h-[1rem]', |
|
|
orient === 'vertical' && 'inline-block min-w-[1rem]', |
|
|
orient === 'vertical' && 'inline-block min-w-[1rem]', |
|
|
orient !== 'vertical' && !block && 'min-w-[16rem]', |
|
|
orient !== 'vertical' && !block && 'min-w-[16rem]', |
|
|
//orient === 'vertical' && 'inline-block min-h-[16rem] min-w-[1rem]', |
|
|
|
|
|
)} |
|
|
)} |
|
|
style={style} |
|
|
style={style} |
|
|
> |
|
|
> |
|
@@ -214,8 +218,8 @@ export const Slider = React.forwardRef<SliderDerivedElement, SliderProps>(({ |
|
|
<input |
|
|
<input |
|
|
{...etcProps} |
|
|
{...etcProps} |
|
|
ref={ref} |
|
|
ref={ref} |
|
|
min={min} |
|
|
|
|
|
max={max} |
|
|
|
|
|
|
|
|
min={minValue} |
|
|
|
|
|
max={maxValue} |
|
|
type="range" |
|
|
type="range" |
|
|
list={children ? tickMarkId : undefined} |
|
|
list={children ? tickMarkId : undefined} |
|
|
className={clsx( |
|
|
className={clsx( |
|
@@ -228,27 +232,37 @@ export const Slider = React.forwardRef<SliderDerivedElement, SliderProps>(({ |
|
|
{Array.isArray(children) && ( |
|
|
{Array.isArray(children) && ( |
|
|
<div className="select-none"> |
|
|
<div className="select-none"> |
|
|
<div className="relative w-full h-full"> |
|
|
<div className="relative w-full h-full"> |
|
|
{children.map((c) => ( |
|
|
|
|
|
<div |
|
|
|
|
|
key={c.props.value} |
|
|
|
|
|
className={clsx( |
|
|
|
|
|
styles['tick-mark'], |
|
|
|
|
|
'absolute w-full h-full box-border', |
|
|
|
|
|
)} |
|
|
|
|
|
data-offset={`${(Number(c.props.value) - Number(min)) / (Number(max) - Number(min)) * 100}%`} |
|
|
|
|
|
> |
|
|
|
|
|
<div |
|
|
|
|
|
className="flex h-full text-xs items-center justify-between" |
|
|
|
|
|
> |
|
|
|
|
|
<div |
|
|
|
|
|
className="bg-current" |
|
|
|
|
|
/> |
|
|
|
|
|
<div> |
|
|
|
|
|
{c.props.children} |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
))} |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
children |
|
|
|
|
|
.filter((c) => { |
|
|
|
|
|
const value = Number(c.props.value); |
|
|
|
|
|
return minValue <= value && value <= maxValue; |
|
|
|
|
|
}) |
|
|
|
|
|
.map((c) => { |
|
|
|
|
|
const value = Number(c.props.value); |
|
|
|
|
|
return ( |
|
|
|
|
|
<div |
|
|
|
|
|
key={c.props.value} |
|
|
|
|
|
className={clsx( |
|
|
|
|
|
styles['tick-mark'], |
|
|
|
|
|
'absolute w-full h-full box-border', |
|
|
|
|
|
)} |
|
|
|
|
|
data-offset={`${(value - minValue) / (maxValue - minValue) * 100}%`} |
|
|
|
|
|
> |
|
|
|
|
|
<div |
|
|
|
|
|
className="flex h-full text-xs items-center justify-between" |
|
|
|
|
|
> |
|
|
|
|
|
<div |
|
|
|
|
|
className="bg-current" |
|
|
|
|
|
/> |
|
|
|
|
|
<div> |
|
|
|
|
|
{c.props.children} |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
)} |
|
|
)} |
|
|