@geekmidas/cli 0.54.0 → 1.0.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 +23 -0
  2. package/README.md +26 -5
  3. package/dist/CachedStateProvider-D73dCqfH.cjs +60 -0
  4. package/dist/CachedStateProvider-D73dCqfH.cjs.map +1 -0
  5. package/dist/CachedStateProvider-DVyKfaMm.mjs +54 -0
  6. package/dist/CachedStateProvider-DVyKfaMm.mjs.map +1 -0
  7. package/dist/CachedStateProvider-D_uISMmJ.cjs +3 -0
  8. package/dist/CachedStateProvider-OiFUGr7p.mjs +3 -0
  9. package/dist/HostingerProvider-DUV9-Tzg.cjs +210 -0
  10. package/dist/HostingerProvider-DUV9-Tzg.cjs.map +1 -0
  11. package/dist/HostingerProvider-DqUq6e9i.mjs +210 -0
  12. package/dist/HostingerProvider-DqUq6e9i.mjs.map +1 -0
  13. package/dist/LocalStateProvider-CdspeSVL.cjs +43 -0
  14. package/dist/LocalStateProvider-CdspeSVL.cjs.map +1 -0
  15. package/dist/LocalStateProvider-DxoSaWUV.mjs +42 -0
  16. package/dist/LocalStateProvider-DxoSaWUV.mjs.map +1 -0
  17. package/dist/Route53Provider-CpRIqu69.cjs +157 -0
  18. package/dist/Route53Provider-CpRIqu69.cjs.map +1 -0
  19. package/dist/Route53Provider-KUAX3vz9.mjs +156 -0
  20. package/dist/Route53Provider-KUAX3vz9.mjs.map +1 -0
  21. package/dist/SSMStateProvider-BxAPU99a.cjs +53 -0
  22. package/dist/SSMStateProvider-BxAPU99a.cjs.map +1 -0
  23. package/dist/SSMStateProvider-C4wp4AZe.mjs +52 -0
  24. package/dist/SSMStateProvider-C4wp4AZe.mjs.map +1 -0
  25. package/dist/{bundler-DGry2vaR.mjs → bundler-BqTN5Dj5.mjs} +3 -3
  26. package/dist/{bundler-DGry2vaR.mjs.map → bundler-BqTN5Dj5.mjs.map} +1 -1
  27. package/dist/{bundler-BB-kETMd.cjs → bundler-tHLLwYuU.cjs} +3 -3
  28. package/dist/{bundler-BB-kETMd.cjs.map → bundler-tHLLwYuU.cjs.map} +1 -1
  29. package/dist/{config-HYiM3iQJ.cjs → config-BGeJsW1r.cjs} +2 -2
  30. package/dist/{config-HYiM3iQJ.cjs.map → config-BGeJsW1r.cjs.map} +1 -1
  31. package/dist/{config-C3LSBNSl.mjs → config-C6awcFBx.mjs} +2 -2
  32. package/dist/{config-C3LSBNSl.mjs.map → config-C6awcFBx.mjs.map} +1 -1
  33. package/dist/config.cjs +2 -2
  34. package/dist/config.d.cts +1 -1
  35. package/dist/config.d.mts +2 -2
  36. package/dist/config.mjs +2 -2
  37. package/dist/credentials-C8DWtnMY.cjs +174 -0
  38. package/dist/credentials-C8DWtnMY.cjs.map +1 -0
  39. package/dist/credentials-DT1dSxIx.mjs +126 -0
  40. package/dist/credentials-DT1dSxIx.mjs.map +1 -0
  41. package/dist/deploy/sniffer-envkit-patch.cjs.map +1 -1
  42. package/dist/deploy/sniffer-envkit-patch.mjs.map +1 -1
  43. package/dist/deploy/sniffer-loader.cjs +1 -1
  44. package/dist/{dokploy-api-94KzmTVf.mjs → dokploy-api-7k3t7_zd.mjs} +1 -1
  45. package/dist/{dokploy-api-94KzmTVf.mjs.map → dokploy-api-7k3t7_zd.mjs.map} +1 -1
  46. package/dist/dokploy-api-CHa8G51l.mjs +3 -0
  47. package/dist/{dokploy-api-YD8WCQfW.cjs → dokploy-api-CQvhV6Hd.cjs} +1 -1
  48. package/dist/{dokploy-api-YD8WCQfW.cjs.map → dokploy-api-CQvhV6Hd.cjs.map} +1 -1
  49. package/dist/dokploy-api-CWc02yyg.cjs +3 -0
  50. package/dist/{encryption-DaCB_NmS.cjs → encryption-BE0UOb8j.cjs} +1 -1
  51. package/dist/{encryption-DaCB_NmS.cjs.map → encryption-BE0UOb8j.cjs.map} +1 -1
  52. package/dist/{encryption-Biq0EZ4m.cjs → encryption-Cv3zips0.cjs} +1 -1
  53. package/dist/{encryption-BC4MAODn.mjs → encryption-JtMsiGNp.mjs} +1 -1
  54. package/dist/{encryption-BC4MAODn.mjs.map → encryption-JtMsiGNp.mjs.map} +1 -1
  55. package/dist/encryption-UUmaWAmz.mjs +3 -0
  56. package/dist/{index-pOA56MWT.d.cts → index-B5rGIc4g.d.cts} +553 -196
  57. package/dist/index-B5rGIc4g.d.cts.map +1 -0
  58. package/dist/{index-A70abJ1m.d.mts → index-KFEbMIRa.d.mts} +554 -197
  59. package/dist/index-KFEbMIRa.d.mts.map +1 -0
  60. package/dist/index.cjs +2265 -658
  61. package/dist/index.cjs.map +1 -1
  62. package/dist/index.mjs +2242 -635
  63. package/dist/index.mjs.map +1 -1
  64. package/dist/{openapi-C3C-BzIZ.mjs → openapi-BMFmLnX6.mjs} +51 -7
  65. package/dist/openapi-BMFmLnX6.mjs.map +1 -0
  66. package/dist/{openapi-D7WwlpPF.cjs → openapi-D1KXv2Ml.cjs} +51 -7
  67. package/dist/openapi-D1KXv2Ml.cjs.map +1 -0
  68. package/dist/{openapi-react-query-C_MxpBgF.cjs → openapi-react-query-BeXvk-wa.cjs} +1 -1
  69. package/dist/{openapi-react-query-C_MxpBgF.cjs.map → openapi-react-query-BeXvk-wa.cjs.map} +1 -1
  70. package/dist/{openapi-react-query-ZoP9DPbY.mjs → openapi-react-query-DGEkD39r.mjs} +1 -1
  71. package/dist/{openapi-react-query-ZoP9DPbY.mjs.map → openapi-react-query-DGEkD39r.mjs.map} +1 -1
  72. package/dist/openapi-react-query.cjs +1 -1
  73. package/dist/openapi-react-query.mjs +1 -1
  74. package/dist/openapi.cjs +3 -3
  75. package/dist/openapi.d.cts +1 -1
  76. package/dist/openapi.d.mts +2 -2
  77. package/dist/openapi.mjs +3 -3
  78. package/dist/{storage-Dhst7BhI.mjs → storage-BMW6yLu3.mjs} +1 -1
  79. package/dist/{storage-Dhst7BhI.mjs.map → storage-BMW6yLu3.mjs.map} +1 -1
  80. package/dist/{storage-fOR8dMu5.cjs → storage-C7pmBq1u.cjs} +1 -1
  81. package/dist/{storage-BPRgh3DU.cjs → storage-CoCNe0Pt.cjs} +1 -1
  82. package/dist/{storage-BPRgh3DU.cjs.map → storage-CoCNe0Pt.cjs.map} +1 -1
  83. package/dist/{storage-DNj_I11J.mjs → storage-D8XzjVaO.mjs} +1 -1
  84. package/dist/{types-BtGL-8QS.d.mts → types-BldpmqQX.d.mts} +1 -1
  85. package/dist/{types-BtGL-8QS.d.mts.map → types-BldpmqQX.d.mts.map} +1 -1
  86. package/dist/workspace/index.cjs +1 -1
  87. package/dist/workspace/index.d.cts +1 -1
  88. package/dist/workspace/index.d.mts +2 -2
  89. package/dist/workspace/index.mjs +1 -1
  90. package/dist/{workspace-CaVW6j2q.cjs → workspace-BFRUOOrh.cjs} +309 -25
  91. package/dist/workspace-BFRUOOrh.cjs.map +1 -0
  92. package/dist/{workspace-DLFRaDc-.mjs → workspace-DAxG3_H2.mjs} +309 -25
  93. package/dist/workspace-DAxG3_H2.mjs.map +1 -0
  94. package/package.json +14 -8
  95. package/scripts/sync-versions.ts +86 -0
  96. package/src/build/__tests__/handler-templates.spec.ts +115 -47
  97. package/src/deploy/CachedStateProvider.ts +86 -0
  98. package/src/deploy/LocalStateProvider.ts +57 -0
  99. package/src/deploy/SSMStateProvider.ts +93 -0
  100. package/src/deploy/StateProvider.ts +171 -0
  101. package/src/deploy/__tests__/CachedStateProvider.spec.ts +228 -0
  102. package/src/deploy/__tests__/HostingerProvider.spec.ts +347 -0
  103. package/src/deploy/__tests__/LocalStateProvider.spec.ts +126 -0
  104. package/src/deploy/__tests__/Route53Provider.spec.ts +402 -0
  105. package/src/deploy/__tests__/SSMStateProvider.spec.ts +177 -0
  106. package/src/deploy/__tests__/__fixtures__/env-parsers/throwing-env-parser.ts +1 -3
  107. package/src/deploy/__tests__/__fixtures__/route-apps/services.ts +28 -19
  108. package/src/deploy/__tests__/createDnsProvider.spec.ts +172 -0
  109. package/src/deploy/__tests__/createStateProvider.spec.ts +116 -0
  110. package/src/deploy/__tests__/dns-orchestration.spec.ts +192 -0
  111. package/src/deploy/__tests__/dns-verification.spec.ts +2 -2
  112. package/src/deploy/__tests__/env-resolver.spec.ts +37 -15
  113. package/src/deploy/__tests__/sniffer.spec.ts +4 -20
  114. package/src/deploy/__tests__/state.spec.ts +13 -5
  115. package/src/deploy/dns/DnsProvider.ts +163 -0
  116. package/src/deploy/dns/HostingerProvider.ts +100 -0
  117. package/src/deploy/dns/Route53Provider.ts +256 -0
  118. package/src/deploy/dns/index.ts +257 -165
  119. package/src/deploy/env-resolver.ts +12 -5
  120. package/src/deploy/index.ts +16 -13
  121. package/src/deploy/sniffer-envkit-patch.ts +3 -1
  122. package/src/deploy/sniffer-routes-worker.ts +104 -0
  123. package/src/deploy/sniffer.ts +77 -55
  124. package/src/deploy/state-commands.ts +274 -0
  125. package/src/dev/__tests__/entry.spec.ts +8 -2
  126. package/src/dev/__tests__/index.spec.ts +1 -3
  127. package/src/dev/index.ts +9 -3
  128. package/src/docker/__tests__/templates.spec.ts +3 -1
  129. package/src/index.ts +88 -0
  130. package/src/init/__tests__/generators.spec.ts +273 -0
  131. package/src/init/__tests__/init.spec.ts +3 -3
  132. package/src/init/generators/auth.ts +1 -0
  133. package/src/init/generators/config.ts +2 -0
  134. package/src/init/generators/models.ts +6 -1
  135. package/src/init/generators/monorepo.ts +3 -0
  136. package/src/init/generators/ui.ts +1472 -0
  137. package/src/init/generators/web.ts +134 -87
  138. package/src/init/index.ts +22 -3
  139. package/src/init/templates/api.ts +109 -3
  140. package/src/init/versions.ts +25 -53
  141. package/src/openapi.ts +99 -13
  142. package/src/workspace/__tests__/schema.spec.ts +107 -0
  143. package/src/workspace/schema.ts +314 -4
  144. package/src/workspace/types.ts +22 -36
  145. package/dist/dokploy-api-CItuaWTq.mjs +0 -3
  146. package/dist/dokploy-api-DBNE8MDt.cjs +0 -3
  147. package/dist/encryption-CQXBZGkt.mjs +0 -3
  148. package/dist/index-A70abJ1m.d.mts.map +0 -1
  149. package/dist/index-pOA56MWT.d.cts.map +0 -1
  150. package/dist/openapi-C3C-BzIZ.mjs.map +0 -1
  151. package/dist/openapi-D7WwlpPF.cjs.map +0 -1
  152. package/dist/workspace-CaVW6j2q.cjs.map +0 -1
  153. package/dist/workspace-DLFRaDc-.mjs.map +0 -1
  154. package/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,1472 @@
