From 319b149eba6e911f95a673c0bcfd18d1754490da Mon Sep 17 00:00:00 2001 From: Jake Ruesink Date: Mon, 2 Dec 2024 15:26:17 -0600 Subject: [PATCH] chore: fix input safari zoom issue for shadcn inputs, and updated import sort order --- .../src/ui/dropdown-menu-select.tsx | 86 +++++++++++-------- packages/components/src/ui/dropdown-menu.tsx | 2 +- packages/components/src/ui/input-otp.tsx | 4 +- packages/components/src/ui/input.tsx | 4 +- packages/components/src/ui/label.tsx | 2 +- packages/components/src/ui/popover.tsx | 2 +- packages/components/src/ui/radio-group.tsx | 8 +- packages/components/src/ui/switch.tsx | 9 +- packages/components/src/ui/textarea.tsx | 18 +++- 9 files changed, 80 insertions(+), 55 deletions(-) diff --git a/packages/components/src/ui/dropdown-menu-select.tsx b/packages/components/src/ui/dropdown-menu-select.tsx index 7bd69310..a3b5f466 100644 --- a/packages/components/src/ui/dropdown-menu-select.tsx +++ b/packages/components/src/ui/dropdown-menu-select.tsx @@ -1,14 +1,22 @@ -import { forwardRef, type ElementRef, type ComponentPropsWithoutRef, type ReactNode } from 'react' // biome-ignore lint/style/noNamespaceImport: from Radix -import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu" -import { type FieldComponents, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from "./form" -import { Button } from './button' -import { DropdownMenuContent } from './dropdown-menu' -import type { Control, FieldPath, FieldValues } from "react-hook-form"; +import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu'; +import { type ComponentPropsWithoutRef, type ElementRef, type ReactNode, forwardRef } from 'react'; +import type { Control, FieldPath, FieldValues } from 'react-hook-form'; +import { Button } from './button'; +import { DropdownMenuContent } from './dropdown-menu'; +import { + type FieldComponents, + FormControl, + FormDescription, + FormField, + FormItem, + FormLabel, + FormMessage, +} from './form'; export interface DropdownMenuSelectProps< TFieldValues extends FieldValues = FieldValues, - TName extends FieldPath = FieldPath + TName extends FieldPath = FieldPath, > extends Omit, 'onChange' | 'value'> { control?: Control; name: TName; @@ -21,35 +29,37 @@ export interface DropdownMenuSelectProps< components?: Partial; } -export const DropdownMenuSelect = forwardRef< - ElementRef, - DropdownMenuSelectProps ->(({ control, name, label, description, children, className, labelClassName, dropdownClassName, components, ...props }, ref) => { - return ( - ( - - {label && {label}} - - - - - - - {children} - - - - {description && {description}} - {fieldState.error?.message} - - )} - /> - ); -}); +export const DropdownMenuSelect = forwardRef, DropdownMenuSelectProps>( + ( + { control, name, label, description, children, className, labelClassName, dropdownClassName, components, ...props }, + ref, + ) => { + return ( + ( + + {label && ( + + {label} + + )} + + + + + + {children} + + + {description && {description}} + {fieldState.error?.message} + + )} + /> + ); + }, +); -DropdownMenuSelect.displayName = "DropdownMenuSelect"; \ No newline at end of file +DropdownMenuSelect.displayName = 'DropdownMenuSelect'; diff --git a/packages/components/src/ui/dropdown-menu.tsx b/packages/components/src/ui/dropdown-menu.tsx index 39ce5ada..89388a2d 100644 --- a/packages/components/src/ui/dropdown-menu.tsx +++ b/packages/components/src/ui/dropdown-menu.tsx @@ -1,7 +1,7 @@ -import { forwardRef, type ElementRef, type ComponentPropsWithoutRef, type HTMLAttributes } from 'react'; // biome-ignore lint/style/noNamespaceImport: from Radix import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu'; import { Check, ChevronRight, Circle } from 'lucide-react'; +import { type ComponentPropsWithoutRef, type ElementRef, type HTMLAttributes, forwardRef } from 'react'; import { cn } from '../../lib/utils'; diff --git a/packages/components/src/ui/input-otp.tsx b/packages/components/src/ui/input-otp.tsx index d18c3744..5e379959 100644 --- a/packages/components/src/ui/input-otp.tsx +++ b/packages/components/src/ui/input-otp.tsx @@ -1,7 +1,7 @@ -import type { Control, FieldValues } from 'react-hook-form'; -import { forwardRef, type ElementRef, type ComponentPropsWithoutRef, useContext } from 'react'; import { OTPInput, OTPInputContext, type OTPInputProps } from 'input-otp'; import { Dot } from 'lucide-react'; +import { type ComponentPropsWithoutRef, type ElementRef, forwardRef, useContext } from 'react'; +import type { Control, FieldValues } from 'react-hook-form'; import { cn } from '../../lib/utils'; import { type FieldComponents, diff --git a/packages/components/src/ui/input.tsx b/packages/components/src/ui/input.tsx index 62d15954..8da061c4 100644 --- a/packages/components/src/ui/input.tsx +++ b/packages/components/src/ui/input.tsx @@ -1,14 +1,14 @@ import { type InputHTMLAttributes, forwardRef } from 'react'; import { cn } from '../../lib/utils'; -export interface InputProps extends InputHTMLAttributes { } +export interface InputProps extends InputHTMLAttributes {} const Input = forwardRef(({ className, type, ...props }, ref) => { return ( , @@ -67,7 +67,9 @@ const RadioGroupField = forwardRef( {description && {description}} - {fieldState.error && {fieldState.error.message}} + {fieldState.error && ( + {fieldState.error.message} + )} )} /> diff --git a/packages/components/src/ui/switch.tsx b/packages/components/src/ui/switch.tsx index a91172ed..5683d1a2 100644 --- a/packages/components/src/ui/switch.tsx +++ b/packages/components/src/ui/switch.tsx @@ -1,9 +1,9 @@ -import { forwardRef, type ComponentPropsWithoutRef, type ReactNode } from 'react'; // biome-ignore lint/style/noNamespaceImport: from Radix import * as SwitchPrimitives from '@radix-ui/react-switch'; +import { type ComponentPropsWithoutRef, type ReactNode, forwardRef } from 'react'; +import type { Control, FieldPath, FieldValues } from 'react-hook-form'; import { cn } from '../../lib/utils'; import { type FieldComponents, FormControl, FormDescription, FormField, FormItem, FormLabel } from './form'; -import type { Control, FieldPath, FieldValues } from 'react-hook-form'; export interface SwitchProps< TFieldValues extends FieldValues = FieldValues, @@ -23,7 +23,10 @@ const Switch = forwardRef( control={control} name={name} render={({ field }) => ( - +
{label && {label}} {description && {description}} diff --git a/packages/components/src/ui/textarea.tsx b/packages/components/src/ui/textarea.tsx index 4c05e9d1..ee4bc1c2 100644 --- a/packages/components/src/ui/textarea.tsx +++ b/packages/components/src/ui/textarea.tsx @@ -1,11 +1,19 @@ import { type TextareaHTMLAttributes, forwardRef } from 'react'; +import type { Control, FieldPath, FieldValues } from 'react-hook-form'; import { cn } from '../../lib/utils'; -import { FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField, type FieldComponents } from './form'; -import type { Control, FieldPath, FieldValues } from "react-hook-form"; +import { + type FieldComponents, + FormControl, + FormDescription, + FormField, + FormItem, + FormLabel, + FormMessage, +} from './form'; export interface TextareaProps< TFieldValues extends FieldValues = FieldValues, - TName extends FieldPath = FieldPath + TName extends FieldPath = FieldPath, > extends Omit, 'name'> { control?: Control; name: TName; @@ -35,7 +43,9 @@ export const Textarea = forwardRef( /> {description && {description}} - {fieldState.error && {fieldState.error.message}} + {fieldState.error && ( + {fieldState.error.message} + )} )} />