@meta-1/design 0.0.172 → 0.0.174
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
CHANGED
|
@@ -29,6 +29,8 @@
|
|
|
29
29
|
--color-error-foreground: var(--error-foreground);
|
|
30
30
|
--color-warning: var(--warning);
|
|
31
31
|
--color-warning-foreground: var(--warning-foreground);
|
|
32
|
+
--color-info: var(--info);
|
|
33
|
+
--color-info-foreground: var(--info-foreground);
|
|
32
34
|
--color-border: var(--border);
|
|
33
35
|
--color-input: var(--input);
|
|
34
36
|
--color-ring: var(--ring);
|
|
@@ -66,6 +68,8 @@
|
|
|
66
68
|
--error-foreground: rgba(245, 63, 63, 1);
|
|
67
69
|
--warning: rgba(255, 247, 232, 1);
|
|
68
70
|
--warning-foreground: rgba(255, 125, 0, 1);
|
|
71
|
+
--info: rgba(232, 243, 255, 1);
|
|
72
|
+
--info-foreground: rgba(37, 99, 235, 1);
|
|
69
73
|
--muted: hsl(0 0% 96.1%);
|
|
70
74
|
--muted-foreground: hsl(0 0% 45.1%);
|
|
71
75
|
--accent: hsl(0 0% 96.1%);
|
|
@@ -101,12 +105,14 @@
|
|
|
101
105
|
--popover-foreground: hsl(0 0% 98%);
|
|
102
106
|
--primary: rgba(68, 133, 105, 1);
|
|
103
107
|
--primary-foreground: rgba(255, 255, 255, 1);
|
|
104
|
-
--success: rgba(
|
|
105
|
-
--success-foreground: rgba(
|
|
106
|
-
--error: rgba(
|
|
107
|
-
--error-foreground: rgba(
|
|
108
|
-
--warning: rgba(
|
|
109
|
-
--warning-foreground: rgba(
|
|
108
|
+
--success: rgba(20, 83, 45, 0.2);
|
|
109
|
+
--success-foreground: rgba(74, 222, 128, 1);
|
|
110
|
+
--error: rgba(127, 29, 29, 0.2);
|
|
111
|
+
--error-foreground: rgba(252, 165, 165, 1);
|
|
112
|
+
--warning: rgba(120, 53, 15, 0.2);
|
|
113
|
+
--warning-foreground: rgba(251, 191, 36, 1);
|
|
114
|
+
--info: rgba(30, 58, 138, 0.2);
|
|
115
|
+
--info-foreground: rgba(147, 197, 253, 1);
|
|
110
116
|
--secondary: hsl(0 0% 14.9%);
|
|
111
117
|
--secondary-foreground: hsl(0 0% 98%);
|
|
112
118
|
--muted: hsl(0 0% 14.9%);
|
|
@@ -3,13 +3,16 @@ import type { ComponentProps, ReactNode } from "react";
|
|
|
3
3
|
import { cn } from "@meta-1/design/lib";
|
|
4
4
|
import { Alert as UIAlert, AlertDescription as UIAlertDescription, AlertTitle as UIAlertTitle } from "../../ui/alert";
|
|
5
5
|
|
|
6
|
-
export type
|
|
6
|
+
export type AlertVariant = "default" | "destructive" | "success" | "error" | "warning" | "info";
|
|
7
|
+
|
|
8
|
+
export type AlertProps = Omit<ComponentProps<typeof UIAlert>, "variant"> & {
|
|
7
9
|
title?: ReactNode;
|
|
8
10
|
description?: ReactNode;
|
|
9
11
|
icon?: ReactNode;
|
|
10
12
|
children?: ReactNode;
|
|
11
13
|
titleClassName?: string;
|
|
12
14
|
descriptionClassName?: string;
|
|
15
|
+
variant?: AlertVariant;
|
|
13
16
|
};
|
|
14
17
|
|
|
15
18
|
export const Alert = (props: AlertProps) => {
|
|
@@ -20,19 +23,30 @@ export const Alert = (props: AlertProps) => {
|
|
|
20
23
|
children: childrenProp,
|
|
21
24
|
titleClassName,
|
|
22
25
|
descriptionClassName,
|
|
23
|
-
variant,
|
|
26
|
+
variant = "default",
|
|
24
27
|
...rest
|
|
25
28
|
} = props;
|
|
26
29
|
|
|
27
30
|
let className = props.className;
|
|
28
31
|
const children = childrenProp || description;
|
|
29
32
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
// 根据 variant 设置样式
|
|
34
|
+
const variantStyles: Record<AlertVariant, string> = {
|
|
35
|
+
default: "",
|
|
36
|
+
destructive: "border-destructive/20 bg-destructive/10 text-destructive",
|
|
37
|
+
success: "border-success-foreground/20 bg-success text-success-foreground",
|
|
38
|
+
error: "border-error-foreground/20 bg-error text-error-foreground",
|
|
39
|
+
warning: "border-warning-foreground/20 bg-warning text-warning-foreground",
|
|
40
|
+
info: "border-info-foreground/20 bg-info text-info-foreground",
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
className = cn(variantStyles[variant], className);
|
|
44
|
+
|
|
45
|
+
// 只有 default 和 destructive 传给 UIAlert,其他的我们自己处理样式
|
|
46
|
+
const uiVariant = variant === "destructive" ? "destructive" : "default";
|
|
33
47
|
|
|
34
48
|
return (
|
|
35
|
-
<UIAlert {...rest} className={cn("flex gap-2", className)} variant={
|
|
49
|
+
<UIAlert {...rest} className={cn("flex gap-2", className)} variant={uiVariant}>
|
|
36
50
|
{icon}
|
|
37
51
|
<div className="flex flex-1 flex-col gap-2">
|
|
38
52
|
{title && <UIAlertTitle className={titleClassName}>{title}</UIAlertTitle>}
|
|
@@ -55,10 +55,16 @@ export const Dialog: FC<DialogProps> = (props) => {
|
|
|
55
55
|
<DialogTitle className={cn(!title && "sr-only")}>{title || "Dialog"}</DialogTitle>
|
|
56
56
|
{description ? <DialogDescription>{description}</DialogDescription> : null}
|
|
57
57
|
</DialogHeader>
|
|
58
|
-
<div className="min-h-0 flex-1 overflow-auto px-6">{props.children}</div>
|
|
58
|
+
<div className={cn("min-h-0 flex-1 overflow-auto px-6", !footer && "pb-6")}>{props.children}</div>
|
|
59
59
|
{footer ? <DialogFooter>{footer}</DialogFooter> : null}
|
|
60
60
|
{loading ? (
|
|
61
|
-
<div
|
|
61
|
+
<div
|
|
62
|
+
className={cn(
|
|
63
|
+
"absolute top-0 right-0 bottom-0 left-0 rounded-lg",
|
|
64
|
+
"bg-background/80 backdrop-blur-sm",
|
|
65
|
+
"flex items-center justify-center",
|
|
66
|
+
)}
|
|
67
|
+
>
|
|
62
68
|
<Spin />
|
|
63
69
|
</div>
|
|
64
70
|
) : null}
|
|
@@ -5,16 +5,40 @@ export const useMessage = () => {
|
|
|
5
5
|
return useMemo(() => {
|
|
6
6
|
return {
|
|
7
7
|
success: (message?: ReactNode, options?: ExternalToast) => {
|
|
8
|
-
toast.success(message,
|
|
8
|
+
toast.success(message, {
|
|
9
|
+
unstyled: true,
|
|
10
|
+
...options,
|
|
11
|
+
className:
|
|
12
|
+
"group w-full max-w-sm border-success-foreground/20 bg-success/80 text-success-foreground rounded-lg border px-4 py-3 shadow-lg flex items-start gap-3 backdrop-blur-sm overflow-hidden",
|
|
13
|
+
descriptionClassName: "text-sm truncate",
|
|
14
|
+
});
|
|
9
15
|
},
|
|
10
16
|
error: (message?: ReactNode, options?: ExternalToast) => {
|
|
11
|
-
toast.error(message,
|
|
17
|
+
toast.error(message, {
|
|
18
|
+
unstyled: true,
|
|
19
|
+
...options,
|
|
20
|
+
className:
|
|
21
|
+
"group w-full max-w-sm border-error-foreground/20 bg-error/80 text-error-foreground rounded-lg border px-4 py-3 shadow-lg flex items-start gap-3 backdrop-blur-sm overflow-hidden",
|
|
22
|
+
descriptionClassName: "text-sm truncate",
|
|
23
|
+
});
|
|
12
24
|
},
|
|
13
25
|
warning: (message?: ReactNode, options?: ExternalToast) => {
|
|
14
|
-
toast.warning(message,
|
|
26
|
+
toast.warning(message, {
|
|
27
|
+
unstyled: true,
|
|
28
|
+
...options,
|
|
29
|
+
className:
|
|
30
|
+
"group w-full max-w-sm border-warning-foreground/20 bg-warning/80 text-warning-foreground rounded-lg border px-4 py-3 shadow-lg flex items-start gap-3 backdrop-blur-sm overflow-hidden",
|
|
31
|
+
descriptionClassName: "text-sm truncate",
|
|
32
|
+
});
|
|
15
33
|
},
|
|
16
34
|
info: (message?: ReactNode, options?: ExternalToast) => {
|
|
17
|
-
toast.info(message,
|
|
35
|
+
toast.info(message, {
|
|
36
|
+
unstyled: true,
|
|
37
|
+
...options,
|
|
38
|
+
className:
|
|
39
|
+
"group w-full max-w-sm border-info-foreground/20 bg-info/80 text-info-foreground rounded-lg border px-4 py-3 shadow-lg flex items-start gap-3 backdrop-blur-sm overflow-hidden",
|
|
40
|
+
descriptionClassName: "text-sm truncate",
|
|
41
|
+
});
|
|
18
42
|
},
|
|
19
43
|
};
|
|
20
44
|
}, []);
|
|
@@ -120,43 +120,81 @@ export const Pagination: FC<PaginationProps> = (props) => {
|
|
|
120
120
|
|
|
121
121
|
const pageNumbers = generatePageNumbers(page, totalPage);
|
|
122
122
|
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
// 渲染简单分页导航(只有上一页、当前页、下一页)
|
|
124
|
+
const renderSimplePagination = () => {
|
|
125
125
|
return (
|
|
126
|
-
<
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
126
|
+
<PaginationContent>
|
|
127
|
+
{/* 上一页 */}
|
|
128
|
+
<PaginationItem>
|
|
129
|
+
<PaginationPrevious
|
|
130
|
+
className={page === 1 ? "pointer-events-none opacity-50" : "cursor-pointer"}
|
|
131
|
+
onClick={page === 1 ? undefined : () => onChange?.(page - 1)}
|
|
132
|
+
size="default"
|
|
133
|
+
/>
|
|
134
|
+
</PaginationItem>
|
|
135
|
+
|
|
136
|
+
{/* 当前页 */}
|
|
137
|
+
<PaginationItem>
|
|
138
|
+
<PaginationLink isActive size="default">
|
|
139
|
+
{page}
|
|
140
|
+
</PaginationLink>
|
|
141
|
+
</PaginationItem>
|
|
142
|
+
|
|
143
|
+
{/* 下一页 */}
|
|
144
|
+
<PaginationItem>
|
|
145
|
+
<PaginationNext
|
|
146
|
+
className={page === totalPage ? "pointer-events-none opacity-50" : "cursor-pointer"}
|
|
147
|
+
onClick={page === totalPage ? undefined : () => onChange?.(page + 1)}
|
|
148
|
+
size="default"
|
|
149
|
+
/>
|
|
150
|
+
</PaginationItem>
|
|
151
|
+
</PaginationContent>
|
|
152
|
+
);
|
|
153
|
+
};
|
|
144
154
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
155
|
+
// 渲染完整分页导航(包含所有页码)
|
|
156
|
+
const renderFullPagination = () => {
|
|
157
|
+
return (
|
|
158
|
+
<PaginationContent>
|
|
159
|
+
{/* 上一页 */}
|
|
160
|
+
<PaginationItem>
|
|
161
|
+
<PaginationPrevious
|
|
162
|
+
className={page === 1 ? "pointer-events-none opacity-50" : "cursor-pointer"}
|
|
163
|
+
onClick={page === 1 ? undefined : () => onChange?.(page - 1)}
|
|
164
|
+
size="default"
|
|
165
|
+
/>
|
|
166
|
+
</PaginationItem>
|
|
167
|
+
|
|
168
|
+
{/* 页码数字 */}
|
|
169
|
+
{pageNumbers.map((pageNum, index) => (
|
|
170
|
+
<PaginationItem key={pageNum === "ellipsis" ? `ellipsis-${index}` : `page-${pageNum}`}>
|
|
171
|
+
{pageNum === "ellipsis" ? (
|
|
172
|
+
<PaginationEllipsis />
|
|
173
|
+
) : (
|
|
174
|
+
<PaginationLink
|
|
175
|
+
className="cursor-pointer"
|
|
176
|
+
isActive={pageNum === page}
|
|
177
|
+
onClick={() => onChange?.(pageNum)}
|
|
150
178
|
size="default"
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
179
|
+
>
|
|
180
|
+
{pageNum}
|
|
181
|
+
</PaginationLink>
|
|
182
|
+
)}
|
|
183
|
+
</PaginationItem>
|
|
184
|
+
))}
|
|
185
|
+
|
|
186
|
+
{/* 下一页 */}
|
|
187
|
+
<PaginationItem>
|
|
188
|
+
<PaginationNext
|
|
189
|
+
className={page === totalPage ? "pointer-events-none opacity-50" : "cursor-pointer"}
|
|
190
|
+
onClick={page === totalPage ? undefined : () => onChange?.(page + 1)}
|
|
191
|
+
size="default"
|
|
192
|
+
/>
|
|
193
|
+
</PaginationItem>
|
|
194
|
+
</PaginationContent>
|
|
156
195
|
);
|
|
157
|
-
}
|
|
196
|
+
};
|
|
158
197
|
|
|
159
|
-
// 标准模式渲染
|
|
160
198
|
return (
|
|
161
199
|
<div className="flex items-center justify-center space-x-6">
|
|
162
200
|
<ShadcnPagination>
|
|
@@ -168,43 +206,7 @@ export const Pagination: FC<PaginationProps> = (props) => {
|
|
|
168
206
|
</div>
|
|
169
207
|
) : null}
|
|
170
208
|
{/* 分页导航 */}
|
|
171
|
-
|
|
172
|
-
{/* 上一页 */}
|
|
173
|
-
<PaginationItem>
|
|
174
|
-
<PaginationPrevious
|
|
175
|
-
className={page === 1 ? "pointer-events-none opacity-50" : "cursor-pointer"}
|
|
176
|
-
onClick={page === 1 ? undefined : () => onChange?.(page - 1)}
|
|
177
|
-
size="default"
|
|
178
|
-
/>
|
|
179
|
-
</PaginationItem>
|
|
180
|
-
|
|
181
|
-
{/* 页码数字 */}
|
|
182
|
-
{pageNumbers.map((pageNum, index) => (
|
|
183
|
-
<PaginationItem key={pageNum === "ellipsis" ? `ellipsis-${index}` : `page-${pageNum}`}>
|
|
184
|
-
{pageNum === "ellipsis" ? (
|
|
185
|
-
<PaginationEllipsis />
|
|
186
|
-
) : (
|
|
187
|
-
<PaginationLink
|
|
188
|
-
className="cursor-pointer"
|
|
189
|
-
isActive={pageNum === page}
|
|
190
|
-
onClick={() => onChange?.(pageNum)}
|
|
191
|
-
size="default"
|
|
192
|
-
>
|
|
193
|
-
{pageNum}
|
|
194
|
-
</PaginationLink>
|
|
195
|
-
)}
|
|
196
|
-
</PaginationItem>
|
|
197
|
-
))}
|
|
198
|
-
|
|
199
|
-
{/* 下一页 */}
|
|
200
|
-
<PaginationItem>
|
|
201
|
-
<PaginationNext
|
|
202
|
-
className={page === totalPage ? "pointer-events-none opacity-50" : "cursor-pointer"}
|
|
203
|
-
onClick={page === totalPage ? undefined : () => onChange?.(page + 1)}
|
|
204
|
-
size="default"
|
|
205
|
-
/>
|
|
206
|
-
</PaginationItem>
|
|
207
|
-
</PaginationContent>
|
|
209
|
+
{simple ? renderSimplePagination() : renderFullPagination()}
|
|
208
210
|
{/* 控制区域 */}
|
|
209
211
|
{showSizeChanger || showQuickJumper ? (
|
|
210
212
|
<div className="flex items-center space-x-3">
|