@mbao01/common 0.0.20 → 0.0.22
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/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/Skeleton/constants.d.ts +2 -2
- package/dist/types/components/Table/Table.d.ts +14 -0
- package/dist/types/components/Table/constants.d.ts +8 -0
- package/dist/types/components/Table/index.d.ts +1 -0
- package/dist/types/components/Table/types.d.ts +11 -0
- package/dist/types/components/ThemeSwitch/ThemeSwitch.d.ts +2 -0
- package/dist/types/components/ThemeSwitch/constants.d.ts +1 -0
- package/dist/types/components/ThemeSwitch/index.d.ts +1 -0
- package/dist/types/components/ThemeSwitch/types.d.ts +10 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/utilities/theme.d.ts +1 -2
- package/package.json +6 -2
- 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/Table/Table.tsx +85 -0
- package/src/components/Table/constants.ts +27 -0
- package/src/components/Table/index.ts +1 -0
- package/src/components/Table/types.ts +19 -0
- package/src/components/ThemeSwitch/ThemeSwitch.tsx +68 -0
- package/src/components/ThemeSwitch/constants.ts +5 -0
- package/src/components/ThemeSwitch/index.ts +1 -0
- package/src/components/ThemeSwitch/types.ts +10 -0
- package/src/index.ts +3 -0
- package/src/utilities/theme.ts +3 -5
|
@@ -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>;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import {
|
|
5
|
+
CheckIcon,
|
|
6
|
+
ChevronRightIcon,
|
|
7
|
+
DotFilledIcon,
|
|
8
|
+
} from "@radix-ui/react-icons";
|
|
9
|
+
import * as MenubarPrimitive from "@radix-ui/react-menubar";
|
|
10
|
+
import type {
|
|
11
|
+
MenubarCheckboxItemProps,
|
|
12
|
+
MenubarContentProps,
|
|
13
|
+
MenubarItemProps,
|
|
14
|
+
MenubarLabelProps,
|
|
15
|
+
MenubarProps,
|
|
16
|
+
MenubarRadioItemProps,
|
|
17
|
+
MenubarSeparatorProps,
|
|
18
|
+
MenubarShortcutProps,
|
|
19
|
+
MenubarSubContentProps,
|
|
20
|
+
MenubarSubTriggerProps,
|
|
21
|
+
MenubarTriggerProps,
|
|
22
|
+
} from "./types";
|
|
23
|
+
import { cn } from "../../../utilities";
|
|
24
|
+
import {
|
|
25
|
+
getMenubarCheckboxItemClasses,
|
|
26
|
+
getMenubarClasses,
|
|
27
|
+
getMenubarContentClasses,
|
|
28
|
+
getMenubarItemClasses,
|
|
29
|
+
getMenubarLabelClasses,
|
|
30
|
+
getMenubarRadioItemClasses,
|
|
31
|
+
getMenubarSeparatorClasses,
|
|
32
|
+
getMenubarShortcutClasses,
|
|
33
|
+
getMenubarSubContentClasses,
|
|
34
|
+
getMenubarSubTriggerClasses,
|
|
35
|
+
getMenubarTriggerClasses,
|
|
36
|
+
} from "./constants";
|
|
37
|
+
|
|
38
|
+
const Menubar = ({ className, ...props }: MenubarProps) => (
|
|
39
|
+
<MenubarPrimitive.Root
|
|
40
|
+
className={cn(getMenubarClasses(), className)}
|
|
41
|
+
{...props}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
Menubar.displayName = MenubarPrimitive.Root.displayName;
|
|
45
|
+
|
|
46
|
+
const MenubarTrigger = forwardRef<
|
|
47
|
+
React.ElementRef<typeof MenubarPrimitive.Trigger>,
|
|
48
|
+
MenubarTriggerProps
|
|
49
|
+
>(({ className, variant, ...props }, ref) => (
|
|
50
|
+
<MenubarPrimitive.Trigger
|
|
51
|
+
ref={ref}
|
|
52
|
+
className={cn(getMenubarTriggerClasses({ variant }), className)}
|
|
53
|
+
{...props}
|
|
54
|
+
/>
|
|
55
|
+
));
|
|
56
|
+
MenubarTrigger.displayName = MenubarPrimitive.Trigger.displayName;
|
|
57
|
+
|
|
58
|
+
const MenubarSubTrigger = forwardRef<
|
|
59
|
+
React.ElementRef<typeof MenubarPrimitive.SubTrigger>,
|
|
60
|
+
MenubarSubTriggerProps
|
|
61
|
+
>(({ className, inset, variant, children, ...props }, ref) => (
|
|
62
|
+
<MenubarPrimitive.SubTrigger
|
|
63
|
+
ref={ref}
|
|
64
|
+
className={cn(getMenubarSubTriggerClasses({ inset, variant }), className)}
|
|
65
|
+
{...props}
|
|
66
|
+
>
|
|
67
|
+
{children}
|
|
68
|
+
<ChevronRightIcon className="ml-auto h-4 w-4" />
|
|
69
|
+
</MenubarPrimitive.SubTrigger>
|
|
70
|
+
));
|
|
71
|
+
MenubarSubTrigger.displayName = MenubarPrimitive.SubTrigger.displayName;
|
|
72
|
+
|
|
73
|
+
const MenubarSubContent = forwardRef<
|
|
74
|
+
React.ElementRef<typeof MenubarPrimitive.SubContent>,
|
|
75
|
+
MenubarSubContentProps
|
|
76
|
+
>(({ className, ...props }, ref) => (
|
|
77
|
+
<MenubarPrimitive.SubContent
|
|
78
|
+
ref={ref}
|
|
79
|
+
className={cn(getMenubarSubContentClasses(), className)}
|
|
80
|
+
{...props}
|
|
81
|
+
/>
|
|
82
|
+
));
|
|
83
|
+
MenubarSubContent.displayName = MenubarPrimitive.SubContent.displayName;
|
|
84
|
+
|
|
85
|
+
const MenubarContent = forwardRef<
|
|
86
|
+
React.ElementRef<typeof MenubarPrimitive.Content>,
|
|
87
|
+
MenubarContentProps
|
|
88
|
+
>(
|
|
89
|
+
(
|
|
90
|
+
{ className, align = "start", alignOffset = -4, sideOffset = 8, ...props },
|
|
91
|
+
ref
|
|
92
|
+
) => (
|
|
93
|
+
<MenubarPrimitive.Portal>
|
|
94
|
+
<MenubarPrimitive.Content
|
|
95
|
+
ref={ref}
|
|
96
|
+
align={align}
|
|
97
|
+
alignOffset={alignOffset}
|
|
98
|
+
sideOffset={sideOffset}
|
|
99
|
+
className={cn(getMenubarContentClasses(), className)}
|
|
100
|
+
{...props}
|
|
101
|
+
/>
|
|
102
|
+
</MenubarPrimitive.Portal>
|
|
103
|
+
)
|
|
104
|
+
);
|
|
105
|
+
MenubarContent.displayName = MenubarPrimitive.Content.displayName;
|
|
106
|
+
|
|
107
|
+
const MenubarItem = forwardRef<
|
|
108
|
+
React.ElementRef<typeof MenubarPrimitive.Item>,
|
|
109
|
+
MenubarItemProps
|
|
110
|
+
>(({ className, inset, variant, ...props }, ref) => (
|
|
111
|
+
<MenubarPrimitive.Item
|
|
112
|
+
ref={ref}
|
|
113
|
+
className={cn(getMenubarItemClasses({ inset, variant }), className)}
|
|
114
|
+
{...props}
|
|
115
|
+
/>
|
|
116
|
+
));
|
|
117
|
+
MenubarItem.displayName = MenubarPrimitive.Item.displayName;
|
|
118
|
+
|
|
119
|
+
const MenubarCheckboxItem = forwardRef<
|
|
120
|
+
React.ElementRef<typeof MenubarPrimitive.CheckboxItem>,
|
|
121
|
+
MenubarCheckboxItemProps
|
|
122
|
+
>(({ className, children, variant, ...props }, ref) => (
|
|
123
|
+
<MenubarPrimitive.CheckboxItem
|
|
124
|
+
ref={ref}
|
|
125
|
+
className={cn(getMenubarCheckboxItemClasses({ variant }), className)}
|
|
126
|
+
{...props}
|
|
127
|
+
>
|
|
128
|
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
129
|
+
<MenubarPrimitive.ItemIndicator>
|
|
130
|
+
<CheckIcon className="h-4 w-4" />
|
|
131
|
+
</MenubarPrimitive.ItemIndicator>
|
|
132
|
+
</span>
|
|
133
|
+
{children}
|
|
134
|
+
</MenubarPrimitive.CheckboxItem>
|
|
135
|
+
));
|
|
136
|
+
MenubarCheckboxItem.displayName = MenubarPrimitive.CheckboxItem.displayName;
|
|
137
|
+
|
|
138
|
+
const MenubarRadioItem = forwardRef<
|
|
139
|
+
React.ElementRef<typeof MenubarPrimitive.RadioItem>,
|
|
140
|
+
MenubarRadioItemProps
|
|
141
|
+
>(({ className, children, variant, ...props }, ref) => (
|
|
142
|
+
<MenubarPrimitive.RadioItem
|
|
143
|
+
ref={ref}
|
|
144
|
+
className={cn(getMenubarRadioItemClasses({ variant }), className)}
|
|
145
|
+
{...props}
|
|
146
|
+
>
|
|
147
|
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
148
|
+
<MenubarPrimitive.ItemIndicator>
|
|
149
|
+
<DotFilledIcon className="h-4 w-4 fill-current" />
|
|
150
|
+
</MenubarPrimitive.ItemIndicator>
|
|
151
|
+
</span>
|
|
152
|
+
{children}
|
|
153
|
+
</MenubarPrimitive.RadioItem>
|
|
154
|
+
));
|
|
155
|
+
MenubarRadioItem.displayName = MenubarPrimitive.RadioItem.displayName;
|
|
156
|
+
|
|
157
|
+
const MenubarLabel = forwardRef<
|
|
158
|
+
React.ElementRef<typeof MenubarPrimitive.Label>,
|
|
159
|
+
MenubarLabelProps
|
|
160
|
+
>(({ className, inset, ...props }, ref) => (
|
|
161
|
+
<MenubarPrimitive.Label
|
|
162
|
+
ref={ref}
|
|
163
|
+
className={cn(getMenubarLabelClasses({ inset }), className)}
|
|
164
|
+
{...props}
|
|
165
|
+
/>
|
|
166
|
+
));
|
|
167
|
+
MenubarLabel.displayName = MenubarPrimitive.Label.displayName;
|
|
168
|
+
|
|
169
|
+
const MenubarSeparator = forwardRef<
|
|
170
|
+
React.ElementRef<typeof MenubarPrimitive.Separator>,
|
|
171
|
+
MenubarSeparatorProps
|
|
172
|
+
>(({ className, ...props }, ref) => (
|
|
173
|
+
<MenubarPrimitive.Separator
|
|
174
|
+
ref={ref}
|
|
175
|
+
className={cn(getMenubarSeparatorClasses(), className)}
|
|
176
|
+
{...props}
|
|
177
|
+
/>
|
|
178
|
+
));
|
|
179
|
+
MenubarSeparator.displayName = MenubarPrimitive.Separator.displayName;
|
|
180
|
+
|
|
181
|
+
const MenubarShortcut = ({ className, ...props }: MenubarShortcutProps) => {
|
|
182
|
+
return (
|
|
183
|
+
<span className={cn(getMenubarShortcutClasses(), className)} {...props} />
|
|
184
|
+
);
|
|
185
|
+
};
|
|
186
|
+
MenubarShortcut.displayname = "MenubarShortcut";
|
|
187
|
+
|
|
188
|
+
Menubar.Menu = MenubarPrimitive.Menu;
|
|
189
|
+
Menubar.Group = MenubarPrimitive.Group;
|
|
190
|
+
Menubar.Portal = MenubarPrimitive.Portal;
|
|
191
|
+
Menubar.Sub = MenubarPrimitive.Sub;
|
|
192
|
+
Menubar.RadioGroup = MenubarPrimitive.RadioGroup;
|
|
193
|
+
Menubar.Trigger = MenubarTrigger;
|
|
194
|
+
Menubar.Content = MenubarContent;
|
|
195
|
+
Menubar.Item = MenubarItem;
|
|
196
|
+
Menubar.Separator = MenubarSeparator;
|
|
197
|
+
Menubar.Label = MenubarLabel;
|
|
198
|
+
Menubar.CheckboxItem = MenubarCheckboxItem;
|
|
199
|
+
Menubar.RadioItem = MenubarRadioItem;
|
|
200
|
+
Menubar.SubContent = MenubarSubContent;
|
|
201
|
+
Menubar.SubTrigger = MenubarSubTrigger;
|
|
202
|
+
Menubar.Shortcut = MenubarShortcut;
|
|
203
|
+
|
|
204
|
+
export { Menubar };
|