|
1 | | -import { FormField, FormItem, FormLabel } from "@/components/ui/form.tsx"; |
| 1 | +import { FormField, FormFieldItem, FormFieldLabel } from "@/components/ui/form.tsx"; |
2 | 2 | import { Input } from "@/components/ui/input.tsx"; |
3 | 3 | import { FormSchema } from "@/types/schema.ts"; |
| 4 | +import { ChevronDown, ChevronUp, Settings } from "lucide-react"; |
| 5 | +import { Fragment, useState } from "react"; |
4 | 6 | import { FormProvider, UseFormReturn } from "react-hook-form"; |
5 | 7 | import { useTranslation } from "react-i18next"; |
| 8 | +import { Button } from "../ui/button"; |
6 | 9 |
|
7 | 10 | export function OptionalClassFormField({ form }: Readonly<{ form: UseFormReturn<FormSchema> }>) { |
8 | 11 | const { t } = useTranslation(); |
| 12 | + const [showAdvanced, setShowAdvanced] = useState(false); |
9 | 13 | return ( |
10 | | - <FormProvider {...form}> |
11 | | - <FormField |
12 | | - control={form.control} |
13 | | - name="shellClassName" |
14 | | - render={({ field }) => ( |
15 | | - <FormItem className="gap-1"> |
16 | | - <FormLabel className="h-6 flex items-center gap-1"> |
17 | | - {t("mainConfig.shellClassName")} {t("optional")} |
18 | | - </FormLabel> |
19 | | - <Input id="shellClassName" {...field} placeholder={t("placeholders.input")} className="h-8" /> |
20 | | - </FormItem> |
21 | | - )} |
22 | | - /> |
23 | | - <FormField |
24 | | - control={form.control} |
25 | | - name="injectorClassName" |
26 | | - render={({ field }) => ( |
27 | | - <FormItem className="gap-1"> |
28 | | - <FormLabel className="h-6 flex items-center gap-1"> |
29 | | - {t("mainConfig.injectorClassName")} {t("optional")} |
30 | | - </FormLabel> |
31 | | - <Input id="injectorClassName" {...field} placeholder={t("placeholders.input")} className="h-8" /> |
32 | | - </FormItem> |
33 | | - )} |
34 | | - /> |
35 | | - </FormProvider> |
| 14 | + <Fragment> |
| 15 | + <div className="pt-2"> |
| 16 | + <Button |
| 17 | + type="button" |
| 18 | + variant="outline" |
| 19 | + size="sm" |
| 20 | + onClick={() => setShowAdvanced(!showAdvanced)} |
| 21 | + className="flex items-center gap-2" |
| 22 | + > |
| 23 | + <Settings className="h-4 w-4" /> |
| 24 | + {t("classNameOptions")} |
| 25 | + {showAdvanced ? <ChevronUp className="h-4 w-4" /> : <ChevronDown className="h-4 w-4" />} |
| 26 | + </Button> |
| 27 | + </div> |
| 28 | + {showAdvanced && ( |
| 29 | + <FormProvider {...form}> |
| 30 | + <FormField |
| 31 | + control={form.control} |
| 32 | + name="shellClassName" |
| 33 | + render={({ field }) => ( |
| 34 | + <FormFieldItem> |
| 35 | + <FormFieldLabel> |
| 36 | + {t("mainConfig.shellClassName")} {t("optional")} |
| 37 | + </FormFieldLabel> |
| 38 | + <Input id="shellClassName" {...field} placeholder={t("placeholders.input")} /> |
| 39 | + </FormFieldItem> |
| 40 | + )} |
| 41 | + /> |
| 42 | + <FormField |
| 43 | + control={form.control} |
| 44 | + name="injectorClassName" |
| 45 | + render={({ field }) => ( |
| 46 | + <FormFieldItem> |
| 47 | + <FormFieldLabel> |
| 48 | + {t("mainConfig.injectorClassName")} {t("optional")} |
| 49 | + </FormFieldLabel> |
| 50 | + <Input id="injectorClassName" {...field} placeholder={t("placeholders.input")} /> |
| 51 | + </FormFieldItem> |
| 52 | + )} |
| 53 | + /> |
| 54 | + </FormProvider> |
| 55 | + )} |
| 56 | + </Fragment> |
36 | 57 | ); |
37 | 58 | } |
0 commit comments