create-auto-app 1.34.0 → 1.35.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 (157) hide show
  1. package/package.json +2 -2
  2. package/templates/typical/.context/components-db.json +4006 -0
  3. package/templates/typical/.gitignore +1 -1
  4. package/templates/typical/auto.config.ts +85 -80
  5. package/templates/typical/client/.gitignore +0 -4
  6. package/templates/typical/client/.storybook/main.ts +0 -66
  7. package/templates/typical/client/.storybook/manager-head.html +0 -154
  8. package/templates/typical/client/.storybook/manager.ts +0 -164
  9. package/templates/typical/client/.storybook/preview-head.html +0 -31
  10. package/templates/typical/client/.storybook/preview.tsx +0 -120
  11. package/templates/typical/client/codegen.ts +0 -17
  12. package/templates/typical/client/components.json +0 -29
  13. package/templates/typical/client/index.html +0 -12
  14. package/templates/typical/client/package.json +0 -69
  15. package/templates/typical/client/pnpm-lock.yaml +0 -7868
  16. package/templates/typical/client/public/blank.svg +0 -1
  17. package/templates/typical/client/public/mockServiceWorker.js +0 -336
  18. package/templates/typical/client/src/App.tsx +0 -29
  19. package/templates/typical/client/src/components/.gitkeep +0 -0
  20. package/templates/typical/client/src/components/ui/Accordion.stories.tsx +0 -49
  21. package/templates/typical/client/src/components/ui/Accordion.tsx +0 -55
  22. package/templates/typical/client/src/components/ui/Alert.stories.tsx +0 -29
  23. package/templates/typical/client/src/components/ui/Alert.tsx +0 -56
  24. package/templates/typical/client/src/components/ui/AlertDialog.stories.tsx +0 -67
  25. package/templates/typical/client/src/components/ui/AlertDialog.tsx +0 -178
  26. package/templates/typical/client/src/components/ui/AspectRatio.stories.tsx +0 -35
  27. package/templates/typical/client/src/components/ui/AspectRatio.tsx +0 -13
  28. package/templates/typical/client/src/components/ui/Avatar.stories.tsx +0 -45
  29. package/templates/typical/client/src/components/ui/Avatar.tsx +0 -98
  30. package/templates/typical/client/src/components/ui/Badge.stories.tsx +0 -41
  31. package/templates/typical/client/src/components/ui/Badge.tsx +0 -45
  32. package/templates/typical/client/src/components/ui/Breadcrumb.stories.tsx +0 -54
  33. package/templates/typical/client/src/components/ui/Breadcrumb.tsx +0 -104
  34. package/templates/typical/client/src/components/ui/Button.stories.tsx +0 -102
  35. package/templates/typical/client/src/components/ui/Button.tsx +0 -67
  36. package/templates/typical/client/src/components/ui/ButtonGroup.stories.tsx +0 -32
  37. package/templates/typical/client/src/components/ui/ButtonGroup.tsx +0 -81
  38. package/templates/typical/client/src/components/ui/Calendar.stories.tsx +0 -40
  39. package/templates/typical/client/src/components/ui/Calendar.tsx +0 -165
  40. package/templates/typical/client/src/components/ui/Card.stories.tsx +0 -44
  41. package/templates/typical/client/src/components/ui/Card.tsx +0 -66
  42. package/templates/typical/client/src/components/ui/Carousel.stories.tsx +0 -56
  43. package/templates/typical/client/src/components/ui/Carousel.tsx +0 -225
  44. package/templates/typical/client/src/components/ui/Chart.stories.tsx +0 -39
  45. package/templates/typical/client/src/components/ui/Chart.tsx +0 -305
  46. package/templates/typical/client/src/components/ui/Checkbox.stories.tsx +0 -35
  47. package/templates/typical/client/src/components/ui/Checkbox.tsx +0 -30
  48. package/templates/typical/client/src/components/ui/Collapsible.stories.tsx +0 -58
  49. package/templates/typical/client/src/components/ui/Collapsible.tsx +0 -18
  50. package/templates/typical/client/src/components/ui/Combobox.stories.tsx +0 -75
  51. package/templates/typical/client/src/components/ui/Combobox.tsx +0 -296
  52. package/templates/typical/client/src/components/ui/Command.stories.tsx +0 -71
  53. package/templates/typical/client/src/components/ui/Command.tsx +0 -157
  54. package/templates/typical/client/src/components/ui/ContextMenu.stories.tsx +0 -68
  55. package/templates/typical/client/src/components/ui/ContextMenu.tsx +0 -231
  56. package/templates/typical/client/src/components/ui/DesignSystem-Colors.mdx +0 -68
  57. package/templates/typical/client/src/components/ui/DesignSystem-Colors.stories.tsx +0 -117
  58. package/templates/typical/client/src/components/ui/DesignSystem-Layout.mdx +0 -64
  59. package/templates/typical/client/src/components/ui/DesignSystem-Layout.stories.tsx +0 -167
  60. package/templates/typical/client/src/components/ui/DesignSystem-Overview.stories.tsx +0 -748
  61. package/templates/typical/client/src/components/ui/DesignSystem-Typography.mdx +0 -31
  62. package/templates/typical/client/src/components/ui/DesignSystem-Typography.stories.tsx +0 -80
  63. package/templates/typical/client/src/components/ui/Dialog.stories.tsx +0 -74
  64. package/templates/typical/client/src/components/ui/Dialog.tsx +0 -154
  65. package/templates/typical/client/src/components/ui/Direction.stories.tsx +0 -38
  66. package/templates/typical/client/src/components/ui/Direction.tsx +0 -24
  67. package/templates/typical/client/src/components/ui/Drawer.stories.tsx +0 -70
  68. package/templates/typical/client/src/components/ui/Drawer.tsx +0 -124
  69. package/templates/typical/client/src/components/ui/DropdownMenu.stories.tsx +0 -74
  70. package/templates/typical/client/src/components/ui/DropdownMenu.tsx +0 -239
  71. package/templates/typical/client/src/components/ui/Empty.stories.tsx +0 -37
  72. package/templates/typical/client/src/components/ui/Empty.tsx +0 -98
  73. package/templates/typical/client/src/components/ui/Field.stories.tsx +0 -50
  74. package/templates/typical/client/src/components/ui/Field.tsx +0 -251
  75. package/templates/typical/client/src/components/ui/Form.stories.tsx +0 -45
  76. package/templates/typical/client/src/components/ui/Form.tsx +0 -148
  77. package/templates/typical/client/src/components/ui/HoverCard.stories.tsx +0 -49
  78. package/templates/typical/client/src/components/ui/HoverCard.tsx +0 -39
  79. package/templates/typical/client/src/components/ui/Input.stories.tsx +0 -42
  80. package/templates/typical/client/src/components/ui/Input.tsx +0 -22
  81. package/templates/typical/client/src/components/ui/InputGroup.stories.tsx +0 -53
  82. package/templates/typical/client/src/components/ui/InputGroup.tsx +0 -153
  83. package/templates/typical/client/src/components/ui/InputOTP.stories.tsx +0 -42
  84. package/templates/typical/client/src/components/ui/InputOTP.tsx +0 -72
  85. package/templates/typical/client/src/components/ui/Item.stories.tsx +0 -64
  86. package/templates/typical/client/src/components/ui/Item.tsx +0 -168
  87. package/templates/typical/client/src/components/ui/Kbd.stories.tsx +0 -59
  88. package/templates/typical/client/src/components/ui/Kbd.tsx +0 -22
  89. package/templates/typical/client/src/components/ui/Label.stories.tsx +0 -90
  90. package/templates/typical/client/src/components/ui/Label.tsx +0 -44
  91. package/templates/typical/client/src/components/ui/Menubar.stories.tsx +0 -78
  92. package/templates/typical/client/src/components/ui/Menubar.tsx +0 -251
  93. package/templates/typical/client/src/components/ui/NativeSelect.stories.tsx +0 -45
  94. package/templates/typical/client/src/components/ui/NativeSelect.tsx +0 -50
  95. package/templates/typical/client/src/components/ui/NavigationMenu.stories.tsx +0 -80
  96. package/templates/typical/client/src/components/ui/NavigationMenu.tsx +0 -152
  97. package/templates/typical/client/src/components/ui/Pagination.stories.tsx +0 -77
  98. package/templates/typical/client/src/components/ui/Pagination.tsx +0 -108
  99. package/templates/typical/client/src/components/ui/Popover.stories.tsx +0 -53
  100. package/templates/typical/client/src/components/ui/Popover.tsx +0 -57
  101. package/templates/typical/client/src/components/ui/Progress.stories.tsx +0 -32
  102. package/templates/typical/client/src/components/ui/Progress.tsx +0 -25
  103. package/templates/typical/client/src/components/ui/RadioGroup.stories.tsx +0 -50
  104. package/templates/typical/client/src/components/ui/RadioGroup.tsx +0 -36
  105. package/templates/typical/client/src/components/ui/Resizable.stories.tsx +0 -72
  106. package/templates/typical/client/src/components/ui/Resizable.tsx +0 -54
  107. package/templates/typical/client/src/components/ui/ScrollArea.stories.tsx +0 -45
  108. package/templates/typical/client/src/components/ui/ScrollArea.tsx +0 -51
  109. package/templates/typical/client/src/components/ui/Select.stories.tsx +0 -59
  110. package/templates/typical/client/src/components/ui/Select.tsx +0 -171
  111. package/templates/typical/client/src/components/ui/Separator.stories.tsx +0 -42
  112. package/templates/typical/client/src/components/ui/Separator.tsx +0 -27
  113. package/templates/typical/client/src/components/ui/Sheet.stories.tsx +0 -68
  114. package/templates/typical/client/src/components/ui/Sheet.tsx +0 -115
  115. package/templates/typical/client/src/components/ui/Sidebar.stories.tsx +0 -96
  116. package/templates/typical/client/src/components/ui/Sidebar.tsx +0 -695
  117. package/templates/typical/client/src/components/ui/Skeleton.stories.tsx +0 -40
  118. package/templates/typical/client/src/components/ui/Skeleton.tsx +0 -11
  119. package/templates/typical/client/src/components/ui/Slider.stories.tsx +0 -24
  120. package/templates/typical/client/src/components/ui/Slider.tsx +0 -55
  121. package/templates/typical/client/src/components/ui/Sonner.stories.tsx +0 -45
  122. package/templates/typical/client/src/components/ui/Sonner.tsx +0 -38
  123. package/templates/typical/client/src/components/ui/Spinner.stories.tsx +0 -26
  124. package/templates/typical/client/src/components/ui/Spinner.tsx +0 -13
  125. package/templates/typical/client/src/components/ui/Switch.stories.tsx +0 -39
  126. package/templates/typical/client/src/components/ui/Switch.tsx +0 -35
  127. package/templates/typical/client/src/components/ui/Table.stories.tsx +0 -67
  128. package/templates/typical/client/src/components/ui/Table.tsx +0 -86
  129. package/templates/typical/client/src/components/ui/Tabs.stories.tsx +0 -53
  130. package/templates/typical/client/src/components/ui/Tabs.tsx +0 -75
  131. package/templates/typical/client/src/components/ui/Textarea.stories.tsx +0 -27
  132. package/templates/typical/client/src/components/ui/Textarea.tsx +0 -22
  133. package/templates/typical/client/src/components/ui/Toast.stories.tsx +0 -116
  134. package/templates/typical/client/src/components/ui/Toast.tsx +0 -123
  135. package/templates/typical/client/src/components/ui/Toaster.tsx +0 -32
  136. package/templates/typical/client/src/components/ui/Toggle.stories.tsx +0 -44
  137. package/templates/typical/client/src/components/ui/Toggle.tsx +0 -42
  138. package/templates/typical/client/src/components/ui/ToggleGroup.stories.tsx +0 -61
  139. package/templates/typical/client/src/components/ui/ToggleGroup.tsx +0 -83
  140. package/templates/typical/client/src/components/ui/Tooltip.stories.tsx +0 -42
  141. package/templates/typical/client/src/components/ui/Tooltip.tsx +0 -48
  142. package/templates/typical/client/src/gql/execute.ts +0 -11
  143. package/templates/typical/client/src/gql/fragment-masking.ts +0 -83
  144. package/templates/typical/client/src/gql/gql.ts +0 -9
  145. package/templates/typical/client/src/gql/graphql.ts +0 -182
  146. package/templates/typical/client/src/gql/index.ts +0 -2
  147. package/templates/typical/client/src/graphql/mutations.ts +0 -0
  148. package/templates/typical/client/src/graphql/queries.ts +0 -0
  149. package/templates/typical/client/src/hooks/.gitkeep +0 -0
  150. package/templates/typical/client/src/hooks/use-mobile.ts +0 -19
  151. package/templates/typical/client/src/hooks/use-toast.ts +0 -186
  152. package/templates/typical/client/src/index.css +0 -121
  153. package/templates/typical/client/src/lib/utils.ts +0 -6
  154. package/templates/typical/client/src/main.tsx +0 -5
  155. package/templates/typical/client/tsconfig.app.json +0 -26
  156. package/templates/typical/client/tsconfig.json +0 -10
  157. package/templates/typical/client/vite.config.ts +0 -50
