@mbao01/common 0.0.18 → 0.0.19

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.
Files changed (37) hide show
  1. package/dist/types/components/Accordion/Accordion.d.ts +10 -0
  2. package/dist/types/components/Accordion/constants.d.ts +3 -0
  3. package/dist/types/components/Accordion/index.d.ts +1 -0
  4. package/dist/types/components/Accordion/types.d.ts +6 -0
  5. package/dist/types/components/Carousel/Carousel.d.ts +27 -0
  6. package/dist/types/components/Carousel/CarouselContext.d.ts +3 -0
  7. package/dist/types/components/Carousel/constants.d.ts +12 -0
  8. package/dist/types/components/Carousel/index.d.ts +1 -0
  9. package/dist/types/components/Carousel/types.d.ts +21 -0
  10. package/dist/types/components/Carousel/useCarousel.d.ts +1 -0
  11. package/dist/types/components/Collapsible/Collapsible.d.ts +9 -0
  12. package/dist/types/components/Collapsible/index.d.ts +1 -0
  13. package/dist/types/components/Collapsible/types.d.ts +3 -0
  14. package/dist/types/components/HoverCard/HoverCard.d.ts +9 -0
  15. package/dist/types/components/HoverCard/constants.d.ts +1 -0
  16. package/dist/types/components/HoverCard/index.d.ts +1 -0
  17. package/dist/types/components/HoverCard/types.d.ts +3 -0
  18. package/dist/types/index.d.ts +5 -1
  19. package/package.json +6 -2
  20. package/src/components/Accordion/Accordion.tsx +68 -0
  21. package/src/components/Accordion/constants.ts +11 -0
  22. package/src/components/Accordion/index.ts +1 -0
  23. package/src/components/Accordion/types.ts +17 -0
  24. package/src/components/Carousel/Carousel.tsx +204 -0
  25. package/src/components/Carousel/CarouselContext.ts +4 -0
  26. package/src/components/Carousel/constants.ts +58 -0
  27. package/src/components/Carousel/index.ts +1 -0
  28. package/src/components/Carousel/types.ts +24 -0
  29. package/src/components/Carousel/useCarousel.ts +12 -0
  30. package/src/components/Collapsible/Collapsible.tsx +13 -0
  31. package/src/components/Collapsible/index.ts +1 -0
  32. package/src/components/Collapsible/types.ts +5 -0
  33. package/src/components/HoverCard/HoverCard.tsx +30 -0
  34. package/src/components/HoverCard/constants.ts +5 -0
  35. package/src/components/HoverCard/index.ts +1 -0
  36. package/src/components/HoverCard/types.ts +5 -0
  37. package/src/index.ts +5 -1
