sunpeak 0.2.5 → 0.3.2

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 (78) hide show
  1. package/README.md +32 -17
  2. package/dist/chatgpt/chatgpt-simulator-types.d.ts +8 -0
  3. package/dist/chatgpt/chatgpt-simulator.d.ts +11 -0
  4. package/dist/chatgpt/conversation.d.ts +11 -0
  5. package/dist/chatgpt/index.d.ts +3 -0
  6. package/dist/chatgpt/mcp-provider.d.ts +25 -0
  7. package/dist/chatgpt/mock-openai.d.ts +61 -0
  8. package/dist/chatgpt/openai-provider.d.ts +19 -0
  9. package/dist/chatgpt/openai-types.d.ts +81 -0
  10. package/dist/chatgpt/simple-sidebar.d.ts +22 -0
  11. package/dist/chatgpt/theme-provider.d.ts +13 -0
  12. package/dist/hooks/index.d.ts +14 -0
  13. package/dist/hooks/use-display-mode.d.ts +2 -0
  14. package/dist/hooks/use-locale.d.ts +1 -0
  15. package/dist/hooks/use-max-height.d.ts +1 -0
  16. package/dist/hooks/use-mobile.d.ts +1 -0
  17. package/dist/hooks/use-safe-area.d.ts +2 -0
  18. package/dist/hooks/use-theme.d.ts +2 -0
  19. package/dist/hooks/use-tool-input.d.ts +2 -0
  20. package/dist/hooks/use-tool-response-metadata.d.ts +2 -0
  21. package/dist/hooks/use-user-agent.d.ts +2 -0
  22. package/dist/hooks/use-view.d.ts +2 -0
  23. package/dist/hooks/use-widget-api.d.ts +8 -0
  24. package/dist/hooks/use-widget-global.d.ts +9 -0
  25. package/dist/hooks/use-widget-props.d.ts +1 -0
  26. package/dist/hooks/use-widget-state.d.ts +4 -0
  27. package/dist/index.cjs +3310 -666
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.ts +5 -366
  30. package/dist/index.js +3325 -640
  31. package/dist/index.js.map +1 -1
  32. package/dist/lib/index.d.ts +2 -0
  33. package/dist/lib/media-queries.d.ts +3 -0
  34. package/dist/lib/utils.d.ts +2 -0
  35. package/dist/mcp/index.cjs +799 -64
  36. package/dist/mcp/index.cjs.map +1 -1
  37. package/dist/mcp/index.d.ts +1 -12
  38. package/dist/mcp/index.js +786 -44
  39. package/dist/mcp/index.js.map +1 -1
  40. package/dist/mcp/server.d.ts +10 -0
  41. package/dist/mcp/types.d.ts +74 -0
  42. package/dist/providers/index.d.ts +40 -0
  43. package/dist/providers/types.d.ts +71 -0
  44. package/dist/style.css +5014 -0
  45. package/dist/test/setup.d.ts +0 -0
  46. package/dist/types/index.d.ts +2 -0
  47. package/package.json +11 -19
  48. package/template/README.md +3 -6
  49. package/template/dev/main.tsx +0 -1
  50. package/template/mcp/server.ts +1 -1
  51. package/template/package.json +4 -14
  52. package/template/src/App.tsx +7 -8
  53. package/template/src/components/index.ts +2 -2
  54. package/template/src/components/openai-card.test.tsx +73 -0
  55. package/template/src/components/openai-card.tsx +126 -0
  56. package/template/src/components/openai-carousel.test.tsx +84 -0
  57. package/template/src/components/openai-carousel.tsx +178 -0
  58. package/template/src/styles/globals.css +5 -216
  59. package/template/vite.config.build.ts +61 -0
  60. package/dist/index.d.cts +0 -366
  61. package/dist/mcp/index.d.cts +0 -12
  62. package/dist/styles/chatgpt/index.css +0 -146
  63. package/dist/styles/globals.css +0 -219
  64. package/template/components.json +0 -21
  65. package/template/dev/styles.css +0 -6
  66. package/template/postcss.config.js +0 -5
  67. package/template/src/components/shadcn/button.tsx +0 -60
  68. package/template/src/components/shadcn/card.tsx +0 -76
  69. package/template/src/components/shadcn/carousel.tsx +0 -260
  70. package/template/src/components/shadcn/index.ts +0 -5
  71. package/template/src/components/shadcn/label.tsx +0 -24
  72. package/template/src/components/shadcn/select.tsx +0 -157
  73. package/template/src/components/sunpeak-card.test.tsx +0 -76
  74. package/template/src/components/sunpeak-card.tsx +0 -171
  75. package/template/src/components/sunpeak-carousel.test.tsx +0 -42
  76. package/template/src/components/sunpeak-carousel.tsx +0 -160
  77. package/template/src/styles/chatgpt.css +0 -146
  78. package/template/tsup.config.ts +0 -50
