diff --git a/packages/ui/src/components/primitives/textarea.tsx b/packages/ui/src/components/primitives/textarea.tsx index 4c831690a..b2523402f 100644 --- a/packages/ui/src/components/primitives/textarea.tsx +++ b/packages/ui/src/components/primitives/textarea.tsx @@ -1,28 +1,10 @@ import { cn } from '@cherrystudio/ui/utils/index' import { composeEventHandlers } from '@radix-ui/primitive' -import { createContext } from '@radix-ui/react-context' import { useCallbackRef } from '@radix-ui/react-use-callback-ref' import { useControllableState } from '@radix-ui/react-use-controllable-state' import { cva } from 'class-variance-authority' import * as React from 'react' -/* ------------------------------------------------------------------------------------------------- - * Textarea Context - * -----------------------------------------------------------------------------------------------*/ - -type TextareaContextValue = { - textareaId: string - hasError: boolean - disabled?: boolean -} - -// eslint-disable-next-line @eslint-react/naming-convention/context-name -const [TextareaContext, useTextareaContext] = createContext('Textarea.TextareaContext', { - textareaId: '', - hasError: false, - disabled: false -}) - /* ------------------------------------------------------------------------------------------------- * Variants * -----------------------------------------------------------------------------------------------*/ @@ -55,21 +37,13 @@ const textareaVariants = cva( const ROOT_NAME = 'TextareaRoot' -interface TextareaRootProps extends React.ComponentPropsWithoutRef<'div'> { - error?: string - disabled?: boolean -} - -function TextareaRoot({ error, disabled, className, children, ...props }: TextareaRootProps) { - const textareaId = React.useId() - const hasError = !!error +interface TextareaRootProps extends React.ComponentPropsWithoutRef<'div'> {} +function TextareaRoot({ className, children, ...props }: TextareaRootProps) { return ( - -
- {children} -
-
+
+ {children} +
) } @@ -85,18 +59,19 @@ interface TextareaInputProps extends Omit void + hasError?: boolean + ref?: React.Ref } -const TextareaInput = function TextareaInput({ - ref, +function TextareaInput({ value: valueProp, defaultValue, onValueChange, + hasError = false, className, + ref, ...props -}: TextareaInputProps & { ref?: React.RefObject }) { - const context = useTextareaContext(INPUT_NAME) - +}: TextareaInputProps) { const [value = '', setValue] = useControllableState({ prop: valueProp, defaultProp: defaultValue ?? '', @@ -114,14 +89,12 @@ const TextareaInput = function TextareaInput({ return (