@arobo/react 1.1.3 → 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.
@@ -22,5 +22,7 @@ type CarouselPreviousProps = React.ComponentProps<typeof Button>;
22
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
24
  declare function CarouselNext({ className, size, variant, children, ...props }: CarouselNextProps): import("react/jsx-runtime").JSX.Element;
25
- export { Carousel as CarouselRoot, CarouselContent, CarouselItem, CarouselPrevious, CarouselNext, };
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, };
@@ -133,7 +133,7 @@ function CarouselPrevious({
133
133
  isDisabled: !canScrollPrev,
134
134
  size: size,
135
135
  variant: variant,
136
- 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),
137
137
  onClick: scrollPrev,
138
138
  ...props,
139
139
  children: children ? children : /*#__PURE__*/jsx(ArrowLeft, {})
@@ -156,11 +156,41 @@ function CarouselNext({
156
156
  isDisabled: !canScrollNext,
157
157
  size: size,
158
158
  variant: variant,
159
- 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),
160
160
  onClick: scrollNext,
161
161
  ...props,
162
162
  children: children ? children : /*#__PURE__*/jsx(ArrowRight, {})
163
163
  });
164
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))
193
+ });
194
+ }
165
195
 
166
- 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arobo/react",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "files": [