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,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook Contract Definition for SpecNavigator
|
|
3
|
+
*
|
|
4
|
+
* This file defines the interface contract between the SpecNavigator design system
|
|
5
|
+
* component and consuming applications. Applications should implement this hook
|
|
6
|
+
* to provide real data and state management for the SpecNavigator feature.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* // Application implementation example
|
|
11
|
+
* import { useSpecNavigator } from './hooks/useSpecNavigator';
|
|
12
|
+
* import { SpecNavigator } from '@/components/features/SpecNavigator';
|
|
13
|
+
*
|
|
14
|
+
* function MySpecView() {
|
|
15
|
+
* const { groups, selectedFileId, loading, handleFileSelect } = useSpecNavigator();
|
|
16
|
+
*
|
|
17
|
+
* if (loading) {
|
|
18
|
+
* return <div>Loading specifications...</div>;
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* return (
|
|
22
|
+
* <SpecNavigator
|
|
23
|
+
* groups={groups}
|
|
24
|
+
* selectedFileId={selectedFileId}
|
|
25
|
+
* onFileSelect={handleFileSelect}
|
|
26
|
+
* />
|
|
27
|
+
* );
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* // Real implementation with API integration
|
|
34
|
+
* export function useSpecNavigator(): UseSpecNavigatorReturn {
|
|
35
|
+
* const [groups, setGroups] = useState<FileGroup[]>([]);
|
|
36
|
+
* const [selectedFileId, setSelectedFileId] = useState<string>();
|
|
37
|
+
* const [loading, setLoading] = useState(true);
|
|
38
|
+
*
|
|
39
|
+
* useEffect(() => {
|
|
40
|
+
* async function fetchSpecs() {
|
|
41
|
+
* setLoading(true);
|
|
42
|
+
* try {
|
|
43
|
+
* const data = await api.getSpecifications();
|
|
44
|
+
* setGroups(transformToFileGroups(data));
|
|
45
|
+
* } catch (error) {
|
|
46
|
+
* console.error('Failed to load specs:', error);
|
|
47
|
+
* } finally {
|
|
48
|
+
* setLoading(false);
|
|
49
|
+
* }
|
|
50
|
+
* }
|
|
51
|
+
* fetchSpecs();
|
|
52
|
+
* }, []);
|
|
53
|
+
*
|
|
54
|
+
* const handleFileSelect = useCallback((fileId: string) => {
|
|
55
|
+
* setSelectedFileId(fileId);
|
|
56
|
+
* // Additional logic: navigate, load file content, etc.
|
|
57
|
+
* }, []);
|
|
58
|
+
*
|
|
59
|
+
* return { groups, selectedFileId, loading, handleFileSelect };
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
import type { FileGroup } from "@/components/composites/FileQueue";
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Return type for the useSpecNavigator hook
|
|
68
|
+
*
|
|
69
|
+
* This interface defines the contract that application implementations must fulfill
|
|
70
|
+
* to integrate with the SpecNavigator component.
|
|
71
|
+
*/
|
|
72
|
+
export interface UseSpecNavigatorReturn {
|
|
73
|
+
/**
|
|
74
|
+
* File groups to display in the navigator
|
|
75
|
+
*
|
|
76
|
+
* Each group represents a category of specification files (e.g., Instructions,
|
|
77
|
+
* Agents, Toolbox, Triggers) with associated files. Groups should be ordered as they should
|
|
78
|
+
* appear in the UI.
|
|
79
|
+
*/
|
|
80
|
+
groups: FileGroup[];
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* ID of the currently selected file
|
|
84
|
+
*
|
|
85
|
+
* When set, the corresponding file in the navigator will be visually highlighted.
|
|
86
|
+
* This should match the `id` property of a file within one of the groups.
|
|
87
|
+
*/
|
|
88
|
+
selectedFileId?: string;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Loading state indicator
|
|
92
|
+
*
|
|
93
|
+
* When true, indicates that specification data is being fetched or processed.
|
|
94
|
+
* Applications can use this to show loading states or disable interactions.
|
|
95
|
+
*/
|
|
96
|
+
loading: boolean;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Handler for file selection events
|
|
100
|
+
*
|
|
101
|
+
* Called when a user selects a file in the navigator. Applications should
|
|
102
|
+
* implement this to update the selected file state and perform any additional
|
|
103
|
+
* actions (e.g., loading file content, navigation, analytics).
|
|
104
|
+
*
|
|
105
|
+
* @param fileId - The unique identifier of the selected file
|
|
106
|
+
*/
|
|
107
|
+
handleFileSelect: (fileId: string) => void;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Hook for managing spec navigator state and interactions
|
|
112
|
+
*
|
|
113
|
+
* Applications must implement this hook to provide data and state management
|
|
114
|
+
* for the SpecNavigator component. The hook should handle:
|
|
115
|
+
* - Fetching specification file data from APIs or local sources
|
|
116
|
+
* - Managing file selection state
|
|
117
|
+
* - Transforming raw data into FileGroup format
|
|
118
|
+
* - Handling loading and error states
|
|
119
|
+
*
|
|
120
|
+
* @returns {UseSpecNavigatorReturn} Object containing groups, selection state, and handlers
|
|
121
|
+
*/
|
|
122
|
+
export function useSpecNavigator(): UseSpecNavigatorReturn;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { useState, useCallback } from "react";
|
|
2
|
+
import type { FileGroup } from "@/components/composites/FileQueue";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mock hook for SpecNavigator state management
|
|
6
|
+
*
|
|
7
|
+
* This mock simulates the behavior of a real application hook that would:
|
|
8
|
+
* - Fetch specification files from an API or file system
|
|
9
|
+
* - Manage file selection state
|
|
10
|
+
* - Transform raw data into FileGroup format
|
|
11
|
+
* - Handle loading states during data fetching
|
|
12
|
+
*
|
|
13
|
+
* Use this as a reference for implementing real application hooks.
|
|
14
|
+
*/
|
|
15
|
+
export interface UseSpecNavigatorReturn {
|
|
16
|
+
/** File groups to display in the navigator */
|
|
17
|
+
groups: FileGroup[];
|
|
18
|
+
/** ID of the currently selected file */
|
|
19
|
+
selectedFileId?: string;
|
|
20
|
+
/** Loading state indicator */
|
|
21
|
+
loading: boolean;
|
|
22
|
+
/** Handler for file selection events */
|
|
23
|
+
handleFileSelect: (fileId: string) => void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface UseSpecNavigatorOptions {
|
|
27
|
+
/** Initial file groups to display */
|
|
28
|
+
initialGroups?: FileGroup[];
|
|
29
|
+
/** Initial selected file ID */
|
|
30
|
+
initialSelectedId?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Mock implementation of spec navigator state management
|
|
35
|
+
*
|
|
36
|
+
* This mock provides a simple state management implementation for Storybook
|
|
37
|
+
* demonstrations. Real applications should implement the useSpecNavigator hook
|
|
38
|
+
* with actual API integration, error handling, and more sophisticated state
|
|
39
|
+
* management.
|
|
40
|
+
*
|
|
41
|
+
* @param options - Configuration for mock behavior
|
|
42
|
+
* @returns State and handlers for spec navigation
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* // In a Storybook story
|
|
47
|
+
* const { groups, selectedFileId, handleFileSelect } = useMockSpecNavigator({
|
|
48
|
+
* initialGroups: [
|
|
49
|
+
* {
|
|
50
|
+
* id: 'requirements',
|
|
51
|
+
* title: 'Requirements',
|
|
52
|
+
* files: [{ id: 'req1', name: 'requirements.md' }],
|
|
53
|
+
* },
|
|
54
|
+
* ],
|
|
55
|
+
* initialSelectedId: 'req1',
|
|
56
|
+
* });
|
|
57
|
+
*
|
|
58
|
+
* return (
|
|
59
|
+
* <SpecNavigator
|
|
60
|
+
* groups={groups}
|
|
61
|
+
* selectedFileId={selectedFileId}
|
|
62
|
+
* onFileSelect={handleFileSelect}
|
|
63
|
+
* />
|
|
64
|
+
* );
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export function useMockSpecNavigator(
|
|
68
|
+
options: UseSpecNavigatorOptions = {}
|
|
69
|
+
): UseSpecNavigatorReturn {
|
|
70
|
+
const { initialGroups = [], initialSelectedId } = options;
|
|
71
|
+
|
|
72
|
+
const [groups] = useState<FileGroup[]>(initialGroups);
|
|
73
|
+
const [selectedFileId, setSelectedFileId] = useState<string | undefined>(
|
|
74
|
+
initialSelectedId
|
|
75
|
+
);
|
|
76
|
+
const [loading] = useState(false);
|
|
77
|
+
|
|
78
|
+
const handleFileSelect = useCallback((fileId: string) => {
|
|
79
|
+
setSelectedFileId(fileId);
|
|
80
|
+
// In a real implementation, this would also:
|
|
81
|
+
// - Load file content from API
|
|
82
|
+
// - Update URL/routing
|
|
83
|
+
// - Track analytics
|
|
84
|
+
// - Trigger side effects
|
|
85
|
+
}, []);
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
groups,
|
|
89
|
+
selectedFileId,
|
|
90
|
+
loading,
|
|
91
|
+
handleFileSelect,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Features
|
|
3
|
+
*
|
|
4
|
+
* Central export point for all feature components.
|
|
5
|
+
* Features are complete, self-contained pieces of functionality.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// RefinementPanel Feature
|
|
9
|
+
export { RefinementPanel } from "./RefinementPanel";
|
|
10
|
+
export type { RefinementPanelProps, RefinementMessage } from "./RefinementPanel";
|
|
11
|
+
|
|
12
|
+
// SpecNavigator Feature
|
|
13
|
+
export { SpecNavigator } from "./SpecNavigator";
|
|
14
|
+
export type { SpecNavigatorProps } from "./SpecNavigator";
|
|
15
|
+
|
|
16
|
+
// AIDocEditor Feature
|
|
17
|
+
export { AIDocEditor } from "./AIDocEditor";
|
|
18
|
+
export type { AIDocEditorProps } from "./AIDocEditor";
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
|
+
import {
|
|
3
|
+
Accordion,
|
|
4
|
+
AccordionContent,
|
|
5
|
+
AccordionItem,
|
|
6
|
+
AccordionTrigger,
|
|
7
|
+
} from "./Accordion"
|
|
8
|
+
|
|
9
|
+
const meta = {
|
|
10
|
+
title: "Primitives/Accordion",
|
|
11
|
+
component: Accordion,
|
|
12
|
+
parameters: {
|
|
13
|
+
layout: "padded",
|
|
14
|
+
},
|
|
15
|
+
tags: ["autodocs"],
|
|
16
|
+
} satisfies Meta<typeof Accordion>
|
|
17
|
+
|
|
18
|
+
export default meta
|
|
19
|
+
type Story = StoryObj<typeof meta>
|
|
20
|
+
|
|
21
|
+
export const Default: Story = {
|
|
22
|
+
render: () => (
|
|
23
|
+
<Accordion type="single" collapsible className="w-full max-w-md">
|
|
24
|
+
<AccordionItem value="item-1">
|
|
25
|
+
<AccordionTrigger>Is it accessible?</AccordionTrigger>
|
|
26
|
+
<AccordionContent>
|
|
27
|
+
Yes. It adheres to the WAI-ARIA design pattern.
|
|
28
|
+
</AccordionContent>
|
|
29
|
+
</AccordionItem>
|
|
30
|
+
<AccordionItem value="item-2">
|
|
31
|
+
<AccordionTrigger>Is it styled?</AccordionTrigger>
|
|
32
|
+
<AccordionContent>
|
|
33
|
+
Yes. It comes with default styles that matches the other components.
|
|
34
|
+
</AccordionContent>
|
|
35
|
+
</AccordionItem>
|
|
36
|
+
<AccordionItem value="item-3">
|
|
37
|
+
<AccordionTrigger>Is it animated?</AccordionTrigger>
|
|
38
|
+
<AccordionContent>
|
|
39
|
+
Yes. It's animated by default, but you can disable it if you prefer.
|
|
40
|
+
</AccordionContent>
|
|
41
|
+
</AccordionItem>
|
|
42
|
+
</Accordion>
|
|
43
|
+
),
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const Multiple: Story = {
|
|
47
|
+
render: () => (
|
|
48
|
+
<Accordion type="multiple" className="w-full max-w-md">
|
|
49
|
+
<AccordionItem value="item-1">
|
|
50
|
+
<AccordionTrigger>Section 1</AccordionTrigger>
|
|
51
|
+
<AccordionContent>Content for section 1.</AccordionContent>
|
|
52
|
+
</AccordionItem>
|
|
53
|
+
<AccordionItem value="item-2">
|
|
54
|
+
<AccordionTrigger>Section 2</AccordionTrigger>
|
|
55
|
+
<AccordionContent>Content for section 2.</AccordionContent>
|
|
56
|
+
</AccordionItem>
|
|
57
|
+
<AccordionItem value="item-3">
|
|
58
|
+
<AccordionTrigger>Section 3</AccordionTrigger>
|
|
59
|
+
<AccordionContent>Content for section 3.</AccordionContent>
|
|
60
|
+
</AccordionItem>
|
|
61
|
+
</Accordion>
|
|
62
|
+
),
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export const DarkMode: Story = {
|
|
66
|
+
parameters: {
|
|
67
|
+
backgrounds: { default: "dark" },
|
|
68
|
+
},
|
|
69
|
+
render: () => (
|
|
70
|
+
<div className="dark">
|
|
71
|
+
<Accordion type="single" collapsible className="w-full max-w-md">
|
|
72
|
+
<AccordionItem value="item-1">
|
|
73
|
+
<AccordionTrigger>Is it accessible?</AccordionTrigger>
|
|
74
|
+
<AccordionContent>
|
|
75
|
+
Yes. It adheres to the WAI-ARIA design pattern.
|
|
76
|
+
</AccordionContent>
|
|
77
|
+
</AccordionItem>
|
|
78
|
+
<AccordionItem value="item-2">
|
|
79
|
+
<AccordionTrigger>Is it styled?</AccordionTrigger>
|
|
80
|
+
<AccordionContent>
|
|
81
|
+
Yes. It comes with default styles.
|
|
82
|
+
</AccordionContent>
|
|
83
|
+
</AccordionItem>
|
|
84
|
+
</Accordion>
|
|
85
|
+
</div>
|
|
86
|
+
),
|
|
87
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import {
|
|
3
|
+
Accordion as ShadcnAccordion,
|
|
4
|
+
AccordionContent,
|
|
5
|
+
AccordionItem,
|
|
6
|
+
AccordionTrigger,
|
|
7
|
+
} from "../../ui/accordion"
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Accordion Primitive
|
|
11
|
+
*
|
|
12
|
+
* A foundational accordion component for collapsible content sections.
|
|
13
|
+
* Built on Radix UI Accordion primitive with WCAG 2.1 Level AA compliance.
|
|
14
|
+
*
|
|
15
|
+
* ## Accessibility Features
|
|
16
|
+
* - Keyboard navigation (Tab, Space, Enter, Arrow keys)
|
|
17
|
+
* - Proper ARIA attributes (aria-expanded, aria-controls)
|
|
18
|
+
* - Focus management
|
|
19
|
+
* - Screen reader support
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* <Accordion type="single" collapsible>
|
|
24
|
+
* <AccordionItem value="item-1">
|
|
25
|
+
* <AccordionTrigger>Section 1</AccordionTrigger>
|
|
26
|
+
* <AccordionContent>Content 1</AccordionContent>
|
|
27
|
+
* </AccordionItem>
|
|
28
|
+
* </Accordion>
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @see https://ui.shadcn.com/docs/components/accordion
|
|
32
|
+
* @see https://www.radix-ui.com/primitives/docs/components/accordion
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
export type AccordionProps = React.ComponentProps<typeof ShadcnAccordion>
|
|
36
|
+
export type AccordionItemProps = React.ComponentProps<typeof AccordionItem>
|
|
37
|
+
export type AccordionTriggerProps = React.ComponentProps<typeof AccordionTrigger>
|
|
38
|
+
export type AccordionContentProps = React.ComponentProps<typeof AccordionContent>
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Accordion component
|
|
42
|
+
*
|
|
43
|
+
* A collapsible content container built on Radix UI Accordion primitive.
|
|
44
|
+
* Supports both single and multiple item expansion.
|
|
45
|
+
*
|
|
46
|
+
* Features:
|
|
47
|
+
* - Keyboard navigation (Tab, Space, Enter, Arrow keys)
|
|
48
|
+
* - Proper ARIA attributes
|
|
49
|
+
* - Focus management
|
|
50
|
+
* - Screen reader support
|
|
51
|
+
* - Smooth animations
|
|
52
|
+
* - Dark mode support
|
|
53
|
+
*/
|
|
54
|
+
export const Accordion = React.forwardRef<
|
|
55
|
+
React.ElementRef<typeof ShadcnAccordion>,
|
|
56
|
+
AccordionProps
|
|
57
|
+
>((props, ref) => {
|
|
58
|
+
return <ShadcnAccordion {...props} />
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
Accordion.displayName = "Accordion"
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Re-export Accordion sub-components for composition
|
|
65
|
+
*/
|
|
66
|
+
export { AccordionContent, AccordionItem, AccordionTrigger }
|