@mbao01/common 0.0.6 → 0.0.8
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/Avatar/Avatar.d.ts +14 -0
- package/dist/types/components/Avatar/constants.d.ts +15 -0
- package/dist/types/components/Avatar/index.d.ts +1 -0
- package/dist/types/components/Avatar/types.d.ts +7 -0
- package/dist/types/components/Badge/types.d.ts +1 -0
- package/dist/types/components/Breadcrumbs/types.d.ts +1 -0
- package/dist/types/components/Combobox/Combobox.d.ts +2 -0
- package/dist/types/components/Combobox/index.d.ts +1 -0
- package/dist/types/components/Combobox/types.d.ts +19 -0
- package/dist/types/components/Command/Command.d.ts +67 -0
- package/dist/types/components/Command/constants.d.ts +11 -0
- package/dist/types/components/Command/index.d.ts +1 -0
- package/dist/types/components/Command/types.d.ts +8 -0
- package/dist/types/components/Description/types.d.ts +1 -0
- package/dist/types/components/Dialog/Dialog.d.ts +22 -0
- package/dist/types/components/Dialog/constants.d.ts +7 -0
- package/dist/types/components/Dialog/index.d.ts +1 -0
- package/dist/types/components/Dialog/types.d.ts +11 -0
- package/dist/types/components/Form/Checkbox/Checkbox.d.ts +6 -0
- package/dist/types/components/Form/Checkbox/constants.d.ts +4 -0
- package/dist/types/components/Form/Checkbox/index.d.ts +1 -0
- package/dist/types/components/Form/Checkbox/types.d.ts +4 -0
- package/dist/types/components/Form/Input/Input.d.ts +7 -0
- package/dist/types/components/Form/Input/constants.d.ts +6 -0
- package/dist/types/components/Form/Input/index.d.ts +1 -0
- package/dist/types/components/Form/Input/types.d.ts +4 -0
- package/dist/types/components/Form/Phone/Phone.d.ts +17 -0
- package/dist/types/components/Form/Phone/constants.d.ts +2 -0
- package/dist/types/components/Form/Phone/index.d.ts +1 -0
- package/dist/types/components/Form/Phone/types.d.ts +8 -0
- package/dist/types/components/Form/Radio/Radio.d.ts +6 -0
- package/dist/types/components/Form/Radio/constants.d.ts +4 -0
- package/dist/types/components/Form/Radio/index.d.ts +1 -0
- package/dist/types/components/Form/Radio/types.d.ts +4 -0
- package/dist/types/components/Form/Range/Range.d.ts +8 -0
- package/dist/types/components/Form/Range/constants.d.ts +6 -0
- package/dist/types/components/Form/Range/index.d.ts +1 -0
- package/dist/types/components/Form/Range/types.d.ts +4 -0
- package/dist/types/components/Form/Select/Select.d.ts +27 -0
- package/dist/types/components/Form/Select/constants.d.ts +17 -0
- package/dist/types/components/Form/Select/index.d.ts +1 -0
- package/dist/types/components/Form/Select/types.d.ts +7 -0
- package/dist/types/components/Form/Slider/Slider.d.ts +15 -0
- package/dist/types/components/Form/Slider/constants.d.ts +15 -0
- package/dist/types/components/Form/Slider/index.d.ts +1 -0
- package/dist/types/components/Form/Slider/types.d.ts +5 -0
- package/dist/types/components/Form/Switch/Switch.d.ts +6 -0
- package/dist/types/components/Form/Switch/constants.d.ts +4 -0
- package/dist/types/components/Form/Switch/index.d.ts +1 -0
- package/dist/types/components/Form/Switch/types.d.ts +4 -0
- package/dist/types/components/Form/TextField/TextField.d.ts +10 -0
- package/dist/types/components/Form/TextField/constants.d.ts +1 -0
- package/dist/types/components/Form/TextField/index.d.ts +1 -0
- package/dist/types/components/Form/TextField/types.d.ts +6 -0
- package/dist/types/components/Form/Textarea/Textarea.d.ts +8 -0
- package/dist/types/components/Form/Textarea/constants.d.ts +6 -0
- package/dist/types/components/Form/Textarea/index.d.ts +1 -0
- package/dist/types/components/Form/Textarea/types.d.ts +4 -0
- package/dist/types/components/Form/components/FormControl/FormControl.d.ts +2 -0
- package/dist/types/components/Form/components/FormControl/constants.d.ts +1 -0
- package/dist/types/components/Form/components/FormControl/index.d.ts +1 -0
- package/dist/types/components/Form/components/FormControl/types.d.ts +9 -0
- package/dist/types/components/Form/components/Label/Label.d.ts +7 -0
- package/dist/types/components/Form/components/Label/constants.d.ts +1 -0
- package/dist/types/components/Form/components/Label/index.d.ts +1 -0
- package/dist/types/components/Form/components/Label/types.d.ts +6 -0
- package/dist/types/components/Form/index.d.ts +11 -0
- package/dist/types/components/Loading/types.d.ts +1 -0
- package/dist/types/components/Popover/Popover.d.ts +9 -0
- package/dist/types/components/Popover/constants.d.ts +1 -0
- package/dist/types/components/Popover/index.d.ts +1 -0
- package/dist/types/components/Popover/types.d.ts +6 -0
- package/dist/types/components/Progress/Progress.d.ts +5 -0
- package/dist/types/components/Progress/constants.d.ts +6 -0
- package/dist/types/components/Progress/index.d.ts +1 -0
- package/dist/types/components/Progress/types.d.ts +5 -0
- package/dist/types/components/Separator/Separator.d.ts +2 -0
- package/dist/types/components/Separator/constants.d.ts +3 -0
- package/dist/types/components/Separator/index.d.ts +1 -0
- package/dist/types/components/Separator/types.d.ts +3 -0
- package/dist/types/components/Skeleton/constants.d.ts +2 -2
- package/dist/types/components/Skeleton/types.d.ts +1 -0
- package/dist/types/components/Text/Text.d.ts +2 -2
- package/dist/types/components/Text/types.d.ts +6 -2
- package/dist/types/components/Tooltip/types.d.ts +1 -0
- package/dist/types/index.d.ts +9 -0
- package/package.json +24 -13
- package/src/components/Avatar/Avatar.tsx +59 -0
- package/src/components/Avatar/constants.ts +69 -0
- package/src/components/Avatar/index.ts +1 -0
- package/src/components/Avatar/types.ts +25 -0
- package/src/components/Combobox/Combobox.tsx +82 -0
- package/src/components/Combobox/index.ts +1 -0
- package/src/components/Combobox/types.ts +21 -0
- package/src/components/Command/Command.tsx +142 -0
- package/src/components/Command/constants.ts +39 -0
- package/src/components/Command/index.ts +1 -0
- package/src/components/Command/types.ts +16 -0
- package/src/components/Dialog/Dialog.tsx +105 -0
- package/src/components/Dialog/constants.ts +27 -0
- package/src/components/Dialog/index.ts +1 -0
- package/src/components/Dialog/types.ts +40 -0
- package/src/components/Form/Checkbox/Checkbox.tsx +18 -0
- package/src/components/Form/Checkbox/constants.ts +21 -0
- package/src/components/Form/Checkbox/index.ts +1 -0
- package/src/components/Form/Checkbox/types.ts +8 -0
- package/src/components/Form/Input/Input.tsx +18 -0
- package/src/components/Form/Input/constants.ts +37 -0
- package/src/components/Form/Input/index.ts +1 -0
- package/src/components/Form/Input/types.ts +8 -0
- package/src/components/Form/Phone/Phone.tsx +120 -0
- package/src/components/Form/Phone/constants.ts +7 -0
- package/src/components/Form/Phone/index.ts +1 -0
- package/src/components/Form/Phone/types.ts +12 -0
- package/src/components/Form/Radio/Radio.tsx +18 -0
- package/src/components/Form/Radio/constants.ts +21 -0
- package/src/components/Form/Radio/index.ts +1 -0
- package/src/components/Form/Radio/types.ts +8 -0
- package/src/components/Form/Range/Range.tsx +22 -0
- package/src/components/Form/Range/constants.ts +31 -0
- package/src/components/Form/Range/index.ts +1 -0
- package/src/components/Form/Range/types.ts +8 -0
- package/src/components/Form/Select/Select.tsx +151 -0
- package/src/components/Form/Select/constants.ts +80 -0
- package/src/components/Form/Select/index.ts +1 -0
- package/src/components/Form/Select/types.ts +18 -0
- package/src/components/Form/Slider/Slider.tsx +43 -0
- package/src/components/Form/Slider/constants.ts +87 -0
- package/src/components/Form/Slider/index.ts +1 -0
- package/src/components/Form/Slider/types.ts +16 -0
- package/src/components/Form/Switch/Switch.tsx +19 -0
- package/src/components/Form/Switch/constants.ts +21 -0
- package/src/components/Form/Switch/index.ts +1 -0
- package/src/components/Form/Switch/types.ts +8 -0
- package/src/components/Form/TextField/TextField.tsx +37 -0
- package/src/components/Form/TextField/constants.ts +5 -0
- package/src/components/Form/TextField/index.ts +1 -0
- package/src/components/Form/TextField/types.ts +7 -0
- package/src/components/Form/Textarea/Textarea.tsx +22 -0
- package/src/components/Form/Textarea/constants.ts +37 -0
- package/src/components/Form/Textarea/index.ts +1 -0
- package/src/components/Form/Textarea/types.ts +8 -0
- package/src/components/Form/components/FormControl/FormControl.tsx +21 -0
- package/src/components/Form/components/FormControl/constants.ts +3 -0
- package/src/components/Form/components/FormControl/index.ts +1 -0
- package/src/components/Form/components/FormControl/types.ts +13 -0
- package/src/components/Form/components/Label/Label.tsx +22 -0
- package/src/components/Form/components/Label/constants.ts +3 -0
- package/src/components/Form/components/Label/index.ts +1 -0
- package/src/components/Form/components/Label/types.ts +10 -0
- package/src/components/Form/index.ts +11 -0
- package/src/components/Popover/Popover.tsx +30 -0
- package/src/components/Popover/constants.ts +5 -0
- package/src/components/Popover/index.ts +1 -0
- package/src/components/Popover/types.ts +12 -0
- package/src/components/Progress/Progress.tsx +31 -0
- package/src/components/Progress/constants.ts +49 -0
- package/src/components/Progress/index.ts +1 -0
- package/src/components/Progress/types.ts +9 -0
- package/src/components/Separator/Separator.tsx +20 -0
- package/src/components/Separator/constants.ts +10 -0
- package/src/components/Separator/index.ts +1 -0
- package/src/components/Separator/types.ts +5 -0
- package/src/components/Text/Text.tsx +3 -3
- package/src/components/Text/types.ts +8 -5
- package/src/index.ts +10 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/* eslint-disable react/prop-types */
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Command as CommandPrimitive } from "cmdk";
|
|
5
|
+
import { MagnifyingGlassIcon } from "@radix-ui/react-icons";
|
|
6
|
+
import type {
|
|
7
|
+
CommandProps,
|
|
8
|
+
CommandDialogProps,
|
|
9
|
+
CommandInputProps,
|
|
10
|
+
} from "./types";
|
|
11
|
+
import { Dialog } from "../Dialog";
|
|
12
|
+
import { cn } from "../../utilities";
|
|
13
|
+
import {
|
|
14
|
+
getDialogContentClasses,
|
|
15
|
+
getCommandClasses,
|
|
16
|
+
getCommandDialogClasses,
|
|
17
|
+
getCommandEmptyClasses,
|
|
18
|
+
getCommandInputClasses,
|
|
19
|
+
getCommandInputWrapperClasses,
|
|
20
|
+
getCommandListClasses,
|
|
21
|
+
getCommandGroupClasses,
|
|
22
|
+
getCommandSeparatorClasses,
|
|
23
|
+
getCommandItemClasses,
|
|
24
|
+
getCommandShortcutClasses,
|
|
25
|
+
} from "./constants";
|
|
26
|
+
|
|
27
|
+
const Command = ({ className, ...props }: CommandProps) => (
|
|
28
|
+
<CommandPrimitive className={cn(getCommandClasses(), className)} {...props} />
|
|
29
|
+
);
|
|
30
|
+
Command.displayName = CommandPrimitive.displayName;
|
|
31
|
+
|
|
32
|
+
const CommandDialog = ({ children, ...props }: CommandDialogProps) => {
|
|
33
|
+
return (
|
|
34
|
+
<Dialog {...props}>
|
|
35
|
+
<Dialog.Content className={cn(getDialogContentClasses())}>
|
|
36
|
+
<Command className={cn(getCommandDialogClasses())}>{children}</Command>
|
|
37
|
+
</Dialog.Content>
|
|
38
|
+
</Dialog>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const CommandInput = React.forwardRef<
|
|
43
|
+
React.ElementRef<typeof CommandPrimitive.Input>,
|
|
44
|
+
CommandInputProps
|
|
45
|
+
>(({ className, ...props }, ref) => (
|
|
46
|
+
// eslint-disable-next-line react/no-unknown-property
|
|
47
|
+
<div className={cn(getCommandInputWrapperClasses())} cmdk-input-wrapper="">
|
|
48
|
+
<MagnifyingGlassIcon className="mr-2 h-4 w-4 shrink-0 opacity-50" />
|
|
49
|
+
<CommandPrimitive.Input
|
|
50
|
+
ref={ref}
|
|
51
|
+
className={cn(getCommandInputClasses(), className)}
|
|
52
|
+
{...props}
|
|
53
|
+
/>
|
|
54
|
+
</div>
|
|
55
|
+
));
|
|
56
|
+
|
|
57
|
+
CommandInput.displayName = CommandPrimitive.Input.displayName;
|
|
58
|
+
|
|
59
|
+
const CommandList = React.forwardRef<
|
|
60
|
+
React.ElementRef<typeof CommandPrimitive.List>,
|
|
61
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
|
|
62
|
+
>(({ className, ...props }, ref) => (
|
|
63
|
+
<CommandPrimitive.List
|
|
64
|
+
ref={ref}
|
|
65
|
+
className={cn(getCommandListClasses(), className)}
|
|
66
|
+
{...props}
|
|
67
|
+
/>
|
|
68
|
+
));
|
|
69
|
+
|
|
70
|
+
CommandList.displayName = CommandPrimitive.List.displayName;
|
|
71
|
+
|
|
72
|
+
const CommandEmpty = React.forwardRef<
|
|
73
|
+
React.ElementRef<typeof CommandPrimitive.Empty>,
|
|
74
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
|
|
75
|
+
>(({ className, ...props }, ref) => (
|
|
76
|
+
<CommandPrimitive.Empty
|
|
77
|
+
ref={ref}
|
|
78
|
+
className={cn(getCommandEmptyClasses(), className)}
|
|
79
|
+
{...props}
|
|
80
|
+
/>
|
|
81
|
+
));
|
|
82
|
+
|
|
83
|
+
CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
|
|
84
|
+
|
|
85
|
+
const CommandGroup = React.forwardRef<
|
|
86
|
+
React.ElementRef<typeof CommandPrimitive.Group>,
|
|
87
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
|
|
88
|
+
>(({ className, ...props }, ref) => (
|
|
89
|
+
<CommandPrimitive.Group
|
|
90
|
+
ref={ref}
|
|
91
|
+
className={cn(getCommandGroupClasses(), className)}
|
|
92
|
+
{...props}
|
|
93
|
+
/>
|
|
94
|
+
));
|
|
95
|
+
|
|
96
|
+
CommandGroup.displayName = CommandPrimitive.Group.displayName;
|
|
97
|
+
|
|
98
|
+
const CommandSeparator = React.forwardRef<
|
|
99
|
+
React.ElementRef<typeof CommandPrimitive.Separator>,
|
|
100
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
|
|
101
|
+
>(({ className, ...props }, ref) => (
|
|
102
|
+
<CommandPrimitive.Separator
|
|
103
|
+
ref={ref}
|
|
104
|
+
className={cn(getCommandSeparatorClasses(), className)}
|
|
105
|
+
{...props}
|
|
106
|
+
/>
|
|
107
|
+
));
|
|
108
|
+
CommandSeparator.displayName = CommandPrimitive.Separator.displayName;
|
|
109
|
+
|
|
110
|
+
const CommandItem = React.forwardRef<
|
|
111
|
+
React.ElementRef<typeof CommandPrimitive.Item>,
|
|
112
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
|
|
113
|
+
>(({ className, ...props }, ref) => (
|
|
114
|
+
<CommandPrimitive.Item
|
|
115
|
+
ref={ref}
|
|
116
|
+
className={cn(getCommandItemClasses(), className)}
|
|
117
|
+
{...props}
|
|
118
|
+
/>
|
|
119
|
+
));
|
|
120
|
+
|
|
121
|
+
CommandItem.displayName = CommandPrimitive.Item.displayName;
|
|
122
|
+
|
|
123
|
+
const CommandShortcut = ({
|
|
124
|
+
className,
|
|
125
|
+
...props
|
|
126
|
+
}: React.HTMLAttributes<HTMLSpanElement>) => {
|
|
127
|
+
return (
|
|
128
|
+
<span className={cn(getCommandShortcutClasses(), className)} {...props} />
|
|
129
|
+
);
|
|
130
|
+
};
|
|
131
|
+
CommandShortcut.displayName = "CommandShortcut";
|
|
132
|
+
|
|
133
|
+
Command.Dialog = CommandDialog;
|
|
134
|
+
Command.Input = CommandInput;
|
|
135
|
+
Command.List = CommandList;
|
|
136
|
+
Command.Empty = CommandEmpty;
|
|
137
|
+
Command.Group = CommandGroup;
|
|
138
|
+
Command.Item = CommandItem;
|
|
139
|
+
Command.Shortcut = CommandShortcut;
|
|
140
|
+
Command.Separator = CommandSeparator;
|
|
141
|
+
|
|
142
|
+
export { Command };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { cva } from "../../libs";
|
|
2
|
+
|
|
3
|
+
export const getCommandClasses = cva(
|
|
4
|
+
"flex h-full w-full flex-col overflow-hidden rounded-md text-base-content"
|
|
5
|
+
);
|
|
6
|
+
|
|
7
|
+
export const getDialogContentClasses = cva("overflow-hidden p-0 shadow-lg");
|
|
8
|
+
|
|
9
|
+
export const getCommandDialogClasses = cva(
|
|
10
|
+
"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5"
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export const getCommandInputWrapperClasses = cva(
|
|
14
|
+
"flex items-center border-b px-3"
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
export const getCommandInputClasses = cva(
|
|
18
|
+
"flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50"
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export const getCommandListClasses = cva(
|
|
22
|
+
"max-h-[300px] overflow-y-auto overflow-x-hidden"
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export const getCommandEmptyClasses = cva("py-6 text-center text-sm");
|
|
26
|
+
|
|
27
|
+
export const getCommandGroupClasses = cva(
|
|
28
|
+
"overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground"
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
export const getCommandSeparatorClasses = cva("-mx-1 h-px bg-border");
|
|
32
|
+
|
|
33
|
+
export const getCommandItemClasses = cva(
|
|
34
|
+
"relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors aria-selected:bg-base-300 aria-selected:text-base-content aria-disabled:underline aria-disabled:pointer-events-none aria-disabled:opacity-50 aria-disabled:cursor-default"
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
export const getCommandShortcutClasses = cva(
|
|
38
|
+
"ml-auto text-xs tracking-widest text-muted-foreground"
|
|
39
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Command } from "./Command";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Command as CommandPrimitive } from "cmdk";
|
|
2
|
+
import { type DialogProps } from "../Dialog/types";
|
|
3
|
+
import { type VariantProps } from "../../libs";
|
|
4
|
+
import { getCommandClasses, getCommandInputClasses } from "./constants";
|
|
5
|
+
|
|
6
|
+
export type CommandProps = React.ComponentPropsWithoutRef<
|
|
7
|
+
typeof CommandPrimitive
|
|
8
|
+
> &
|
|
9
|
+
VariantProps<typeof getCommandClasses>;
|
|
10
|
+
|
|
11
|
+
export type CommandInputProps = React.ComponentPropsWithoutRef<
|
|
12
|
+
typeof CommandPrimitive.Input
|
|
13
|
+
> &
|
|
14
|
+
VariantProps<typeof getCommandInputClasses>;
|
|
15
|
+
|
|
16
|
+
export type CommandDialogProps = DialogProps;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
5
|
+
import { Cross2Icon } from "@radix-ui/react-icons";
|
|
6
|
+
import type {
|
|
7
|
+
DialogProps,
|
|
8
|
+
DialogFooterProps,
|
|
9
|
+
DialogHeaderProps,
|
|
10
|
+
DialogTitleProps,
|
|
11
|
+
DialogDescriptionProps,
|
|
12
|
+
DialogOverlayProps,
|
|
13
|
+
DialogContentProps,
|
|
14
|
+
} from "./types";
|
|
15
|
+
import { cn } from "../../utilities";
|
|
16
|
+
import {
|
|
17
|
+
getDialogCloseClasses,
|
|
18
|
+
getDialogContentClasses,
|
|
19
|
+
getDialogDescriptionClasses,
|
|
20
|
+
getDialogFooterClasses,
|
|
21
|
+
getDialogHeaderClasses,
|
|
22
|
+
getDialogOverlayClasses,
|
|
23
|
+
getDialogTitleClasses,
|
|
24
|
+
} from "./constants";
|
|
25
|
+
|
|
26
|
+
const Dialog = (props: DialogProps) => <DialogPrimitive.Root {...props} />;
|
|
27
|
+
|
|
28
|
+
const DialogOverlay = React.forwardRef<
|
|
29
|
+
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
|
30
|
+
DialogOverlayProps
|
|
31
|
+
>(({ className, ...props }, ref) => (
|
|
32
|
+
<DialogPrimitive.Overlay
|
|
33
|
+
ref={ref}
|
|
34
|
+
className={cn(getDialogOverlayClasses(), className)}
|
|
35
|
+
{...props}
|
|
36
|
+
/>
|
|
37
|
+
));
|
|
38
|
+
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
39
|
+
|
|
40
|
+
const DialogContent = React.forwardRef<
|
|
41
|
+
React.ElementRef<typeof DialogPrimitive.Content>,
|
|
42
|
+
DialogContentProps
|
|
43
|
+
>(({ className, children, ...props }, ref) => (
|
|
44
|
+
<DialogPrimitive.Portal>
|
|
45
|
+
<DialogOverlay />
|
|
46
|
+
<DialogPrimitive.Content
|
|
47
|
+
ref={ref}
|
|
48
|
+
className={cn(getDialogContentClasses(), className)}
|
|
49
|
+
{...props}
|
|
50
|
+
>
|
|
51
|
+
{children}
|
|
52
|
+
<DialogPrimitive.Close className={cn(getDialogCloseClasses())}>
|
|
53
|
+
<Cross2Icon className="h-4 w-4" />
|
|
54
|
+
<span className="sr-only">Close</span>
|
|
55
|
+
</DialogPrimitive.Close>
|
|
56
|
+
</DialogPrimitive.Content>
|
|
57
|
+
</DialogPrimitive.Portal>
|
|
58
|
+
));
|
|
59
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
60
|
+
|
|
61
|
+
const DialogHeader = ({ className, ...props }: DialogHeaderProps) => (
|
|
62
|
+
<div className={cn(getDialogHeaderClasses(), className)} {...props} />
|
|
63
|
+
);
|
|
64
|
+
DialogHeader.displayName = "DialogHeader";
|
|
65
|
+
|
|
66
|
+
const DialogFooter = ({ className, ...props }: DialogFooterProps) => (
|
|
67
|
+
<div className={cn(getDialogFooterClasses(), className)} {...props} />
|
|
68
|
+
);
|
|
69
|
+
DialogFooter.displayName = "DialogFooter";
|
|
70
|
+
|
|
71
|
+
const DialogTitle = React.forwardRef<
|
|
72
|
+
React.ElementRef<typeof DialogPrimitive.Title>,
|
|
73
|
+
DialogTitleProps
|
|
74
|
+
>(({ className, ...props }, ref) => (
|
|
75
|
+
<DialogPrimitive.Title
|
|
76
|
+
ref={ref}
|
|
77
|
+
className={cn(getDialogTitleClasses(), className)}
|
|
78
|
+
{...props}
|
|
79
|
+
/>
|
|
80
|
+
));
|
|
81
|
+
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
82
|
+
|
|
83
|
+
const DialogDescription = React.forwardRef<
|
|
84
|
+
React.ElementRef<typeof DialogPrimitive.Description>,
|
|
85
|
+
DialogDescriptionProps
|
|
86
|
+
>(({ className, ...props }, ref) => (
|
|
87
|
+
<DialogPrimitive.Description
|
|
88
|
+
ref={ref}
|
|
89
|
+
className={cn(getDialogDescriptionClasses(), className)}
|
|
90
|
+
{...props}
|
|
91
|
+
/>
|
|
92
|
+
));
|
|
93
|
+
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
94
|
+
|
|
95
|
+
Dialog.Trigger = DialogPrimitive.Trigger;
|
|
96
|
+
Dialog.Portal = DialogPrimitive.Portal;
|
|
97
|
+
Dialog.Close = DialogPrimitive.Close;
|
|
98
|
+
Dialog.Header = DialogHeader;
|
|
99
|
+
Dialog.Title = DialogTitle;
|
|
100
|
+
Dialog.Description = DialogDescription;
|
|
101
|
+
Dialog.Content = DialogContent;
|
|
102
|
+
Dialog.Footer = DialogFooter;
|
|
103
|
+
Dialog.Overlay = DialogOverlay;
|
|
104
|
+
|
|
105
|
+
export { Dialog };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { cva } from "../../libs";
|
|
2
|
+
|
|
3
|
+
export const getDialogOverlayClasses = cva(
|
|
4
|
+
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"
|
|
5
|
+
);
|
|
6
|
+
|
|
7
|
+
export const getDialogContentClasses = cva(
|
|
8
|
+
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-base-100 p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg"
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
export const getDialogHeaderClasses = cva(
|
|
12
|
+
"flex flex-col space-y-1.5 text-center sm:text-left"
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export const getDialogFooterClasses = cva(
|
|
16
|
+
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2"
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export const getDialogTitleClasses = cva(
|
|
20
|
+
"text-lg font-semibold leading-none tracking-tight"
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export const getDialogDescriptionClasses = cva("text-sm text-muted-foreground");
|
|
24
|
+
|
|
25
|
+
export const getDialogCloseClasses = cva(
|
|
26
|
+
"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"
|
|
27
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Dialog } from "./Dialog";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
2
|
+
import { type VariantProps } from "../../libs";
|
|
3
|
+
import {
|
|
4
|
+
getDialogContentClasses,
|
|
5
|
+
getDialogDescriptionClasses,
|
|
6
|
+
getDialogFooterClasses,
|
|
7
|
+
getDialogHeaderClasses,
|
|
8
|
+
getDialogOverlayClasses,
|
|
9
|
+
getDialogTitleClasses,
|
|
10
|
+
} from "./constants";
|
|
11
|
+
|
|
12
|
+
export type DialogProps = React.ComponentPropsWithoutRef<
|
|
13
|
+
typeof DialogPrimitive.Root
|
|
14
|
+
>;
|
|
15
|
+
|
|
16
|
+
export type DialogOverlayProps = React.ComponentPropsWithoutRef<
|
|
17
|
+
typeof DialogPrimitive.Overlay
|
|
18
|
+
> &
|
|
19
|
+
VariantProps<typeof getDialogOverlayClasses>;
|
|
20
|
+
|
|
21
|
+
export type DialogContentProps = React.ComponentPropsWithoutRef<
|
|
22
|
+
typeof DialogPrimitive.Content
|
|
23
|
+
> &
|
|
24
|
+
VariantProps<typeof getDialogContentClasses>;
|
|
25
|
+
|
|
26
|
+
export type DialogHeaderProps = React.HTMLAttributes<HTMLDivElement> &
|
|
27
|
+
VariantProps<typeof getDialogHeaderClasses>;
|
|
28
|
+
|
|
29
|
+
export type DialogFooterProps = React.HTMLAttributes<HTMLDivElement> &
|
|
30
|
+
VariantProps<typeof getDialogFooterClasses>;
|
|
31
|
+
|
|
32
|
+
export type DialogTitleProps = React.ComponentPropsWithoutRef<
|
|
33
|
+
typeof DialogPrimitive.Title
|
|
34
|
+
> &
|
|
35
|
+
VariantProps<typeof getDialogTitleClasses>;
|
|
36
|
+
|
|
37
|
+
export type DialogDescriptionProps = React.ComponentPropsWithoutRef<
|
|
38
|
+
typeof DialogPrimitive.Description
|
|
39
|
+
> &
|
|
40
|
+
VariantProps<typeof getDialogDescriptionClasses>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type CheckboxProps } from "./types";
|
|
3
|
+
import { getCheckboxClasses } from "./constants";
|
|
4
|
+
import { cn } from "../../../utilities";
|
|
5
|
+
|
|
6
|
+
const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(
|
|
7
|
+
({ className, size, variant, ...props }, ref) => (
|
|
8
|
+
<input
|
|
9
|
+
ref={ref}
|
|
10
|
+
type="checkbox"
|
|
11
|
+
className={cn(getCheckboxClasses({ size, variant }), className)}
|
|
12
|
+
{...props}
|
|
13
|
+
/>
|
|
14
|
+
)
|
|
15
|
+
);
|
|
16
|
+
Checkbox.displayName = "Checkbox";
|
|
17
|
+
|
|
18
|
+
export { Checkbox };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { cva } from "../../../libs";
|
|
2
|
+
|
|
3
|
+
export const getCheckboxClasses = cva("checkbox", {
|
|
4
|
+
variants: {
|
|
5
|
+
variant: {
|
|
6
|
+
primary: "checkbox-primary",
|
|
7
|
+
secondary: "checkbox-secondary",
|
|
8
|
+
accent: "checkbox-accent",
|
|
9
|
+
success: "checkbox-success",
|
|
10
|
+
warning: "checkbox-warning",
|
|
11
|
+
info: "checkbox-info",
|
|
12
|
+
error: "checkbox-error",
|
|
13
|
+
},
|
|
14
|
+
size: {
|
|
15
|
+
xs: "checkbox-xs",
|
|
16
|
+
sm: "checkbox-sm",
|
|
17
|
+
md: "checkbox-md",
|
|
18
|
+
lg: "checkbox-lg",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Checkbox } from "./Checkbox";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type InputProps } from "./types";
|
|
3
|
+
import { cn } from "../../../utilities";
|
|
4
|
+
import { getInputClasses } from "./constants";
|
|
5
|
+
|
|
6
|
+
export const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
7
|
+
({ size, variant, wide, outline, className, ...props }: InputProps, ref) => (
|
|
8
|
+
<input
|
|
9
|
+
ref={ref}
|
|
10
|
+
className={cn(
|
|
11
|
+
getInputClasses({ size, wide, variant, outline }),
|
|
12
|
+
className
|
|
13
|
+
)}
|
|
14
|
+
{...props}
|
|
15
|
+
/>
|
|
16
|
+
)
|
|
17
|
+
);
|
|
18
|
+
Input.displayName = "Input";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { cva } from "../../../libs";
|
|
2
|
+
|
|
3
|
+
export const getInputClasses = cva(
|
|
4
|
+
"input rounded-md transition-all duration-100",
|
|
5
|
+
{
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
accent: "input-accent",
|
|
9
|
+
error: "input-error",
|
|
10
|
+
ghost: "input-ghost",
|
|
11
|
+
info: "input-info",
|
|
12
|
+
primary: "input-primary",
|
|
13
|
+
secondary: "input-secondary",
|
|
14
|
+
success: "input-success",
|
|
15
|
+
warning: "input-warning",
|
|
16
|
+
},
|
|
17
|
+
outline: {
|
|
18
|
+
true: "input-bordered",
|
|
19
|
+
},
|
|
20
|
+
wide: {
|
|
21
|
+
true: "w-full",
|
|
22
|
+
},
|
|
23
|
+
size: {
|
|
24
|
+
xs: "input-xs",
|
|
25
|
+
sm: "input-sm",
|
|
26
|
+
md: "input-md",
|
|
27
|
+
lg: "input-lg",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
compoundVariants: [
|
|
31
|
+
{
|
|
32
|
+
size: undefined,
|
|
33
|
+
className: "min-h-fit h-10",
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
}
|
|
37
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Input } from "./Input";
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React, { MutableRefObject } from "react";
|
|
4
|
+
import {
|
|
5
|
+
defaultCountries,
|
|
6
|
+
usePhoneInput,
|
|
7
|
+
FlagImage,
|
|
8
|
+
} from "react-international-phone";
|
|
9
|
+
import { type PhoneProps } from "./types";
|
|
10
|
+
import { Popover } from "../../Popover";
|
|
11
|
+
import { Command } from "../../Command";
|
|
12
|
+
import { cn } from "../../../utilities";
|
|
13
|
+
import { Button } from "../../Button";
|
|
14
|
+
import { Input } from "../Input";
|
|
15
|
+
import { getPhoneButtonClasses, getPhoneInputClasses } from "./constants";
|
|
16
|
+
import { getInputClasses } from "../Input/constants";
|
|
17
|
+
import { getButtonClasses } from "../../Button/constants";
|
|
18
|
+
|
|
19
|
+
const Phone = React.forwardRef<HTMLInputElement, PhoneProps>(
|
|
20
|
+
(
|
|
21
|
+
{
|
|
22
|
+
defaultValue,
|
|
23
|
+
className,
|
|
24
|
+
placeholder,
|
|
25
|
+
onChange,
|
|
26
|
+
inputProps,
|
|
27
|
+
buttonProps,
|
|
28
|
+
...props
|
|
29
|
+
},
|
|
30
|
+
ref
|
|
31
|
+
) => {
|
|
32
|
+
const [open, setOpen] = React.useState(false);
|
|
33
|
+
const {
|
|
34
|
+
inputValue,
|
|
35
|
+
handlePhoneValueChange,
|
|
36
|
+
inputRef,
|
|
37
|
+
country,
|
|
38
|
+
setCountry,
|
|
39
|
+
} = usePhoneInput({
|
|
40
|
+
value: String(defaultValue) ?? "+231",
|
|
41
|
+
defaultCountry: "lr",
|
|
42
|
+
forceDialCode: true,
|
|
43
|
+
inputRef: ref as MutableRefObject<HTMLInputElement | null>,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const options = defaultCountries.map((country) => ({
|
|
47
|
+
label: country[0],
|
|
48
|
+
value: country[1],
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
52
|
+
handlePhoneValueChange(e);
|
|
53
|
+
onChange?.(e);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<div className="join">
|
|
58
|
+
<Popover open={open} onOpenChange={setOpen}>
|
|
59
|
+
<Popover.Trigger asChild>
|
|
60
|
+
<Button
|
|
61
|
+
role="combobox"
|
|
62
|
+
aria-expanded={open}
|
|
63
|
+
className={cn(
|
|
64
|
+
getPhoneButtonClasses(),
|
|
65
|
+
getButtonClasses(buttonProps)
|
|
66
|
+
)}
|
|
67
|
+
>
|
|
68
|
+
<FlagImage iso2={country.iso2} size="30px" />
|
|
69
|
+
</Button>
|
|
70
|
+
</Popover.Trigger>
|
|
71
|
+
<Popover.Content className="w-[200px] p-0">
|
|
72
|
+
<Command>
|
|
73
|
+
<Command.Input placeholder="Search country..." />
|
|
74
|
+
<Command.Empty>No country found.</Command.Empty>
|
|
75
|
+
<Command.List>
|
|
76
|
+
<Command.Group>
|
|
77
|
+
{options.map((option) => (
|
|
78
|
+
<Command.Item
|
|
79
|
+
key={option.value}
|
|
80
|
+
value={option.value}
|
|
81
|
+
keywords={[option.label, option.value]}
|
|
82
|
+
onSelect={(currentValue) => {
|
|
83
|
+
setCountry(currentValue);
|
|
84
|
+
setOpen(false);
|
|
85
|
+
}}
|
|
86
|
+
className={cn({
|
|
87
|
+
"bg-base-300": country.iso2 === option.value,
|
|
88
|
+
})}
|
|
89
|
+
>
|
|
90
|
+
<FlagImage iso2={option.value} size="20px" />
|
|
91
|
+
<span className="truncate ml-2">{option.label}</span>
|
|
92
|
+
</Command.Item>
|
|
93
|
+
))}
|
|
94
|
+
</Command.Group>
|
|
95
|
+
</Command.List>
|
|
96
|
+
</Command>
|
|
97
|
+
</Popover.Content>
|
|
98
|
+
</Popover>
|
|
99
|
+
<Input
|
|
100
|
+
type="text"
|
|
101
|
+
ref={inputRef}
|
|
102
|
+
value={inputValue}
|
|
103
|
+
pattern="^\+\d{1,4}\s\d{6,}$"
|
|
104
|
+
inputMode="numeric"
|
|
105
|
+
placeholder={placeholder ?? " "}
|
|
106
|
+
onChange={handleInputChange}
|
|
107
|
+
className={cn(
|
|
108
|
+
getPhoneInputClasses(),
|
|
109
|
+
getInputClasses(inputProps),
|
|
110
|
+
className
|
|
111
|
+
)}
|
|
112
|
+
{...props}
|
|
113
|
+
/>
|
|
114
|
+
</div>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
Phone.displayName = "Phone";
|
|
119
|
+
|
|
120
|
+
export { Phone };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { cva } from "../../../libs";
|
|
2
|
+
|
|
3
|
+
export const getPhoneButtonClasses = cva("join-item justify-between px-2");
|
|
4
|
+
|
|
5
|
+
export const getPhoneInputClasses = cva(
|
|
6
|
+
"input join-item input-bordered h-10 w-full rounded-md !rounded-r-md !pl-2 text-sm transition-all duration-100"
|
|
7
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Phone } from "./Phone";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type VariantProps } from "../../../libs";
|
|
2
|
+
import { type InputProps } from "../Input/types";
|
|
3
|
+
import { getInputClasses } from "../Input/constants";
|
|
4
|
+
import { getButtonClasses } from "../../Button/constants";
|
|
5
|
+
|
|
6
|
+
export type PhoneProps = Omit<
|
|
7
|
+
InputProps,
|
|
8
|
+
"type" | "size" | "label" | "inputMode"
|
|
9
|
+
> & {
|
|
10
|
+
inputProps?: VariantProps<typeof getInputClasses>;
|
|
11
|
+
buttonProps?: VariantProps<typeof getButtonClasses>;
|
|
12
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type RadioProps } from "./types";
|
|
3
|
+
import { getRadioClasses } from "./constants";
|
|
4
|
+
import { cn } from "../../../utilities";
|
|
5
|
+
|
|
6
|
+
const Radio = React.forwardRef<HTMLInputElement, RadioProps>(
|
|
7
|
+
({ className, size, variant, ...props }, ref) => (
|
|
8
|
+
<input
|
|
9
|
+
ref={ref}
|
|
10
|
+
type="radio"
|
|
11
|
+
className={cn(getRadioClasses({ size, variant }), className)}
|
|
12
|
+
{...props}
|
|
13
|
+
/>
|
|
14
|
+
)
|
|
15
|
+
);
|
|
16
|
+
Radio.displayName = "Radio";
|
|
17
|
+
|
|
18
|
+
export { Radio };
|