This commit is contained in:
MarkLo 2025-12-03 00:09:09 +08:00
parent 0c955d4057
commit 4f2327f5c2
3 changed files with 50 additions and 37 deletions

View File

@ -8,6 +8,9 @@ import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod"; import { zodResolver } from "@hookform/resolvers/zod";
import * as z from "zod"; import * as z from "zod";
import { format } from "date-fns"; import { format } from "date-fns";
import { CheckIcon } from "lucide-react";
import { cn } from "@/lib/utils";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { DatePicker } from "@/components/ui/date-picker"; import { DatePicker } from "@/components/ui/date-picker";
@ -154,34 +157,44 @@ export function AnalysisForm({ onSubmit, loading = false }: AnalysisFormProps) {
render={({ field }) => ( render={({ field }) => (
<FormItem> <FormItem>
<div className="grid grid-cols-2 md:grid-cols-4 gap-4"> <div className="grid grid-cols-2 md:grid-cols-4 gap-4">
{ANALYSTS.map((analyst) => ( {ANALYSTS.map((analyst) => {
<FormItem const isSelected = field.value?.includes(analyst.value);
key={analyst.value} return (
className="flex flex-row items-center space-x-3 space-y-0" <FormItem
> key={analyst.value}
<FormControl> className="space-y-0"
<Checkbox >
checked={field.value?.includes(analyst.value)} <FormControl>
onCheckedChange={(checked) => { <div
return checked onClick={() => {
? field.onChange([ const newValue = isSelected
...(field.value ?? []), ? field.value?.filter((v: string) => v !== analyst.value)
analyst.value, : [...(field.value ?? []), analyst.value];
]) field.onChange(newValue);
: field.onChange( }}
field.value?.filter( className={cn(
(value: string) => "relative flex cursor-pointer flex-row items-center gap-3 rounded-lg border-2 p-4 transition-all hover:bg-accent",
value !== analyst.value isSelected
) ? "border-primary bg-primary/5 text-primary"
); : "border-muted-foreground/25 bg-card text-muted-foreground"
}} )}
/> >
</FormControl> <div
<FormLabel className="font-normal cursor-pointer leading-none"> className={cn(
{analyst.label} "flex h-5 w-5 shrink-0 items-center justify-center rounded-sm border transition-colors",
</FormLabel> isSelected
</FormItem> ? "border-primary bg-primary text-primary-foreground"
))} : "border-muted-foreground"
)}
>
{isSelected && <CheckIcon className="h-3.5 w-3.5" />}
</div>
<span className="font-medium select-none">{analyst.label}</span>
</div>
</FormControl>
</FormItem>
);
})}
</div> </div>
<FormMessage /> <FormMessage />
</FormItem> </FormItem>

View File

@ -28,7 +28,7 @@
"react": "19.2.0", "react": "19.2.0",
"react-day-picker": "^9.11.3", "react-day-picker": "^9.11.3",
"react-dom": "19.2.0", "react-dom": "19.2.0",
"react-hook-form": "^7.66.1", "react-hook-form": "^7.67.0",
"react-markdown": "^10.1.0", "react-markdown": "^10.1.0",
"recharts": "^3.4.1", "recharts": "^3.4.1",
"rehype-raw": "^7.0.0", "rehype-raw": "^7.0.0",

View File

@ -10,7 +10,7 @@ importers:
dependencies: dependencies:
'@hookform/resolvers': '@hookform/resolvers':
specifier: ^5.2.2 specifier: ^5.2.2
version: 5.2.2(react-hook-form@7.66.1(react@19.2.0)) version: 5.2.2(react-hook-form@7.67.0(react@19.2.0))
'@radix-ui/react-checkbox': '@radix-ui/react-checkbox':
specifier: ^1.3.3 specifier: ^1.3.3
version: 1.3.3(@types/react-dom@19.2.3(@types/react@19.2.6))(@types/react@19.2.6)(react-dom@19.2.0(react@19.2.0))(react@19.2.0) version: 1.3.3(@types/react-dom@19.2.3(@types/react@19.2.6))(@types/react@19.2.6)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
@ -66,8 +66,8 @@ importers:
specifier: 19.2.0 specifier: 19.2.0
version: 19.2.0(react@19.2.0) version: 19.2.0(react@19.2.0)
react-hook-form: react-hook-form:
specifier: ^7.66.1 specifier: ^7.67.0
version: 7.66.1(react@19.2.0) version: 7.67.0(react@19.2.0)
react-markdown: react-markdown:
specifier: ^10.1.0 specifier: ^10.1.0
version: 10.1.0(@types/react@19.2.6)(react@19.2.0) version: 10.1.0(@types/react@19.2.6)(react@19.2.0)
@ -2567,8 +2567,8 @@ packages:
peerDependencies: peerDependencies:
react: ^19.2.0 react: ^19.2.0
react-hook-form@7.66.1: react-hook-form@7.67.0:
resolution: {integrity: sha512-2KnjpgG2Rhbi+CIiIBQQ9Df6sMGH5ExNyFl4Hw9qO7pIqMBR8Bvu9RQyjl3JM4vehzCh9soiNUM/xYMswb2EiA==} resolution: {integrity: sha512-E55EOwKJHHIT/I6J9DmQbCWToAYSw9nN5R57MZw9rMtjh+YQreMDxRLfdjfxQbiJ3/qbg3Z02wGzBX4M+5fMtQ==}
engines: {node: '>=18.0.0'} engines: {node: '>=18.0.0'}
peerDependencies: peerDependencies:
react: ^16.8.0 || ^17 || ^18 || ^19 react: ^16.8.0 || ^17 || ^18 || ^19
@ -3212,10 +3212,10 @@ snapshots:
'@floating-ui/utils@0.2.10': {} '@floating-ui/utils@0.2.10': {}
'@hookform/resolvers@5.2.2(react-hook-form@7.66.1(react@19.2.0))': '@hookform/resolvers@5.2.2(react-hook-form@7.67.0(react@19.2.0))':
dependencies: dependencies:
'@standard-schema/utils': 0.3.0 '@standard-schema/utils': 0.3.0
react-hook-form: 7.66.1(react@19.2.0) react-hook-form: 7.67.0(react@19.2.0)
'@humanfs/core@0.19.1': {} '@humanfs/core@0.19.1': {}
@ -5819,7 +5819,7 @@ snapshots:
react: 19.2.0 react: 19.2.0
scheduler: 0.27.0 scheduler: 0.27.0
react-hook-form@7.66.1(react@19.2.0): react-hook-form@7.67.0(react@19.2.0):
dependencies: dependencies:
react: 19.2.0 react: 19.2.0