@auto-engineer/generate-react-client 1.12.1

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 (154) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/LICENSE +10 -0
  3. package/dist/src/commands/generate-react-client.d.ts +21 -0
  4. package/dist/src/commands/generate-react-client.d.ts.map +1 -0
  5. package/dist/src/commands/generate-react-client.js +62 -0
  6. package/dist/src/commands/generate-react-client.js.map +1 -0
  7. package/dist/src/copy-starter.d.ts +2 -0
  8. package/dist/src/copy-starter.d.ts.map +1 -0
  9. package/dist/src/copy-starter.js +34 -0
  10. package/dist/src/copy-starter.js.map +1 -0
  11. package/dist/src/index.d.ts +10 -0
  12. package/dist/src/index.d.ts.map +1 -0
  13. package/dist/src/index.js +4 -0
  14. package/dist/src/index.js.map +1 -0
  15. package/dist/starter/.storybook/main.ts +33 -0
  16. package/dist/starter/.storybook/preview.tsx +35 -0
  17. package/dist/starter/components.json +29 -0
  18. package/dist/starter/index.html +12 -0
  19. package/dist/starter/package.json +60 -0
  20. package/dist/starter/pnpm-lock.yaml +5236 -0
  21. package/dist/starter/public/mockServiceWorker.js +336 -0
  22. package/dist/starter/src/App.tsx +15 -0
  23. package/dist/starter/src/components/.gitkeep +0 -0
  24. package/dist/starter/src/components/ui/Accordion.stories.tsx +47 -0
  25. package/dist/starter/src/components/ui/Accordion.tsx +51 -0
  26. package/dist/starter/src/components/ui/Alert.stories.tsx +27 -0
  27. package/dist/starter/src/components/ui/Alert.tsx +49 -0
  28. package/dist/starter/src/components/ui/AlertDialog.stories.tsx +65 -0
  29. package/dist/starter/src/components/ui/AlertDialog.tsx +163 -0
  30. package/dist/starter/src/components/ui/AspectRatio.stories.tsx +33 -0
  31. package/dist/starter/src/components/ui/AspectRatio.tsx +9 -0
  32. package/dist/starter/src/components/ui/Avatar.stories.tsx +42 -0
  33. package/dist/starter/src/components/ui/Avatar.tsx +87 -0
  34. package/dist/starter/src/components/ui/Badge.stories.tsx +36 -0
  35. package/dist/starter/src/components/ui/Badge.tsx +40 -0
  36. package/dist/starter/src/components/ui/Breadcrumb.stories.tsx +52 -0
  37. package/dist/starter/src/components/ui/Breadcrumb.tsx +92 -0
  38. package/dist/starter/src/components/ui/Button.stories.tsx +92 -0
  39. package/dist/starter/src/components/ui/Button.tsx +62 -0
  40. package/dist/starter/src/components/ui/ButtonGroup.stories.tsx +30 -0
  41. package/dist/starter/src/components/ui/ButtonGroup.tsx +75 -0
  42. package/dist/starter/src/components/ui/Calendar.stories.tsx +38 -0
  43. package/dist/starter/src/components/ui/Calendar.tsx +159 -0
  44. package/dist/starter/src/components/ui/Card.stories.tsx +42 -0
  45. package/dist/starter/src/components/ui/Card.tsx +56 -0
  46. package/dist/starter/src/components/ui/Carousel.stories.tsx +54 -0
  47. package/dist/starter/src/components/ui/Carousel.tsx +216 -0
  48. package/dist/starter/src/components/ui/Chart.stories.tsx +38 -0
  49. package/dist/starter/src/components/ui/Chart.tsx +296 -0
  50. package/dist/starter/src/components/ui/Checkbox.stories.tsx +31 -0
  51. package/dist/starter/src/components/ui/Checkbox.tsx +29 -0
  52. package/dist/starter/src/components/ui/Collapsible.stories.tsx +56 -0
  53. package/dist/starter/src/components/ui/Collapsible.tsx +15 -0
  54. package/dist/starter/src/components/ui/Combobox.stories.tsx +73 -0
  55. package/dist/starter/src/components/ui/Combobox.tsx +267 -0
  56. package/dist/starter/src/components/ui/Command.stories.tsx +69 -0
  57. package/dist/starter/src/components/ui/Command.tsx +137 -0
  58. package/dist/starter/src/components/ui/ContextMenu.stories.tsx +66 -0
  59. package/dist/starter/src/components/ui/ContextMenu.tsx +211 -0
  60. package/dist/starter/src/components/ui/DesignSystem-Colors.mdx +68 -0
  61. package/dist/starter/src/components/ui/DesignSystem-Colors.stories.tsx +116 -0
  62. package/dist/starter/src/components/ui/DesignSystem-Layout.mdx +64 -0
  63. package/dist/starter/src/components/ui/DesignSystem-Layout.stories.tsx +166 -0
  64. package/dist/starter/src/components/ui/DesignSystem-Typography.mdx +31 -0
  65. package/dist/starter/src/components/ui/DesignSystem-Typography.stories.tsx +79 -0
  66. package/dist/starter/src/components/ui/Dialog.stories.tsx +72 -0
  67. package/dist/starter/src/components/ui/Dialog.tsx +136 -0
  68. package/dist/starter/src/components/ui/Direction.stories.tsx +36 -0
  69. package/dist/starter/src/components/ui/Direction.tsx +18 -0
  70. package/dist/starter/src/components/ui/Drawer.stories.tsx +68 -0
  71. package/dist/starter/src/components/ui/Drawer.tsx +106 -0
  72. package/dist/starter/src/components/ui/DropdownMenu.stories.tsx +72 -0
  73. package/dist/starter/src/components/ui/DropdownMenu.tsx +219 -0
  74. package/dist/starter/src/components/ui/Empty.stories.tsx +35 -0
  75. package/dist/starter/src/components/ui/Empty.tsx +85 -0
  76. package/dist/starter/src/components/ui/Field.stories.tsx +47 -0
  77. package/dist/starter/src/components/ui/Field.tsx +226 -0
  78. package/dist/starter/src/components/ui/Form.stories.tsx +44 -0
  79. package/dist/starter/src/components/ui/Form.tsx +136 -0
  80. package/dist/starter/src/components/ui/HoverCard.stories.tsx +47 -0
  81. package/dist/starter/src/components/ui/HoverCard.tsx +36 -0
  82. package/dist/starter/src/components/ui/Input.stories.tsx +38 -0
  83. package/dist/starter/src/components/ui/Input.tsx +21 -0
  84. package/dist/starter/src/components/ui/InputGroup.stories.tsx +50 -0
  85. package/dist/starter/src/components/ui/InputGroup.tsx +147 -0
  86. package/dist/starter/src/components/ui/InputOTP.stories.tsx +40 -0
  87. package/dist/starter/src/components/ui/InputOTP.tsx +68 -0
  88. package/dist/starter/src/components/ui/Item.stories.tsx +61 -0
  89. package/dist/starter/src/components/ui/Item.tsx +158 -0
  90. package/dist/starter/src/components/ui/Kbd.stories.tsx +54 -0
  91. package/dist/starter/src/components/ui/Kbd.tsx +18 -0
  92. package/dist/starter/src/components/ui/Label.stories.tsx +85 -0
  93. package/dist/starter/src/components/ui/Label.tsx +40 -0
  94. package/dist/starter/src/components/ui/Menubar.stories.tsx +76 -0
  95. package/dist/starter/src/components/ui/Menubar.tsx +236 -0
  96. package/dist/starter/src/components/ui/NativeSelect.stories.tsx +42 -0
  97. package/dist/starter/src/components/ui/NativeSelect.tsx +44 -0
  98. package/dist/starter/src/components/ui/NavigationMenu.stories.tsx +78 -0
  99. package/dist/starter/src/components/ui/NavigationMenu.tsx +142 -0
  100. package/dist/starter/src/components/ui/Pagination.stories.tsx +75 -0
  101. package/dist/starter/src/components/ui/Pagination.tsx +100 -0
  102. package/dist/starter/src/components/ui/Popover.stories.tsx +51 -0
  103. package/dist/starter/src/components/ui/Popover.tsx +52 -0
  104. package/dist/starter/src/components/ui/Progress.stories.tsx +28 -0
  105. package/dist/starter/src/components/ui/Progress.tsx +24 -0
  106. package/dist/starter/src/components/ui/RadioGroup.stories.tsx +48 -0
  107. package/dist/starter/src/components/ui/RadioGroup.tsx +31 -0
  108. package/dist/starter/src/components/ui/Resizable.stories.tsx +69 -0
  109. package/dist/starter/src/components/ui/Resizable.tsx +47 -0
  110. package/dist/starter/src/components/ui/ScrollArea.stories.tsx +43 -0
  111. package/dist/starter/src/components/ui/ScrollArea.tsx +46 -0
  112. package/dist/starter/src/components/ui/Select.stories.tsx +57 -0
  113. package/dist/starter/src/components/ui/Select.tsx +162 -0
  114. package/dist/starter/src/components/ui/Separator.stories.tsx +40 -0
  115. package/dist/starter/src/components/ui/Separator.tsx +26 -0
  116. package/dist/starter/src/components/ui/Sheet.stories.tsx +66 -0
  117. package/dist/starter/src/components/ui/Sheet.tsx +107 -0
  118. package/dist/starter/src/components/ui/Sidebar.stories.tsx +94 -0
  119. package/dist/starter/src/components/ui/Sidebar.tsx +675 -0
  120. package/dist/starter/src/components/ui/Skeleton.stories.tsx +38 -0
  121. package/dist/starter/src/components/ui/Skeleton.tsx +7 -0
  122. package/dist/starter/src/components/ui/Slider.stories.tsx +21 -0
  123. package/dist/starter/src/components/ui/Slider.tsx +54 -0
  124. package/dist/starter/src/components/ui/Sonner.stories.tsx +44 -0
  125. package/dist/starter/src/components/ui/Sonner.tsx +34 -0
  126. package/dist/starter/src/components/ui/Spinner.stories.tsx +23 -0
  127. package/dist/starter/src/components/ui/Spinner.tsx +9 -0
  128. package/dist/starter/src/components/ui/Switch.stories.tsx +35 -0
  129. package/dist/starter/src/components/ui/Switch.tsx +33 -0
  130. package/dist/starter/src/components/ui/Table.stories.tsx +65 -0
  131. package/dist/starter/src/components/ui/Table.tsx +75 -0
  132. package/dist/starter/src/components/ui/Tabs.stories.tsx +51 -0
  133. package/dist/starter/src/components/ui/Tabs.tsx +69 -0
  134. package/dist/starter/src/components/ui/Textarea.stories.tsx +24 -0
  135. package/dist/starter/src/components/ui/Textarea.tsx +18 -0
  136. package/dist/starter/src/components/ui/Toast.stories.tsx +112 -0
  137. package/dist/starter/src/components/ui/Toast.tsx +114 -0
  138. package/dist/starter/src/components/ui/Toaster.tsx +28 -0
  139. package/dist/starter/src/components/ui/Toggle.stories.tsx +40 -0
  140. package/dist/starter/src/components/ui/Toggle.tsx +41 -0
  141. package/dist/starter/src/components/ui/ToggleGroup.stories.tsx +58 -0
  142. package/dist/starter/src/components/ui/ToggleGroup.tsx +80 -0
  143. package/dist/starter/src/components/ui/Tooltip.stories.tsx +40 -0
  144. package/dist/starter/src/components/ui/Tooltip.tsx +42 -0
  145. package/dist/starter/src/hooks/use-mobile.ts +19 -0
  146. package/dist/starter/src/hooks/use-toast.ts +186 -0
  147. package/dist/starter/src/index.css +123 -0
  148. package/dist/starter/src/lib/utils.ts +6 -0
  149. package/dist/starter/src/main.tsx +5 -0
  150. package/dist/starter/tsconfig.app.json +25 -0
  151. package/dist/starter/tsconfig.json +4 -0
  152. package/dist/starter/vite.config.ts +16 -0
  153. package/dist/tsconfig.tsbuildinfo +1 -0
  154. package/package.json +37 -0
