feat(frontend): add shadcn ui primitives and compatibility bridge

This commit is contained in:
Sagit
2026-02-19 05:14:42 +00:00
parent c5124a01e6
commit 12c50df6a7
43 changed files with 2839 additions and 0 deletions
@@ -0,0 +1,63 @@
import * as React from "react";
import { RadioGroup as BaseRadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
import { Label } from "@/components/ui/label";
import { cn } from "@/lib/utils";
interface RadioContextValue {
name: string;
}
const RadioContext = React.createContext<RadioContextValue>({ name: "radio-group" });
export interface RadioGroupProps {
children: React.ReactNode;
label?: React.ReactNode;
onValueChange?: (value: string) => void;
orientation?: "horizontal" | "vertical";
value?: string;
}
export function RadioGroup({
children,
label,
onValueChange,
orientation = "vertical",
value,
}: RadioGroupProps) {
const generatedName = React.useId();
return (
<div className="space-y-2">
{label ? <p className="text-sm font-medium">{label}</p> : null}
<RadioContext.Provider value={{ name: generatedName }}>
<BaseRadioGroup
className={cn(
orientation === "horizontal" ? "flex flex-wrap items-center gap-4" : "grid gap-3",
)}
value={value}
onValueChange={onValueChange}
>
{children}
</BaseRadioGroup>
</RadioContext.Provider>
</div>
);
}
export interface RadioProps {
children?: React.ReactNode;
value: string;
}
export function Radio({ children, value }: RadioProps) {
const context = React.useContext(RadioContext);
const id = `${context.name}-${value}`;
return (
<div className="flex items-center gap-2">
<RadioGroupItem id={id} value={value} />
<Label htmlFor={id}>{children}</Label>
</div>
);
}