@arobo/react 1.1.2 → 1.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.
|
@@ -19,8 +19,10 @@ declare function CarouselContent({ className, ...props }: CarouselContentProps):
|
|
|
19
19
|
type CarouselItemProps = React.ComponentProps<"div">;
|
|
20
20
|
declare function CarouselItem({ className, ...props }: CarouselItemProps): import("react/jsx-runtime").JSX.Element;
|
|
21
21
|
type CarouselPreviousProps = React.ComponentProps<typeof Button>;
|
|
22
|
-
declare function CarouselPrevious({ className, size, variant, ...props }: CarouselPreviousProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
declare function CarouselPrevious({ className, size, variant, children, ...props }: CarouselPreviousProps): import("react/jsx-runtime").JSX.Element;
|
|
23
23
|
type CarouselNextProps = React.ComponentProps<typeof Button>;
|
|
24
|
-
declare function CarouselNext({ className, size, variant, ...props }: CarouselNextProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
-
|
|
24
|
+
declare function CarouselNext({ className, size, variant, children, ...props }: CarouselNextProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
type CarouselDotsProps = React.ComponentProps<"div">;
|
|
26
|
+
declare function CarouselDots({ className, ...props }: CarouselDotsProps): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export { Carousel as CarouselRoot, CarouselContent, CarouselItem, CarouselPrevious, CarouselNext, CarouselDots, };
|
|
26
28
|
export type { CarouselProps as CarouselRootProps, CarouselContentProps, CarouselItemProps, CarouselPreviousProps, CarouselNextProps, };
|
|
@@ -3,7 +3,7 @@ import { ArrowRight, ArrowLeft } from 'lucide-react';
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { cn } from 'tailwind-variants';
|
|
5
5
|
import { Button } from '../button/index.js';
|
|
6
|
-
import { jsx
|
|
6
|
+
import { jsx } from 'react/jsx-runtime';
|
|
7
7
|
|
|
8
8
|
const CarouselContext = /*#__PURE__*/React.createContext(null);
|
|
9
9
|
function useCarousel() {
|
|
@@ -120,6 +120,7 @@ function CarouselPrevious({
|
|
|
120
120
|
className,
|
|
121
121
|
size = "md",
|
|
122
122
|
variant = "outline",
|
|
123
|
+
children,
|
|
123
124
|
...props
|
|
124
125
|
}) {
|
|
125
126
|
const {
|
|
@@ -127,24 +128,22 @@ function CarouselPrevious({
|
|
|
127
128
|
scrollPrev,
|
|
128
129
|
canScrollPrev
|
|
129
130
|
} = useCarousel();
|
|
130
|
-
return /*#__PURE__*/
|
|
131
|
+
return /*#__PURE__*/jsx(Button, {
|
|
131
132
|
"data-slot": "carousel-previous",
|
|
132
133
|
isDisabled: !canScrollPrev,
|
|
133
134
|
size: size,
|
|
134
135
|
variant: variant,
|
|
135
|
-
className: cn("absolute size-8 rounded-full", orientation === "horizontal" ? "top-1/2 -left-12 -translate-y-1/2" : "-top-12 left-1/2 -translate-x-1/2 rotate-90", className),
|
|
136
|
+
className: cn("absolute size-8 rounded-full hover:bg-accent hover:text-white transition-colors", orientation === "horizontal" ? "top-1/2 -left-12 -translate-y-1/2" : "-top-12 left-1/2 -translate-x-1/2 rotate-90", className),
|
|
136
137
|
onClick: scrollPrev,
|
|
137
138
|
...props,
|
|
138
|
-
children:
|
|
139
|
-
className: "sr-only",
|
|
140
|
-
children: "Previous slide"
|
|
141
|
-
})]
|
|
139
|
+
children: children ? children : /*#__PURE__*/jsx(ArrowLeft, {})
|
|
142
140
|
});
|
|
143
141
|
}
|
|
144
142
|
function CarouselNext({
|
|
145
143
|
className,
|
|
146
144
|
size = "md",
|
|
147
145
|
variant = "outline",
|
|
146
|
+
children,
|
|
148
147
|
...props
|
|
149
148
|
}) {
|
|
150
149
|
const {
|
|
@@ -152,19 +151,46 @@ function CarouselNext({
|
|
|
152
151
|
scrollNext,
|
|
153
152
|
canScrollNext
|
|
154
153
|
} = useCarousel();
|
|
155
|
-
return /*#__PURE__*/
|
|
154
|
+
return /*#__PURE__*/jsx(Button, {
|
|
156
155
|
"data-slot": "carousel-next",
|
|
157
156
|
isDisabled: !canScrollNext,
|
|
158
157
|
size: size,
|
|
159
158
|
variant: variant,
|
|
160
|
-
className: cn("absolute size-8 rounded-full", orientation === "horizontal" ? "top-1/2 -right-12 -translate-y-1/2" : "-bottom-12 left-1/2 -translate-x-1/2 rotate-90", className),
|
|
159
|
+
className: cn("absolute size-8 rounded-full hover:bg-accent hover:text-white transition-colors", orientation === "horizontal" ? "top-1/2 -right-12 -translate-y-1/2" : "-bottom-12 left-1/2 -translate-x-1/2 rotate-90", className),
|
|
161
160
|
onClick: scrollNext,
|
|
162
161
|
...props,
|
|
163
|
-
children:
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
162
|
+
children: children ? children : /*#__PURE__*/jsx(ArrowRight, {})
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
function CarouselDots({
|
|
166
|
+
className,
|
|
167
|
+
...props
|
|
168
|
+
}) {
|
|
169
|
+
const {
|
|
170
|
+
api,
|
|
171
|
+
orientation
|
|
172
|
+
} = useCarousel();
|
|
173
|
+
const [scrollSnaps, setScrollSnaps] = React.useState([]);
|
|
174
|
+
const [selectedIndex, setSelectedIndex] = React.useState(0);
|
|
175
|
+
React.useEffect(() => {
|
|
176
|
+
if (!api) return;
|
|
177
|
+
setScrollSnaps(api.scrollSnapList());
|
|
178
|
+
setSelectedIndex(api.selectedScrollSnap());
|
|
179
|
+
api.on("select", () => setSelectedIndex(api.selectedScrollSnap()));
|
|
180
|
+
return () => {
|
|
181
|
+
api?.off("select", () => setSelectedIndex(api.selectedScrollSnap()));
|
|
182
|
+
};
|
|
183
|
+
}, [api]);
|
|
184
|
+
return /*#__PURE__*/jsx("div", {
|
|
185
|
+
className: cn("flex justify-center gap-2", orientation === "vertical" ? "flex-col" : "", className),
|
|
186
|
+
"data-slot": "carousel-dots",
|
|
187
|
+
...props,
|
|
188
|
+
children: scrollSnaps.map((_, index) => /*#__PURE__*/jsx("div", {
|
|
189
|
+
className: cn("h-3 w-3 rounded-full transition-all cursor-pointer mt-4 border", selectedIndex === index ? "bg-accent" : "bg-gray-100"),
|
|
190
|
+
onClick: () => api?.scrollTo(index),
|
|
191
|
+
"aria-label": `Go to slide ${index + 1}`
|
|
192
|
+
}, index))
|
|
167
193
|
});
|
|
168
194
|
}
|
|
169
195
|
|
|
170
|
-
export { CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, Carousel as CarouselRoot };
|
|
196
|
+
export { CarouselContent, CarouselDots, CarouselItem, CarouselNext, CarouselPrevious, Carousel as CarouselRoot };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, CarouselRoot } from "./carousel";
|
|
1
|
+
import { CarouselContent, CarouselDots, CarouselItem, CarouselNext, CarouselPrevious, CarouselRoot } from "./carousel";
|
|
2
2
|
export declare const Carousel: typeof CarouselRoot & {
|
|
3
3
|
Content: typeof CarouselContent;
|
|
4
4
|
Item: typeof CarouselItem;
|
|
5
5
|
Previous: typeof CarouselPrevious;
|
|
6
6
|
Next: typeof CarouselNext;
|
|
7
|
+
Dot: typeof CarouselDots;
|
|
7
8
|
};
|
|
8
9
|
export type Carousel = {
|
|
9
10
|
Props: React.ComponentProps<typeof CarouselRoot>;
|
|
@@ -12,6 +13,7 @@ export type Carousel = {
|
|
|
12
13
|
ItemProps: React.ComponentProps<typeof CarouselItem>;
|
|
13
14
|
PreviousProps: React.ComponentProps<typeof CarouselPrevious>;
|
|
14
15
|
NextProps: React.ComponentProps<typeof CarouselNext>;
|
|
16
|
+
DotProps: React.ComponentProps<typeof CarouselDots>;
|
|
15
17
|
};
|
|
16
18
|
export { CarouselRoot, CarouselContent, CarouselItem, CarouselPrevious, CarouselNext, };
|
|
17
19
|
export type { CarouselApi, CarouselRootProps, CarouselContentProps, CarouselItemProps, CarouselPreviousProps, CarouselNextProps, } from "./carousel";
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { CarouselRoot as Carousel$1, CarouselNext, CarouselPrevious, CarouselItem, CarouselContent } from './carousel.js';
|
|
1
|
+
import { CarouselRoot as Carousel$1, CarouselDots, CarouselNext, CarouselPrevious, CarouselItem, CarouselContent } from './carousel.js';
|
|
2
2
|
|
|
3
3
|
const Carousel = Object.assign(Carousel$1, {
|
|
4
4
|
Content: CarouselContent,
|
|
5
5
|
Item: CarouselItem,
|
|
6
6
|
Previous: CarouselPrevious,
|
|
7
|
-
Next: CarouselNext
|
|
7
|
+
Next: CarouselNext,
|
|
8
|
+
Dot: CarouselDots
|
|
8
9
|
});
|
|
9
10
|
|
|
10
11
|
export { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, Carousel$1 as CarouselRoot };
|