mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-15 01:21:48 +03:00
9522d6b71f
Issue: https://github.com/StanGirard/quivr/issues/1647 - Refactor brain management page settings tabs hooks: use context - Fix brain status change Demo: https://github.com/StanGirard/quivr/assets/63923024/073be02f-394c-4887-8572-ff293792c023
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import { forwardRef } from "react";
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
type RadioItem = {
|
|
value: string;
|
|
label: string;
|
|
};
|
|
|
|
interface RadioProps {
|
|
name: string;
|
|
items: RadioItem[];
|
|
label?: string;
|
|
className?: string;
|
|
}
|
|
|
|
export const Radio = forwardRef<HTMLInputElement, RadioProps>(
|
|
({ items, label, className, ...props }, ref) => (
|
|
<div className={cn("flex flex-col", className)}>
|
|
{label !== undefined && (
|
|
<label className="text-sm font-medium leading-6 mb-2">{label}</label>
|
|
)}
|
|
<div className="flex flex-row gap-4">
|
|
{items.map((item) => (
|
|
<div key={item.value} className="flex items-center mb-2">
|
|
<input
|
|
ref={ref} // Forward the ref to the input element
|
|
type="radio"
|
|
className="form-radio h-4 w-4 text-indigo-600 border-indigo-600"
|
|
value={item.value}
|
|
{...props}
|
|
/>
|
|
<label className="ml-2" htmlFor={item.value}>
|
|
{item.label}
|
|
</label>
|
|
</div>
|
|
))}
|
|
</div>
|
|
</div>
|
|
)
|
|
);
|
|
|
|
Radio.displayName = "Radio";
|