@gram-ai/elements 1.25.1 → 1.26.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.
Files changed (177) hide show
  1. package/dist/components/Chat/stories/Charts.stories.d.ts +37 -0
  2. package/dist/components/Chat/stories/GenerativeUI.stories.d.ts +17 -0
  3. package/dist/components/Chat/stories/MessageFeedback.stories.d.ts +1 -1
  4. package/dist/components/ui/button.d.ts +1 -1
  5. package/dist/components/ui/buttonVariants.d.ts +1 -1
  6. package/dist/components/ui/charts.stories.d.ts +43 -0
  7. package/dist/components/ui/generative-ui.stories.d.ts +53 -0
  8. package/dist/contexts/ChatIdContext.d.ts +11 -0
  9. package/dist/contexts/contexts.d.ts +1 -0
  10. package/dist/elements.cjs +1 -1
  11. package/dist/elements.css +1 -1
  12. package/dist/elements.js +7 -6
  13. package/dist/index-BJnv49-A.js +37057 -0
  14. package/dist/index-BJnv49-A.js.map +1 -0
  15. package/dist/index-BpJstUh1.cjs +280 -0
  16. package/dist/index-BpJstUh1.cjs.map +1 -0
  17. package/dist/index-CUitXazZ.js +30426 -0
  18. package/dist/index-CUitXazZ.js.map +1 -0
  19. package/dist/index-ChW-CSuu.cjs +147 -0
  20. package/dist/index-ChW-CSuu.cjs.map +1 -0
  21. package/dist/index.d.ts +1 -0
  22. package/dist/plugins/chart/catalog.d.ts +123 -0
  23. package/dist/plugins/chart/index.d.ts +1 -1
  24. package/dist/plugins/chart/ui/area-chart.d.ts +16 -0
  25. package/dist/plugins/chart/ui/bar-chart.d.ts +16 -0
  26. package/dist/plugins/chart/ui/donut-chart.d.ts +17 -0
  27. package/dist/plugins/chart/ui/index.d.ts +7 -0
  28. package/dist/plugins/chart/ui/line-chart.d.ts +17 -0
  29. package/dist/plugins/chart/ui/pie-chart.d.ts +15 -0
  30. package/dist/plugins/chart/ui/radar-chart.d.ts +14 -0
  31. package/dist/plugins/chart/ui/scatter-chart.d.ts +18 -0
  32. package/dist/plugins/components/MacOSWindowFrame.d.ts +13 -0
  33. package/dist/plugins/components/PluginLoadingState.d.ts +1 -1
  34. package/dist/plugins/generative-ui/catalog.d.ts +293 -0
  35. package/dist/plugins/generative-ui/ui/accordion-wrapper.d.ts +18 -0
  36. package/dist/plugins/generative-ui/ui/accordion.d.ts +7 -0
  37. package/dist/plugins/generative-ui/ui/action-button.d.ts +10 -0
  38. package/dist/plugins/generative-ui/ui/alert-wrapper.d.ts +9 -0
  39. package/dist/plugins/generative-ui/ui/alert.d.ts +9 -0
  40. package/dist/plugins/generative-ui/ui/avatar-wrapper.d.ts +9 -0
  41. package/dist/plugins/generative-ui/ui/avatar.d.ts +11 -0
  42. package/dist/plugins/generative-ui/ui/badge.d.ts +12 -0
  43. package/dist/plugins/generative-ui/ui/button-wrapper.d.ts +15 -0
  44. package/dist/plugins/generative-ui/ui/button.d.ts +10 -0
  45. package/dist/plugins/generative-ui/ui/card-wrapper.d.ts +10 -0
  46. package/dist/plugins/generative-ui/ui/card.d.ts +9 -0
  47. package/dist/plugins/generative-ui/ui/checkbox-wrapper.d.ts +10 -0
  48. package/dist/plugins/generative-ui/ui/checkbox.d.ts +4 -0
  49. package/dist/plugins/generative-ui/ui/data-table.d.ts +10 -0
  50. package/dist/plugins/generative-ui/ui/dialog.d.ts +17 -0
  51. package/dist/plugins/generative-ui/ui/dropdown-menu.d.ts +25 -0
  52. package/dist/plugins/generative-ui/ui/grid.d.ts +6 -0
  53. package/dist/plugins/generative-ui/ui/index.d.ts +40 -0
  54. package/dist/plugins/generative-ui/ui/input-wrapper.d.ts +11 -0
  55. package/dist/plugins/generative-ui/ui/input.d.ts +3 -0
  56. package/dist/plugins/generative-ui/ui/label.d.ts +4 -0
  57. package/dist/plugins/generative-ui/ui/list.d.ts +6 -0
  58. package/dist/plugins/generative-ui/ui/metric.d.ts +7 -0
  59. package/dist/plugins/generative-ui/ui/pagination.d.ts +13 -0
  60. package/dist/plugins/generative-ui/ui/popover.d.ts +10 -0
  61. package/dist/plugins/generative-ui/ui/progress.d.ts +10 -0
  62. package/dist/plugins/generative-ui/ui/radio-group.d.ts +5 -0
  63. package/dist/plugins/generative-ui/ui/select-wrapper.d.ts +13 -0
  64. package/dist/plugins/generative-ui/ui/select.d.ts +15 -0
  65. package/dist/plugins/generative-ui/ui/separator.d.ts +4 -0
  66. package/dist/plugins/generative-ui/ui/skeleton-wrapper.d.ts +9 -0
  67. package/dist/plugins/generative-ui/ui/skeleton.d.ts +2 -0
  68. package/dist/plugins/generative-ui/ui/stack.d.ts +8 -0
  69. package/dist/plugins/generative-ui/ui/switch.d.ts +6 -0
  70. package/dist/plugins/generative-ui/ui/table.d.ts +10 -0
  71. package/dist/plugins/generative-ui/ui/tabs-wrapper.d.ts +21 -0
  72. package/dist/plugins/generative-ui/ui/tabs.d.ts +11 -0
  73. package/dist/plugins/generative-ui/ui/text.d.ts +7 -0
  74. package/dist/plugins/generative-ui/ui/textarea.d.ts +3 -0
  75. package/dist/plugins/generative-ui/ui/tooltip.d.ts +7 -0
  76. package/dist/plugins.cjs +1 -1
  77. package/dist/plugins.js +1 -1
  78. package/dist/{profiler-CijCgLrw.js → profiler-D4Tw5ecI.js} +2 -2
  79. package/dist/{profiler-CijCgLrw.js.map → profiler-D4Tw5ecI.js.map} +1 -1
  80. package/dist/{profiler-DAT0DL1W.cjs → profiler-DCWYDZ1F.cjs} +2 -2
  81. package/dist/{profiler-DAT0DL1W.cjs.map → profiler-DCWYDZ1F.cjs.map} +1 -1
  82. package/dist/{startRecording-DotsE8QT.cjs → startRecording-3sTskM3H.cjs} +2 -2
  83. package/dist/{startRecording-DotsE8QT.cjs.map → startRecording-3sTskM3H.cjs.map} +1 -1
  84. package/dist/{startRecording-gmhENmf0.js → startRecording-BHhcCWQE.js} +2 -2
  85. package/dist/{startRecording-gmhENmf0.js.map → startRecording-BHhcCWQE.js.map} +1 -1
  86. package/dist/types/index.d.ts +4 -4
  87. package/package.json +4 -1
  88. package/src/components/Chat/stories/Charts.stories.tsx +260 -0
  89. package/src/components/Chat/stories/ConnectionConfiguration.stories.tsx +6 -6
  90. package/src/components/Chat/stories/GenerativeUI.stories.tsx +113 -0
  91. package/src/components/Chat/stories/MessageFeedback.stories.tsx +6 -6
  92. package/src/components/Chat/stories/ToolApproval.stories.tsx +10 -10
  93. package/src/components/Chat/stories/Tools.stories.tsx +122 -104
  94. package/src/components/Chat/stories/Variants.stories.tsx +1 -1
  95. package/src/components/Replay.stories.tsx +1 -1
  96. package/src/components/Replay.tsx +18 -13
  97. package/src/components/ShadowRoot.tsx +5 -1
  98. package/src/components/assistant-ui/message-feedback.tsx +6 -7
  99. package/src/components/assistant-ui/thread.tsx +76 -11
  100. package/src/components/ui/charts.stories.tsx +246 -0
  101. package/src/components/ui/generative-ui.stories.tsx +557 -0
  102. package/src/components/ui/generative-ui.tsx +60 -360
  103. package/src/components/ui/tool-ui.stories.tsx +6 -3
  104. package/src/contexts/ChatIdContext.tsx +21 -0
  105. package/src/contexts/ElementsProvider.tsx +77 -37
  106. package/src/contexts/contexts.ts +2 -0
  107. package/src/hooks/useAuth.ts +18 -3
  108. package/src/hooks/useFollowOnSuggestions.ts +6 -1
  109. package/src/index.ts +1 -0
  110. package/src/plugins/chart/catalog.ts +141 -0
  111. package/src/plugins/chart/component.tsx +79 -125
  112. package/src/plugins/chart/index.ts +141 -89
  113. package/src/plugins/chart/ui/area-chart.tsx +133 -0
  114. package/src/plugins/chart/ui/bar-chart.tsx +137 -0
  115. package/src/plugins/chart/ui/donut-chart.tsx +167 -0
  116. package/src/plugins/chart/ui/index.ts +7 -0
  117. package/src/plugins/chart/ui/line-chart.tsx +135 -0
  118. package/src/plugins/chart/ui/pie-chart.tsx +148 -0
  119. package/src/plugins/chart/ui/radar-chart.tsx +105 -0
  120. package/src/plugins/chart/ui/scatter-chart.tsx +132 -0
  121. package/src/plugins/components/MacOSWindowFrame.tsx +55 -0
  122. package/src/plugins/components/PluginLoadingState.tsx +9 -13
  123. package/src/plugins/generative-ui/catalog.ts +277 -0
  124. package/src/plugins/generative-ui/component.tsx +112 -21
  125. package/src/plugins/generative-ui/index.ts +20 -141
  126. package/src/plugins/generative-ui/ui/accordion-wrapper.tsx +57 -0
  127. package/src/plugins/generative-ui/ui/accordion.tsx +66 -0
  128. package/src/plugins/generative-ui/ui/action-button.tsx +68 -0
  129. package/src/plugins/generative-ui/ui/alert-wrapper.tsx +26 -0
  130. package/src/plugins/generative-ui/ui/alert.tsx +66 -0
  131. package/src/plugins/generative-ui/ui/avatar-wrapper.tsx +22 -0
  132. package/src/plugins/generative-ui/ui/avatar.tsx +109 -0
  133. package/src/plugins/generative-ui/ui/badge.tsx +65 -0
  134. package/src/plugins/generative-ui/ui/button-wrapper.tsx +32 -0
  135. package/src/plugins/generative-ui/ui/button.tsx +65 -0
  136. package/src/plugins/generative-ui/ui/card-wrapper.tsx +36 -0
  137. package/src/plugins/generative-ui/ui/card.tsx +92 -0
  138. package/src/plugins/generative-ui/ui/checkbox-wrapper.tsx +39 -0
  139. package/src/plugins/generative-ui/ui/checkbox.tsx +32 -0
  140. package/src/plugins/generative-ui/ui/data-table.tsx +53 -0
  141. package/src/plugins/generative-ui/ui/dialog.tsx +158 -0
  142. package/src/plugins/generative-ui/ui/dropdown-menu.tsx +257 -0
  143. package/src/plugins/generative-ui/ui/grid.tsx +29 -0
  144. package/src/plugins/generative-ui/ui/index.ts +43 -0
  145. package/src/plugins/generative-ui/ui/input-wrapper.tsx +38 -0
  146. package/src/plugins/generative-ui/ui/input.tsx +21 -0
  147. package/src/plugins/generative-ui/ui/label.tsx +24 -0
  148. package/src/plugins/generative-ui/ui/list.tsx +34 -0
  149. package/src/plugins/generative-ui/ui/metric.tsx +53 -0
  150. package/src/plugins/generative-ui/ui/pagination.tsx +127 -0
  151. package/src/plugins/generative-ui/ui/popover.tsx +89 -0
  152. package/src/plugins/generative-ui/ui/progress.tsx +57 -0
  153. package/src/plugins/generative-ui/ui/radio-group.tsx +45 -0
  154. package/src/plugins/generative-ui/ui/select-wrapper.tsx +41 -0
  155. package/src/plugins/generative-ui/ui/select.tsx +190 -0
  156. package/src/plugins/generative-ui/ui/separator.tsx +28 -0
  157. package/src/plugins/generative-ui/ui/skeleton-wrapper.tsx +30 -0
  158. package/src/plugins/generative-ui/ui/skeleton.tsx +13 -0
  159. package/src/plugins/generative-ui/ui/stack.tsx +54 -0
  160. package/src/plugins/generative-ui/ui/switch.tsx +35 -0
  161. package/src/plugins/generative-ui/ui/table.tsx +116 -0
  162. package/src/plugins/generative-ui/ui/tabs-wrapper.tsx +51 -0
  163. package/src/plugins/generative-ui/ui/tabs.tsx +92 -0
  164. package/src/plugins/generative-ui/ui/text.tsx +33 -0
  165. package/src/plugins/generative-ui/ui/textarea.tsx +18 -0
  166. package/src/plugins/generative-ui/ui/tooltip.tsx +57 -0
  167. package/src/types/index.ts +4 -4
  168. package/dist/components/Chat/stories/Plugins.stories.d.ts +0 -12
  169. package/dist/index-C3UbmFRR.cjs +0 -178
  170. package/dist/index-C3UbmFRR.cjs.map +0 -1
  171. package/dist/index-CtyV0c-T.js +0 -27225
  172. package/dist/index-CtyV0c-T.js.map +0 -1
  173. package/dist/index-DxJwZ5Kc.js +0 -39975
  174. package/dist/index-DxJwZ5Kc.js.map +0 -1
  175. package/dist/index-iUSSoKFz.cjs +0 -251
  176. package/dist/index-iUSSoKFz.cjs.map +0 -1
  177. package/src/components/Chat/stories/Plugins.stories.tsx +0 -158
