import { useState } from 'react' import { Slider, Input, Tooltip } from '@janhq/joi' import { useClickOutside } from '@janhq/joi' import { InfoIcon } from 'lucide-react' type Props = { name: string title: string disabled: boolean description: string min: number max: number step: number value: number onValueChanged: (e: string | number | boolean) => void } const SliderRightPanel = ({ title, disabled, min, max, step, description, value, onValueChanged, }: Props) => { const [showTooltip, setShowTooltip] = useState({ max: false, min: false }) useClickOutside(() => setShowTooltip({ max: false, min: false }), null, []) return (

{title}

} content={description} />
onValueChanged?.(e[0])} min={min} max={max} step={step} disabled={disabled} />

{min}

{max}

{ if (Number(e.target.value) > Number(max)) { onValueChanged?.(Number(max)) setShowTooltip({ max: true, min: false }) } else if (Number(e.target.value) < Number(min)) { onValueChanged?.(Number(min)) setShowTooltip({ max: false, min: true }) } }} onChange={(e) => { onValueChanged?.(Number(e.target.value)) }} /> } content={ <> {showTooltip.max && ( Automatically set to the maximum allowed tokens )} {showTooltip.min && ( Automatically set to the minimum allowed tokens )} } />
) } export default SliderRightPanel