@hilum/ui 3.2.4 → 3.2.6
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
|
@@ -5,6 +5,7 @@ import { Badge } from "./badge";
|
|
|
5
5
|
import { cn } from "../lib/utils";
|
|
6
6
|
|
|
7
7
|
type StatusBadgeVariant = NonNullable<React.ComponentProps<typeof Badge>["variant"]>;
|
|
8
|
+
type StatusBadgeIcon = React.ComponentType<{ className?: string }>;
|
|
8
9
|
|
|
9
10
|
interface StatusBadgeProps extends Omit<
|
|
10
11
|
React.ComponentProps<typeof Badge>,
|
|
@@ -15,6 +16,9 @@ interface StatusBadgeProps extends Omit<
|
|
|
15
16
|
variant?: StatusBadgeVariant;
|
|
16
17
|
variantMap?: Record<string, StatusBadgeVariant>;
|
|
17
18
|
labelMap?: Record<string, React.ReactNode>;
|
|
19
|
+
icon?: StatusBadgeIcon;
|
|
20
|
+
iconMap?: Record<string, StatusBadgeIcon>;
|
|
21
|
+
iconClassName?: string;
|
|
18
22
|
showDot?: boolean;
|
|
19
23
|
dotClassName?: string;
|
|
20
24
|
}
|
|
@@ -108,6 +112,9 @@ function StatusBadge({
|
|
|
108
112
|
variant,
|
|
109
113
|
variantMap,
|
|
110
114
|
labelMap,
|
|
115
|
+
icon,
|
|
116
|
+
iconMap,
|
|
117
|
+
iconClassName,
|
|
111
118
|
showDot = false,
|
|
112
119
|
dotClassName,
|
|
113
120
|
className,
|
|
@@ -116,11 +123,12 @@ function StatusBadge({
|
|
|
116
123
|
const normalized = normalizeStatus(status);
|
|
117
124
|
const resolvedVariant = variant ?? statusBadgeVariantFor(normalized, variantMap);
|
|
118
125
|
const resolvedLabel = label ?? labelMap?.[normalized] ?? statusLabel(normalized);
|
|
126
|
+
const Icon = icon ?? iconMap?.[normalized];
|
|
119
127
|
|
|
120
128
|
return (
|
|
121
129
|
<Badge
|
|
122
130
|
variant={resolvedVariant}
|
|
123
|
-
className={cn("max-w-full whitespace-nowrap", showDot && "pl-2", className)}
|
|
131
|
+
className={cn("max-w-full whitespace-nowrap", (showDot || Icon) && "pl-2", className)}
|
|
124
132
|
{...props}
|
|
125
133
|
>
|
|
126
134
|
{showDot && (
|
|
@@ -133,6 +141,7 @@ function StatusBadge({
|
|
|
133
141
|
aria-hidden="true"
|
|
134
142
|
/>
|
|
135
143
|
)}
|
|
144
|
+
{Icon && <Icon className={cn("size-3 shrink-0", iconClassName)} aria-hidden="true" />}
|
|
136
145
|
<span className="min-w-0 truncate">{resolvedLabel}</span>
|
|
137
146
|
</Badge>
|
|
138
147
|
);
|