From ebddfd3e56def0f5428a62f362941a939505e5e6 Mon Sep 17 00:00:00 2001 From: SuYao Date: Tue, 2 Dec 2025 18:33:06 +0800 Subject: [PATCH] feat(textarea): add Textarea component with variants and Storybook examples (#11260) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(textarea): add Textarea component with variants and Storybook examples * feat(textarea): enhance Textarea component with context, improved variants, and Storybook examples * Fine-tuning the style * fix ci * feat(textarea): refactor Textarea stories to use custom label and caption components * feat(textarea): add TextareaContext for managing textarea state * fix: format * feat(textarea): refactor TextareaInput to simplify props and remove autoSize handling * feat(textarea): remove TextareaContext and update stories to reflect new error handling * refactor(textarea): remove TextareaRoot component After removing TextareaContext, TextareaRoot became a simple wrapper div with no functionality beyond applying layout styles. This change: - Removes TextareaRoot component and its exports - Updates all Storybook stories to use plain divs with the same styling - Simplifies the component API while maintaining the same functionality Addresses reviewer feedback: https://github.com/CherryHQ/cherry-studio/pull/11260#discussion_r2580009134 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude * chore: format --------- Co-authored-by: Claude Co-authored-by: MyPrototypeWhat --- packages/ui/src/components/index.ts | 2 +- .../src/components/primitives/input-group.tsx | 7 +- .../ui/src/components/primitives/textarea.tsx | 115 ++++- .../primitives/Textarea.stories.tsx | 418 ++++++++++++++++++ 4 files changed, 530 insertions(+), 12 deletions(-) create mode 100644 packages/ui/stories/components/primitives/Textarea.stories.tsx diff --git a/packages/ui/src/components/index.ts b/packages/ui/src/components/index.ts index 7381afc1ba..c8ed30ea0a 100644 --- a/packages/ui/src/components/index.ts +++ b/packages/ui/src/components/index.ts @@ -74,4 +74,4 @@ export * from './primitives/radioGroup' export * from './primitives/select' export * from './primitives/shadcn-io/dropzone' export * from './primitives/tabs' -export * from './primitives/textarea' +export * as Textarea from './primitives/textarea' diff --git a/packages/ui/src/components/primitives/input-group.tsx b/packages/ui/src/components/primitives/input-group.tsx index 8c9ff10fac..9c27456b34 100644 --- a/packages/ui/src/components/primitives/input-group.tsx +++ b/packages/ui/src/components/primitives/input-group.tsx @@ -1,7 +1,8 @@ import { Button } from '@cherrystudio/ui/components/primitives/button' import type { InputProps } from '@cherrystudio/ui/components/primitives/input' import { Input } from '@cherrystudio/ui/components/primitives/input' -import { Textarea } from '@cherrystudio/ui/components/primitives/textarea' +import type { TextareaInputProps } from '@cherrystudio/ui/components/primitives/textarea' +import * as Textarea from '@cherrystudio/ui/components/primitives/textarea' import { cn } from '@cherrystudio/ui/utils/index' import { cva, type VariantProps } from 'class-variance-authority' import * as React from 'react' @@ -131,9 +132,9 @@ function InputGroupInput({ className, ...props }: InputProps) { ) } -function InputGroupTextarea({ className, ...props }: React.ComponentProps<'textarea'>) { +function InputGroupTextarea({ className, ...props }: TextareaInputProps) { return ( -