@enya-learning/nova 0.4.0 → 0.4.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 (148) hide show
  1. package/dist/chunks/{button-npy7isi3nsvlhf86.js → button-kvgr8g13fe959ju0.js} +19 -19
  2. package/dist/chunks/{button-npy7isi3nsvlhf86.js.map → button-kvgr8g13fe959ju0.js.map} +1 -1
  3. package/dist/chunks/vendor-utils-egkaeebaqpft6cxj.js +473 -0
  4. package/dist/chunks/vendor-utils-egkaeebaqpft6cxj.js.map +1 -0
  5. package/dist/components/button.js +1 -1
  6. package/dist/components/enya-logo.js +1 -1
  7. package/dist/index.js +6782 -7036
  8. package/dist/index.js.map +1 -1
  9. package/package.json +26 -11
  10. package/changelog.md +0 -44
  11. package/components.json +0 -23
  12. package/dist/chunks/vendor-base-ui-efqwzv4oinwg1f0d.js +0 -16049
  13. package/dist/chunks/vendor-base-ui-efqwzv4oinwg1f0d.js.map +0 -1
  14. package/eslint.config.js +0 -30
  15. package/plopfile.mjs +0 -49
  16. package/src/components/.gitkeep +0 -0
  17. package/src/components/accordion/accordion.mdx +0 -83
  18. package/src/components/accordion/accordion.tsx +0 -81
  19. package/src/components/accordion/index.ts +0 -1
  20. package/src/components/alert/alert.tsx +0 -76
  21. package/src/components/alert/index.ts +0 -1
  22. package/src/components/alert-dialog/alert-dialog.tsx +0 -187
  23. package/src/components/alert-dialog/index.ts +0 -1
  24. package/src/components/aspect-ratio/aspect-ratio.tsx +0 -22
  25. package/src/components/aspect-ratio/index.ts +0 -1
  26. package/src/components/avatar/avatar.tsx +0 -107
  27. package/src/components/avatar/index.ts +0 -1
  28. package/src/components/badge/badge.tsx +0 -52
  29. package/src/components/badge/index.ts +0 -1
  30. package/src/components/breadcrumb/breadcrumb.tsx +0 -122
  31. package/src/components/breadcrumb/index.ts +0 -1
  32. package/src/components/button/button.mdx +0 -255
  33. package/src/components/button/button.tsx +0 -59
  34. package/src/components/button/index.ts +0 -1
  35. package/src/components/button-group/button-group.tsx +0 -87
  36. package/src/components/button-group/index.ts +0 -1
  37. package/src/components/calendar/calendar.tsx +0 -228
  38. package/src/components/calendar/index.ts +0 -1
  39. package/src/components/card/card.tsx +0 -100
  40. package/src/components/card/index.ts +0 -1
  41. package/src/components/carousel/carousel.tsx +0 -243
  42. package/src/components/carousel/index.ts +0 -1
  43. package/src/components/chart/chart.tsx +0 -371
  44. package/src/components/chart/index.ts +0 -1
  45. package/src/components/checkbox/checkbox.tsx +0 -28
  46. package/src/components/checkbox/index.ts +0 -1
  47. package/src/components/collapsible/collapsible.tsx +0 -19
  48. package/src/components/collapsible/index.ts +0 -1
  49. package/src/components/combobox/combobox.tsx +0 -298
  50. package/src/components/combobox/index.ts +0 -1
  51. package/src/components/command/command.tsx +0 -193
  52. package/src/components/command/index.ts +0 -1
  53. package/src/components/context-menu/context-menu.tsx +0 -272
  54. package/src/components/context-menu/index.ts +0 -1
  55. package/src/components/dialog/dialog.tsx +0 -157
  56. package/src/components/dialog/index.ts +0 -1
  57. package/src/components/direction/direction.tsx +0 -4
  58. package/src/components/direction/index.ts +0 -1
  59. package/src/components/drawer/drawer.tsx +0 -134
  60. package/src/components/drawer/index.ts +0 -1
  61. package/src/components/dropdown-menu/dropdown-menu.tsx +0 -270
  62. package/src/components/dropdown-menu/index.ts +0 -1
  63. package/src/components/empty/empty.tsx +0 -104
  64. package/src/components/empty/index.ts +0 -1
  65. package/src/components/enya-logo/enya-logo.mdx +0 -174
  66. package/src/components/enya-logo/enya-logo.tsx +0 -383
  67. package/src/components/enya-logo/index.ts +0 -1
  68. package/src/components/field/field.tsx +0 -236
  69. package/src/components/field/index.ts +0 -1
  70. package/src/components/hover-card/hover-card.tsx +0 -51
  71. package/src/components/hover-card/index.ts +0 -1
  72. package/src/components/input/index.ts +0 -1
  73. package/src/components/input/input.tsx +0 -20
  74. package/src/components/input-group/index.ts +0 -1
  75. package/src/components/input-group/input-group.tsx +0 -157
  76. package/src/components/input-otp/index.ts +0 -1
  77. package/src/components/input-otp/input-otp.tsx +0 -84
  78. package/src/components/item/index.ts +0 -1
  79. package/src/components/item/item.tsx +0 -201
  80. package/src/components/kbd/index.ts +0 -1
  81. package/src/components/kbd/kbd.tsx +0 -26
  82. package/src/components/label/index.ts +0 -1
  83. package/src/components/label/label.tsx +0 -20
  84. package/src/components/menubar/index.ts +0 -1
  85. package/src/components/menubar/menubar.tsx +0 -281
  86. package/src/components/native-select/index.ts +0 -1
  87. package/src/components/native-select/native-select.tsx +0 -65
  88. package/src/components/navigation-menu/index.ts +0 -1
  89. package/src/components/navigation-menu/navigation-menu.tsx +0 -171
  90. package/src/components/pagination/index.ts +0 -1
  91. package/src/components/pagination/pagination.tsx +0 -133
  92. package/src/components/popover/index.ts +0 -1
  93. package/src/components/popover/popover.tsx +0 -88
  94. package/src/components/progress/index.ts +0 -1
  95. package/src/components/progress/progress.tsx +0 -83
  96. package/src/components/radio-group/index.ts +0 -1
  97. package/src/components/radio-group/radio-group.tsx +0 -36
  98. package/src/components/resizable/index.ts +0 -1
  99. package/src/components/resizable/resizable.tsx +0 -50
  100. package/src/components/scroll-area/index.ts +0 -1
  101. package/src/components/scroll-area/scroll-area.tsx +0 -53
  102. package/src/components/select/index.ts +0 -1
  103. package/src/components/select/select.tsx +0 -205
  104. package/src/components/separator/index.ts +0 -1
  105. package/src/components/separator/separator.tsx +0 -23
  106. package/src/components/sheet/index.ts +0 -1
  107. package/src/components/sheet/sheet.tsx +0 -137
  108. package/src/components/sidebar/index.ts +0 -1
  109. package/src/components/sidebar/sidebar.tsx +0 -722
  110. package/src/components/skeleton/index.ts +0 -1
  111. package/src/components/skeleton/skeleton.tsx +0 -13
  112. package/src/components/slider/index.ts +0 -1
  113. package/src/components/slider/slider.tsx +0 -52
  114. package/src/components/sonner/index.ts +0 -1
  115. package/src/components/sonner/sonner.tsx +0 -45
  116. package/src/components/spinner/index.ts +0 -1
  117. package/src/components/spinner/spinner.tsx +0 -15
  118. package/src/components/switch/index.ts +0 -1
  119. package/src/components/switch/switch.tsx +0 -30
  120. package/src/components/table/index.ts +0 -1
  121. package/src/components/table/table.tsx +0 -116
  122. package/src/components/tabs/index.ts +0 -1
  123. package/src/components/tabs/tabs.tsx +0 -80
  124. package/src/components/textarea/index.ts +0 -1
  125. package/src/components/textarea/textarea.tsx +0 -18
  126. package/src/components/toggle/index.ts +0 -1
  127. package/src/components/toggle/toggle.tsx +0 -45
  128. package/src/components/toggle-group/index.ts +0 -1
  129. package/src/components/toggle-group/toggle-group.tsx +0 -87
  130. package/src/components/tooltip/index.ts +0 -1
  131. package/src/components/tooltip/tooltip.tsx +0 -64
  132. package/src/hooks/use-mobile.ts +0 -21
  133. package/src/index.ts +0 -58
  134. package/src/lib/.gitkeep +0 -0
  135. package/src/lib/utils.ts +0 -6
  136. package/src/styles/nova-binding.css +0 -290
  137. package/src/styles/nova.css +0 -58
  138. package/src/styles/theme-nova.css +0 -201
  139. package/src/styles/typography.css +0 -215
  140. package/src/utils/index.ts +0 -1
  141. package/templates/component/component.tsx.hbs +0 -16
  142. package/templates/component/index.ts.hbs +0 -1
  143. package/templates/component/stories.tsx.hbs +0 -13
  144. package/tsconfig.json +0 -18
  145. package/tsconfig.lint.json +0 -14
  146. package/vite.config.ts +0 -101
  147. /package/{Readme.md → README.md} +0 -0
  148. /package/{src → dist}/styles/globals.css +0 -0
