import classNames from "@calcom/ui/classNames"; export type SegmentedControlData = T | { value: T; label: string }; export interface SegmentedControlProps { data: SegmentedControlData[]; value: T; onChange: (value: T) => void; disabled?: boolean; className?: string; "data-testid"?: string; } const SegmentedControl = function ({ data, value, onChange, disabled = false, className, "data-testid": dataTestId, ...props }: SegmentedControlProps) { const handleChange = (newValue: T) => { if (!disabled) { onChange(newValue); } }; return (
{data.map((item, idx) => { const itemValue = typeof item === "string" ? item : item.value; const itemLabel = typeof item === "string" ? item : item.label; const isActive = value === itemValue; const inputId = `segmented-control-${itemValue}-${idx}`; return ( ); })}
); }; export default SegmentedControl;