@meta-1/design 0.0.171 → 0.0.173
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 +1 -1
- package/src/assets/style/theme.css +12 -6
- package/src/components/ui/dialog.tsx +1 -1
- package/src/components/ui/scroll-area.tsx +1 -1
- package/src/components/uix/alert/index.tsx +20 -6
- package/src/components/uix/data-table/index.tsx +20 -13
- package/src/components/uix/data-table/style.css +36 -0
- package/src/components/uix/dialog/index.tsx +8 -3
- package/src/components/uix/message/index.tsx +28 -4
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%);
|
|
@@ -52,7 +52,7 @@ function DialogContent({
|
|
|
52
52
|
<DialogOverlay onClick={onOverlayClick} />
|
|
53
53
|
<DialogPrimitive.Content
|
|
54
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 flex flex-col w-full max-w-[calc(100vw-2rem)] max-h-[calc(100vh-2rem)] translate-x-[-50%] translate-y-[-50%] rounded-lg border bg-background shadow-lg duration-200 data-[state=closed]:animate-out data-[state=open]:animate-in sm:max-w-lg",
|
|
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 flex flex-col gap-4 w-full max-w-[calc(100vw-2rem)] max-h-[calc(100vh-2rem)] translate-x-[-50%] translate-y-[-50%] rounded-lg border bg-background shadow-lg duration-200 data-[state=closed]:animate-out data-[state=open]:animate-in sm:max-w-lg",
|
|
56
56
|
className,
|
|
57
57
|
)}
|
|
58
58
|
data-slot="dialog-content"
|
|
@@ -5,7 +5,7 @@ import { cn } from "@meta-1/design/lib/utils";
|
|
|
5
5
|
|
|
6
6
|
function ScrollArea({ className, children, ...props }: React.ComponentProps<typeof ScrollAreaPrimitive.Root>) {
|
|
7
7
|
return (
|
|
8
|
-
<ScrollAreaPrimitive.Root className={cn("relative", className)} data-slot="scroll-area" {...props}>
|
|
8
|
+
<ScrollAreaPrimitive.Root className={cn("relative overflow-hidden", className)} data-slot="scroll-area" {...props}>
|
|
9
9
|
<ScrollAreaPrimitive.Viewport
|
|
10
10
|
className="size-full rounded-[inherit] outline-none transition-[color,box-shadow] focus-visible:outline-1 focus-visible:ring-[3px] focus-visible:ring-ring/50"
|
|
11
11
|
data-slot="scroll-area-viewport"
|
|
@@ -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>}
|
|
@@ -28,7 +28,6 @@ import {
|
|
|
28
28
|
type PaginationProps,
|
|
29
29
|
Spin,
|
|
30
30
|
} from "@meta-1/design";
|
|
31
|
-
import { ScrollArea } from "@meta-1/design/components/ui/scroll-area";
|
|
32
31
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "../../ui/table";
|
|
33
32
|
import "./style.css";
|
|
34
33
|
|
|
@@ -368,10 +367,9 @@ export function DataTable<TData>(props: DataTableProps<TData>) {
|
|
|
368
367
|
}, [pagination, autoHidePagination]);
|
|
369
368
|
|
|
370
369
|
// 渲染表头的通用函数
|
|
371
|
-
const renderTableHeader = (
|
|
372
|
-
const { fixedHeader = false } = options;
|
|
370
|
+
const renderTableHeader = () => {
|
|
373
371
|
return (
|
|
374
|
-
<TableHeader className={cn(!showHeader && "hidden"
|
|
372
|
+
<TableHeader className={cn(!showHeader && "hidden")}>
|
|
375
373
|
{table.getHeaderGroups().map((headerGroup) => (
|
|
376
374
|
<TableRow key={headerGroup.id}>
|
|
377
375
|
{headerGroup.headers.map((header) => {
|
|
@@ -394,7 +392,7 @@ export function DataTable<TData>(props: DataTableProps<TData>) {
|
|
|
394
392
|
style={
|
|
395
393
|
sticky.enable
|
|
396
394
|
? {
|
|
397
|
-
zIndex:
|
|
395
|
+
zIndex: 10,
|
|
398
396
|
minWidth: sticky.width,
|
|
399
397
|
[sticky.position as string]: sticky.offset,
|
|
400
398
|
}
|
|
@@ -491,14 +489,23 @@ export function DataTable<TData>(props: DataTableProps<TData>) {
|
|
|
491
489
|
) : null}
|
|
492
490
|
<div className={cn("relative")}>
|
|
493
491
|
{maxHeight ? (
|
|
494
|
-
//
|
|
495
|
-
<div className={cn("
|
|
496
|
-
<
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
<
|
|
501
|
-
|
|
492
|
+
// 有高度限制时:直接渲染 table 元素,避免 Table 组件自带的 overflow-x-auto 包裹层
|
|
493
|
+
<div className={cn("overflow-x-auto", !mounted && "invisible")}>
|
|
494
|
+
<div
|
|
495
|
+
className="overflow-y-auto"
|
|
496
|
+
style={{ maxHeight: typeof maxHeight === "number" ? `${maxHeight}px` : maxHeight }}
|
|
497
|
+
>
|
|
498
|
+
<table
|
|
499
|
+
className={classNames(
|
|
500
|
+
"data-table data-table-sticky-header w-full caption-bottom text-sm",
|
|
501
|
+
inCard ? "in-card" : null,
|
|
502
|
+
)}
|
|
503
|
+
data-slot="table"
|
|
504
|
+
>
|
|
505
|
+
{renderTableHeader()}
|
|
506
|
+
{renderTableBody()}
|
|
507
|
+
</table>
|
|
508
|
+
</div>
|
|
502
509
|
</div>
|
|
503
510
|
) : (
|
|
504
511
|
// 无高度限制时,使用原有布局
|
|
@@ -38,3 +38,39 @@
|
|
|
38
38
|
.data-table tr[data-state="selected"] td.table-sticky-col .inner {
|
|
39
39
|
@apply bg-[hsl(var(--muted))];
|
|
40
40
|
}
|
|
41
|
+
|
|
42
|
+
.data-table-sticky-header thead {
|
|
43
|
+
position: sticky;
|
|
44
|
+
top: 0;
|
|
45
|
+
z-index: 20;
|
|
46
|
+
@apply bg-background;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.data-table-sticky-header.in-card thead {
|
|
50
|
+
@apply bg-card;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.data-table-sticky-header thead th {
|
|
54
|
+
@apply bg-background;
|
|
55
|
+
z-index: 20;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.data-table-sticky-header.in-card thead th {
|
|
59
|
+
@apply bg-card;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.data-table-sticky-header thead th.table-sticky-col {
|
|
63
|
+
z-index: 30;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.data-table-sticky-header thead th.table-sticky-col.sticky {
|
|
67
|
+
position: sticky !important;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.data-table-sticky-header thead th.table-sticky-col .inner {
|
|
71
|
+
@apply bg-background;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.data-table-sticky-header.in-card thead th.table-sticky-col .inner {
|
|
75
|
+
@apply bg-card;
|
|
76
|
+
}
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
DialogTitle,
|
|
10
10
|
Dialog as UIDialog,
|
|
11
11
|
} from "@meta-1/design/components/ui/dialog";
|
|
12
|
-
import { ScrollArea } from "@meta-1/design/components/ui/scroll-area";
|
|
13
12
|
import { Spin } from "@meta-1/design/components/uix/spin";
|
|
14
13
|
import { cn } from "@meta-1/design/lib";
|
|
15
14
|
|
|
@@ -56,10 +55,16 @@ export const Dialog: FC<DialogProps> = (props) => {
|
|
|
56
55
|
<DialogTitle className={cn(!title && "sr-only")}>{title || "Dialog"}</DialogTitle>
|
|
57
56
|
{description ? <DialogDescription>{description}</DialogDescription> : null}
|
|
58
57
|
</DialogHeader>
|
|
59
|
-
<
|
|
58
|
+
<div className={cn("min-h-0 flex-1 overflow-auto px-6", !footer && "pb-6")}>{props.children}</div>
|
|
60
59
|
{footer ? <DialogFooter>{footer}</DialogFooter> : null}
|
|
61
60
|
{loading ? (
|
|
62
|
-
<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
|
+
>
|
|
63
68
|
<Spin />
|
|
64
69
|
</div>
|
|
65
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
|
}, []);
|