@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,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 };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { cva } from "../../../libs";
|
|
2
|
+
|
|
3
|
+
const itemVariant = {
|
|
4
|
+
primary: "focus:bg-primary focus:text-primary-content",
|
|
5
|
+
secondary: "focus:bg-secondary focus:text-secondary-content",
|
|
6
|
+
accent: "focus:bg-accent focus:text-accent-content",
|
|
7
|
+
neutral: "focus:bg-neutral focus:text-neutral-content",
|
|
8
|
+
base: "focus:bg-base-300 focus:text-base-content",
|
|
9
|
+
info: "focus:bg-info focus:text-info-content",
|
|
10
|
+
success: "focus:bg-success focus:text-success-content",
|
|
11
|
+
warning: "focus:bg-warning focus:text-warning-content",
|
|
12
|
+
error: "focus:bg-error focus:text-error-content",
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const triggerVariant = {
|
|
16
|
+
primary:
|
|
17
|
+
"focus:bg-primary focus:text-primary-content data-[state=open]:bg-primary data-[state=open]:text-primary-content",
|
|
18
|
+
secondary:
|
|
19
|
+
"focus:bg-secondary focus:text-secondary-content data-[state=open]:bg-secondary data-[state=open]:text-secondary-content",
|
|
20
|
+
accent:
|
|
21
|
+
"focus:bg-accent focus:text-accent-content data-[state=open]:bg-accent data-[state=open]:text-accent-content",
|
|
22
|
+
neutral:
|
|
23
|
+
"focus:bg-neutral focus:text-neutral-content data-[state=open]:bg-neutral data-[state=open]:text-neutral-content",
|
|
24
|
+
base: "focus:bg-base-300 focus:text-base-content data-[state=open]:bg-base-300 data-[state=open]:text-base-content",
|
|
25
|
+
info: "focus:bg-info focus:text-info-content data-[state=open]:bg-info data-[state=open]:text-info-content",
|
|
26
|
+
success:
|
|
27
|
+
"focus:bg-success focus:text-success-content data-[state=open]:bg-success data-[state=open]:text-success-content",
|
|
28
|
+
warning:
|
|
29
|
+
"focus:bg-warning focus:text-warning-content data-[state=open]:bg-warning data-[state=open]:text-warning-content",
|
|
30
|
+
error:
|
|
31
|
+
"focus:bg-error focus:text-error-content data-[state=open]:bg-error data-[state=open]:text-error-content",
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const getMenubarClasses = cva(
|
|
35
|
+
"flex h-9 items-center space-x-1 rounded-md border bg-base-100 p-1 shadow-sm"
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
export const getMenubarTriggerClasses = cva(
|
|
39
|
+
"flex cursor-default select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none",
|
|
40
|
+
{
|
|
41
|
+
variants: {
|
|
42
|
+
variant: triggerVariant,
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
export const getMenubarSubTriggerClasses = cva(
|
|
48
|
+
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none",
|
|
49
|
+
{
|
|
50
|
+
variants: {
|
|
51
|
+
variant: triggerVariant,
|
|
52
|
+
inset: {
|
|
53
|
+
true: "pl-8",
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
export const getMenubarContentClasses = cva(
|
|
60
|
+
"z-50 min-w-[12rem] overflow-hidden rounded-md border bg-base-100 p-1 text-base-content shadow-md data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
export const getMenubarSubContentClasses = cva(
|
|
64
|
+
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-base-100 p-1 text-base-content shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
export const getMenubarItemClasses = cva(
|
|
68
|
+
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
69
|
+
{
|
|
70
|
+
variants: {
|
|
71
|
+
variant: itemVariant,
|
|
72
|
+
inset: {
|
|
73
|
+
true: "pl-8",
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
export const getMenubarCheckboxItemClasses = cva(
|
|
80
|
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
81
|
+
{
|
|
82
|
+
variants: {
|
|
83
|
+
variant: itemVariant,
|
|
84
|
+
},
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
export const getMenubarRadioItemClasses = cva(
|
|
89
|
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
90
|
+
{
|
|
91
|
+
variants: {
|
|
92
|
+
variant: itemVariant,
|
|
93
|
+
},
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
export const getMenubarLabelClasses = cva("px-2 py-1.5 text-sm font-semibold", {
|
|
98
|
+
variants: {
|
|
99
|
+
inset: {
|
|
100
|
+
true: "pl-8",
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
export const getMenubarSeparatorClasses = cva("-mx-1 my-1 h-px bg-base-200");
|
|
106
|
+
|
|
107
|
+
export const getMenubarShortcutClasses = cva("ml-auto text-xs tracking-widest");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Menubar } from "./Menubar";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as MenubarPrimitive from "@radix-ui/react-menubar";
|
|
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
|
+
getMenubarTriggerClasses,
|
|
14
|
+
} from "./constants";
|
|
15
|
+
|
|
16
|
+
export type MenubarProps = React.ComponentPropsWithoutRef<
|
|
17
|
+
typeof MenubarPrimitive.Root
|
|
18
|
+
>;
|
|
19
|
+
|
|
20
|
+
export type MenubarTriggerProps = React.ComponentPropsWithoutRef<
|
|
21
|
+
typeof MenubarPrimitive.Trigger
|
|
22
|
+
> &
|
|
23
|
+
VariantProps<typeof getMenubarTriggerClasses>;
|
|
24
|
+
|
|
25
|
+
export type MenubarSubTriggerProps = React.ComponentPropsWithoutRef<
|
|
26
|
+
typeof MenubarPrimitive.SubTrigger
|
|
27
|
+
> &
|
|
28
|
+
VariantProps<typeof getMenubarSubTriggerClasses>;
|
|
29
|
+
|
|
30
|
+
export type MenubarContentProps = React.ComponentPropsWithoutRef<
|
|
31
|
+
typeof MenubarPrimitive.Content
|
|
32
|
+
> &
|
|
33
|
+
VariantProps<typeof getMenubarContentClasses>;
|
|
34
|
+
|
|
35
|
+
export type MenubarSubContentProps = React.ComponentPropsWithoutRef<
|
|
36
|
+
typeof MenubarPrimitive.SubContent
|
|
37
|
+
> &
|
|
38
|
+
VariantProps<typeof getMenubarSubContentClasses>;
|
|
39
|
+
|
|
40
|
+
export type MenubarItemProps = React.ComponentPropsWithoutRef<
|
|
41
|
+
typeof MenubarPrimitive.Item
|
|
42
|
+
> &
|
|
43
|
+
VariantProps<typeof getMenubarItemClasses>;
|
|
44
|
+
|
|
45
|
+
export type MenubarCheckboxItemProps = React.ComponentPropsWithoutRef<
|
|
46
|
+
typeof MenubarPrimitive.CheckboxItem
|
|
47
|
+
> &
|
|
48
|
+
VariantProps<typeof getMenubarCheckboxItemClasses>;
|
|
49
|
+
|
|
50
|
+
export type MenubarRadioItemProps = React.ComponentPropsWithoutRef<
|
|
51
|
+
typeof MenubarPrimitive.RadioItem
|
|
52
|
+
> &
|
|
53
|
+
VariantProps<typeof getMenubarRadioItemClasses>;
|
|
54
|
+
|
|
55
|
+
export type MenubarLabelProps = React.ComponentPropsWithoutRef<
|
|
56
|
+
typeof MenubarPrimitive.Label
|
|
57
|
+
> &
|
|
58
|
+
VariantProps<typeof getMenubarLabelClasses>;
|
|
59
|
+
|
|
60
|
+
export type MenubarSeparatorProps = React.ComponentPropsWithoutRef<
|
|
61
|
+
typeof MenubarPrimitive.Separator
|
|
62
|
+
> &
|
|
63
|
+
VariantProps<typeof getMenubarSeparatorClasses>;
|
|
64
|
+
|
|
65
|
+
export type MenubarShortcutProps = React.HTMLAttributes<HTMLSpanElement> &
|
|
66
|
+
VariantProps<typeof getMenubarShortcutClasses>;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import { ChevronDownIcon } from "@radix-ui/react-icons";
|
|
3
|
+
import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu";
|
|
4
|
+
import type {
|
|
5
|
+
NavigationMenuContentProps,
|
|
6
|
+
NavigationMenuIndicatorProps,
|
|
7
|
+
NavigationMenuListProps,
|
|
8
|
+
NavigationMenuProps,
|
|
9
|
+
NavigationMenuTriggerProps,
|
|
10
|
+
NavigationMenuViewportProps,
|
|
11
|
+
} from "./types";
|
|
12
|
+
import { cn } from "../../../utilities";
|
|
13
|
+
import {
|
|
14
|
+
getNavigationMenuClasses,
|
|
15
|
+
getNavigationMenuContentClasses,
|
|
16
|
+
getNavigationMenuIndicatorClasses,
|
|
17
|
+
getNavigationMenuListClasses,
|
|
18
|
+
getNavigationMenuTriggerClasses,
|
|
19
|
+
getNavigationMenuViewportClasses,
|
|
20
|
+
} from "./constants";
|
|
21
|
+
|
|
22
|
+
const NavigationMenu = ({
|
|
23
|
+
className,
|
|
24
|
+
children,
|
|
25
|
+
...props
|
|
26
|
+
}: NavigationMenuProps) => (
|
|
27
|
+
<NavigationMenuPrimitive.Root
|
|
28
|
+
className={cn(getNavigationMenuClasses(), className)}
|
|
29
|
+
{...props}
|
|
30
|
+
>
|
|
31
|
+
{children}
|
|
32
|
+
<NavigationMenuViewport />
|
|
33
|
+
</NavigationMenuPrimitive.Root>
|
|
34
|
+
);
|
|
35
|
+
NavigationMenu.displayName = NavigationMenuPrimitive.Root.displayName;
|
|
36
|
+
|
|
37
|
+
const NavigationMenuList = forwardRef<
|
|
38
|
+
React.ElementRef<typeof NavigationMenuPrimitive.List>,
|
|
39
|
+
NavigationMenuListProps
|
|
40
|
+
>(({ className, ...props }, ref) => (
|
|
41
|
+
<NavigationMenuPrimitive.List
|
|
42
|
+
ref={ref}
|
|
43
|
+
className={cn(getNavigationMenuListClasses(), className)}
|
|
44
|
+
{...props}
|
|
45
|
+
/>
|
|
46
|
+
));
|
|
47
|
+
NavigationMenuList.displayName = NavigationMenuPrimitive.List.displayName;
|
|
48
|
+
|
|
49
|
+
const NavigationMenuTrigger = forwardRef<
|
|
50
|
+
React.ElementRef<typeof NavigationMenuPrimitive.Trigger>,
|
|
51
|
+
NavigationMenuTriggerProps
|
|
52
|
+
>(({ className, children, variant, ...props }, ref) => (
|
|
53
|
+
<NavigationMenuPrimitive.Trigger
|
|
54
|
+
ref={ref}
|
|
55
|
+
className={cn(getNavigationMenuTriggerClasses({ variant }), className)}
|
|
56
|
+
{...props}
|
|
57
|
+
>
|
|
58
|
+
{children}{" "}
|
|
59
|
+
<ChevronDownIcon
|
|
60
|
+
className="relative top-[1px] ml-1 h-3 w-3 transition duration-300 group-data-[state=open]:rotate-180"
|
|
61
|
+
aria-hidden="true"
|
|
62
|
+
/>
|
|
63
|
+
</NavigationMenuPrimitive.Trigger>
|
|
64
|
+
));
|
|
65
|
+
NavigationMenuTrigger.displayName = NavigationMenuPrimitive.Trigger.displayName;
|
|
66
|
+
|
|
67
|
+
const NavigationMenuContent = forwardRef<
|
|
68
|
+
React.ElementRef<typeof NavigationMenuPrimitive.Content>,
|
|
69
|
+
NavigationMenuContentProps
|
|
70
|
+
>(({ className, ...props }, ref) => (
|
|
71
|
+
<NavigationMenuPrimitive.Content
|
|
72
|
+
ref={ref}
|
|
73
|
+
className={cn(getNavigationMenuContentClasses(), className)}
|
|
74
|
+
{...props}
|
|
75
|
+
/>
|
|
76
|
+
));
|
|
77
|
+
NavigationMenuContent.displayName = NavigationMenuPrimitive.Content.displayName;
|
|
78
|
+
|
|
79
|
+
const NavigationMenuViewport = forwardRef<
|
|
80
|
+
React.ElementRef<typeof NavigationMenuPrimitive.Viewport>,
|
|
81
|
+
NavigationMenuViewportProps
|
|
82
|
+
>(({ className, ...props }, ref) => (
|
|
83
|
+
<div className={cn("absolute left-0 top-full flex justify-center")}>
|
|
84
|
+
<NavigationMenuPrimitive.Viewport
|
|
85
|
+
className={cn(getNavigationMenuViewportClasses(), className)}
|
|
86
|
+
ref={ref}
|
|
87
|
+
{...props}
|
|
88
|
+
/>
|
|
89
|
+
</div>
|
|
90
|
+
));
|
|
91
|
+
NavigationMenuViewport.displayName =
|
|
92
|
+
NavigationMenuPrimitive.Viewport.displayName;
|
|
93
|
+
|
|
94
|
+
const NavigationMenuIndicator = forwardRef<
|
|
95
|
+
React.ElementRef<typeof NavigationMenuPrimitive.Indicator>,
|
|
96
|
+
NavigationMenuIndicatorProps
|
|
97
|
+
>(({ className, ...props }, ref) => (
|
|
98
|
+
<NavigationMenuPrimitive.Indicator
|
|
99
|
+
ref={ref}
|
|
100
|
+
className={cn(getNavigationMenuIndicatorClasses(), className)}
|
|
101
|
+
{...props}
|
|
102
|
+
>
|
|
103
|
+
<div className="relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md" />
|
|
104
|
+
</NavigationMenuPrimitive.Indicator>
|
|
105
|
+
));
|
|
106
|
+
NavigationMenuIndicator.displayName =
|
|
107
|
+
NavigationMenuPrimitive.Indicator.displayName;
|
|
108
|
+
|
|
109
|
+
NavigationMenu.List = NavigationMenuList;
|
|
110
|
+
NavigationMenu.Item = NavigationMenuPrimitive.Item;
|
|
111
|
+
NavigationMenu.Content = NavigationMenuContent;
|
|
112
|
+
NavigationMenu.Trigger = NavigationMenuTrigger;
|
|
113
|
+
NavigationMenu.Link = NavigationMenuPrimitive.Link;
|
|
114
|
+
NavigationMenu.Indicator = NavigationMenuIndicator;
|
|
115
|
+
NavigationMenu.Viewport = NavigationMenuViewport;
|
|
116
|
+
|
|
117
|
+
export { NavigationMenu };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { cva } from "../../../libs";
|
|
2
|
+
|
|
3
|
+
export const getNavigationMenuClasses = cva(
|
|
4
|
+
"relative z-10 flex max-w-max flex-1 items-center justify-center"
|
|
5
|
+
);
|
|
6
|
+
|
|
7
|
+
export const getNavigationMenuListClasses = cva(
|
|
8
|
+
"group flex flex-1 list-none items-center justify-center space-x-1"
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
export const getNavigationMenuTriggerClasses = cva(
|
|
12
|
+
"group inline-flex h-9 w-max items-center justify-center rounded-md px-4 py-2 text-sm font-medium transition-colors focus:outline-none disabled:pointer-events-none disabled:opacity-50",
|
|
13
|
+
{
|
|
14
|
+
variants: {
|
|
15
|
+
variant: {
|
|
16
|
+
primary:
|
|
17
|
+
"hover:bg-primary hover:text-primary-content focus:bg-primary focus:text-primary-content data-[active]:bg-primary/50 data-[state=open]:bg-primary/50",
|
|
18
|
+
secondary:
|
|
19
|
+
"hover:bg-secondary hover:text-secondary-content focus:bg-secondary focus:text-secondary-content data-[active]:bg-secondary/50 data-[state=open]:bg-secondary/50",
|
|
20
|
+
accent:
|
|
21
|
+
"hover:bg-accent hover:text-accent-content focus:bg-accent focus:text-accent-content data-[active]:bg-accent/50 data-[state=open]:bg-accent/50",
|
|
22
|
+
neutral:
|
|
23
|
+
"hover:bg-neutral hover:text-neutral-content focus:bg-neutral focus:text-neutral-content data-[active]:bg-neutral/50 data-[state=open]:bg-neutral/50",
|
|
24
|
+
base: "hover:bg-base-300 hover:text-base-content focus:bg-base-300 focus:text-base-content data-[active]:bg-base-300/50 data-[state=open]:bg-base-300/50",
|
|
25
|
+
info: "hover:bg-info hover:text-info-content focus:bg-info focus:text-info-content data-[active]:bg-info/50 data-[state=open]:bg-info/50",
|
|
26
|
+
success:
|
|
27
|
+
"hover:bg-success hover:text-success-content focus:bg-success focus:text-success-content data-[active]:bg-success/50 data-[state=open]:bg-success/50",
|
|
28
|
+
warning:
|
|
29
|
+
"hover:bg-warning hover:text-warning-content focus:bg-warning focus:text-warning-content data-[active]:bg-warning/50 data-[state=open]:bg-warning/50",
|
|
30
|
+
error:
|
|
31
|
+
"hover:bg-error hover:text-error-content focus:bg-error focus:text-error-content data-[active]:bg-error/50 data-[state=open]:bg-error/50",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
export const getNavigationMenuContentClasses = cva(
|
|
38
|
+
"left-0 top-0 w-full data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 md:absolute md:w-auto"
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
export const getNavigationMenuViewportClasses = cva(
|
|
42
|
+
"origin-top-center relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border bg-base-100 shadow data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 md:w-[var(--radix-navigation-menu-viewport-width)]"
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
export const getNavigationMenuIndicatorClasses = cva(
|
|
46
|
+
"top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in"
|
|
47
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NavigationMenu } from "./NavigationMenu";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu";
|
|
2
|
+
import { type VariantProps } from "../../../libs";
|
|
3
|
+
import {
|
|
4
|
+
getNavigationMenuClasses,
|
|
5
|
+
getNavigationMenuContentClasses,
|
|
6
|
+
getNavigationMenuIndicatorClasses,
|
|
7
|
+
getNavigationMenuListClasses,
|
|
8
|
+
getNavigationMenuTriggerClasses,
|
|
9
|
+
getNavigationMenuViewportClasses,
|
|
10
|
+
} from "./constants";
|
|
11
|
+
|
|
12
|
+
export type NavigationMenuProps = React.ComponentPropsWithoutRef<
|
|
13
|
+
typeof NavigationMenuPrimitive.Root
|
|
14
|
+
> &
|
|
15
|
+
VariantProps<typeof getNavigationMenuClasses>;
|
|
16
|
+
|
|
17
|
+
export type NavigationMenuListProps = React.ComponentPropsWithoutRef<
|
|
18
|
+
typeof NavigationMenuPrimitive.List
|
|
19
|
+
> &
|
|
20
|
+
VariantProps<typeof getNavigationMenuListClasses>;
|
|
21
|
+
|
|
22
|
+
export type NavigationMenuTriggerProps = React.ComponentPropsWithoutRef<
|
|
23
|
+
typeof NavigationMenuPrimitive.Trigger
|
|
24
|
+
> &
|
|
25
|
+
VariantProps<typeof getNavigationMenuTriggerClasses>;
|
|
26
|
+
|
|
27
|
+
export type NavigationMenuContentProps = React.ComponentPropsWithoutRef<
|
|
28
|
+
typeof NavigationMenuPrimitive.Content
|
|
29
|
+
> &
|
|
30
|
+
VariantProps<typeof getNavigationMenuContentClasses>;
|
|
31
|
+
|
|
32
|
+
export type NavigationMenuViewportProps = React.ComponentPropsWithoutRef<
|
|
33
|
+
typeof NavigationMenuPrimitive.Viewport
|
|
34
|
+
> &
|
|
35
|
+
VariantProps<typeof getNavigationMenuViewportClasses>;
|
|
36
|
+
|
|
37
|
+
export type NavigationMenuIndicatorProps = React.ComponentPropsWithoutRef<
|
|
38
|
+
typeof NavigationMenuPrimitive.Indicator
|
|
39
|
+
> &
|
|
40
|
+
VariantProps<typeof getNavigationMenuIndicatorClasses>;
|