@@ -1,219 +0,0 @@
1
- @import "tailwindcss";
2
-
3
- @custom-variant dark (&:is(.dark *));
4
-
5
- /* Tailwind v4 theme configuration */
6
- @theme {
7
- /* ===================================
8
- * COLORS - Mapped to shadcn and --sp- variables
9
- * ===================================
10
- */
11
- --color-*: initial;
12
-
13
- /* Shadcn colors */
14
- --color-background: var(--background);
15
- --color-foreground: var(--foreground);
16
- --color-border: var(--border);
17
- --color-card: var(--card);
18
- --color-card-foreground: var(--card-foreground);
19
- --color-popover: var(--popover);
20
- --color-popover-foreground: var(--popover-foreground);
21
- --color-primary: var(--primary);
22
- --color-primary-foreground: var(--primary-foreground);
23
- --color-secondary: var(--secondary);
24
- --color-secondary-foreground: var(--secondary-foreground);
25
- --color-muted: var(--muted);
26
- --color-muted-foreground: var(--muted-foreground);
27
- --color-accent: var(--accent);
28
- --color-accent-foreground: var(--accent-foreground);
29
- --color-destructive: var(--destructive);
30
- --color-destructive-foreground: var(--destructive-foreground);
31
- --color-input: var(--input);
32
- --color-ring: var(--ring);
33
-
34
- /* Sunpeak semantic colors */
35
- --color-success: var(--sp-success);
36
- --color-warning: var(--sp-warning);
37
- --color-error: var(--sp-error);
38
- --color-info: var(--sp-info);
39
-
40
- /* ===================================
41
- * TYPOGRAPHY - Mapped to --sp- variables
42
- * ===================================
43
- */
44
-
45
- /* Font families */
46
- --font-sans: var(--sp-font-family);
47
-
48
- /* Font sizes */
49
- --text-xs: var(--sp-font-size-xs);
50
- --text-sm: var(--sp-font-size-sm);
51
- --text-base: var(--sp-font-size-base);
52
- --text-lg: var(--sp-font-size-lg);
53
- --text-xl: var(--sp-font-size-xl);
54
-
55
- /* Font weights */
56
- --font-weight-normal: var(--sp-font-weight-normal);
57
- --font-weight-medium: var(--sp-font-weight-medium);
58
- --font-weight-semibold: var(--sp-font-weight-semibold);
59
- --font-weight-bold: var(--sp-font-weight-bold);
60
-
61
- /* Line heights */
62
- --leading-tight: var(--sp-line-height-tight);
63
- --leading-normal: var(--sp-line-height-normal);
64
- --leading-relaxed: var(--sp-line-height-relaxed);
65
-
66
- /* ===================================
67
- * SPACING - Mapped to --sp- variables
68
- * ===================================
69
- */
70
- --spacing-1: var(--sp-spacing-1);
71
- --spacing-2: var(--sp-spacing-2);
72
- --spacing-3: var(--sp-spacing-3);
73
- --spacing-4: var(--sp-spacing-4);
74
- --spacing-5: var(--sp-spacing-5);
75
- --spacing-6: var(--sp-spacing-6);
76
- --spacing-8: var(--sp-spacing-8);
77
-
78
- /* ===================================
79
- * BORDER RADIUS - Mapped to --sp- variables
80
- * ===================================
81
- */
82
- --radius-sm: var(--sp-radius-sm);
83
- --radius-md: var(--sp-radius-md);
84
- --radius-lg: var(--sp-radius-lg);
85
- --radius-xl: var(--sp-radius-xl);
86
- --radius-2xl: var(--sp-radius-2xl);
87
- --radius-full: var(--sp-radius-full);
88
-
89
- /* ===================================
90
- * SHADOWS - Mapped to --sp- variables
91
- * ===================================
92
- */
93
- --shadow-sm: var(--sp-shadow-sm);
94
- --shadow-md: var(--sp-shadow-md);
95
- --shadow-lg: var(--sp-shadow-lg);
96
- --shadow-xl: var(--sp-shadow-xl);
97
- }
98
-
99
- /* ===================================
100
- * THEME MODE CLASSES
101
- * ===================================
102
- * Force light/dark mode on specific elements
103
- */
104
-
105
- .light {
106
- --sp-color-bg-primary: var(--sp-light-color-bg-primary);
107
- --sp-color-bg-secondary: var(--sp-light-color-bg-secondary);
108
- --sp-color-bg-tertiary: var(--sp-light-color-bg-tertiary);
109
- --sp-color-text-primary: var(--sp-light-color-text-primary);
110
- --sp-color-text-secondary: var(--sp-light-color-text-secondary);
111
- --sp-color-text-tertiary: var(--sp-light-color-text-tertiary);
112
- --sp-color-text-inverted: var(--sp-light-color-text-inverted);
113
- --sp-color-border: var(--sp-light-color-border);
114
- --sp-success: var(--sp-light-success);
115
- --sp-warning: var(--sp-light-warning);
116
- --sp-error: var(--sp-light-error);
117
- --sp-info: var(--sp-light-info);
118
- --sp-accent: var(--sp-light-accent);
119
- --sp-accent-hover: var(--sp-light-accent-hover);
120
- --sp-accent-active: var(--sp-light-accent-active);
121
- --sp-accent-foreground: var(--sp-light-accent-foreground);
122
-
123
- /* shadcn/ui light mode variables */
124
- --background: var(--sp-light-color-bg-primary);
125
- --foreground: var(--sp-light-color-text-primary);
126
- --card: var(--sp-light-color-bg-primary);
127
- --card-foreground: var(--sp-light-color-text-primary);
128
- --popover: var(--sp-light-color-bg-primary);
129
- --popover-foreground: var(--sp-light-color-text-primary);
130
- --primary: var(--sp-light-accent);
131
- --primary-foreground: var(--sp-accent-foreground);
132
- --secondary: var(--sp-light-color-bg-secondary);
133
- --secondary-foreground: var(--sp-light-color-text-primary);
134
- --muted: var(--sp-light-color-bg-tertiary);
135
- --muted-foreground: var(--sp-light-color-text-tertiary);
136
- --accent: var(--sp-light-accent);
137
- --accent-foreground: var(--sp-accent-foreground);
138
- --destructive: var(--sp-light-error);
139
- --destructive-foreground: var(--sp-accent-foreground);
140
- --border: var(--sp-light-color-border);
141
- --input: var(--sp-light-color-bg-secondary);
142
- --ring: var(--sp-light-accent);
143
- --sidebar: var(--sp-light-sidebar);
144
- --sidebar-foreground: var(--sp-light-color-text-primary);
145
- --sidebar-primary: var(--sp-light-accent);
146
- --sidebar-primary-foreground: var(--sp-light-color-text-primary);
147
- --sidebar-accent: var(--sp-light-accent);
148
- --sidebar-accent-foreground: var(--sp-light-color-text-primary);
149
- --sidebar-border: var(--sp-light-color-border);
150
- --sidebar-ring: var(--sp-light-accent);
151
- }
152
-
153
- .dark {
154
- --sp-color-bg-primary: var(--sp-dark-color-bg-primary);
155
- --sp-color-bg-secondary: var(--sp-dark-color-bg-secondary);
156
- --sp-color-bg-tertiary: var(--sp-dark-color-bg-tertiary);
157
- --sp-color-text-primary: var(--sp-dark-color-text-primary);
158
- --sp-color-text-secondary: var(--sp-dark-color-text-secondary);
159
- --sp-color-text-tertiary: var(--sp-dark-color-text-tertiary);
160
- --sp-color-text-inverted: var(--sp-dark-color-text-inverted);
161
- --sp-color-border: var(--sp-dark-color-border);
162
- --sp-success: var(--sp-dark-success);
163
- --sp-warning: var(--sp-dark-warning);
164
- --sp-error: var(--sp-dark-error);
165
- --sp-info: var(--sp-dark-info);
166
- --sp-accent: var(--sp-dark-accent);
167
- --sp-accent-hover: var(--sp-dark-accent-hover);
168
- --sp-accent-active: var(--sp-dark-accent-active);
169
- --sp-accent-foreground: var(--sp-dark-accent-foreground);
170
-
171
- /* shadcn/ui dark mode variables */
172
- --background: var(--sp-dark-color-bg-primary);
173
- --foreground: var(--sp-dark-color-text-primary);
174
- --card: var(--sp-dark-color-bg-primary);
175
- --card-foreground: var(--sp-dark-color-text-primary);
176
- --popover: var(--sp-dark-color-bg-primary);
177
- --popover-foreground: var(--sp-dark-color-text-primary);
178
- --primary: var(--sp-dark-accent);
179
- --primary-foreground: var(--sp-accent-foreground);
180
- --secondary: var(--sp-dark-color-bg-secondary);
181
- --secondary-foreground: var(--sp-dark-color-text-primary);
182
- --muted: var(--sp-dark-color-bg-tertiary);
183
- --muted-foreground: var(--sp-dark-color-text-tertiary);
184
- --accent: var(--sp-dark-accent);
185
- --accent-foreground: var(--sp-accent-foreground);
186
- --destructive: var(--sp-dark-error);
187
- --destructive-foreground: var(--sp-accent-foreground);
188
- --border: var(--sp-dark-color-border);
189
- --input: var(--sp-dark-color-bg-secondary);
190
- --ring: var(--sp-dark-accent);
191
- --sidebar: var(--sp-dark-sidebar);
192
- --sidebar-foreground: var(--sp-dark-color-text-primary);
193
- --sidebar-primary: var(--sp-dark-accent);
194
- --sidebar-primary-foreground: var(--sp-dark-color-text-primary);
195
- --sidebar-accent: var(--sp-dark-accent);
196
- --sidebar-accent-foreground: var(--sp-dark-color-text-primary);
197
- --sidebar-border: var(--sp-dark-color-border);
198
- --sidebar-ring: var(--sp-dark-accent);
199
- }
200
-
201
- @theme inline {
202
- --color-sidebar: var(--sidebar);
203
- --color-sidebar-foreground: var(--sidebar-foreground);
204
- --color-sidebar-primary: var(--sidebar-primary);
205
- --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
206
- --color-sidebar-accent: var(--sidebar-accent);
207
- --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
208
- --color-sidebar-border: var(--sidebar-border);
209
- --color-sidebar-ring: var(--sidebar-ring);
210
- }
211
-
212
- @layer base {
213
- * {
214
- @apply border-border outline-ring/50;
215
- }
216
- body {
217
- @apply bg-background text-foreground;
218
- }
219
- }
@@ -1,21 +0,0 @@
1
- {
2
- "$schema": "https://ui.shadcn.com/schema.json",
3
- "style": "new-york",
4
- "rsc": false,
5
- "tsx": true,
6
- "tailwind": {
7
- "config": "",
8
- "css": "src/styles/globals.css",
9
- "baseColor": "neutral",
10
- "cssVariables": true,
11
- "prefix": ""
12
- },
13
- "aliases": {
14
- "components": "@/components",
15
- "utils": "@/lib",
16
- "ui": "@/components/shadcn",
17
- "lib": "@/lib",
18
- "hooks": "@/hooks"
19
- },
20
- "iconLibrary": "lucide"
21
- }
@@ -1,6 +0,0 @@
1
- /* Dev styles - imports globals.css */
2
- @import "@/styles/globals.css";
3
-
4
- /* Scan sunpeak source for Tailwind classes (only works in workspace, ignored otherwise) */
5
- @source "../../src/**/*.{ts,tsx}";
6
- @source "../node_modules/sunpeak/**/*.{ts,tsx}"
@@ -1,5 +0,0 @@
1
- export default {
2
- plugins: {
3
- '@tailwindcss/postcss': {},
4
- },
5
- };
@@ -1,60 +0,0 @@
1
- import * as React from "react"
2
- import { Slot } from "@radix-ui/react-slot"
3
- import { cva, type VariantProps } from "class-variance-authority"
4
-
5
- import { cn } from "@/lib/index"
6
-
7
- const buttonVariants = cva(
8
- "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
9
- {
10
- variants: {
11
- variant: {
12
- default: "bg-primary text-primary-foreground hover:bg-primary/90",
13
- destructive:
14
- "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
15
- outline:
16
- "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
17
- secondary:
18
- "bg-secondary text-secondary-foreground hover:bg-secondary/80",
19
- ghost:
20
- "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
21
- link: "text-primary underline-offset-4 hover:underline",
22
- },
23
- size: {
24
- default: "h-9 px-4 py-2 has-[>svg]:px-3",
25
- sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
26
- lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
27
- icon: "size-9",
28
- "icon-sm": "size-8",
29
- "icon-lg": "size-10",
30
- },
31
- },
32
- defaultVariants: {
33
- variant: "default",
34
- size: "default",
35
- },
36
- }
37
- )
38
-
39
- function Button({
40
- className,
41
- variant,
42
- size,
43
- asChild = false,
44
- ...props
45
- }: React.ComponentProps<"button"> &
46
- VariantProps<typeof buttonVariants> & {
47
- asChild?: boolean
48
- }) {
49
- const Comp = asChild ? Slot : "button"
50
-
51
- return (
52
- <Comp
53
- data-slot="button"
54
- className={cn(buttonVariants({ variant, size, className }))}
55
- {...props}
56
- />
57
- )
58
- }
59
-
60
- export { Button, buttonVariants }
@@ -1,76 +0,0 @@
1
- import * as React from "react"
2
-
3
- import { cn } from "@/lib/index"
4
-
5
- const Card = React.forwardRef<
6
- HTMLDivElement,
7
- React.HTMLAttributes<HTMLDivElement>
8
- >(({ className, ...props }, ref) => (
9
- <div
10
- ref={ref}
11
- className={cn(
12
- "rounded-xl border bg-card text-card-foreground shadow",
13
- className
14
- )}
15
- {...props}
16
- />
17
- ))
18
- Card.displayName = "Card"
19
-
20
- const CardHeader = React.forwardRef<
21
- HTMLDivElement,
22
- React.HTMLAttributes<HTMLDivElement>
23
- >(({ className, ...props }, ref) => (
24
- <div
25
- ref={ref}
26
- className={cn("flex flex-col space-y-1.5 p-6", className)}
27
- {...props}
28
- />
29
- ))
30
- CardHeader.displayName = "CardHeader"
31
-
32
- const CardTitle = React.forwardRef<
33
- HTMLDivElement,
34
- React.HTMLAttributes<HTMLDivElement>
35
- >(({ className, ...props }, ref) => (
36
- <div
37
- ref={ref}
38
- className={cn("font-semibold leading-none tracking-tight", className)}
39
- {...props}
40
- />
41
- ))
42
- CardTitle.displayName = "CardTitle"
43
-
44
- const CardDescription = React.forwardRef<
45
- HTMLDivElement,
46
- React.HTMLAttributes<HTMLDivElement>
47
- >(({ className, ...props }, ref) => (
48
- <div
49
- ref={ref}
50
- className={cn("text-sm text-muted-foreground", className)}
51
- {...props}
52
- />
53
- ))
54
- CardDescription.displayName = "CardDescription"
55
-
56
- const CardContent = React.forwardRef<
57
- HTMLDivElement,
58
- React.HTMLAttributes<HTMLDivElement>
59
- >(({ className, ...props }, ref) => (
60
- <div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
61
- ))
62
- CardContent.displayName = "CardContent"
63
-
64
- const CardFooter = React.forwardRef<
65
- HTMLDivElement,
66
- React.HTMLAttributes<HTMLDivElement>
67
- >(({ className, ...props }, ref) => (
68
- <div
69
- ref={ref}
70
- className={cn("flex items-center p-6 pt-0", className)}
71
- {...props}
72
- />
73
- ))
74
- CardFooter.displayName = "CardFooter"
75
-
76
- export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }
@@ -1,260 +0,0 @@
1
- import * as React from "react"
2
- import useEmblaCarousel, {
3
- type UseEmblaCarouselType,
4
- } from "embla-carousel-react"
5
- import { ArrowLeft, ArrowRight } from "lucide-react"
6
-
7
- import { cn } from "@/lib/index"
8
- import { Button } from "@/components/shadcn/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
- const Carousel = React.forwardRef<
44
- HTMLDivElement,
45
- React.HTMLAttributes<HTMLDivElement> & CarouselProps
46
- >(
47
- (
48
- {
49
- orientation = "horizontal",
50
- opts,
51
- setApi,
52
- plugins,
53
- className,
54
- children,
55
- ...props
56
- },
57
- ref
58
- ) => {
59
- const [carouselRef, api] = useEmblaCarousel(
60
- {
61
- ...opts,
62
- axis: orientation === "horizontal" ? "x" : "y",
63
- },
64
- plugins
65
- )
66
- const [canScrollPrev, setCanScrollPrev] = React.useState(false)
67
- const [canScrollNext, setCanScrollNext] = React.useState(false)
68
-
69
- const onSelect = React.useCallback((api: CarouselApi) => {
70
- if (!api) {
71
- return
72
- }
73
-
74
- setCanScrollPrev(api.canScrollPrev())
75
- setCanScrollNext(api.canScrollNext())
76
- }, [])
77
-
78
- const scrollPrev = React.useCallback(() => {
79
- api?.scrollPrev()
80
- }, [api])
81
-
82
- const scrollNext = React.useCallback(() => {
83
- api?.scrollNext()
84
- }, [api])
85
-
86
- const handleKeyDown = React.useCallback(
87
- (event: React.KeyboardEvent<HTMLDivElement>) => {
88
- if (event.key === "ArrowLeft") {
89
- event.preventDefault()
90
- scrollPrev()
91
- } else if (event.key === "ArrowRight") {
92
- event.preventDefault()
93
- scrollNext()
94
- }
95
- },
96
- [scrollPrev, scrollNext]
97
- )
98
-
99
- React.useEffect(() => {
100
- if (!api || !setApi) {
101
- return
102
- }
103
-
104
- setApi(api)
105
- }, [api, setApi])
106
-
107
- React.useEffect(() => {
108
- if (!api) {
109
- return
110
- }
111
-
112
- onSelect(api)
113
- api.on("reInit", onSelect)
114
- api.on("select", onSelect)
115
-
116
- return () => {
117
- api?.off("select", onSelect)
118
- }
119
- }, [api, onSelect])
120
-
121
- return (
122
- <CarouselContext.Provider
123
- value={{
124
- carouselRef,
125
- api: api,
126
- opts,
127
- orientation:
128
- orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
129
- scrollPrev,
130
- scrollNext,
131
- canScrollPrev,
132
- canScrollNext,
133
- }}
134
- >
135
- <div
136
- ref={ref}
137
- onKeyDownCapture={handleKeyDown}
138
- className={cn("relative", className)}
139
- role="region"
140
- aria-roledescription="carousel"
141
- {...props}
142
- >
143
- {children}
144
- </div>
145
- </CarouselContext.Provider>
146
- )
147
- }
148
- )
149
- Carousel.displayName = "Carousel"
150
-
151
- const CarouselContent = React.forwardRef<
152
- HTMLDivElement,
153
- React.HTMLAttributes<HTMLDivElement>
154
- >(({ className, ...props }, ref) => {
155
- const { carouselRef, orientation } = useCarousel()
156
-
157
- return (
158
- <div ref={carouselRef} className="overflow-hidden">
159
- <div
160
- ref={ref}
161
- className={cn(
162
- "flex",
163
- orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col",
164
- className
165
- )}
166
- {...props}
167
- />
168
- </div>
169
- )
170
- })
171
- CarouselContent.displayName = "CarouselContent"
172
-
173
- const CarouselItem = React.forwardRef<
174
- HTMLDivElement,
175
- React.HTMLAttributes<HTMLDivElement>
176
- >(({ className, ...props }, ref) => {
177
- const { orientation } = useCarousel()
178
-
179
- return (
180
- <div
181
- ref={ref}
182
- role="group"
183
- aria-roledescription="slide"
184
- className={cn(
185
- "min-w-0 shrink-0 grow-0 basis-full",
186
- orientation === "horizontal" ? "pl-4" : "pt-4",
187
- className
188
- )}
189
- {...props}
190
- />
191
- )
192
- })
193
- CarouselItem.displayName = "CarouselItem"
194
-
195
- const CarouselPrevious = React.forwardRef<
196
- HTMLButtonElement,
197
- React.ComponentProps<typeof Button>
198
- >(({ className, variant = "outline", size = "icon", ...props }, ref) => {
199
- const { orientation, scrollPrev, canScrollPrev } = useCarousel()
200
-
201
- return (
202
- <Button
203
- ref={ref}
204
- variant={variant}
205
- size={size}
206
- className={cn(
207
- "absolute h-8 w-8 rounded-full",
208
- orientation === "horizontal"
209
- ? "-left-12 top-1/2 -translate-y-1/2"
210
- : "-top-12 left-1/2 -translate-x-1/2 rotate-90",
211
- className
212
- )}
213
- disabled={!canScrollPrev}
214
- onClick={scrollPrev}
215
- {...props}
216
- >
217
- <ArrowLeft className="h-4 w-4" />
218
- <span className="sr-only">Previous slide</span>
219
- </Button>
220
- )
221
- })
222
- CarouselPrevious.displayName = "CarouselPrevious"
223
-
224
- const CarouselNext = React.forwardRef<
225
- HTMLButtonElement,
226
- React.ComponentProps<typeof Button>
227
- >(({ className, variant = "outline", size = "icon", ...props }, ref) => {
228
- const { orientation, scrollNext, canScrollNext } = useCarousel()
229
-
230
- return (
231
- <Button
232
- ref={ref}
233
- variant={variant}
234
- size={size}
235
- className={cn(
236
- "absolute h-8 w-8 rounded-full",
237
- orientation === "horizontal"
238
- ? "-right-12 top-1/2 -translate-y-1/2"
239
- : "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
240
- className
241
- )}
242
- disabled={!canScrollNext}
243
- onClick={scrollNext}
244
- {...props}
245
- >
246
- <ArrowRight className="h-4 w-4" />
247
- <span className="sr-only">Next slide</span>
248
- </Button>
249
- )
250
- })
251
- CarouselNext.displayName = "CarouselNext"
252
-
253
- export {
254
- type CarouselApi,
255
- Carousel,
256
- CarouselContent,
257
- CarouselItem,
258
- CarouselPrevious,
259
- CarouselNext,
260
- }
@@ -1,5 +0,0 @@
1
- export * from './button';
2
- export * from './card';
3
- export * from './carousel';
4
- export * from './label';
5
- export * from './select';
@@ -1,24 +0,0 @@
1
- import * as React from "react"
2
- import * as LabelPrimitive from "@radix-ui/react-label"
3
- import { cva, type VariantProps } from "class-variance-authority"
4
-
5
- import { cn } from "@/lib/index"
6
-
7
- const labelVariants = cva(
8
- "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
9
- )
10
-
11
- const Label = React.forwardRef<
12
- React.ElementRef<typeof LabelPrimitive.Root>,
13
- React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
14
- VariantProps<typeof labelVariants>
15
- >(({ className, ...props }, ref) => (
16
- <LabelPrimitive.Root
17
- ref={ref}
18
- className={cn(labelVariants(), className)}
19
- {...props}
20
- />
21
- ))
22
- Label.displayName = LabelPrimitive.Root.displayName
23
-
24
- export { Label }