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,389 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
2
|
+
import {
|
|
3
|
+
Table,
|
|
4
|
+
TableHeader,
|
|
5
|
+
TableBody,
|
|
6
|
+
TableFooter,
|
|
7
|
+
TableRow,
|
|
8
|
+
TableHead,
|
|
9
|
+
TableCell,
|
|
10
|
+
TableCaption,
|
|
11
|
+
} from './Table'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Table Primitive Stories
|
|
15
|
+
*
|
|
16
|
+
* The Table component is a foundational primitive for displaying tabular data.
|
|
17
|
+
* It extends shadcn/ui's Table with design system-specific enhancements and maintains
|
|
18
|
+
* full accessibility compliance (WCAG 2.1 Level AA).
|
|
19
|
+
*
|
|
20
|
+
* ## Features
|
|
21
|
+
* - Semantic HTML table structure
|
|
22
|
+
* - Responsive overflow handling
|
|
23
|
+
* - Consistent styling across the application
|
|
24
|
+
* - Dark mode support
|
|
25
|
+
* - Accessible table structure
|
|
26
|
+
*
|
|
27
|
+
* ## Accessibility
|
|
28
|
+
* - Uses semantic table elements
|
|
29
|
+
* - Proper header associations with scope attributes
|
|
30
|
+
* - Caption support for screen readers
|
|
31
|
+
* - Keyboard navigation support
|
|
32
|
+
* - Maintains proper color contrast ratios
|
|
33
|
+
*
|
|
34
|
+
* ## Usage Guidelines
|
|
35
|
+
*
|
|
36
|
+
* ### Do's
|
|
37
|
+
* - Use for displaying structured tabular data
|
|
38
|
+
* - Include TableCaption for accessibility
|
|
39
|
+
* - Use TableHead for column headers
|
|
40
|
+
* - Ensure proper header-cell associations
|
|
41
|
+
*
|
|
42
|
+
* ### Don'ts
|
|
43
|
+
* - Don't use tables for layout purposes
|
|
44
|
+
* - Don't omit table headers
|
|
45
|
+
* - Don't nest tables unnecessarily
|
|
46
|
+
* - Don't use tables for non-tabular data
|
|
47
|
+
*/
|
|
48
|
+
const meta = {
|
|
49
|
+
title: 'Primitives/Table',
|
|
50
|
+
component: Table,
|
|
51
|
+
tags: ['autodocs'],
|
|
52
|
+
parameters: {
|
|
53
|
+
layout: 'padded',
|
|
54
|
+
docs: {
|
|
55
|
+
description: {
|
|
56
|
+
component: 'A semantic table component for displaying tabular data, built on shadcn/ui foundation.',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
} satisfies Meta<typeof Table>
|
|
61
|
+
|
|
62
|
+
export default meta
|
|
63
|
+
type Story = StoryObj<typeof meta>
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Default table
|
|
67
|
+
*
|
|
68
|
+
* Basic table with header and body rows.
|
|
69
|
+
*/
|
|
70
|
+
export const Default: Story = {
|
|
71
|
+
render: () => (
|
|
72
|
+
<Table>
|
|
73
|
+
<TableHeader>
|
|
74
|
+
<TableRow>
|
|
75
|
+
<TableHead>Name</TableHead>
|
|
76
|
+
<TableHead>Email</TableHead>
|
|
77
|
+
<TableHead>Role</TableHead>
|
|
78
|
+
</TableRow>
|
|
79
|
+
</TableHeader>
|
|
80
|
+
<TableBody>
|
|
81
|
+
<TableRow>
|
|
82
|
+
<TableCell>John Doe</TableCell>
|
|
83
|
+
<TableCell>john@example.com</TableCell>
|
|
84
|
+
<TableCell>Admin</TableCell>
|
|
85
|
+
</TableRow>
|
|
86
|
+
<TableRow>
|
|
87
|
+
<TableCell>Jane Smith</TableCell>
|
|
88
|
+
<TableCell>jane@example.com</TableCell>
|
|
89
|
+
<TableCell>User</TableCell>
|
|
90
|
+
</TableRow>
|
|
91
|
+
<TableRow>
|
|
92
|
+
<TableCell>Bob Johnson</TableCell>
|
|
93
|
+
<TableCell>bob@example.com</TableCell>
|
|
94
|
+
<TableCell>User</TableCell>
|
|
95
|
+
</TableRow>
|
|
96
|
+
</TableBody>
|
|
97
|
+
</Table>
|
|
98
|
+
),
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* With Caption
|
|
103
|
+
*
|
|
104
|
+
* Table with an accessible caption for screen readers.
|
|
105
|
+
*/
|
|
106
|
+
export const WithCaption: Story = {
|
|
107
|
+
render: () => (
|
|
108
|
+
<Table>
|
|
109
|
+
<TableCaption>A list of team members and their roles</TableCaption>
|
|
110
|
+
<TableHeader>
|
|
111
|
+
<TableRow>
|
|
112
|
+
<TableHead>Name</TableHead>
|
|
113
|
+
<TableHead>Email</TableHead>
|
|
114
|
+
<TableHead>Role</TableHead>
|
|
115
|
+
</TableRow>
|
|
116
|
+
</TableHeader>
|
|
117
|
+
<TableBody>
|
|
118
|
+
<TableRow>
|
|
119
|
+
<TableCell>John Doe</TableCell>
|
|
120
|
+
<TableCell>john@example.com</TableCell>
|
|
121
|
+
<TableCell>Admin</TableCell>
|
|
122
|
+
</TableRow>
|
|
123
|
+
<TableRow>
|
|
124
|
+
<TableCell>Jane Smith</TableCell>
|
|
125
|
+
<TableCell>jane@example.com</TableCell>
|
|
126
|
+
<TableCell>User</TableCell>
|
|
127
|
+
</TableRow>
|
|
128
|
+
</TableBody>
|
|
129
|
+
</Table>
|
|
130
|
+
),
|
|
131
|
+
parameters: {
|
|
132
|
+
docs: {
|
|
133
|
+
description: {
|
|
134
|
+
story: 'TableCaption provides context for screen reader users.',
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* With Footer
|
|
142
|
+
*
|
|
143
|
+
* Table with a footer row for totals or summaries.
|
|
144
|
+
*/
|
|
145
|
+
export const WithFooter: Story = {
|
|
146
|
+
render: () => (
|
|
147
|
+
<Table>
|
|
148
|
+
<TableHeader>
|
|
149
|
+
<TableRow>
|
|
150
|
+
<TableHead>Product</TableHead>
|
|
151
|
+
<TableHead>Quantity</TableHead>
|
|
152
|
+
<TableHead className="text-right">Price</TableHead>
|
|
153
|
+
</TableRow>
|
|
154
|
+
</TableHeader>
|
|
155
|
+
<TableBody>
|
|
156
|
+
<TableRow>
|
|
157
|
+
<TableCell>Widget A</TableCell>
|
|
158
|
+
<TableCell>5</TableCell>
|
|
159
|
+
<TableCell className="text-right">$50.00</TableCell>
|
|
160
|
+
</TableRow>
|
|
161
|
+
<TableRow>
|
|
162
|
+
<TableCell>Widget B</TableCell>
|
|
163
|
+
<TableCell>3</TableCell>
|
|
164
|
+
<TableCell className="text-right">$30.00</TableCell>
|
|
165
|
+
</TableRow>
|
|
166
|
+
<TableRow>
|
|
167
|
+
<TableCell>Widget C</TableCell>
|
|
168
|
+
<TableCell>2</TableCell>
|
|
169
|
+
<TableCell className="text-right">$20.00</TableCell>
|
|
170
|
+
</TableRow>
|
|
171
|
+
</TableBody>
|
|
172
|
+
<TableFooter>
|
|
173
|
+
<TableRow>
|
|
174
|
+
<TableCell colSpan={2}>Total</TableCell>
|
|
175
|
+
<TableCell className="text-right">$100.00</TableCell>
|
|
176
|
+
</TableRow>
|
|
177
|
+
</TableFooter>
|
|
178
|
+
</Table>
|
|
179
|
+
),
|
|
180
|
+
parameters: {
|
|
181
|
+
docs: {
|
|
182
|
+
description: {
|
|
183
|
+
story: 'TableFooter is useful for displaying totals or summary information.',
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* With Alignment
|
|
191
|
+
*
|
|
192
|
+
* Table demonstrating different text alignments.
|
|
193
|
+
*/
|
|
194
|
+
export const WithAlignment: Story = {
|
|
195
|
+
render: () => (
|
|
196
|
+
<Table>
|
|
197
|
+
<TableHeader>
|
|
198
|
+
<TableRow>
|
|
199
|
+
<TableHead>Product</TableHead>
|
|
200
|
+
<TableHead className="text-center">Status</TableHead>
|
|
201
|
+
<TableHead className="text-right">Price</TableHead>
|
|
202
|
+
</TableRow>
|
|
203
|
+
</TableHeader>
|
|
204
|
+
<TableBody>
|
|
205
|
+
<TableRow>
|
|
206
|
+
<TableCell>Widget A</TableCell>
|
|
207
|
+
<TableCell className="text-center">In Stock</TableCell>
|
|
208
|
+
<TableCell className="text-right">$50.00</TableCell>
|
|
209
|
+
</TableRow>
|
|
210
|
+
<TableRow>
|
|
211
|
+
<TableCell>Widget B</TableCell>
|
|
212
|
+
<TableCell className="text-center">Low Stock</TableCell>
|
|
213
|
+
<TableCell className="text-right">$30.00</TableCell>
|
|
214
|
+
</TableRow>
|
|
215
|
+
<TableRow>
|
|
216
|
+
<TableCell>Widget C</TableCell>
|
|
217
|
+
<TableCell className="text-center">Out of Stock</TableCell>
|
|
218
|
+
<TableCell className="text-right">$20.00</TableCell>
|
|
219
|
+
</TableRow>
|
|
220
|
+
</TableBody>
|
|
221
|
+
</Table>
|
|
222
|
+
),
|
|
223
|
+
parameters: {
|
|
224
|
+
docs: {
|
|
225
|
+
description: {
|
|
226
|
+
story: 'Use text alignment classes to align content appropriately (numbers right-aligned, status centered).',
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* With Many Columns
|
|
234
|
+
*
|
|
235
|
+
* Table with multiple columns demonstrating horizontal scrolling.
|
|
236
|
+
*/
|
|
237
|
+
export const WithManyColumns: Story = {
|
|
238
|
+
render: () => (
|
|
239
|
+
<Table>
|
|
240
|
+
<TableHeader>
|
|
241
|
+
<TableRow>
|
|
242
|
+
<TableHead>ID</TableHead>
|
|
243
|
+
<TableHead>Name</TableHead>
|
|
244
|
+
<TableHead>Email</TableHead>
|
|
245
|
+
<TableHead>Role</TableHead>
|
|
246
|
+
<TableHead>Department</TableHead>
|
|
247
|
+
<TableHead>Status</TableHead>
|
|
248
|
+
<TableHead className="text-right">Salary</TableHead>
|
|
249
|
+
</TableRow>
|
|
250
|
+
</TableHeader>
|
|
251
|
+
<TableBody>
|
|
252
|
+
<TableRow>
|
|
253
|
+
<TableCell>001</TableCell>
|
|
254
|
+
<TableCell>John Doe</TableCell>
|
|
255
|
+
<TableCell>john@example.com</TableCell>
|
|
256
|
+
<TableCell>Admin</TableCell>
|
|
257
|
+
<TableCell>Engineering</TableCell>
|
|
258
|
+
<TableCell>Active</TableCell>
|
|
259
|
+
<TableCell className="text-right">$120,000</TableCell>
|
|
260
|
+
</TableRow>
|
|
261
|
+
<TableRow>
|
|
262
|
+
<TableCell>002</TableCell>
|
|
263
|
+
<TableCell>Jane Smith</TableCell>
|
|
264
|
+
<TableCell>jane@example.com</TableCell>
|
|
265
|
+
<TableCell>Manager</TableCell>
|
|
266
|
+
<TableCell>Sales</TableCell>
|
|
267
|
+
<TableCell>Active</TableCell>
|
|
268
|
+
<TableCell className="text-right">$95,000</TableCell>
|
|
269
|
+
</TableRow>
|
|
270
|
+
<TableRow>
|
|
271
|
+
<TableCell>003</TableCell>
|
|
272
|
+
<TableCell>Bob Johnson</TableCell>
|
|
273
|
+
<TableCell>bob@example.com</TableCell>
|
|
274
|
+
<TableCell>Developer</TableCell>
|
|
275
|
+
<TableCell>Engineering</TableCell>
|
|
276
|
+
<TableCell>Active</TableCell>
|
|
277
|
+
<TableCell className="text-right">$85,000</TableCell>
|
|
278
|
+
</TableRow>
|
|
279
|
+
</TableBody>
|
|
280
|
+
</Table>
|
|
281
|
+
),
|
|
282
|
+
parameters: {
|
|
283
|
+
docs: {
|
|
284
|
+
description: {
|
|
285
|
+
story: 'Tables with many columns automatically handle overflow with horizontal scrolling.',
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* With Row States
|
|
293
|
+
*
|
|
294
|
+
* Table demonstrating different row states (hover, selected).
|
|
295
|
+
*/
|
|
296
|
+
export const WithRowStates: Story = {
|
|
297
|
+
render: () => (
|
|
298
|
+
<Table>
|
|
299
|
+
<TableHeader>
|
|
300
|
+
<TableRow>
|
|
301
|
+
<TableHead>Name</TableHead>
|
|
302
|
+
<TableHead>Email</TableHead>
|
|
303
|
+
<TableHead>Status</TableHead>
|
|
304
|
+
</TableRow>
|
|
305
|
+
</TableHeader>
|
|
306
|
+
<TableBody>
|
|
307
|
+
<TableRow>
|
|
308
|
+
<TableCell>John Doe</TableCell>
|
|
309
|
+
<TableCell>john@example.com</TableCell>
|
|
310
|
+
<TableCell>Active</TableCell>
|
|
311
|
+
</TableRow>
|
|
312
|
+
<TableRow data-state="selected">
|
|
313
|
+
<TableCell>Jane Smith</TableCell>
|
|
314
|
+
<TableCell>jane@example.com</TableCell>
|
|
315
|
+
<TableCell>Active</TableCell>
|
|
316
|
+
</TableRow>
|
|
317
|
+
<TableRow>
|
|
318
|
+
<TableCell>Bob Johnson</TableCell>
|
|
319
|
+
<TableCell>bob@example.com</TableCell>
|
|
320
|
+
<TableCell>Inactive</TableCell>
|
|
321
|
+
</TableRow>
|
|
322
|
+
</TableBody>
|
|
323
|
+
</Table>
|
|
324
|
+
),
|
|
325
|
+
parameters: {
|
|
326
|
+
docs: {
|
|
327
|
+
description: {
|
|
328
|
+
story: 'Rows support hover and selected states via data-state attribute.',
|
|
329
|
+
},
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Dark Mode Preview
|
|
336
|
+
*
|
|
337
|
+
* Table in dark mode to verify theming compatibility.
|
|
338
|
+
*/
|
|
339
|
+
export const DarkMode: Story = {
|
|
340
|
+
render: () => (
|
|
341
|
+
<div className="dark" style={{ padding: '24px', background: 'hsl(222.2 84% 4.9%)', borderRadius: '8px' }}>
|
|
342
|
+
<Table>
|
|
343
|
+
<TableCaption>A list of team members in dark mode</TableCaption>
|
|
344
|
+
<TableHeader>
|
|
345
|
+
<TableRow>
|
|
346
|
+
<TableHead>Name</TableHead>
|
|
347
|
+
<TableHead>Email</TableHead>
|
|
348
|
+
<TableHead>Role</TableHead>
|
|
349
|
+
<TableHead className="text-right">Salary</TableHead>
|
|
350
|
+
</TableRow>
|
|
351
|
+
</TableHeader>
|
|
352
|
+
<TableBody>
|
|
353
|
+
<TableRow>
|
|
354
|
+
<TableCell>John Doe</TableCell>
|
|
355
|
+
<TableCell>john@example.com</TableCell>
|
|
356
|
+
<TableCell>Admin</TableCell>
|
|
357
|
+
<TableCell className="text-right">$120,000</TableCell>
|
|
358
|
+
</TableRow>
|
|
359
|
+
<TableRow data-state="selected">
|
|
360
|
+
<TableCell>Jane Smith</TableCell>
|
|
361
|
+
<TableCell>jane@example.com</TableCell>
|
|
362
|
+
<TableCell>Manager</TableCell>
|
|
363
|
+
<TableCell className="text-right">$95,000</TableCell>
|
|
364
|
+
</TableRow>
|
|
365
|
+
<TableRow>
|
|
366
|
+
<TableCell>Bob Johnson</TableCell>
|
|
367
|
+
<TableCell>bob@example.com</TableCell>
|
|
368
|
+
<TableCell>Developer</TableCell>
|
|
369
|
+
<TableCell className="text-right">$85,000</TableCell>
|
|
370
|
+
</TableRow>
|
|
371
|
+
</TableBody>
|
|
372
|
+
<TableFooter>
|
|
373
|
+
<TableRow>
|
|
374
|
+
<TableCell colSpan={3}>Total</TableCell>
|
|
375
|
+
<TableCell className="text-right">$300,000</TableCell>
|
|
376
|
+
</TableRow>
|
|
377
|
+
</TableFooter>
|
|
378
|
+
</Table>
|
|
379
|
+
</div>
|
|
380
|
+
),
|
|
381
|
+
parameters: {
|
|
382
|
+
docs: {
|
|
383
|
+
description: {
|
|
384
|
+
story: 'Tables automatically adapt to dark mode with appropriate contrast and visibility.',
|
|
385
|
+
},
|
|
386
|
+
},
|
|
387
|
+
backgrounds: { disable: true },
|
|
388
|
+
},
|
|
389
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import {
|
|
3
|
+
Table as ShadcnTable,
|
|
4
|
+
TableHeader as ShadcnTableHeader,
|
|
5
|
+
TableBody as ShadcnTableBody,
|
|
6
|
+
TableFooter as ShadcnTableFooter,
|
|
7
|
+
TableRow as ShadcnTableRow,
|
|
8
|
+
TableHead as ShadcnTableHead,
|
|
9
|
+
TableCell as ShadcnTableCell,
|
|
10
|
+
TableCaption as ShadcnTableCaption,
|
|
11
|
+
} from "../../ui/table"
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Table Primitive
|
|
15
|
+
*
|
|
16
|
+
* A foundational table component that wraps shadcn/ui Table with design system
|
|
17
|
+
* enhancements. This primitive serves as the single source of truth for all tabular
|
|
18
|
+
* data display across the application.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* <Table>
|
|
23
|
+
* <TableHeader>
|
|
24
|
+
* <TableRow>
|
|
25
|
+
* <TableHead>Name</TableHead>
|
|
26
|
+
* <TableHead>Email</TableHead>
|
|
27
|
+
* </TableRow>
|
|
28
|
+
* </TableHeader>
|
|
29
|
+
* <TableBody>
|
|
30
|
+
* <TableRow>
|
|
31
|
+
* <TableCell>John Doe</TableCell>
|
|
32
|
+
* <TableCell>john@example.com</TableCell>
|
|
33
|
+
* </TableRow>
|
|
34
|
+
* </TableBody>
|
|
35
|
+
* </Table>
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @see https://ui.shadcn.com/docs/components/table - shadcn/ui Table documentation
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Table component props
|
|
43
|
+
*/
|
|
44
|
+
export type TableProps = React.HTMLAttributes<HTMLTableElement>
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Table component
|
|
48
|
+
*
|
|
49
|
+
* A semantic table component for displaying tabular data, built on shadcn/ui foundation.
|
|
50
|
+
* Optimized with React.memo for performance in high-frequency rendering scenarios.
|
|
51
|
+
*
|
|
52
|
+
* Features:
|
|
53
|
+
* - Semantic HTML table structure
|
|
54
|
+
* - Responsive overflow handling
|
|
55
|
+
* - Consistent styling across the application
|
|
56
|
+
* - Dark mode support
|
|
57
|
+
* - Accessible table structure
|
|
58
|
+
*/
|
|
59
|
+
export const Table = React.memo(
|
|
60
|
+
React.forwardRef<HTMLTableElement, TableProps>((props, ref) => {
|
|
61
|
+
return <ShadcnTable ref={ref} {...props} />
|
|
62
|
+
})
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
Table.displayName = "Table"
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* TableHeader component props
|
|
69
|
+
*/
|
|
70
|
+
export type TableHeaderProps = React.HTMLAttributes<HTMLTableSectionElement>
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* TableHeader component
|
|
74
|
+
*
|
|
75
|
+
* Wraps table header rows with proper semantic markup.
|
|
76
|
+
*/
|
|
77
|
+
export const TableHeader = React.memo(
|
|
78
|
+
React.forwardRef<HTMLTableSectionElement, TableHeaderProps>((props, ref) => {
|
|
79
|
+
return <ShadcnTableHeader ref={ref} {...props} />
|
|
80
|
+
})
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
TableHeader.displayName = "TableHeader"
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* TableBody component props
|
|
87
|
+
*/
|
|
88
|
+
export type TableBodyProps = React.HTMLAttributes<HTMLTableSectionElement>
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* TableBody component
|
|
92
|
+
*
|
|
93
|
+
* Wraps table body rows with proper semantic markup.
|
|
94
|
+
*/
|
|
95
|
+
export const TableBody = React.memo(
|
|
96
|
+
React.forwardRef<HTMLTableSectionElement, TableBodyProps>((props, ref) => {
|
|
97
|
+
return <ShadcnTableBody ref={ref} {...props} />
|
|
98
|
+
})
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
TableBody.displayName = "TableBody"
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* TableFooter component props
|
|
105
|
+
*/
|
|
106
|
+
export type TableFooterProps = React.HTMLAttributes<HTMLTableSectionElement>
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* TableFooter component
|
|
110
|
+
*
|
|
111
|
+
* Wraps table footer rows with proper semantic markup.
|
|
112
|
+
*/
|
|
113
|
+
export const TableFooter = React.memo(
|
|
114
|
+
React.forwardRef<HTMLTableSectionElement, TableFooterProps>((props, ref) => {
|
|
115
|
+
return <ShadcnTableFooter ref={ref} {...props} />
|
|
116
|
+
})
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
TableFooter.displayName = "TableFooter"
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* TableRow component props
|
|
123
|
+
*/
|
|
124
|
+
export type TableRowProps = React.HTMLAttributes<HTMLTableRowElement>
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* TableRow component
|
|
128
|
+
*
|
|
129
|
+
* Represents a single row in the table.
|
|
130
|
+
*/
|
|
131
|
+
export const TableRow = React.memo(
|
|
132
|
+
React.forwardRef<HTMLTableRowElement, TableRowProps>((props, ref) => {
|
|
133
|
+
return <ShadcnTableRow ref={ref} {...props} />
|
|
134
|
+
})
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
TableRow.displayName = "TableRow"
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* TableHead component props
|
|
141
|
+
*/
|
|
142
|
+
export type TableHeadProps = React.ThHTMLAttributes<HTMLTableCellElement>
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* TableHead component
|
|
146
|
+
*
|
|
147
|
+
* Represents a header cell in the table.
|
|
148
|
+
*/
|
|
149
|
+
export const TableHead = React.memo(
|
|
150
|
+
React.forwardRef<HTMLTableCellElement, TableHeadProps>((props, ref) => {
|
|
151
|
+
return <ShadcnTableHead ref={ref} {...props} />
|
|
152
|
+
})
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
TableHead.displayName = "TableHead"
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* TableCell component props
|
|
159
|
+
*/
|
|
160
|
+
export type TableCellProps = React.TdHTMLAttributes<HTMLTableCellElement>
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* TableCell component
|
|
164
|
+
*
|
|
165
|
+
* Represents a data cell in the table.
|
|
166
|
+
*/
|
|
167
|
+
export const TableCell = React.memo(
|
|
168
|
+
React.forwardRef<HTMLTableCellElement, TableCellProps>((props, ref) => {
|
|
169
|
+
return <ShadcnTableCell ref={ref} {...props} />
|
|
170
|
+
})
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
TableCell.displayName = "TableCell"
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* TableCaption component props
|
|
177
|
+
*/
|
|
178
|
+
export type TableCaptionProps = React.HTMLAttributes<HTMLTableCaptionElement>
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* TableCaption component
|
|
182
|
+
*
|
|
183
|
+
* Provides a caption for the table for accessibility.
|
|
184
|
+
*/
|
|
185
|
+
export const TableCaption = React.memo(
|
|
186
|
+
React.forwardRef<HTMLTableCaptionElement, TableCaptionProps>((props, ref) => {
|
|
187
|
+
return <ShadcnTableCaption ref={ref} {...props} />
|
|
188
|
+
})
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
TableCaption.displayName = "TableCaption"
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Table Primitive
|
|
3
|
+
*
|
|
4
|
+
* Central export point for the Table primitive component and its related types.
|
|
5
|
+
*/
|
|
6
|
+
export {
|
|
7
|
+
Table,
|
|
8
|
+
TableHeader,
|
|
9
|
+
TableBody,
|
|
10
|
+
TableFooter,
|
|
11
|
+
TableRow,
|
|
12
|
+
TableHead,
|
|
13
|
+
TableCell,
|
|
14
|
+
TableCaption,
|
|
15
|
+
} from './Table'
|
|
16
|
+
|
|
17
|
+
export type {
|
|
18
|
+
TableProps,
|
|
19
|
+
TableHeaderProps,
|
|
20
|
+
TableBodyProps,
|
|
21
|
+
TableFooterProps,
|
|
22
|
+
TableRowProps,
|
|
23
|
+
TableHeadProps,
|
|
24
|
+
TableCellProps,
|
|
25
|
+
TableCaptionProps,
|
|
26
|
+
} from './Table'
|