@mbao01/common 0.0.19 → 0.0.20
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/dist/types/components/Drawer/Drawer.d.ts +41 -0
- package/dist/types/components/Drawer/constants.d.ts +6 -0
- package/dist/types/components/Drawer/index.d.ts +1 -0
- package/dist/types/components/Drawer/types.d.ts +3 -0
- package/dist/types/components/Pagination/Pagination.d.ts +25 -0
- package/dist/types/components/Pagination/constants.d.ts +5 -0
- package/dist/types/components/Pagination/index.d.ts +1 -0
- package/dist/types/components/Pagination/types.d.ts +12 -0
- package/dist/types/components/ScrollArea/ScrollArea.d.ts +11 -0
- package/dist/types/components/ScrollArea/constants.d.ts +8 -0
- package/dist/types/components/ScrollArea/index.d.ts +1 -0
- package/dist/types/components/ScrollArea/types.d.ts +8 -0
- package/dist/types/index.d.ts +2 -0
- package/package.json +5 -3
- package/src/components/Drawer/Drawer.tsx +121 -0
- package/src/components/Drawer/constants.ts +19 -0
- package/src/components/Drawer/index.ts +1 -0
- package/src/components/Drawer/types.ts +3 -0
- package/src/components/Pagination/Pagination.tsx +132 -0
- package/src/components/Pagination/constants.ts +15 -0
- package/src/components/Pagination/index.ts +1 -0
- package/src/components/Pagination/types.ts +19 -0
- package/src/components/ScrollArea/ScrollArea.tsx +52 -0
- package/src/components/ScrollArea/constants.ts +36 -0
- package/src/components/ScrollArea/index.ts +1 -0
- package/src/components/ScrollArea/types.ts +14 -0
- package/src/index.ts +2 -0
- package/vitest-setup.ts +3 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DrawerProps } from "./types";
|
|
3
|
+
declare const Drawer: {
|
|
4
|
+
({ shouldScaleBackground, ...props }: DrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
displayName: string;
|
|
6
|
+
Portal: import("react").FC<import("@radix-ui/react-dialog").DialogPortalProps>;
|
|
7
|
+
Overlay: import("react").ForwardRefExoticComponent<Omit<Omit<import("@radix-ui/react-dialog").DialogOverlayProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
8
|
+
Trigger: import("react").ForwardRefExoticComponent<import("@radix-ui/react-dialog").DialogTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
9
|
+
Close: import("react").ForwardRefExoticComponent<import("@radix-ui/react-dialog").DialogCloseProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
10
|
+
Content: import("react").ForwardRefExoticComponent<Omit<Omit<import("@radix-ui/react-dialog").DialogContentProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
|
|
11
|
+
onAnimationEnd?: ((open: boolean) => void) | undefined;
|
|
12
|
+
} & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
13
|
+
Header: {
|
|
14
|
+
({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
displayName: string;
|
|
16
|
+
};
|
|
17
|
+
Footer: {
|
|
18
|
+
({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
displayName: string;
|
|
20
|
+
};
|
|
21
|
+
Title: import("react").ForwardRefExoticComponent<Omit<import("@radix-ui/react-dialog").DialogTitleProps & import("react").RefAttributes<HTMLHeadingElement>, "ref"> & import("react").RefAttributes<HTMLHeadingElement>>;
|
|
22
|
+
Description: import("react").ForwardRefExoticComponent<Omit<import("@radix-ui/react-dialog").DialogDescriptionProps & import("react").RefAttributes<HTMLParagraphElement>, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
|
|
23
|
+
};
|
|
24
|
+
declare const DrawerTrigger: import("react").ForwardRefExoticComponent<import("@radix-ui/react-dialog").DialogTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
25
|
+
declare const DrawerPortal: import("react").FC<import("@radix-ui/react-dialog").DialogPortalProps>;
|
|
26
|
+
declare const DrawerClose: import("react").ForwardRefExoticComponent<import("@radix-ui/react-dialog").DialogCloseProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
27
|
+
declare const DrawerOverlay: import("react").ForwardRefExoticComponent<Omit<Omit<import("@radix-ui/react-dialog").DialogOverlayProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
28
|
+
declare const DrawerContent: import("react").ForwardRefExoticComponent<Omit<Omit<import("@radix-ui/react-dialog").DialogContentProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
|
|
29
|
+
onAnimationEnd?: ((open: boolean) => void) | undefined;
|
|
30
|
+
} & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
31
|
+
declare const DrawerHeader: {
|
|
32
|
+
({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
displayName: string;
|
|
34
|
+
};
|
|
35
|
+
declare const DrawerFooter: {
|
|
36
|
+
({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
displayName: string;
|
|
38
|
+
};
|
|
39
|
+
declare const DrawerTitle: import("react").ForwardRefExoticComponent<Omit<import("@radix-ui/react-dialog").DialogTitleProps & import("react").RefAttributes<HTMLHeadingElement>, "ref"> & import("react").RefAttributes<HTMLHeadingElement>>;
|
|
40
|
+
declare const DrawerDescription: import("react").ForwardRefExoticComponent<Omit<import("@radix-ui/react-dialog").DialogDescriptionProps & import("react").RefAttributes<HTMLParagraphElement>, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
|
|
41
|
+
export { Drawer, DrawerPortal, DrawerOverlay, DrawerTrigger, DrawerClose, DrawerContent, DrawerHeader, DrawerFooter, DrawerTitle, DrawerDescription, };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const getDrawerContentClasses: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
2
|
+
export declare const getDrawerDescriptionClasses: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
3
|
+
export declare const getDrawerHeaderClasses: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
4
|
+
export declare const getDrawerFooterClasses: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
5
|
+
export declare const getDrawerOverlayClasses: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
6
|
+
export declare const getDrawerTitleClasses: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Drawer } from "./Drawer";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { PaginationEllipsisProps, PaginationLinkProps, PaginationNextProps, PaginationPreviousProps, type PaginationProps } from "./types";
|
|
3
|
+
declare const Pagination: {
|
|
4
|
+
({ className, ...props }: PaginationProps): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
displayName: string;
|
|
6
|
+
Content: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & import("react").RefAttributes<HTMLUListElement>>;
|
|
7
|
+
Link: {
|
|
8
|
+
({ className, size, wide, outline, variant, isActive, ...props }: PaginationLinkProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
displayName: string;
|
|
10
|
+
};
|
|
11
|
+
Item: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> & import("react").RefAttributes<HTMLLIElement>>;
|
|
12
|
+
Previous: {
|
|
13
|
+
({ className, children, ...props }: PaginationPreviousProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
displayName: string;
|
|
15
|
+
};
|
|
16
|
+
Next: {
|
|
17
|
+
({ className, children, ...props }: PaginationNextProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
displayName: string;
|
|
19
|
+
};
|
|
20
|
+
Ellipsis: {
|
|
21
|
+
({ className, ...props }: PaginationEllipsisProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
displayName: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export { Pagination };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const getPaginationClasses: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
2
|
+
export declare const getPaginationContentClasses: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
3
|
+
export declare const getPaginationEllipsisClasses: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
4
|
+
export declare const getPaginationNextClasses: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
5
|
+
export declare const getPaginationPreviousClasses: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Pagination } from "./Pagination";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { VariantProps } from "../../libs";
|
|
3
|
+
import { getButtonClasses } from "../Button/constants";
|
|
4
|
+
export type PaginationProps = React.ComponentProps<"nav">;
|
|
5
|
+
export type PaginationContentProps = React.ComponentProps<"ul">;
|
|
6
|
+
export type PaginationEllipsisProps = React.ComponentProps<"span">;
|
|
7
|
+
export type PaginationItemProps = React.ComponentProps<"li">;
|
|
8
|
+
export type PaginationLinkProps = React.ComponentProps<"a"> & VariantProps<typeof getButtonClasses> & {
|
|
9
|
+
isActive?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type PaginationPreviousProps = PaginationLinkProps;
|
|
12
|
+
export type PaginationNextProps = PaginationLinkProps;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area";
|
|
3
|
+
import type { ScrollAreaProps } from "./types";
|
|
4
|
+
declare const ScrollArea: {
|
|
5
|
+
({ className, children, scrollbar, ...props }: ScrollAreaProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
displayName: string | undefined;
|
|
7
|
+
};
|
|
8
|
+
declare const Scrollbar: import("react").ForwardRefExoticComponent<Omit<ScrollAreaPrimitive.ScrollAreaScrollbarProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
|
|
9
|
+
variant?: "accent" | "error" | "ghost" | "info" | "neutral" | "primary" | "secondary" | "success" | "warning" | "base" | undefined;
|
|
10
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
11
|
+
export { ScrollArea, Scrollbar };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const getScrollAreaClasses: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
2
|
+
export declare const getScrollAreaScrollbarClasses: (props?: ({
|
|
3
|
+
orientation?: "horizontal" | "vertical" | null | undefined;
|
|
4
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
5
|
+
export declare const getScrollAreaThumbClasses: (props?: ({
|
|
6
|
+
variant?: "accent" | "error" | "ghost" | "info" | "neutral" | "primary" | "secondary" | "success" | "warning" | "base" | null | undefined;
|
|
7
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
|
+
export declare const getScrollAreaViewportClasses: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ScrollArea } from "./ScrollArea";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area";
|
|
3
|
+
import { VariantProps } from "../../libs";
|
|
4
|
+
import { getScrollAreaThumbClasses } from "./constants";
|
|
5
|
+
export type ScrollAreaProps = React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root> & {
|
|
6
|
+
scrollbar?: ScrollbarProps;
|
|
7
|
+
};
|
|
8
|
+
export type ScrollbarProps = React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar> & VariantProps<typeof getScrollAreaThumbClasses>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** actions */
|
|
2
2
|
export * from "./components/Button";
|
|
3
3
|
export * from "./components/Breadcrumbs";
|
|
4
|
+
export * from "./components/Pagination";
|
|
4
5
|
export * from "./components/Toggle";
|
|
5
6
|
export * from "./components/ToggleGroup";
|
|
6
7
|
/** data display */
|
|
@@ -13,6 +14,7 @@ export * from "./components/Calendar";
|
|
|
13
14
|
export * from "./components/Collapsible";
|
|
14
15
|
export * from "./components/Description";
|
|
15
16
|
export * from "./components/Progress";
|
|
17
|
+
export * from "./components/ScrollArea";
|
|
16
18
|
export * from "./components/Separator";
|
|
17
19
|
export * from "./components/Sonner";
|
|
18
20
|
export * from "./components/Tabs";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mbao01/common",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.20",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Ayomide Bakare",
|
|
7
7
|
"license": "MIT",
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
"@radix-ui/react-label": "^2.0.2",
|
|
72
72
|
"@radix-ui/react-popover": "^1.0.7",
|
|
73
73
|
"@radix-ui/react-progress": "^1.0.3",
|
|
74
|
+
"@radix-ui/react-scroll-area": "^1.0.5",
|
|
74
75
|
"@radix-ui/react-select": "^2.0.0",
|
|
75
76
|
"@radix-ui/react-separator": "^1.0.3",
|
|
76
77
|
"@radix-ui/react-slider": "^1.1.2",
|
|
@@ -89,7 +90,8 @@
|
|
|
89
90
|
"react-international-phone": "^4.2.6",
|
|
90
91
|
"sonner": "^1.4.41",
|
|
91
92
|
"tailwind-merge": "^2.2.1",
|
|
92
|
-
"tailwindcss-animate": "^1.0.7"
|
|
93
|
+
"tailwindcss-animate": "^1.0.7",
|
|
94
|
+
"vaul": "^0.9.0"
|
|
93
95
|
},
|
|
94
96
|
"devDependencies": {
|
|
95
97
|
"@storybook/addon-essentials": "^8.0.6",
|
|
@@ -136,5 +138,5 @@
|
|
|
136
138
|
"react-dom": "^18.2.0",
|
|
137
139
|
"typescript": "^5.2.2"
|
|
138
140
|
},
|
|
139
|
-
"gitHead": "
|
|
141
|
+
"gitHead": "957331eff1e44996fb087ad2feef3052d2e1a3f7"
|
|
140
142
|
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Drawer as DrawerPrimitive } from "vaul";
|
|
4
|
+
import { cn } from "../../utilities";
|
|
5
|
+
import { forwardRef } from "react";
|
|
6
|
+
import { DrawerProps } from "./types";
|
|
7
|
+
import {
|
|
8
|
+
getDrawerContentClasses,
|
|
9
|
+
getDrawerDescriptionClasses,
|
|
10
|
+
getDrawerFooterClasses,
|
|
11
|
+
getDrawerHeaderClasses,
|
|
12
|
+
getDrawerOverlayClasses,
|
|
13
|
+
getDrawerTitleClasses,
|
|
14
|
+
} from "./constants";
|
|
15
|
+
|
|
16
|
+
const Drawer = ({ shouldScaleBackground = true, ...props }: DrawerProps) => (
|
|
17
|
+
<DrawerPrimitive.Root
|
|
18
|
+
shouldScaleBackground={shouldScaleBackground}
|
|
19
|
+
{...props}
|
|
20
|
+
/>
|
|
21
|
+
);
|
|
22
|
+
Drawer.displayName = "Drawer";
|
|
23
|
+
|
|
24
|
+
const DrawerTrigger = DrawerPrimitive.Trigger;
|
|
25
|
+
|
|
26
|
+
const DrawerPortal = DrawerPrimitive.Portal;
|
|
27
|
+
|
|
28
|
+
const DrawerClose = DrawerPrimitive.Close;
|
|
29
|
+
|
|
30
|
+
const DrawerOverlay = forwardRef<
|
|
31
|
+
React.ElementRef<typeof DrawerPrimitive.Overlay>,
|
|
32
|
+
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Overlay>
|
|
33
|
+
>(({ className, ...props }, ref) => (
|
|
34
|
+
<DrawerPrimitive.Overlay
|
|
35
|
+
ref={ref}
|
|
36
|
+
className={cn(getDrawerOverlayClasses(), className)}
|
|
37
|
+
{...props}
|
|
38
|
+
/>
|
|
39
|
+
));
|
|
40
|
+
DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName;
|
|
41
|
+
|
|
42
|
+
const DrawerContent = forwardRef<
|
|
43
|
+
React.ElementRef<typeof DrawerPrimitive.Content>,
|
|
44
|
+
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Content>
|
|
45
|
+
>(({ className, children, ...props }, ref) => (
|
|
46
|
+
<DrawerPortal>
|
|
47
|
+
<DrawerOverlay />
|
|
48
|
+
<DrawerPrimitive.Content
|
|
49
|
+
ref={ref}
|
|
50
|
+
className={cn(getDrawerContentClasses(), className)}
|
|
51
|
+
{...props}
|
|
52
|
+
>
|
|
53
|
+
<div className="mx-auto mt-4 h-2 w-[80px] rounded-full bg-base-300" />
|
|
54
|
+
{children}
|
|
55
|
+
</DrawerPrimitive.Content>
|
|
56
|
+
</DrawerPortal>
|
|
57
|
+
));
|
|
58
|
+
DrawerContent.displayName = "DrawerContent";
|
|
59
|
+
|
|
60
|
+
const DrawerHeader = ({
|
|
61
|
+
className,
|
|
62
|
+
...props
|
|
63
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
64
|
+
<div className={cn(getDrawerHeaderClasses(), className)} {...props} />
|
|
65
|
+
);
|
|
66
|
+
DrawerHeader.displayName = "DrawerHeader";
|
|
67
|
+
|
|
68
|
+
const DrawerFooter = ({
|
|
69
|
+
className,
|
|
70
|
+
...props
|
|
71
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
72
|
+
<div className={cn(getDrawerFooterClasses(), className)} {...props} />
|
|
73
|
+
);
|
|
74
|
+
DrawerFooter.displayName = "DrawerFooter";
|
|
75
|
+
|
|
76
|
+
const DrawerTitle = forwardRef<
|
|
77
|
+
React.ElementRef<typeof DrawerPrimitive.Title>,
|
|
78
|
+
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Title>
|
|
79
|
+
>(({ className, ...props }, ref) => (
|
|
80
|
+
<DrawerPrimitive.Title
|
|
81
|
+
ref={ref}
|
|
82
|
+
className={cn(getDrawerTitleClasses(), className)}
|
|
83
|
+
{...props}
|
|
84
|
+
/>
|
|
85
|
+
));
|
|
86
|
+
DrawerTitle.displayName = DrawerPrimitive.Title.displayName;
|
|
87
|
+
|
|
88
|
+
const DrawerDescription = forwardRef<
|
|
89
|
+
React.ElementRef<typeof DrawerPrimitive.Description>,
|
|
90
|
+
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Description>
|
|
91
|
+
>(({ className, ...props }, ref) => (
|
|
92
|
+
<DrawerPrimitive.Description
|
|
93
|
+
ref={ref}
|
|
94
|
+
className={cn(getDrawerDescriptionClasses(), className)}
|
|
95
|
+
{...props}
|
|
96
|
+
/>
|
|
97
|
+
));
|
|
98
|
+
DrawerDescription.displayName = DrawerPrimitive.Description.displayName;
|
|
99
|
+
|
|
100
|
+
Drawer.Portal = DrawerPortal;
|
|
101
|
+
Drawer.Overlay = DrawerOverlay;
|
|
102
|
+
Drawer.Trigger = DrawerTrigger;
|
|
103
|
+
Drawer.Close = DrawerClose;
|
|
104
|
+
Drawer.Content = DrawerContent;
|
|
105
|
+
Drawer.Header = DrawerHeader;
|
|
106
|
+
Drawer.Footer = DrawerFooter;
|
|
107
|
+
Drawer.Title = DrawerTitle;
|
|
108
|
+
Drawer.Description = DrawerDescription;
|
|
109
|
+
|
|
110
|
+
export {
|
|
111
|
+
Drawer,
|
|
112
|
+
DrawerPortal,
|
|
113
|
+
DrawerOverlay,
|
|
114
|
+
DrawerTrigger,
|
|
115
|
+
DrawerClose,
|
|
116
|
+
DrawerContent,
|
|
117
|
+
DrawerHeader,
|
|
118
|
+
DrawerFooter,
|
|
119
|
+
DrawerTitle,
|
|
120
|
+
DrawerDescription,
|
|
121
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { cva } from "../../libs";
|
|
2
|
+
|
|
3
|
+
export const getDrawerContentClasses = cva(
|
|
4
|
+
"fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-base-100"
|
|
5
|
+
);
|
|
6
|
+
|
|
7
|
+
export const getDrawerDescriptionClasses = cva("text-sm");
|
|
8
|
+
|
|
9
|
+
export const getDrawerHeaderClasses = cva(
|
|
10
|
+
"grid gap-1.5 p-4 text-center sm:text-left"
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export const getDrawerFooterClasses = cva("mt-auto flex flex-col gap-2 p-4");
|
|
14
|
+
|
|
15
|
+
export const getDrawerOverlayClasses = cva("fixed inset-0 z-50 bg-black/80");
|
|
16
|
+
|
|
17
|
+
export const getDrawerTitleClasses = cva(
|
|
18
|
+
"text-lg font-semibold leading-none tracking-tight"
|
|
19
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Drawer } from "./Drawer";
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import {
|
|
3
|
+
ChevronLeftIcon,
|
|
4
|
+
ChevronRightIcon,
|
|
5
|
+
DotsHorizontalIcon,
|
|
6
|
+
} from "@radix-ui/react-icons";
|
|
7
|
+
import {
|
|
8
|
+
PaginationContentProps,
|
|
9
|
+
PaginationEllipsisProps,
|
|
10
|
+
PaginationItemProps,
|
|
11
|
+
PaginationLinkProps,
|
|
12
|
+
PaginationNextProps,
|
|
13
|
+
PaginationPreviousProps,
|
|
14
|
+
type PaginationProps,
|
|
15
|
+
} from "./types";
|
|
16
|
+
import { cn } from "../../utilities";
|
|
17
|
+
import {
|
|
18
|
+
getPaginationClasses,
|
|
19
|
+
getPaginationContentClasses,
|
|
20
|
+
getPaginationEllipsisClasses,
|
|
21
|
+
getPaginationNextClasses,
|
|
22
|
+
getPaginationPreviousClasses,
|
|
23
|
+
} from "./constants";
|
|
24
|
+
|
|
25
|
+
import { getButtonClasses } from "../Button/constants";
|
|
26
|
+
|
|
27
|
+
const Pagination = ({ className, ...props }: PaginationProps) => (
|
|
28
|
+
<nav
|
|
29
|
+
role="navigation"
|
|
30
|
+
aria-label="pagination"
|
|
31
|
+
className={cn(getPaginationClasses(), className)}
|
|
32
|
+
{...props}
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
Pagination.displayName = "Pagination";
|
|
36
|
+
|
|
37
|
+
const PaginationContent = forwardRef<HTMLUListElement, PaginationContentProps>(
|
|
38
|
+
({ className, ...props }, ref) => (
|
|
39
|
+
<ul
|
|
40
|
+
ref={ref}
|
|
41
|
+
className={cn(getPaginationContentClasses(), className)}
|
|
42
|
+
{...props}
|
|
43
|
+
/>
|
|
44
|
+
)
|
|
45
|
+
);
|
|
46
|
+
PaginationContent.displayName = "PaginationContent";
|
|
47
|
+
|
|
48
|
+
const PaginationItem = forwardRef<HTMLLIElement, PaginationItemProps>(
|
|
49
|
+
(props, ref) => <li ref={ref} {...props} />
|
|
50
|
+
);
|
|
51
|
+
PaginationItem.displayName = "PaginationItem";
|
|
52
|
+
|
|
53
|
+
const PaginationLink = ({
|
|
54
|
+
className,
|
|
55
|
+
size,
|
|
56
|
+
wide,
|
|
57
|
+
outline,
|
|
58
|
+
variant = "ghost",
|
|
59
|
+
isActive,
|
|
60
|
+
...props
|
|
61
|
+
}: PaginationLinkProps) => (
|
|
62
|
+
<a
|
|
63
|
+
aria-current={isActive ? "page" : undefined}
|
|
64
|
+
className={cn(
|
|
65
|
+
getButtonClasses({
|
|
66
|
+
size,
|
|
67
|
+
wide,
|
|
68
|
+
outline: outline ?? isActive,
|
|
69
|
+
variant,
|
|
70
|
+
}),
|
|
71
|
+
className
|
|
72
|
+
)}
|
|
73
|
+
{...props}
|
|
74
|
+
/>
|
|
75
|
+
);
|
|
76
|
+
PaginationLink.displayName = "PaginationLink";
|
|
77
|
+
|
|
78
|
+
const PaginationPrevious = ({
|
|
79
|
+
className,
|
|
80
|
+
children,
|
|
81
|
+
...props
|
|
82
|
+
}: PaginationPreviousProps) => (
|
|
83
|
+
<PaginationLink
|
|
84
|
+
aria-label="Go to previous page"
|
|
85
|
+
className={cn(getPaginationPreviousClasses(), className)}
|
|
86
|
+
{...props}
|
|
87
|
+
>
|
|
88
|
+
<ChevronLeftIcon className="h-4 w-4" />
|
|
89
|
+
{children && <span>{children}</span>}
|
|
90
|
+
</PaginationLink>
|
|
91
|
+
);
|
|
92
|
+
PaginationPrevious.displayName = "PaginationPrevious";
|
|
93
|
+
|
|
94
|
+
const PaginationNext = ({
|
|
95
|
+
className,
|
|
96
|
+
children,
|
|
97
|
+
...props
|
|
98
|
+
}: PaginationNextProps) => (
|
|
99
|
+
<PaginationLink
|
|
100
|
+
aria-label="Go to next page"
|
|
101
|
+
className={cn(getPaginationNextClasses(), className)}
|
|
102
|
+
{...props}
|
|
103
|
+
>
|
|
104
|
+
{children && <span>{children}</span>}
|
|
105
|
+
<ChevronRightIcon className="h-4 w-4" />
|
|
106
|
+
</PaginationLink>
|
|
107
|
+
);
|
|
108
|
+
PaginationNext.displayName = "PaginationNext";
|
|
109
|
+
|
|
110
|
+
const PaginationEllipsis = ({
|
|
111
|
+
className,
|
|
112
|
+
...props
|
|
113
|
+
}: PaginationEllipsisProps) => (
|
|
114
|
+
<span
|
|
115
|
+
aria-hidden
|
|
116
|
+
className={cn(getPaginationEllipsisClasses(), className)}
|
|
117
|
+
{...props}
|
|
118
|
+
>
|
|
119
|
+
<DotsHorizontalIcon className="h-4 w-4" />
|
|
120
|
+
<span className="sr-only">More pages</span>
|
|
121
|
+
</span>
|
|
122
|
+
);
|
|
123
|
+
PaginationEllipsis.displayName = "PaginationEllipsis";
|
|
124
|
+
|
|
125
|
+
Pagination.Content = PaginationContent;
|
|
126
|
+
Pagination.Link = PaginationLink;
|
|
127
|
+
Pagination.Item = PaginationItem;
|
|
128
|
+
Pagination.Previous = PaginationPrevious;
|
|
129
|
+
Pagination.Next = PaginationNext;
|
|
130
|
+
Pagination.Ellipsis = PaginationEllipsis;
|
|
131
|
+
|
|
132
|
+
export { Pagination };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { cva } from "../../libs";
|
|
2
|
+
|
|
3
|
+
export const getPaginationClasses = cva("mx-auto flex w-full justify-center");
|
|
4
|
+
|
|
5
|
+
export const getPaginationContentClasses = cva(
|
|
6
|
+
"flex flex-row items-center gap-1"
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
export const getPaginationEllipsisClasses = cva(
|
|
10
|
+
"flex h-9 w-9 items-center justify-center"
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export const getPaginationNextClasses = cva("gap-1 px-3");
|
|
14
|
+
|
|
15
|
+
export const getPaginationPreviousClasses = cva("gap-1 px-3");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Pagination } from "./Pagination";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { VariantProps } from "../../libs";
|
|
2
|
+
import { getButtonClasses } from "../Button/constants";
|
|
3
|
+
|
|
4
|
+
export type PaginationProps = React.ComponentProps<"nav">;
|
|
5
|
+
|
|
6
|
+
export type PaginationContentProps = React.ComponentProps<"ul">;
|
|
7
|
+
|
|
8
|
+
export type PaginationEllipsisProps = React.ComponentProps<"span">;
|
|
9
|
+
|
|
10
|
+
export type PaginationItemProps = React.ComponentProps<"li">;
|
|
11
|
+
|
|
12
|
+
export type PaginationLinkProps = React.ComponentProps<"a"> &
|
|
13
|
+
VariantProps<typeof getButtonClasses> & {
|
|
14
|
+
isActive?: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type PaginationPreviousProps = PaginationLinkProps;
|
|
18
|
+
|
|
19
|
+
export type PaginationNextProps = PaginationLinkProps;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area";
|
|
5
|
+
import type { ScrollAreaProps, ScrollbarProps } from "./types";
|
|
6
|
+
import { cn } from "../../utilities";
|
|
7
|
+
import {
|
|
8
|
+
getScrollAreaClasses,
|
|
9
|
+
getScrollAreaScrollbarClasses,
|
|
10
|
+
getScrollAreaThumbClasses,
|
|
11
|
+
getScrollAreaViewportClasses,
|
|
12
|
+
} from "./constants";
|
|
13
|
+
|
|
14
|
+
const ScrollArea = ({
|
|
15
|
+
className,
|
|
16
|
+
children,
|
|
17
|
+
scrollbar,
|
|
18
|
+
...props
|
|
19
|
+
}: ScrollAreaProps) => (
|
|
20
|
+
<ScrollAreaPrimitive.Root
|
|
21
|
+
className={cn(getScrollAreaClasses(), className)}
|
|
22
|
+
{...props}
|
|
23
|
+
>
|
|
24
|
+
<ScrollAreaPrimitive.Viewport
|
|
25
|
+
className={cn(getScrollAreaViewportClasses())}
|
|
26
|
+
>
|
|
27
|
+
{children}
|
|
28
|
+
</ScrollAreaPrimitive.Viewport>
|
|
29
|
+
<Scrollbar {...scrollbar} />
|
|
30
|
+
<ScrollAreaPrimitive.Corner />
|
|
31
|
+
</ScrollAreaPrimitive.Root>
|
|
32
|
+
);
|
|
33
|
+
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
|
|
34
|
+
|
|
35
|
+
const Scrollbar = forwardRef<
|
|
36
|
+
React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,
|
|
37
|
+
ScrollbarProps
|
|
38
|
+
>(({ className, variant, orientation = "vertical", ...props }, ref) => (
|
|
39
|
+
<ScrollAreaPrimitive.ScrollAreaScrollbar
|
|
40
|
+
ref={ref}
|
|
41
|
+
orientation={orientation}
|
|
42
|
+
className={cn(getScrollAreaScrollbarClasses({ orientation }), className)}
|
|
43
|
+
{...props}
|
|
44
|
+
>
|
|
45
|
+
<ScrollAreaPrimitive.ScrollAreaThumb
|
|
46
|
+
className={cn(getScrollAreaThumbClasses({ variant }))}
|
|
47
|
+
/>
|
|
48
|
+
</ScrollAreaPrimitive.ScrollAreaScrollbar>
|
|
49
|
+
));
|
|
50
|
+
Scrollbar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
|
|
51
|
+
|
|
52
|
+
export { ScrollArea, Scrollbar };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { cva } from "../../libs";
|
|
2
|
+
|
|
3
|
+
export const getScrollAreaClasses = cva("relative overflow-hidden");
|
|
4
|
+
|
|
5
|
+
export const getScrollAreaScrollbarClasses = cva(
|
|
6
|
+
"flex touch-none select-none transition-colors",
|
|
7
|
+
{
|
|
8
|
+
variants: {
|
|
9
|
+
orientation: {
|
|
10
|
+
horizontal: "h-2.5 flex-col border-t border-t-transparent p-[1px]",
|
|
11
|
+
vertical: "h-full w-2.5 border-l border-l-transparent p-[1px]",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
}
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
export const getScrollAreaThumbClasses = cva("relative flex-1 rounded-full", {
|
|
18
|
+
variants: {
|
|
19
|
+
variant: {
|
|
20
|
+
accent: "bg-accent",
|
|
21
|
+
base: "bg-base-300",
|
|
22
|
+
error: "bg-error",
|
|
23
|
+
ghost: "bg-ghost",
|
|
24
|
+
info: "bg-info",
|
|
25
|
+
neutral: "bg-neutral",
|
|
26
|
+
primary: "bg-primary",
|
|
27
|
+
secondary: "bg-secondary",
|
|
28
|
+
success: "bg-success",
|
|
29
|
+
warning: "bg-warning",
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export const getScrollAreaViewportClasses = cva(
|
|
35
|
+
"h-full w-full rounded-[inherit]"
|
|
36
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ScrollArea } from "./ScrollArea";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area";
|
|
2
|
+
import { VariantProps } from "../../libs";
|
|
3
|
+
import { getScrollAreaThumbClasses } from "./constants";
|
|
4
|
+
|
|
5
|
+
export type ScrollAreaProps = React.ComponentPropsWithoutRef<
|
|
6
|
+
typeof ScrollAreaPrimitive.Root
|
|
7
|
+
> & {
|
|
8
|
+
scrollbar?: ScrollbarProps;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type ScrollbarProps = React.ComponentPropsWithoutRef<
|
|
12
|
+
typeof ScrollAreaPrimitive.ScrollAreaScrollbar
|
|
13
|
+
> &
|
|
14
|
+
VariantProps<typeof getScrollAreaThumbClasses>;
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** actions */
|
|
2
2
|
export * from "./components/Button";
|
|
3
3
|
export * from "./components/Breadcrumbs";
|
|
4
|
+
export * from "./components/Pagination";
|
|
4
5
|
export * from "./components/Toggle";
|
|
5
6
|
export * from "./components/ToggleGroup";
|
|
6
7
|
|
|
@@ -14,6 +15,7 @@ export * from "./components/Calendar";
|
|
|
14
15
|
export * from "./components/Collapsible";
|
|
15
16
|
export * from "./components/Description";
|
|
16
17
|
export * from "./components/Progress";
|
|
18
|
+
export * from "./components/ScrollArea";
|
|
17
19
|
export * from "./components/Separator";
|
|
18
20
|
export * from "./components/Sonner";
|
|
19
21
|
export * from "./components/Tabs";
|
package/vitest-setup.ts
CHANGED
|
@@ -12,6 +12,9 @@ const ResizeObserverMock = vi.fn(() => ({
|
|
|
12
12
|
// Stub the global ResizeObserver
|
|
13
13
|
vi.stubGlobal("ResizeObserver", ResizeObserverMock);
|
|
14
14
|
|
|
15
|
+
// Mock the scrollTo method
|
|
16
|
+
vi.stubGlobal("scrollTo", vi.fn());
|
|
17
|
+
|
|
15
18
|
// runs a cleanup after each test case (e.g. clearing jsdom)
|
|
16
19
|
afterEach(() => {
|
|
17
20
|
cleanup();
|