From e84ebc42c8ba133a59413769dce254169ab6a8de Mon Sep 17 00:00:00 2001 From: Yasir Ekinci Date: Tue, 2 Apr 2024 03:52:21 +0200 Subject: [PATCH] deps update --- package.json | 2 - src/components/ui/form.tsx | 172 ----------------------- src/components/ui/label.tsx | 27 ---- src/components/ui/select.tsx | 156 --------------------- yarn.lock | 262 ++++++++++++----------------------- 5 files changed, 87 insertions(+), 532 deletions(-) delete mode 100644 src/components/ui/form.tsx delete mode 100644 src/components/ui/label.tsx delete mode 100644 src/components/ui/select.tsx diff --git a/package.json b/package.json index 726ec88..f9ab751 100644 --- a/package.json +++ b/package.json @@ -12,8 +12,6 @@ "@hookform/resolvers": "^3.3.4", "@radix-ui/react-dialog": "^1.0.5", "@radix-ui/react-icons": "^1.3.0", - "@radix-ui/react-label": "^2.0.2", - "@radix-ui/react-select": "^2.0.0", "@radix-ui/react-slot": "^1.0.2", "@radix-ui/react-tabs": "^1.0.4", "@radix-ui/react-tooltip": "^1.0.7", diff --git a/src/components/ui/form.tsx b/src/components/ui/form.tsx deleted file mode 100644 index 5a0ecd5..0000000 --- a/src/components/ui/form.tsx +++ /dev/null @@ -1,172 +0,0 @@ -import * as React from "react" - -import * as LabelPrimitive from "@radix-ui/react-label" -import { Slot } from "@radix-ui/react-slot" -import { - Controller, - ControllerProps, - FieldPath, - FieldValues, - FormProvider, - useFormContext, -} from "react-hook-form" - -import { Label } from "@/components/ui/label" -import { cn } from "@/lib/utils" - -const Form = FormProvider - -type FormFieldContextValue< - TFieldValues extends FieldValues = FieldValues, - TName extends FieldPath = FieldPath -> = { - name: TName -} - -const FormFieldContext = React.createContext( - {} as FormFieldContextValue -) - -const FormField = < - TFieldValues extends FieldValues = FieldValues, - TName extends FieldPath = FieldPath ->({ - ...props -}: ControllerProps) => { - return ( - - - - ) -} - -const useFormField = () => { - const fieldContext = React.useContext(FormFieldContext) - const itemContext = React.useContext(FormItemContext) - const { getFieldState, formState } = useFormContext() - - const fieldState = getFieldState(fieldContext.name, formState) - - if (!fieldContext) { - throw new Error("useFormField should be used within ") - } - - const { id } = itemContext - - return { - id, - name: fieldContext.name, - formItemId: `${id}-form-item`, - formDescriptionId: `${id}-form-item-description`, - formMessageId: `${id}-form-item-message`, - ...fieldState, - } -} - -type FormItemContextValue = { - id: string -} - -const FormItemContext = React.createContext( - {} as FormItemContextValue -) - -const FormItem = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => { - const id = React.useId() - - return ( - -
- - ) -}) -FormItem.displayName = "FormItem" - -const FormLabel = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => { - const { error, formItemId } = useFormField() - - return ( -