@@ -1,225 +0,0 @@
1
- 'use client';
2
-
3
- import * as React from 'react';
4
- import useEmblaCarousel, { type UseEmblaCarouselType } from 'embla-carousel-react';
5
- import { ArrowLeft, ArrowRight } from 'lucide-react';
6
-
7
- import { cn } from '@/lib/utils';
8
- import { Button } from '@/components/ui/Button';
9
-
10
- type CarouselApi = UseEmblaCarouselType[1];
11
- type UseCarouselParameters = Parameters<typeof useEmblaCarousel>;
12
- type CarouselOptions = UseCarouselParameters[0];
13
- type CarouselPlugin = UseCarouselParameters[1];
14
-
15
- type CarouselProps = {
16
- opts?: CarouselOptions;
17
- plugins?: CarouselPlugin;
18
- orientation?: 'horizontal' | 'vertical';
19
- setApi?: (api: CarouselApi) => void;
20
- };
21
-
22
- type CarouselContextProps = {
23
- carouselRef: ReturnType<typeof useEmblaCarousel>[0];
24
- api: ReturnType<typeof useEmblaCarousel>[1];
25
- scrollPrev: () => void;
26
- scrollNext: () => void;
27
- canScrollPrev: boolean;
28
- canScrollNext: boolean;
29
- } & CarouselProps;
30
-
31
- const CarouselContext = React.createContext<CarouselContextProps | null>(null);
32
-
33
- function useCarousel() {
34
- const context = React.useContext(CarouselContext);
35
-
36
- if (!context) {
37
- throw new Error('useCarousel must be used within a <Carousel />');
38
- }
39
-
40
- return context;
41
- }
42
-
43
- /**
44
- * A slideshow component for cycling through content panels with arrow-key navigation.
45
- * Built on Embla Carousel. Compose with CarouselContent, CarouselItem, CarouselPrevious, and CarouselNext.
46
- * Supports horizontal and vertical orientation, and accepts Embla plugins (e.g., autoplay).
47
- */
48
- function Carousel({
49
- orientation = 'horizontal',
50
- opts,
51
- setApi,
52
- plugins,
53
- className,
54
- children,
55
- ...props
56
- }: React.ComponentProps<'div'> & CarouselProps) {
57
- const [carouselRef, api] = useEmblaCarousel(
58
- {
59
- ...opts,
60
- axis: orientation === 'horizontal' ? 'x' : 'y',
61
- },
62
- plugins,
63
- );
64
- const [canScrollPrev, setCanScrollPrev] = React.useState(false);
65
- const [canScrollNext, setCanScrollNext] = React.useState(false);
66
-
67
- const onSelect = React.useCallback((api: CarouselApi) => {
68
- if (!api) return;
69
- setCanScrollPrev(api.canScrollPrev());
70
- setCanScrollNext(api.canScrollNext());
71
- }, []);
72
-
73
- const scrollPrev = React.useCallback(() => {
74
- api?.scrollPrev();
75
- }, [api]);
76
-
77
- const scrollNext = React.useCallback(() => {
78
- api?.scrollNext();
79
- }, [api]);
80
-
81
- const handleKeyDown = React.useCallback(
82
- (event: React.KeyboardEvent<HTMLDivElement>) => {
83
- if (event.key === 'ArrowLeft') {
84
- event.preventDefault();
85
- scrollPrev();
86
- } else if (event.key === 'ArrowRight') {
87
- event.preventDefault();
88
- scrollNext();
89
- }
90
- },
91
- [scrollPrev, scrollNext],
92
- );
93
-
94
- React.useEffect(() => {
95
- if (!api || !setApi) return;
96
- setApi(api);
97
- }, [api, setApi]);
98
-
99
- React.useEffect(() => {
100
- if (!api) return;
101
- onSelect(api);
102
- api.on('reInit', onSelect);
103
- api.on('select', onSelect);
104
-
105
- return () => {
106
- api?.off('select', onSelect);
107
- };
108
- }, [api, onSelect]);
109
-
110
- return (
111
- <CarouselContext.Provider
112
- value={{
113
- carouselRef,
114
- api: api,
115
- opts,
116
- orientation: orientation || (opts?.axis === 'y' ? 'vertical' : 'horizontal'),
117
- scrollPrev,
118
- scrollNext,
119
- canScrollPrev,
120
- canScrollNext,
121
- }}
122
- >
123
- <div
124
- onKeyDownCapture={handleKeyDown}
125
- className={cn('relative', className)}
126
- role="region"
127
- aria-roledescription="carousel"
128
- data-slot="carousel"
129
- {...props}
130
- >
131
- {children}
132
- </div>
133
- </CarouselContext.Provider>
134
- );
135
- }
136
-
137
- /** The scrollable container for carousel slides. Wraps CarouselItem children in a flex layout. */
138
- function CarouselContent({ className, ...props }: React.ComponentProps<'div'>) {
139
- const { carouselRef, orientation } = useCarousel();
140
-
141
- return (
142
- <div ref={carouselRef} className="overflow-hidden" data-slot="carousel-content">
143
- <div className={cn('flex', orientation === 'horizontal' ? '-ml-4' : '-mt-4 flex-col', className)} {...props} />
144
- </div>
145
- );
146
- }
147
-
148
- /** A single slide within the carousel. Takes full width by default; use `basis-*` classes to show multiple slides. */
149
- function CarouselItem({ className, ...props }: React.ComponentProps<'div'>) {
150
- const { orientation } = useCarousel();
151
-
152
- return (
153
- <div
154
- role="group"
155
- aria-roledescription="slide"
156
- data-slot="carousel-item"
157
- className={cn('min-w-0 shrink-0 grow-0 basis-full', orientation === 'horizontal' ? 'pl-4' : 'pt-4', className)}
158
- {...props}
159
- />
160
- );
161
- }
162
-
163
- /** Navigation button to scroll to the previous slide, automatically disabled at the beginning. */
164
- function CarouselPrevious({
165
- className,
166
- variant = 'outline',
167
- size = 'icon',
168
- ...props
169
- }: React.ComponentProps<typeof Button>) {
170
- const { orientation, scrollPrev, canScrollPrev } = useCarousel();
171
-
172
- return (
173
- <Button
174
- data-slot="carousel-previous"
175
- variant={variant}
176
- size={size}
177
- className={cn(
178
- 'absolute size-8 rounded-full',
179
- orientation === 'horizontal'
180
- ? 'top-1/2 -left-12 -translate-y-1/2'
181
- : '-top-12 left-1/2 -translate-x-1/2 rotate-90',
182
- className,
183
- )}
184
- disabled={!canScrollPrev}
185
- onClick={scrollPrev}
186
- {...props}
187
- >
188
- <ArrowLeft />
189
- <span className="sr-only">Previous slide</span>
190
- </Button>
191
- );
192
- }
193
-
194
- /** Navigation button to scroll to the next slide, automatically disabled at the end. */
195
- function CarouselNext({
196
- className,
197
- variant = 'outline',
198
- size = 'icon',
199
- ...props
200
- }: React.ComponentProps<typeof Button>) {
201
- const { orientation, scrollNext, canScrollNext } = useCarousel();
202
-
203
- return (
204
- <Button
205
- data-slot="carousel-next"
206
- variant={variant}
207
- size={size}
208
- className={cn(
209
- 'absolute size-8 rounded-full',
210
- orientation === 'horizontal'
211
- ? 'top-1/2 -right-12 -translate-y-1/2'
212
- : '-bottom-12 left-1/2 -translate-x-1/2 rotate-90',
213
- className,
214
- )}
215
- disabled={!canScrollNext}
216
- onClick={scrollNext}
217
- {...props}
218
- >
219
- <ArrowRight />
220
- <span className="sr-only">Next slide</span>
221
- </Button>
222
- );
223
- }
224
-
225
- export { type CarouselApi, Carousel, CarouselContent, CarouselItem, CarouselPrevious, CarouselNext };
@@ -1,39 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react-vite';
2
- import { Bar, BarChart, XAxis, YAxis } from 'recharts';
3
- import { type ChartConfig, ChartContainer, ChartTooltip, ChartTooltipContent } from '@/components/ui/Chart';
4
-
5
- const meta: Meta<typeof ChartContainer> = {
6
- title: 'UI Components/Chart',
7
- component: ChartContainer,
8
- };
9
- export default meta;
10
- type Story = StoryObj<typeof ChartContainer>;
11
-
12
- const chartData = [
13
- { month: 'Jan', desktop: 186, mobile: 80 },
14
- { month: 'Feb', desktop: 305, mobile: 200 },
15
- { month: 'Mar', desktop: 237, mobile: 120 },
16
- { month: 'Apr', desktop: 73, mobile: 190 },
17
- { month: 'May', desktop: 209, mobile: 130 },
18
- { month: 'Jun', desktop: 214, mobile: 140 },
19
- ];
20
-
21
- const chartConfig = {
22
- desktop: { label: 'Desktop', color: 'var(--chart-1)' },
23
- mobile: { label: 'Mobile', color: 'var(--chart-2)' },
24
- } satisfies ChartConfig;
25
-
26
- /** Shows a grouped bar chart with desktop and mobile data series, tooltips, and themed colors. */
27
- export const Default: Story = {
28
- render: () => (
29
- <ChartContainer config={chartConfig} className="min-h-[200px] w-full">
30
- <BarChart data={chartData}>
31
- <XAxis dataKey="month" />
32
- <YAxis />
33
- <ChartTooltip content={<ChartTooltipContent />} />
34
- <Bar dataKey="desktop" fill="var(--color-desktop)" radius={4} />
35
- <Bar dataKey="mobile" fill="var(--color-mobile)" radius={4} />
36
- </BarChart>
37
- </ChartContainer>
38
- ),
39
- };
@@ -1,305 +0,0 @@
1
- import * as React from 'react';
2
- import * as RechartsPrimitive from 'recharts';
3
-
4
- import { cn } from '@/lib/utils';
5
-
6
- // Format: { THEME_NAME: CSS_SELECTOR }
7
- const THEMES = { light: '', dark: '.dark' } as const;
8
-
9
- export type ChartConfig = {
10
- [k in string]: {
11
- label?: React.ReactNode;
12
- icon?: React.ComponentType;
13
- } & ({ color?: string; theme?: never } | { color?: never; theme: Record<keyof typeof THEMES, string> });
14
- };
15
-
16
- type ChartContextProps = {
17
- config: ChartConfig;
18
- };
19
-
20
- const ChartContext = React.createContext<ChartContextProps | null>(null);
21
-
22
- function useChart() {
23
- const context = React.useContext(ChartContext);
24
-
25
- if (!context) {
26
- throw new Error('useChart must be used within a <ChartContainer />');
27
- }
28
-
29
- return context;
30
- }
31
-
32
- /**
33
- * A themed wrapper for Recharts charts that provides responsive sizing, CSS custom property-based color theming, and a chart context for tooltips and legends.
34
- * Pass a `config` object mapping data keys to labels, colors, and optional icons.
35
- */
36
- function ChartContainer({
37
- id,
38
- className,
39
- children,
40
- config,
41
- ...props
42
- }: React.ComponentProps<'div'> & {
43
- config: ChartConfig;
44
- children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>['children'];
45
- }) {
46
- const uniqueId = React.useId();
47
- const chartId = `chart-${id || uniqueId.replace(/:/g, '')}`;
48
-
49
- return (
50
- <ChartContext.Provider value={{ config }}>
51
- <div
52
- data-slot="chart"
53
- data-chart={chartId}
54
- className={cn(
55
- "[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border flex aspect-video justify-center text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
56
- className,
57
- )}
58
- {...props}
59
- >
60
- <ChartStyle id={chartId} config={config} />
61
- <RechartsPrimitive.ResponsiveContainer>{children}</RechartsPrimitive.ResponsiveContainer>
62
- </div>
63
- </ChartContext.Provider>
64
- );
65
- }
66
-
67
- const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
68
- const colorConfig = Object.entries(config).filter(([, config]) => config.theme || config.color);
69
-
70
- if (!colorConfig.length) {
71
- return null;
72
- }
73
-
74
- return (
75
- <style
76
- dangerouslySetInnerHTML={{
77
- __html: Object.entries(THEMES)
78
- .map(
79
- ([theme, prefix]) => `
80
- ${prefix} [data-chart=${id}] {
81
- ${colorConfig
82
- .map(([key, itemConfig]) => {
83
- const color = itemConfig.theme?.[theme as keyof typeof itemConfig.theme] || itemConfig.color;
84
- return color ? ` --color-${key}: ${color};` : null;
85
- })
86
- .join('\n')}
87
- }
88
- `,
89
- )
90
- .join('\n'),
91
- }}
92
- />
93
- );
94
- };
95
-
96
- const ChartTooltip = RechartsPrimitive.Tooltip;
97
-
98
- /**
99
- * A styled tooltip content component for Recharts that reads labels and colors from ChartConfig.
100
- * Supports dot, line, and dashed indicator styles.
101
- */
102
- function ChartTooltipContent({
103
- active,
104
- payload,
105
- className,
106
- indicator = 'dot',
107
- hideLabel = false,
108
- hideIndicator = false,
109
- label,
110
- labelFormatter,
111
- labelClassName,
112
- formatter,
113
- color,
114
- nameKey,
115
- labelKey,
116
- }: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
117
- React.ComponentProps<'div'> & {
118
- hideLabel?: boolean;
119
- hideIndicator?: boolean;
120
- indicator?: 'line' | 'dot' | 'dashed';
121
- nameKey?: string;
122
- labelKey?: string;
123
- }) {
124
- const { config } = useChart();
125
-
126
- const tooltipLabel = React.useMemo(() => {
127
- if (hideLabel || !payload?.length) {
128
- return null;
129
- }
130
-
131
- const [item] = payload;
132
- const key = `${labelKey || item?.dataKey || item?.name || 'value'}`;
133
- const itemConfig = getPayloadConfigFromPayload(config, item, key);
134
- const value =
135
- !labelKey && typeof label === 'string' ? config[label as keyof typeof config]?.label || label : itemConfig?.label;
136
-
137
- if (labelFormatter) {
138
- return <div className={cn('font-medium', labelClassName)}>{labelFormatter(value, payload)}</div>;
139
- }
140
-
141
- if (!value) {
142
- return null;
143
- }
144
-
145
- return <div className={cn('font-medium', labelClassName)}>{value}</div>;
146
- }, [label, labelFormatter, payload, hideLabel, labelClassName, config, labelKey]);
147
-
148
- if (!active || !payload?.length) {
149
- return null;
150
- }
151
-
152
- const nestLabel = payload.length === 1 && indicator !== 'dot';
153
-
154
- return (
155
- <div
156
- className={cn(
157
- 'border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl',
158
- className,
159
- )}
160
- >
161
- {!nestLabel ? tooltipLabel : null}
162
- <div className="grid gap-1.5">
163
- {payload
164
- .filter((item) => item.type !== 'none')
165
- .map((item, index) => {
166
- const key = `${nameKey || item.name || item.dataKey || 'value'}`;
167
- const itemConfig = getPayloadConfigFromPayload(config, item, key);
168
- const indicatorColor = color || item.payload.fill || item.color;
169
-
170
- return (
171
- <div
172
- key={item.dataKey}
173
- className={cn(
174
- '[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5',
175
- indicator === 'dot' && 'items-center',
176
- )}
177
- >
178
- {formatter && item?.value !== undefined && item.name ? (
179
- formatter(item.value, item.name, item, index, item.payload)
180
- ) : (
181
- <>
182
- {itemConfig?.icon ? (
183
- <itemConfig.icon />
184
- ) : (
185
- !hideIndicator && (
186
- <div
187
- className={cn('shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)', {
188
- 'h-2.5 w-2.5': indicator === 'dot',
189
- 'w-1': indicator === 'line',
190
- 'w-0 border-[1.5px] border-dashed bg-transparent': indicator === 'dashed',
191
- 'my-0.5': nestLabel && indicator === 'dashed',
192
- })}
193
- style={
194
- {
195
- '--color-bg': indicatorColor,
196
- '--color-border': indicatorColor,
197
- } as React.CSSProperties
198
- }
199
- />
200
- )
201
- )}
202
- <div
203
- className={cn(
204
- 'flex flex-1 justify-between leading-none',
205
- nestLabel ? 'items-end' : 'items-center',
206
- )}
207
- >
208
- <div className="grid gap-1.5">
209
- {nestLabel ? tooltipLabel : null}
210
- <span className="text-muted-foreground">{itemConfig?.label || item.name}</span>
211
- </div>
212
- {item.value && (
213
- <span className="text-foreground font-mono font-medium tabular-nums">
214
- {item.value.toLocaleString()}
215
- </span>
216
- )}
217
- </div>
218
- </>
219
- )}
220
- </div>
221
- );
222
- })}
223
- </div>
224
- </div>
225
- );
226
- }
227
-
228
- const ChartLegend = RechartsPrimitive.Legend;
229
-
230
- /** A styled legend content component for Recharts that reads labels, colors, and icons from ChartConfig. */
231
- function ChartLegendContent({
232
- className,
233
- hideIcon = false,
234
- payload,
235
- verticalAlign = 'bottom',
236
- nameKey,
237
- }: React.ComponentProps<'div'> &
238
- Pick<RechartsPrimitive.LegendProps, 'payload' | 'verticalAlign'> & {
239
- hideIcon?: boolean;
240
- nameKey?: string;
241
- }) {
242
- const { config } = useChart();
243
-
244
- if (!payload?.length) {
245
- return null;
246
- }
247
-
248
- return (
249
- <div className={cn('flex items-center justify-center gap-4', verticalAlign === 'top' ? 'pb-3' : 'pt-3', className)}>
250
- {payload
251
- .filter((item) => item.type !== 'none')
252
- .map((item) => {
253
- const key = `${nameKey || item.dataKey || 'value'}`;
254
- const itemConfig = getPayloadConfigFromPayload(config, item, key);
255
-
256
- return (
257
- <div
258
- key={item.value}
259
- className={cn('[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3')}
260
- >
261
- {itemConfig?.icon && !hideIcon ? (
262
- <itemConfig.icon />
263
- ) : (
264
- <div
265
- className="h-2 w-2 shrink-0 rounded-[2px]"
266
- style={{
267
- backgroundColor: item.color,
268
- }}
269
- />
270
- )}
271
- {itemConfig?.label}
272
- </div>
273
- );
274
- })}
275
- </div>
276
- );
277
- }
278
-
279
- // Helper to extract item config from a payload.
280
- function getPayloadConfigFromPayload(config: ChartConfig, payload: unknown, key: string) {
281
- if (typeof payload !== 'object' || payload === null) {
282
- return undefined;
283
- }
284
-
285
- const payloadPayload =
286
- 'payload' in payload && typeof payload.payload === 'object' && payload.payload !== null
287
- ? payload.payload
288
- : undefined;
289
-
290
- let configLabelKey: string = key;
291
-
292
- if (key in payload && typeof payload[key as keyof typeof payload] === 'string') {
293
- configLabelKey = payload[key as keyof typeof payload] as string;
294
- } else if (
295
- payloadPayload &&
296
- key in payloadPayload &&
297
- typeof payloadPayload[key as keyof typeof payloadPayload] === 'string'
298
- ) {
299
- configLabelKey = payloadPayload[key as keyof typeof payloadPayload] as string;
300
- }
301
-
302
- return configLabelKey in config ? config[configLabelKey] : config[key as keyof typeof config];
303
- }
304
-
305
- export { ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent, ChartStyle };
@@ -1,35 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react-vite';
2
- import { Checkbox } from '@/components/ui/Checkbox';
3
- import { Label } from '@/components/ui/Label';
4
-
5
- const meta: Meta<typeof Checkbox> = {
6
- title: 'UI Components/Checkbox',
7
- component: Checkbox,
8
- };
9
- export default meta;
10
- type Story = StoryObj<typeof Checkbox>;
11
-
12
- /** Shows an unchecked checkbox in its default state. */
13
- export const Default: Story = {
14
- render: () => <Checkbox />,
15
- };
16
-
17
- /** Shows a checkbox that starts in the checked state. */
18
- export const Checked: Story = {
19
- render: () => <Checkbox defaultChecked />,
20
- };
21
-
22
- /** Shows a disabled checkbox that cannot be interacted with. */
23
- export const Disabled: Story = {
24
- render: () => <Checkbox disabled />,
25
- };
26
-
27
- /** Shows a checkbox paired with a Label component for accessible form usage. */
28
- export const WithLabel: Story = {
29
- render: () => (
30
- <div className="flex items-center space-x-2">
31
- <Checkbox id="terms" />
32
- <Label htmlFor="terms">Accept terms and conditions</Label>
33
- </div>
34
- ),
35
- };
@@ -1,30 +0,0 @@
1
- 'use client';
2
-
3
- import * as React from 'react';
4
- import { CheckIcon } from 'lucide-react';
5
- import { Checkbox as CheckboxPrimitive } from 'radix-ui';
6
-
7
- import { cn } from '@/lib/utils';
8
-
9
- /** A toggleable boolean input with check icon. Supports checked, unchecked, and indeterminate states. Pair with Label for forms. */
10
- function Checkbox({ className, ...props }: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
11
- return (
12
- <CheckboxPrimitive.Root
13
- data-slot="checkbox"
14
- className={cn(
15
- 'peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50',
16
- className,
17
- )}
18
- {...props}
19
- >
20
- <CheckboxPrimitive.Indicator
21
- data-slot="checkbox-indicator"
22
- className="grid place-content-center text-current transition-none"
23
- >
24
- <CheckIcon className="size-3.5" />
25
- </CheckboxPrimitive.Indicator>
26
- </CheckboxPrimitive.Root>
27
- );
28
- }
29
-
30
- export { Checkbox };
@@ -1,58 +0,0 @@
1
- import { useState } from 'react';
2
- import type { Meta, StoryObj } from '@storybook/react-vite';
3
- import { Collapsible, CollapsibleTrigger, CollapsibleContent } from '@/components/ui/Collapsible';
4
- import { Button } from '@/components/ui/Button';
5
-
6
- const meta: Meta<typeof Collapsible> = {
7
- title: 'UI Components/Collapsible',
8
- component: Collapsible,
9
- };
10
- export default meta;
11
- type Story = StoryObj<typeof Collapsible>;
12
-
13
- function CollapsibleDemo() {
14
- const [isOpen, setIsOpen] = useState(false);
15
- return (
16
- <Collapsible open={isOpen} onOpenChange={setIsOpen} className="w-[350px] space-y-2">
17
- <div className="flex items-center justify-between space-x-4 px-4">
18
- <h4 className="text-sm font-semibold">3 items tagged</h4>
19
- <CollapsibleTrigger asChild>
20
- <Button variant="ghost" size="sm">
21
- {isOpen ? 'Hide' : 'Show'}
22
- </Button>
23
- </CollapsibleTrigger>
24
- </div>
25
- <div className="rounded-md border px-4 py-2 font-mono text-sm shadow-sm">@radix-ui/primitives</div>
26
- <CollapsibleContent className="space-y-2">
27
- <div className="rounded-md border px-4 py-2 font-mono text-sm shadow-sm">@radix-ui/colors</div>
28
- <div className="rounded-md border px-4 py-2 font-mono text-sm shadow-sm">@stitches/react</div>
29
- </CollapsibleContent>
30
- </Collapsible>
31
- );
32
- }
33
-
34
- /** Shows a controlled collapsible section that starts closed and can be toggled with a button. */
35
- export const Default: Story = {
36
- render: () => <CollapsibleDemo />,
37
- };
38
-
39
- /** Shows a collapsible section that starts in the open state using `defaultOpen`. */
40
- export const DefaultOpen: Story = {
41
- render: () => (
42
- <Collapsible defaultOpen className="w-[350px] space-y-2">
43
- <div className="flex items-center justify-between space-x-4 px-4">
44
- <h4 className="text-sm font-semibold">Additional details</h4>
45
- <CollapsibleTrigger asChild>
46
- <Button variant="ghost" size="sm">
47
- Toggle
48
- </Button>
49
- </CollapsibleTrigger>
50
- </div>
51
- <CollapsibleContent className="space-y-2">
52
- <div className="rounded-md border px-4 py-2 text-sm shadow-sm">
53
- This section is open by default and can be collapsed.
54
- </div>
55
- </CollapsibleContent>
56
- </Collapsible>
57
- ),
58
- };