startx 0.0.1 → 0.1.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.
- package/.prettierignore +0 -13
- package/.prettierrc.js +52 -52
- package/.vscode/launch.json +32 -0
- package/.vscode/settings.json +9 -3
- package/apps/core-server/.env.example +18 -24
- package/apps/core-server/Dockerfile +35 -61
- package/apps/core-server/eslint.config.ts +7 -0
- package/apps/core-server/package.json +41 -52
- package/apps/core-server/src/config/custom-type.ts +2 -40
- package/apps/core-server/src/events/index.ts +37 -37
- package/apps/core-server/src/index.ts +4 -13
- package/apps/core-server/src/middlewares/auth-middleware.ts +24 -7
- package/apps/core-server/src/middlewares/cors-middleware.ts +7 -6
- package/apps/core-server/src/middlewares/error-middleware.ts +7 -4
- package/apps/core-server/src/middlewares/logger-middleware.ts +81 -21
- package/apps/core-server/src/middlewares/notfound-middleware.ts +6 -14
- package/apps/core-server/src/middlewares/serve-static.ts +30 -24
- package/apps/core-server/src/routes/files/router.ts +9 -7
- package/apps/core-server/src/routes/server.ts +30 -36
- package/apps/core-server/tsdown.config.ts +4 -3
- package/biome.json +58 -60
- package/configs/eslint-config/package.json +16 -19
- package/configs/eslint-config/src/configs/base.ts +185 -225
- package/configs/eslint-config/src/configs/extend.ts +3 -0
- package/configs/eslint-config/src/configs/frontend.ts +81 -56
- package/configs/eslint-config/src/configs/node.ts +6 -6
- package/configs/eslint-config/src/plugin.ts +1 -0
- package/configs/eslint-config/src/rules/index.ts +8 -12
- package/configs/eslint-config/src/rules/no-json-parse-json-stringify.test.ts +30 -17
- package/configs/eslint-config/src/rules/no-json-parse-json-stringify.ts +52 -49
- package/configs/eslint-config/src/rules/no-uncaught-json-parse.ts +43 -45
- package/configs/tsdown-config/package.json +10 -3
- package/configs/typescript-config/package.json +10 -1
- package/configs/typescript-config/tsconfig.common.json +3 -3
- package/configs/vitest-config/dist/base.mjs +1 -0
- package/configs/vitest-config/dist/frontend.mjs +1 -0
- package/configs/vitest-config/dist/node.mjs +1 -0
- package/configs/vitest-config/package.json +12 -0
- package/configs/vitest-config/src/base.ts +17 -29
- package/configs/vitest-config/src/index.ts +1 -0
- package/package.json +21 -13
- package/packages/@repo/constants/eslint.config.ts +4 -0
- package/packages/@repo/constants/package.json +16 -0
- package/packages/@repo/constants/src/index.ts +8 -8
- package/packages/@repo/db/eslint.config.ts +4 -0
- package/packages/@repo/db/package.json +16 -8
- package/packages/@repo/db/src/index.ts +26 -20
- package/packages/@repo/db/src/schema/common.ts +45 -49
- package/packages/@repo/env/eslint.config.ts +4 -0
- package/packages/@repo/env/package.json +39 -0
- package/packages/@repo/env/src/default-env.ts +12 -0
- package/packages/@repo/env/src/define-env.ts +70 -0
- package/packages/@repo/env/src/index.ts +2 -0
- package/packages/@repo/env/src/utils.ts +52 -0
- package/packages/@repo/env/tsconfig.json +7 -0
- package/packages/@repo/lib/eslint.config.ts +4 -0
- package/packages/@repo/lib/package.json +34 -34
- package/packages/@repo/lib/src/bucket-module/file-storage.ts +50 -49
- package/packages/@repo/lib/src/bucket-module/index.ts +3 -0
- package/packages/@repo/lib/src/bucket-module/s3-storage.ts +120 -114
- package/packages/@repo/lib/src/bucket-module/utils.ts +10 -11
- package/packages/@repo/lib/src/{cookie-module.ts → cookie-module/cookie-module.ts} +48 -42
- package/packages/@repo/lib/src/cookie-module/index.ts +1 -0
- package/packages/@repo/lib/src/extra/index.ts +1 -0
- package/packages/@repo/lib/src/extra/pagination-module.ts +35 -0
- package/packages/@repo/lib/src/{token-module.ts → extra/token-module.ts} +12 -5
- package/packages/@repo/lib/src/file-system-module/index.ts +170 -0
- package/packages/@repo/lib/src/{hashing-module.ts → hashing-module/index.ts} +9 -9
- package/packages/@repo/lib/src/index.ts +0 -26
- package/packages/@repo/lib/src/mail-module/index.ts +2 -0
- package/packages/@repo/lib/src/mail-module/mock.ts +8 -8
- package/packages/@repo/lib/src/mail-module/nodemailer.ts +17 -7
- package/packages/@repo/lib/src/notification-module/index.ts +1 -172
- package/packages/@repo/lib/src/notification-module/push-notification.ts +97 -90
- package/packages/@repo/lib/src/{oauth2-client.ts → oauth2-module/index.ts} +107 -109
- package/packages/@repo/lib/src/otp-module/index.ts +91 -0
- package/packages/@repo/lib/src/session-module/index.ts +113 -0
- package/packages/@repo/lib/src/utils.ts +43 -42
- package/packages/@repo/lib/src/validation-module/index.ts +242 -0
- package/packages/@repo/logger/eslint.config.ts +4 -0
- package/packages/@repo/logger/package.json +40 -0
- package/packages/@repo/logger/src/index.ts +2 -0
- package/packages/@repo/logger/src/logger.ts +72 -0
- package/packages/@repo/{lib/src/logger-module → logger/src}/memory-profiler.ts +64 -65
- package/packages/@repo/logger/tsconfig.json +7 -0
- package/packages/@repo/mail/eslint.config.ts +4 -0
- package/packages/@repo/mail/package.json +10 -3
- package/packages/@repo/mail/src/emails/admin/OtpEmail.tsx +169 -168
- package/packages/@repo/mail/src/index.ts +1 -2
- package/packages/@repo/mail/tsconfig.json +3 -3
- package/packages/@repo/redis/dist/index.d.mts +3 -0
- package/packages/@repo/redis/dist/index.mjs +5 -0
- package/packages/@repo/redis/dist/lib/redis-client.d.mts +7 -0
- package/packages/@repo/redis/dist/lib/redis-client.mjs +25 -0
- package/packages/@repo/redis/dist/lib/redis-client.mjs.map +1 -0
- package/packages/@repo/redis/dist/lib/redis-module.d.mts +5 -0
- package/packages/@repo/redis/dist/lib/redis-module.mjs +6 -0
- package/packages/@repo/redis/dist/lib/redis-module.mjs.map +1 -0
- package/packages/@repo/redis/eslint.config.ts +4 -0
- package/packages/@repo/redis/package.json +13 -10
- package/packages/@repo/redis/src/index.ts +2 -2
- package/packages/@repo/redis/src/lib/redis-client.ts +36 -23
- package/packages/@repo/redis/src/lib/redis-module.ts +69 -3
- package/packages/cli/dist/index.mjs +203 -0
- package/packages/cli/eslint.config.ts +4 -0
- package/packages/cli/package.json +44 -0
- package/packages/cli/tsconfig.json +12 -0
- package/packages/cli/tsdown.config.ts +17 -0
- package/packages/ui/components.json +0 -1
- package/packages/ui/eslint.config.ts +4 -0
- package/packages/ui/package.json +16 -3
- package/packages/ui/postcss.config.mjs +9 -9
- package/packages/ui/src/components/lib/utils.ts +53 -53
- package/packages/ui/src/components/ui/alert-dialog.tsx +118 -116
- package/packages/ui/src/components/ui/avatar.tsx +52 -53
- package/packages/ui/src/components/ui/badge.tsx +45 -46
- package/packages/ui/src/components/ui/breadcrumb.tsx +108 -109
- package/packages/ui/src/components/ui/card.tsx +91 -92
- package/packages/ui/src/components/ui/carousel.tsx +243 -243
- package/packages/ui/src/components/ui/checkbox.tsx +32 -32
- package/packages/ui/src/components/ui/command.tsx +144 -155
- package/packages/ui/src/components/ui/dialog.tsx +124 -127
- package/packages/ui/src/components/ui/form.tsx +166 -165
- package/packages/ui/src/components/ui/input-otp.tsx +74 -76
- package/packages/ui/src/components/ui/input.tsx +19 -21
- package/packages/ui/src/components/ui/multiple-select.tsx +4 -4
- package/packages/ui/src/{components/lucide.tsx → lucide.ts} +3 -3
- package/packages/ui/tailwind.config.ts +94 -94
- package/packages/ui/tsconfig.json +7 -1
- package/pnpm-workspace.yaml +41 -1
- package/turbo.json +20 -27
- package/apps/core-server/eslint.config.mjs +0 -47
- package/configs/eslint-config/src/rules/no-dynamic-import-template.ts +0 -32
- package/configs/eslint-config/src/rules/no-plain-errors.ts +0 -50
- package/configs/eslint-config/tsdown.config.ts +0 -11
- package/packages/@repo/constants/eslint.config.mjs +0 -21
- package/packages/@repo/db/eslint.config.mjs +0 -21
- package/packages/@repo/lib/eslint.config.mjs +0 -49
- package/packages/@repo/lib/src/command-module.ts +0 -77
- package/packages/@repo/lib/src/constants.ts +0 -3
- package/packages/@repo/lib/src/custom-type.ts +0 -54
- package/packages/@repo/lib/src/env.ts +0 -13
- package/packages/@repo/lib/src/file-system/index.ts +0 -90
- package/packages/@repo/lib/src/logger-module/log-config.ts +0 -16
- package/packages/@repo/lib/src/logger-module/logger.ts +0 -78
- package/packages/@repo/lib/src/mail-module/api.ts +0 -0
- package/packages/@repo/lib/src/otp-module.ts +0 -98
- package/packages/@repo/lib/src/pagination-module.ts +0 -49
- package/packages/@repo/lib/src/user-session.ts +0 -117
- package/packages/@repo/lib/src/validation-module.ts +0 -187
- package/packages/@repo/mail/tsconfig.build.json +0 -14
- package/packages/@repo/mail/tsdown.config.ts +0 -9
- package/packages/@repo/redis/eslint.config.mjs +0 -8
- package/packages/ui/eslint.config.mjs +0 -18
|
@@ -1,243 +1,243 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import useEmblaCarousel, {
|
|
4
|
-
type UseEmblaCarouselType,
|
|
5
|
-
} from "embla-carousel-react"
|
|
6
|
-
import { ArrowLeft, ArrowRight } from "lucide-react"
|
|
7
|
-
import * as React from "react"
|
|
8
|
-
|
|
9
|
-
import { Button } from "@/components/ui/button"
|
|
10
|
-
|
|
11
|
-
import { cn } from "../lib/utils"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
type CarouselApi = UseEmblaCarouselType[1]
|
|
15
|
-
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>
|
|
16
|
-
type CarouselOptions = UseCarouselParameters[0]
|
|
17
|
-
type CarouselPlugin = UseCarouselParameters[1]
|
|
18
|
-
|
|
19
|
-
type CarouselProps = {
|
|
20
|
-
opts?: CarouselOptions
|
|
21
|
-
plugins?: CarouselPlugin
|
|
22
|
-
orientation?: "horizontal" | "vertical"
|
|
23
|
-
setApi?: (api: CarouselApi) => void
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
type CarouselContextProps = {
|
|
27
|
-
carouselRef: ReturnType<typeof useEmblaCarousel>[0]
|
|
28
|
-
api: ReturnType<typeof useEmblaCarousel>[1]
|
|
29
|
-
scrollPrev: () => void
|
|
30
|
-
scrollNext: () => void
|
|
31
|
-
canScrollPrev: boolean
|
|
32
|
-
canScrollNext: boolean
|
|
33
|
-
} & CarouselProps
|
|
34
|
-
|
|
35
|
-
const CarouselContext = React.createContext<CarouselContextProps | null>(null)
|
|
36
|
-
|
|
37
|
-
function useCarousel() {
|
|
38
|
-
const context = React.useContext(CarouselContext)
|
|
39
|
-
|
|
40
|
-
if (!context) {
|
|
41
|
-
throw new Error("useCarousel must be used within a <Carousel />")
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return context
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function Carousel({
|
|
48
|
-
orientation = "horizontal",
|
|
49
|
-
opts,
|
|
50
|
-
setApi,
|
|
51
|
-
plugins,
|
|
52
|
-
className,
|
|
53
|
-
children,
|
|
54
|
-
...props
|
|
55
|
-
}: React.ComponentProps<"div"> & CarouselProps) {
|
|
56
|
-
const [carouselRef, api] = useEmblaCarousel(
|
|
57
|
-
{
|
|
58
|
-
...opts,
|
|
59
|
-
axis: orientation === "horizontal" ? "x" : "y",
|
|
60
|
-
},
|
|
61
|
-
plugins
|
|
62
|
-
)
|
|
63
|
-
const [canScrollPrev, setCanScrollPrev] = React.useState(false)
|
|
64
|
-
const [canScrollNext, setCanScrollNext] = React.useState(false)
|
|
65
|
-
|
|
66
|
-
const onSelect = React.useCallback((api: CarouselApi) => {
|
|
67
|
-
if (!api) return
|
|
68
|
-
setCanScrollPrev(api.canScrollPrev())
|
|
69
|
-
setCanScrollNext(api.canScrollNext())
|
|
70
|
-
}, [])
|
|
71
|
-
|
|
72
|
-
const scrollPrev = React.useCallback(() => {
|
|
73
|
-
api?.scrollPrev()
|
|
74
|
-
}, [api])
|
|
75
|
-
|
|
76
|
-
const scrollNext = React.useCallback(() => {
|
|
77
|
-
api?.scrollNext()
|
|
78
|
-
}, [api])
|
|
79
|
-
|
|
80
|
-
const handleKeyDown = React.useCallback(
|
|
81
|
-
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
82
|
-
if (event.key === "ArrowLeft") {
|
|
83
|
-
event.preventDefault()
|
|
84
|
-
scrollPrev()
|
|
85
|
-
} else if (event.key === "ArrowRight") {
|
|
86
|
-
event.preventDefault()
|
|
87
|
-
scrollNext()
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
[scrollPrev, scrollNext]
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
React.useEffect(() => {
|
|
94
|
-
if (!api || !setApi) return
|
|
95
|
-
setApi(api)
|
|
96
|
-
}, [api, setApi])
|
|
97
|
-
|
|
98
|
-
React.useEffect(() => {
|
|
99
|
-
if (!api) return
|
|
100
|
-
onSelect(api)
|
|
101
|
-
api.on("reInit", onSelect)
|
|
102
|
-
api.on("select", onSelect)
|
|
103
|
-
|
|
104
|
-
return () => {
|
|
105
|
-
api?.off("select", onSelect)
|
|
106
|
-
}
|
|
107
|
-
}, [api, onSelect])
|
|
108
|
-
|
|
109
|
-
return (
|
|
110
|
-
<CarouselContext.Provider
|
|
111
|
-
value={{
|
|
112
|
-
carouselRef,
|
|
113
|
-
api,
|
|
114
|
-
opts,
|
|
115
|
-
orientation:
|
|
116
|
-
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
|
-
function CarouselContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
138
|
-
const { carouselRef, orientation } = useCarousel()
|
|
139
|
-
|
|
140
|
-
return (
|
|
141
|
-
<div
|
|
142
|
-
ref={carouselRef}
|
|
143
|
-
className="overflow-hidden"
|
|
144
|
-
data-slot="carousel-content"
|
|
145
|
-
>
|
|
146
|
-
<div
|
|
147
|
-
className={cn(
|
|
148
|
-
"flex",
|
|
149
|
-
orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col",
|
|
150
|
-
className
|
|
151
|
-
)}
|
|
152
|
-
{...props}
|
|
153
|
-
/>
|
|
154
|
-
</div>
|
|
155
|
-
)
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function CarouselItem({ className, ...props }: React.ComponentProps<"div">) {
|
|
159
|
-
const { orientation } = useCarousel()
|
|
160
|
-
|
|
161
|
-
return (
|
|
162
|
-
<div
|
|
163
|
-
role="group"
|
|
164
|
-
aria-roledescription="slide"
|
|
165
|
-
data-slot="carousel-item"
|
|
166
|
-
className={cn(
|
|
167
|
-
"min-w-0 shrink-0 grow-0 basis-full",
|
|
168
|
-
orientation === "horizontal" ? "pl-4" : "pt-4",
|
|
169
|
-
className
|
|
170
|
-
)}
|
|
171
|
-
{...props}
|
|
172
|
-
/>
|
|
173
|
-
)
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function CarouselPrevious({
|
|
177
|
-
className,
|
|
178
|
-
variant = "outline",
|
|
179
|
-
size = "icon",
|
|
180
|
-
...props
|
|
181
|
-
}: React.ComponentProps<typeof Button>) {
|
|
182
|
-
const { orientation, scrollPrev, canScrollPrev } = useCarousel()
|
|
183
|
-
|
|
184
|
-
return (
|
|
185
|
-
<Button
|
|
186
|
-
data-slot="carousel-previous"
|
|
187
|
-
variant={variant}
|
|
188
|
-
size={size}
|
|
189
|
-
className={cn(
|
|
190
|
-
"absolute size-8 rounded-full",
|
|
191
|
-
orientation === "horizontal"
|
|
192
|
-
? "top-1/2 -left-12 -translate-y-1/2"
|
|
193
|
-
: "-top-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
194
|
-
className
|
|
195
|
-
)}
|
|
196
|
-
disabled={!canScrollPrev}
|
|
197
|
-
onClick={scrollPrev}
|
|
198
|
-
{...props}
|
|
199
|
-
>
|
|
200
|
-
<ArrowLeft />
|
|
201
|
-
<span className="sr-only">Previous slide</span>
|
|
202
|
-
</Button>
|
|
203
|
-
)
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
function CarouselNext({
|
|
207
|
-
className,
|
|
208
|
-
variant = "outline",
|
|
209
|
-
size = "icon",
|
|
210
|
-
...props
|
|
211
|
-
}: React.ComponentProps<typeof Button>) {
|
|
212
|
-
const { orientation, scrollNext, canScrollNext } = useCarousel()
|
|
213
|
-
|
|
214
|
-
return (
|
|
215
|
-
<Button
|
|
216
|
-
data-slot="carousel-next"
|
|
217
|
-
variant={variant}
|
|
218
|
-
size={size}
|
|
219
|
-
className={cn(
|
|
220
|
-
"absolute size-8 rounded-full",
|
|
221
|
-
orientation === "horizontal"
|
|
222
|
-
? "top-1/2 -right-12 -translate-y-1/2"
|
|
223
|
-
: "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
224
|
-
className
|
|
225
|
-
)}
|
|
226
|
-
disabled={!canScrollNext}
|
|
227
|
-
onClick={scrollNext}
|
|
228
|
-
{...props}
|
|
229
|
-
>
|
|
230
|
-
<ArrowRight />
|
|
231
|
-
<span className="sr-only">Next slide</span>
|
|
232
|
-
</Button>
|
|
233
|
-
)
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
export {
|
|
237
|
-
type CarouselApi,
|
|
238
|
-
Carousel,
|
|
239
|
-
CarouselContent,
|
|
240
|
-
CarouselItem,
|
|
241
|
-
CarouselPrevious,
|
|
242
|
-
CarouselNext,
|
|
243
|
-
}
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import useEmblaCarousel, {
|
|
4
|
+
type UseEmblaCarouselType,
|
|
5
|
+
} from "embla-carousel-react"
|
|
6
|
+
import { ArrowLeft, ArrowRight } from "lucide-react"
|
|
7
|
+
import * as React from "react"
|
|
8
|
+
|
|
9
|
+
import { Button } from "@/components/ui/button"
|
|
10
|
+
|
|
11
|
+
import { cn } from "../lib/utils"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
type CarouselApi = UseEmblaCarouselType[1]
|
|
15
|
+
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>
|
|
16
|
+
type CarouselOptions = UseCarouselParameters[0]
|
|
17
|
+
type CarouselPlugin = UseCarouselParameters[1]
|
|
18
|
+
|
|
19
|
+
type CarouselProps = {
|
|
20
|
+
opts?: CarouselOptions;
|
|
21
|
+
plugins?: CarouselPlugin;
|
|
22
|
+
orientation?: "horizontal" | "vertical";
|
|
23
|
+
setApi?: (api: CarouselApi) => void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type CarouselContextProps = {
|
|
27
|
+
carouselRef: ReturnType<typeof useEmblaCarousel>[0];
|
|
28
|
+
api: ReturnType<typeof useEmblaCarousel>[1];
|
|
29
|
+
scrollPrev: () => void;
|
|
30
|
+
scrollNext: () => void;
|
|
31
|
+
canScrollPrev: boolean;
|
|
32
|
+
canScrollNext: boolean;
|
|
33
|
+
} & CarouselProps
|
|
34
|
+
|
|
35
|
+
const CarouselContext = React.createContext<CarouselContextProps | null>(null)
|
|
36
|
+
|
|
37
|
+
function useCarousel() {
|
|
38
|
+
const context = React.useContext(CarouselContext)
|
|
39
|
+
|
|
40
|
+
if (!context) {
|
|
41
|
+
throw new Error("useCarousel must be used within a <Carousel />")
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return context
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function Carousel({
|
|
48
|
+
orientation = "horizontal",
|
|
49
|
+
opts,
|
|
50
|
+
setApi,
|
|
51
|
+
plugins,
|
|
52
|
+
className,
|
|
53
|
+
children,
|
|
54
|
+
...props
|
|
55
|
+
}: React.ComponentProps<"div"> & CarouselProps) {
|
|
56
|
+
const [carouselRef, api] = useEmblaCarousel(
|
|
57
|
+
{
|
|
58
|
+
...opts,
|
|
59
|
+
axis: orientation === "horizontal" ? "x" : "y",
|
|
60
|
+
},
|
|
61
|
+
plugins
|
|
62
|
+
)
|
|
63
|
+
const [canScrollPrev, setCanScrollPrev] = React.useState(false)
|
|
64
|
+
const [canScrollNext, setCanScrollNext] = React.useState(false)
|
|
65
|
+
|
|
66
|
+
const onSelect = React.useCallback((api: CarouselApi) => {
|
|
67
|
+
if (!api) return
|
|
68
|
+
setCanScrollPrev(api.canScrollPrev())
|
|
69
|
+
setCanScrollNext(api.canScrollNext())
|
|
70
|
+
}, [])
|
|
71
|
+
|
|
72
|
+
const scrollPrev = React.useCallback(() => {
|
|
73
|
+
api?.scrollPrev()
|
|
74
|
+
}, [api])
|
|
75
|
+
|
|
76
|
+
const scrollNext = React.useCallback(() => {
|
|
77
|
+
api?.scrollNext()
|
|
78
|
+
}, [api])
|
|
79
|
+
|
|
80
|
+
const handleKeyDown = React.useCallback(
|
|
81
|
+
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
82
|
+
if (event.key === "ArrowLeft") {
|
|
83
|
+
event.preventDefault()
|
|
84
|
+
scrollPrev()
|
|
85
|
+
} else if (event.key === "ArrowRight") {
|
|
86
|
+
event.preventDefault()
|
|
87
|
+
scrollNext()
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
[scrollPrev, scrollNext]
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
React.useEffect(() => {
|
|
94
|
+
if (!api || !setApi) return
|
|
95
|
+
setApi(api)
|
|
96
|
+
}, [api, setApi])
|
|
97
|
+
|
|
98
|
+
React.useEffect(() => {
|
|
99
|
+
if (!api) return
|
|
100
|
+
onSelect(api)
|
|
101
|
+
api.on("reInit", onSelect)
|
|
102
|
+
api.on("select", onSelect)
|
|
103
|
+
|
|
104
|
+
return () => {
|
|
105
|
+
api?.off("select", onSelect)
|
|
106
|
+
}
|
|
107
|
+
}, [api, onSelect])
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<CarouselContext.Provider
|
|
111
|
+
value={{
|
|
112
|
+
carouselRef,
|
|
113
|
+
api,
|
|
114
|
+
opts,
|
|
115
|
+
orientation:
|
|
116
|
+
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
|
+
function CarouselContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
138
|
+
const { carouselRef, orientation } = useCarousel()
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
<div
|
|
142
|
+
ref={carouselRef}
|
|
143
|
+
className="overflow-hidden"
|
|
144
|
+
data-slot="carousel-content"
|
|
145
|
+
>
|
|
146
|
+
<div
|
|
147
|
+
className={cn(
|
|
148
|
+
"flex",
|
|
149
|
+
orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col",
|
|
150
|
+
className
|
|
151
|
+
)}
|
|
152
|
+
{...props}
|
|
153
|
+
/>
|
|
154
|
+
</div>
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function CarouselItem({ className, ...props }: React.ComponentProps<"div">) {
|
|
159
|
+
const { orientation } = useCarousel()
|
|
160
|
+
|
|
161
|
+
return (
|
|
162
|
+
<div
|
|
163
|
+
role="group"
|
|
164
|
+
aria-roledescription="slide"
|
|
165
|
+
data-slot="carousel-item"
|
|
166
|
+
className={cn(
|
|
167
|
+
"min-w-0 shrink-0 grow-0 basis-full",
|
|
168
|
+
orientation === "horizontal" ? "pl-4" : "pt-4",
|
|
169
|
+
className
|
|
170
|
+
)}
|
|
171
|
+
{...props}
|
|
172
|
+
/>
|
|
173
|
+
)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function CarouselPrevious({
|
|
177
|
+
className,
|
|
178
|
+
variant = "outline",
|
|
179
|
+
size = "icon",
|
|
180
|
+
...props
|
|
181
|
+
}: React.ComponentProps<typeof Button>) {
|
|
182
|
+
const { orientation, scrollPrev, canScrollPrev } = useCarousel()
|
|
183
|
+
|
|
184
|
+
return (
|
|
185
|
+
<Button
|
|
186
|
+
data-slot="carousel-previous"
|
|
187
|
+
variant={variant}
|
|
188
|
+
size={size}
|
|
189
|
+
className={cn(
|
|
190
|
+
"absolute size-8 rounded-full",
|
|
191
|
+
orientation === "horizontal"
|
|
192
|
+
? "top-1/2 -left-12 -translate-y-1/2"
|
|
193
|
+
: "-top-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
194
|
+
className
|
|
195
|
+
)}
|
|
196
|
+
disabled={!canScrollPrev}
|
|
197
|
+
onClick={scrollPrev}
|
|
198
|
+
{...props}
|
|
199
|
+
>
|
|
200
|
+
<ArrowLeft />
|
|
201
|
+
<span className="sr-only">Previous slide</span>
|
|
202
|
+
</Button>
|
|
203
|
+
)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function CarouselNext({
|
|
207
|
+
className,
|
|
208
|
+
variant = "outline",
|
|
209
|
+
size = "icon",
|
|
210
|
+
...props
|
|
211
|
+
}: React.ComponentProps<typeof Button>) {
|
|
212
|
+
const { orientation, scrollNext, canScrollNext } = useCarousel()
|
|
213
|
+
|
|
214
|
+
return (
|
|
215
|
+
<Button
|
|
216
|
+
data-slot="carousel-next"
|
|
217
|
+
variant={variant}
|
|
218
|
+
size={size}
|
|
219
|
+
className={cn(
|
|
220
|
+
"absolute size-8 rounded-full",
|
|
221
|
+
orientation === "horizontal"
|
|
222
|
+
? "top-1/2 -right-12 -translate-y-1/2"
|
|
223
|
+
: "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
224
|
+
className
|
|
225
|
+
)}
|
|
226
|
+
disabled={!canScrollNext}
|
|
227
|
+
onClick={scrollNext}
|
|
228
|
+
{...props}
|
|
229
|
+
>
|
|
230
|
+
<ArrowRight />
|
|
231
|
+
<span className="sr-only">Next slide</span>
|
|
232
|
+
</Button>
|
|
233
|
+
)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export {
|
|
237
|
+
type CarouselApi,
|
|
238
|
+
Carousel,
|
|
239
|
+
CarouselContent,
|
|
240
|
+
CarouselItem,
|
|
241
|
+
CarouselPrevious,
|
|
242
|
+
CarouselNext,
|
|
243
|
+
}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
4
|
-
import { CheckIcon } from "lucide-react";
|
|
5
|
-
import type * as React from "react";
|
|
6
|
-
|
|
7
|
-
import { cn } from "../lib/utils";
|
|
8
|
-
|
|
9
|
-
function Checkbox({
|
|
10
|
-
className,
|
|
11
|
-
...props
|
|
12
|
-
}: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
|
|
13
|
-
return (
|
|
14
|
-
<CheckboxPrimitive.Root
|
|
15
|
-
data-slot="checkbox"
|
|
16
|
-
className={cn(
|
|
17
|
-
"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",
|
|
18
|
-
className
|
|
19
|
-
)}
|
|
20
|
-
{...props}
|
|
21
|
-
>
|
|
22
|
-
<CheckboxPrimitive.Indicator
|
|
23
|
-
data-slot="checkbox-indicator"
|
|
24
|
-
className="flex items-center justify-center text-current transition-none"
|
|
25
|
-
>
|
|
26
|
-
<CheckIcon className="size-3.5" />
|
|
27
|
-
</CheckboxPrimitive.Indicator>
|
|
28
|
-
</CheckboxPrimitive.Root>
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export { Checkbox };
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
4
|
+
import { CheckIcon } from "lucide-react";
|
|
5
|
+
import type * as React from "react";
|
|
6
|
+
|
|
7
|
+
import { cn } from "../lib/utils";
|
|
8
|
+
|
|
9
|
+
function Checkbox({
|
|
10
|
+
className,
|
|
11
|
+
...props
|
|
12
|
+
}: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
|
|
13
|
+
return (
|
|
14
|
+
<CheckboxPrimitive.Root
|
|
15
|
+
data-slot="checkbox"
|
|
16
|
+
className={cn(
|
|
17
|
+
"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",
|
|
18
|
+
className
|
|
19
|
+
)}
|
|
20
|
+
{...props}
|
|
21
|
+
>
|
|
22
|
+
<CheckboxPrimitive.Indicator
|
|
23
|
+
data-slot="checkbox-indicator"
|
|
24
|
+
className="flex items-center justify-center text-current transition-none"
|
|
25
|
+
>
|
|
26
|
+
<CheckIcon className="size-3.5" />
|
|
27
|
+
</CheckboxPrimitive.Indicator>
|
|
28
|
+
</CheckboxPrimitive.Root>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { Checkbox };
|