1
+ import type { GeneratedFile, TemplateOptions } from '../templates/index.js';
2
+
3
+ /**
4
+ * Generate UI package files for fullstack template
5
+ * Based on @geekmidas/ui with shadcn/ui, Tailwind CSS v4, and Storybook
6
+ */
7
+ export function generateUiPackageFiles(
8
+ options: TemplateOptions,
9
+ ): GeneratedFile[] {
10
+ if (!options.monorepo || options.template !== 'fullstack') {
11
+ return [];
12
+ }
13
+
14
+ const packageName = `@${options.name}/ui`;
15
+
16
+ // package.json for UI package
17
+ const packageJson = {
18
+ name: packageName,
19
+ version: '0.0.1',
20
+ private: true,
21
+ type: 'module',
22
+ exports: {
23
+ '.': './src/index.ts',
24
+ './components': './src/components/index.ts',
25
+ './lib/utils': './src/lib/utils.ts',
26
+ './styles': './src/styles/globals.css',
27
+ },
28
+ scripts: {
29
+ 'ts:check': 'tsc --noEmit',
30
+ storybook: 'storybook dev -p 6006',
31
+ 'build:storybook': 'storybook build -o dist/storybook',
32
+ },
33
+ dependencies: {
34
+ '@radix-ui/react-dialog': '~1.1.4',
35
+ '@radix-ui/react-label': '~2.1.2',
36
+ '@radix-ui/react-separator': '~1.1.2',
37
+ '@radix-ui/react-slot': '~1.2.4',
38
+ '@radix-ui/react-tabs': '~1.1.2',
39
+ '@radix-ui/react-tooltip': '~1.1.6',
40
+ 'class-variance-authority': '~0.7.1',
41
+ clsx: '^2.1.1',
42
+ 'lucide-react': '~0.562.0',
43
+ 'tailwind-merge': '~3.4.0',
44
+ },
45
+ devDependencies: {
46
+ '@storybook/addon-a11y': '^8.4.7',
47
+ '@storybook/addon-essentials': '^8.4.7',
48
+ '@storybook/addon-interactions': '^8.4.7',
49
+ '@storybook/react': '^8.4.7',
50
+ '@storybook/react-vite': '^8.4.7',
51
+ '@tailwindcss/vite': '^4.0.0',
52
+ '@types/react': '^19.0.0',
53
+ '@types/react-dom': '^19.0.0',
54
+ react: '^19.0.0',
55
+ 'react-dom': '^19.0.0',
56
+ storybook: '^8.4.7',
57
+ tailwindcss: '^4.0.0',
58
+ typescript: '^5.8.2',
59
+ vite: '^6.0.0',
60
+ },
61
+ peerDependencies: {
62
+ react: '>=18.0.0',
63
+ 'react-dom': '>=18.0.0',
64
+ tailwindcss: '>=4.0.0',
65
+ },
66
+ };
67
+
68
+ // tsconfig.json for UI package
69
+ const tsConfig = {
70
+ extends: '../../tsconfig.json',
71
+ compilerOptions: {
72
+ jsx: 'react-jsx',
73
+ lib: ['ES2023', 'DOM', 'DOM.Iterable'],
74
+ noEmit: true,
75
+ baseUrl: '.',
76
+ paths: {
77
+ '~/*': ['./src/*'],
78
+ },
79
+ },
80
+ include: ['src/**/*'],
81
+ exclude: ['node_modules', 'dist', '**/*.stories.tsx'],
82
+ };
83
+
84
+ // components.json (shadcn config)
85
+ const componentsJson = {
86
+ $schema: 'https://ui.shadcn.com/schema.json',
87
+ style: 'new-york',
88
+ rsc: false,
89
+ tsx: true,
90
+ tailwind: {
91
+ config: '',
92
+ css: 'src/styles/globals.css',
93
+ baseColor: 'neutral',
94
+ cssVariables: true,
95
+ prefix: '',
96
+ },
97
+ aliases: {
98
+ components: '~/components',
99
+ utils: '~/lib/utils',
100
+ ui: '~/components/ui',
101
+ lib: '~/lib',
102
+ hooks: '~/hooks',
103
+ },
104
+ iconLibrary: 'lucide',
105
+ };
106
+
107
+ // .storybook/main.ts
108
+ const storybookMain = `import type { StorybookConfig } from '@storybook/react-vite';
109
+
110
+ const config: StorybookConfig = {
111
+ stories: ['../src/**/*.stories.@(ts|tsx)'],
112
+ addons: [
113
+ '@storybook/addon-essentials',
114
+ '@storybook/addon-interactions',
115
+ '@storybook/addon-a11y',
116
+ ],
117
+ framework: {
118
+ name: '@storybook/react-vite',
119
+ options: {},
120
+ },
121
+ docs: {
122
+ autodocs: 'tag',
123
+ },
124
+ viteFinal: async (config) => {
125
+ // Add Tailwind CSS v4 plugin
126
+ const tailwindcss = await import('@tailwindcss/vite');
127
+ config.plugins = config.plugins || [];
128
+ config.plugins.push(tailwindcss.default());
129
+ return config;
130
+ },
131
+ };
132
+
133
+ export default config;
134
+ `;
135
+
136
+ // .storybook/preview.ts
137
+ const storybookPreview = `import type { Preview } from '@storybook/react';
138
+ import '../src/styles/globals.css';
139
+
140
+ const preview: Preview = {
141
+ parameters: {
142
+ backgrounds: {
143
+ default: 'dark',
144
+ values: [
145
+ { name: 'dark', value: '#171717' },
146
+ { name: 'surface', value: '#1c1c1c' },
147
+ { name: 'light', value: '#fafafa' },
148
+ ],
149
+ },
150
+ controls: {
151
+ matchers: {
152
+ color: /(background|color)$/i,
153
+ date: /Date$/i,
154
+ },
155
+ },
156
+ layout: 'centered',
157
+ },
158
+ };
159
+
160
+ export default preview;
161
+ `;
162
+
163
+ // src/styles/globals.css (Tailwind v4 format)
164
+ const globalsCss = `@import "tailwindcss";
165
+
166
+ @theme {
167
+ --color-background: hsl(var(--background));
168
+ --color-foreground: hsl(var(--foreground));
169
+ --color-card: hsl(var(--card));
170
+ --color-card-foreground: hsl(var(--card-foreground));
171
+ --color-popover: hsl(var(--popover));
172
+ --color-popover-foreground: hsl(var(--popover-foreground));
173
+ --color-primary: hsl(var(--primary));
174
+ --color-primary-foreground: hsl(var(--primary-foreground));
175
+ --color-secondary: hsl(var(--secondary));
176
+ --color-secondary-foreground: hsl(var(--secondary-foreground));
177
+ --color-muted: hsl(var(--muted));
178
+ --color-muted-foreground: hsl(var(--muted-foreground));
179
+ --color-accent: hsl(var(--accent));
180
+ --color-accent-foreground: hsl(var(--accent-foreground));
181
+ --color-destructive: hsl(var(--destructive));
182
+ --color-destructive-foreground: hsl(var(--destructive-foreground));
183
+ --color-border: hsl(var(--border));
184
+ --color-input: hsl(var(--input));
185
+ --color-ring: hsl(var(--ring));
186
+ --radius-sm: calc(var(--radius) - 4px);
187
+ --radius-md: calc(var(--radius) - 2px);
188
+ --radius-lg: var(--radius);
189
+ --radius-xl: calc(var(--radius) + 4px);
190
+ }
191
+
192
+ @layer base {
193
+ :root {
194
+ --background: 0 0% 100%;
195
+ --foreground: 0 0% 3.9%;
196
+ --card: 0 0% 100%;
197
+ --card-foreground: 0 0% 3.9%;
198
+ --popover: 0 0% 100%;
199
+ --popover-foreground: 0 0% 3.9%;
200
+ --primary: 160 84% 39%;
201
+ --primary-foreground: 0 0% 98%;
202
+ --secondary: 0 0% 96.1%;
203
+ --secondary-foreground: 0 0% 9%;
204
+ --muted: 0 0% 96.1%;
205
+ --muted-foreground: 0 0% 45.1%;
206
+ --accent: 0 0% 96.1%;
207
+ --accent-foreground: 0 0% 9%;
208
+ --destructive: 0 84.2% 60.2%;
209
+ --destructive-foreground: 0 0% 98%;
210
+ --border: 0 0% 89.8%;
211
+ --input: 0 0% 89.8%;
212
+ --ring: 160 84% 39%;
213
+ --radius: 0.5rem;
214
+ }
215
+
216
+ .dark {
217
+ --background: 0 0% 9%;
218
+ --foreground: 0 0% 98%;
219
+ --card: 0 0% 11%;
220
+ --card-foreground: 0 0% 98%;
221
+ --popover: 0 0% 11%;
222
+ --popover-foreground: 0 0% 98%;
223
+ --primary: 160 84% 52%;
224
+ --primary-foreground: 0 0% 9%;
225
+ --secondary: 0 0% 15%;
226
+ --secondary-foreground: 0 0% 98%;
227
+ --muted: 0 0% 15%;
228
+ --muted-foreground: 0 0% 64%;
229
+ --accent: 0 0% 15%;
230
+ --accent-foreground: 0 0% 98%;
231
+ --destructive: 0 62.8% 50.6%;
232
+ --destructive-foreground: 0 0% 98%;
233
+ --border: 0 0% 18%;
234
+ --input: 0 0% 18%;
235
+ --ring: 160 84% 52%;
236
+ }
237
+ }
238
+
239
+ @layer base {
240
+ * {
241
+ @apply border-border;
242
+ }
243
+ body {
244
+ @apply bg-background text-foreground;
245
+ }
246
+ }
247
+ `;
248
+
249
+ // src/lib/utils.ts
250
+ const utilsTs = `import { type ClassValue, clsx } from 'clsx';
251
+ import { twMerge } from 'tailwind-merge';
252
+
253
+ export function cn(...inputs: ClassValue[]) {
254
+ return twMerge(clsx(inputs));
255
+ }
256
+ `;
257
+
258
+ // src/components/ui/button.tsx
259
+ const buttonTsx = `import { Slot } from '@radix-ui/react-slot';
260
+ import { cva, type VariantProps } from 'class-variance-authority';
261
+ import * as React from 'react';
262
+
263
+ import { cn } from '~/lib/utils';
264
+
265
+ const buttonVariants = cva(
266
+ 'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
267
+ {
268
+ variants: {
269
+ variant: {
270
+ default:
271
+ 'bg-primary text-primary-foreground shadow hover:bg-primary/90',
272
+ destructive:
273
+ 'bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90',
274
+ outline:
275
+ 'border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground',
276
+ secondary:
277
+ 'bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80',
278
+ ghost: 'hover:bg-accent hover:text-accent-foreground',
279
+ link: 'text-primary underline-offset-4 hover:underline',
280
+ },
281
+ size: {
282
+ default: 'h-9 px-4 py-2',
283
+ sm: 'h-8 rounded-md px-3 text-xs',
284
+ lg: 'h-10 rounded-md px-8',
285
+ icon: 'h-9 w-9',
286
+ },
287
+ },
288
+ defaultVariants: {
289
+ variant: 'default',
290
+ size: 'default',
291
+ },
292
+ },
293
+ );
294
+
295
+ export interface ButtonProps
296
+ extends React.ButtonHTMLAttributes<HTMLButtonElement>,
297
+ VariantProps<typeof buttonVariants> {
298
+ asChild?: boolean;
299
+ }
300
+
301
+ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
302
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
303
+ const Comp = asChild ? Slot : 'button';
304
+ return (
305
+ <Comp
306
+ className={cn(buttonVariants({ variant, size, className }))}
307
+ ref={ref}
308
+ {...props}
309
+ />
310
+ );
311
+ },
312
+ );
313
+ Button.displayName = 'Button';
314
+
315
+ export { Button, buttonVariants };
316
+ `;
317
+
318
+ // src/components/ui/button/button.stories.tsx
319
+ const buttonStories = `import type { Meta, StoryObj } from '@storybook/react';
320
+ import { Button } from '.';
321
+
322
+ const meta: Meta<typeof Button> = {
323
+ title: 'Components/Button',
324
+ component: Button,
325
+ tags: ['autodocs'],
326
+ argTypes: {
327
+ variant: {
328
+ control: 'select',
329
+ options: ['default', 'destructive', 'outline', 'secondary', 'ghost', 'link'],
330
+ },
331
+ size: {
332
+ control: 'select',
333
+ options: ['default', 'sm', 'lg', 'icon'],
334
+ },
335
+ },
336
+ };
337
+
338
+ export default meta;
339
+ type Story = StoryObj<typeof Button>;
340
+
341
+ export const Default: Story = {
342
+ args: {
343
+ children: 'Button',
344
+ variant: 'default',
345
+ size: 'default',
346
+ },
347
+ };
348
+
349
+ export const Secondary: Story = {
350
+ args: {
351
+ children: 'Secondary',
352
+ variant: 'secondary',
353
+ },
354
+ };
355
+
356
+ export const Destructive: Story = {
357
+ args: {
358
+ children: 'Destructive',
359
+ variant: 'destructive',
360
+ },
361
+ };
362
+
363
+ export const Outline: Story = {
364
+ args: {
365
+ children: 'Outline',
366
+ variant: 'outline',
367
+ },
368
+ };
369
+
370
+ export const Ghost: Story = {
371
+ args: {
372
+ children: 'Ghost',
373
+ variant: 'ghost',
374
+ },
375
+ };
376
+
377
+ export const Link: Story = {
378
+ args: {
379
+ children: 'Link',
380
+ variant: 'link',
381
+ },
382
+ };
383
+ `;
384
+
385
+ // src/components/ui/input.tsx
386
+ const inputTsx = `import * as React from 'react';
387
+
388
+ import { cn } from '~/lib/utils';
389
+
390
+ const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<'input'>>(
391
+ ({ className, type, ...props }, ref) => {
392
+ return (
393
+ <input
394
+ type={type}
395
+ className={cn(
396
+ 'flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm',
397
+ className,
398
+ )}
399
+ ref={ref}
400
+ {...props}
401
+ />
402
+ );
403
+ },
404
+ );
405
+ Input.displayName = 'Input';
406
+
407
+ export { Input };
408
+ `;
409
+
410
+ // src/components/ui/card.tsx
411
+ const cardTsx = `import * as React from 'react';
412
+
413
+ import { cn } from '~/lib/utils';
414
+
415
+ const Card = React.forwardRef<
416
+ HTMLDivElement,
417
+ React.HTMLAttributes<HTMLDivElement>
418
+ >(({ className, ...props }, ref) => (
419
+ <div
420
+ ref={ref}
421
+ className={cn(
422
+ 'rounded-xl border bg-card text-card-foreground shadow',
423
+ className,
424
+ )}
425
+ {...props}
426
+ />
427
+ ));
428
+ Card.displayName = 'Card';
429
+
430
+ const CardHeader = React.forwardRef<
431
+ HTMLDivElement,
432
+ React.HTMLAttributes<HTMLDivElement>
433
+ >(({ className, ...props }, ref) => (
434
+ <div
435
+ ref={ref}
436
+ className={cn('flex flex-col space-y-1.5 p-6', className)}
437
+ {...props}
438
+ />
439
+ ));
440
+ CardHeader.displayName = 'CardHeader';
441
+
442
+ const CardTitle = React.forwardRef<
443
+ HTMLDivElement,
444
+ React.HTMLAttributes<HTMLDivElement>
445
+ >(({ className, ...props }, ref) => (
446
+ <div
447
+ ref={ref}
448
+ className={cn('font-semibold leading-none tracking-tight', className)}
449
+ {...props}
450
+ />
451
+ ));
452
+ CardTitle.displayName = 'CardTitle';
453
+
454
+ const CardDescription = React.forwardRef<
455
+ HTMLDivElement,
456
+ React.HTMLAttributes<HTMLDivElement>
457
+ >(({ className, ...props }, ref) => (
458
+ <div
459
+ ref={ref}
460
+ className={cn('text-sm text-muted-foreground', className)}
461
+ {...props}
462
+ />
463
+ ));
464
+ CardDescription.displayName = 'CardDescription';
465
+
466
+ const CardContent = React.forwardRef<
467
+ HTMLDivElement,
468
+ React.HTMLAttributes<HTMLDivElement>
469
+ >(({ className, ...props }, ref) => (
470
+ <div ref={ref} className={cn('p-6 pt-0', className)} {...props} />
471
+ ));
472
+ CardContent.displayName = 'CardContent';
473
+
474
+ const CardFooter = React.forwardRef<
475
+ HTMLDivElement,
476
+ React.HTMLAttributes<HTMLDivElement>
477
+ >(({ className, ...props }, ref) => (
478
+ <div
479
+ ref={ref}
480
+ className={cn('flex items-center p-6 pt-0', className)}
481
+ {...props}
482
+ />
483
+ ));
484
+ CardFooter.displayName = 'CardFooter';
485
+
486
+ export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent };
487
+ `;
488
+
489
+ // src/components/ui/input/input.stories.tsx
490
+ const inputStories = `import type { Meta, StoryObj } from '@storybook/react';
491
+ import { Input } from '.';
492
+
493
+ const meta: Meta<typeof Input> = {
494
+ title: 'Components/Input',
495
+ component: Input,
496
+ tags: ['autodocs'],
497
+ argTypes: {
498
+ type: {
499
+ control: 'select',
500
+ options: ['text', 'email', 'password', 'number', 'search', 'tel', 'url'],
501
+ },
502
+ disabled: {
503
+ control: 'boolean',
504
+ },
505
+ },
506
+ };
507
+
508
+ export default meta;
509
+ type Story = StoryObj<typeof Input>;
510
+
511
+ export const Default: Story = {
512
+ args: {
513
+ placeholder: 'Enter text...',
514
+ },
515
+ };
516
+
517
+ export const Email: Story = {
518
+ args: {
519
+ type: 'email',
520
+ placeholder: 'Enter email...',
521
+ },
522
+ };
523
+
524
+ export const Password: Story = {
525
+ args: {
526
+ type: 'password',
527
+ placeholder: 'Enter password...',
528
+ },
529
+ };
530
+
531
+ export const Disabled: Story = {
532
+ args: {
533
+ placeholder: 'Disabled input',
534
+ disabled: true,
535
+ },
536
+ };
537
+
538
+ export const WithValue: Story = {
539
+ args: {
540
+ defaultValue: 'Hello World',
541
+ },
542
+ };
543
+ `;
544
+
545
+ // src/components/ui/card/card.stories.tsx
546
+ const cardStories = `import type { Meta, StoryObj } from '@storybook/react';
547
+ import { Button } from '../button';
548
+ import {
549
+ Card,
550
+ CardContent,
551
+ CardDescription,
552
+ CardFooter,
553
+ CardHeader,
554
+ CardTitle,
555
+ } from '.';
556
+ import { Input } from '../input';
557
+
558
+ const meta: Meta<typeof Card> = {
559
+ title: 'Components/Card',
560
+ component: Card,
561
+ tags: ['autodocs'],
562
+ };
563
+
564
+ export default meta;
565
+ type Story = StoryObj<typeof Card>;
566
+
567
+ export const Default: Story = {
568
+ render: () => (
569
+ <Card className="w-[350px]">
570
+ <CardHeader>
571
+ <CardTitle>Card Title</CardTitle>
572
+ <CardDescription>Card description goes here.</CardDescription>
573
+ </CardHeader>
574
+ <CardContent>
575
+ <p>Card content goes here.</p>
576
+ </CardContent>
577
+ </Card>
578
+ ),
579
+ };
580
+
581
+ export const WithFooter: Story = {
582
+ render: () => (
583
+ <Card className="w-[350px]">
584
+ <CardHeader>
585
+ <CardTitle>Create Account</CardTitle>
586
+ <CardDescription>Enter your details below.</CardDescription>
587
+ </CardHeader>
588
+ <CardContent className="space-y-4">
589
+ <Input placeholder="Email" type="email" />
590
+ <Input placeholder="Password" type="password" />
591
+ </CardContent>
592
+ <CardFooter className="flex justify-between">
593
+ <Button variant="outline">Cancel</Button>
594
+ <Button>Create</Button>
595
+ </CardFooter>
596
+ </Card>
597
+ ),
598
+ };
599
+
600
+ export const Simple: Story = {
601
+ render: () => (
602
+ <Card className="w-[350px] p-6">
603
+ <p>Simple card with just content.</p>
604
+ </Card>
605
+ ),
606
+ };
607
+ `;
608
+
609
+ // src/components/ui/label/index.tsx
610
+ const labelTsx = `import * as LabelPrimitive from '@radix-ui/react-label';
611
+ import { cva, type VariantProps } from 'class-variance-authority';
612
+ import * as React from 'react';
613
+
614
+ import { cn } from '~/lib/utils';
615
+
616
+ const labelVariants = cva(
617
+ 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70',
618
+ );
619
+
620
+ const Label = React.forwardRef<
621
+ React.ElementRef<typeof LabelPrimitive.Root>,
622
+ React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
623
+ VariantProps<typeof labelVariants>
624
+ >(({ className, ...props }, ref) => (
625
+ <LabelPrimitive.Root
626
+ ref={ref}
627
+ className={cn(labelVariants(), className)}
628
+ {...props}
629
+ />
630
+ ));
631
+ Label.displayName = LabelPrimitive.Root.displayName;
632
+
633
+ export { Label };
634
+ `;
635
+
636
+ // src/components/ui/label/label.stories.tsx
637
+ const labelStories = `import type { Meta, StoryObj } from '@storybook/react';
638
+ import { Input } from '../input';
639
+ import { Label } from '.';
640
+
641
+ const meta: Meta<typeof Label> = {
642
+ title: 'Components/Label',
643
+ component: Label,
644
+ tags: ['autodocs'],
645
+ };
646
+
647
+ export default meta;
648
+ type Story = StoryObj<typeof Label>;
649
+
650
+ export const Default: Story = {
651
+ args: {
652
+ children: 'Label',
653
+ },
654
+ };
655
+
656
+ export const WithInput: Story = {
657
+ render: () => (
658
+ <div className="grid w-full max-w-sm items-center gap-1.5">
659
+ <Label htmlFor="email">Email</Label>
660
+ <Input type="email" id="email" placeholder="Email" />
661
+ </div>
662
+ ),
663
+ };
664
+
665
+ export const Disabled: Story = {
666
+ render: () => (
667
+ <div className="grid w-full max-w-sm items-center gap-1.5">
668
+ <Label htmlFor="disabled" className="peer-disabled:cursor-not-allowed peer-disabled:opacity-70">
669
+ Disabled
670
+ </Label>
671
+ <Input type="text" id="disabled" placeholder="Disabled" disabled className="peer" />
672
+ </div>
673
+ ),
674
+ };
675
+ `;
676
+
677
+ // src/components/ui/badge/index.tsx
678
+ const badgeTsx = `import { cva, type VariantProps } from 'class-variance-authority';
679
+ import * as React from 'react';
680
+
681
+ import { cn } from '~/lib/utils';
682
+
683
+ const badgeVariants = cva(
684
+ 'inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2',
685
+ {
686
+ variants: {
687
+ variant: {
688
+ default:
689
+ 'border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80',
690
+ secondary:
691
+ 'border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80',
692
+ destructive:
693
+ 'border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80',
694
+ outline: 'text-foreground',
695
+ },
696
+ },
697
+ defaultVariants: {
698
+ variant: 'default',
699
+ },
700
+ },
701
+ );
702
+
703
+ export interface BadgeProps
704
+ extends React.HTMLAttributes<HTMLDivElement>,
705
+ VariantProps<typeof badgeVariants> {}
706
+
707
+ function Badge({ className, variant, ...props }: BadgeProps) {
708
+ return (
709
+ <div className={cn(badgeVariants({ variant }), className)} {...props} />
710
+ );
711
+ }
712
+
713
+ export { Badge, badgeVariants };
714
+ `;
715
+
716
+ // src/components/ui/badge/badge.stories.tsx
717
+ const badgeStories = `import type { Meta, StoryObj } from '@storybook/react';
718
+ import { Badge } from '.';
719
+
720
+ const meta: Meta<typeof Badge> = {
721
+ title: 'Components/Badge',
722
+ component: Badge,
723
+ tags: ['autodocs'],
724
+ argTypes: {
725
+ variant: {
726
+ control: 'select',
727
+ options: ['default', 'secondary', 'destructive', 'outline'],
728
+ },
729
+ },
730
+ };
731
+
732
+ export default meta;
733
+ type Story = StoryObj<typeof Badge>;
734
+
735
+ export const Default: Story = {
736
+ args: {
737
+ children: 'Badge',
738
+ variant: 'default',
739
+ },
740
+ };
741
+
742
+ export const Secondary: Story = {
743
+ args: {
744
+ children: 'Secondary',
745
+ variant: 'secondary',
746
+ },
747
+ };
748
+
749
+ export const Destructive: Story = {
750
+ args: {
751
+ children: 'Destructive',
752
+ variant: 'destructive',
753
+ },
754
+ };
755
+
756
+ export const Outline: Story = {
757
+ args: {
758
+ children: 'Outline',
759
+ variant: 'outline',
760
+ },
761
+ };
762
+ `;
763
+
764
+ // src/components/ui/separator/index.tsx
765
+ const separatorTsx = `import * as SeparatorPrimitive from '@radix-ui/react-separator';
766
+ import * as React from 'react';
767
+
768
+ import { cn } from '~/lib/utils';
769
+
770
+ const Separator = React.forwardRef<
771
+ React.ElementRef<typeof SeparatorPrimitive.Root>,
772
+ React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
773
+ >(
774
+ (
775
+ { className, orientation = 'horizontal', decorative = true, ...props },
776
+ ref,
777
+ ) => (
778
+ <SeparatorPrimitive.Root
779
+ ref={ref}
780
+ decorative={decorative}
781
+ orientation={orientation}
782
+ className={cn(
783
+ 'shrink-0 bg-border',
784
+ orientation === 'horizontal' ? 'h-[1px] w-full' : 'h-full w-[1px]',
785
+ className,
786
+ )}
787
+ {...props}
788
+ />
789
+ ),
790
+ );
791
+ Separator.displayName = SeparatorPrimitive.Root.displayName;
792
+
793
+ export { Separator };
794
+ `;
795
+
796
+ // src/components/ui/separator/separator.stories.tsx
797
+ const separatorStories = `import type { Meta, StoryObj } from '@storybook/react';
798
+ import { Separator } from '.';
799
+
800
+ const meta: Meta<typeof Separator> = {
801
+ title: 'Components/Separator',
802
+ component: Separator,
803
+ tags: ['autodocs'],
804
+ argTypes: {
805
+ orientation: {
806
+ control: 'select',
807
+ options: ['horizontal', 'vertical'],
808
+ },
809
+ },
810
+ };
811
+
812
+ export default meta;
813
+ type Story = StoryObj<typeof Separator>;
814
+
815
+ export const Horizontal: Story = {
816
+ render: () => (
817
+ <div className="w-[300px]">
818
+ <div className="space-y-1">
819
+ <h4 className="text-sm font-medium leading-none">Radix Primitives</h4>
820
+ <p className="text-sm text-muted-foreground">
821
+ An open-source UI component library.
822
+ </p>
823
+ </div>
824
+ <Separator className="my-4" />
825
+ <div className="flex h-5 items-center space-x-4 text-sm">
826
+ <div>Blog</div>
827
+ <Separator orientation="vertical" />
828
+ <div>Docs</div>
829
+ <Separator orientation="vertical" />
830
+ <div>Source</div>
831
+ </div>
832
+ </div>
833
+ ),
834
+ };
835
+
836
+ export const Vertical: Story = {
837
+ render: () => (
838
+ <div className="flex h-5 items-center space-x-4 text-sm">
839
+ <div>Blog</div>
840
+ <Separator orientation="vertical" />
841
+ <div>Docs</div>
842
+ <Separator orientation="vertical" />
843
+ <div>Source</div>
844
+ </div>
845
+ ),
846
+ };
847
+ `;
848
+
849
+ // src/components/ui/tabs/index.tsx
850
+ const tabsTsx = `import * as TabsPrimitive from '@radix-ui/react-tabs';
851
+ import * as React from 'react';
852
+
853
+ import { cn } from '~/lib/utils';
854
+
855
+ const Tabs = TabsPrimitive.Root;
856
+
857
+ const TabsList = React.forwardRef<
858
+ React.ElementRef<typeof TabsPrimitive.List>,
859
+ React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
860
+ >(({ className, ...props }, ref) => (
861
+ <TabsPrimitive.List
862
+ ref={ref}
863
+ className={cn(
864
+ 'inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground',
865
+ className,
866
+ )}
867
+ {...props}
868
+ />
869
+ ));
870
+ TabsList.displayName = TabsPrimitive.List.displayName;
871
+
872
+ const TabsTrigger = React.forwardRef<
873
+ React.ElementRef<typeof TabsPrimitive.Trigger>,
874
+ React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
875
+ >(({ className, ...props }, ref) => (
876
+ <TabsPrimitive.Trigger
877
+ ref={ref}
878
+ className={cn(
879
+ 'inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow',
880
+ className,
881
+ )}
882
+ {...props}
883
+ />
884
+ ));
885
+ TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
886
+
887
+ const TabsContent = React.forwardRef<
888
+ React.ElementRef<typeof TabsPrimitive.Content>,
889
+ React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
890
+ >(({ className, ...props }, ref) => (
891
+ <TabsPrimitive.Content
892
+ ref={ref}
893
+ className={cn(
894
+ 'mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
895
+ className,
896
+ )}
897
+ {...props}
898
+ />
899
+ ));
900
+ TabsContent.displayName = TabsPrimitive.Content.displayName;
901
+
902
+ export { Tabs, TabsList, TabsTrigger, TabsContent };
903
+ `;
904
+
905
+ // src/components/ui/tabs/tabs.stories.tsx
906
+ const tabsStories = `import type { Meta, StoryObj } from '@storybook/react';
907
+ import { Tabs, TabsContent, TabsList, TabsTrigger } from '.';
908
+ import { Button } from '../button';
909
+ import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '../card';
910
+ import { Input } from '../input';
911
+ import { Label } from '../label';
912
+
913
+ const meta: Meta<typeof Tabs> = {
914
+ title: 'Components/Tabs',
915
+ component: Tabs,
916
+ tags: ['autodocs'],
917
+ };
918
+
919
+ export default meta;
920
+ type Story = StoryObj<typeof Tabs>;
921
+
922
+ export const Default: Story = {
923
+ render: () => (
924
+ <Tabs defaultValue="account" className="w-[400px]">
925
+ <TabsList>
926
+ <TabsTrigger value="account">Account</TabsTrigger>
927
+ <TabsTrigger value="password">Password</TabsTrigger>
928
+ </TabsList>
929
+ <TabsContent value="account">
930
+ <Card>
931
+ <CardHeader>
932
+ <CardTitle>Account</CardTitle>
933
+ <CardDescription>
934
+ Make changes to your account here. Click save when you're done.
935
+ </CardDescription>
936
+ </CardHeader>
937
+ <CardContent className="space-y-2">
938
+ <div className="space-y-1">
939
+ <Label htmlFor="name">Name</Label>
940
+ <Input id="name" defaultValue="Pedro Duarte" />
941
+ </div>
942
+ <div className="space-y-1">
943
+ <Label htmlFor="username">Username</Label>
944
+ <Input id="username" defaultValue="@peduarte" />
945
+ </div>
946
+ </CardContent>
947
+ <CardFooter>
948
+ <Button>Save changes</Button>
949
+ </CardFooter>
950
+ </Card>
951
+ </TabsContent>
952
+ <TabsContent value="password">
953
+ <Card>
954
+ <CardHeader>
955
+ <CardTitle>Password</CardTitle>
956
+ <CardDescription>
957
+ Change your password here. After saving, you'll be logged out.
958
+ </CardDescription>
959
+ </CardHeader>
960
+ <CardContent className="space-y-2">
961
+ <div className="space-y-1">
962
+ <Label htmlFor="current">Current password</Label>
963
+ <Input id="current" type="password" />
964
+ </div>
965
+ <div className="space-y-1">
966
+ <Label htmlFor="new">New password</Label>
967
+ <Input id="new" type="password" />
968
+ </div>
969
+ </CardContent>
970
+ <CardFooter>
971
+ <Button>Save password</Button>
972
+ </CardFooter>
973
+ </Card>
974
+ </TabsContent>
975
+ </Tabs>
976
+ ),
977
+ };
978
+ `;
979
+
980
+ // src/components/ui/tooltip/index.tsx
981
+ const tooltipTsx = `import * as TooltipPrimitive from '@radix-ui/react-tooltip';
982
+ import * as React from 'react';
983
+
984
+ import { cn } from '~/lib/utils';
985
+
986
+ const TooltipProvider = TooltipPrimitive.Provider;
987
+
988
+ const Tooltip = TooltipPrimitive.Root;
989
+
990
+ const TooltipTrigger = TooltipPrimitive.Trigger;
991
+
992
+ const TooltipContent = React.forwardRef<
993
+ React.ElementRef<typeof TooltipPrimitive.Content>,
994
+ React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
995
+ >(({ className, sideOffset = 4, ...props }, ref) => (
996
+ <TooltipPrimitive.Portal>
997
+ <TooltipPrimitive.Content
998
+ ref={ref}
999
+ sideOffset={sideOffset}
1000
+ className={cn(
1001
+ 'z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
1002
+ className,
1003
+ )}
1004
+ {...props}
1005
+ />
1006
+ </TooltipPrimitive.Portal>
1007
+ ));
1008
+ TooltipContent.displayName = TooltipPrimitive.Content.displayName;
1009
+
1010
+ export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
1011
+ `;
1012
+
1013
+ // src/components/ui/tooltip/tooltip.stories.tsx
1014
+ const tooltipStories = `import type { Meta, StoryObj } from '@storybook/react';
1015
+ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '.';
1016
+ import { Button } from '../button';
1017
+
1018
+ const meta: Meta<typeof Tooltip> = {
1019
+ title: 'Components/Tooltip',
1020
+ component: Tooltip,
1021
+ tags: ['autodocs'],
1022
+ decorators: [
1023
+ (Story) => (
1024
+ <TooltipProvider>
1025
+ <Story />
1026
+ </TooltipProvider>
1027
+ ),
1028
+ ],
1029
+ };
1030
+
1031
+ export default meta;
1032
+ type Story = StoryObj<typeof Tooltip>;
1033
+
1034
+ export const Default: Story = {
1035
+ render: () => (
1036
+ <Tooltip>
1037
+ <TooltipTrigger asChild>
1038
+ <Button variant="outline">Hover me</Button>
1039
+ </TooltipTrigger>
1040
+ <TooltipContent>
1041
+ <p>Add to library</p>
1042
+ </TooltipContent>
1043
+ </Tooltip>
1044
+ ),
1045
+ };
1046
+
1047
+ export const Positions: Story = {
1048
+ render: () => (
1049
+ <div className="flex gap-4">
1050
+ <Tooltip>
1051
+ <TooltipTrigger asChild>
1052
+ <Button variant="outline">Top</Button>
1053
+ </TooltipTrigger>
1054
+ <TooltipContent side="top">
1055
+ <p>Top tooltip</p>
1056
+ </TooltipContent>
1057
+ </Tooltip>
1058
+ <Tooltip>
1059
+ <TooltipTrigger asChild>
1060
+ <Button variant="outline">Bottom</Button>
1061
+ </TooltipTrigger>
1062
+ <TooltipContent side="bottom">
1063
+ <p>Bottom tooltip</p>
1064
+ </TooltipContent>
1065
+ </Tooltip>
1066
+ <Tooltip>
1067
+ <TooltipTrigger asChild>
1068
+ <Button variant="outline">Left</Button>
1069
+ </TooltipTrigger>
1070
+ <TooltipContent side="left">
1071
+ <p>Left tooltip</p>
1072
+ </TooltipContent>
1073
+ </Tooltip>
1074
+ <Tooltip>
1075
+ <TooltipTrigger asChild>
1076
+ <Button variant="outline">Right</Button>
1077
+ </TooltipTrigger>
1078
+ <TooltipContent side="right">
1079
+ <p>Right tooltip</p>
1080
+ </TooltipContent>
1081
+ </Tooltip>
1082
+ </div>
1083
+ ),
1084
+ };
1085
+ `;
1086
+
1087
+ // src/components/ui/dialog/index.tsx
1088
+ const dialogTsx = `import * as DialogPrimitive from '@radix-ui/react-dialog';
1089
+ import { X } from 'lucide-react';
1090
+ import * as React from 'react';
1091
+
1092
+ import { cn } from '~/lib/utils';
1093
+
1094
+ const Dialog = DialogPrimitive.Root;
1095
+
1096
+ const DialogTrigger = DialogPrimitive.Trigger;
1097
+
1098
+ const DialogPortal = DialogPrimitive.Portal;
1099
+
1100
+ const DialogClose = DialogPrimitive.Close;
1101
+
1102
+ const DialogOverlay = React.forwardRef<
1103
+ React.ElementRef<typeof DialogPrimitive.Overlay>,
1104
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
1105
+ >(({ className, ...props }, ref) => (
1106
+ <DialogPrimitive.Overlay
1107
+ ref={ref}
1108
+ className={cn(
1109
+ 'fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
1110
+ className,
1111
+ )}
1112
+ {...props}
1113
+ />
1114
+ ));
1115
+ DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
1116
+
1117
+ const DialogContent = React.forwardRef<
1118
+ React.ElementRef<typeof DialogPrimitive.Content>,
1119
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
1120
+ >(({ className, children, ...props }, ref) => (
1121
+ <DialogPortal>
1122
+ <DialogOverlay />
1123
+ <DialogPrimitive.Content
1124
+ ref={ref}
1125
+ className={cn(
1126
+ 'fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg',
1127
+ className,
1128
+ )}
1129
+ {...props}
1130
+ >
1131
+ {children}
1132
+ <DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
1133
+ <X className="h-4 w-4" />
1134
+ <span className="sr-only">Close</span>
1135
+ </DialogPrimitive.Close>
1136
+ </DialogPrimitive.Content>
1137
+ </DialogPortal>
1138
+ ));
1139
+ DialogContent.displayName = DialogPrimitive.Content.displayName;
1140
+
1141
+ const DialogHeader = ({
1142
+ className,
1143
+ ...props
1144
+ }: React.HTMLAttributes<HTMLDivElement>) => (
1145
+ <div
1146
+ className={cn(
1147
+ 'flex flex-col space-y-1.5 text-center sm:text-left',
1148
+ className,
1149
+ )}
1150
+ {...props}
1151
+ />
1152
+ );
1153
+ DialogHeader.displayName = 'DialogHeader';
1154
+
1155
+ const DialogFooter = ({
1156
+ className,
1157
+ ...props
1158
+ }: React.HTMLAttributes<HTMLDivElement>) => (
1159
+ <div
1160
+ className={cn(
1161
+ 'flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2',
1162
+ className,
1163
+ )}
1164
+ {...props}
1165
+ />
1166
+ );
1167
+ DialogFooter.displayName = 'DialogFooter';
1168
+
1169
+ const DialogTitle = React.forwardRef<
1170
+ React.ElementRef<typeof DialogPrimitive.Title>,
1171
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
1172
+ >(({ className, ...props }, ref) => (
1173
+ <DialogPrimitive.Title
1174
+ ref={ref}
1175
+ className={cn(
1176
+ 'text-lg font-semibold leading-none tracking-tight',
1177
+ className,
1178
+ )}
1179
+ {...props}
1180
+ />
1181
+ ));
1182
+ DialogTitle.displayName = DialogPrimitive.Title.displayName;
1183
+
1184
+ const DialogDescription = React.forwardRef<
1185
+ React.ElementRef<typeof DialogPrimitive.Description>,
1186
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
1187
+ >(({ className, ...props }, ref) => (
1188
+ <DialogPrimitive.Description
1189
+ ref={ref}
1190
+ className={cn('text-sm text-muted-foreground', className)}
1191
+ {...props}
1192
+ />
1193
+ ));
1194
+ DialogDescription.displayName = DialogPrimitive.Description.displayName;
1195
+
1196
+ export {
1197
+ Dialog,
1198
+ DialogPortal,
1199
+ DialogOverlay,
1200
+ DialogTrigger,
1201
+ DialogClose,
1202
+ DialogContent,
1203
+ DialogHeader,
1204
+ DialogFooter,
1205
+ DialogTitle,
1206
+ DialogDescription,
1207
+ };
1208
+ `;
1209
+
1210
+ // src/components/ui/dialog/dialog.stories.tsx
1211
+ const dialogStories = `import type { Meta, StoryObj } from '@storybook/react';
1212
+ import {
1213
+ Dialog,
1214
+ DialogContent,
1215
+ DialogDescription,
1216
+ DialogFooter,
1217
+ DialogHeader,
1218
+ DialogTitle,
1219
+ DialogTrigger,
1220
+ } from '.';
1221
+ import { Button } from '../button';
1222
+ import { Input } from '../input';
1223
+ import { Label } from '../label';
1224
+
1225
+ const meta: Meta<typeof Dialog> = {
1226
+ title: 'Components/Dialog',
1227
+ component: Dialog,
1228
+ tags: ['autodocs'],
1229
+ };
1230
+
1231
+ export default meta;
1232
+ type Story = StoryObj<typeof Dialog>;
1233
+
1234
+ export const Default: Story = {
1235
+ render: () => (
1236
+ <Dialog>
1237
+ <DialogTrigger asChild>
1238
+ <Button variant="outline">Edit Profile</Button>
1239
+ </DialogTrigger>
1240
+ <DialogContent className="sm:max-w-[425px]">
1241
+ <DialogHeader>
1242
+ <DialogTitle>Edit profile</DialogTitle>
1243
+ <DialogDescription>
1244
+ Make changes to your profile here. Click save when you're done.
1245
+ </DialogDescription>
1246
+ </DialogHeader>
1247
+ <div className="grid gap-4 py-4">
1248
+ <div className="grid grid-cols-4 items-center gap-4">
1249
+ <Label htmlFor="name" className="text-right">
1250
+ Name
1251
+ </Label>
1252
+ <Input id="name" defaultValue="Pedro Duarte" className="col-span-3" />
1253
+ </div>
1254
+ <div className="grid grid-cols-4 items-center gap-4">
1255
+ <Label htmlFor="username" className="text-right">
1256
+ Username
1257
+ </Label>
1258
+ <Input id="username" defaultValue="@peduarte" className="col-span-3" />
1259
+ </div>
1260
+ </div>
1261
+ <DialogFooter>
1262
+ <Button type="submit">Save changes</Button>
1263
+ </DialogFooter>
1264
+ </DialogContent>
1265
+ </Dialog>
1266
+ ),
1267
+ };
1268
+
1269
+ export const Alert: Story = {
1270
+ render: () => (
1271
+ <Dialog>
1272
+ <DialogTrigger asChild>
1273
+ <Button variant="destructive">Delete Account</Button>
1274
+ </DialogTrigger>
1275
+ <DialogContent>
1276
+ <DialogHeader>
1277
+ <DialogTitle>Are you absolutely sure?</DialogTitle>
1278
+ <DialogDescription>
1279
+ This action cannot be undone. This will permanently delete your
1280
+ account and remove your data from our servers.
1281
+ </DialogDescription>
1282
+ </DialogHeader>
1283
+ <DialogFooter>
1284
+ <Button variant="outline">Cancel</Button>
1285
+ <Button variant="destructive">Delete</Button>
1286
+ </DialogFooter>
1287
+ </DialogContent>
1288
+ </Dialog>
1289
+ ),
1290
+ };
1291
+ `;
1292
+
1293
+ // src/components/ui/index.ts
1294
+ const componentsUiIndex = `export { Button, type ButtonProps, buttonVariants } from './button';
1295
+ export { Input } from './input';
1296
+ export {
1297
+ Card,
1298
+ CardHeader,
1299
+ CardFooter,
1300
+ CardTitle,
1301
+ CardDescription,
1302
+ CardContent,
1303
+ } from './card';
1304
+ export { Label } from './label';
1305
+ export { Badge, type BadgeProps, badgeVariants } from './badge';
1306
+ export { Separator } from './separator';
1307
+ export { Tabs, TabsList, TabsTrigger, TabsContent } from './tabs';
1308
+ export {
1309
+ Tooltip,
1310
+ TooltipTrigger,
1311
+ TooltipContent,
1312
+ TooltipProvider,
1313
+ } from './tooltip';
1314
+ export {
1315
+ Dialog,
1316
+ DialogPortal,
1317
+ DialogOverlay,
1318
+ DialogTrigger,
1319
+ DialogClose,
1320
+ DialogContent,
1321
+ DialogHeader,
1322
+ DialogFooter,
1323
+ DialogTitle,
1324
+ DialogDescription,
1325
+ } from './dialog';
1326
+ `;
1327
+
1328
+ // Rename component files to index.tsx (same content)
1329
+ const buttonIndexTsx = buttonTsx;
1330
+ const inputIndexTsx = inputTsx;
1331
+ const cardIndexTsx = cardTsx;
1332
+
1333
+ // src/components/index.ts
1334
+ const componentsIndex = `export * from './ui';
1335
+ `;
1336
+
1337
+ // src/index.ts
1338
+ const indexTs = `// @${options.name}/ui - Shared UI component library
1339
+
1340
+ // shadcn/ui components
1341
+ export * from './components';
1342
+
1343
+ // Utilities
1344
+ export { cn } from './lib/utils';
1345
+ `;
1346
+
1347
+ // .gitignore for UI package
1348
+ const gitignore = `node_modules/
1349
+ dist/
1350
+ storybook-static/
1351
+ *.log
1352
+ `;
1353
+
1354
+ return [
1355
+ {
1356
+ path: 'packages/ui/package.json',
1357
+ content: `${JSON.stringify(packageJson, null, 2)}\n`,
1358
+ },
1359
+ {
1360
+ path: 'packages/ui/tsconfig.json',
1361
+ content: `${JSON.stringify(tsConfig, null, 2)}\n`,
1362
+ },
1363
+ {
1364
+ path: 'packages/ui/components.json',
1365
+ content: `${JSON.stringify(componentsJson, null, 2)}\n`,
1366
+ },
1367
+ {
1368
+ path: 'packages/ui/.storybook/main.ts',
1369
+ content: storybookMain,
1370
+ },
1371
+ {
1372
+ path: 'packages/ui/.storybook/preview.ts',
1373
+ content: storybookPreview,
1374
+ },
1375
+ {
1376
+ path: 'packages/ui/src/styles/globals.css',
1377
+ content: globalsCss,
1378
+ },
1379
+ {
1380
+ path: 'packages/ui/src/lib/utils.ts',
1381
+ content: utilsTs,
1382
+ },
1383
+ {
1384
+ path: 'packages/ui/src/components/ui/button/index.tsx',
1385
+ content: buttonIndexTsx,
1386
+ },
1387
+ {
1388
+ path: 'packages/ui/src/components/ui/button/button.stories.tsx',
1389
+ content: buttonStories,
1390
+ },
1391
+ {
1392
+ path: 'packages/ui/src/components/ui/input/index.tsx',
1393
+ content: inputIndexTsx,
1394
+ },
1395
+ {
1396
+ path: 'packages/ui/src/components/ui/input/input.stories.tsx',
1397
+ content: inputStories,
1398
+ },
1399
+ {
1400
+ path: 'packages/ui/src/components/ui/card/index.tsx',
1401
+ content: cardIndexTsx,
1402
+ },
1403
+ {
1404
+ path: 'packages/ui/src/components/ui/card/card.stories.tsx',
1405
+ content: cardStories,
1406
+ },
1407
+ {
1408
+ path: 'packages/ui/src/components/ui/label/index.tsx',
1409
+ content: labelTsx,
1410
+ },
1411
+ {
1412
+ path: 'packages/ui/src/components/ui/label/label.stories.tsx',
1413
+ content: labelStories,
1414
+ },
1415
+ {
1416
+ path: 'packages/ui/src/components/ui/badge/index.tsx',
1417
+ content: badgeTsx,
1418
+ },
1419
+ {
1420
+ path: 'packages/ui/src/components/ui/badge/badge.stories.tsx',
1421
+ content: badgeStories,
1422
+ },
1423
+ {
1424
+ path: 'packages/ui/src/components/ui/separator/index.tsx',
1425
+ content: separatorTsx,
1426
+ },
1427
+ {
1428
+ path: 'packages/ui/src/components/ui/separator/separator.stories.tsx',
1429
+ content: separatorStories,
1430
+ },
1431
+ {
1432
+ path: 'packages/ui/src/components/ui/tabs/index.tsx',
1433
+ content: tabsTsx,
1434
+ },
1435
+ {
1436
+ path: 'packages/ui/src/components/ui/tabs/tabs.stories.tsx',
1437
+ content: tabsStories,
1438
+ },
1439
+ {
1440
+ path: 'packages/ui/src/components/ui/tooltip/index.tsx',
1441
+ content: tooltipTsx,
1442
+ },
1443
+ {
1444
+ path: 'packages/ui/src/components/ui/tooltip/tooltip.stories.tsx',
1445
+ content: tooltipStories,
1446
+ },
1447
+ {
1448
+ path: 'packages/ui/src/components/ui/dialog/index.tsx',
1449
+ content: dialogTsx,
1450
+ },
1451
+ {
1452
+ path: 'packages/ui/src/components/ui/dialog/dialog.stories.tsx',
1453
+ content: dialogStories,
1454
+ },
1455
+ {
1456
+ path: 'packages/ui/src/components/ui/index.ts',
1457
+ content: componentsUiIndex,
1458
+ },
1459
+ {
1460
+ path: 'packages/ui/src/components/index.ts',
1461
+ content: componentsIndex,
1462
+ },
1463
+ {
1464
+ path: 'packages/ui/src/index.ts',
1465
+ content: indexTs,
1466
+ },
1467
+ {
1468
+ path: 'packages/ui/.gitignore',
1469
+ content: gitignore,
1470
+ },
1471
+ ];
1472
+ }