@@ -0,0 +1,10 @@
1
+ import * as React from "react";
2
+ import * as AccordionPrimitive from "@radix-ui/react-accordion";
3
+ import type { AccordionProps } from "./types";
4
+ declare const Accordion: {
5
+ (props: AccordionProps): import("react/jsx-runtime").JSX.Element;
6
+ Item: React.ForwardRefExoticComponent<Omit<AccordionPrimitive.AccordionItemProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
7
+ Trigger: React.ForwardRefExoticComponent<Omit<AccordionPrimitive.AccordionTriggerProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
8
+ Content: React.ForwardRefExoticComponent<Omit<AccordionPrimitive.AccordionContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
9
+ };
10
+ export { Accordion };
@@ -0,0 +1,3 @@
1
+ export declare const getAccordionItemClasses: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
2
+ export declare const getAccordionTriggerClasses: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
3
+ export declare const getAccordionContentClasses: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
@@ -0,0 +1 @@
1
+ export { Accordion } from "./Accordion";
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import * as AccordionPrimitive from "@radix-ui/react-accordion";
3
+ export type AccordionProps = React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Root>;
4
+ export type AccordionContentProps = React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>;
5
+ export type AccordionItemProps = React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>;
6
+ export type AccordionTriggerProps = React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>;
@@ -0,0 +1,27 @@
1
+ /// <reference types="react" />
2
+ import type { CarouselProps } from "./types";
3
+ declare const Carousel: {
4
+ ({ orientation, opts, setApi, plugins, className, children, ...props }: CarouselProps & React.HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
5
+ displayName: string;
6
+ Content: import("react").ForwardRefExoticComponent<import("react").HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
7
+ Item: import("react").ForwardRefExoticComponent<import("react").HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
8
+ Next: import("react").ForwardRefExoticComponent<Omit<import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
9
+ variant?: "accent" | "default" | "error" | "ghost" | "info" | "link" | "neutral" | "primary" | "secondary" | "success" | "warning" | undefined;
10
+ outline?: boolean | undefined;
11
+ wide?: boolean | undefined;
12
+ size?: "xs" | "sm" | "md" | "lg" | undefined;
13
+ isLoading?: boolean | undefined;
14
+ } & {
15
+ as?: "a" | "span" | "p" | undefined;
16
+ } & import("react").RefAttributes<HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
17
+ Previous: import("react").ForwardRefExoticComponent<Omit<import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
18
+ variant?: "accent" | "default" | "error" | "ghost" | "info" | "link" | "neutral" | "primary" | "secondary" | "success" | "warning" | undefined;
19
+ outline?: boolean | undefined;
20
+ wide?: boolean | undefined;
21
+ size?: "xs" | "sm" | "md" | "lg" | undefined;
22
+ isLoading?: boolean | undefined;
23
+ } & {
24
+ as?: "a" | "span" | "p" | undefined;
25
+ } & import("react").RefAttributes<HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
26
+ };
27
+ export { Carousel };
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { type CarouselContextProps } from "./types";
3
+ export declare const CarouselContext: import("react").Context<CarouselContextProps | null>;
@@ -0,0 +1,12 @@
1
+ export declare const getCarouselContentClasses: (props?: ({
2
+ orientation?: "horizontal" | "vertical" | null | undefined;
3
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
4
+ export declare const getCarouselItemClasses: (props?: ({
5
+ orientation?: "horizontal" | "vertical" | null | undefined;
6
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
7
+ export declare const getCarouselNextClasses: (props?: ({
8
+ orientation?: "horizontal" | "vertical" | null | undefined;
9
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
10
+ export declare const getCarouselPreviousClasses: (props?: ({
11
+ orientation?: "horizontal" | "vertical" | null | undefined;
12
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
@@ -0,0 +1 @@
1
+ export { Carousel } from "./Carousel";
@@ -0,0 +1,21 @@
1
+ import { type UseEmblaCarouselType } from "embla-carousel-react";
2
+ import useEmblaCarousel from "embla-carousel-react";
3
+ type UseCarouselParameters = Parameters<typeof useEmblaCarousel>;
4
+ type CarouselOptions = UseCarouselParameters[0];
5
+ type CarouselPlugin = UseCarouselParameters[1];
6
+ export type CarouselApi = UseEmblaCarouselType[1];
7
+ export type CarouselProps = {
8
+ opts?: CarouselOptions;
9
+ plugins?: CarouselPlugin;
10
+ orientation?: "horizontal" | "vertical";
11
+ setApi?: (api: CarouselApi) => void;
12
+ };
13
+ export type CarouselContextProps = {
14
+ carouselRef: ReturnType<typeof useEmblaCarousel>[0];
15
+ api: ReturnType<typeof useEmblaCarousel>[1];
16
+ scrollPrev: () => void;
17
+ scrollNext: () => void;
18
+ canScrollPrev: boolean;
19
+ canScrollNext: boolean;
20
+ } & CarouselProps;
21
+ export {};
@@ -0,0 +1 @@
1
+ export declare function useCarousel(): import("./types").CarouselContextProps;
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
3
+ import { type CollapsibleProps } from "@radix-ui/react-accordion";
4
+ declare const Collapsible: {
5
+ (props: CollapsibleProps): import("react/jsx-runtime").JSX.Element;
6
+ Trigger: import("react").ForwardRefExoticComponent<CollapsiblePrimitive.CollapsibleTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
7
+ Content: import("react").ForwardRefExoticComponent<CollapsiblePrimitive.CollapsibleContentProps & import("react").RefAttributes<HTMLDivElement>>;
8
+ };
9
+ export { Collapsible };
@@ -0,0 +1 @@
1
+ export { Collapsible } from "./Collapsible";
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
3
+ export type CollapsibleProps = React.ComponentPropsWithoutRef<typeof CollapsiblePrimitive.Root>;
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import * as HoverCardPrimitive from "@radix-ui/react-hover-card";
3
+ import { HoverCardProps } from "./types";
4
+ declare const HoverCard: {
5
+ (props: HoverCardProps): import("react/jsx-runtime").JSX.Element;
6
+ Content: import("react").ForwardRefExoticComponent<Omit<HoverCardPrimitive.HoverCardContentProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
7
+ Trigger: import("react").ForwardRefExoticComponent<HoverCardPrimitive.HoverCardTriggerProps & import("react").RefAttributes<HTMLAnchorElement>>;
8
+ };
9
+ export { HoverCard };
@@ -0,0 +1 @@
1
+ export declare const getHoverCardContentClasses: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
@@ -0,0 +1 @@
1
+ export { HoverCard } from "./HoverCard";
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import * as HoverCardPrimitive from "@radix-ui/react-hover-card";
3
+ export type HoverCardProps = React.ComponentPropsWithoutRef<typeof HoverCardPrimitive.Root>;
@@ -2,12 +2,15 @@
2
2
  export * from "./components/Button";
3
3
  export * from "./components/Breadcrumbs";
4
4
  export * from "./components/Toggle";
5
+ export * from "./components/ToggleGroup";
5
6
  /** data display */
7
+ export * from "./components/Accordion";
6
8
  export * from "./components/Alert";
7
9
  export * from "./components/Avatar";
8
10
  export * from "./components/Badge";
9
11
  export * from "./components/Card";
10
12
  export * from "./components/Calendar";
13
+ export * from "./components/Collapsible";
11
14
  export * from "./components/Description";
12
15
  export * from "./components/Progress";
13
16
  export * from "./components/Separator";
@@ -24,6 +27,7 @@ export * from "./components/Skeleton";
24
27
  export * from "./components/Tooltip";
25
28
  /** composable */
26
29
  export * from "./components/AlertDialog";
27
- export * from "./components/Dialog";
28
30
  export * from "./components/Command";
31
+ export * from "./components/Dialog";
32
+ export * from "./components/HoverCard";
29
33
  export * from "./components/Popover";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mbao01/common",
3
3
  "private": false,
4
- "version": "0.0.18",
4
+ "version": "0.0.19",
5
5
  "type": "module",
6
6
  "author": "Ayomide Bakare",
7
7
  "license": "MIT",
@@ -60,10 +60,13 @@
60
60
  "test:coverage": "vitest run --coverage"
61
61
  },
62
62
  "dependencies": {
63
+ "@radix-ui/react-accordion": "^1.1.2",
63
64
  "@radix-ui/react-alert-dialog": "^1.0.5",
64
65
  "@radix-ui/react-avatar": "^1.0.4",
65
66
  "@radix-ui/react-checkbox": "^1.0.4",
67
+ "@radix-ui/react-collapsible": "^1.0.3",
66
68
  "@radix-ui/react-dialog": "^1.0.5",
69
+ "@radix-ui/react-hover-card": "^1.0.7",
67
70
  "@radix-ui/react-icons": "^1.3.0",
68
71
  "@radix-ui/react-label": "^2.0.2",
69
72
  "@radix-ui/react-popover": "^1.0.7",
@@ -81,6 +84,7 @@
81
84
  "cmdk": "^1.0.0",
82
85
  "daisyui": "^4.6.2",
83
86
  "date-fns": "^3.6.0",
87
+ "embla-carousel-react": "^8.0.2",
84
88
  "react-day-picker": "^8.10.0",
85
89
  "react-international-phone": "^4.2.6",
86
90
  "sonner": "^1.4.41",
@@ -132,5 +136,5 @@
132
136
  "react-dom": "^18.2.0",
133
137
  "typescript": "^5.2.2"
134
138
  },
135
- "gitHead": "9bc26c6619e27427b22532be6aa94ea63817c0b1"
139
+ "gitHead": "3bc7cfc3008d4e1a0f47a850aec1055455ec399a"
136
140
  }
@@ -0,0 +1,68 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import * as AccordionPrimitive from "@radix-ui/react-accordion";
5
+ import type {
6
+ AccordionProps,
7
+ AccordionContentProps,
8
+ AccordionItemProps,
9
+ AccordionTriggerProps,
10
+ } from "./types";
11
+ import { cn } from "../../utilities";
12
+ import {
13
+ getAccordionContentClasses,
14
+ getAccordionItemClasses,
15
+ getAccordionTriggerClasses,
16
+ } from "./constants";
17
+
18
+ const Accordion = (props: AccordionProps) => (
19
+ <AccordionPrimitive.Root {...props} />
20
+ );
21
+
22
+ const AccordionItem = React.forwardRef<
23
+ React.ElementRef<typeof AccordionPrimitive.Item>,
24
+ AccordionItemProps
25
+ >(({ className, ...props }, ref) => (
26
+ <AccordionPrimitive.Item
27
+ ref={ref}
28
+ className={cn(getAccordionItemClasses(), className)}
29
+ {...props}
30
+ />
31
+ ));
32
+ AccordionItem.displayName = "AccordionItem";
33
+
34
+ const AccordionTrigger = React.forwardRef<
35
+ React.ElementRef<typeof AccordionPrimitive.Trigger>,
36
+ AccordionTriggerProps
37
+ >(({ className, children, ...props }, ref) => (
38
+ <AccordionPrimitive.Header className="flex">
39
+ <AccordionPrimitive.Trigger
40
+ ref={ref}
41
+ className={cn(getAccordionTriggerClasses(), className)}
42
+ {...props}
43
+ >
44
+ {children}
45
+ </AccordionPrimitive.Trigger>
46
+ </AccordionPrimitive.Header>
47
+ ));
48
+ AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;
49
+
50
+ const AccordionContent = React.forwardRef<
51
+ React.ElementRef<typeof AccordionPrimitive.Content>,
52
+ AccordionContentProps
53
+ >(({ className, children, ...props }, ref) => (
54
+ <AccordionPrimitive.Content
55
+ ref={ref}
56
+ className={cn(getAccordionContentClasses())}
57
+ {...props}
58
+ >
59
+ <div className={cn("pb-4 pt-0", className)}>{children}</div>
60
+ </AccordionPrimitive.Content>
61
+ ));
62
+ AccordionContent.displayName = AccordionPrimitive.Content.displayName;
63
+
64
+ Accordion.Item = AccordionItem;
65
+ Accordion.Trigger = AccordionTrigger;
66
+ Accordion.Content = AccordionContent;
67
+
68
+ export { Accordion };
@@ -0,0 +1,11 @@
1
+ import { cva } from "../../libs";
2
+
3
+ export const getAccordionItemClasses = cva("border-b");
4
+
5
+ export const getAccordionTriggerClasses = cva(
6
+ "flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all [&:hover:not(:disabled)]:underline disabled:opacity-50 [&[data-state=open]>svg]:rotate-180"
7
+ );
8
+
9
+ export const getAccordionContentClasses = cva(
10
+ "overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
11
+ );
@@ -0,0 +1 @@
1
+ export { Accordion } from "./Accordion";
@@ -0,0 +1,17 @@
1
+ import * as AccordionPrimitive from "@radix-ui/react-accordion";
2
+
3
+ export type AccordionProps = React.ComponentPropsWithoutRef<
4
+ typeof AccordionPrimitive.Root
5
+ >;
6
+
7
+ export type AccordionContentProps = React.ComponentPropsWithoutRef<
8
+ typeof AccordionPrimitive.Content
9
+ >;
10
+
11
+ export type AccordionItemProps = React.ComponentPropsWithoutRef<
12
+ typeof AccordionPrimitive.Item
13
+ >;
14
+
15
+ export type AccordionTriggerProps = React.ComponentPropsWithoutRef<
16
+ typeof AccordionPrimitive.Trigger
17
+ >;
@@ -0,0 +1,204 @@
1
+ "use client";
2
+
3
+ import { forwardRef, useCallback, useEffect, useState } from "react";
4
+ import useEmblaCarousel from "embla-carousel-react";
5
+ import { ArrowLeftIcon, ArrowRightIcon } from "@radix-ui/react-icons";
6
+ import type { CarouselApi, CarouselProps } from "./types";
7
+ import { cn } from "../../utilities";
8
+ import { Button } from "../Button";
9
+ import {
10
+ getCarouselContentClasses,
11
+ getCarouselItemClasses,
12
+ getCarouselNextClasses,
13
+ getCarouselPreviousClasses,
14
+ } from "./constants";
15
+ import { CarouselContext } from "./CarouselContext";
16
+ import { useCarousel } from "./useCarousel";
17
+
18
+ const Carousel = ({
19
+ orientation = "horizontal",
20
+ opts,
21
+ setApi,
22
+ plugins,
23
+ className,
24
+ children,
25
+ ...props
26
+ }: CarouselProps & React.HTMLAttributes<HTMLDivElement>) => {
27
+ const [carouselRef, api] = useEmblaCarousel(
28
+ {
29
+ ...opts,
30
+ axis: orientation === "horizontal" ? "x" : "y",
31
+ },
32
+ plugins
33
+ );
34
+ const [canScrollPrev, setCanScrollPrev] = useState(false);
35
+ const [canScrollNext, setCanScrollNext] = useState(false);
36
+
37
+ const onSelect = useCallback((api: CarouselApi) => {
38
+ if (!api) {
39
+ return;
40
+ }
41
+
42
+ setCanScrollPrev(api.canScrollPrev());
43
+ setCanScrollNext(api.canScrollNext());
44
+ }, []);
45
+
46
+ const scrollPrev = useCallback(() => {
47
+ api?.scrollPrev();
48
+ }, [api]);
49
+
50
+ const scrollNext = useCallback(() => {
51
+ api?.scrollNext();
52
+ }, [api]);
53
+
54
+ const handleKeyDown = useCallback(
55
+ (event: React.KeyboardEvent<HTMLDivElement>) => {
56
+ if (event.key === "ArrowLeft") {
57
+ event.preventDefault();
58
+ scrollPrev();
59
+ } else if (event.key === "ArrowRight") {
60
+ event.preventDefault();
61
+ scrollNext();
62
+ }
63
+ },
64
+ [scrollPrev, scrollNext]
65
+ );
66
+
67
+ useEffect(() => {
68
+ if (!api || !setApi) {
69
+ return;
70
+ }
71
+
72
+ setApi(api);
73
+ }, [api, setApi]);
74
+
75
+ useEffect(() => {
76
+ if (!api) {
77
+ return;
78
+ }
79
+
80
+ onSelect(api);
81
+ api.on("reInit", onSelect);
82
+ api.on("select", onSelect);
83
+
84
+ return () => {
85
+ api?.off("select", onSelect);
86
+ };
87
+ }, [api, onSelect]);
88
+
89
+ return (
90
+ <CarouselContext.Provider
91
+ value={{
92
+ carouselRef,
93
+ api: api,
94
+ opts,
95
+ orientation:
96
+ orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
97
+ scrollPrev,
98
+ scrollNext,
99
+ canScrollPrev,
100
+ canScrollNext,
101
+ }}
102
+ >
103
+ <div
104
+ onKeyDownCapture={handleKeyDown}
105
+ className={cn("relative", className)}
106
+ role="region"
107
+ aria-roledescription="carousel"
108
+ {...props}
109
+ >
110
+ {children}
111
+ </div>
112
+ </CarouselContext.Provider>
113
+ );
114
+ };
115
+ Carousel.displayName = "Carousel";
116
+
117
+ const CarouselContent = forwardRef<
118
+ HTMLDivElement,
119
+ React.HTMLAttributes<HTMLDivElement>
120
+ >(({ className, ...props }, ref) => {
121
+ const { carouselRef, orientation } = useCarousel();
122
+
123
+ return (
124
+ <div ref={carouselRef} className="overflow-hidden">
125
+ <div
126
+ ref={ref}
127
+ className={cn(getCarouselContentClasses({ orientation }), className)}
128
+ {...props}
129
+ />
130
+ </div>
131
+ );
132
+ });
133
+ CarouselContent.displayName = "CarouselContent";
134
+
135
+ const CarouselItem = forwardRef<
136
+ HTMLDivElement,
137
+ React.HTMLAttributes<HTMLDivElement>
138
+ >(({ className, ...props }, ref) => {
139
+ const { orientation } = useCarousel();
140
+
141
+ return (
142
+ <div
143
+ ref={ref}
144
+ role="group"
145
+ aria-roledescription="slide"
146
+ className={cn(getCarouselItemClasses({ orientation }), className)}
147
+ {...props}
148
+ />
149
+ );
150
+ });
151
+ CarouselItem.displayName = "CarouselItem";
152
+
153
+ const CarouselPrevious = forwardRef<
154
+ HTMLButtonElement,
155
+ React.ComponentProps<typeof Button>
156
+ >(({ className, variant = "ghost", outline = true, ...props }, ref) => {
157
+ const { orientation, scrollPrev, canScrollPrev } = useCarousel();
158
+
159
+ return (
160
+ <Button
161
+ ref={ref}
162
+ outline={outline}
163
+ variant={variant}
164
+ className={cn(getCarouselPreviousClasses({ orientation }), className)}
165
+ disabled={!canScrollPrev}
166
+ onClick={scrollPrev}
167
+ {...props}
168
+ >
169
+ <ArrowLeftIcon className="h-4 w-4" />
170
+ <span className="sr-only">Previous slide</span>
171
+ </Button>
172
+ );
173
+ });
174
+ CarouselPrevious.displayName = "CarouselPrevious";
175
+
176
+ const CarouselNext = forwardRef<
177
+ HTMLButtonElement,
178
+ React.ComponentProps<typeof Button>
179
+ >(({ className, outline = true, variant = "ghost", ...props }, ref) => {
180
+ const { orientation, scrollNext, canScrollNext } = useCarousel();
181
+
182
+ return (
183
+ <Button
184
+ ref={ref}
185
+ outline={outline}
186
+ variant={variant}
187
+ className={cn(getCarouselNextClasses({ orientation }), className)}
188
+ disabled={!canScrollNext}
189
+ onClick={scrollNext}
190
+ {...props}
191
+ >
192
+ <ArrowRightIcon className="h-4 w-4" />
193
+ <span className="sr-only">Next slide</span>
194
+ </Button>
195
+ );
196
+ });
197
+ CarouselNext.displayName = "CarouselNext";
198
+
199
+ Carousel.Content = CarouselContent;
200
+ Carousel.Item = CarouselItem;
201
+ Carousel.Next = CarouselNext;
202
+ Carousel.Previous = CarouselPrevious;
203
+
204
+ export { Carousel };
@@ -0,0 +1,4 @@
1
+ import { createContext } from "react";
2
+ import { type CarouselContextProps } from "./types";
3
+
4
+ export const CarouselContext = createContext<CarouselContextProps | null>(null);
@@ -0,0 +1,58 @@
1
+ import { cva } from "../../libs";
2
+
3
+ export const getCarouselContentClasses = cva("flex", {
4
+ variants: {
5
+ orientation: {
6
+ horizontal: "-ml-4",
7
+ vertical: "-mt-4 flex-col",
8
+ },
9
+ },
10
+ defaultVariants: {
11
+ orientation: "horizontal",
12
+ },
13
+ });
14
+
15
+ export const getCarouselItemClasses = cva(
16
+ "min-w-0 shrink-0 grow-0 basis-full",
17
+ {
18
+ variants: {
19
+ orientation: {
20
+ horizontal: "pl-4",
21
+ vertical: "pt-4",
22
+ },
23
+ },
24
+ defaultVariants: {
25
+ orientation: "horizontal",
26
+ },
27
+ }
28
+ );
29
+
30
+ export const getCarouselNextClasses = cva(
31
+ "absolute h-8 w-8 rounded-full p-0 disabled:bg-transparent",
32
+ {
33
+ variants: {
34
+ orientation: {
35
+ horizontal: "-right-12 top-1/2 -translate-y-1/2",
36
+ vertical: "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
37
+ },
38
+ },
39
+ defaultVariants: {
40
+ orientation: "horizontal",
41
+ },
42
+ }
43
+ );
44
+
45
+ export const getCarouselPreviousClasses = cva(
46
+ "absolute h-8 w-8 rounded-full p-0 disabled:bg-transparent",
47
+ {
48
+ variants: {
49
+ orientation: {
50
+ horizontal: "-left-12 top-1/2 -translate-y-1/2",
51
+ vertical: "-top-12 left-1/2 -translate-x-1/2 rotate-90",
52
+ },
53
+ },
54
+ defaultVariants: {
55
+ orientation: "horizontal",
56
+ },
57
+ }
58
+ );
@@ -0,0 +1 @@
1
+ export { Carousel } from "./Carousel";
@@ -0,0 +1,24 @@
1
+ import { type UseEmblaCarouselType } from "embla-carousel-react";
2
+ import useEmblaCarousel from "embla-carousel-react";
3
+
4
+ type UseCarouselParameters = Parameters<typeof useEmblaCarousel>;
5
+ type CarouselOptions = UseCarouselParameters[0];
6
+ type CarouselPlugin = UseCarouselParameters[1];
7
+
8
+ export type CarouselApi = UseEmblaCarouselType[1];
9
+
10
+ export type CarouselProps = {
11
+ opts?: CarouselOptions;
12
+ plugins?: CarouselPlugin;
13
+ orientation?: "horizontal" | "vertical";
14
+ setApi?: (api: CarouselApi) => void;
15
+ };
16
+
17
+ export type CarouselContextProps = {
18
+ carouselRef: ReturnType<typeof useEmblaCarousel>[0];
19
+ api: ReturnType<typeof useEmblaCarousel>[1];
20
+ scrollPrev: () => void;
21
+ scrollNext: () => void;
22
+ canScrollPrev: boolean;
23
+ canScrollNext: boolean;
24
+ } & CarouselProps;
@@ -0,0 +1,12 @@
1
+ import { useContext } from "react";
2
+ import { CarouselContext } from "./CarouselContext";
3
+
4
+ export function useCarousel() {
5
+ const context = useContext(CarouselContext);
6
+
7
+ if (!context) {
8
+ throw new Error("useCarousel must be used within a <Carousel />");
9
+ }
10
+
11
+ return context;
12
+ }
@@ -0,0 +1,13 @@
1
+ "use client";
2
+
3
+ import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
4
+ import { type CollapsibleProps } from "@radix-ui/react-accordion";
5
+
6
+ const Collapsible = (props: CollapsibleProps) => (
7
+ <CollapsiblePrimitive.Root {...props} />
8
+ );
9
+
10
+ Collapsible.Trigger = CollapsiblePrimitive.CollapsibleTrigger;
11
+ Collapsible.Content = CollapsiblePrimitive.CollapsibleContent;
12
+
13
+ export { Collapsible };
@@ -0,0 +1 @@
1
+ export { Collapsible } from "./Collapsible";
@@ -0,0 +1,5 @@
1
+ import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
2
+
3
+ export type CollapsibleProps = React.ComponentPropsWithoutRef<
4
+ typeof CollapsiblePrimitive.Root
5
+ >;
@@ -0,0 +1,30 @@
1
+ "use client";
2
+
3
+ import * as HoverCardPrimitive from "@radix-ui/react-hover-card";
4
+ import { cn } from "../../utilities";
5
+ import { getHoverCardContentClasses } from "./constants";
6
+ import { forwardRef } from "react";
7
+ import { HoverCardProps } from "./types";
8
+
9
+ const HoverCard = (props: HoverCardProps) => (
10
+ <HoverCardPrimitive.Root {...props} />
11
+ );
12
+
13
+ const HoverCardContent = forwardRef<
14
+ React.ElementRef<typeof HoverCardPrimitive.Content>,
15
+ React.ComponentPropsWithoutRef<typeof HoverCardPrimitive.Content>
16
+ >(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
17
+ <HoverCardPrimitive.Content
18
+ ref={ref}
19
+ align={align}
20
+ sideOffset={sideOffset}
21
+ className={cn(getHoverCardContentClasses(), className)}
22
+ {...props}
23
+ />
24
+ ));
25
+ HoverCardContent.displayName = HoverCardPrimitive.Content.displayName;
26
+
27
+ HoverCard.Content = HoverCardContent;
28
+ HoverCard.Trigger = HoverCardPrimitive.Trigger;
29
+
30
+ export { HoverCard };
@@ -0,0 +1,5 @@
1
+ import { cva } from "../../libs";
2
+
3
+ export const getHoverCardContentClasses = cva(
4
+ "z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"
5
+ );
@@ -0,0 +1 @@
1
+ export { HoverCard } from "./HoverCard";
@@ -0,0 +1,5 @@
1
+ import * as HoverCardPrimitive from "@radix-ui/react-hover-card";
2
+
3
+ export type HoverCardProps = React.ComponentPropsWithoutRef<
4
+ typeof HoverCardPrimitive.Root
5
+ >;
package/src/index.ts CHANGED
@@ -2,13 +2,16 @@
2
2
  export * from "./components/Button";
3
3
  export * from "./components/Breadcrumbs";
4
4
  export * from "./components/Toggle";
5
+ export * from "./components/ToggleGroup";
5
6
 
6
7
  /** data display */
8
+ export * from "./components/Accordion";
7
9
  export * from "./components/Alert";
8
10
  export * from "./components/Avatar";
9
11
  export * from "./components/Badge";
10
12
  export * from "./components/Card";
11
13
  export * from "./components/Calendar";
14
+ export * from "./components/Collapsible";
12
15
  export * from "./components/Description";
13
16
  export * from "./components/Progress";
14
17
  export * from "./components/Separator";
@@ -28,6 +31,7 @@ export * from "./components/Tooltip";
28
31
 
29
32
  /** composable */
30
33
  export * from "./components/AlertDialog";
31
- export * from "./components/Dialog";
32
34
  export * from "./components/Command";
35
+ export * from "./components/Dialog";
36
+ export * from "./components/HoverCard";
33
37
  export * from "./components/Popover";