@hilum/ui 3.6.1 → 3.6.3
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/dist/index.d.ts +46 -2
- package/dist/index.js +108 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/status-tile.tsx +85 -0
- package/src/components/summary-tile.tsx +56 -0
- package/src/components/titled-card.tsx +12 -12
- package/src/index.ts +2 -0
package/package.json
CHANGED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cn } from "../lib/utils";
|
|
3
|
+
import { StatusBadge, type StatusBadgeVariant } from "./status-badge";
|
|
4
|
+
|
|
5
|
+
interface StatusTileGridProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
columns?: 2 | 3 | 4;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface StatusTileProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title"> {
|
|
10
|
+
title: React.ReactNode;
|
|
11
|
+
status: string;
|
|
12
|
+
description?: React.ReactNode;
|
|
13
|
+
meta?: React.ReactNode;
|
|
14
|
+
icon?: React.ComponentType<{ className?: string }>;
|
|
15
|
+
labelMap?: Record<string, React.ReactNode>;
|
|
16
|
+
variantMap?: Record<string, StatusBadgeVariant>;
|
|
17
|
+
iconMap?: Record<string, React.ComponentType<{ className?: string }>>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const columnClassName: Record<NonNullable<StatusTileGridProps["columns"]>, string> = {
|
|
21
|
+
2: "md:grid-cols-2",
|
|
22
|
+
3: "md:grid-cols-2 xl:grid-cols-3",
|
|
23
|
+
4: "md:grid-cols-2 xl:grid-cols-4",
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
function StatusTileGrid({ columns = 3, className, ...props }: StatusTileGridProps) {
|
|
27
|
+
return (
|
|
28
|
+
<div
|
|
29
|
+
data-slot="status-tile-grid"
|
|
30
|
+
className={cn(
|
|
31
|
+
"divide-y divide-border md:grid md:gap-4 md:divide-y-0",
|
|
32
|
+
columnClassName[columns],
|
|
33
|
+
className,
|
|
34
|
+
)}
|
|
35
|
+
{...props}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function StatusTile({
|
|
41
|
+
title,
|
|
42
|
+
status,
|
|
43
|
+
description,
|
|
44
|
+
meta,
|
|
45
|
+
icon: Icon,
|
|
46
|
+
labelMap,
|
|
47
|
+
variantMap,
|
|
48
|
+
iconMap,
|
|
49
|
+
className,
|
|
50
|
+
...props
|
|
51
|
+
}: StatusTileProps) {
|
|
52
|
+
return (
|
|
53
|
+
<div
|
|
54
|
+
data-slot="status-tile"
|
|
55
|
+
className={cn(
|
|
56
|
+
"min-w-0 py-4 md:rounded-lg md:border md:border-border md:bg-background md:p-4 md:shadow-natural",
|
|
57
|
+
className,
|
|
58
|
+
)}
|
|
59
|
+
{...props}
|
|
60
|
+
>
|
|
61
|
+
<div className="flex min-w-0 items-start justify-between gap-3">
|
|
62
|
+
<div className="flex min-w-0 items-center gap-2">
|
|
63
|
+
{Icon ? <Icon className="size-4 shrink-0 text-muted-foreground" /> : null}
|
|
64
|
+
<h3 className="body min-w-0 truncate font-medium text-foreground">{title}</h3>
|
|
65
|
+
</div>
|
|
66
|
+
<StatusBadge
|
|
67
|
+
status={status}
|
|
68
|
+
{...(labelMap ? { labelMap } : {})}
|
|
69
|
+
{...(variantMap ? { variantMap } : {})}
|
|
70
|
+
{...(iconMap ? { iconMap } : {})}
|
|
71
|
+
className="shrink-0"
|
|
72
|
+
/>
|
|
73
|
+
</div>
|
|
74
|
+
{description ? (
|
|
75
|
+
<p className="body-sm mt-3 text-muted-foreground">{description}</p>
|
|
76
|
+
) : null}
|
|
77
|
+
{meta ? <div className="mt-3 min-w-0 text-muted-foreground">{meta}</div> : null}
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
StatusTileGrid.displayName = "StatusTileGrid";
|
|
83
|
+
StatusTile.displayName = "StatusTile";
|
|
84
|
+
|
|
85
|
+
export { StatusTile, StatusTileGrid, type StatusTileProps, type StatusTileGridProps };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cn } from "../lib/utils";
|
|
3
|
+
|
|
4
|
+
interface SummaryTileGridProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
columns?: 2 | 3 | 4;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface SummaryTileProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
9
|
+
title: string;
|
|
10
|
+
value: React.ReactNode;
|
|
11
|
+
description?: React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const columnClassName: Record<NonNullable<SummaryTileGridProps["columns"]>, string> = {
|
|
15
|
+
2: "md:grid-cols-2",
|
|
16
|
+
3: "md:grid-cols-2 xl:grid-cols-3",
|
|
17
|
+
4: "md:grid-cols-2 xl:grid-cols-4",
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
function SummaryTileGrid({ columns = 3, className, ...props }: SummaryTileGridProps) {
|
|
21
|
+
return (
|
|
22
|
+
<div
|
|
23
|
+
data-slot="summary-tile-grid"
|
|
24
|
+
className={cn(
|
|
25
|
+
"divide-y divide-border md:grid md:gap-3 md:divide-y-0",
|
|
26
|
+
columnClassName[columns],
|
|
27
|
+
className,
|
|
28
|
+
)}
|
|
29
|
+
{...props}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function SummaryTile({ title, value, description, className, ...props }: SummaryTileProps) {
|
|
35
|
+
return (
|
|
36
|
+
<div
|
|
37
|
+
data-slot="summary-tile"
|
|
38
|
+
className={cn(
|
|
39
|
+
"min-w-0 py-4 md:rounded-lg md:border md:border-border md:bg-card md:p-4",
|
|
40
|
+
className,
|
|
41
|
+
)}
|
|
42
|
+
{...props}
|
|
43
|
+
>
|
|
44
|
+
<p className="text-xs font-semibold uppercase tracking-wide text-muted-foreground">{title}</p>
|
|
45
|
+
<p className="mt-2 text-xl font-semibold text-foreground">{value}</p>
|
|
46
|
+
{description ? (
|
|
47
|
+
<p className="mt-1 text-sm leading-5 text-muted-foreground">{description}</p>
|
|
48
|
+
) : null}
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
SummaryTileGrid.displayName = "SummaryTileGrid";
|
|
54
|
+
SummaryTile.displayName = "SummaryTile";
|
|
55
|
+
|
|
56
|
+
export { SummaryTile, SummaryTileGrid, type SummaryTileProps, type SummaryTileGridProps };
|
|
@@ -2,13 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { cn } from "../lib/utils";
|
|
5
|
-
import {
|
|
6
|
-
Card,
|
|
7
|
-
CardContent,
|
|
8
|
-
CardDescription,
|
|
9
|
-
CardHeader,
|
|
10
|
-
CardTitle,
|
|
11
|
-
} from "./card";
|
|
5
|
+
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "./card";
|
|
12
6
|
import { CardHeading } from "./card-heading";
|
|
13
7
|
|
|
14
8
|
interface TitledCardProps {
|
|
@@ -17,6 +11,7 @@ interface TitledCardProps {
|
|
|
17
11
|
children?: React.ReactNode;
|
|
18
12
|
actionButtons?: React.ReactNode;
|
|
19
13
|
icon?: React.ComponentType<{ className?: string }>;
|
|
14
|
+
contentPadding?: "default" | "flush-mobile" | "flush";
|
|
20
15
|
className?: string;
|
|
21
16
|
contentClassName?: string;
|
|
22
17
|
containerClassName?: string;
|
|
@@ -29,6 +24,7 @@ function TitledCard({
|
|
|
29
24
|
children,
|
|
30
25
|
actionButtons,
|
|
31
26
|
icon: Icon,
|
|
27
|
+
contentPadding = "default",
|
|
32
28
|
className,
|
|
33
29
|
contentClassName,
|
|
34
30
|
containerClassName,
|
|
@@ -36,6 +32,14 @@ function TitledCard({
|
|
|
36
32
|
}: TitledCardProps) {
|
|
37
33
|
const hasHeader = Boolean(title || subtitle || actionButtons);
|
|
38
34
|
const canUseCardHeading = Boolean(title) && !actionButtons && !titleClassName;
|
|
35
|
+
const contentPaddingClassName =
|
|
36
|
+
contentPadding === "flush"
|
|
37
|
+
? "p-0"
|
|
38
|
+
: contentPadding === "flush-mobile"
|
|
39
|
+
? "p-0 sm:p-5"
|
|
40
|
+
: hasHeader
|
|
41
|
+
? "p-4 sm:p-5"
|
|
42
|
+
: "p-0 sm:p-5";
|
|
39
43
|
|
|
40
44
|
return (
|
|
41
45
|
<Card
|
|
@@ -84,11 +88,7 @@ function TitledCard({
|
|
|
84
88
|
) : null}
|
|
85
89
|
{children && (
|
|
86
90
|
<CardContent
|
|
87
|
-
className={cn(
|
|
88
|
-
hasHeader ? "p-4 sm:p-5" : "p-0 sm:p-5",
|
|
89
|
-
"min-w-0 max-sm:px-0",
|
|
90
|
-
contentClassName,
|
|
91
|
-
)}
|
|
91
|
+
className={cn(contentPaddingClassName, "min-w-0 max-sm:px-0", contentClassName)}
|
|
92
92
|
>
|
|
93
93
|
{children}
|
|
94
94
|
</CardContent>
|
package/src/index.ts
CHANGED
|
@@ -98,7 +98,9 @@ export * from "./components/spinner";
|
|
|
98
98
|
export * from "./components/stacked-list";
|
|
99
99
|
export * from "./components/stat-card";
|
|
100
100
|
export * from "./components/status-badge";
|
|
101
|
+
export * from "./components/status-tile";
|
|
101
102
|
export * from "./components/steps";
|
|
103
|
+
export * from "./components/summary-tile";
|
|
102
104
|
export * from "./components/switch";
|
|
103
105
|
export * from "./components/table";
|
|
104
106
|
export * from "./components/tabs";
|