@mbao01/common 0.0.19 → 0.0.21
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/Command/Command.d.ts +5 -5
- 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/Menu/ContextMenu/ContextMenu.d.ts +36 -0
- package/dist/types/components/Menu/ContextMenu/constants.d.ts +0 -0
- package/dist/types/components/Menu/ContextMenu/index.d.ts +1 -0
- package/dist/types/components/Menu/ContextMenu/types.d.ts +14 -0
- package/dist/types/components/Menu/DropdownMenu/DropdownMenu.d.ts +36 -0
- package/dist/types/components/Menu/DropdownMenu/index.d.ts +1 -0
- package/dist/types/components/Menu/DropdownMenu/types.d.ts +14 -0
- package/dist/types/components/Menu/Menubar/Menubar.d.ts +43 -0
- package/dist/types/components/Menu/Menubar/constants.d.ts +25 -0
- package/dist/types/components/Menu/Menubar/index.d.ts +1 -0
- package/dist/types/components/Menu/Menubar/types.d.ts +15 -0
- package/dist/types/components/Menu/NavigationMenu/NavigationMenu.d.ts +17 -0
- package/dist/types/components/Menu/NavigationMenu/constants.d.ts +8 -0
- package/dist/types/components/Menu/NavigationMenu/index.d.ts +1 -0
- package/dist/types/components/Menu/NavigationMenu/types.d.ts +10 -0
- package/dist/types/components/Menu/index.d.ts +4 -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/components/Skeleton/constants.d.ts +2 -2
- package/dist/types/index.d.ts +3 -0
- package/package.json +9 -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/Menu/ContextMenu/ContextMenu.tsx +180 -0
- package/src/components/Menu/ContextMenu/constants.ts +0 -0
- package/src/components/Menu/ContextMenu/index.ts +1 -0
- package/src/components/Menu/ContextMenu/types.ts +60 -0
- package/src/components/Menu/DropdownMenu/DropdownMenu.tsx +183 -0
- package/src/components/Menu/DropdownMenu/index.ts +1 -0
- package/src/components/Menu/DropdownMenu/types.ts +60 -0
- package/src/components/Menu/Menubar/Menubar.tsx +204 -0
- package/src/components/Menu/Menubar/constants.ts +107 -0
- package/src/components/Menu/Menubar/index.ts +1 -0
- package/src/components/Menu/Menubar/types.ts +66 -0
- package/src/components/Menu/NavigationMenu/NavigationMenu.tsx +117 -0
- package/src/components/Menu/NavigationMenu/constants.ts +47 -0
- package/src/components/Menu/NavigationMenu/index.ts +1 -0
- package/src/components/Menu/NavigationMenu/types.ts +40 -0
- package/src/components/Menu/index.ts +4 -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 +3 -0
- package/vitest-setup.ts +3 -0
|
@@ -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,180 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import * as ContextMenuPrimitive from "@radix-ui/react-context-menu";
|
|
5
|
+
import {
|
|
6
|
+
CheckIcon,
|
|
7
|
+
ChevronRightIcon,
|
|
8
|
+
DotFilledIcon,
|
|
9
|
+
} from "@radix-ui/react-icons";
|
|
10
|
+
import type {
|
|
11
|
+
ContextMenuCheckboxItemProps,
|
|
12
|
+
ContextMenuContentProps,
|
|
13
|
+
ContextMenuItemProps,
|
|
14
|
+
ContextMenuLabelProps,
|
|
15
|
+
ContextMenuProps,
|
|
16
|
+
ContextMenuRadioItemProps,
|
|
17
|
+
ContextMenuSeparatorProps,
|
|
18
|
+
ContextMenuShortcutProps,
|
|
19
|
+
ContextMenuSubContentProps,
|
|
20
|
+
ContextMenuSubTriggerProps,
|
|
21
|
+
} from "./types";
|
|
22
|
+
import { cn } from "../../../utilities";
|
|
23
|
+
import {
|
|
24
|
+
getMenubarCheckboxItemClasses,
|
|
25
|
+
getMenubarContentClasses,
|
|
26
|
+
getMenubarItemClasses,
|
|
27
|
+
getMenubarLabelClasses,
|
|
28
|
+
getMenubarRadioItemClasses,
|
|
29
|
+
getMenubarSeparatorClasses,
|
|
30
|
+
getMenubarShortcutClasses,
|
|
31
|
+
getMenubarSubContentClasses,
|
|
32
|
+
getMenubarSubTriggerClasses,
|
|
33
|
+
} from "../Menubar/constants";
|
|
34
|
+
|
|
35
|
+
const ContextMenu = (props: ContextMenuProps) => (
|
|
36
|
+
<ContextMenuPrimitive.Root {...props} />
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const ContextMenuSubTrigger = forwardRef<
|
|
40
|
+
React.ElementRef<typeof ContextMenuPrimitive.SubTrigger>,
|
|
41
|
+
ContextMenuSubTriggerProps
|
|
42
|
+
>(({ className, inset, variant, children, ...props }, ref) => (
|
|
43
|
+
<ContextMenuPrimitive.SubTrigger
|
|
44
|
+
ref={ref}
|
|
45
|
+
className={cn(getMenubarSubTriggerClasses({ inset, variant }), className)}
|
|
46
|
+
{...props}
|
|
47
|
+
>
|
|
48
|
+
{children}
|
|
49
|
+
<ChevronRightIcon className="ml-auto h-4 w-4" />
|
|
50
|
+
</ContextMenuPrimitive.SubTrigger>
|
|
51
|
+
));
|
|
52
|
+
ContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName;
|
|
53
|
+
|
|
54
|
+
const ContextMenuSubContent = forwardRef<
|
|
55
|
+
React.ElementRef<typeof ContextMenuPrimitive.SubContent>,
|
|
56
|
+
ContextMenuSubContentProps
|
|
57
|
+
>(({ className, ...props }, ref) => (
|
|
58
|
+
<ContextMenuPrimitive.SubContent
|
|
59
|
+
ref={ref}
|
|
60
|
+
className={cn(getMenubarSubContentClasses(), className)}
|
|
61
|
+
{...props}
|
|
62
|
+
/>
|
|
63
|
+
));
|
|
64
|
+
ContextMenuSubContent.displayName = ContextMenuPrimitive.SubContent.displayName;
|
|
65
|
+
|
|
66
|
+
const ContextMenuContent = forwardRef<
|
|
67
|
+
React.ElementRef<typeof ContextMenuPrimitive.Content>,
|
|
68
|
+
ContextMenuContentProps
|
|
69
|
+
>(({ className, ...props }, ref) => (
|
|
70
|
+
<ContextMenuPrimitive.Portal>
|
|
71
|
+
<ContextMenuPrimitive.Content
|
|
72
|
+
ref={ref}
|
|
73
|
+
className={cn(getMenubarContentClasses(), className)}
|
|
74
|
+
{...props}
|
|
75
|
+
/>
|
|
76
|
+
</ContextMenuPrimitive.Portal>
|
|
77
|
+
));
|
|
78
|
+
ContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName;
|
|
79
|
+
|
|
80
|
+
const ContextMenuItem = forwardRef<
|
|
81
|
+
React.ElementRef<typeof ContextMenuPrimitive.Item>,
|
|
82
|
+
ContextMenuItemProps
|
|
83
|
+
>(({ className, inset, variant, ...props }, ref) => (
|
|
84
|
+
<ContextMenuPrimitive.Item
|
|
85
|
+
ref={ref}
|
|
86
|
+
className={cn(getMenubarItemClasses({ inset, variant }), className)}
|
|
87
|
+
{...props}
|
|
88
|
+
/>
|
|
89
|
+
));
|
|
90
|
+
ContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName;
|
|
91
|
+
|
|
92
|
+
const ContextMenuCheckboxItem = forwardRef<
|
|
93
|
+
React.ElementRef<typeof ContextMenuPrimitive.CheckboxItem>,
|
|
94
|
+
ContextMenuCheckboxItemProps
|
|
95
|
+
>(({ className, children, variant, ...props }, ref) => (
|
|
96
|
+
<ContextMenuPrimitive.CheckboxItem
|
|
97
|
+
ref={ref}
|
|
98
|
+
className={cn(getMenubarCheckboxItemClasses({ variant }), className)}
|
|
99
|
+
{...props}
|
|
100
|
+
>
|
|
101
|
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
102
|
+
<ContextMenuPrimitive.ItemIndicator>
|
|
103
|
+
<CheckIcon className="h-4 w-4" />
|
|
104
|
+
</ContextMenuPrimitive.ItemIndicator>
|
|
105
|
+
</span>
|
|
106
|
+
{children}
|
|
107
|
+
</ContextMenuPrimitive.CheckboxItem>
|
|
108
|
+
));
|
|
109
|
+
ContextMenuCheckboxItem.displayName =
|
|
110
|
+
ContextMenuPrimitive.CheckboxItem.displayName;
|
|
111
|
+
|
|
112
|
+
const ContextMenuRadioItem = forwardRef<
|
|
113
|
+
React.ElementRef<typeof ContextMenuPrimitive.RadioItem>,
|
|
114
|
+
ContextMenuRadioItemProps
|
|
115
|
+
>(({ className, children, variant, ...props }, ref) => (
|
|
116
|
+
<ContextMenuPrimitive.RadioItem
|
|
117
|
+
ref={ref}
|
|
118
|
+
className={cn(getMenubarRadioItemClasses({ variant }), className)}
|
|
119
|
+
{...props}
|
|
120
|
+
>
|
|
121
|
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
122
|
+
<ContextMenuPrimitive.ItemIndicator>
|
|
123
|
+
<DotFilledIcon className="h-4 w-4 fill-current" />
|
|
124
|
+
</ContextMenuPrimitive.ItemIndicator>
|
|
125
|
+
</span>
|
|
126
|
+
{children}
|
|
127
|
+
</ContextMenuPrimitive.RadioItem>
|
|
128
|
+
));
|
|
129
|
+
ContextMenuRadioItem.displayName = ContextMenuPrimitive.RadioItem.displayName;
|
|
130
|
+
|
|
131
|
+
const ContextMenuLabel = forwardRef<
|
|
132
|
+
React.ElementRef<typeof ContextMenuPrimitive.Label>,
|
|
133
|
+
ContextMenuLabelProps
|
|
134
|
+
>(({ className, inset, ...props }, ref) => (
|
|
135
|
+
<ContextMenuPrimitive.Label
|
|
136
|
+
ref={ref}
|
|
137
|
+
className={cn(getMenubarLabelClasses({ inset }), className)}
|
|
138
|
+
{...props}
|
|
139
|
+
/>
|
|
140
|
+
));
|
|
141
|
+
ContextMenuLabel.displayName = ContextMenuPrimitive.Label.displayName;
|
|
142
|
+
|
|
143
|
+
const ContextMenuSeparator = forwardRef<
|
|
144
|
+
React.ElementRef<typeof ContextMenuPrimitive.Separator>,
|
|
145
|
+
ContextMenuSeparatorProps
|
|
146
|
+
>(({ className, ...props }, ref) => (
|
|
147
|
+
<ContextMenuPrimitive.Separator
|
|
148
|
+
ref={ref}
|
|
149
|
+
className={cn(getMenubarSeparatorClasses(), className)}
|
|
150
|
+
{...props}
|
|
151
|
+
/>
|
|
152
|
+
));
|
|
153
|
+
ContextMenuSeparator.displayName = ContextMenuPrimitive.Separator.displayName;
|
|
154
|
+
|
|
155
|
+
const ContextMenuShortcut = ({
|
|
156
|
+
className,
|
|
157
|
+
...props
|
|
158
|
+
}: ContextMenuShortcutProps) => {
|
|
159
|
+
return (
|
|
160
|
+
<span className={cn(getMenubarShortcutClasses(), className)} {...props} />
|
|
161
|
+
);
|
|
162
|
+
};
|
|
163
|
+
ContextMenuShortcut.displayName = "ContextMenuShortcut";
|
|
164
|
+
|
|
165
|
+
ContextMenu.Trigger = ContextMenuPrimitive.Trigger;
|
|
166
|
+
ContextMenu.Group = ContextMenuPrimitive.Group;
|
|
167
|
+
ContextMenu.Portal = ContextMenuPrimitive.Portal;
|
|
168
|
+
ContextMenu.Sub = ContextMenuPrimitive.Sub;
|
|
169
|
+
ContextMenu.RadioGroup = ContextMenuPrimitive.RadioGroup;
|
|
170
|
+
ContextMenu.Content = ContextMenuContent;
|
|
171
|
+
ContextMenu.Item = ContextMenuItem;
|
|
172
|
+
ContextMenu.CheckboxItem = ContextMenuCheckboxItem;
|
|
173
|
+
ContextMenu.RadioItem = ContextMenuRadioItem;
|
|
174
|
+
ContextMenu.Label = ContextMenuLabel;
|
|
175
|
+
ContextMenu.Separator = ContextMenuSeparator;
|
|
176
|
+
ContextMenu.Shortcut = ContextMenuShortcut;
|
|
177
|
+
ContextMenu.SubContent = ContextMenuSubContent;
|
|
178
|
+
ContextMenu.SubTrigger = ContextMenuSubTrigger;
|
|
179
|
+
|
|
180
|
+
export { ContextMenu };
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ContextMenu } from "./ContextMenu";
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as ContextMenuPrimitive from "@radix-ui/react-context-menu";
|
|
2
|
+
import { type VariantProps } from "../../../libs";
|
|
3
|
+
import {
|
|
4
|
+
getMenubarCheckboxItemClasses,
|
|
5
|
+
getMenubarContentClasses,
|
|
6
|
+
getMenubarItemClasses,
|
|
7
|
+
getMenubarLabelClasses,
|
|
8
|
+
getMenubarRadioItemClasses,
|
|
9
|
+
getMenubarSeparatorClasses,
|
|
10
|
+
getMenubarShortcutClasses,
|
|
11
|
+
getMenubarSubContentClasses,
|
|
12
|
+
getMenubarSubTriggerClasses,
|
|
13
|
+
} from "../Menubar/constants";
|
|
14
|
+
|
|
15
|
+
export type ContextMenuProps = React.ComponentPropsWithoutRef<
|
|
16
|
+
typeof ContextMenuPrimitive.Root
|
|
17
|
+
>;
|
|
18
|
+
|
|
19
|
+
export type ContextMenuSubTriggerProps = React.ComponentPropsWithoutRef<
|
|
20
|
+
typeof ContextMenuPrimitive.SubTrigger
|
|
21
|
+
> &
|
|
22
|
+
VariantProps<typeof getMenubarSubTriggerClasses>;
|
|
23
|
+
|
|
24
|
+
export type ContextMenuContentProps = React.ComponentPropsWithoutRef<
|
|
25
|
+
typeof ContextMenuPrimitive.Content
|
|
26
|
+
> &
|
|
27
|
+
VariantProps<typeof getMenubarContentClasses>;
|
|
28
|
+
|
|
29
|
+
export type ContextMenuSubContentProps = React.ComponentPropsWithoutRef<
|
|
30
|
+
typeof ContextMenuPrimitive.SubContent
|
|
31
|
+
> &
|
|
32
|
+
VariantProps<typeof getMenubarSubContentClasses>;
|
|
33
|
+
|
|
34
|
+
export type ContextMenuItemProps = React.ComponentPropsWithoutRef<
|
|
35
|
+
typeof ContextMenuPrimitive.Item
|
|
36
|
+
> &
|
|
37
|
+
VariantProps<typeof getMenubarItemClasses>;
|
|
38
|
+
|
|
39
|
+
export type ContextMenuCheckboxItemProps = React.ComponentPropsWithoutRef<
|
|
40
|
+
typeof ContextMenuPrimitive.CheckboxItem
|
|
41
|
+
> &
|
|
42
|
+
VariantProps<typeof getMenubarCheckboxItemClasses>;
|
|
43
|
+
|
|
44
|
+
export type ContextMenuRadioItemProps = React.ComponentPropsWithoutRef<
|
|
45
|
+
typeof ContextMenuPrimitive.RadioItem
|
|
46
|
+
> &
|
|
47
|
+
VariantProps<typeof getMenubarRadioItemClasses>;
|
|
48
|
+
|
|
49
|
+
export type ContextMenuLabelProps = React.ComponentPropsWithoutRef<
|
|
50
|
+
typeof ContextMenuPrimitive.Label
|
|
51
|
+
> &
|
|
52
|
+
VariantProps<typeof getMenubarLabelClasses>;
|
|
53
|
+
|
|
54
|
+
export type ContextMenuSeparatorProps = React.ComponentPropsWithoutRef<
|
|
55
|
+
typeof ContextMenuPrimitive.Separator
|
|
56
|
+
> &
|
|
57
|
+
VariantProps<typeof getMenubarSeparatorClasses>;
|
|
58
|
+
|
|
59
|
+
export type ContextMenuShortcutProps = React.HTMLAttributes<HTMLSpanElement> &
|
|
60
|
+
VariantProps<typeof getMenubarShortcutClasses>;
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
5
|
+
import {
|
|
6
|
+
CheckIcon,
|
|
7
|
+
ChevronRightIcon,
|
|
8
|
+
DotFilledIcon,
|
|
9
|
+
} from "@radix-ui/react-icons";
|
|
10
|
+
import type {
|
|
11
|
+
DropdownMenuCheckboxItemProps,
|
|
12
|
+
DropdownMenuContentProps,
|
|
13
|
+
DropdownMenuItemProps,
|
|
14
|
+
DropdownMenuLabelProps,
|
|
15
|
+
DropdownMenuProps,
|
|
16
|
+
DropdownMenuRadioItemProps,
|
|
17
|
+
DropdownMenuSeparatorProps,
|
|
18
|
+
DropdownMenuShortcutProps,
|
|
19
|
+
DropdownMenuSubContentProps,
|
|
20
|
+
DropdownMenuSubTriggerProps,
|
|
21
|
+
} from "./types";
|
|
22
|
+
import { cn } from "../../../utilities";
|
|
23
|
+
import {
|
|
24
|
+
getMenubarCheckboxItemClasses,
|
|
25
|
+
getMenubarContentClasses,
|
|
26
|
+
getMenubarItemClasses,
|
|
27
|
+
getMenubarLabelClasses,
|
|
28
|
+
getMenubarRadioItemClasses,
|
|
29
|
+
getMenubarSeparatorClasses,
|
|
30
|
+
getMenubarShortcutClasses,
|
|
31
|
+
getMenubarSubContentClasses,
|
|
32
|
+
getMenubarSubTriggerClasses,
|
|
33
|
+
} from "../Menubar/constants";
|
|
34
|
+
|
|
35
|
+
const DropdownMenu = (props: DropdownMenuProps) => (
|
|
36
|
+
<DropdownMenuPrimitive.Root {...props} />
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const DropdownMenuSubTrigger = forwardRef<
|
|
40
|
+
React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
|
|
41
|
+
DropdownMenuSubTriggerProps
|
|
42
|
+
>(({ className, inset, variant, children, ...props }, ref) => (
|
|
43
|
+
<DropdownMenuPrimitive.SubTrigger
|
|
44
|
+
ref={ref}
|
|
45
|
+
className={cn(getMenubarSubTriggerClasses({ inset, variant }), className)}
|
|
46
|
+
{...props}
|
|
47
|
+
>
|
|
48
|
+
{children}
|
|
49
|
+
<ChevronRightIcon className="ml-auto h-4 w-4" />
|
|
50
|
+
</DropdownMenuPrimitive.SubTrigger>
|
|
51
|
+
));
|
|
52
|
+
DropdownMenuSubTrigger.displayName =
|
|
53
|
+
DropdownMenuPrimitive.SubTrigger.displayName;
|
|
54
|
+
|
|
55
|
+
const DropdownMenuSubContent = forwardRef<
|
|
56
|
+
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
|
|
57
|
+
DropdownMenuSubContentProps
|
|
58
|
+
>(({ className, ...props }, ref) => (
|
|
59
|
+
<DropdownMenuPrimitive.SubContent
|
|
60
|
+
ref={ref}
|
|
61
|
+
className={cn(getMenubarSubContentClasses(), className)}
|
|
62
|
+
{...props}
|
|
63
|
+
/>
|
|
64
|
+
));
|
|
65
|
+
DropdownMenuSubContent.displayName =
|
|
66
|
+
DropdownMenuPrimitive.SubContent.displayName;
|
|
67
|
+
|
|
68
|
+
const DropdownMenuContent = forwardRef<
|
|
69
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
|
|
70
|
+
DropdownMenuContentProps
|
|
71
|
+
>(({ className, sideOffset = 4, ...props }, ref) => (
|
|
72
|
+
<DropdownMenuPrimitive.Portal>
|
|
73
|
+
<DropdownMenuPrimitive.Content
|
|
74
|
+
ref={ref}
|
|
75
|
+
sideOffset={sideOffset}
|
|
76
|
+
className={cn(getMenubarContentClasses(), className)}
|
|
77
|
+
{...props}
|
|
78
|
+
/>
|
|
79
|
+
</DropdownMenuPrimitive.Portal>
|
|
80
|
+
));
|
|
81
|
+
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
|
82
|
+
|
|
83
|
+
const DropdownMenuItem = forwardRef<
|
|
84
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
|
|
85
|
+
DropdownMenuItemProps
|
|
86
|
+
>(({ className, inset, variant, ...props }, ref) => (
|
|
87
|
+
<DropdownMenuPrimitive.Item
|
|
88
|
+
ref={ref}
|
|
89
|
+
className={cn(getMenubarItemClasses({ inset, variant }), className)}
|
|
90
|
+
{...props}
|
|
91
|
+
/>
|
|
92
|
+
));
|
|
93
|
+
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
|
|
94
|
+
|
|
95
|
+
const DropdownMenuCheckboxItem = forwardRef<
|
|
96
|
+
React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
|
|
97
|
+
DropdownMenuCheckboxItemProps
|
|
98
|
+
>(({ className, children, variant, ...props }, ref) => (
|
|
99
|
+
<DropdownMenuPrimitive.CheckboxItem
|
|
100
|
+
ref={ref}
|
|
101
|
+
className={cn(getMenubarCheckboxItemClasses({ variant }), className)}
|
|
102
|
+
{...props}
|
|
103
|
+
>
|
|
104
|
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
105
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
|
106
|
+
<CheckIcon className="h-4 w-4" />
|
|
107
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
|
108
|
+
</span>
|
|
109
|
+
{children}
|
|
110
|
+
</DropdownMenuPrimitive.CheckboxItem>
|
|
111
|
+
));
|
|
112
|
+
DropdownMenuCheckboxItem.displayName =
|
|
113
|
+
DropdownMenuPrimitive.CheckboxItem.displayName;
|
|
114
|
+
|
|
115
|
+
const DropdownMenuRadioItem = forwardRef<
|
|
116
|
+
React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
|
|
117
|
+
DropdownMenuRadioItemProps
|
|
118
|
+
>(({ className, children, variant, ...props }, ref) => (
|
|
119
|
+
<DropdownMenuPrimitive.RadioItem
|
|
120
|
+
ref={ref}
|
|
121
|
+
className={cn(getMenubarRadioItemClasses({ variant }), className)}
|
|
122
|
+
{...props}
|
|
123
|
+
>
|
|
124
|
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
125
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
|
126
|
+
<DotFilledIcon className="h-4 w-4 fill-current" />
|
|
127
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
|
128
|
+
</span>
|
|
129
|
+
{children}
|
|
130
|
+
</DropdownMenuPrimitive.RadioItem>
|
|
131
|
+
));
|
|
132
|
+
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
|
|
133
|
+
|
|
134
|
+
const DropdownMenuLabel = forwardRef<
|
|
135
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Label>,
|
|
136
|
+
DropdownMenuLabelProps
|
|
137
|
+
>(({ className, inset, ...props }, ref) => (
|
|
138
|
+
<DropdownMenuPrimitive.Label
|
|
139
|
+
ref={ref}
|
|
140
|
+
className={cn(getMenubarLabelClasses({ inset }), className)}
|
|
141
|
+
{...props}
|
|
142
|
+
/>
|
|
143
|
+
));
|
|
144
|
+
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
|
|
145
|
+
|
|
146
|
+
const DropdownMenuSeparator = forwardRef<
|
|
147
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
|
|
148
|
+
DropdownMenuSeparatorProps
|
|
149
|
+
>(({ className, ...props }, ref) => (
|
|
150
|
+
<DropdownMenuPrimitive.Separator
|
|
151
|
+
ref={ref}
|
|
152
|
+
className={cn(getMenubarSeparatorClasses(), className)}
|
|
153
|
+
{...props}
|
|
154
|
+
/>
|
|
155
|
+
));
|
|
156
|
+
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
|
|
157
|
+
|
|
158
|
+
const DropdownMenuShortcut = ({
|
|
159
|
+
className,
|
|
160
|
+
...props
|
|
161
|
+
}: DropdownMenuShortcutProps) => {
|
|
162
|
+
return (
|
|
163
|
+
<span className={cn(getMenubarShortcutClasses(), className)} {...props} />
|
|
164
|
+
);
|
|
165
|
+
};
|
|
166
|
+
DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
|
|
167
|
+
|
|
168
|
+
DropdownMenu.Trigger = DropdownMenuPrimitive.Trigger;
|
|
169
|
+
DropdownMenu.Content = DropdownMenuContent;
|
|
170
|
+
DropdownMenu.Item = DropdownMenuItem;
|
|
171
|
+
DropdownMenu.CheckboxItem = DropdownMenuCheckboxItem;
|
|
172
|
+
DropdownMenu.RadioItem = DropdownMenuRadioItem;
|
|
173
|
+
DropdownMenu.Label = DropdownMenuLabel;
|
|
174
|
+
DropdownMenu.Separator = DropdownMenuSeparator;
|
|
175
|
+
DropdownMenu.Shortcut = DropdownMenuShortcut;
|
|
176
|
+
DropdownMenu.Group = DropdownMenuPrimitive.Group;
|
|
177
|
+
DropdownMenu.Portal = DropdownMenuPrimitive.Portal;
|
|
178
|
+
DropdownMenu.Sub = DropdownMenuPrimitive.Sub;
|
|
179
|
+
DropdownMenu.SubContent = DropdownMenuSubContent;
|
|
180
|
+
DropdownMenu.SubTrigger = DropdownMenuSubTrigger;
|
|
181
|
+
DropdownMenu.RadioGroup = DropdownMenuPrimitive.RadioGroup;
|
|
182
|
+
|
|
183
|
+
export { DropdownMenu };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DropdownMenu } from "./DropdownMenu";
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
2
|
+
import { type VariantProps } from "../../../libs";
|
|
3
|
+
import {
|
|
4
|
+
getMenubarCheckboxItemClasses,
|
|
5
|
+
getMenubarContentClasses,
|
|
6
|
+
getMenubarItemClasses,
|
|
7
|
+
getMenubarLabelClasses,
|
|
8
|
+
getMenubarRadioItemClasses,
|
|
9
|
+
getMenubarSeparatorClasses,
|
|
10
|
+
getMenubarShortcutClasses,
|
|
11
|
+
getMenubarSubContentClasses,
|
|
12
|
+
getMenubarSubTriggerClasses,
|
|
13
|
+
} from "../Menubar/constants";
|
|
14
|
+
|
|
15
|
+
export type DropdownMenuProps = React.ComponentPropsWithoutRef<
|
|
16
|
+
typeof DropdownMenuPrimitive.Root
|
|
17
|
+
>;
|
|
18
|
+
|
|
19
|
+
export type DropdownMenuSubTriggerProps = React.ComponentPropsWithoutRef<
|
|
20
|
+
typeof DropdownMenuPrimitive.SubTrigger
|
|
21
|
+
> &
|
|
22
|
+
VariantProps<typeof getMenubarSubTriggerClasses>;
|
|
23
|
+
|
|
24
|
+
export type DropdownMenuContentProps = React.ComponentPropsWithoutRef<
|
|
25
|
+
typeof DropdownMenuPrimitive.Content
|
|
26
|
+
> &
|
|
27
|
+
VariantProps<typeof getMenubarContentClasses>;
|
|
28
|
+
|
|
29
|
+
export type DropdownMenuSubContentProps = React.ComponentPropsWithoutRef<
|
|
30
|
+
typeof DropdownMenuPrimitive.SubContent
|
|
31
|
+
> &
|
|
32
|
+
VariantProps<typeof getMenubarSubContentClasses>;
|
|
33
|
+
|
|
34
|
+
export type DropdownMenuItemProps = React.ComponentPropsWithoutRef<
|
|
35
|
+
typeof DropdownMenuPrimitive.Item
|
|
36
|
+
> &
|
|
37
|
+
VariantProps<typeof getMenubarItemClasses>;
|
|
38
|
+
|
|
39
|
+
export type DropdownMenuCheckboxItemProps = React.ComponentPropsWithoutRef<
|
|
40
|
+
typeof DropdownMenuPrimitive.CheckboxItem
|
|
41
|
+
> &
|
|
42
|
+
VariantProps<typeof getMenubarCheckboxItemClasses>;
|
|
43
|
+
|
|
44
|
+
export type DropdownMenuRadioItemProps = React.ComponentPropsWithoutRef<
|
|
45
|
+
typeof DropdownMenuPrimitive.RadioItem
|
|
46
|
+
> &
|
|
47
|
+
VariantProps<typeof getMenubarRadioItemClasses>;
|
|
48
|
+
|
|
49
|
+
export type DropdownMenuLabelProps = React.ComponentPropsWithoutRef<
|
|
50
|
+
typeof DropdownMenuPrimitive.Label
|
|
51
|
+
> &
|
|
52
|
+
VariantProps<typeof getMenubarLabelClasses>;
|
|
53
|
+
|
|
54
|
+
export type DropdownMenuSeparatorProps = React.ComponentPropsWithoutRef<
|
|
55
|
+
typeof DropdownMenuPrimitive.Separator
|
|
56
|
+
> &
|
|
57
|
+
VariantProps<typeof getMenubarSeparatorClasses>;
|
|
58
|
+
|
|
59
|
+
export type DropdownMenuShortcutProps = React.HTMLAttributes<HTMLSpanElement> &
|
|
60
|
+
VariantProps<typeof getMenubarShortcutClasses>;
|