@meta-1/design 0.0.199 → 0.0.200
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/package.json +3 -1
- package/src/assets/locales/en-us.ts +4 -0
- package/src/assets/locales/zh-cn.ts +4 -0
- package/src/assets/locales/zh-tw.ts +4 -0
- package/src/assets/style/theme.css +72 -21
- package/src/components/ui/button.tsx +28 -18
- package/src/components/uix/action/index.tsx +7 -5
- package/src/components/uix/action/style.css +21 -0
- package/src/components/uix/alert/index.tsx +5 -5
- package/src/components/uix/alert-dialog/index.tsx +56 -16
- package/src/components/uix/badge/index.tsx +8 -2
- package/src/components/uix/button/index.tsx +7 -5
- package/src/components/uix/card/index.tsx +7 -4
- package/src/components/uix/checkbox-group/index.tsx +3 -4
- package/src/components/uix/combo-select/index.tsx +99 -129
- package/src/components/uix/command/index.tsx +126 -0
- package/src/components/uix/data-grid/index.tsx +625 -0
- package/src/components/uix/data-grid/overlays.tsx +26 -0
- package/src/components/uix/data-grid/style.css +6 -0
- package/src/components/uix/data-table/index.tsx +10 -7
- package/src/components/uix/date-picker/index.tsx +55 -46
- package/src/components/uix/date-range-picker/index.tsx +116 -36
- package/src/components/uix/dialog/index.tsx +5 -5
- package/src/components/uix/dropdown/index.tsx +1 -1
- package/src/components/uix/input/index.tsx +23 -0
- package/src/components/uix/message/index.tsx +4 -4
- package/src/components/uix/pagination/index.tsx +17 -31
- package/src/components/uix/popover/index.tsx +30 -0
- package/src/components/uix/radio-group/index.tsx +2 -2
- package/src/components/uix/select/index.tsx +6 -2
- package/src/components/uix/sheet/index.tsx +76 -0
- package/src/components/uix/tabs/index.tsx +38 -0
- package/src/components/uix/tags-input/index.tsx +22 -3
- package/src/components/uix/textarea/index.tsx +23 -0
- package/src/components/uix/tooltip/index.tsx +5 -4
- package/src/components/uix/tree/style.css +1 -0
- package/src/components/uix/tree-select/index.tsx +59 -64
- package/src/components/uix/uploader/index.tsx +1 -1
- package/src/components/uix/value-formatter/index.tsx +40 -46
- package/src/index.ts +19 -35
- package/src/lib/utils.ts +50 -1
- package/src/components/uix/breadcrumbs/index.tsx +0 -38
- package/src/components/uix/space/index.tsx +0 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meta-1/design",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.200",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"easykit",
|
|
6
6
|
"design",
|
|
@@ -47,6 +47,8 @@
|
|
|
47
47
|
"@radix-ui/react-toast": "1.2.2",
|
|
48
48
|
"@radix-ui/react-tooltip": "1.1.4",
|
|
49
49
|
"@tanstack/react-table": "8.20.5",
|
|
50
|
+
"ag-grid-community": "34.3.1",
|
|
51
|
+
"ag-grid-react": "34.3.1",
|
|
50
52
|
"class-variance-authority": "0.7.0",
|
|
51
53
|
"clsx": "2.1.1",
|
|
52
54
|
"cmdk": "1.0.0",
|
|
@@ -48,6 +48,77 @@
|
|
|
48
48
|
--color-sidebar-border: var(--sidebar-border);
|
|
49
49
|
--color-sidebar-ring: var(--sidebar-ring);
|
|
50
50
|
--color-action-hover: var(--action-hover);
|
|
51
|
+
|
|
52
|
+
--radius-default: 4px;
|
|
53
|
+
--gap-default: 0.5rem;
|
|
54
|
+
|
|
55
|
+
/* Button */
|
|
56
|
+
--radius-button: var(--radius-default);
|
|
57
|
+
--padding-button: 0.75rem;
|
|
58
|
+
--spacing-button: 2rem;
|
|
59
|
+
|
|
60
|
+
/* Alert */
|
|
61
|
+
--radius-alert: var(--radius-default);
|
|
62
|
+
--padding-alert: 0.75rem;
|
|
63
|
+
--gap-alert: var(--gap-default);
|
|
64
|
+
|
|
65
|
+
/* Dialog */
|
|
66
|
+
--radius-dialog: var(--radius-default);
|
|
67
|
+
--padding-dialog: 1rem;
|
|
68
|
+
--gap-dialog: 1rem;
|
|
69
|
+
|
|
70
|
+
/* Badge */
|
|
71
|
+
--radius-badge: var(--radius-default);
|
|
72
|
+
--padding-badge: var(--padding-badge-y) var(--padding-badge-x);
|
|
73
|
+
--padding-badge-x: 0.3rem;
|
|
74
|
+
--padding-badge-y: 0.1rem;
|
|
75
|
+
|
|
76
|
+
/* Card */
|
|
77
|
+
--radius-card: var(--radius-default);
|
|
78
|
+
--padding-card: 1rem;
|
|
79
|
+
--gap-card: var(--gap-default);
|
|
80
|
+
|
|
81
|
+
/* Select */
|
|
82
|
+
--radius-select: var(--radius-default);
|
|
83
|
+
--padding-select: 0.5rem;
|
|
84
|
+
--spacing-select: 2rem;
|
|
85
|
+
|
|
86
|
+
/* Popover */
|
|
87
|
+
--radius-popover: var(--radius-default);
|
|
88
|
+
--padding-popover: 0.25rem;
|
|
89
|
+
|
|
90
|
+
/* Command */
|
|
91
|
+
--radius-command: var(--radius-default);
|
|
92
|
+
--padding-command: 0.375rem;
|
|
93
|
+
|
|
94
|
+
/* Calendar */
|
|
95
|
+
--radius-calendar: var(--radius-default);
|
|
96
|
+
--padding-calendar: 0.5rem;
|
|
97
|
+
--gap-calendar: var(--gap-default);
|
|
98
|
+
|
|
99
|
+
/* Button */
|
|
100
|
+
--radius-input: var(--radius-default);
|
|
101
|
+
--padding-input: 0.5rem;
|
|
102
|
+
--spacing-input: 2rem;
|
|
103
|
+
|
|
104
|
+
/* Tabs */
|
|
105
|
+
--radius-tabs-title: var(--radius-default);
|
|
106
|
+
--spacing-tabs-title: 2rem;
|
|
107
|
+
|
|
108
|
+
/* Message */
|
|
109
|
+
--radius-message: var(--radius-default);
|
|
110
|
+
--padding-message: var(--padding-message-y) var(--padding-message-x);
|
|
111
|
+
--padding-message-x: 0.75rem;
|
|
112
|
+
--padding-message-y: 0.5rem;
|
|
113
|
+
|
|
114
|
+
/* Sheet */
|
|
115
|
+
--radius-sheet: var(--radius-default);
|
|
116
|
+
--padding-sheet: 1rem;
|
|
117
|
+
--gap-sheet: 1rem;
|
|
118
|
+
|
|
119
|
+
/* Tooltip */
|
|
120
|
+
--radius-tooltip: var(--radius-default);
|
|
121
|
+
--padding-tooltip: 0.5rem;
|
|
51
122
|
}
|
|
52
123
|
|
|
53
124
|
@layer base {
|
|
@@ -156,24 +227,4 @@
|
|
|
156
227
|
display: inline-block;
|
|
157
228
|
}
|
|
158
229
|
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
@utility action-effect {
|
|
162
|
-
@apply hover:bg-[var(--action-hover)] hover:text-primary;
|
|
163
|
-
@apply focus:bg-[var(--action-hover)] focus:border-[var(--border)] focus:shadow-[0_0_0_1px_var(--card),0_0_0_3px_var(--primary)];
|
|
164
|
-
@apply dark:focus:border-[var(--sidebar-border)] dark:focus:shadow-[0_0_0_1px_var(--secondary),0_0_0_3px_var(--primary)];
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
@utility action-effect-active {
|
|
168
|
-
@apply active:bg-[var(--action-hover)] active:border-[var(--border)] active:shadow-[0_0_0_1px_var(--card),0_0_0_3px_var(--primary)];
|
|
169
|
-
@apply dark:active:border-[var(--sidebar-border)] dark:active:shadow-[0_0_0_1px_var(--secondary),0_0_0_3px_var(--primary)];
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
@utility action-active {
|
|
173
|
-
@apply text-primary bg-[var(--action-hover)];
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
@utility action-effect-disabled {
|
|
177
|
-
@apply opacity-50 cursor-not-allowed focus:bg-transparent active:bg-transparent focus:shadow-none active:shadow-none focus:border-transparent active:border-transparent;
|
|
178
|
-
@apply hover:bg-transparent;
|
|
179
|
-
}
|
|
230
|
+
}
|
|
@@ -1,26 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Slot } from "@radix-ui/react-slot"
|
|
3
|
-
import { cva, type VariantProps } from "class-variance-authority"
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot"
|
|
3
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
4
4
|
|
|
5
|
-
import { cn } from "@meta-1/design/lib
|
|
5
|
+
import { cn } from "@meta-1/design/lib"
|
|
6
6
|
|
|
7
7
|
const buttonVariants = cva(
|
|
8
|
-
"inline-flex
|
|
8
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
9
9
|
{
|
|
10
10
|
variants: {
|
|
11
11
|
variant: {
|
|
12
12
|
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
13
13
|
destructive:
|
|
14
|
-
"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:
|
|
14
|
+
"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
|
15
15
|
outline:
|
|
16
|
-
"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:
|
|
17
|
-
secondary:
|
|
18
|
-
|
|
16
|
+
"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
|
|
17
|
+
secondary:
|
|
18
|
+
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
19
|
+
ghost:
|
|
20
|
+
"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
|
19
21
|
link: "text-primary underline-offset-4 hover:underline",
|
|
20
22
|
},
|
|
21
23
|
size: {
|
|
22
24
|
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
23
|
-
sm: "h-8 gap-1.5
|
|
25
|
+
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
|
|
24
26
|
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
25
27
|
icon: "size-9",
|
|
26
28
|
"icon-sm": "size-8",
|
|
@@ -31,22 +33,30 @@ const buttonVariants = cva(
|
|
|
31
33
|
variant: "default",
|
|
32
34
|
size: "default",
|
|
33
35
|
},
|
|
34
|
-
}
|
|
35
|
-
)
|
|
36
|
+
}
|
|
37
|
+
)
|
|
36
38
|
|
|
37
39
|
function Button({
|
|
38
40
|
className,
|
|
39
|
-
variant,
|
|
40
|
-
size,
|
|
41
|
+
variant = "default",
|
|
42
|
+
size = "default",
|
|
41
43
|
asChild = false,
|
|
42
44
|
...props
|
|
43
45
|
}: React.ComponentProps<"button"> &
|
|
44
46
|
VariantProps<typeof buttonVariants> & {
|
|
45
|
-
asChild?: boolean
|
|
47
|
+
asChild?: boolean
|
|
46
48
|
}) {
|
|
47
|
-
const Comp = asChild ? Slot : "button"
|
|
49
|
+
const Comp = asChild ? Slot : "button"
|
|
48
50
|
|
|
49
|
-
return
|
|
51
|
+
return (
|
|
52
|
+
<Comp
|
|
53
|
+
data-slot="button"
|
|
54
|
+
data-variant={variant}
|
|
55
|
+
data-size={size}
|
|
56
|
+
className={cn(buttonVariants({ variant, size, className }))}
|
|
57
|
+
{...props}
|
|
58
|
+
/>
|
|
59
|
+
)
|
|
50
60
|
}
|
|
51
61
|
|
|
52
|
-
export { Button, buttonVariants }
|
|
62
|
+
export { Button, buttonVariants }
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { FC, HTMLAttributes, PropsWithChildren } from "react";
|
|
2
|
-
import
|
|
2
|
+
import "./style.css";
|
|
3
|
+
|
|
4
|
+
import { cn } from "@meta-1/design";
|
|
3
5
|
|
|
4
6
|
export type ActionProps = PropsWithChildren<HTMLAttributes<HTMLButtonElement>> & {
|
|
5
7
|
theme?: "dark" | "light";
|
|
@@ -14,11 +16,11 @@ export const Action: FC<ActionProps> = (props) => {
|
|
|
14
16
|
const elProps = {
|
|
15
17
|
...rest,
|
|
16
18
|
disabled,
|
|
17
|
-
className:
|
|
18
|
-
"
|
|
19
|
+
className: cn(
|
|
20
|
+
"flex h-button items-center justify-center rounded-button border border-transparent border-solid px-button font-medium text-sm focus-visible:outline-none",
|
|
19
21
|
theme === "light" && "hover:bg-white/20",
|
|
20
|
-
theme === "light" && "focus:
|
|
21
|
-
theme === "light" && "active:
|
|
22
|
+
theme === "light" && "focus:border-white/30 focus:bg-white/30",
|
|
23
|
+
theme === "light" && "active:border-white/30 active:bg-white/30",
|
|
22
24
|
theme === "dark" && "action-effect action-effect-active",
|
|
23
25
|
active && theme === "light" && "bg-white/20",
|
|
24
26
|
active && theme === "dark" && "action-active",
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
@import "../../../assets/style/theme.css";
|
|
2
|
+
|
|
3
|
+
@utility action-effect {
|
|
4
|
+
@apply hover:bg-[var(--action-hover)] hover:text-primary;
|
|
5
|
+
@apply focus:bg-[var(--action-hover)] focus:border-[var(--border)] focus:shadow-[0_0_0_1px_var(--card),0_0_0_3px_var(--primary)];
|
|
6
|
+
@apply dark:focus:border-[var(--sidebar-border)] dark:focus:shadow-[0_0_0_1px_var(--secondary),0_0_0_3px_var(--primary)];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
@utility action-effect-active {
|
|
10
|
+
@apply active:bg-[var(--action-hover)] active:border-[var(--border)] active:shadow-[0_0_0_1px_var(--card),0_0_0_3px_var(--primary)];
|
|
11
|
+
@apply dark:active:border-[var(--sidebar-border)] dark:active:shadow-[0_0_0_1px_var(--secondary),0_0_0_3px_var(--primary)];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@utility action-active {
|
|
15
|
+
@apply text-primary bg-[var(--action-hover)];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@utility action-effect-disabled {
|
|
19
|
+
@apply opacity-50 cursor-not-allowed focus:bg-transparent active:bg-transparent focus:shadow-none active:shadow-none focus:border-transparent active:border-transparent;
|
|
20
|
+
@apply hover:bg-transparent;
|
|
21
|
+
}
|
|
@@ -20,7 +20,7 @@ export const Alert = (props: AlertProps) => {
|
|
|
20
20
|
title,
|
|
21
21
|
description,
|
|
22
22
|
icon,
|
|
23
|
-
children
|
|
23
|
+
children,
|
|
24
24
|
titleClassName,
|
|
25
25
|
descriptionClassName,
|
|
26
26
|
variant = "default",
|
|
@@ -28,7 +28,6 @@ export const Alert = (props: AlertProps) => {
|
|
|
28
28
|
} = props;
|
|
29
29
|
|
|
30
30
|
let className = props.className;
|
|
31
|
-
const children = childrenProp || description;
|
|
32
31
|
|
|
33
32
|
// 根据 variant 设置样式
|
|
34
33
|
const variantStyles: Record<AlertVariant, string> = {
|
|
@@ -46,11 +45,12 @@ export const Alert = (props: AlertProps) => {
|
|
|
46
45
|
const uiVariant = variant === "destructive" ? "destructive" : "default";
|
|
47
46
|
|
|
48
47
|
return (
|
|
49
|
-
<UIAlert {...rest} className={cn("flex gap-
|
|
48
|
+
<UIAlert {...rest} className={cn("flex gap-alert rounded-alert p-alert", className)} variant={uiVariant}>
|
|
50
49
|
{icon}
|
|
51
|
-
<div className="flex flex-1 flex-col gap-
|
|
50
|
+
<div className="flex flex-1 flex-col gap-alert">
|
|
52
51
|
{title && <UIAlertTitle className={titleClassName}>{title}</UIAlertTitle>}
|
|
53
|
-
{
|
|
52
|
+
{description && <UIAlertDescription className={descriptionClassName}>{description}</UIAlertDescription>}
|
|
53
|
+
{children}
|
|
54
54
|
</div>
|
|
55
55
|
</UIAlert>
|
|
56
56
|
);
|
|
@@ -25,33 +25,55 @@ export interface ConfirmProps {
|
|
|
25
25
|
confirmLoading?: boolean;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
export interface AlertDialogProps {
|
|
29
|
+
title: ReactNode;
|
|
30
|
+
description: ReactNode;
|
|
31
|
+
okText?: string;
|
|
32
|
+
// biome-ignore lint/suspicious/noConfusingVoidType: <onOk>
|
|
33
|
+
onOk?: () => boolean | void | Promise<boolean | void>;
|
|
34
|
+
open?: boolean;
|
|
35
|
+
confirmLoading?: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface InternalAlertDialogProps extends ConfirmProps {
|
|
39
|
+
showCancel?: boolean;
|
|
40
|
+
onClose?: () => void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const AlertDialog: FC<InternalAlertDialogProps> = (props) => {
|
|
44
|
+
const { description, title, onOk, onCancel, showCancel = true, onClose } = props;
|
|
30
45
|
|
|
31
46
|
const config = useContext(UIXContext);
|
|
32
|
-
const okText = props.okText || get(config.locale, "Alert.okText");
|
|
47
|
+
const okText = props.okText || get(config.locale, "Alert.okText") || "确定";
|
|
33
48
|
const cancelText = props.cancelText || get(config.locale, "Alert.cancelText");
|
|
34
49
|
|
|
35
50
|
const [open, setOpen] = useState(props.open);
|
|
36
51
|
const [loading, setLoading] = useState(false);
|
|
37
52
|
|
|
53
|
+
const handleClose = () => {
|
|
54
|
+
setOpen(false);
|
|
55
|
+
onClose?.();
|
|
56
|
+
};
|
|
57
|
+
|
|
38
58
|
return (
|
|
39
59
|
<UIAlertDialog {...props} open={open}>
|
|
40
|
-
<AlertDialogContent>
|
|
41
|
-
<AlertDialogHeader>
|
|
60
|
+
<AlertDialogContent className="gap-dialog rounded-dialog p-dialog">
|
|
61
|
+
<AlertDialogHeader className="gap-dialog">
|
|
42
62
|
<AlertDialogTitle>{title}</AlertDialogTitle>
|
|
43
63
|
<AlertDialogDescription>{description}</AlertDialogDescription>
|
|
44
64
|
</AlertDialogHeader>
|
|
45
65
|
<AlertDialogFooter>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
66
|
+
{showCancel && (
|
|
67
|
+
<Button
|
|
68
|
+
onClick={() => {
|
|
69
|
+
setOpen(false);
|
|
70
|
+
onCancel?.();
|
|
71
|
+
}}
|
|
72
|
+
variant="outline"
|
|
73
|
+
>
|
|
74
|
+
{cancelText}
|
|
75
|
+
</Button>
|
|
76
|
+
)}
|
|
55
77
|
<Button
|
|
56
78
|
loading={loading}
|
|
57
79
|
onClick={async () => {
|
|
@@ -70,7 +92,7 @@ const AlertDialog: FC<ConfirmProps> = (props) => {
|
|
|
70
92
|
}
|
|
71
93
|
setLoading(false);
|
|
72
94
|
if (value) {
|
|
73
|
-
|
|
95
|
+
handleClose();
|
|
74
96
|
}
|
|
75
97
|
}}
|
|
76
98
|
>
|
|
@@ -102,7 +124,25 @@ export const useAlert = () => {
|
|
|
102
124
|
close();
|
|
103
125
|
props.onCancel?.();
|
|
104
126
|
};
|
|
105
|
-
root = ReactDOMRender(
|
|
127
|
+
root = ReactDOMRender(
|
|
128
|
+
<AlertDialog {...props} onCancel={onCancel} onClose={close} open={true} showCancel={true} />,
|
|
129
|
+
div,
|
|
130
|
+
);
|
|
131
|
+
},
|
|
132
|
+
alert: (props: AlertDialogProps) => {
|
|
133
|
+
// biome-ignore lint/suspicious/noExplicitAny: <root>
|
|
134
|
+
let root: any;
|
|
135
|
+
const div = document.createElement("div");
|
|
136
|
+
document.body.appendChild(div);
|
|
137
|
+
const close = () => {
|
|
138
|
+
setTimeout(() => {
|
|
139
|
+
root = root?._unmount();
|
|
140
|
+
if (div.parentNode) {
|
|
141
|
+
div.parentNode.removeChild(div);
|
|
142
|
+
}
|
|
143
|
+
}, 200);
|
|
144
|
+
};
|
|
145
|
+
root = ReactDOMRender(<AlertDialog {...props} onClose={close} open={true} showCancel={false} />, div);
|
|
106
146
|
},
|
|
107
147
|
};
|
|
108
148
|
}, []);
|
|
@@ -28,14 +28,20 @@ export const Badge = ({ variant = "default", className, ...props }: BadgeProps)
|
|
|
28
28
|
|
|
29
29
|
// 扩展场景使用 default variant,并添加自定义样式
|
|
30
30
|
if (variant && ["success", "error", "warning", "info"].includes(variant)) {
|
|
31
|
-
return
|
|
31
|
+
return (
|
|
32
|
+
<UIBadge
|
|
33
|
+
{...props}
|
|
34
|
+
className={cn("rounded-badge p-badge", variantStyles[variant], className)}
|
|
35
|
+
variant="default"
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
32
38
|
}
|
|
33
39
|
|
|
34
40
|
// 原生 variant 直接传递
|
|
35
41
|
return (
|
|
36
42
|
<UIBadge
|
|
37
43
|
{...props}
|
|
38
|
-
className={className}
|
|
44
|
+
className={cn("rounded-badge p-badge", className)}
|
|
39
45
|
variant={variant as "default" | "secondary" | "destructive" | "outline"}
|
|
40
46
|
/>
|
|
41
47
|
);
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { forwardRef } from "react";
|
|
1
|
+
import { ComponentProps, forwardRef } from "react";
|
|
2
|
+
import { VariantProps } from "class-variance-authority";
|
|
2
3
|
|
|
3
4
|
import { Button as UIButton } from "@meta-1/design/components/ui/button";
|
|
4
5
|
import { Spin } from "@meta-1/design/components/uix/spin";
|
|
5
6
|
import { cn } from "@meta-1/design/lib";
|
|
6
7
|
|
|
7
|
-
export
|
|
8
|
-
loading?: boolean;
|
|
8
|
+
export type ButtonProps = Omit<ComponentProps<typeof UIButton>, "size"> & {
|
|
9
9
|
long?: boolean;
|
|
10
|
-
|
|
10
|
+
loading?: boolean;
|
|
11
|
+
};
|
|
11
12
|
|
|
12
13
|
export const Button = forwardRef<HTMLButtonElement, ButtonProps>((props, forwardedRef) => {
|
|
13
14
|
const { loading = false, long = false, disabled = false, className, ...rest } = props;
|
|
@@ -16,9 +17,10 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>((props, forward
|
|
|
16
17
|
return (
|
|
17
18
|
<UIButton
|
|
18
19
|
{...rest}
|
|
19
|
-
className={cn("gap-0.5", className, long ? "w-full" : null)}
|
|
20
|
+
className={cn("h-button rounded-button px-button", "gap-0.5", className, long ? "w-full" : null)}
|
|
20
21
|
disabled={loading || disabled}
|
|
21
22
|
ref={elementRef}
|
|
23
|
+
size={"none" as VariantProps<typeof UIButton>["size"]}
|
|
22
24
|
>
|
|
23
25
|
{loading ? <Spin /> : null}
|
|
24
26
|
{props.children}
|
|
@@ -19,9 +19,12 @@ export const Card: FC<CardProps> = (props) => {
|
|
|
19
19
|
const { title = "", description = "", className, contentClassName, footer, shadow = false, actions } = props;
|
|
20
20
|
|
|
21
21
|
return (
|
|
22
|
-
<UICard
|
|
22
|
+
<UICard
|
|
23
|
+
className={classNames("gap-card rounded-card py-card", shadow ? null : "shadow-none", className)}
|
|
24
|
+
onClick={props.onClick}
|
|
25
|
+
>
|
|
23
26
|
{title || description ? (
|
|
24
|
-
<CardHeader className="pb-0">
|
|
27
|
+
<CardHeader className="px-card pb-0">
|
|
25
28
|
{title ? (
|
|
26
29
|
<div className="flex items-center justify-between">
|
|
27
30
|
<CardTitle>{title}</CardTitle>
|
|
@@ -31,8 +34,8 @@ export const Card: FC<CardProps> = (props) => {
|
|
|
31
34
|
{description ? <CardDescription>{description}</CardDescription> : null}
|
|
32
35
|
</CardHeader>
|
|
33
36
|
) : null}
|
|
34
|
-
<CardContent className={cn("px-
|
|
35
|
-
{footer ? <CardFooter>{footer}</CardFooter> : null}
|
|
37
|
+
<CardContent className={cn("px-card", contentClassName)}>{props.children}</CardContent>
|
|
38
|
+
{footer ? <CardFooter className="px-card">{footer}</CardFooter> : null}
|
|
36
39
|
</UICard>
|
|
37
40
|
);
|
|
38
41
|
};
|
|
@@ -36,8 +36,7 @@ export const CheckboxGroup: FC<CheckboxGroupProps> = forwardRef((props, _ref) =>
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
return (
|
|
39
|
-
<div className={classNames("
|
|
40
|
-
<span />
|
|
39
|
+
<div className={classNames("flex flex-wrap items-center justify-start gap-2", className)}>
|
|
41
40
|
{options.map((option) => {
|
|
42
41
|
const id = `checkbox-group-${option.value}`;
|
|
43
42
|
const isDisabled = disabled || option.disabled;
|
|
@@ -49,12 +48,12 @@ export const CheckboxGroup: FC<CheckboxGroupProps> = forwardRef((props, _ref) =>
|
|
|
49
48
|
>
|
|
50
49
|
<Checkbox
|
|
51
50
|
checked={checkedValues.includes(option.value)}
|
|
52
|
-
className={checkboxClassName}
|
|
51
|
+
className={classNames("shrink-0", checkboxClassName)}
|
|
53
52
|
disabled={isDisabled}
|
|
54
53
|
id={id}
|
|
55
54
|
onCheckedChange={(checked: boolean) => onCheckedChange(option.value, checked)}
|
|
56
55
|
/>
|
|
57
|
-
<span>{option.label}</span>
|
|
56
|
+
<span className="leading-none">{option.label}</span>
|
|
58
57
|
</label>
|
|
59
58
|
);
|
|
60
59
|
})}
|