create-disposabl-app 0.9.1 → 0.10.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.
- package/dist/disposabl.js +1 -1
- package/dist/index.js +2 -2
- package/dist/templates/default/.github/workflows/pipeline.yml +1 -1
- package/dist/templates/default/apps/web/src/router/_authenticated/dashboard.api-keys.tsx +1 -1
- package/dist/templates/default/bun.lock +77 -1397
- package/dist/templates/default/package.json +1 -2
- package/dist/templates/default/packages/backend/README.md +3 -1
- package/dist/templates/default/packages/backend/convex/_generated/api.d.ts +6 -0
- package/dist/templates/default/packages/backend/convex/_generated/server.d.ts +0 -2
- package/dist/templates/default/packages/backend/convex/auth.config.ts +2 -10
- package/dist/templates/default/packages/backend/convex/convex.config.ts +3 -14
- package/dist/templates/default/packages/backend/convex/mcpEnterprise/README.md +42 -0
- package/dist/templates/default/packages/backend/convex/mcpEnterprise/internal.ts +153 -0
- package/dist/templates/default/packages/backend/convex/mcpEnterprise/provision.ts +102 -0
- package/dist/templates/default/packages/backend/convex/mcpEnterprise/validator.ts +35 -0
- package/dist/templates/default/packages/backend/convex/schema.ts +18 -0
- package/dist/templates/default/packages/backend/package.json +0 -1
- package/dist/templates/default/packages/cli/README.md +9 -24
- package/dist/templates/default/packages/disposabl-kit/client/routes/_auth-pages/login.tsx +1 -1
- package/dist/templates/default/packages/disposabl-kit/client/routes/_auth-pages/signUp.tsx +1 -1
- package/dist/templates/default/packages/disposabl-kit/client/routes/consent.tsx +71 -13
- package/dist/templates/default/packages/disposabl-kit/package.json +4 -14
- package/dist/templates/default/packages/disposabl-kit/server/http.ts +19 -12
- package/dist/templates/default/packages/disposabl-kit/server/lib/functions.ts +12 -0
- package/dist/templates/default/packages/disposabl-kit/server/mcp/enterprise.ts +267 -0
- package/dist/templates/default/packages/disposabl-kit/server/mcp/identity.ts +33 -0
- package/dist/templates/default/vendor/README.md +30 -0
- package/dist/templates/default/vendor/convex-auth-6c0ebf3f.tgz +0 -0
- package/package.json +1 -1
- package/dist/templates/default/apps/web/src/components/connections/expo-connection.tsx +0 -97
- package/dist/templates/default/apps/web/src/components/connections/provider-logo.tsx +0 -44
- package/dist/templates/default/apps/web/src/components/connections/use-connection-setup.ts +0 -169
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/accordion.tsx +0 -77
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/alert-dialog.tsx +0 -185
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/alert.tsx +0 -75
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/aspect-ratio.tsx +0 -22
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/attachment.tsx +0 -207
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/avatar.tsx +0 -106
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/badge.tsx +0 -51
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/breadcrumb.tsx +0 -121
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/bubble.tsx +0 -127
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/button-group.tsx +0 -87
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/calendar.tsx +0 -241
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/carousel.tsx +0 -239
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/chart.tsx +0 -368
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/checkbox.tsx +0 -27
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/code-block.tsx +0 -243
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/collapsible.tsx +0 -19
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/combobox.tsx +0 -300
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/command.tsx +0 -194
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/context-menu.tsx +0 -271
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/dialog.tsx +0 -156
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/direction.tsx +0 -4
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/drawer.tsx +0 -224
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/dropdown-menu.tsx +0 -269
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/empty.tsx +0 -103
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/hover-card.tsx +0 -50
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/input-group.tsx +0 -158
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/input-otp.tsx +0 -83
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/item.tsx +0 -201
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/kbd.tsx +0 -26
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/marker.tsx +0 -70
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/menubar.tsx +0 -284
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/message-scroller.tsx +0 -128
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/message.tsx +0 -91
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/native-select.tsx +0 -64
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/navigation-menu.tsx +0 -170
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/pagination.tsx +0 -133
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/popover.tsx +0 -87
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/progress.tsx +0 -82
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/questionnaire.tsx +0 -330
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/radio-group.tsx +0 -35
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/resizable.tsx +0 -49
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/scroll-area.tsx +0 -51
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/select.tsx +0 -201
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/sheet.tsx +0 -132
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/sidebar.tsx +0 -723
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/skeleton.tsx +0 -13
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/slider.tsx +0 -51
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/switch.tsx +0 -31
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/table.tsx +0 -113
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/tabs.tsx +0 -81
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/textarea.tsx +0 -17
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/toast.tsx +0 -229
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/toggle-group.tsx +0 -87
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/toggle.tsx +0 -42
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/tooltip.tsx +0 -65
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/trace.tsx +0 -161
- package/dist/templates/default/packages/disposabl-kit/client/hooks/use-mobile.ts +0 -21
- package/dist/templates/default/patches/@convex-dev%2Fauth@2.0.0-beta.0.patch +0 -310
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import { cn } from "@disposabl/disposabl-kit/client/lib/utils";
|
|
5
|
-
import {
|
|
6
|
-
DayPicker,
|
|
7
|
-
getDefaultClassNames,
|
|
8
|
-
type DayButton,
|
|
9
|
-
type Locale,
|
|
10
|
-
} from "react-day-picker";
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
Button,
|
|
14
|
-
buttonVariants,
|
|
15
|
-
} from "@disposabl/disposabl-kit/client/components/ui/button";
|
|
16
|
-
import {
|
|
17
|
-
ChevronLeftIcon,
|
|
18
|
-
ChevronRightIcon,
|
|
19
|
-
ChevronDownIcon,
|
|
20
|
-
} from "lucide-react";
|
|
21
|
-
|
|
22
|
-
function Calendar({
|
|
23
|
-
className,
|
|
24
|
-
classNames,
|
|
25
|
-
showOutsideDays = true,
|
|
26
|
-
captionLayout = "label",
|
|
27
|
-
buttonVariant = "ghost",
|
|
28
|
-
locale,
|
|
29
|
-
formatters,
|
|
30
|
-
components,
|
|
31
|
-
...props
|
|
32
|
-
}: React.ComponentProps<typeof DayPicker> & {
|
|
33
|
-
buttonVariant?: React.ComponentProps<typeof Button>["variant"];
|
|
34
|
-
}) {
|
|
35
|
-
const defaultClassNames = getDefaultClassNames();
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<DayPicker
|
|
39
|
-
showOutsideDays={showOutsideDays}
|
|
40
|
-
className={cn(
|
|
41
|
-
"group/calendar bg-background p-3 [--cell-radius:var(--radius-md)] [--cell-size:--spacing(8)] in-data-[slot=card-content]:bg-transparent in-data-[slot=popover-content]:bg-transparent",
|
|
42
|
-
String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
|
|
43
|
-
String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
|
|
44
|
-
className,
|
|
45
|
-
)}
|
|
46
|
-
captionLayout={captionLayout}
|
|
47
|
-
locale={locale}
|
|
48
|
-
formatters={{
|
|
49
|
-
formatMonthDropdown: (date) =>
|
|
50
|
-
date.toLocaleString(locale?.code, { month: "short" }),
|
|
51
|
-
...formatters,
|
|
52
|
-
}}
|
|
53
|
-
classNames={{
|
|
54
|
-
root: cn("w-fit", defaultClassNames.root),
|
|
55
|
-
months: cn(
|
|
56
|
-
"relative flex flex-col gap-4 md:flex-row",
|
|
57
|
-
defaultClassNames.months,
|
|
58
|
-
),
|
|
59
|
-
month: cn("flex w-full flex-col gap-4", defaultClassNames.month),
|
|
60
|
-
nav: cn(
|
|
61
|
-
"absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",
|
|
62
|
-
defaultClassNames.nav,
|
|
63
|
-
),
|
|
64
|
-
button_previous: cn(
|
|
65
|
-
buttonVariants({ variant: buttonVariant }),
|
|
66
|
-
"size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
|
|
67
|
-
defaultClassNames.button_previous,
|
|
68
|
-
),
|
|
69
|
-
button_next: cn(
|
|
70
|
-
buttonVariants({ variant: buttonVariant }),
|
|
71
|
-
"size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
|
|
72
|
-
defaultClassNames.button_next,
|
|
73
|
-
),
|
|
74
|
-
month_caption: cn(
|
|
75
|
-
"flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)",
|
|
76
|
-
defaultClassNames.month_caption,
|
|
77
|
-
),
|
|
78
|
-
dropdowns: cn(
|
|
79
|
-
"flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium",
|
|
80
|
-
defaultClassNames.dropdowns,
|
|
81
|
-
),
|
|
82
|
-
dropdown_root: cn(
|
|
83
|
-
"relative rounded-(--cell-radius)",
|
|
84
|
-
defaultClassNames.dropdown_root,
|
|
85
|
-
),
|
|
86
|
-
dropdown: cn(
|
|
87
|
-
"absolute inset-0 bg-popover opacity-0",
|
|
88
|
-
defaultClassNames.dropdown,
|
|
89
|
-
),
|
|
90
|
-
caption_label: cn(
|
|
91
|
-
"font-medium select-none",
|
|
92
|
-
captionLayout === "label"
|
|
93
|
-
? "text-sm"
|
|
94
|
-
: "flex items-center gap-1 rounded-(--cell-radius) text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground",
|
|
95
|
-
defaultClassNames.caption_label,
|
|
96
|
-
),
|
|
97
|
-
month_grid: cn("w-full border-collapse", defaultClassNames.month_grid),
|
|
98
|
-
weekdays: cn("flex", defaultClassNames.weekdays),
|
|
99
|
-
weekday: cn(
|
|
100
|
-
"flex-1 rounded-(--cell-radius) text-[0.8rem] font-normal text-muted-foreground select-none",
|
|
101
|
-
defaultClassNames.weekday,
|
|
102
|
-
),
|
|
103
|
-
week: cn("mt-2 flex w-full", defaultClassNames.week),
|
|
104
|
-
week_number_header: cn(
|
|
105
|
-
"w-(--cell-size) select-none",
|
|
106
|
-
defaultClassNames.week_number_header,
|
|
107
|
-
),
|
|
108
|
-
week_number: cn(
|
|
109
|
-
"text-[0.8rem] text-muted-foreground select-none",
|
|
110
|
-
defaultClassNames.week_number,
|
|
111
|
-
),
|
|
112
|
-
day: cn(
|
|
113
|
-
"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-r-(--cell-radius)",
|
|
114
|
-
props.showWeekNumber
|
|
115
|
-
? "[&:nth-child(2)[data-selected=true]_button]:rounded-l-(--cell-radius)"
|
|
116
|
-
: "[&:first-child[data-selected=true]_button]:rounded-l-(--cell-radius)",
|
|
117
|
-
defaultClassNames.day,
|
|
118
|
-
),
|
|
119
|
-
range_start: cn(
|
|
120
|
-
"relative isolate z-0 rounded-l-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:right-0 after:w-4 after:bg-muted",
|
|
121
|
-
defaultClassNames.range_start,
|
|
122
|
-
),
|
|
123
|
-
range_middle: cn("rounded-none", defaultClassNames.range_middle),
|
|
124
|
-
range_end: cn(
|
|
125
|
-
"relative isolate z-0 rounded-r-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:left-0 after:w-4 after:bg-muted",
|
|
126
|
-
defaultClassNames.range_end,
|
|
127
|
-
),
|
|
128
|
-
today: cn(
|
|
129
|
-
"rounded-(--cell-radius) bg-muted text-foreground data-[selected=true]:rounded-none",
|
|
130
|
-
defaultClassNames.today,
|
|
131
|
-
),
|
|
132
|
-
outside: cn(
|
|
133
|
-
"text-muted-foreground aria-selected:text-muted-foreground",
|
|
134
|
-
defaultClassNames.outside,
|
|
135
|
-
),
|
|
136
|
-
disabled: cn(
|
|
137
|
-
"text-muted-foreground opacity-50",
|
|
138
|
-
defaultClassNames.disabled,
|
|
139
|
-
),
|
|
140
|
-
hidden: cn("invisible", defaultClassNames.hidden),
|
|
141
|
-
...classNames,
|
|
142
|
-
}}
|
|
143
|
-
components={{
|
|
144
|
-
Root: ({ className: rootClassName, rootRef, ...rootProps }) => {
|
|
145
|
-
return (
|
|
146
|
-
<div
|
|
147
|
-
data-slot="calendar"
|
|
148
|
-
ref={rootRef}
|
|
149
|
-
className={cn(rootClassName)}
|
|
150
|
-
{...rootProps}
|
|
151
|
-
/>
|
|
152
|
-
);
|
|
153
|
-
},
|
|
154
|
-
Chevron: ({
|
|
155
|
-
className: chevronClassName,
|
|
156
|
-
orientation,
|
|
157
|
-
...chevronProps
|
|
158
|
-
}) => {
|
|
159
|
-
if (orientation === "left") {
|
|
160
|
-
return (
|
|
161
|
-
<ChevronLeftIcon
|
|
162
|
-
className={cn("size-4", chevronClassName)}
|
|
163
|
-
{...chevronProps}
|
|
164
|
-
/>
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
if (orientation === "right") {
|
|
169
|
-
return (
|
|
170
|
-
<ChevronRightIcon
|
|
171
|
-
className={cn("size-4", chevronClassName)}
|
|
172
|
-
{...chevronProps}
|
|
173
|
-
/>
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
return (
|
|
178
|
-
<ChevronDownIcon
|
|
179
|
-
className={cn("size-4", chevronClassName)}
|
|
180
|
-
{...chevronProps}
|
|
181
|
-
/>
|
|
182
|
-
);
|
|
183
|
-
},
|
|
184
|
-
DayButton: (dayButtonProps) => (
|
|
185
|
-
<CalendarDayButton locale={locale} {...dayButtonProps} />
|
|
186
|
-
),
|
|
187
|
-
WeekNumber: ({ children, ...weekNumberProps }) => {
|
|
188
|
-
return (
|
|
189
|
-
<td {...weekNumberProps}>
|
|
190
|
-
<div className="flex size-(--cell-size) items-center justify-center text-center">
|
|
191
|
-
{children}
|
|
192
|
-
</div>
|
|
193
|
-
</td>
|
|
194
|
-
);
|
|
195
|
-
},
|
|
196
|
-
...components,
|
|
197
|
-
}}
|
|
198
|
-
{...props}
|
|
199
|
-
/>
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
function CalendarDayButton({
|
|
204
|
-
className,
|
|
205
|
-
day,
|
|
206
|
-
modifiers,
|
|
207
|
-
locale,
|
|
208
|
-
...props
|
|
209
|
-
}: React.ComponentProps<typeof DayButton> & { locale?: Partial<Locale> }) {
|
|
210
|
-
const defaultClassNames = getDefaultClassNames();
|
|
211
|
-
|
|
212
|
-
const ref = React.useRef<HTMLButtonElement>(null);
|
|
213
|
-
React.useEffect(() => {
|
|
214
|
-
if (modifiers.focused) ref.current?.focus();
|
|
215
|
-
}, [modifiers.focused]);
|
|
216
|
-
|
|
217
|
-
return (
|
|
218
|
-
<Button
|
|
219
|
-
variant="ghost"
|
|
220
|
-
size="icon"
|
|
221
|
-
data-day={day.date.toLocaleDateString(locale?.code)}
|
|
222
|
-
data-selected-single={
|
|
223
|
-
modifiers.selected &&
|
|
224
|
-
!modifiers.range_start &&
|
|
225
|
-
!modifiers.range_end &&
|
|
226
|
-
!modifiers.range_middle
|
|
227
|
-
}
|
|
228
|
-
data-range-start={modifiers.range_start}
|
|
229
|
-
data-range-end={modifiers.range_end}
|
|
230
|
-
data-range-middle={modifiers.range_middle}
|
|
231
|
-
className={cn(
|
|
232
|
-
"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-r-(--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-l-(--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",
|
|
233
|
-
defaultClassNames.day,
|
|
234
|
-
className,
|
|
235
|
-
)}
|
|
236
|
-
{...props}
|
|
237
|
-
/>
|
|
238
|
-
);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
export { Calendar, CalendarDayButton };
|
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { cn } from "@disposabl/disposabl-kit/client/lib/utils";
|
|
3
|
-
import useEmblaCarousel, {
|
|
4
|
-
type UseEmblaCarouselType,
|
|
5
|
-
} from "embla-carousel-react";
|
|
6
|
-
|
|
7
|
-
import { Button } from "@disposabl/disposabl-kit/client/components/ui/button";
|
|
8
|
-
import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
|
|
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
|
-
function Carousel({
|
|
44
|
-
orientation = "horizontal",
|
|
45
|
-
opts,
|
|
46
|
-
setApi,
|
|
47
|
-
plugins,
|
|
48
|
-
className,
|
|
49
|
-
children,
|
|
50
|
-
...props
|
|
51
|
-
}: React.ComponentProps<"div"> & CarouselProps) {
|
|
52
|
-
const [carouselRef, api] = useEmblaCarousel(
|
|
53
|
-
{
|
|
54
|
-
...opts,
|
|
55
|
-
axis: orientation === "horizontal" ? "x" : "y",
|
|
56
|
-
},
|
|
57
|
-
plugins,
|
|
58
|
-
);
|
|
59
|
-
const [canScrollPrev, setCanScrollPrev] = React.useState(false);
|
|
60
|
-
const [canScrollNext, setCanScrollNext] = React.useState(false);
|
|
61
|
-
|
|
62
|
-
const onSelect = React.useCallback((carouselApi: CarouselApi) => {
|
|
63
|
-
if (!carouselApi) return;
|
|
64
|
-
setCanScrollPrev(carouselApi.canScrollPrev());
|
|
65
|
-
setCanScrollNext(carouselApi.canScrollNext());
|
|
66
|
-
}, []);
|
|
67
|
-
|
|
68
|
-
const scrollPrev = React.useCallback(() => {
|
|
69
|
-
api?.scrollPrev();
|
|
70
|
-
}, [api]);
|
|
71
|
-
|
|
72
|
-
const scrollNext = React.useCallback(() => {
|
|
73
|
-
api?.scrollNext();
|
|
74
|
-
}, [api]);
|
|
75
|
-
|
|
76
|
-
const handleKeyDown = React.useCallback(
|
|
77
|
-
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
78
|
-
if (event.key === "ArrowLeft") {
|
|
79
|
-
event.preventDefault();
|
|
80
|
-
scrollPrev();
|
|
81
|
-
} else if (event.key === "ArrowRight") {
|
|
82
|
-
event.preventDefault();
|
|
83
|
-
scrollNext();
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
[scrollPrev, scrollNext],
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
React.useEffect(() => {
|
|
90
|
-
if (!api || !setApi) return;
|
|
91
|
-
setApi(api);
|
|
92
|
-
}, [api, setApi]);
|
|
93
|
-
|
|
94
|
-
React.useEffect(() => {
|
|
95
|
-
if (!api) return;
|
|
96
|
-
onSelect(api);
|
|
97
|
-
api.on("reInit", onSelect);
|
|
98
|
-
api.on("select", onSelect);
|
|
99
|
-
|
|
100
|
-
return () => {
|
|
101
|
-
api.off("select", onSelect);
|
|
102
|
-
};
|
|
103
|
-
}, [api, onSelect]);
|
|
104
|
-
|
|
105
|
-
return (
|
|
106
|
-
<CarouselContext.Provider
|
|
107
|
-
value={{
|
|
108
|
-
carouselRef,
|
|
109
|
-
api: api,
|
|
110
|
-
opts,
|
|
111
|
-
orientation,
|
|
112
|
-
scrollPrev,
|
|
113
|
-
scrollNext,
|
|
114
|
-
canScrollPrev,
|
|
115
|
-
canScrollNext,
|
|
116
|
-
}}
|
|
117
|
-
>
|
|
118
|
-
<div
|
|
119
|
-
onKeyDownCapture={handleKeyDown}
|
|
120
|
-
className={cn("relative", className)}
|
|
121
|
-
role="region"
|
|
122
|
-
aria-roledescription="carousel"
|
|
123
|
-
data-slot="carousel"
|
|
124
|
-
{...props}
|
|
125
|
-
>
|
|
126
|
-
{children}
|
|
127
|
-
</div>
|
|
128
|
-
</CarouselContext.Provider>
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function CarouselContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
133
|
-
const { carouselRef, orientation } = useCarousel();
|
|
134
|
-
|
|
135
|
-
return (
|
|
136
|
-
<div
|
|
137
|
-
ref={carouselRef}
|
|
138
|
-
className="overflow-hidden"
|
|
139
|
-
data-slot="carousel-content"
|
|
140
|
-
>
|
|
141
|
-
<div
|
|
142
|
-
className={cn(
|
|
143
|
-
"flex",
|
|
144
|
-
orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col",
|
|
145
|
-
className,
|
|
146
|
-
)}
|
|
147
|
-
{...props}
|
|
148
|
-
/>
|
|
149
|
-
</div>
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
function CarouselItem({ className, ...props }: React.ComponentProps<"div">) {
|
|
154
|
-
const { orientation } = useCarousel();
|
|
155
|
-
|
|
156
|
-
return (
|
|
157
|
-
<div
|
|
158
|
-
role="group"
|
|
159
|
-
aria-roledescription="slide"
|
|
160
|
-
data-slot="carousel-item"
|
|
161
|
-
className={cn(
|
|
162
|
-
"min-w-0 shrink-0 grow-0 basis-full",
|
|
163
|
-
orientation === "horizontal" ? "pl-4" : "pt-4",
|
|
164
|
-
className,
|
|
165
|
-
)}
|
|
166
|
-
{...props}
|
|
167
|
-
/>
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
function CarouselPrevious({
|
|
172
|
-
className,
|
|
173
|
-
variant = "outline",
|
|
174
|
-
size = "icon-sm",
|
|
175
|
-
...props
|
|
176
|
-
}: React.ComponentProps<typeof Button>) {
|
|
177
|
-
const { orientation, scrollPrev, canScrollPrev } = useCarousel();
|
|
178
|
-
|
|
179
|
-
return (
|
|
180
|
-
<Button
|
|
181
|
-
data-slot="carousel-previous"
|
|
182
|
-
variant={variant}
|
|
183
|
-
size={size}
|
|
184
|
-
className={cn(
|
|
185
|
-
"absolute touch-manipulation rounded-full",
|
|
186
|
-
orientation === "horizontal"
|
|
187
|
-
? "inset-y-0 -left-12 my-auto"
|
|
188
|
-
: "-top-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
189
|
-
className,
|
|
190
|
-
)}
|
|
191
|
-
disabled={!canScrollPrev}
|
|
192
|
-
onClick={scrollPrev}
|
|
193
|
-
{...props}
|
|
194
|
-
>
|
|
195
|
-
<ChevronLeftIcon />
|
|
196
|
-
<span className="sr-only">Previous slide</span>
|
|
197
|
-
</Button>
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
function CarouselNext({
|
|
202
|
-
className,
|
|
203
|
-
variant = "outline",
|
|
204
|
-
size = "icon-sm",
|
|
205
|
-
...props
|
|
206
|
-
}: React.ComponentProps<typeof Button>) {
|
|
207
|
-
const { orientation, scrollNext, canScrollNext } = useCarousel();
|
|
208
|
-
|
|
209
|
-
return (
|
|
210
|
-
<Button
|
|
211
|
-
data-slot="carousel-next"
|
|
212
|
-
variant={variant}
|
|
213
|
-
size={size}
|
|
214
|
-
className={cn(
|
|
215
|
-
"absolute touch-manipulation rounded-full",
|
|
216
|
-
orientation === "horizontal"
|
|
217
|
-
? "inset-y-0 -right-12 my-auto"
|
|
218
|
-
: "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
219
|
-
className,
|
|
220
|
-
)}
|
|
221
|
-
disabled={!canScrollNext}
|
|
222
|
-
onClick={scrollNext}
|
|
223
|
-
{...props}
|
|
224
|
-
>
|
|
225
|
-
<ChevronRightIcon />
|
|
226
|
-
<span className="sr-only">Next slide</span>
|
|
227
|
-
</Button>
|
|
228
|
-
);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
export {
|
|
232
|
-
type CarouselApi,
|
|
233
|
-
Carousel,
|
|
234
|
-
CarouselContent,
|
|
235
|
-
CarouselItem,
|
|
236
|
-
CarouselPrevious,
|
|
237
|
-
CarouselNext,
|
|
238
|
-
useCarousel,
|
|
239
|
-
};
|