@meta-1/design 0.0.159
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/README.md +412 -0
- package/package.json +138 -0
- package/src/assets/icons/empty.svg +1 -0
- package/src/assets/icons/spin.svg +1 -0
- package/src/assets/locales/en-us.ts +74 -0
- package/src/assets/locales/zh-cn.ts +74 -0
- package/src/assets/locales/zh-tw.ts +74 -0
- package/src/assets/style/theme.css +173 -0
- package/src/components/icons/Empty.tsx +18 -0
- package/src/components/icons/Spin.tsx +16 -0
- package/src/components/icons/index.ts +2 -0
- package/src/components/ui/alert-dialog.tsx +111 -0
- package/src/components/ui/alert.tsx +49 -0
- package/src/components/ui/avatar.tsx +32 -0
- package/src/components/ui/badge.tsx +36 -0
- package/src/components/ui/breadcrumb.tsx +92 -0
- package/src/components/ui/button.tsx +52 -0
- package/src/components/ui/calendar.tsx +56 -0
- package/src/components/ui/card.tsx +56 -0
- package/src/components/ui/checkbox.tsx +28 -0
- package/src/components/ui/command.tsx +137 -0
- package/src/components/ui/dialog.tsx +127 -0
- package/src/components/ui/dropdown-menu.tsx +217 -0
- package/src/components/ui/form.tsx +138 -0
- package/src/components/ui/hover-card.tsx +36 -0
- package/src/components/ui/input-otp.tsx +66 -0
- package/src/components/ui/input.tsx +21 -0
- package/src/components/ui/label.tsx +21 -0
- package/src/components/ui/navigation-menu.tsx +142 -0
- package/src/components/ui/pagination.tsx +118 -0
- package/src/components/ui/popover.tsx +40 -0
- package/src/components/ui/progress.tsx +22 -0
- package/src/components/ui/radio-group.tsx +31 -0
- package/src/components/ui/resizable.tsx +46 -0
- package/src/components/ui/scroll-area.tsx +46 -0
- package/src/components/ui/select.tsx +158 -0
- package/src/components/ui/separator.tsx +26 -0
- package/src/components/ui/sheet.tsx +101 -0
- package/src/components/ui/skeleton.tsx +7 -0
- package/src/components/ui/sonner.tsx +23 -0
- package/src/components/ui/switch.tsx +26 -0
- package/src/components/ui/table.tsx +73 -0
- package/src/components/ui/tabs.tsx +40 -0
- package/src/components/ui/textarea.tsx +18 -0
- package/src/components/ui/tooltip.tsx +46 -0
- package/src/components/uix/action/index.tsx +37 -0
- package/src/components/uix/alert/index.tsx +43 -0
- package/src/components/uix/alert-dialog/index.tsx +109 -0
- package/src/components/uix/avatar/index.tsx +25 -0
- package/src/components/uix/breadcrumbs/index.tsx +38 -0
- package/src/components/uix/broadcast-channel-context/index.tsx +28 -0
- package/src/components/uix/button/index.tsx +29 -0
- package/src/components/uix/card/index.tsx +32 -0
- package/src/components/uix/checkbox/index.tsx +79 -0
- package/src/components/uix/checkbox-group/index.tsx +60 -0
- package/src/components/uix/combo-select/index.tsx +364 -0
- package/src/components/uix/config-provider/index.tsx +31 -0
- package/src/components/uix/data-table/index.tsx +491 -0
- package/src/components/uix/data-table/style.css +40 -0
- package/src/components/uix/date-picker/index.tsx +88 -0
- package/src/components/uix/date-range-picker/index.tsx +71 -0
- package/src/components/uix/dialog/index.tsx +70 -0
- package/src/components/uix/divider/index.tsx +23 -0
- package/src/components/uix/dropdown/index.tsx +117 -0
- package/src/components/uix/empty/index.tsx +29 -0
- package/src/components/uix/filters/index.tsx +105 -0
- package/src/components/uix/form/index.tsx +274 -0
- package/src/components/uix/image/index.tsx +13 -0
- package/src/components/uix/loading/index.tsx +24 -0
- package/src/components/uix/message/index.tsx +21 -0
- package/src/components/uix/pagination/index.tsx +180 -0
- package/src/components/uix/radio-group/index.tsx +35 -0
- package/src/components/uix/result/index.tsx +45 -0
- package/src/components/uix/select/index.tsx +93 -0
- package/src/components/uix/space/index.tsx +24 -0
- package/src/components/uix/spin/index.tsx +12 -0
- package/src/components/uix/steps/index.tsx +67 -0
- package/src/components/uix/switch/index.tsx +33 -0
- package/src/components/uix/tooltip/index.tsx +29 -0
- package/src/components/uix/tree/index.tsx +39 -0
- package/src/components/uix/tree/style.css +75 -0
- package/src/components/uix/tree-select/index.tsx +137 -0
- package/src/components/uix/tree-table/action.tsx +24 -0
- package/src/components/uix/tree-table/config.ts +2 -0
- package/src/components/uix/tree-table/index.tsx +86 -0
- package/src/components/uix/tree-table/utils.tsx +63 -0
- package/src/components/uix/uploader/index.tsx +237 -0
- package/src/components/uix/uploader/type.ts +20 -0
- package/src/components/uix/uploader/utils.ts +41 -0
- package/src/components/uix/value-formatter/index.tsx +59 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/resize.ts +29 -0
- package/src/hooks/use.outside.ts +30 -0
- package/src/index.ts +159 -0
- package/src/lib/formatters.ts +13 -0
- package/src/lib/index.ts +4 -0
- package/src/lib/is.ts +6 -0
- package/src/lib/react-dom.ts +98 -0
- package/src/lib/utils.ts +39 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
3
|
+
import { DayPicker } from "react-day-picker";
|
|
4
|
+
|
|
5
|
+
import { buttonVariants } from "@meta-1/design/components/ui/button";
|
|
6
|
+
import { cn } from "@meta-1/design/lib/utils";
|
|
7
|
+
|
|
8
|
+
function Calendar({ className, classNames, showOutsideDays = true, ...props }: React.ComponentProps<typeof DayPicker>) {
|
|
9
|
+
return (
|
|
10
|
+
<DayPicker
|
|
11
|
+
className={cn("p-3", className)}
|
|
12
|
+
classNames={{
|
|
13
|
+
months: "flex flex-col sm:flex-row gap-2",
|
|
14
|
+
month: "flex flex-col gap-4",
|
|
15
|
+
caption: "flex justify-center pt-1 relative items-center w-full",
|
|
16
|
+
caption_label: "text-sm font-medium",
|
|
17
|
+
nav: "flex items-center gap-1",
|
|
18
|
+
nav_button: cn(
|
|
19
|
+
buttonVariants({ variant: "outline" }),
|
|
20
|
+
"size-7 bg-transparent p-0 opacity-50 hover:opacity-100",
|
|
21
|
+
),
|
|
22
|
+
nav_button_previous: "absolute left-1",
|
|
23
|
+
nav_button_next: "absolute right-1",
|
|
24
|
+
table: "w-full border-collapse space-x-1",
|
|
25
|
+
head_row: "flex",
|
|
26
|
+
head_cell: "text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",
|
|
27
|
+
row: "flex w-full mt-2",
|
|
28
|
+
cell: cn(
|
|
29
|
+
"relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-range-end)]:rounded-r-md",
|
|
30
|
+
props.mode === "range"
|
|
31
|
+
? "[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md"
|
|
32
|
+
: "[&:has([aria-selected])]:rounded-md",
|
|
33
|
+
),
|
|
34
|
+
day: cn(buttonVariants({ variant: "ghost" }), "size-8 p-0 font-normal aria-selected:opacity-100"),
|
|
35
|
+
day_range_start: "day-range-start aria-selected:bg-primary aria-selected:text-primary-foreground",
|
|
36
|
+
day_range_end: "day-range-end aria-selected:bg-primary aria-selected:text-primary-foreground",
|
|
37
|
+
day_selected:
|
|
38
|
+
"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
|
|
39
|
+
day_today: "bg-accent text-accent-foreground",
|
|
40
|
+
day_outside: "day-outside text-muted-foreground aria-selected:text-muted-foreground",
|
|
41
|
+
day_disabled: "text-muted-foreground opacity-50",
|
|
42
|
+
day_range_middle: "aria-selected:bg-accent aria-selected:text-accent-foreground",
|
|
43
|
+
day_hidden: "invisible",
|
|
44
|
+
...classNames,
|
|
45
|
+
}}
|
|
46
|
+
components={{
|
|
47
|
+
IconLeft: ({ className, ...props }) => <ChevronLeft className={cn("size-4", className)} {...props} />,
|
|
48
|
+
IconRight: ({ className, ...props }) => <ChevronRight className={cn("size-4", className)} {...props} />,
|
|
49
|
+
}}
|
|
50
|
+
showOutsideDays={showOutsideDays}
|
|
51
|
+
{...props}
|
|
52
|
+
/>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { Calendar };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@meta-1/design/lib/utils";
|
|
4
|
+
|
|
5
|
+
function Card({ className, ...props }: React.ComponentProps<"div">) {
|
|
6
|
+
return (
|
|
7
|
+
<div
|
|
8
|
+
className={cn("flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm", className)}
|
|
9
|
+
data-slot="card"
|
|
10
|
+
{...props}
|
|
11
|
+
/>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
16
|
+
return (
|
|
17
|
+
<div
|
|
18
|
+
className={cn(
|
|
19
|
+
"@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
|
|
20
|
+
className,
|
|
21
|
+
)}
|
|
22
|
+
data-slot="card-header"
|
|
23
|
+
{...props}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
|
|
29
|
+
return <div className={cn("font-semibold leading-none", className)} data-slot="card-title" {...props} />;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
|
|
33
|
+
return <div className={cn("text-muted-foreground text-sm", className)} data-slot="card-description" {...props} />;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
|
|
37
|
+
return (
|
|
38
|
+
<div
|
|
39
|
+
className={cn("col-start-2 row-span-2 row-start-1 self-start justify-self-end", className)}
|
|
40
|
+
data-slot="card-action"
|
|
41
|
+
{...props}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
47
|
+
return <div className={cn("px-6", className)} data-slot="card-content" {...props} />;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
51
|
+
return (
|
|
52
|
+
<div className={cn("flex items-center px-6 [.border-t]:pt-6", className)} data-slot="card-footer" {...props} />
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
3
|
+
import { CheckIcon } from "lucide-react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "@meta-1/design/lib/utils";
|
|
6
|
+
|
|
7
|
+
function Checkbox({ className, ...props }: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
|
|
8
|
+
return (
|
|
9
|
+
<CheckboxPrimitive.Root
|
|
10
|
+
className={cn(
|
|
11
|
+
"peer size-4 shrink-0 rounded-[4px] border border-input shadow-xs outline-none transition-shadow focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:bg-input/30 dark:data-[state=checked]:bg-primary dark:aria-invalid:ring-destructive/40",
|
|
12
|
+
className,
|
|
13
|
+
)}
|
|
14
|
+
data-slot="checkbox"
|
|
15
|
+
{...props}
|
|
16
|
+
>
|
|
17
|
+
<CheckboxPrimitive.Indicator
|
|
18
|
+
className="flex items-center justify-center text-current transition-none"
|
|
19
|
+
data-slot="checkbox-indicator"
|
|
20
|
+
>
|
|
21
|
+
<CheckIcon className="size-3.5 text-primary-foreground" />
|
|
22
|
+
</CheckboxPrimitive.Indicator>
|
|
23
|
+
{props.children}
|
|
24
|
+
</CheckboxPrimitive.Root>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { Checkbox };
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import { Command as CommandPrimitive } from "cmdk";
|
|
3
|
+
import { SearchIcon } from "lucide-react";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Dialog,
|
|
7
|
+
DialogContent,
|
|
8
|
+
DialogDescription,
|
|
9
|
+
DialogHeader,
|
|
10
|
+
DialogTitle,
|
|
11
|
+
} from "@meta-1/design/components/ui/dialog";
|
|
12
|
+
import { cn } from "@meta-1/design/lib/utils";
|
|
13
|
+
|
|
14
|
+
function Command({ className, ...props }: React.ComponentProps<typeof CommandPrimitive>) {
|
|
15
|
+
return (
|
|
16
|
+
<CommandPrimitive
|
|
17
|
+
className={cn(
|
|
18
|
+
"flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
|
|
19
|
+
className,
|
|
20
|
+
)}
|
|
21
|
+
data-slot="command"
|
|
22
|
+
{...props}
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function CommandDialog({
|
|
28
|
+
title = "Command Palette",
|
|
29
|
+
description = "Search for a command to run...",
|
|
30
|
+
children,
|
|
31
|
+
...props
|
|
32
|
+
}: React.ComponentProps<typeof Dialog> & {
|
|
33
|
+
title?: string;
|
|
34
|
+
description?: string;
|
|
35
|
+
}) {
|
|
36
|
+
return (
|
|
37
|
+
<Dialog {...props}>
|
|
38
|
+
<DialogHeader className="sr-only">
|
|
39
|
+
<DialogTitle>{title}</DialogTitle>
|
|
40
|
+
<DialogDescription>{description}</DialogDescription>
|
|
41
|
+
</DialogHeader>
|
|
42
|
+
<DialogContent className="overflow-hidden p-0">
|
|
43
|
+
<Command className="**:data-[slot=command-input-wrapper]:h-12 [&_[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">
|
|
44
|
+
{children}
|
|
45
|
+
</Command>
|
|
46
|
+
</DialogContent>
|
|
47
|
+
</Dialog>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function CommandInput({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Input>) {
|
|
52
|
+
return (
|
|
53
|
+
<div className="flex h-9 items-center gap-2 border-b px-3" data-slot="command-input-wrapper">
|
|
54
|
+
<SearchIcon className="size-4 shrink-0 opacity-50" />
|
|
55
|
+
<CommandPrimitive.Input
|
|
56
|
+
className={cn(
|
|
57
|
+
"flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
|
|
58
|
+
className,
|
|
59
|
+
)}
|
|
60
|
+
data-slot="command-input"
|
|
61
|
+
{...props}
|
|
62
|
+
/>
|
|
63
|
+
</div>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function CommandList({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.List>) {
|
|
68
|
+
return (
|
|
69
|
+
<CommandPrimitive.List
|
|
70
|
+
className={cn("max-h-[300px] scroll-py-1 overflow-y-auto overflow-x-hidden", className)}
|
|
71
|
+
data-slot="command-list"
|
|
72
|
+
{...props}
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function CommandEmpty({ ...props }: React.ComponentProps<typeof CommandPrimitive.Empty>) {
|
|
78
|
+
return <CommandPrimitive.Empty className="py-6 text-center text-sm" data-slot="command-empty" {...props} />;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function CommandGroup({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Group>) {
|
|
82
|
+
return (
|
|
83
|
+
<CommandPrimitive.Group
|
|
84
|
+
className={cn(
|
|
85
|
+
"overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:text-xs",
|
|
86
|
+
className,
|
|
87
|
+
)}
|
|
88
|
+
data-slot="command-group"
|
|
89
|
+
{...props}
|
|
90
|
+
/>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function CommandSeparator({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Separator>) {
|
|
95
|
+
return (
|
|
96
|
+
<CommandPrimitive.Separator
|
|
97
|
+
className={cn("-mx-1 h-px bg-border", className)}
|
|
98
|
+
data-slot="command-separator"
|
|
99
|
+
{...props}
|
|
100
|
+
/>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function CommandItem({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Item>) {
|
|
105
|
+
return (
|
|
106
|
+
<CommandPrimitive.Item
|
|
107
|
+
className={cn(
|
|
108
|
+
"relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
109
|
+
className,
|
|
110
|
+
)}
|
|
111
|
+
data-slot="command-item"
|
|
112
|
+
{...props}
|
|
113
|
+
/>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function CommandShortcut({ className, ...props }: React.ComponentProps<"span">) {
|
|
118
|
+
return (
|
|
119
|
+
<span
|
|
120
|
+
className={cn("ml-auto text-muted-foreground text-xs tracking-widest", className)}
|
|
121
|
+
data-slot="command-shortcut"
|
|
122
|
+
{...props}
|
|
123
|
+
/>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export {
|
|
128
|
+
Command,
|
|
129
|
+
CommandDialog,
|
|
130
|
+
CommandInput,
|
|
131
|
+
CommandList,
|
|
132
|
+
CommandEmpty,
|
|
133
|
+
CommandGroup,
|
|
134
|
+
CommandItem,
|
|
135
|
+
CommandShortcut,
|
|
136
|
+
CommandSeparator,
|
|
137
|
+
};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type * as React from "react";
|
|
4
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
5
|
+
import { XIcon } from "lucide-react";
|
|
6
|
+
|
|
7
|
+
import { cn } from "@meta-1/design/lib/utils";
|
|
8
|
+
|
|
9
|
+
function Dialog({ ...props }: React.ComponentProps<typeof DialogPrimitive.Root>) {
|
|
10
|
+
return <DialogPrimitive.Root data-slot="dialog" {...props} />;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function DialogTrigger({ ...props }: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
|
|
14
|
+
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function DialogPortal({ ...props }: React.ComponentProps<typeof DialogPrimitive.Portal>) {
|
|
18
|
+
return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function DialogClose({ ...props }: React.ComponentProps<typeof DialogPrimitive.Close>) {
|
|
22
|
+
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function DialogOverlay({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
|
|
26
|
+
return (
|
|
27
|
+
<DialogPrimitive.Overlay
|
|
28
|
+
className={cn(
|
|
29
|
+
"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=open]:animate-in",
|
|
30
|
+
className,
|
|
31
|
+
)}
|
|
32
|
+
data-slot="dialog-overlay"
|
|
33
|
+
{...props}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function DialogContent({
|
|
39
|
+
className,
|
|
40
|
+
children,
|
|
41
|
+
showClose = true,
|
|
42
|
+
onCloseClick,
|
|
43
|
+
onOverlayClick,
|
|
44
|
+
...props
|
|
45
|
+
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
|
46
|
+
onOverlayClick?: () => void;
|
|
47
|
+
showClose?: boolean;
|
|
48
|
+
onCloseClick?: () => void;
|
|
49
|
+
}) {
|
|
50
|
+
return (
|
|
51
|
+
<DialogPortal data-slot="dialog-portal">
|
|
52
|
+
<DialogOverlay onClick={onOverlayClick} />
|
|
53
|
+
<DialogPrimitive.Content
|
|
54
|
+
className={cn(
|
|
55
|
+
"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[state=closed]:animate-out data-[state=open]:animate-in sm:max-w-lg",
|
|
56
|
+
className,
|
|
57
|
+
)}
|
|
58
|
+
data-slot="dialog-content"
|
|
59
|
+
{...props}
|
|
60
|
+
>
|
|
61
|
+
{children}
|
|
62
|
+
{showClose ? (
|
|
63
|
+
<DialogPrimitive.Close
|
|
64
|
+
className="absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden 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 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0"
|
|
65
|
+
onClick={onCloseClick}
|
|
66
|
+
>
|
|
67
|
+
<XIcon />
|
|
68
|
+
<span className="sr-only">Close</span>
|
|
69
|
+
</DialogPrimitive.Close>
|
|
70
|
+
) : null}
|
|
71
|
+
</DialogPrimitive.Content>
|
|
72
|
+
</DialogPortal>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
77
|
+
return (
|
|
78
|
+
<div
|
|
79
|
+
className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
|
|
80
|
+
data-slot="dialog-header"
|
|
81
|
+
{...props}
|
|
82
|
+
/>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function DialogFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
87
|
+
return (
|
|
88
|
+
<div
|
|
89
|
+
className={cn("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className)}
|
|
90
|
+
data-slot="dialog-footer"
|
|
91
|
+
{...props}
|
|
92
|
+
/>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function DialogTitle({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Title>) {
|
|
97
|
+
return (
|
|
98
|
+
<DialogPrimitive.Title
|
|
99
|
+
className={cn("font-semibold text-lg leading-none", className)}
|
|
100
|
+
data-slot="dialog-title"
|
|
101
|
+
{...props}
|
|
102
|
+
/>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function DialogDescription({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Description>) {
|
|
107
|
+
return (
|
|
108
|
+
<DialogPrimitive.Description
|
|
109
|
+
className={cn("text-muted-foreground text-sm", className)}
|
|
110
|
+
data-slot="dialog-description"
|
|
111
|
+
{...props}
|
|
112
|
+
/>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export {
|
|
117
|
+
Dialog,
|
|
118
|
+
DialogClose,
|
|
119
|
+
DialogContent,
|
|
120
|
+
DialogDescription,
|
|
121
|
+
DialogFooter,
|
|
122
|
+
DialogHeader,
|
|
123
|
+
DialogOverlay,
|
|
124
|
+
DialogPortal,
|
|
125
|
+
DialogTitle,
|
|
126
|
+
DialogTrigger,
|
|
127
|
+
};
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
3
|
+
import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "@meta-1/design/lib/utils";
|
|
6
|
+
|
|
7
|
+
function DropdownMenu({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
|
|
8
|
+
return <DropdownMenuPrimitive.Root data-slot="dropdown-menu" {...props} />;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function DropdownMenuPortal({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>) {
|
|
12
|
+
return <DropdownMenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function DropdownMenuTrigger({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>) {
|
|
16
|
+
return <DropdownMenuPrimitive.Trigger data-slot="dropdown-menu-trigger" {...props} />;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function DropdownMenuContent({
|
|
20
|
+
className,
|
|
21
|
+
sideOffset = 4,
|
|
22
|
+
...props
|
|
23
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {
|
|
24
|
+
return (
|
|
25
|
+
<DropdownMenuPrimitive.Portal>
|
|
26
|
+
<DropdownMenuPrimitive.Content
|
|
27
|
+
className={cn(
|
|
28
|
+
"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 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=closed]:animate-out data-[state=open]:animate-in",
|
|
29
|
+
className,
|
|
30
|
+
)}
|
|
31
|
+
data-slot="dropdown-menu-content"
|
|
32
|
+
sideOffset={sideOffset}
|
|
33
|
+
{...props}
|
|
34
|
+
/>
|
|
35
|
+
</DropdownMenuPrimitive.Portal>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function DropdownMenuGroup({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Group>) {
|
|
40
|
+
return <DropdownMenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function DropdownMenuItem({
|
|
44
|
+
className,
|
|
45
|
+
inset,
|
|
46
|
+
variant = "default",
|
|
47
|
+
...props
|
|
48
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {
|
|
49
|
+
inset?: boolean;
|
|
50
|
+
variant?: "default" | "destructive";
|
|
51
|
+
}) {
|
|
52
|
+
return (
|
|
53
|
+
<DropdownMenuPrimitive.Item
|
|
54
|
+
className={cn(
|
|
55
|
+
"data-[variant=destructive]:*:[svg]:!text-destructive relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[disabled]:opacity-50 data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
56
|
+
className,
|
|
57
|
+
)}
|
|
58
|
+
data-inset={inset}
|
|
59
|
+
data-slot="dropdown-menu-item"
|
|
60
|
+
data-variant={variant}
|
|
61
|
+
{...props}
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function DropdownMenuCheckboxItem({
|
|
67
|
+
className,
|
|
68
|
+
children,
|
|
69
|
+
checked,
|
|
70
|
+
...props
|
|
71
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem>) {
|
|
72
|
+
return (
|
|
73
|
+
<DropdownMenuPrimitive.CheckboxItem
|
|
74
|
+
checked={checked}
|
|
75
|
+
className={cn(
|
|
76
|
+
"relative flex cursor-default select-none items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
77
|
+
className,
|
|
78
|
+
)}
|
|
79
|
+
data-slot="dropdown-menu-checkbox-item"
|
|
80
|
+
{...props}
|
|
81
|
+
>
|
|
82
|
+
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
|
83
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
|
84
|
+
<CheckIcon className="size-4" />
|
|
85
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
|
86
|
+
</span>
|
|
87
|
+
{children}
|
|
88
|
+
</DropdownMenuPrimitive.CheckboxItem>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function DropdownMenuRadioGroup({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.RadioGroup>) {
|
|
93
|
+
return <DropdownMenuPrimitive.RadioGroup data-slot="dropdown-menu-radio-group" {...props} />;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function DropdownMenuRadioItem({
|
|
97
|
+
className,
|
|
98
|
+
children,
|
|
99
|
+
...props
|
|
100
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem>) {
|
|
101
|
+
return (
|
|
102
|
+
<DropdownMenuPrimitive.RadioItem
|
|
103
|
+
className={cn(
|
|
104
|
+
"relative flex cursor-default select-none items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
105
|
+
className,
|
|
106
|
+
)}
|
|
107
|
+
data-slot="dropdown-menu-radio-item"
|
|
108
|
+
{...props}
|
|
109
|
+
>
|
|
110
|
+
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
|
111
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
|
112
|
+
<CircleIcon className="size-2 fill-current" />
|
|
113
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
|
114
|
+
</span>
|
|
115
|
+
{children}
|
|
116
|
+
</DropdownMenuPrimitive.RadioItem>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function DropdownMenuLabel({
|
|
121
|
+
className,
|
|
122
|
+
inset,
|
|
123
|
+
...props
|
|
124
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Label> & {
|
|
125
|
+
inset?: boolean;
|
|
126
|
+
}) {
|
|
127
|
+
return (
|
|
128
|
+
<DropdownMenuPrimitive.Label
|
|
129
|
+
className={cn("px-2 py-1.5 font-medium text-sm data-[inset]:pl-8", className)}
|
|
130
|
+
data-inset={inset}
|
|
131
|
+
data-slot="dropdown-menu-label"
|
|
132
|
+
{...props}
|
|
133
|
+
/>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function DropdownMenuSeparator({ className, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>) {
|
|
138
|
+
return (
|
|
139
|
+
<DropdownMenuPrimitive.Separator
|
|
140
|
+
className={cn("-mx-1 my-1 h-px bg-border", className)}
|
|
141
|
+
data-slot="dropdown-menu-separator"
|
|
142
|
+
{...props}
|
|
143
|
+
/>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function DropdownMenuShortcut({ className, ...props }: React.ComponentProps<"span">) {
|
|
148
|
+
return (
|
|
149
|
+
<span
|
|
150
|
+
className={cn("ml-auto text-muted-foreground text-xs tracking-widest", className)}
|
|
151
|
+
data-slot="dropdown-menu-shortcut"
|
|
152
|
+
{...props}
|
|
153
|
+
/>
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function DropdownMenuSub({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>) {
|
|
158
|
+
return <DropdownMenuPrimitive.Sub data-slot="dropdown-menu-sub" {...props} />;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function DropdownMenuSubTrigger({
|
|
162
|
+
className,
|
|
163
|
+
inset,
|
|
164
|
+
children,
|
|
165
|
+
...props
|
|
166
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {
|
|
167
|
+
inset?: boolean;
|
|
168
|
+
}) {
|
|
169
|
+
return (
|
|
170
|
+
<DropdownMenuPrimitive.SubTrigger
|
|
171
|
+
className={cn(
|
|
172
|
+
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-hidden focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[inset]:pl-8 data-[state=open]:text-accent-foreground",
|
|
173
|
+
className,
|
|
174
|
+
)}
|
|
175
|
+
data-inset={inset}
|
|
176
|
+
data-slot="dropdown-menu-sub-trigger"
|
|
177
|
+
{...props}
|
|
178
|
+
>
|
|
179
|
+
{children}
|
|
180
|
+
<ChevronRightIcon className="ml-auto size-4" />
|
|
181
|
+
</DropdownMenuPrimitive.SubTrigger>
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function DropdownMenuSubContent({
|
|
186
|
+
className,
|
|
187
|
+
...props
|
|
188
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>) {
|
|
189
|
+
return (
|
|
190
|
+
<DropdownMenuPrimitive.SubContent
|
|
191
|
+
className={cn(
|
|
192
|
+
"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 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=closed]:animate-out data-[state=open]:animate-in",
|
|
193
|
+
className,
|
|
194
|
+
)}
|
|
195
|
+
data-slot="dropdown-menu-sub-content"
|
|
196
|
+
{...props}
|
|
197
|
+
/>
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export {
|
|
202
|
+
DropdownMenu,
|
|
203
|
+
DropdownMenuPortal,
|
|
204
|
+
DropdownMenuTrigger,
|
|
205
|
+
DropdownMenuContent,
|
|
206
|
+
DropdownMenuGroup,
|
|
207
|
+
DropdownMenuLabel,
|
|
208
|
+
DropdownMenuItem,
|
|
209
|
+
DropdownMenuCheckboxItem,
|
|
210
|
+
DropdownMenuRadioGroup,
|
|
211
|
+
DropdownMenuRadioItem,
|
|
212
|
+
DropdownMenuSeparator,
|
|
213
|
+
DropdownMenuShortcut,
|
|
214
|
+
DropdownMenuSub,
|
|
215
|
+
DropdownMenuSubTrigger,
|
|
216
|
+
DropdownMenuSubContent,
|
|
217
|
+
};
|