@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,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>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import { cn } from "../../utilities";
|
|
3
|
+
import type {
|
|
4
|
+
TableBodyProps,
|
|
5
|
+
TableCaptionProps,
|
|
6
|
+
TableCellProps,
|
|
7
|
+
TableFooterProps,
|
|
8
|
+
TableHeadProps,
|
|
9
|
+
TableHeaderProps,
|
|
10
|
+
TableProps,
|
|
11
|
+
TableRowProps,
|
|
12
|
+
} from "./types";
|
|
13
|
+
import { getTableClasses, getTableHeaderClasses } from "./constants";
|
|
14
|
+
|
|
15
|
+
const Table = ({
|
|
16
|
+
className,
|
|
17
|
+
caption,
|
|
18
|
+
zebra,
|
|
19
|
+
size,
|
|
20
|
+
pinRow,
|
|
21
|
+
pinColumn,
|
|
22
|
+
...props
|
|
23
|
+
}: TableProps) => (
|
|
24
|
+
<div className="relative w-full overflow-auto">
|
|
25
|
+
<table
|
|
26
|
+
className={cn(
|
|
27
|
+
getTableClasses({ caption, zebra, size, pinRow, pinColumn }),
|
|
28
|
+
className
|
|
29
|
+
)}
|
|
30
|
+
{...props}
|
|
31
|
+
/>
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
|
+
Table.displayName = "Table";
|
|
35
|
+
|
|
36
|
+
const TableHeader = forwardRef<HTMLTableSectionElement, TableHeaderProps>(
|
|
37
|
+
({ className, ...props }, ref) => (
|
|
38
|
+
<thead
|
|
39
|
+
ref={ref}
|
|
40
|
+
className={cn(getTableHeaderClasses(), className)}
|
|
41
|
+
{...props}
|
|
42
|
+
/>
|
|
43
|
+
)
|
|
44
|
+
);
|
|
45
|
+
TableHeader.displayName = "TableHeader";
|
|
46
|
+
|
|
47
|
+
const TableBody = forwardRef<HTMLTableSectionElement, TableBodyProps>(
|
|
48
|
+
(props, ref) => <tbody ref={ref} {...props} />
|
|
49
|
+
);
|
|
50
|
+
TableBody.displayName = "TableBody";
|
|
51
|
+
|
|
52
|
+
const TableFooter = forwardRef<HTMLTableSectionElement, TableFooterProps>(
|
|
53
|
+
(props, ref) => <tfoot ref={ref} {...props} />
|
|
54
|
+
);
|
|
55
|
+
TableFooter.displayName = "TableFooter";
|
|
56
|
+
|
|
57
|
+
const TableRow = forwardRef<HTMLTableRowElement, TableRowProps>(
|
|
58
|
+
(props, ref) => <tr ref={ref} {...props} />
|
|
59
|
+
);
|
|
60
|
+
TableRow.displayName = "TableRow";
|
|
61
|
+
|
|
62
|
+
const TableHead = forwardRef<HTMLTableCellElement, TableHeadProps>(
|
|
63
|
+
(props, ref) => <th ref={ref} {...props} />
|
|
64
|
+
);
|
|
65
|
+
TableHead.displayName = "TableHead";
|
|
66
|
+
|
|
67
|
+
const TableCell = forwardRef<HTMLTableCellElement, TableCellProps>(
|
|
68
|
+
(props, ref) => <td ref={ref} {...props} />
|
|
69
|
+
);
|
|
70
|
+
TableCell.displayName = "TableCell";
|
|
71
|
+
|
|
72
|
+
const TableCaption = forwardRef<HTMLTableCaptionElement, TableCaptionProps>(
|
|
73
|
+
(props, ref) => <caption ref={ref} {...props} />
|
|
74
|
+
);
|
|
75
|
+
TableCaption.displayName = "TableCaption";
|
|
76
|
+
|
|
77
|
+
Table.Header = TableHeader;
|
|
78
|
+
Table.Body = TableBody;
|
|
79
|
+
Table.Footer = TableFooter;
|
|
80
|
+
Table.Head = TableHead;
|
|
81
|
+
Table.Row = TableRow;
|
|
82
|
+
Table.Cell = TableCell;
|
|
83
|
+
Table.Caption = TableCaption;
|
|
84
|
+
|
|
85
|
+
export { Table };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { cva } from "../../libs";
|
|
2
|
+
|
|
3
|
+
export const getTableClasses = cva("table", {
|
|
4
|
+
variants: {
|
|
5
|
+
caption: {
|
|
6
|
+
top: "caption-top",
|
|
7
|
+
bottom: "caption-bottom",
|
|
8
|
+
},
|
|
9
|
+
zebra: {
|
|
10
|
+
true: "table-zebra",
|
|
11
|
+
},
|
|
12
|
+
pinRow: {
|
|
13
|
+
true: "table-pin-rows",
|
|
14
|
+
},
|
|
15
|
+
pinColumn: {
|
|
16
|
+
true: "table-pin-cols",
|
|
17
|
+
},
|
|
18
|
+
size: {
|
|
19
|
+
xs: "table-xs",
|
|
20
|
+
sm: "table-sm",
|
|
21
|
+
md: "table-md",
|
|
22
|
+
lg: "table-lg",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export const getTableHeaderClasses = cva("[&_tr]:border-b");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Table } from "./Table";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { VariantProps } from "../../libs";
|
|
2
|
+
import { getTableClasses } from "./constants";
|
|
3
|
+
|
|
4
|
+
export type TableProps = React.HTMLAttributes<HTMLTableElement> &
|
|
5
|
+
VariantProps<typeof getTableClasses>;
|
|
6
|
+
|
|
7
|
+
export type TableHeaderProps = React.HTMLAttributes<HTMLTableSectionElement>;
|
|
8
|
+
|
|
9
|
+
export type TableBodyProps = React.HTMLAttributes<HTMLTableSectionElement>;
|
|
10
|
+
|
|
11
|
+
export type TableFooterProps = React.HTMLAttributes<HTMLTableSectionElement>;
|
|
12
|
+
|
|
13
|
+
export type TableRowProps = React.HTMLAttributes<HTMLTableRowElement>;
|
|
14
|
+
|
|
15
|
+
export type TableHeadProps = React.ThHTMLAttributes<HTMLTableCellElement>;
|
|
16
|
+
|
|
17
|
+
export type TableCellProps = React.TdHTMLAttributes<HTMLTableCellElement>;
|
|
18
|
+
|
|
19
|
+
export type TableCaptionProps = React.HTMLAttributes<HTMLTableCaptionElement>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { type ChangeEvent, useLayoutEffect, useState } from "react";
|
|
4
|
+
import { type ThemeSwitchProps } from "./types";
|
|
5
|
+
import { cn, getTheme, saveTheme } from "../../utilities";
|
|
6
|
+
import { getThemeSwitchClasses } from "./constants";
|
|
7
|
+
|
|
8
|
+
const MoonIcon = ({ title }: { title: string }) => (
|
|
9
|
+
<svg
|
|
10
|
+
className="swap-on h-4 w-4 fill-current"
|
|
11
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
12
|
+
viewBox="0 0 24 24"
|
|
13
|
+
>
|
|
14
|
+
{title && <title>{title}</title>}
|
|
15
|
+
<path d="M21.64,13a1,1,0,0,0-1.05-.14,8.05,8.05,0,0,1-3.37.73A8.15,8.15,0,0,1,9.08,5.49a8.59,8.59,0,0,1,.25-2A1,1,0,0,0,8,2.36,10.14,10.14,0,1,0,22,14.05,1,1,0,0,0,21.64,13Zm-9.5,6.69A8.14,8.14,0,0,1,7.08,5.22v.27A10.15,10.15,0,0,0,17.22,15.63a9.79,9.79,0,0,0,2.1-.22A8.11,8.11,0,0,1,12.14,19.73Z" />
|
|
16
|
+
</svg>
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const SunIcon = ({ title }: { title: string }) => (
|
|
20
|
+
<svg
|
|
21
|
+
className="swap-off h-4 w-4 fill-current"
|
|
22
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
23
|
+
viewBox="0 0 24 24"
|
|
24
|
+
xlinkTitle="sun-icon"
|
|
25
|
+
>
|
|
26
|
+
{title && <title>{title}</title>}
|
|
27
|
+
<path d="M5.64,17l-.71.71a1,1,0,0,0,0,1.41,1,1,0,0,0,1.41,0l.71-.71A1,1,0,0,0,5.64,17ZM5,12a1,1,0,0,0-1-1H3a1,1,0,0,0,0,2H4A1,1,0,0,0,5,12Zm7-7a1,1,0,0,0,1-1V3a1,1,0,0,0-2,0V4A1,1,0,0,0,12,5ZM5.64,7.05a1,1,0,0,0,.7.29,1,1,0,0,0,.71-.29,1,1,0,0,0,0-1.41l-.71-.71A1,1,0,0,0,4.93,6.34Zm12,.29a1,1,0,0,0,.7-.29l.71-.71a1,1,0,1,0-1.41-1.41L17,5.64a1,1,0,0,0,0,1.41A1,1,0,0,0,17.66,7.34ZM21,11H20a1,1,0,0,0,0,2h1a1,1,0,0,0,0-2Zm-9,8a1,1,0,0,0-1,1v1a1,1,0,0,0,2,0V20A1,1,0,0,0,12,19ZM18.36,17A1,1,0,0,0,17,18.36l.71.71a1,1,0,0,0,1.41,0,1,1,0,0,0,0-1.41ZM12,6.5A5.5,5.5,0,1,0,17.5,12,5.51,5.51,0,0,0,12,6.5Zm0,9A3.5,3.5,0,1,1,15.5,12,3.5,3.5,0,0,1,12,15.5Z" />
|
|
28
|
+
</svg>
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
export const ThemeSwitch = ({
|
|
32
|
+
name,
|
|
33
|
+
render,
|
|
34
|
+
className,
|
|
35
|
+
theme: defaultTheme,
|
|
36
|
+
...props
|
|
37
|
+
}: ThemeSwitchProps) => {
|
|
38
|
+
const [theme, setTheme] = useState(defaultTheme ?? getTheme);
|
|
39
|
+
|
|
40
|
+
useLayoutEffect(() => {
|
|
41
|
+
if (theme) saveTheme(theme);
|
|
42
|
+
}, [theme]);
|
|
43
|
+
|
|
44
|
+
if (render) {
|
|
45
|
+
return render({ theme, setTheme });
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const changeTheme = (e: ChangeEvent<HTMLInputElement>) => {
|
|
49
|
+
const t = e.target.checked ? "light" : "dark";
|
|
50
|
+
setTheme(t);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<label className={cn(getThemeSwitchClasses(), className)} {...props}>
|
|
55
|
+
{/* this hidden checkbox controls the state */}
|
|
56
|
+
<input
|
|
57
|
+
hidden
|
|
58
|
+
name={name}
|
|
59
|
+
type="checkbox"
|
|
60
|
+
className="theme-controller"
|
|
61
|
+
checked={theme === "light"}
|
|
62
|
+
onChange={changeTheme}
|
|
63
|
+
/>
|
|
64
|
+
<MoonIcon title="Switch to dark theme" />
|
|
65
|
+
<SunIcon title="Switch to light theme" />
|
|
66
|
+
</label>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ThemeSwitch } from "./ThemeSwitch";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Theme } from "../../utilities";
|
|
2
|
+
|
|
3
|
+
export type ThemeSwitchProps = React.ComponentPropsWithoutRef<"label"> & {
|
|
4
|
+
name?: string;
|
|
5
|
+
theme?: Theme;
|
|
6
|
+
render?: (params: {
|
|
7
|
+
theme: Theme | null;
|
|
8
|
+
setTheme: React.Dispatch<React.SetStateAction<Theme | null>>;
|
|
9
|
+
}) => JSX.Element;
|
|
10
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/** actions */
|
|
2
2
|
export * from "./components/Button";
|
|
3
3
|
export * from "./components/Breadcrumbs";
|
|
4
|
+
export * from "./components/Menu";
|
|
4
5
|
export * from "./components/Pagination";
|
|
6
|
+
export * from "./components/ThemeSwitch";
|
|
5
7
|
export * from "./components/Toggle";
|
|
6
8
|
export * from "./components/ToggleGroup";
|
|
7
9
|
|
|
@@ -18,6 +20,7 @@ export * from "./components/Progress";
|
|
|
18
20
|
export * from "./components/ScrollArea";
|
|
19
21
|
export * from "./components/Separator";
|
|
20
22
|
export * from "./components/Sonner";
|
|
23
|
+
export * from "./components/Table";
|
|
21
24
|
export * from "./components/Tabs";
|
|
22
25
|
export * from "./components/Text";
|
|
23
26
|
|
package/src/utilities/theme.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type Theme = "dark" | "light"
|
|
1
|
+
export type Theme = "dark" | "light";
|
|
2
2
|
|
|
3
3
|
export const getTheme = () => {
|
|
4
4
|
if (typeof window === "undefined") return null;
|
|
@@ -7,13 +7,11 @@ export const getTheme = () => {
|
|
|
7
7
|
if (!t)
|
|
8
8
|
t = window.matchMedia("(prefers-color-scheme: dark)")?.matches
|
|
9
9
|
? "dark"
|
|
10
|
-
:
|
|
11
|
-
? "light"
|
|
12
|
-
: "system";
|
|
10
|
+
: "light";
|
|
13
11
|
return t;
|
|
14
12
|
};
|
|
15
13
|
|
|
16
14
|
export const saveTheme = (theme: Theme) => {
|
|
17
15
|
document.body.setAttribute("data-theme", theme);
|
|
18
|
-
localStorage.setItem("__theme", theme);
|
|
16
|
+
window.localStorage.setItem("__theme", theme);
|
|
19
17
|
};
|