@tapcart/mobile-components 0.1.2 → 0.1.4

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.
@@ -1,262 +0,0 @@
1
- "use client"
2
-
3
- import * as React from "react"
4
- import useEmblaCarousel, {
5
- type UseEmblaCarouselType,
6
- } from "embla-carousel-react"
7
- import { ArrowLeft, ArrowRight } from "lucide-react"
8
-
9
- import { cn } from "@/lib/utils"
10
- import { Button } from "@/components/ui/button"
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
- const Carousel = React.forwardRef<
46
- HTMLDivElement,
47
- React.HTMLAttributes<HTMLDivElement> & CarouselProps
48
- >(
49
- (
50
- {
51
- orientation = "horizontal",
52
- opts,
53
- setApi,
54
- plugins,
55
- className,
56
- children,
57
- ...props
58
- },
59
- ref
60
- ) => {
61
- const [carouselRef, api] = useEmblaCarousel(
62
- {
63
- ...opts,
64
- axis: orientation === "horizontal" ? "x" : "y",
65
- },
66
- plugins
67
- )
68
- const [canScrollPrev, setCanScrollPrev] = React.useState(false)
69
- const [canScrollNext, setCanScrollNext] = React.useState(false)
70
-
71
- const onSelect = React.useCallback((api: CarouselApi) => {
72
- if (!api) {
73
- return
74
- }
75
-
76
- setCanScrollPrev(api.canScrollPrev())
77
- setCanScrollNext(api.canScrollNext())
78
- }, [])
79
-
80
- const scrollPrev = React.useCallback(() => {
81
- api?.scrollPrev()
82
- }, [api])
83
-
84
- const scrollNext = React.useCallback(() => {
85
- api?.scrollNext()
86
- }, [api])
87
-
88
- const handleKeyDown = React.useCallback(
89
- (event: React.KeyboardEvent<HTMLDivElement>) => {
90
- if (event.key === "ArrowLeft") {
91
- event.preventDefault()
92
- scrollPrev()
93
- } else if (event.key === "ArrowRight") {
94
- event.preventDefault()
95
- scrollNext()
96
- }
97
- },
98
- [scrollPrev, scrollNext]
99
- )
100
-
101
- React.useEffect(() => {
102
- if (!api || !setApi) {
103
- return
104
- }
105
-
106
- setApi(api)
107
- }, [api, setApi])
108
-
109
- React.useEffect(() => {
110
- if (!api) {
111
- return
112
- }
113
-
114
- onSelect(api)
115
- api.on("reInit", onSelect)
116
- api.on("select", onSelect)
117
-
118
- return () => {
119
- api?.off("select", onSelect)
120
- }
121
- }, [api, onSelect])
122
-
123
- return (
124
- <CarouselContext.Provider
125
- value={{
126
- carouselRef,
127
- api: api,
128
- opts,
129
- orientation:
130
- orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
131
- scrollPrev,
132
- scrollNext,
133
- canScrollPrev,
134
- canScrollNext,
135
- }}
136
- >
137
- <div
138
- ref={ref}
139
- onKeyDownCapture={handleKeyDown}
140
- className={cn("relative", className)}
141
- role="region"
142
- aria-roledescription="carousel"
143
- {...props}
144
- >
145
- {children}
146
- </div>
147
- </CarouselContext.Provider>
148
- )
149
- }
150
- )
151
- Carousel.displayName = "Carousel"
152
-
153
- const CarouselContent = React.forwardRef<
154
- HTMLDivElement,
155
- React.HTMLAttributes<HTMLDivElement>
156
- >(({ className, ...props }, ref) => {
157
- const { carouselRef, orientation } = useCarousel()
158
-
159
- return (
160
- <div ref={carouselRef} className="overflow-hidden">
161
- <div
162
- ref={ref}
163
- className={cn(
164
- "flex",
165
- orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col",
166
- className
167
- )}
168
- {...props}
169
- />
170
- </div>
171
- )
172
- })
173
- CarouselContent.displayName = "CarouselContent"
174
-
175
- const CarouselItem = React.forwardRef<
176
- HTMLDivElement,
177
- React.HTMLAttributes<HTMLDivElement>
178
- >(({ className, ...props }, ref) => {
179
- const { orientation } = useCarousel()
180
-
181
- return (
182
- <div
183
- ref={ref}
184
- role="group"
185
- aria-roledescription="slide"
186
- className={cn(
187
- "min-w-0 shrink-0 grow-0 basis-full",
188
- orientation === "horizontal" ? "pl-4" : "pt-4",
189
- className
190
- )}
191
- {...props}
192
- />
193
- )
194
- })
195
- CarouselItem.displayName = "CarouselItem"
196
-
197
- const CarouselPrevious = React.forwardRef<
198
- HTMLButtonElement,
199
- React.ComponentProps<typeof Button>
200
- >(({ className, variant = "outline", size = "icon", ...props }, ref) => {
201
- const { orientation, scrollPrev, canScrollPrev } = useCarousel()
202
-
203
- return (
204
- <Button
205
- ref={ref}
206
- variant={variant}
207
- size={size}
208
- className={cn(
209
- "absolute h-8 w-8 rounded-full",
210
- orientation === "horizontal"
211
- ? "-left-12 top-1/2 -translate-y-1/2"
212
- : "-top-12 left-1/2 -translate-x-1/2 rotate-90",
213
- className
214
- )}
215
- disabled={!canScrollPrev}
216
- onClick={scrollPrev}
217
- {...props}
218
- >
219
- <ArrowLeft className="h-4 w-4" />
220
- <span className="sr-only">Previous slide</span>
221
- </Button>
222
- )
223
- })
224
- CarouselPrevious.displayName = "CarouselPrevious"
225
-
226
- const CarouselNext = React.forwardRef<
227
- HTMLButtonElement,
228
- React.ComponentProps<typeof Button>
229
- >(({ className, variant = "outline", size = "icon", ...props }, ref) => {
230
- const { orientation, scrollNext, canScrollNext } = useCarousel()
231
-
232
- return (
233
- <Button
234
- ref={ref}
235
- variant={variant}
236
- size={size}
237
- className={cn(
238
- "absolute h-8 w-8 rounded-full",
239
- orientation === "horizontal"
240
- ? "-right-12 top-1/2 -translate-y-1/2"
241
- : "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
242
- className
243
- )}
244
- disabled={!canScrollNext}
245
- onClick={scrollNext}
246
- {...props}
247
- >
248
- <ArrowRight className="h-4 w-4" />
249
- <span className="sr-only">Next slide</span>
250
- </Button>
251
- )
252
- })
253
- CarouselNext.displayName = "CarouselNext"
254
-
255
- export {
256
- type CarouselApi,
257
- Carousel,
258
- CarouselContent,
259
- CarouselItem,
260
- CarouselPrevious,
261
- CarouselNext,
262
- }
@@ -1,24 +0,0 @@
1
- import * as React from "react"
2
- import { cva, type VariantProps } from "class-variance-authority"
3
-
4
- import { cn } from "@/lib/utils"
5
-
6
- const containerVariants = cva("container", {
7
- variants: {
8
- variant: {
9
- spaced: "my-3",
10
- },
11
- },
12
- })
13
-
14
- export interface ContainerProps
15
- extends React.HTMLAttributes<HTMLDivElement>,
16
- VariantProps<typeof containerVariants> {}
17
-
18
- function Container({ className, variant, ...props }: ContainerProps) {
19
- return (
20
- <div className={cn(containerVariants({ variant }), className)} {...props} />
21
- )
22
- }
23
-
24
- export { Container, containerVariants }
@@ -1,38 +0,0 @@
1
- import * as React from "react"
2
- import { cva, type VariantProps } from "class-variance-authority"
3
- import { Container } from "./container"
4
-
5
- import { cn } from "@/lib/utils"
6
-
7
- interface GridType {
8
- className: any
9
- children: React.ReactNode
10
- }
11
-
12
- const gridVariants = cva("grid", {
13
- variants: {
14
- columns: {
15
- 1: "grid-cols-1 gap-y-[7px]",
16
- 2: "grid-cols-2 gap-x-[7px] gap-y-[7px]",
17
- 3: "grid-cols-3 gap-x-[7px] gap-y-[7px]",
18
- 4: "grid-cols-4 gap-x-[7px] gap-y-[7px]",
19
- },
20
- },
21
- defaultVariants: {
22
- columns: 2,
23
- },
24
- })
25
-
26
- export interface GridProps
27
- extends GridType,
28
- VariantProps<typeof gridVariants> {}
29
-
30
- function Grid({ className, columns, ...props }: GridProps) {
31
- return (
32
- <Container>
33
- <div className={cn(gridVariants({ columns }), className)} {...props} />
34
- </Container>
35
- )
36
- }
37
-
38
- export { Grid, gridVariants }
@@ -1,25 +0,0 @@
1
- import * as React from "react"
2
- import { cva, type VariantProps } from "class-variance-authority"
3
- import { IconUpload, IconPencilMinus } from "@tabler/icons-react"
4
- import { cn } from "@/lib/utils"
5
-
6
- const iconVariants = cva("inline-flex items-center", {
7
- variants: {
8
- variant: {
9
- default: "fill-primary-foreground px-2",
10
- },
11
- },
12
- defaultVariants: {
13
- variant: "default",
14
- },
15
- })
16
-
17
- export interface IconProps
18
- extends React.HTMLAttributes<HTMLDivElement>,
19
- VariantProps<typeof iconVariants> {}
20
-
21
- function Icon({ className, variant, ...props }: IconProps) {
22
- return <div className={cn(iconVariants({ variant }), className)} {...props} />
23
- }
24
-
25
- export { Icon, iconVariants, IconUpload, IconPencilMinus }
@@ -1,25 +0,0 @@
1
- import * as React from "react"
2
-
3
- import { cn } from "@/lib/utils"
4
-
5
- export interface InputProps
6
- extends React.InputHTMLAttributes<HTMLInputElement> {}
7
-
8
- const Input = React.forwardRef<HTMLInputElement, InputProps>(
9
- ({ className, type, ...props }, ref) => {
10
- return (
11
- <input
12
- type={type}
13
- className={cn(
14
- "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
15
- className
16
- )}
17
- ref={ref}
18
- {...props}
19
- />
20
- )
21
- }
22
- )
23
- Input.displayName = "Input"
24
-
25
- export { Input }
@@ -1,26 +0,0 @@
1
- "use client"
2
-
3
- import * as React from "react"
4
- import * as LabelPrimitive from "@radix-ui/react-label"
5
- import { cva, type VariantProps } from "class-variance-authority"
6
-
7
- import { cn } from "@/lib/utils"
8
-
9
- const labelVariants = cva(
10
- "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
11
- )
12
-
13
- const Label = React.forwardRef<
14
- React.ElementRef<typeof LabelPrimitive.Root>,
15
- React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
16
- VariantProps<typeof labelVariants>
17
- >(({ className, ...props }, ref) => (
18
- <LabelPrimitive.Root
19
- ref={ref}
20
- className={cn(labelVariants(), className)}
21
- {...props}
22
- />
23
- ))
24
- Label.displayName = LabelPrimitive.Root.displayName
25
-
26
- export { Label }
@@ -1,32 +0,0 @@
1
- import * as React from "react"
2
- import { cva, type VariantProps } from "class-variance-authority"
3
-
4
- interface MoneyType {
5
- currency: string
6
- locale: string
7
- price: number
8
- }
9
-
10
- const moneyVariants = cva("", {
11
- variants: {},
12
- defaultVariants: {
13
- currency: "USD",
14
- locale: "en-US",
15
- },
16
- })
17
-
18
- export interface MoneyProps
19
- extends MoneyType,
20
- VariantProps<typeof moneyVariants> {}
21
-
22
- function Money({ price, locale, currency, ...props }: MoneyProps) {
23
- const formatter = new Intl.NumberFormat(locale, {
24
- style: "currency",
25
- currency: currency,
26
- })
27
- let formattedPrice = formatter.format(Number(price))
28
-
29
- return <span {...props}>{formattedPrice}</span>
30
- }
31
-
32
- export { Money, moneyVariants }
@@ -1,54 +0,0 @@
1
- "use client"
2
-
3
- import * as React from "react"
4
- import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area"
5
-
6
- import { cn } from "@/lib/utils"
7
-
8
- type Orientation = "horizontal" | "vertical"
9
-
10
- const ScrollArea = React.forwardRef<
11
- React.ElementRef<typeof ScrollAreaPrimitive.Root>,
12
- React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>
13
- >(({ className, children, ...props }, ref) => (
14
- <ScrollAreaPrimitive.Root
15
- ref={ref}
16
- className={cn("relative overflow-hidden", className)}
17
- {...props}
18
- >
19
- <ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">
20
- <div className="flex w-max px-[16px]">{children}</div>
21
- </ScrollAreaPrimitive.Viewport>
22
- <ScrollBar />
23
- <ScrollAreaPrimitive.Corner />
24
- </ScrollAreaPrimitive.Root>
25
- ))
26
- ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName
27
-
28
- const ScrollBar = React.forwardRef<
29
- React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,
30
- React.ComponentPropsWithoutRef<
31
- typeof ScrollAreaPrimitive.ScrollAreaScrollbar
32
- > & {
33
- orientation?: Orientation
34
- }
35
- >(({ className, orientation = "horizontal", ...props }, ref) => (
36
- <ScrollAreaPrimitive.ScrollAreaScrollbar
37
- ref={ref}
38
- orientation={orientation}
39
- className={cn(
40
- "flex touch-none select-none transition-colors",
41
- orientation === "vertical" &&
42
- "h-full w-2.5 border-l border-l-transparent p-[1px]",
43
- orientation === "horizontal" &&
44
- "h-2.5 flex-col border-t border-t-transparent p-[1px] ",
45
- className
46
- )}
47
- {...props}
48
- >
49
- <ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" />
50
- </ScrollAreaPrimitive.ScrollAreaScrollbar>
51
- ))
52
- ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName
53
-
54
- export { ScrollArea, ScrollBar }
@@ -1,31 +0,0 @@
1
- "use client"
2
-
3
- import * as React from "react"
4
- import * as SeparatorPrimitive from "@radix-ui/react-separator"
5
-
6
- import { cn } from "@/lib/utils"
7
-
8
- const Separator = React.forwardRef<
9
- React.ElementRef<typeof SeparatorPrimitive.Root>,
10
- React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
11
- >(
12
- (
13
- { className, orientation = "horizontal", decorative = true, ...props },
14
- ref
15
- ) => (
16
- <SeparatorPrimitive.Root
17
- ref={ref}
18
- decorative={decorative}
19
- orientation={orientation}
20
- className={cn(
21
- "shrink-0 bg-border",
22
- orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
23
- className
24
- )}
25
- {...props}
26
- />
27
- )
28
- )
29
- Separator.displayName = SeparatorPrimitive.Root.displayName
30
-
31
- export { Separator }
@@ -1,15 +0,0 @@
1
- import { cn } from "@/lib/utils"
2
-
3
- function Skeleton({
4
- className,
5
- ...props
6
- }: React.HTMLAttributes<HTMLDivElement>) {
7
- return (
8
- <div
9
- className={cn("animate-pulse rounded-md bg-muted", className)}
10
- {...props}
11
- />
12
- )
13
- }
14
-
15
- export { Skeleton }
@@ -1,29 +0,0 @@
1
- "use client"
2
-
3
- import * as React from "react"
4
- import * as SwitchPrimitives from "@radix-ui/react-switch"
5
-
6
- import { cn } from "@/lib/utils"
7
-
8
- const Switch = React.forwardRef<
9
- React.ElementRef<typeof SwitchPrimitives.Root>,
10
- React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>
11
- >(({ className, ...props }, ref) => (
12
- <SwitchPrimitives.Root
13
- className={cn(
14
- "peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
15
- className
16
- )}
17
- {...props}
18
- ref={ref}
19
- >
20
- <SwitchPrimitives.Thumb
21
- className={cn(
22
- "pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0"
23
- )}
24
- />
25
- </SwitchPrimitives.Root>
26
- ))
27
- Switch.displayName = SwitchPrimitives.Root.displayName
28
-
29
- export { Switch }
@@ -1,28 +0,0 @@
1
- import * as React from "react"
2
- import { cva, type VariantProps } from "class-variance-authority"
3
- import { cn } from "@/lib/utils"
4
-
5
- const textVariants = cva("", {
6
- variants: {
7
- type: {
8
- h1: "text-2xl font-normal text-[#121212]",
9
- h2: "text-xl font-medium text-[#121212]",
10
- body: "text-base font-normal text-[#121212]",
11
- paragraph: "text-sm font-normal text-[#727272]",
12
- label: "text-xs font-normal text-[#727272]",
13
- },
14
- },
15
- defaultVariants: {
16
- type: "body",
17
- },
18
- })
19
-
20
- export interface TextProps
21
- extends React.HTMLAttributes<HTMLParagraphElement>,
22
- VariantProps<typeof textVariants> {}
23
-
24
- function Text({ className, type, ...props }: TextProps) {
25
- return <p className={cn(textVariants({ type }), className)} {...props} />
26
- }
27
-
28
- export { Text, textVariants }