ai-design-system 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +307 -0
- package/components/ai-elements/actions.tsx +65 -0
- package/components/ai-elements/artifact.tsx +147 -0
- package/components/ai-elements/branch.tsx +212 -0
- package/components/ai-elements/canvas.tsx +24 -0
- package/components/ai-elements/chain-of-thought.tsx +228 -0
- package/components/ai-elements/code-block.tsx +179 -0
- package/components/ai-elements/confirmation.tsx +169 -0
- package/components/ai-elements/connection.tsx +28 -0
- package/components/ai-elements/context.tsx +408 -0
- package/components/ai-elements/controls.tsx +18 -0
- package/components/ai-elements/conversation.tsx +97 -0
- package/components/ai-elements/edge.tsx +140 -0
- package/components/ai-elements/image.tsx +24 -0
- package/components/ai-elements/inline-citation.tsx +287 -0
- package/components/ai-elements/loader.tsx +96 -0
- package/components/ai-elements/message.tsx +80 -0
- package/components/ai-elements/node.tsx +71 -0
- package/components/ai-elements/open-in-chat.tsx +363 -0
- package/components/ai-elements/panel.tsx +15 -0
- package/components/ai-elements/plan.tsx +142 -0
- package/components/ai-elements/prompt-input.tsx +1352 -0
- package/components/ai-elements/queue.tsx +274 -0
- package/components/ai-elements/reasoning.tsx +178 -0
- package/components/ai-elements/response.tsx +22 -0
- package/components/ai-elements/shimmer.tsx +64 -0
- package/components/ai-elements/sources.tsx +77 -0
- package/components/ai-elements/suggestion.tsx +56 -0
- package/components/ai-elements/task.tsx +87 -0
- package/components/ai-elements/tool.tsx +179 -0
- package/components/ai-elements/toolbar.tsx +16 -0
- package/components/ai-elements/web-preview.tsx +263 -0
- package/components/blocks/AIConversation/AIConversation.stories.tsx +164 -0
- package/components/blocks/AIConversation/AIConversation.tsx +186 -0
- package/components/blocks/AIConversation/index.ts +8 -0
- package/components/blocks/AppSidebar/AppSidebar.stories.tsx +63 -0
- package/components/blocks/AppSidebar/AppSidebar.tsx +87 -0
- package/components/blocks/AppSidebar/index.ts +2 -0
- package/components/blocks/DocumentEditorWithComments/DocumentEditorWithComments.stories.tsx +341 -0
- package/components/blocks/DocumentEditorWithComments/DocumentEditorWithComments.tsx +255 -0
- package/components/blocks/DocumentEditorWithComments/index.ts +9 -0
- package/components/blocks/FileChangeQueue/FileChangeQueue.stories.tsx +207 -0
- package/components/blocks/FileChangeQueue/FileChangeQueue.tsx +143 -0
- package/components/blocks/FileChangeQueue/index.ts +7 -0
- package/components/blocks/LayoutProvider/LayoutProvider.tsx +34 -0
- package/components/blocks/LayoutProvider/index.ts +1 -0
- package/components/blocks/index.ts +2 -0
- package/components/composites/AgentIndicator/AgentIndicator.stories.tsx +154 -0
- package/components/composites/AgentIndicator/AgentIndicator.tsx +102 -0
- package/components/composites/AgentIndicator/index.ts +8 -0
- package/components/composites/AppHeader/AppHeader.stories.tsx +46 -0
- package/components/composites/AppHeader/AppHeader.tsx +24 -0
- package/components/composites/AppHeader/index.ts +2 -0
- package/components/composites/CommentBox/CommentBox.stories.tsx +192 -0
- package/components/composites/CommentBox/CommentBox.tsx +364 -0
- package/components/composites/CommentBox/index.ts +8 -0
- package/components/composites/Confirmation/Confirmation.stories.tsx +151 -0
- package/components/composites/Confirmation/Confirmation.tsx +93 -0
- package/components/composites/Confirmation/index.ts +7 -0
- package/components/composites/DataTable/DataTable.stories.tsx +35 -0
- package/components/composites/DataTable/DataTable.tsx +95 -0
- package/components/composites/DataTable/index.ts +2 -0
- package/components/composites/DocumentEditor/DocumentEditor.css +106 -0
- package/components/composites/DocumentEditor/DocumentEditor.stories.tsx +927 -0
- package/components/composites/DocumentEditor/DocumentEditor.tsx +279 -0
- package/components/composites/DocumentEditor/index.ts +8 -0
- package/components/composites/FileQueue/FileQueue.stories.tsx +175 -0
- package/components/composites/FileQueue/FileQueue.tsx +161 -0
- package/components/composites/FileQueue/FileStatusBadge.tsx +74 -0
- package/components/composites/FileQueue/index.ts +24 -0
- package/components/composites/InteractiveChart/InteractiveChart.stories.tsx +49 -0
- package/components/composites/InteractiveChart/InteractiveChart.tsx +69 -0
- package/components/composites/InteractiveChart/index.ts +2 -0
- package/components/composites/ModeToggle/ModeToggle.stories.tsx +212 -0
- package/components/composites/ModeToggle/ModeToggle.tsx +100 -0
- package/components/composites/ModeToggle/index.ts +7 -0
- package/components/composites/NavUser/NavUser.stories.tsx +50 -0
- package/components/composites/NavUser/NavUser.tsx +60 -0
- package/components/composites/NavUser/index.ts +2 -0
- package/components/composites/NavigationList/NavigationList.stories.tsx +46 -0
- package/components/composites/NavigationList/NavigationList.tsx +46 -0
- package/components/composites/NavigationList/index.ts +2 -0
- package/components/composites/OrchestratorMessage/OrchestratorMessage.stories.tsx +188 -0
- package/components/composites/OrchestratorMessage/OrchestratorMessage.tsx +72 -0
- package/components/composites/OrchestratorMessage/index.ts +8 -0
- package/components/composites/PageContainer/PageContainer.stories.tsx +41 -0
- package/components/composites/PageContainer/PageContainer.tsx +24 -0
- package/components/composites/PageContainer/index.ts +2 -0
- package/components/composites/PromptInput/PromptInput.stories.tsx +200 -0
- package/components/composites/PromptInput/PromptInput.tsx +129 -0
- package/components/composites/PromptInput/index.ts +8 -0
- package/components/composites/SpecialistMessage/SpecialistMessage.stories.tsx +286 -0
- package/components/composites/SpecialistMessage/SpecialistMessage.tsx +107 -0
- package/components/composites/SpecialistMessage/index.ts +8 -0
- package/components/composites/StatsCard/StatsCard.stories.tsx +76 -0
- package/components/composites/StatsCard/StatsCard.tsx +81 -0
- package/components/composites/StatsCard/index.ts +2 -0
- package/components/composites/TablePagination/TablePagination.stories.tsx +38 -0
- package/components/composites/TablePagination/TablePagination.tsx +119 -0
- package/components/composites/TablePagination/index.ts +2 -0
- package/components/composites/TableToolbar/TableToolbar.stories.tsx +60 -0
- package/components/composites/TableToolbar/TableToolbar.tsx +66 -0
- package/components/composites/TableToolbar/index.ts +2 -0
- package/components/composites/ThemeSelector/ThemeSelector.stories.tsx +48 -0
- package/components/composites/ThemeSelector/ThemeSelector.tsx +79 -0
- package/components/composites/ThemeSelector/index.ts +2 -0
- package/components/composites/ToolCallDisplay/ToolCallDisplay.stories.tsx +49 -0
- package/components/composites/ToolCallDisplay/ToolCallDisplay.tsx +108 -0
- package/components/composites/ToolCallDisplay/index.ts +8 -0
- package/components/composites/UserMessage/UserMessage.stories.tsx +59 -0
- package/components/composites/UserMessage/UserMessage.tsx +52 -0
- package/components/composites/UserMessage/index.ts +8 -0
- package/components/composites/index.ts +90 -0
- package/components/features/AIDocEditor/AIDocEditor.behaviors.stories.tsx +451 -0
- package/components/features/AIDocEditor/AIDocEditor.mocks.ts +96 -0
- package/components/features/AIDocEditor/AIDocEditor.stories.tsx +140 -0
- package/components/features/AIDocEditor/AIDocEditor.tsx +130 -0
- package/components/features/AIDocEditor/index.ts +8 -0
- package/components/features/AIDocEditor/useAIDocEditor.d.ts +97 -0
- package/components/features/AIDocEditor/useAIDocEditor.mock.ts +83 -0
- package/components/features/PageLayout/PageLayout.behaviors.stories.tsx +119 -0
- package/components/features/PageLayout/PageLayout.mocks.ts +27 -0
- package/components/features/PageLayout/PageLayout.stories.tsx +142 -0
- package/components/features/PageLayout/PageLayout.tsx +94 -0
- package/components/features/PageLayout/index.ts +4 -0
- package/components/features/PageLayout/usePageLayout.d.ts +24 -0
- package/components/features/PageLayout/usePageLayout.mock.ts +19 -0
- package/components/features/RefinementPanel/README.md +189 -0
- package/components/features/RefinementPanel/RefinementPanel.behaviors.stories.tsx +475 -0
- package/components/features/RefinementPanel/RefinementPanel.mocks.ts +131 -0
- package/components/features/RefinementPanel/RefinementPanel.stories.tsx +141 -0
- package/components/features/RefinementPanel/RefinementPanel.tsx +160 -0
- package/components/features/RefinementPanel/index.ts +25 -0
- package/components/features/RefinementPanel/useRefinementPanel.d.ts +74 -0
- package/components/features/RefinementPanel/useRefinementPanel.mock.ts +121 -0
- package/components/features/SpecNavigator/SpecNavigator.behaviors.stories.tsx +379 -0
- package/components/features/SpecNavigator/SpecNavigator.mocks.ts +131 -0
- package/components/features/SpecNavigator/SpecNavigator.stories.tsx +122 -0
- package/components/features/SpecNavigator/SpecNavigator.tsx +43 -0
- package/components/features/SpecNavigator/index.ts +2 -0
- package/components/features/SpecNavigator/useSpecNavigator.d.ts +122 -0
- package/components/features/SpecNavigator/useSpecNavigator.mock.ts +93 -0
- package/components/features/index.ts +18 -0
- package/components/index.ts +14 -0
- package/components/primitives/Accordion/Accordion.stories.tsx +87 -0
- package/components/primitives/Accordion/Accordion.tsx +66 -0
- package/components/primitives/Accordion/index.ts +13 -0
- package/components/primitives/Alert/Alert.stories.tsx +422 -0
- package/components/primitives/Alert/Alert.tsx +61 -0
- package/components/primitives/Alert/index.ts +8 -0
- package/components/primitives/AlertDialog/AlertDialog.stories.tsx +367 -0
- package/components/primitives/AlertDialog/AlertDialog.tsx +182 -0
- package/components/primitives/AlertDialog/index.ts +25 -0
- package/components/primitives/Avatar/Avatar.stories.tsx +321 -0
- package/components/primitives/Avatar/Avatar.tsx +63 -0
- package/components/primitives/Avatar/index.ts +8 -0
- package/components/primitives/Badge/Badge.stories.tsx +74 -0
- package/components/primitives/Badge/Badge.tsx +49 -0
- package/components/primitives/Badge/index.ts +2 -0
- package/components/primitives/Button/Button.stories.tsx +445 -0
- package/components/primitives/Button/Button.tsx +89 -0
- package/components/primitives/Button/index.ts +7 -0
- package/components/primitives/Card/Card.stories.tsx +831 -0
- package/components/primitives/Card/Card.tsx +242 -0
- package/components/primitives/Card/index.ts +30 -0
- package/components/primitives/Carousel/Carousel.stories.tsx +32 -0
- package/components/primitives/Carousel/Carousel.tsx +63 -0
- package/components/primitives/Carousel/index.ts +13 -0
- package/components/primitives/Chart/Chart.stories.tsx +346 -0
- package/components/primitives/Chart/Chart.tsx +117 -0
- package/components/primitives/Chart/index.ts +20 -0
- package/components/primitives/Checkbox/Checkbox.stories.tsx +87 -0
- package/components/primitives/Checkbox/Checkbox.tsx +38 -0
- package/components/primitives/Checkbox/index.ts +2 -0
- package/components/primitives/Collapsible/Collapsible.stories.tsx +38 -0
- package/components/primitives/Collapsible/Collapsible.tsx +39 -0
- package/components/primitives/Collapsible/index.ts +8 -0
- package/components/primitives/Command/Command.stories.tsx +150 -0
- package/components/primitives/Command/Command.tsx +147 -0
- package/components/primitives/Command/index.ts +20 -0
- package/components/primitives/Dialog/Dialog.stories.tsx +390 -0
- package/components/primitives/Dialog/Dialog.tsx +140 -0
- package/components/primitives/Dialog/index.ts +22 -0
- package/components/primitives/Drawer/Drawer.stories.tsx +327 -0
- package/components/primitives/Drawer/Drawer.tsx +208 -0
- package/components/primitives/Drawer/index.ts +27 -0
- package/components/primitives/DropdownMenu/DropdownMenu.stories.tsx +150 -0
- package/components/primitives/DropdownMenu/DropdownMenu.tsx +73 -0
- package/components/primitives/DropdownMenu/index.ts +1 -0
- package/components/primitives/HoverCard/HoverCard.stories.tsx +26 -0
- package/components/primitives/HoverCard/HoverCard.tsx +39 -0
- package/components/primitives/HoverCard/index.ts +8 -0
- package/components/primitives/Icon/Icon.stories.tsx +281 -0
- package/components/primitives/Icon/Icon.tsx +87 -0
- package/components/primitives/Icon/index.ts +8 -0
- package/components/primitives/Input/Input.stories.tsx +370 -0
- package/components/primitives/Input/Input.tsx +88 -0
- package/components/primitives/Input/index.ts +7 -0
- package/components/primitives/InputGroup/InputGroup.stories.tsx +40 -0
- package/components/primitives/InputGroup/InputGroup.tsx +72 -0
- package/components/primitives/InputGroup/index.ts +14 -0
- package/components/primitives/Label/Label.stories.tsx +227 -0
- package/components/primitives/Label/Label.tsx +53 -0
- package/components/primitives/Label/index.ts +7 -0
- package/components/primitives/Popover/Popover.stories.tsx +42 -0
- package/components/primitives/Popover/Popover.tsx +107 -0
- package/components/primitives/Popover/index.ts +2 -0
- package/components/primitives/Progress/Progress.stories.tsx +340 -0
- package/components/primitives/Progress/Progress.tsx +31 -0
- package/components/primitives/Progress/index.ts +1 -0
- package/components/primitives/ScrollArea/ScrollArea.stories.tsx +26 -0
- package/components/primitives/ScrollArea/ScrollArea.tsx +28 -0
- package/components/primitives/ScrollArea/index.ts +6 -0
- package/components/primitives/Select/Select.stories.tsx +288 -0
- package/components/primitives/Select/Select.tsx +162 -0
- package/components/primitives/Select/index.ts +22 -0
- package/components/primitives/Separator/Separator.stories.tsx +264 -0
- package/components/primitives/Separator/Separator.tsx +48 -0
- package/components/primitives/Separator/index.ts +7 -0
- package/components/primitives/Sidebar/Sidebar.stories.tsx +358 -0
- package/components/primitives/Sidebar/Sidebar.tsx +317 -0
- package/components/primitives/Sidebar/index.ts +41 -0
- package/components/primitives/Table/Table.stories.tsx +389 -0
- package/components/primitives/Table/Table.tsx +191 -0
- package/components/primitives/Table/index.ts +26 -0
- package/components/primitives/Tabs/Tabs.stories.tsx +129 -0
- package/components/primitives/Tabs/Tabs.tsx +70 -0
- package/components/primitives/Tabs/index.ts +13 -0
- package/components/primitives/Textarea/Textarea.stories.tsx +358 -0
- package/components/primitives/Textarea/Textarea.tsx +91 -0
- package/components/primitives/Textarea/index.ts +7 -0
- package/components/primitives/ToggleGroup/ToggleGroup.stories.tsx +87 -0
- package/components/primitives/ToggleGroup/ToggleGroup.tsx +52 -0
- package/components/primitives/ToggleGroup/index.ts +6 -0
- package/components/primitives/Tooltip/Tooltip.stories.tsx +336 -0
- package/components/primitives/Tooltip/Tooltip.tsx +78 -0
- package/components/primitives/Tooltip/index.ts +10 -0
- package/components/primitives/index.ts +34 -0
- package/components/ui/accordion.tsx +66 -0
- package/components/ui/alert-dialog.tsx +157 -0
- package/components/ui/alert.tsx +66 -0
- package/components/ui/avatar.tsx +53 -0
- package/components/ui/badge.tsx +46 -0
- package/components/ui/button.tsx +60 -0
- package/components/ui/card.tsx +117 -0
- package/components/ui/carousel.tsx +241 -0
- package/components/ui/chart.tsx +334 -0
- package/components/ui/checkbox.tsx +32 -0
- package/components/ui/collapsible.tsx +33 -0
- package/components/ui/command.tsx +184 -0
- package/components/ui/dialog.tsx +143 -0
- package/components/ui/drawer.tsx +118 -0
- package/components/ui/dropdown-menu.tsx +257 -0
- package/components/ui/hover-card.tsx +44 -0
- package/components/ui/input-group.tsx +170 -0
- package/components/ui/input.tsx +48 -0
- package/components/ui/label.tsx +26 -0
- package/components/ui/popover.tsx +33 -0
- package/components/ui/progress.tsx +31 -0
- package/components/ui/scroll-area.tsx +58 -0
- package/components/ui/select.tsx +187 -0
- package/components/ui/separator.tsx +31 -0
- package/components/ui/sidebar.tsx +577 -0
- package/components/ui/table.tsx +120 -0
- package/components/ui/tabs.tsx +66 -0
- package/components/ui/textarea.tsx +46 -0
- package/components/ui/toggle-group.tsx +83 -0
- package/components/ui/toggle.tsx +47 -0
- package/components/ui/tooltip.tsx +61 -0
- package/dist/index.cjs +7389 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +75 -0
- package/dist/index.css.map +1 -0
- package/dist/index.js +7160 -0
- package/dist/index.js.map +1 -0
- package/hooks/useAIDocReviewer.d.ts +0 -0
- package/lib/utils.ts +6 -0
- package/package.json +140 -0
- package/tokens/color/base.json +14 -0
- package/tokens/color/dark.json +40 -0
- package/tokens/color/green.json +21 -0
- package/tokens/color/light.json +52 -0
- package/tokens/color/neutral.json +20 -0
- package/tokens/color/violet.json +21 -0
- package/tokens/spacing.json +22 -0
- package/utils/ai-editor/format-date.ts +41 -0
- package/utils/ai-editor/index.ts +22 -0
- package/utils/ai-editor/type-guards.ts +72 -0
- package/utils/ai-editor/validation.ts +130 -0
- package/utils/editor-annotations.ts +122 -0
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
|
+
import { Input } from "./Input"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Input Primitive Stories
|
|
6
|
+
*
|
|
7
|
+
* The Input primitive provides a consistent text input experience across the application.
|
|
8
|
+
* It supports various input types, validation states, and accessibility features.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const meta = {
|
|
12
|
+
title: "Primitives/Input",
|
|
13
|
+
component: Input,
|
|
14
|
+
parameters: {
|
|
15
|
+
layout: "centered",
|
|
16
|
+
docs: {
|
|
17
|
+
description: {
|
|
18
|
+
component:
|
|
19
|
+
"A foundational input component built on shadcn/ui Input. Supports all native HTML input types, validation states, and accessibility features including ARIA attributes for error states.",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
tags: ["autodocs"],
|
|
24
|
+
argTypes: {
|
|
25
|
+
type: {
|
|
26
|
+
control: "select",
|
|
27
|
+
options: ["text", "email", "password", "number", "tel", "url", "search"],
|
|
28
|
+
description: "The type of input field",
|
|
29
|
+
table: {
|
|
30
|
+
defaultValue: { summary: "text" },
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
size: {
|
|
34
|
+
control: "select",
|
|
35
|
+
options: ["sm", "default", "lg"],
|
|
36
|
+
description: "Size variant of the input",
|
|
37
|
+
table: {
|
|
38
|
+
defaultValue: { summary: "default" },
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
state: {
|
|
42
|
+
control: "select",
|
|
43
|
+
options: ["default", "error", "success", "warning"],
|
|
44
|
+
description: "Visual state of the input",
|
|
45
|
+
table: {
|
|
46
|
+
defaultValue: { summary: "default" },
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
placeholder: {
|
|
50
|
+
control: "text",
|
|
51
|
+
description: "Placeholder text displayed when input is empty",
|
|
52
|
+
},
|
|
53
|
+
disabled: {
|
|
54
|
+
control: "boolean",
|
|
55
|
+
description: "Whether the input is disabled",
|
|
56
|
+
table: {
|
|
57
|
+
defaultValue: { summary: false },
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
"aria-invalid": {
|
|
61
|
+
control: "boolean",
|
|
62
|
+
description: "Indicates whether the input value is invalid",
|
|
63
|
+
table: {
|
|
64
|
+
defaultValue: { summary: false },
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
} satisfies Meta<typeof Input>
|
|
69
|
+
|
|
70
|
+
export default meta
|
|
71
|
+
type Story = StoryObj<typeof meta>
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Default text input
|
|
75
|
+
*/
|
|
76
|
+
export const Default: Story = {
|
|
77
|
+
args: {
|
|
78
|
+
type: "text",
|
|
79
|
+
placeholder: "Enter text...",
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Email input with appropriate keyboard on mobile devices
|
|
85
|
+
*/
|
|
86
|
+
export const Email: Story = {
|
|
87
|
+
args: {
|
|
88
|
+
type: "email",
|
|
89
|
+
placeholder: "email@example.com",
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Password input with masked characters
|
|
95
|
+
*/
|
|
96
|
+
export const Password: Story = {
|
|
97
|
+
args: {
|
|
98
|
+
type: "password",
|
|
99
|
+
placeholder: "Enter password",
|
|
100
|
+
},
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Number input with increment/decrement controls
|
|
105
|
+
*/
|
|
106
|
+
export const Number: Story = {
|
|
107
|
+
args: {
|
|
108
|
+
type: "number",
|
|
109
|
+
placeholder: "Enter number",
|
|
110
|
+
},
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Search input with search icon styling
|
|
115
|
+
*/
|
|
116
|
+
export const Search: Story = {
|
|
117
|
+
args: {
|
|
118
|
+
type: "search",
|
|
119
|
+
placeholder: "Search...",
|
|
120
|
+
},
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Telephone input with appropriate keyboard on mobile devices
|
|
125
|
+
*/
|
|
126
|
+
export const Telephone: Story = {
|
|
127
|
+
args: {
|
|
128
|
+
type: "tel",
|
|
129
|
+
placeholder: "+1 (555) 000-0000",
|
|
130
|
+
},
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* URL input with URL validation
|
|
135
|
+
*/
|
|
136
|
+
export const URL: Story = {
|
|
137
|
+
args: {
|
|
138
|
+
type: "url",
|
|
139
|
+
placeholder: "https://example.com",
|
|
140
|
+
},
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Disabled input that cannot be interacted with
|
|
145
|
+
*/
|
|
146
|
+
export const Disabled: Story = {
|
|
147
|
+
args: {
|
|
148
|
+
type: "text",
|
|
149
|
+
placeholder: "Disabled input",
|
|
150
|
+
disabled: true,
|
|
151
|
+
},
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Input with pre-filled value
|
|
156
|
+
*/
|
|
157
|
+
export const WithValue: Story = {
|
|
158
|
+
args: {
|
|
159
|
+
type: "text",
|
|
160
|
+
defaultValue: "Pre-filled value",
|
|
161
|
+
},
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Invalid input showing error state
|
|
166
|
+
*/
|
|
167
|
+
export const Invalid: Story = {
|
|
168
|
+
args: {
|
|
169
|
+
type: "email",
|
|
170
|
+
placeholder: "email@example.com",
|
|
171
|
+
defaultValue: "invalid-email",
|
|
172
|
+
"aria-invalid": true,
|
|
173
|
+
},
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* File input for file selection
|
|
178
|
+
*/
|
|
179
|
+
export const File: Story = {
|
|
180
|
+
args: {
|
|
181
|
+
type: "file",
|
|
182
|
+
},
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Small input size
|
|
187
|
+
*/
|
|
188
|
+
export const Small: Story = {
|
|
189
|
+
args: {
|
|
190
|
+
type: "text",
|
|
191
|
+
placeholder: "Small input",
|
|
192
|
+
size: "sm",
|
|
193
|
+
},
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Large input size
|
|
198
|
+
*/
|
|
199
|
+
export const Large: Story = {
|
|
200
|
+
args: {
|
|
201
|
+
type: "text",
|
|
202
|
+
placeholder: "Large input",
|
|
203
|
+
size: "lg",
|
|
204
|
+
},
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Error state input
|
|
209
|
+
*/
|
|
210
|
+
export const ErrorState: Story = {
|
|
211
|
+
args: {
|
|
212
|
+
type: "email",
|
|
213
|
+
placeholder: "email@example.com",
|
|
214
|
+
defaultValue: "invalid-email",
|
|
215
|
+
state: "error",
|
|
216
|
+
},
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Success state input
|
|
221
|
+
*/
|
|
222
|
+
export const SuccessState: Story = {
|
|
223
|
+
args: {
|
|
224
|
+
type: "email",
|
|
225
|
+
placeholder: "email@example.com",
|
|
226
|
+
defaultValue: "valid@email.com",
|
|
227
|
+
state: "success",
|
|
228
|
+
},
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Warning state input
|
|
233
|
+
*/
|
|
234
|
+
export const WarningState: Story = {
|
|
235
|
+
args: {
|
|
236
|
+
type: "text",
|
|
237
|
+
placeholder: "Enter text",
|
|
238
|
+
defaultValue: "This might need attention",
|
|
239
|
+
state: "warning",
|
|
240
|
+
},
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Size variants showcase
|
|
245
|
+
*/
|
|
246
|
+
export const SizeVariants: Story = {
|
|
247
|
+
render: () => (
|
|
248
|
+
<div className="flex flex-col gap-4 w-80">
|
|
249
|
+
<div>
|
|
250
|
+
<label className="text-sm font-medium mb-1 block">Small</label>
|
|
251
|
+
<Input type="text" placeholder="Small input" size="sm" />
|
|
252
|
+
</div>
|
|
253
|
+
<div>
|
|
254
|
+
<label className="text-sm font-medium mb-1 block">Default</label>
|
|
255
|
+
<Input type="text" placeholder="Default input" size="default" />
|
|
256
|
+
</div>
|
|
257
|
+
<div>
|
|
258
|
+
<label className="text-sm font-medium mb-1 block">Large</label>
|
|
259
|
+
<Input type="text" placeholder="Large input" size="lg" />
|
|
260
|
+
</div>
|
|
261
|
+
</div>
|
|
262
|
+
),
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* State variants showcase
|
|
267
|
+
*/
|
|
268
|
+
export const StateVariants: Story = {
|
|
269
|
+
render: () => (
|
|
270
|
+
<div className="flex flex-col gap-4 w-80">
|
|
271
|
+
<div>
|
|
272
|
+
<label className="text-sm font-medium mb-1 block">Default State</label>
|
|
273
|
+
<Input type="text" placeholder="Default state" state="default" />
|
|
274
|
+
</div>
|
|
275
|
+
<div>
|
|
276
|
+
<label className="text-sm font-medium mb-1 block">Error State</label>
|
|
277
|
+
<Input type="text" placeholder="Error state" state="error" defaultValue="Invalid input" />
|
|
278
|
+
</div>
|
|
279
|
+
<div>
|
|
280
|
+
<label className="text-sm font-medium mb-1 block">Success State</label>
|
|
281
|
+
<Input type="text" placeholder="Success state" state="success" defaultValue="Valid input" />
|
|
282
|
+
</div>
|
|
283
|
+
<div>
|
|
284
|
+
<label className="text-sm font-medium mb-1 block">Warning State</label>
|
|
285
|
+
<Input type="text" placeholder="Warning state" state="warning" defaultValue="Needs attention" />
|
|
286
|
+
</div>
|
|
287
|
+
</div>
|
|
288
|
+
),
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Combined variants showcase
|
|
293
|
+
*/
|
|
294
|
+
export const CombinedVariants: Story = {
|
|
295
|
+
render: () => (
|
|
296
|
+
<div className="flex flex-col gap-4 w-80">
|
|
297
|
+
<div>
|
|
298
|
+
<label className="text-sm font-medium mb-1 block">Small Error</label>
|
|
299
|
+
<Input type="text" placeholder="Small error" size="sm" state="error" />
|
|
300
|
+
</div>
|
|
301
|
+
<div>
|
|
302
|
+
<label className="text-sm font-medium mb-1 block">Default Success</label>
|
|
303
|
+
<Input type="text" placeholder="Default success" size="default" state="success" />
|
|
304
|
+
</div>
|
|
305
|
+
<div>
|
|
306
|
+
<label className="text-sm font-medium mb-1 block">Large Warning</label>
|
|
307
|
+
<Input type="text" placeholder="Large warning" size="lg" state="warning" />
|
|
308
|
+
</div>
|
|
309
|
+
</div>
|
|
310
|
+
),
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* All input variants and states showcased together
|
|
315
|
+
*/
|
|
316
|
+
export const AllVariants: Story = {
|
|
317
|
+
render: () => (
|
|
318
|
+
<div className="flex flex-col gap-4 w-80">
|
|
319
|
+
<div>
|
|
320
|
+
<label className="text-sm font-medium mb-1 block">Default Text</label>
|
|
321
|
+
<Input type="text" placeholder="Enter text..." />
|
|
322
|
+
</div>
|
|
323
|
+
|
|
324
|
+
<div>
|
|
325
|
+
<label className="text-sm font-medium mb-1 block">Email</label>
|
|
326
|
+
<Input type="email" placeholder="email@example.com" />
|
|
327
|
+
</div>
|
|
328
|
+
|
|
329
|
+
<div>
|
|
330
|
+
<label className="text-sm font-medium mb-1 block">Password</label>
|
|
331
|
+
<Input type="password" placeholder="Enter password" />
|
|
332
|
+
</div>
|
|
333
|
+
|
|
334
|
+
<div>
|
|
335
|
+
<label className="text-sm font-medium mb-1 block">Number</label>
|
|
336
|
+
<Input type="number" placeholder="Enter number" />
|
|
337
|
+
</div>
|
|
338
|
+
|
|
339
|
+
<div>
|
|
340
|
+
<label className="text-sm font-medium mb-1 block">Search</label>
|
|
341
|
+
<Input type="search" placeholder="Search..." />
|
|
342
|
+
</div>
|
|
343
|
+
|
|
344
|
+
<div>
|
|
345
|
+
<label className="text-sm font-medium mb-1 block">With Value</label>
|
|
346
|
+
<Input type="text" defaultValue="Pre-filled value" />
|
|
347
|
+
</div>
|
|
348
|
+
|
|
349
|
+
<div>
|
|
350
|
+
<label className="text-sm font-medium mb-1 block">Disabled</label>
|
|
351
|
+
<Input type="text" placeholder="Disabled input" disabled />
|
|
352
|
+
</div>
|
|
353
|
+
|
|
354
|
+
<div>
|
|
355
|
+
<label className="text-sm font-medium mb-1 block">Invalid</label>
|
|
356
|
+
<Input
|
|
357
|
+
type="email"
|
|
358
|
+
placeholder="email@example.com"
|
|
359
|
+
defaultValue="invalid-email"
|
|
360
|
+
aria-invalid
|
|
361
|
+
/>
|
|
362
|
+
</div>
|
|
363
|
+
|
|
364
|
+
<div>
|
|
365
|
+
<label className="text-sm font-medium mb-1 block">File</label>
|
|
366
|
+
<Input type="file" />
|
|
367
|
+
</div>
|
|
368
|
+
</div>
|
|
369
|
+
),
|
|
370
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import {
|
|
3
|
+
Input as ShadcnInput,
|
|
4
|
+
inputVariants,
|
|
5
|
+
} from "../../ui/input"
|
|
6
|
+
import type { VariantProps } from "class-variance-authority"
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Input Primitive
|
|
10
|
+
*
|
|
11
|
+
* A foundational input component that wraps shadcn/ui Input with design system
|
|
12
|
+
* enhancements. This primitive serves as the single source of truth for all text
|
|
13
|
+
* input interactions across the application.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* <Input type="text" placeholder="Enter your name" />
|
|
18
|
+
*
|
|
19
|
+
* <Input type="email" placeholder="email@example.com" size="sm" />
|
|
20
|
+
*
|
|
21
|
+
* <Input
|
|
22
|
+
* type="password"
|
|
23
|
+
* placeholder="Enter password"
|
|
24
|
+
* state="error"
|
|
25
|
+
* />
|
|
26
|
+
*
|
|
27
|
+
* <Input
|
|
28
|
+
* type="text"
|
|
29
|
+
* placeholder="Success state"
|
|
30
|
+
* state="success"
|
|
31
|
+
* size="lg"
|
|
32
|
+
* />
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @see https://ui.shadcn.com/docs/components/input - shadcn/ui Input documentation
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Input component props
|
|
40
|
+
* Extends the native input element props with variant options
|
|
41
|
+
*/
|
|
42
|
+
export type InputProps = React.ComponentProps<"input"> &
|
|
43
|
+
VariantProps<typeof inputVariants>
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Input component
|
|
47
|
+
*
|
|
48
|
+
* A versatile input component built on shadcn/ui foundation with full accessibility support.
|
|
49
|
+
* Optimized with React.memo for performance in high-frequency rendering scenarios.
|
|
50
|
+
*
|
|
51
|
+
* Features:
|
|
52
|
+
* - Full WCAG 2.1 Level AA compliance
|
|
53
|
+
* - Support for all native input types
|
|
54
|
+
* - Size variants (sm, default, lg) for different contexts
|
|
55
|
+
* - State variants (default, error, success, warning) for visual feedback
|
|
56
|
+
* - Validation state styling via aria-invalid
|
|
57
|
+
* - Dark mode support
|
|
58
|
+
* - Placeholder and disabled states
|
|
59
|
+
*/
|
|
60
|
+
export const Input = React.memo(
|
|
61
|
+
React.forwardRef<HTMLInputElement, InputProps>(
|
|
62
|
+
(props, ref) => {
|
|
63
|
+
return <ShadcnInput ref={ref} {...props} />
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
Input.displayName = "Input"
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Re-export inputVariants for consumers who need direct access to the variant generator.
|
|
72
|
+
* This is useful for creating custom input-like components that need consistent styling.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```tsx
|
|
76
|
+
* import { inputVariants } from './Input'
|
|
77
|
+
*
|
|
78
|
+
* <div className={inputVariants({ size: "sm", state: "error" })}>
|
|
79
|
+
* Custom input-like div
|
|
80
|
+
* </div>
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export { inputVariants }
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Re-export VariantProps for type inference in consuming components
|
|
87
|
+
*/
|
|
88
|
+
export type { VariantProps }
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import {
|
|
3
|
+
InputGroup,
|
|
4
|
+
InputGroupAddon,
|
|
5
|
+
InputGroupButton,
|
|
6
|
+
InputGroupInput,
|
|
7
|
+
InputGroupText,
|
|
8
|
+
} from "./InputGroup";
|
|
9
|
+
|
|
10
|
+
const meta: Meta<typeof InputGroup> = {
|
|
11
|
+
title: "Primitives/InputGroup",
|
|
12
|
+
component: InputGroup,
|
|
13
|
+
parameters: { layout: "centered" },
|
|
14
|
+
tags: ["autodocs"],
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default meta;
|
|
18
|
+
type Story = StoryObj<typeof InputGroup>;
|
|
19
|
+
|
|
20
|
+
export const Default: Story = {
|
|
21
|
+
render: () => (
|
|
22
|
+
<InputGroup className="w-[300px]">
|
|
23
|
+
<InputGroupAddon align="inline-start">
|
|
24
|
+
<InputGroupText>$</InputGroupText>
|
|
25
|
+
</InputGroupAddon>
|
|
26
|
+
<InputGroupInput type="text" placeholder="0.00" />
|
|
27
|
+
</InputGroup>
|
|
28
|
+
),
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const WithButton: Story = {
|
|
32
|
+
render: () => (
|
|
33
|
+
<InputGroup className="w-[300px]">
|
|
34
|
+
<InputGroupInput type="text" placeholder="Search..." />
|
|
35
|
+
<InputGroupAddon align="inline-end">
|
|
36
|
+
<InputGroupButton>Search</InputGroupButton>
|
|
37
|
+
</InputGroupAddon>
|
|
38
|
+
</InputGroup>
|
|
39
|
+
),
|
|
40
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import {
|
|
5
|
+
InputGroup as ShadcnInputGroup,
|
|
6
|
+
InputGroupAddon as ShadcnInputGroupAddon,
|
|
7
|
+
InputGroupButton as ShadcnInputGroupButton,
|
|
8
|
+
InputGroupInput as ShadcnInputGroupInput,
|
|
9
|
+
InputGroupText as ShadcnInputGroupText,
|
|
10
|
+
InputGroupTextarea as ShadcnInputGroupTextarea,
|
|
11
|
+
} from "@/components/ui/input-group";
|
|
12
|
+
|
|
13
|
+
export type InputGroupProps = React.ComponentProps<typeof ShadcnInputGroup>;
|
|
14
|
+
export type InputGroupAddonProps = React.ComponentProps<typeof ShadcnInputGroupAddon>;
|
|
15
|
+
export type InputGroupButtonProps = React.ComponentProps<typeof ShadcnInputGroupButton>;
|
|
16
|
+
export type InputGroupInputProps = React.ComponentProps<typeof ShadcnInputGroupInput>;
|
|
17
|
+
export type InputGroupTextProps = React.ComponentProps<typeof ShadcnInputGroupText>;
|
|
18
|
+
export type InputGroupTextareaProps = React.ComponentProps<typeof ShadcnInputGroupTextarea>;
|
|
19
|
+
|
|
20
|
+
export const InputGroup = React.memo<InputGroupProps>(
|
|
21
|
+
React.forwardRef<React.ElementRef<typeof ShadcnInputGroup>, InputGroupProps>(
|
|
22
|
+
(props, ref) => {
|
|
23
|
+
return <ShadcnInputGroup ref={ref} {...props} />;
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
);
|
|
27
|
+
InputGroup.displayName = "InputGroup";
|
|
28
|
+
|
|
29
|
+
export const InputGroupAddon = React.memo<InputGroupAddonProps>(
|
|
30
|
+
React.forwardRef<React.ElementRef<typeof ShadcnInputGroupAddon>, InputGroupAddonProps>(
|
|
31
|
+
(props, ref) => {
|
|
32
|
+
return <ShadcnInputGroupAddon ref={ref} {...props} />;
|
|
33
|
+
}
|
|
34
|
+
)
|
|
35
|
+
);
|
|
36
|
+
InputGroupAddon.displayName = "InputGroupAddon";
|
|
37
|
+
|
|
38
|
+
export const InputGroupButton = React.memo<InputGroupButtonProps>(
|
|
39
|
+
React.forwardRef<React.ElementRef<typeof ShadcnInputGroupButton>, InputGroupButtonProps>(
|
|
40
|
+
(props, ref) => {
|
|
41
|
+
return <ShadcnInputGroupButton ref={ref} {...props} />;
|
|
42
|
+
}
|
|
43
|
+
)
|
|
44
|
+
);
|
|
45
|
+
InputGroupButton.displayName = "InputGroupButton";
|
|
46
|
+
|
|
47
|
+
export const InputGroupInput = React.memo<InputGroupInputProps>(
|
|
48
|
+
React.forwardRef<React.ElementRef<typeof ShadcnInputGroupInput>, InputGroupInputProps>(
|
|
49
|
+
(props, ref) => {
|
|
50
|
+
return <ShadcnInputGroupInput ref={ref} {...props} />;
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
);
|
|
54
|
+
InputGroupInput.displayName = "InputGroupInput";
|
|
55
|
+
|
|
56
|
+
export const InputGroupText = React.memo<InputGroupTextProps>(
|
|
57
|
+
React.forwardRef<React.ElementRef<typeof ShadcnInputGroupText>, InputGroupTextProps>(
|
|
58
|
+
(props, ref) => {
|
|
59
|
+
return <ShadcnInputGroupText ref={ref} {...props} />;
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
);
|
|
63
|
+
InputGroupText.displayName = "InputGroupText";
|
|
64
|
+
|
|
65
|
+
export const InputGroupTextarea = React.memo<InputGroupTextareaProps>(
|
|
66
|
+
React.forwardRef<React.ElementRef<typeof ShadcnInputGroupTextarea>, InputGroupTextareaProps>(
|
|
67
|
+
(props, ref) => {
|
|
68
|
+
return <ShadcnInputGroupTextarea ref={ref} {...props} />;
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
);
|
|
72
|
+
InputGroupTextarea.displayName = "InputGroupTextarea";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export {
|
|
2
|
+
InputGroup,
|
|
3
|
+
InputGroupAddon,
|
|
4
|
+
InputGroupButton,
|
|
5
|
+
InputGroupInput,
|
|
6
|
+
InputGroupText,
|
|
7
|
+
InputGroupTextarea,
|
|
8
|
+
type InputGroupProps,
|
|
9
|
+
type InputGroupAddonProps,
|
|
10
|
+
type InputGroupButtonProps,
|
|
11
|
+
type InputGroupInputProps,
|
|
12
|
+
type InputGroupTextProps,
|
|
13
|
+
type InputGroupTextareaProps,
|
|
14
|
+
} from "./InputGroup";
|