@@ -1,228 +0,0 @@
1
- import * as React from "react"
2
- import {
3
- DayPicker,
4
- getDefaultClassNames,
5
- type DayButton,
6
- type Locale,
7
- } from "react-day-picker"
8
-
9
- import { cn } from "../../lib/utils"
10
- import { Button, buttonVariants } from "../button"
11
- import {
12
- ChevronLeftIcon,
13
- ChevronRightIcon,
14
- ChevronDownIcon,
15
- } from "lucide-react"
16
-
17
- function Calendar({
18
- className,
19
- classNames,
20
- showOutsideDays = true,
21
- captionLayout = "label",
22
- buttonVariant = "ghost",
23
- locale,
24
- formatters,
25
- components,
26
- ...props
27
- }: React.ComponentProps<typeof DayPicker> & {
28
- buttonVariant?: React.ComponentProps<typeof Button>["variant"]
29
- }) {
30
- const defaultClassNames = getDefaultClassNames()
31
-
32
- return (
33
- <DayPicker
34
- showOutsideDays={showOutsideDays}
35
- className={cn(
36
- "group/calendar bg-background p-3 [--cell-radius:var(--radius-4xl)] [--cell-size:--spacing(8)] in-data-[slot=card-content]:bg-transparent in-data-[slot=popover-content]:bg-transparent",
37
- String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
38
- String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
39
- className
40
- )}
41
- captionLayout={captionLayout}
42
- locale={locale}
43
- formatters={{
44
- formatMonthDropdown: (date) =>
45
- date.toLocaleString(locale?.code, { month: "short" }),
46
- ...formatters,
47
- }}
48
- classNames={{
49
- root: cn("w-fit", defaultClassNames.root),
50
- months: cn(
51
- "relative flex flex-col gap-4 md:flex-row",
52
- defaultClassNames.months
53
- ),
54
- month: cn("flex w-full flex-col gap-4", defaultClassNames.month),
55
- nav: cn(
56
- "absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",
57
- defaultClassNames.nav
58
- ),
59
- button_previous: cn(
60
- buttonVariants({ variant: buttonVariant }),
61
- "size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
62
- defaultClassNames.button_previous
63
- ),
64
- button_next: cn(
65
- buttonVariants({ variant: buttonVariant }),
66
- "size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
67
- defaultClassNames.button_next
68
- ),
69
- month_caption: cn(
70
- "flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)",
71
- defaultClassNames.month_caption
72
- ),
73
- dropdowns: cn(
74
- "flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium",
75
- defaultClassNames.dropdowns
76
- ),
77
- dropdown_root: cn(
78
- "relative rounded-(--cell-radius)",
79
- defaultClassNames.dropdown_root
80
- ),
81
- dropdown: cn(
82
- "absolute inset-0 bg-popover opacity-0",
83
- defaultClassNames.dropdown
84
- ),
85
- caption_label: cn(
86
- "font-medium select-none",
87
- captionLayout === "label"
88
- ? "text-sm"
89
- : "flex items-center gap-1 rounded-(--cell-radius) text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground",
90
- defaultClassNames.caption_label
91
- ),
92
- weekdays: cn("flex", defaultClassNames.weekdays),
93
- weekday: cn(
94
- "flex-1 rounded-(--cell-radius) text-[0.8rem] font-normal text-muted-foreground select-none",
95
- defaultClassNames.weekday
96
- ),
97
- week: cn("mt-2 flex w-full", defaultClassNames.week),
98
- week_number_header: cn(
99
- "w-(--cell-size) select-none",
100
- defaultClassNames.week_number_header
101
- ),
102
- week_number: cn(
103
- "text-[0.8rem] text-muted-foreground select-none",
104
- defaultClassNames.week_number
105
- ),
106
- day: cn(
107
- "group/day relative aspect-square h-full w-full rounded-(--cell-radius) p-0 text-center select-none [&:last-child[data-selected=true]_button]:rounded-e-(--cell-radius)",
108
- props.showWeekNumber
109
- ? "[&:nth-child(2)[data-selected=true]_button]:rounded-s-(--cell-radius)"
110
- : "[&:first-child[data-selected=true]_button]:rounded-s-(--cell-radius)",
111
- defaultClassNames.day
112
- ),
113
- range_start: cn(
114
- "relative isolate z-0 rounded-s-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:end-0 after:w-4 after:bg-muted",
115
- defaultClassNames.range_start
116
- ),
117
- range_middle: cn("rounded-none", defaultClassNames.range_middle),
118
- range_end: cn(
119
- "relative isolate z-0 rounded-e-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:start-0 after:w-4 after:bg-muted",
120
- defaultClassNames.range_end
121
- ),
122
- today: cn(
123
- "rounded-(--cell-radius) bg-muted text-foreground data-[selected=true]:rounded-none",
124
- defaultClassNames.today
125
- ),
126
- outside: cn(
127
- "text-muted-foreground aria-selected:text-muted-foreground",
128
- defaultClassNames.outside
129
- ),
130
- disabled: cn(
131
- "text-muted-foreground opacity-50",
132
- defaultClassNames.disabled
133
- ),
134
- hidden: cn("invisible", defaultClassNames.hidden),
135
- ...classNames,
136
- }}
137
- components={{
138
- Root: ({ className, rootRef, ...props }) => {
139
- return (
140
- <div
141
- data-slot="calendar"
142
- ref={rootRef}
143
- className={cn(className)}
144
- {...props}
145
- />
146
- )
147
- },
148
- Chevron: ({ className, orientation, ...props }) => {
149
- if (orientation === "left") {
150
- return (
151
- <ChevronLeftIcon
152
- className={cn("size-4 rtl:rotate-180", className)}
153
- {...props}
154
- />
155
- )
156
- }
157
-
158
- if (orientation === "right") {
159
- return (
160
- <ChevronRightIcon
161
- className={cn("size-4 rtl:rotate-180", className)}
162
- {...props}
163
- />
164
- )
165
- }
166
-
167
- return (
168
- <ChevronDownIcon className={cn("size-4", className)} {...props} />
169
- )
170
- },
171
- DayButton: ({ ...props }) => (
172
- <CalendarDayButton locale={locale} {...props} />
173
- ),
174
- WeekNumber: ({ children, ...props }) => {
175
- return (
176
- <td {...props}>
177
- <div className="flex size-(--cell-size) items-center justify-center text-center">
178
- {children}
179
- </div>
180
- </td>
181
- )
182
- },
183
- ...components,
184
- }}
185
- {...props}
186
- />
187
- )
188
- }
189
-
190
- function CalendarDayButton({
191
- className,
192
- day,
193
- modifiers,
194
- locale,
195
- ...props
196
- }: React.ComponentProps<typeof DayButton> & { locale?: Partial<Locale> }) {
197
- const defaultClassNames = getDefaultClassNames()
198
-
199
- const ref = React.useRef<HTMLButtonElement>(null)
200
- React.useEffect(() => {
201
- if (modifiers.focused) ref.current?.focus()
202
- }, [modifiers.focused])
203
-
204
- return (
205
- <Button
206
- variant="ghost"
207
- size="icon"
208
- data-day={day.date.toLocaleDateString(locale?.code)}
209
- data-selected-single={
210
- modifiers.selected &&
211
- !modifiers.range_start &&
212
- !modifiers.range_end &&
213
- !modifiers.range_middle
214
- }
215
- data-range-start={modifiers.range_start}
216
- data-range-end={modifiers.range_end}
217
- data-range-middle={modifiers.range_middle}
218
- className={cn(
219
- "relative isolate z-10 flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 border-0 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-[3px] group-data-[focused=true]/day:ring-ring/50 data-[range-end=true]:rounded-(--cell-radius) data-[range-end=true]:rounded-e-(--cell-radius) data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground data-[range-middle=true]:rounded-none data-[range-middle=true]:bg-muted data-[range-middle=true]:text-foreground data-[range-start=true]:rounded-(--cell-radius) data-[range-start=true]:rounded-s-(--cell-radius) data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground dark:hover:text-foreground [&>span]:text-xs [&>span]:opacity-70",
220
- defaultClassNames.day,
221
- className
222
- )}
223
- {...props}
224
- />
225
- )
226
- }
227
-
228
- export { Calendar, CalendarDayButton }
@@ -1 +0,0 @@
1
- export * from "./calendar"
@@ -1,100 +0,0 @@
1
- import * as React from "react"
2
-
3
- import { cn } from "../../lib/utils"
4
-
5
- function Card({
6
- className,
7
- size = "default",
8
- ...props
9
- }: React.ComponentProps<"div"> & { size?: "default" | "sm" }) {
10
- return (
11
- <div
12
- data-slot="card"
13
- data-size={size}
14
- className={cn(
15
- "group/card flex flex-col gap-6 overflow-hidden rounded-2xl bg-card py-6 text-sm text-card-foreground ring-1 ring-foreground/10 has-[>img:first-child]:pt-0 data-[size=sm]:gap-4 data-[size=sm]:py-4 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
16
- className
17
- )}
18
- {...props}
19
- />
20
- )
21
- }
22
-
23
- function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
24
- return (
25
- <div
26
- data-slot="card-header"
27
- className={cn(
28
- "group/card-header @container/card-header grid auto-rows-min items-start gap-2 rounded-t-xl px-6 group-data-[size=sm]/card:px-4 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-6 group-data-[size=sm]/card:[.border-b]:pb-4",
29
- className
30
- )}
31
- {...props}
32
- />
33
- )
34
- }
35
-
36
- function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
37
- return (
38
- <div
39
- data-slot="card-title"
40
- className={cn("font-heading text-base font-medium", className)}
41
- {...props}
42
- />
43
- )
44
- }
45
-
46
- function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
47
- return (
48
- <div
49
- data-slot="card-description"
50
- className={cn("text-sm text-muted-foreground", className)}
51
- {...props}
52
- />
53
- )
54
- }
55
-
56
- function CardAction({ className, ...props }: React.ComponentProps<"div">) {
57
- return (
58
- <div
59
- data-slot="card-action"
60
- className={cn(
61
- "col-start-2 row-span-2 row-start-1 self-start justify-self-end",
62
- className
63
- )}
64
- {...props}
65
- />
66
- )
67
- }
68
-
69
- function CardContent({ className, ...props }: React.ComponentProps<"div">) {
70
- return (
71
- <div
72
- data-slot="card-content"
73
- className={cn("px-6 group-data-[size=sm]/card:px-4", className)}
74
- {...props}
75
- />
76
- )
77
- }
78
-
79
- function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
80
- return (
81
- <div
82
- data-slot="card-footer"
83
- className={cn(
84
- "flex items-center rounded-b-xl px-6 group-data-[size=sm]/card:px-4 [.border-t]:pt-6 group-data-[size=sm]/card:[.border-t]:pt-4",
85
- className
86
- )}
87
- {...props}
88
- />
89
- )
90
- }
91
-
92
- export {
93
- Card,
94
- CardHeader,
95
- CardFooter,
96
- CardTitle,
97
- CardAction,
98
- CardDescription,
99
- CardContent,
100
- }
@@ -1 +0,0 @@
1
- export * from "./card"
@@ -1,243 +0,0 @@
1
- "use client"
2
-
3
- import * as React from "react"
4
- import useEmblaCarousel, {
5
- type UseEmblaCarouselType,
6
- } from "embla-carousel-react"
7
-
8
- import { cn } from "../../lib/utils"
9
- import { Button } from "../button"
10
- import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
11
-
12
- type CarouselApi = UseEmblaCarouselType[1]
13
- type UseCarouselParameters = Parameters<typeof useEmblaCarousel>
14
- type CarouselOptions = UseCarouselParameters[0]
15
- type CarouselPlugin = UseCarouselParameters[1]
16
-
17
- type CarouselProps = {
18
- opts?: CarouselOptions
19
- plugins?: CarouselPlugin
20
- orientation?: "horizontal" | "vertical"
21
- setApi?: (api: CarouselApi) => void
22
- }
23
-
24
- type CarouselContextProps = {
25
- carouselRef: ReturnType<typeof useEmblaCarousel>[0]
26
- api: ReturnType<typeof useEmblaCarousel>[1]
27
- scrollPrev: () => void
28
- scrollNext: () => void
29
- canScrollPrev: boolean
30
- canScrollNext: boolean
31
- } & CarouselProps
32
-
33
- const CarouselContext = React.createContext<CarouselContextProps | null>(null)
34
-
35
- function useCarousel() {
36
- const context = React.useContext(CarouselContext)
37
-
38
- if (!context) {
39
- throw new Error("useCarousel must be used within a <Carousel />")
40
- }
41
-
42
- return context
43
- }
44
-
45
- function Carousel({
46
- orientation = "horizontal",
47
- opts,
48
- setApi,
49
- plugins,
50
- className,
51
- children,
52
- ...props
53
- }: React.ComponentProps<"div"> & CarouselProps) {
54
- const [carouselRef, api] = useEmblaCarousel(
55
- {
56
- ...opts,
57
- axis: orientation === "horizontal" ? "x" : "y",
58
- },
59
- plugins
60
- )
61
- const [canScrollPrev, setCanScrollPrev] = React.useState(false)
62
- const [canScrollNext, setCanScrollNext] = React.useState(false)
63
-
64
- const onSelect = React.useCallback((api: CarouselApi) => {
65
- if (!api) return
66
- setCanScrollPrev(api.canScrollPrev())
67
- setCanScrollNext(api.canScrollNext())
68
- }, [])
69
-
70
- const scrollPrev = React.useCallback(() => {
71
- api?.scrollPrev()
72
- }, [api])
73
-
74
- const scrollNext = React.useCallback(() => {
75
- api?.scrollNext()
76
- }, [api])
77
-
78
- const handleKeyDown = React.useCallback(
79
- (event: React.KeyboardEvent<HTMLDivElement>) => {
80
- if (event.key === "ArrowLeft") {
81
- event.preventDefault()
82
- scrollPrev()
83
- } else if (event.key === "ArrowRight") {
84
- event.preventDefault()
85
- scrollNext()
86
- }
87
- },
88
- [scrollPrev, scrollNext]
89
- )
90
-
91
- React.useEffect(() => {
92
- if (!api || !setApi) return
93
- setApi(api)
94
- }, [api, setApi])
95
-
96
- React.useEffect(() => {
97
- if (!api) return
98
- // eslint-disable-next-line react-hooks/set-state-in-effect
99
- onSelect(api)
100
- api.on("reInit", onSelect)
101
- api.on("select", onSelect)
102
-
103
- return () => {
104
- api?.off("select", onSelect)
105
- }
106
- }, [api, onSelect])
107
-
108
- return (
109
- <CarouselContext.Provider
110
- value={{
111
- carouselRef,
112
- api: api,
113
- opts,
114
- orientation:
115
- orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
116
- scrollPrev,
117
- scrollNext,
118
- canScrollPrev,
119
- canScrollNext,
120
- }}
121
- >
122
- <div
123
- onKeyDownCapture={handleKeyDown}
124
- className={cn("relative", className)}
125
- role="region"
126
- aria-roledescription="carousel"
127
- data-slot="carousel"
128
- {...props}
129
- >
130
- {children}
131
- </div>
132
- </CarouselContext.Provider>
133
- )
134
- }
135
-
136
- function CarouselContent({ className, ...props }: React.ComponentProps<"div">) {
137
- const { carouselRef, orientation } = useCarousel()
138
-
139
- return (
140
- <div
141
- ref={carouselRef}
142
- className="overflow-hidden"
143
- data-slot="carousel-content"
144
- >
145
- <div
146
- className={cn(
147
- "flex",
148
- orientation === "horizontal" ? "-ms-4" : "-mt-4 flex-col",
149
- className
150
- )}
151
- {...props}
152
- />
153
- </div>
154
- )
155
- }
156
-
157
- function CarouselItem({ className, ...props }: React.ComponentProps<"div">) {
158
- const { orientation } = useCarousel()
159
-
160
- return (
161
- <div
162
- role="group"
163
- aria-roledescription="slide"
164
- data-slot="carousel-item"
165
- className={cn(
166
- "min-w-0 shrink-0 grow-0 basis-full",
167
- orientation === "horizontal" ? "ps-4" : "pt-4",
168
- className
169
- )}
170
- {...props}
171
- />
172
- )
173
- }
174
-
175
- function CarouselPrevious({
176
- className,
177
- variant = "outline",
178
- size = "icon-sm",
179
- ...props
180
- }: React.ComponentProps<typeof Button>) {
181
- const { orientation, scrollPrev, canScrollPrev } = useCarousel()
182
-
183
- return (
184
- <Button
185
- data-slot="carousel-previous"
186
- variant={variant}
187
- size={size}
188
- className={cn(
189
- "absolute touch-manipulation rounded-full",
190
- orientation === "horizontal"
191
- ? "-start-12 top-1/2 -translate-y-1/2"
192
- : "start-1/2 -top-12 -translate-x-1/2 rotate-90 rtl:translate-x-1/2",
193
- className
194
- )}
195
- disabled={!canScrollPrev}
196
- onClick={scrollPrev}
197
- {...props}
198
- >
199
- <ChevronLeftIcon className="rtl:rotate-180" />
200
- <span className="sr-only">Previous slide</span>
201
- </Button>
202
- )
203
- }
204
-
205
- function CarouselNext({
206
- className,
207
- variant = "outline",
208
- size = "icon-sm",
209
- ...props
210
- }: React.ComponentProps<typeof Button>) {
211
- const { orientation, scrollNext, canScrollNext } = useCarousel()
212
-
213
- return (
214
- <Button
215
- data-slot="carousel-next"
216
- variant={variant}
217
- size={size}
218
- className={cn(
219
- "absolute touch-manipulation rounded-full",
220
- orientation === "horizontal"
221
- ? "-end-12 top-1/2 -translate-y-1/2"
222
- : "start-1/2 -bottom-12 -translate-x-1/2 rotate-90 rtl:translate-x-1/2",
223
- className
224
- )}
225
- disabled={!canScrollNext}
226
- onClick={scrollNext}
227
- {...props}
228
- >
229
- <ChevronRightIcon className="rtl:rotate-180" />
230
- <span className="sr-only">Next slide</span>
231
- </Button>
232
- )
233
- }
234
-
235
- export {
236
- type CarouselApi,
237
- Carousel,
238
- CarouselContent,
239
- CarouselItem,
240
- CarouselPrevious,
241
- CarouselNext,
242
- useCarousel,
243
- }
@@ -1 +0,0 @@
1
- export * from "./carousel"