@@ -0,0 +1,336 @@
1
+ /* eslint-disable */
2
+ /* tslint:disable */
3
+
4
+ /**
5
+ * Mock Service Worker.
6
+ * @see https://github.com/mswjs/msw
7
+ * - Please do NOT modify this file.
8
+ */
9
+
10
+ const PACKAGE_VERSION = '2.12.10';
11
+ const INTEGRITY_CHECKSUM = '4db4a41e972cec1b64cc569c66952d82';
12
+ const IS_MOCKED_RESPONSE = Symbol('isMockedResponse');
13
+ const activeClientIds = new Set();
14
+
15
+ addEventListener('install', function () {
16
+ self.skipWaiting();
17
+ });
18
+
19
+ addEventListener('activate', function (event) {
20
+ event.waitUntil(self.clients.claim());
21
+ });
22
+
23
+ addEventListener('message', async function (event) {
24
+ const clientId = Reflect.get(event.source || {}, 'id');
25
+
26
+ if (!clientId || !self.clients) {
27
+ return;
28
+ }
29
+
30
+ const client = await self.clients.get(clientId);
31
+
32
+ if (!client) {
33
+ return;
34
+ }
35
+
36
+ const allClients = await self.clients.matchAll({
37
+ type: 'window',
38
+ });
39
+
40
+ switch (event.data) {
41
+ case 'KEEPALIVE_REQUEST': {
42
+ sendToClient(client, {
43
+ type: 'KEEPALIVE_RESPONSE',
44
+ });
45
+ break;
46
+ }
47
+
48
+ case 'INTEGRITY_CHECK_REQUEST': {
49
+ sendToClient(client, {
50
+ type: 'INTEGRITY_CHECK_RESPONSE',
51
+ payload: {
52
+ packageVersion: PACKAGE_VERSION,
53
+ checksum: INTEGRITY_CHECKSUM,
54
+ },
55
+ });
56
+ break;
57
+ }
58
+
59
+ case 'MOCK_ACTIVATE': {
60
+ activeClientIds.add(clientId);
61
+
62
+ sendToClient(client, {
63
+ type: 'MOCKING_ENABLED',
64
+ payload: {
65
+ client: {
66
+ id: client.id,
67
+ frameType: client.frameType,
68
+ },
69
+ },
70
+ });
71
+ break;
72
+ }
73
+
74
+ case 'CLIENT_CLOSED': {
75
+ activeClientIds.delete(clientId);
76
+
77
+ const remainingClients = allClients.filter((client) => {
78
+ return client.id !== clientId;
79
+ });
80
+
81
+ // Unregister itself when there are no more clients
82
+ if (remainingClients.length === 0) {
83
+ self.registration.unregister();
84
+ }
85
+
86
+ break;
87
+ }
88
+ }
89
+ });
90
+
91
+ addEventListener('fetch', function (event) {
92
+ const requestInterceptedAt = Date.now();
93
+
94
+ // Bypass navigation requests.
95
+ if (event.request.mode === 'navigate') {
96
+ return;
97
+ }
98
+
99
+ // Opening the DevTools triggers the "only-if-cached" request
100
+ // that cannot be handled by the worker. Bypass such requests.
101
+ if (event.request.cache === 'only-if-cached' && event.request.mode !== 'same-origin') {
102
+ return;
103
+ }
104
+
105
+ // Bypass all requests when there are no active clients.
106
+ // Prevents the self-unregistered worked from handling requests
107
+ // after it's been terminated (still remains active until the next reload).
108
+ if (activeClientIds.size === 0) {
109
+ return;
110
+ }
111
+
112
+ const requestId = crypto.randomUUID();
113
+ event.respondWith(handleRequest(event, requestId, requestInterceptedAt));
114
+ });
115
+
116
+ /**
117
+ * @param {FetchEvent} event
118
+ * @param {string} requestId
119
+ * @param {number} requestInterceptedAt
120
+ */
121
+ async function handleRequest(event, requestId, requestInterceptedAt) {
122
+ const client = await resolveMainClient(event);
123
+ const requestCloneForEvents = event.request.clone();
124
+ const response = await getResponse(event, client, requestId, requestInterceptedAt);
125
+
126
+ // Send back the response clone for the "response:*" life-cycle events.
127
+ // Ensure MSW is active and ready to handle the message, otherwise
128
+ // this message will pend indefinitely.
129
+ if (client && activeClientIds.has(client.id)) {
130
+ const serializedRequest = await serializeRequest(requestCloneForEvents);
131
+
132
+ // Clone the response so both the client and the library could consume it.
133
+ const responseClone = response.clone();
134
+
135
+ sendToClient(
136
+ client,
137
+ {
138
+ type: 'RESPONSE',
139
+ payload: {
140
+ isMockedResponse: IS_MOCKED_RESPONSE in response,
141
+ request: {
142
+ id: requestId,
143
+ ...serializedRequest,
144
+ },
145
+ response: {
146
+ type: responseClone.type,
147
+ status: responseClone.status,
148
+ statusText: responseClone.statusText,
149
+ headers: Object.fromEntries(responseClone.headers.entries()),
150
+ body: responseClone.body,
151
+ },
152
+ },
153
+ },
154
+ responseClone.body ? [serializedRequest.body, responseClone.body] : [],
155
+ );
156
+ }
157
+
158
+ return response;
159
+ }
160
+
161
+ /**
162
+ * Resolve the main client for the given event.
163
+ * Client that issues a request doesn't necessarily equal the client
164
+ * that registered the worker. It's with the latter the worker should
165
+ * communicate with during the response resolving phase.
166
+ * @param {FetchEvent} event
167
+ * @returns {Promise<Client | undefined>}
168
+ */
169
+ async function resolveMainClient(event) {
170
+ const client = await self.clients.get(event.clientId);
171
+
172
+ if (activeClientIds.has(event.clientId)) {
173
+ return client;
174
+ }
175
+
176
+ if (client?.frameType === 'top-level') {
177
+ return client;
178
+ }
179
+
180
+ const allClients = await self.clients.matchAll({
181
+ type: 'window',
182
+ });
183
+
184
+ return allClients
185
+ .filter((client) => {
186
+ // Get only those clients that are currently visible.
187
+ return client.visibilityState === 'visible';
188
+ })
189
+ .find((client) => {
190
+ // Find the client ID that's recorded in the
191
+ // set of clients that have registered the worker.
192
+ return activeClientIds.has(client.id);
193
+ });
194
+ }
195
+
196
+ /**
197
+ * @param {FetchEvent} event
198
+ * @param {Client | undefined} client
199
+ * @param {string} requestId
200
+ * @param {number} requestInterceptedAt
201
+ * @returns {Promise<Response>}
202
+ */
203
+ async function getResponse(event, client, requestId, requestInterceptedAt) {
204
+ // Clone the request because it might've been already used
205
+ // (i.e. its body has been read and sent to the client).
206
+ const requestClone = event.request.clone();
207
+
208
+ function passthrough() {
209
+ // Cast the request headers to a new Headers instance
210
+ // so the headers can be manipulated with.
211
+ const headers = new Headers(requestClone.headers);
212
+
213
+ // Remove the "accept" header value that marked this request as passthrough.
214
+ // This prevents request alteration and also keeps it compliant with the
215
+ // user-defined CORS policies.
216
+ const acceptHeader = headers.get('accept');
217
+ if (acceptHeader) {
218
+ const values = acceptHeader.split(',').map((value) => value.trim());
219
+ const filteredValues = values.filter((value) => value !== 'msw/passthrough');
220
+
221
+ if (filteredValues.length > 0) {
222
+ headers.set('accept', filteredValues.join(', '));
223
+ } else {
224
+ headers.delete('accept');
225
+ }
226
+ }
227
+
228
+ return fetch(requestClone, { headers });
229
+ }
230
+
231
+ // Bypass mocking when the client is not active.
232
+ if (!client) {
233
+ return passthrough();
234
+ }
235
+
236
+ // Bypass initial page load requests (i.e. static assets).
237
+ // The absence of the immediate/parent client in the map of the active clients
238
+ // means that MSW hasn't dispatched the "MOCK_ACTIVATE" event yet
239
+ // and is not ready to handle requests.
240
+ if (!activeClientIds.has(client.id)) {
241
+ return passthrough();
242
+ }
243
+
244
+ // Notify the client that a request has been intercepted.
245
+ const serializedRequest = await serializeRequest(event.request);
246
+ const clientMessage = await sendToClient(
247
+ client,
248
+ {
249
+ type: 'REQUEST',
250
+ payload: {
251
+ id: requestId,
252
+ interceptedAt: requestInterceptedAt,
253
+ ...serializedRequest,
254
+ },
255
+ },
256
+ [serializedRequest.body],
257
+ );
258
+
259
+ switch (clientMessage.type) {
260
+ case 'MOCK_RESPONSE': {
261
+ return respondWithMock(clientMessage.data);
262
+ }
263
+
264
+ case 'PASSTHROUGH': {
265
+ return passthrough();
266
+ }
267
+ }
268
+
269
+ return passthrough();
270
+ }
271
+
272
+ /**
273
+ * @param {Client} client
274
+ * @param {any} message
275
+ * @param {Array<Transferable>} transferrables
276
+ * @returns {Promise<any>}
277
+ */
278
+ function sendToClient(client, message, transferrables = []) {
279
+ return new Promise((resolve, reject) => {
280
+ const channel = new MessageChannel();
281
+
282
+ channel.port1.onmessage = (event) => {
283
+ if (event.data && event.data.error) {
284
+ return reject(event.data.error);
285
+ }
286
+
287
+ resolve(event.data);
288
+ };
289
+
290
+ client.postMessage(message, [channel.port2, ...transferrables.filter(Boolean)]);
291
+ });
292
+ }
293
+
294
+ /**
295
+ * @param {Response} response
296
+ * @returns {Response}
297
+ */
298
+ function respondWithMock(response) {
299
+ // Setting response status code to 0 is a no-op.
300
+ // However, when responding with a "Response.error()", the produced Response
301
+ // instance will have status code set to 0. Since it's not possible to create
302
+ // a Response instance with status code 0, handle that use-case separately.
303
+ if (response.status === 0) {
304
+ return Response.error();
305
+ }
306
+
307
+ const mockedResponse = new Response(response.body, response);
308
+
309
+ Reflect.defineProperty(mockedResponse, IS_MOCKED_RESPONSE, {
310
+ value: true,
311
+ enumerable: true,
312
+ });
313
+
314
+ return mockedResponse;
315
+ }
316
+
317
+ /**
318
+ * @param {Request} request
319
+ */
320
+ async function serializeRequest(request) {
321
+ return {
322
+ url: request.url,
323
+ mode: request.mode,
324
+ method: request.method,
325
+ headers: Object.fromEntries(request.headers.entries()),
326
+ cache: request.cache,
327
+ credentials: request.credentials,
328
+ destination: request.destination,
329
+ integrity: request.integrity,
330
+ redirect: request.redirect,
331
+ referrer: request.referrer,
332
+ referrerPolicy: request.referrerPolicy,
333
+ body: await request.arrayBuffer(),
334
+ keepalive: request.keepalive,
335
+ };
336
+ }
@@ -0,0 +1,15 @@
1
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
2
+ import { BrowserRouter, Route, Routes } from 'react-router-dom';
3
+
4
+ const queryClient = new QueryClient();
5
+
6
+ export const App = () => (
7
+ <QueryClientProvider client={queryClient}>
8
+ <BrowserRouter>
9
+ <Routes>
10
+ {/* Add routes here */}
11
+ <Route path="/" element={<div>Hello World</div>} />
12
+ </Routes>
13
+ </BrowserRouter>
14
+ </QueryClientProvider>
15
+ );
File without changes
@@ -0,0 +1,47 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from '@/components/ui/Accordion';
3
+
4
+ const meta: Meta<typeof Accordion> = {
5
+ title: 'Accordion',
6
+ component: Accordion,
7
+ };
8
+ export default meta;
9
+ type Story = StoryObj<typeof Accordion>;
10
+
11
+ export const Default: Story = {
12
+ render: () => (
13
+ <Accordion type="single" collapsible className="w-full max-w-md">
14
+ <AccordionItem value="item-1">
15
+ <AccordionTrigger>Is it accessible?</AccordionTrigger>
16
+ <AccordionContent>Yes. It adheres to the WAI-ARIA design pattern for accordions.</AccordionContent>
17
+ </AccordionItem>
18
+ <AccordionItem value="item-2">
19
+ <AccordionTrigger>Is it styled?</AccordionTrigger>
20
+ <AccordionContent>Yes. It comes with default styles that match the other components.</AccordionContent>
21
+ </AccordionItem>
22
+ <AccordionItem value="item-3">
23
+ <AccordionTrigger>Is it animated?</AccordionTrigger>
24
+ <AccordionContent>Yes. It uses CSS animations for smooth open and close transitions.</AccordionContent>
25
+ </AccordionItem>
26
+ </Accordion>
27
+ ),
28
+ };
29
+
30
+ export const Multiple: Story = {
31
+ render: () => (
32
+ <Accordion type="multiple" className="w-full max-w-md">
33
+ <AccordionItem value="item-1">
34
+ <AccordionTrigger>First section</AccordionTrigger>
35
+ <AccordionContent>Content for the first section. Multiple items can be open at once.</AccordionContent>
36
+ </AccordionItem>
37
+ <AccordionItem value="item-2">
38
+ <AccordionTrigger>Second section</AccordionTrigger>
39
+ <AccordionContent>Content for the second section. Try opening multiple items.</AccordionContent>
40
+ </AccordionItem>
41
+ <AccordionItem value="item-3">
42
+ <AccordionTrigger>Third section</AccordionTrigger>
43
+ <AccordionContent>Content for the third section. All three can be open simultaneously.</AccordionContent>
44
+ </AccordionItem>
45
+ </Accordion>
46
+ ),
47
+ };
@@ -0,0 +1,51 @@
1
+ import * as React from 'react';
2
+ import { ChevronDownIcon } from 'lucide-react';
3
+ import { Accordion as AccordionPrimitive } from 'radix-ui';
4
+
5
+ import { cn } from '@/lib/utils';
6
+
7
+ function Accordion({ ...props }: React.ComponentProps<typeof AccordionPrimitive.Root>) {
8
+ return <AccordionPrimitive.Root data-slot="accordion" {...props} />;
9
+ }
10
+
11
+ function AccordionItem({ className, ...props }: React.ComponentProps<typeof AccordionPrimitive.Item>) {
12
+ return (
13
+ <AccordionPrimitive.Item
14
+ data-slot="accordion-item"
15
+ className={cn('border-b last:border-b-0', className)}
16
+ {...props}
17
+ />
18
+ );
19
+ }
20
+
21
+ function AccordionTrigger({ className, children, ...props }: React.ComponentProps<typeof AccordionPrimitive.Trigger>) {
22
+ return (
23
+ <AccordionPrimitive.Header className="flex">
24
+ <AccordionPrimitive.Trigger
25
+ data-slot="accordion-trigger"
26
+ className={cn(
27
+ 'focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180',
28
+ className,
29
+ )}
30
+ {...props}
31
+ >
32
+ {children}
33
+ <ChevronDownIcon className="text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200" />
34
+ </AccordionPrimitive.Trigger>
35
+ </AccordionPrimitive.Header>
36
+ );
37
+ }
38
+
39
+ function AccordionContent({ className, children, ...props }: React.ComponentProps<typeof AccordionPrimitive.Content>) {
40
+ return (
41
+ <AccordionPrimitive.Content
42
+ data-slot="accordion-content"
43
+ className="data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm"
44
+ {...props}
45
+ >
46
+ <div className={cn('pt-0 pb-4', className)}>{children}</div>
47
+ </AccordionPrimitive.Content>
48
+ );
49
+ }
50
+
51
+ export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
@@ -0,0 +1,27 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { Alert, AlertTitle, AlertDescription } from '@/components/ui/Alert';
3
+
4
+ const meta: Meta<typeof Alert> = {
5
+ title: 'Alert',
6
+ component: Alert,
7
+ };
8
+ export default meta;
9
+ type Story = StoryObj<typeof Alert>;
10
+
11
+ export const Default: Story = {
12
+ render: () => (
13
+ <Alert>
14
+ <AlertTitle>Heads up!</AlertTitle>
15
+ <AlertDescription>You can add components to your app using the CLI.</AlertDescription>
16
+ </Alert>
17
+ ),
18
+ };
19
+
20
+ export const Destructive: Story = {
21
+ render: () => (
22
+ <Alert variant="destructive">
23
+ <AlertTitle>Error</AlertTitle>
24
+ <AlertDescription>Your session has expired. Please log in again.</AlertDescription>
25
+ </Alert>
26
+ ),
27
+ };
@@ -0,0 +1,49 @@
1
+ import * as React from 'react';
2
+ import { cva, type VariantProps } from 'class-variance-authority';
3
+
4
+ import { cn } from '@/lib/utils';
5
+
6
+ const alertVariants = cva(
7
+ 'relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current',
8
+ {
9
+ variants: {
10
+ variant: {
11
+ default: 'bg-card text-card-foreground',
12
+ destructive:
13
+ 'text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90',
14
+ },
15
+ },
16
+ defaultVariants: {
17
+ variant: 'default',
18
+ },
19
+ },
20
+ );
21
+
22
+ function Alert({ className, variant, ...props }: React.ComponentProps<'div'> & VariantProps<typeof alertVariants>) {
23
+ return <div data-slot="alert" role="alert" className={cn(alertVariants({ variant }), className)} {...props} />;
24
+ }
25
+
26
+ function AlertTitle({ className, ...props }: React.ComponentProps<'div'>) {
27
+ return (
28
+ <div
29
+ data-slot="alert-title"
30
+ className={cn('col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight', className)}
31
+ {...props}
32
+ />
33
+ );
34
+ }
35
+
36
+ function AlertDescription({ className, ...props }: React.ComponentProps<'div'>) {
37
+ return (
38
+ <div
39
+ data-slot="alert-description"
40
+ className={cn(
41
+ 'text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed',
42
+ className,
43
+ )}
44
+ {...props}
45
+ />
46
+ );
47
+ }
48
+
49
+ export { Alert, AlertTitle, AlertDescription };
@@ -0,0 +1,65 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import {
3
+ AlertDialog,
4
+ AlertDialogAction,
5
+ AlertDialogCancel,
6
+ AlertDialogContent,
7
+ AlertDialogDescription,
8
+ AlertDialogFooter,
9
+ AlertDialogHeader,
10
+ AlertDialogTitle,
11
+ AlertDialogTrigger,
12
+ } from '@/components/ui/AlertDialog';
13
+ import { Button } from '@/components/ui/Button';
14
+
15
+ const meta: Meta<typeof AlertDialog> = {
16
+ title: 'AlertDialog',
17
+ component: AlertDialog,
18
+ };
19
+ export default meta;
20
+ type Story = StoryObj<typeof AlertDialog>;
21
+
22
+ export const Default: Story = {
23
+ render: () => (
24
+ <AlertDialog>
25
+ <AlertDialogTrigger asChild>
26
+ <Button variant="outline">Delete Account</Button>
27
+ </AlertDialogTrigger>
28
+ <AlertDialogContent>
29
+ <AlertDialogHeader>
30
+ <AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
31
+ <AlertDialogDescription>
32
+ This action cannot be undone. This will permanently delete your account and remove your data from our
33
+ servers.
34
+ </AlertDialogDescription>
35
+ </AlertDialogHeader>
36
+ <AlertDialogFooter>
37
+ <AlertDialogCancel>Cancel</AlertDialogCancel>
38
+ <AlertDialogAction>Continue</AlertDialogAction>
39
+ </AlertDialogFooter>
40
+ </AlertDialogContent>
41
+ </AlertDialog>
42
+ ),
43
+ };
44
+
45
+ export const DestructiveAction: Story = {
46
+ render: () => (
47
+ <AlertDialog>
48
+ <AlertDialogTrigger asChild>
49
+ <Button variant="destructive">Delete Item</Button>
50
+ </AlertDialogTrigger>
51
+ <AlertDialogContent>
52
+ <AlertDialogHeader>
53
+ <AlertDialogTitle>Delete this item?</AlertDialogTitle>
54
+ <AlertDialogDescription>
55
+ This item will be permanently removed. This action cannot be undone.
56
+ </AlertDialogDescription>
57
+ </AlertDialogHeader>
58
+ <AlertDialogFooter>
59
+ <AlertDialogCancel>Cancel</AlertDialogCancel>
60
+ <AlertDialogAction variant="destructive">Delete</AlertDialogAction>
61
+ </AlertDialogFooter>
62
+ </AlertDialogContent>
63
+ </AlertDialog>
64
+ ),
65
+ };