@@ -23,10 +23,16 @@ import {
23
23
  useAssistantState,
24
24
  } from '@assistant-ui/react'
25
25
 
26
- import { LazyMotion, MotionConfig, domAnimation } from 'motion/react'
26
+ import {
27
+ AnimatePresence,
28
+ LazyMotion,
29
+ MotionConfig,
30
+ domAnimation,
31
+ } from 'motion/react'
27
32
  import * as m from 'motion/react-m'
28
33
  import {
29
34
  createContext,
35
+ useCallback,
30
36
  useContext,
31
37
  useEffect,
32
38
  useMemo,
@@ -34,7 +40,6 @@ import {
34
40
  useState,
35
41
  type FC,
36
42
  } from 'react'
37
- import { AnimatePresence } from 'motion/react'
38
43
 
39
44
  import {
40
45
  ComposerAddAttachment,
@@ -43,25 +48,27 @@ import {
43
48
  } from '@/components/assistant-ui/attachment'
44
49
  import { FollowOnSuggestions } from '@/components/assistant-ui/follow-on-suggestions'
45
50
  import { MarkdownText } from '@/components/assistant-ui/markdown-text'
51
+ import { MentionedToolsBadges } from '@/components/assistant-ui/mentioned-tools-badges'
46
52
  import { MessageFeedback } from '@/components/assistant-ui/message-feedback'
47
53
  import { Reasoning, ReasoningGroup } from '@/components/assistant-ui/reasoning'
48
54
  import { ToolFallback } from '@/components/assistant-ui/tool-fallback'
49
55
  import { ToolMentionAutocomplete } from '@/components/assistant-ui/tool-mention-autocomplete'
50
- import { MentionedToolsBadges } from '@/components/assistant-ui/mentioned-tools-badges'
51
56
  import { TooltipIconButton } from '@/components/assistant-ui/tooltip-icon-button'
52
57
  import { Button } from '@/components/ui/button'
53
- import { useToolMentions } from '@/hooks/useToolMentions'
54
-
58
+ import { useChatId } from '@/contexts/ChatIdContext'
59
+ import { useReplayContext } from '@/contexts/ReplayContext'
60
+ import { useAuth } from '@/hooks/useAuth'
55
61
  import { useDensity } from '@/hooks/useDensity'
56
62
  import { useElements } from '@/hooks/useElements'
63
+ import { isLocalThreadId } from '@/hooks/useGramThreadListAdapter'
57
64
  import { useRadius } from '@/hooks/useRadius'
65
+ import { useRecordCassette } from '@/hooks/useRecordCassette'
58
66
  import { useThemeProps } from '@/hooks/useThemeProps'
67
+ import { useToolMentions } from '@/hooks/useToolMentions'
68
+ import { getApiUrl } from '@/lib/api'
59
69
  import { EASE_OUT_QUINT } from '@/lib/easing'
60
70
  import { MODELS } from '@/lib/models'
61
71
  import { cn } from '@/lib/utils'
62
- import { useRecordCassette } from '@/hooks/useRecordCassette'
63
- import { useReplayContext } from '@/contexts/ReplayContext'
64
- import { ConnectionStatusIndicatorSafe } from './connection-status-indicator'
65
72
  import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover'
66
73
  import {
67
74
  Tooltip,
@@ -69,8 +76,11 @@ import {
69
76
  TooltipProvider,
70
77
  TooltipTrigger,
71
78
  } from '../ui/tooltip'
79
+ import { ConnectionStatusIndicatorSafe } from './connection-status-indicator'
72
80
  import { ToolGroup } from './tool-group'
73
81
 
82
+ type Feedback = 'success' | 'failure'
83
+
74
84
  // Context for chat resolution state
75
85
  const ChatResolutionContext = createContext<{
76
86
  isResolved: boolean
@@ -78,12 +88,14 @@ const ChatResolutionContext = createContext<{
78
88
  setResolved: () => void
79
89
  setUnresolved: () => void
80
90
  resetFeedbackHidden: () => void
91
+ submitFeedback: (feedback: Feedback) => Promise<void>
81
92
  }>({
82
93
  isResolved: false,
83
94
  feedbackHidden: false,
84
95
  setResolved: () => {},
85
96
  setUnresolved: () => {},
86
97
  resetFeedbackHidden: () => {},
98
+ submitFeedback: async () => {},
87
99
  })
88
100
 
89
101
  const useChatResolution = () => useContext(ChatResolutionContext)
@@ -113,9 +125,16 @@ export const Thread: FC<ThreadProps> = ({ className }) => {
113
125
  const { config } = useElements()
114
126
  const components = config.components ?? {}
115
127
  const showStaticSessionWarning = config.api && 'sessionToken' in config.api
116
- const showFeedback = config.thread?.experimental_showFeedback ?? false
128
+ const showFeedback = config.thread?.showFeedback ?? false
117
129
  const [isResolved, setIsResolved] = useState(false)
118
130
  const [feedbackHidden, setFeedbackHidden] = useState(false)
131
+ const chatId = useChatId()
132
+
133
+ const apiUrl = getApiUrl(config)
134
+ const auth = useAuth({
135
+ auth: config.api,
136
+ projectSlug: config.projectSlug,
137
+ })
119
138
 
120
139
  const setResolved = () => setIsResolved(true)
121
140
  const setUnresolved = () => {
@@ -124,6 +143,38 @@ export const Thread: FC<ThreadProps> = ({ className }) => {
124
143
  }
125
144
  const resetFeedbackHidden = () => setFeedbackHidden(false)
126
145
 
146
+ // Submit feedback to the API
147
+ const submitFeedback = useCallback(
148
+ async (feedback: Feedback) => {
149
+ if (!chatId) return
150
+ if (isLocalThreadId(chatId)) {
151
+ console.error("Local thread ID, can't submit feedback")
152
+ return
153
+ }
154
+
155
+ try {
156
+ const response = await fetch(`${apiUrl}/rpc/chat.submitFeedback`, {
157
+ method: 'POST',
158
+ headers: {
159
+ 'Content-Type': 'application/json',
160
+ ...auth.headers,
161
+ },
162
+ body: JSON.stringify({
163
+ id: chatId,
164
+ feedback,
165
+ }),
166
+ })
167
+
168
+ if (!response.ok) {
169
+ console.error('Failed to submit feedback:', response.statusText)
170
+ }
171
+ } catch (error) {
172
+ console.error('Failed to submit feedback:', error)
173
+ }
174
+ },
175
+ [chatId, apiUrl, auth.headers]
176
+ )
177
+
127
178
  return (
128
179
  <ChatResolutionContext.Provider
129
180
  value={{
@@ -132,6 +183,7 @@ export const Thread: FC<ThreadProps> = ({ className }) => {
132
183
  setResolved,
133
184
  setUnresolved,
134
185
  resetFeedbackHidden,
186
+ submitFeedback,
135
187
  }}
136
188
  >
137
189
  <LazyMotion features={domAnimation}>
@@ -448,7 +500,16 @@ const FeedbackHiddenResetter: FC = () => {
448
500
  }
449
501
 
450
502
  const ComposerFeedback: FC = () => {
451
- const { isResolved, feedbackHidden, setResolved } = useChatResolution()
503
+ const { isResolved, feedbackHidden, setResolved, submitFeedback } =
504
+ useChatResolution()
505
+
506
+ const handleFeedback = useCallback(
507
+ async (type: 'like' | 'dislike') => {
508
+ const feedback = type === 'like' ? 'success' : 'failure'
509
+ await submitFeedback(feedback)
510
+ },
511
+ [submitFeedback]
512
+ )
452
513
 
453
514
  return (
454
515
  <ThreadPrimitive.If empty={false}>
@@ -466,7 +527,11 @@ const ComposerFeedback: FC = () => {
466
527
  transition={{ duration: 0.2, ease: EASE_OUT_QUINT }}
467
528
  className="mb-3"
468
529
  >
469
- <MessageFeedback className="mx-auto" onResolved={setResolved} />
530
+ <MessageFeedback
531
+ className="mx-auto"
532
+ onResolved={setResolved}
533
+ onFeedback={handleFeedback}
534
+ />
470
535
  </m.div>
471
536
  )}
472
537
  </AnimatePresence>
@@ -0,0 +1,246 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite'
2
+ import {
3
+ AreaChart,
4
+ BarChart,
5
+ LineChart,
6
+ PieChart,
7
+ DonutChart,
8
+ RadarChart,
9
+ ScatterChart,
10
+ } from '@/plugins/chart/ui'
11
+
12
+ // Wrapper component to render different chart types
13
+ const ChartWrapper = ({ children }: { children: React.ReactNode }) => (
14
+ <div className="w-full">{children}</div>
15
+ )
16
+
17
+ const meta: Meta = {
18
+ title: 'Components/Charts',
19
+ parameters: {
20
+ layout: 'fullscreen',
21
+ },
22
+ decorators: [
23
+ (Story) => (
24
+ <div className="bg-background text-foreground min-h-screen p-6">
25
+ <div className="max-w-2xl">
26
+ <Story />
27
+ </div>
28
+ </div>
29
+ ),
30
+ ],
31
+ }
32
+
33
+ export default meta
34
+
35
+ // Sample data for time series charts
36
+ const timeSeriesData = [
37
+ { label: 'Jan', value: 4000, revenue: 2400, profit: 1200 },
38
+ { label: 'Feb', value: 3000, revenue: 1398, profit: 900 },
39
+ { label: 'Mar', value: 2000, revenue: 9800, profit: 2100 },
40
+ { label: 'Apr', value: 2780, revenue: 3908, profit: 1500 },
41
+ { label: 'May', value: 1890, revenue: 4800, profit: 1800 },
42
+ { label: 'Jun', value: 2390, revenue: 3800, profit: 1400 },
43
+ { label: 'Jul', value: 3490, revenue: 4300, profit: 2000 },
44
+ ]
45
+
46
+ // Sample data for category charts
47
+ const categoryData = [
48
+ { label: 'Electronics', value: 4500 },
49
+ { label: 'Clothing', value: 3200 },
50
+ { label: 'Home & Garden', value: 2800 },
51
+ { label: 'Sports', value: 2100 },
52
+ { label: 'Books', value: 1500 },
53
+ ]
54
+
55
+ // Sample data for pie/donut charts
56
+ const pieData = [
57
+ { label: 'Desktop', value: 45 },
58
+ { label: 'Mobile', value: 35 },
59
+ { label: 'Tablet', value: 15 },
60
+ { label: 'Other', value: 5 },
61
+ ]
62
+
63
+ // Sample data for radar chart
64
+ const radarData = [
65
+ { label: 'Speed', value: 85 },
66
+ { label: 'Reliability', value: 90 },
67
+ { label: 'Comfort', value: 78 },
68
+ { label: 'Safety', value: 95 },
69
+ { label: 'Efficiency', value: 82 },
70
+ ]
71
+
72
+ // Sample data for scatter chart
73
+ const scatterData = [
74
+ { x: 10, y: 30, label: 'A' },
75
+ { x: 40, y: 50, label: 'B' },
76
+ { x: 20, y: 80, label: 'C' },
77
+ { x: 60, y: 40, label: 'D' },
78
+ { x: 80, y: 90, label: 'E' },
79
+ { x: 30, y: 60, label: 'F' },
80
+ { x: 50, y: 20, label: 'G' },
81
+ { x: 70, y: 70, label: 'H' },
82
+ ]
83
+
84
+ /**
85
+ * Area chart showing trends over time with filled areas.
86
+ */
87
+ export const Area: StoryObj = {
88
+ render: () => (
89
+ <ChartWrapper>
90
+ <AreaChart
91
+ title="Revenue Over Time"
92
+ data={timeSeriesData}
93
+ series={['value', 'revenue']}
94
+ showGrid
95
+ showLegend
96
+ />
97
+ </ChartWrapper>
98
+ ),
99
+ }
100
+
101
+ /**
102
+ * Stacked area chart comparing multiple data series.
103
+ */
104
+ export const AreaStacked: StoryObj = {
105
+ render: () => (
106
+ <ChartWrapper>
107
+ <AreaChart
108
+ title="Stacked Revenue Breakdown"
109
+ data={timeSeriesData}
110
+ series={['revenue', 'profit']}
111
+ stacked
112
+ showGrid
113
+ showLegend
114
+ />
115
+ </ChartWrapper>
116
+ ),
117
+ }
118
+
119
+ /**
120
+ * Vertical bar chart for comparing categories.
121
+ */
122
+ export const Bar: StoryObj = {
123
+ render: () => (
124
+ <ChartWrapper>
125
+ <BarChart
126
+ title="Sales by Category"
127
+ data={categoryData}
128
+ showGrid
129
+ showLegend
130
+ />
131
+ </ChartWrapper>
132
+ ),
133
+ }
134
+
135
+ /**
136
+ * Horizontal bar chart layout.
137
+ */
138
+ export const BarHorizontal: StoryObj = {
139
+ render: () => (
140
+ <ChartWrapper>
141
+ <BarChart
142
+ title="Sales by Category"
143
+ data={categoryData}
144
+ layout="horizontal"
145
+ showGrid
146
+ />
147
+ </ChartWrapper>
148
+ ),
149
+ }
150
+
151
+ /**
152
+ * Line chart for tracking trends over time.
153
+ */
154
+ export const Line: StoryObj = {
155
+ render: () => (
156
+ <ChartWrapper>
157
+ <LineChart
158
+ title="Monthly Performance"
159
+ data={timeSeriesData}
160
+ series={['value', 'revenue']}
161
+ showGrid
162
+ showLegend
163
+ showDots
164
+ />
165
+ </ChartWrapper>
166
+ ),
167
+ }
168
+
169
+ /**
170
+ * Curved line chart with smooth interpolation.
171
+ */
172
+ export const LineCurved: StoryObj = {
173
+ render: () => (
174
+ <ChartWrapper>
175
+ <LineChart
176
+ title="Smooth Trend Line"
177
+ data={timeSeriesData}
178
+ series={['value']}
179
+ showGrid
180
+ curved
181
+ showDots
182
+ />
183
+ </ChartWrapper>
184
+ ),
185
+ }
186
+
187
+ /**
188
+ * Pie chart showing proportional data.
189
+ */
190
+ export const Pie: StoryObj = {
191
+ render: () => (
192
+ <ChartWrapper>
193
+ <PieChart
194
+ title="Traffic by Device"
195
+ data={pieData}
196
+ showLegend
197
+ showLabels
198
+ />
199
+ </ChartWrapper>
200
+ ),
201
+ }
202
+
203
+ /**
204
+ * Donut chart with center label.
205
+ */
206
+ export const Donut: StoryObj = {
207
+ render: () => (
208
+ <ChartWrapper>
209
+ <DonutChart
210
+ title="Traffic by Device"
211
+ data={pieData}
212
+ showLegend
213
+ innerLabel="Total"
214
+ innerValue="100%"
215
+ />
216
+ </ChartWrapper>
217
+ ),
218
+ }
219
+
220
+ /**
221
+ * Radar chart for multi-dimensional comparison.
222
+ */
223
+ export const Radar: StoryObj = {
224
+ render: () => (
225
+ <ChartWrapper>
226
+ <RadarChart title="Product Metrics" data={radarData} showLegend />
227
+ </ChartWrapper>
228
+ ),
229
+ }
230
+
231
+ /**
232
+ * Scatter chart for showing correlation between variables.
233
+ */
234
+ export const Scatter: StoryObj = {
235
+ render: () => (
236
+ <ChartWrapper>
237
+ <ScatterChart
238
+ title="Price vs. Performance"
239
+ data={scatterData}
240
+ xLabel="Price"
241
+ yLabel="Performance"
242
+ showGrid
243
+ />
244
+ </ChartWrapper>
245
+ ),
246
+ }