@meta-1/design 0.0.174 → 0.0.176

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meta-1/design",
3
- "version": "0.0.174",
3
+ "version": "0.0.176",
4
4
  "keywords": [
5
5
  "easykit",
6
6
  "design",
@@ -0,0 +1,42 @@
1
+ import type * as React from "react";
2
+
3
+ import { Badge as UIBadge } from "@meta-1/design/components/ui/badge";
4
+ import { cn } from "@meta-1/design/lib";
5
+
6
+ export type BadgeVariant =
7
+ | "default"
8
+ | "secondary"
9
+ | "destructive"
10
+ | "outline"
11
+ | "success"
12
+ | "error"
13
+ | "warning"
14
+ | "info";
15
+
16
+ export type BadgeProps = Omit<React.ComponentProps<typeof UIBadge>, "variant"> & {
17
+ variant?: BadgeVariant;
18
+ };
19
+
20
+ export const Badge = ({ variant = "default", className, ...props }: BadgeProps) => {
21
+ // 扩展的场景色样式
22
+ const variantStyles: Partial<Record<BadgeVariant, string>> = {
23
+ success: "border-transparent bg-success text-success-foreground",
24
+ error: "border-transparent bg-error text-error-foreground",
25
+ warning: "border-transparent bg-warning text-warning-foreground",
26
+ info: "border-transparent bg-info text-info-foreground",
27
+ };
28
+
29
+ // 扩展场景使用 default variant,并添加自定义样式
30
+ if (variant && ["success", "error", "warning", "info"].includes(variant)) {
31
+ return <UIBadge {...props} className={cn(variantStyles[variant], className)} variant="default" />;
32
+ }
33
+
34
+ // 原生 variant 直接传递
35
+ return (
36
+ <UIBadge
37
+ {...props}
38
+ className={className}
39
+ variant={variant as "default" | "secondary" | "destructive" | "outline"}
40
+ />
41
+ );
42
+ };
@@ -514,8 +514,8 @@ export function DataTable<TData>(props: DataTableProps<TData>) {
514
514
  {renderTableBody()}
515
515
  </Table>
516
516
  )}
517
- <div className={cn("py-4", !mounted && "invisible")}>
518
- {showPagination && (
517
+ {showPagination ? (
518
+ <div className={cn("py-4", !mounted && "invisible")}>
519
519
  <Pagination
520
520
  {...(pagination as PaginationProps)}
521
521
  onChange={(page: number) => {
@@ -525,8 +525,8 @@ export function DataTable<TData>(props: DataTableProps<TData>) {
525
525
  load?.({ size, page: 1 });
526
526
  }}
527
527
  />
528
- )}
529
- </div>
528
+ </div>
529
+ ) : null}
530
530
  {loading || !mounted ? (
531
531
  <div className="dark:!bg-black/5 absolute top-0 right-0 bottom-0 left-0 z-50 flex items-center justify-center bg-white/50">
532
532
  <Spin />
@@ -55,13 +55,15 @@ 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={cn("min-h-0 flex-1 overflow-auto px-6", !footer && "pb-6")}>{props.children}</div>
58
+ <div className="min-h-0 flex-1 overflow-auto">
59
+ <div className={cn("w-fit px-6", !footer && "pb-6")}>{props.children}</div>
60
+ </div>
59
61
  {footer ? <DialogFooter>{footer}</DialogFooter> : null}
60
62
  {loading ? (
61
63
  <div
62
64
  className={cn(
63
65
  "absolute top-0 right-0 bottom-0 left-0 rounded-lg",
64
- "bg-background/80 backdrop-blur-sm",
66
+ "bg-background/20 backdrop-blur-sm",
65
67
  "flex items-center justify-center",
66
68
  )}
67
69
  >
@@ -196,8 +196,8 @@ export const Pagination: FC<PaginationProps> = (props) => {
196
196
  };
197
197
 
198
198
  return (
199
- <div className="flex items-center justify-center space-x-6">
200
- <ShadcnPagination>
199
+ <div className="flex items-center justify-center">
200
+ <ShadcnPagination className="flex items-center justify-center gap-md">
201
201
  {/* 总数信息 */}
202
202
  {showTotal ? (
203
203
  <div className="flex items-center space-x-2 text-muted-foreground text-sm">
package/src/index.ts CHANGED
@@ -8,7 +8,6 @@ export {
8
8
  InputOTPSeparator,
9
9
  InputOTPSlot,
10
10
  } from "@meta-1/design/components/ui/input-otp";
11
- export { Badge } from "./components/ui/badge";
12
11
  export {
13
12
  Breadcrumb,
14
13
  BreadcrumbItem,
@@ -104,6 +103,8 @@ export type { ConfirmProps } from "./components/uix/alert-dialog";
104
103
  export { useAlert } from "./components/uix/alert-dialog";
105
104
  export type { AvatarProps } from "./components/uix/avatar";
106
105
  export { Avatar } from "./components/uix/avatar";
106
+ export type { BadgeProps } from "./components/uix/badge";
107
+ export { Badge } from "./components/uix/badge";
107
108
  export type { BreadcrumbsItemProps, BreadcrumbsProps } from "./components/uix/breadcrumbs";
108
109
  export { Breadcrumbs, BreadcrumbsItem } from "./components/uix/breadcrumbs";
109
110
  export type { BroadcastChannelProviderProps } from "./components/uix/broadcast-channel-context";