"use client"; import * as Popover from "@radix-ui/react-popover"; import { useState } from "react"; import { Badge, Button } from "@calcom/ui"; import { inputStyles, TextField } from "../inputs/TextField"; import { Slider } from "./index"; interface RangeSliderPopoverProps { triggerText: string; value: number[]; onChange: (value: number[]) => void; min: number; max: number; step?: number; badgeVariant?: "default" | "success" | "gray" | "warning" | "orange" | "red"; badgeSuffix?: string; inputSuffix?: string; inputLeading?: string; } export const RangeSliderPopover = ({ triggerText, value, onChange, min, max, step = 1, badgeVariant = "default", badgeSuffix, inputSuffix, inputLeading, }: RangeSliderPopoverProps) => { const [internalValue, setInternalValue] = useState(value); const [open, setOpen] = useState(false); const handleReset = () => { setInternalValue([min, max]); }; const handleApply = () => { onChange(internalValue); setOpen(false); }; return (
{ const newValue = parseInt(e.target.value); if (!isNaN(newValue) && newValue >= min && newValue <= internalValue[1]) { setInternalValue([newValue, internalValue[1]]); } }} addOnLeading={inputLeading ? inputLeading : undefined} addOnSuffix={inputSuffix ? inputSuffix : undefined} containerClassName="w-full" /> { const newValue = parseInt(e.target.value); if (!isNaN(newValue) && newValue >= internalValue[0] && newValue <= max) { setInternalValue([internalValue[0], newValue]); } }} addOnLeading={inputLeading ? inputLeading : undefined} addOnSuffix={inputSuffix ? inputSuffix : undefined} containerClassName="w-full" />

); };