@schandlergarcia/sf-web-components 1.6.0 → 1.8.0
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/components/library/cards/ActionList.d.ts +10 -10
- package/dist/components/library/cards/ActionList.js +2 -3
- package/dist/components/library/cards/ActionList.js.map +1 -1
- package/dist/components/library/cards/ActivityCard.d.ts +18 -5
- package/dist/components/library/cards/ActivityCard.js +3 -4
- package/dist/components/library/cards/ActivityCard.js.map +1 -1
- package/dist/components/library/cards/BaseCard.d.ts +30 -24
- package/dist/components/library/cards/BaseCard.js +2 -3
- package/dist/components/library/cards/BaseCard.js.map +1 -1
- package/dist/components/library/cards/CalloutCard.d.ts +11 -9
- package/dist/components/library/cards/CalloutCard.js +2 -3
- package/dist/components/library/cards/CalloutCard.js.map +1 -1
- package/dist/components/library/cards/ChartCard.d.ts +29 -17
- package/dist/components/library/cards/ChartCard.js +13 -14
- package/dist/components/library/cards/ChartCard.js.map +1 -1
- package/dist/components/library/cards/FeedPanel.d.ts +12 -11
- package/dist/components/library/cards/FeedPanel.js +3 -4
- package/dist/components/library/cards/FeedPanel.js.map +1 -1
- package/dist/components/library/cards/ListCard.d.ts +33 -20
- package/dist/components/library/cards/ListCard.js +35 -35
- package/dist/components/library/cards/ListCard.js.map +1 -1
- package/dist/components/library/cards/MetricCard.d.ts +23 -17
- package/dist/components/library/cards/MetricCard.js +10 -11
- package/dist/components/library/cards/MetricCard.js.map +1 -1
- package/dist/components/library/cards/MetricsStrip.d.ts +11 -11
- package/dist/components/library/cards/MetricsStrip.js +1 -1
- package/dist/components/library/cards/MetricsStrip.js.map +1 -1
- package/dist/components/library/cards/SectionCard.d.ts +17 -12
- package/dist/components/library/cards/SectionCard.js +18 -19
- package/dist/components/library/cards/SectionCard.js.map +1 -1
- package/dist/components/library/cards/SemanticMetricCard.d.ts +15 -20
- package/dist/components/library/cards/SemanticMetricCardWithLoading.d.ts +8 -7
- package/dist/components/library/cards/SemanticTableCard.d.ts +13 -18
- package/dist/components/library/cards/SemanticTableCardWithLoading.d.ts +8 -7
- package/dist/components/library/cards/StatusCard.d.ts +29 -15
- package/dist/components/library/cards/StatusCard.js +16 -17
- package/dist/components/library/cards/StatusCard.js.map +1 -1
- package/dist/components/library/cards/TableCard.d.ts +40 -23
- package/dist/components/library/cards/TableCard.js +59 -59
- package/dist/components/library/cards/TableCard.js.map +1 -1
- package/dist/components/library/cards/WidgetCard.d.ts +19 -11
- package/dist/components/library/cards/WidgetCard.js.map +1 -1
- package/dist/components/library/charts/D3Chart.d.ts +23 -16
- package/dist/components/library/charts/D3Chart.js.map +1 -1
- package/dist/components/library/charts/D3ChartTemplates.d.ts +33 -3
- package/dist/components/library/charts/D3ChartTemplates.js +7 -7
- package/dist/components/library/charts/D3ChartTemplates.js.map +1 -1
- package/dist/components/library/charts/GeoMap.d.ts +81 -18
- package/dist/components/library/charts/GeoMap.js +28 -26
- package/dist/components/library/charts/GeoMap.js.map +1 -1
- package/dist/components/library/filters/FilterBar.d.ts +18 -8
- package/dist/components/library/filters/FilterBar.js +2 -3
- package/dist/components/library/filters/FilterBar.js.map +1 -1
- package/dist/components/library/filters/SearchFilter.d.ts +7 -6
- package/dist/components/library/filters/SearchFilter.js +2 -3
- package/dist/components/library/filters/SearchFilter.js.map +1 -1
- package/dist/components/library/filters/SelectFilter.d.ts +13 -7
- package/dist/components/library/filters/SelectFilter.js +2 -3
- package/dist/components/library/filters/SelectFilter.js.map +1 -1
- package/dist/components/library/filters/ToggleFilter.d.ts +7 -5
- package/dist/components/library/filters/ToggleFilter.js +2 -3
- package/dist/components/library/filters/ToggleFilter.js.map +1 -1
- package/dist/components/library/forms/FormField.d.ts +10 -8
- package/dist/components/library/forms/FormField.js +3 -4
- package/dist/components/library/forms/FormField.js.map +1 -1
- package/dist/components/library/forms/FormModal.d.ts +23 -14
- package/dist/components/library/forms/FormModal.js.map +1 -1
- package/dist/components/library/forms/FormRenderer.d.ts +29 -9
- package/dist/components/library/forms/FormRenderer.js +6 -7
- package/dist/components/library/forms/FormRenderer.js.map +1 -1
- package/dist/components/library/forms/FormSection.d.ts +10 -8
- package/dist/components/library/forms/FormSection.js +2 -3
- package/dist/components/library/forms/FormSection.js.map +1 -1
- package/dist/components/library/forms/index.d.ts +5 -0
- package/dist/components/library/forms/useFormState.d.ts +23 -15
- package/dist/components/library/forms/useFormState.js +53 -47
- package/dist/components/library/forms/useFormState.js.map +1 -1
- package/dist/components/library/heroui/Accordion.d.ts +6 -5
- package/dist/components/library/heroui/Accordion.js +7 -8
- package/dist/components/library/heroui/Accordion.js.map +1 -1
- package/dist/components/library/heroui/Breadcrumbs.d.ts +5 -2
- package/dist/components/library/heroui/Breadcrumbs.js +4 -5
- package/dist/components/library/heroui/Breadcrumbs.js.map +1 -1
- package/dist/components/library/heroui/Collapsible.d.ts +19 -30
- package/dist/components/library/heroui/Collapsible.js +13 -13
- package/dist/components/library/heroui/Collapsible.js.map +1 -1
- package/dist/components/library/heroui/DatePicker.d.ts +24 -52
- package/dist/components/library/heroui/DatePicker.js +5 -6
- package/dist/components/library/heroui/DatePicker.js.map +1 -1
- package/dist/components/library/heroui/Dialog.d.ts +18 -32
- package/dist/components/library/heroui/Dialog.js +6 -7
- package/dist/components/library/heroui/Dialog.js.map +1 -1
- package/dist/components/library/heroui/Drawer.d.ts +6 -2
- package/dist/components/library/heroui/Drawer.js +2 -3
- package/dist/components/library/heroui/Drawer.js.map +1 -1
- package/dist/components/library/heroui/Dropdown.d.ts +6 -2
- package/dist/components/library/heroui/Dropdown.js +2 -3
- package/dist/components/library/heroui/Dropdown.js.map +1 -1
- package/dist/components/library/heroui/Field.d.ts +19 -38
- package/dist/components/library/heroui/Field.js +9 -10
- package/dist/components/library/heroui/Field.js.map +1 -1
- package/dist/components/library/heroui/Meter.d.ts +7 -5
- package/dist/components/library/heroui/Meter.js +4 -5
- package/dist/components/library/heroui/Meter.js.map +1 -1
- package/dist/components/library/heroui/Popover.d.ts +23 -38
- package/dist/components/library/heroui/Popover.js +12 -12
- package/dist/components/library/heroui/Popover.js.map +1 -1
- package/dist/components/library/heroui/Select.d.ts +31 -37
- package/dist/components/library/heroui/Select.js +3 -4
- package/dist/components/library/heroui/Select.js.map +1 -1
- package/dist/components/library/layout/PageContainer.d.ts +6 -4
- package/dist/components/library/layout/PageContainer.js +4 -5
- package/dist/components/library/layout/PageContainer.js.map +1 -1
- package/package.json +4 -1
- package/src/components/library/cards/{ActionList.jsx → ActionList.tsx} +13 -9
- package/src/components/library/cards/{ActivityCard.jsx → ActivityCard.tsx} +33 -4
- package/src/components/library/cards/{BaseCard.jsx → BaseCard.tsx} +33 -6
- package/src/components/library/cards/{CalloutCard.jsx → CalloutCard.tsx} +12 -10
- package/src/components/library/cards/{ChartCard.jsx → ChartCard.tsx} +32 -6
- package/src/components/library/cards/{FeedPanel.jsx → FeedPanel.tsx} +13 -2
- package/src/components/library/cards/{ListCard.jsx → ListCard.tsx} +43 -7
- package/src/components/library/cards/{MetricCard.jsx → MetricCard.tsx} +25 -6
- package/src/components/library/cards/{MetricsStrip.jsx → MetricsStrip.tsx} +22 -12
- package/src/components/library/cards/{SectionCard.jsx → SectionCard.tsx} +27 -8
- package/src/components/library/cards/{SemanticMetricCard.jsx → SemanticMetricCard.tsx} +17 -5
- package/src/components/library/cards/{SemanticMetricCardWithLoading.jsx → SemanticMetricCardWithLoading.tsx} +9 -3
- package/src/components/library/cards/{SemanticTableCard.jsx → SemanticTableCard.tsx} +14 -3
- package/src/components/library/cards/{SemanticTableCardWithLoading.jsx → SemanticTableCardWithLoading.tsx} +9 -5
- package/src/components/library/cards/{StatusCard.jsx → StatusCard.tsx} +61 -12
- package/src/components/library/cards/{TableCard.jsx → TableCard.tsx} +51 -12
- package/src/components/library/cards/{WidgetCard.jsx → WidgetCard.tsx} +28 -5
- package/src/components/library/charts/{D3Chart.jsx → D3Chart.tsx} +27 -7
- package/src/components/library/charts/{D3ChartTemplates.jsx → D3ChartTemplates.tsx} +60 -28
- package/src/components/library/charts/{GeoMap.jsx → GeoMap.tsx} +106 -17
- package/src/components/library/filters/{FilterBar.jsx → FilterBar.tsx} +21 -11
- package/src/components/library/filters/{SearchFilter.jsx → SearchFilter.tsx} +8 -2
- package/src/components/library/filters/{SelectFilter.jsx → SelectFilter.tsx} +15 -8
- package/src/components/library/filters/{ToggleFilter.jsx → ToggleFilter.tsx} +7 -6
- package/src/components/library/forms/{FormField.jsx → FormField.tsx} +91 -45
- package/src/components/library/forms/{FormModal.jsx → FormModal.tsx} +21 -20
- package/src/components/library/forms/{FormRenderer.jsx → FormRenderer.tsx} +32 -10
- package/src/components/library/forms/{FormSection.jsx → FormSection.tsx} +13 -7
- package/src/components/library/forms/index.tsx +11 -0
- package/src/components/library/forms/{useFormState.jsx → useFormState.tsx} +43 -23
- package/src/components/library/heroui/{Accordion.jsx → Accordion.tsx} +8 -3
- package/src/components/library/heroui/{Breadcrumbs.jsx → Breadcrumbs.tsx} +5 -2
- package/src/components/library/heroui/Collapsible.tsx +62 -0
- package/src/components/library/heroui/{DatePicker.jsx → DatePicker.tsx} +28 -4
- package/src/components/library/heroui/Dialog.tsx +43 -0
- package/src/components/library/heroui/{Drawer.jsx → Drawer.tsx} +6 -2
- package/src/components/library/heroui/{Dropdown.jsx → Dropdown.tsx} +6 -2
- package/src/components/library/heroui/{Field.jsx → Field.tsx} +23 -6
- package/src/components/library/heroui/Meter.tsx +13 -0
- package/src/components/library/heroui/{Popover.jsx → Popover.tsx} +29 -8
- package/src/components/library/heroui/Select.tsx +73 -0
- package/src/components/library/layout/{PageContainer.jsx → PageContainer.tsx} +6 -3
- package/src/components/library/forms/index.jsx +0 -5
- package/src/components/library/heroui/Collapsible.jsx +0 -42
- package/src/components/library/heroui/Dialog.jsx +0 -37
- package/src/components/library/heroui/Meter.jsx +0 -8
- package/src/components/library/heroui/Select.jsx +0 -37
- /package/src/components/library/filters/{index.jsx → index.ts} +0 -0
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import UIText from "../ui/Text";
|
|
3
3
|
|
|
4
|
+
export interface FeedPanelProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title"> {
|
|
5
|
+
title?: string;
|
|
6
|
+
subtitle?: string;
|
|
7
|
+
actions?: React.ReactNode;
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
width?: number | string;
|
|
10
|
+
className?: string;
|
|
11
|
+
headerClassName?: string;
|
|
12
|
+
bodyClassName?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
4
15
|
export default function FeedPanel({
|
|
5
16
|
title,
|
|
6
17
|
subtitle,
|
|
@@ -11,7 +22,7 @@ export default function FeedPanel({
|
|
|
11
22
|
headerClassName = "",
|
|
12
23
|
bodyClassName = "",
|
|
13
24
|
...rest
|
|
14
|
-
}) {
|
|
25
|
+
}: FeedPanelProps) {
|
|
15
26
|
const widthStyle = width ? (typeof width === "number" ? { width: `${width}px` } : { width }) : undefined;
|
|
16
27
|
|
|
17
28
|
return (
|
|
@@ -24,7 +35,7 @@ export default function FeedPanel({
|
|
|
24
35
|
<div className={`shrink-0 border-b border-slate-100 px-4 py-3 dark:border-slate-800 ${headerClassName}`}>
|
|
25
36
|
<div className="flex items-start justify-between gap-3">
|
|
26
37
|
<div className="min-w-0">
|
|
27
|
-
{title && <UIText as="div" size="sm" weight="
|
|
38
|
+
{title && <UIText as="div" size="sm" weight="medium">{title}</UIText>}
|
|
28
39
|
{subtitle && <UIText as="div" size="xs" muted className="mt-0.5">{subtitle}</UIText>}
|
|
29
40
|
</div>
|
|
30
41
|
{actions && <div className="shrink-0">{actions}</div>}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import BaseCard from "./BaseCard";
|
|
2
|
+
import BaseCard, { BaseCardProps } from "./BaseCard";
|
|
3
3
|
import UIText from "../ui/Text";
|
|
4
4
|
import UIChip from "../ui/Chip";
|
|
5
5
|
|
|
6
|
-
function formatTimestamp(ts) {
|
|
6
|
+
function formatTimestamp(ts: string | Date | undefined): string {
|
|
7
7
|
if (!ts) return "";
|
|
8
8
|
try {
|
|
9
9
|
const d = ts instanceof Date ? ts : new Date(ts);
|
|
@@ -14,7 +14,11 @@ function formatTimestamp(ts) {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
interface AvatarProps {
|
|
18
|
+
item: ListItem;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function Avatar({ item }: AvatarProps) {
|
|
18
22
|
const avatar = item?.avatar;
|
|
19
23
|
const name = item?.title ?? item?.name ?? "Item";
|
|
20
24
|
if (!avatar) return null;
|
|
@@ -41,6 +45,38 @@ function Avatar({ item }) {
|
|
|
41
45
|
);
|
|
42
46
|
}
|
|
43
47
|
|
|
48
|
+
export interface ListItem {
|
|
49
|
+
id?: string | number;
|
|
50
|
+
title?: string;
|
|
51
|
+
name?: string;
|
|
52
|
+
description?: string;
|
|
53
|
+
status?: string;
|
|
54
|
+
timestamp?: string | Date;
|
|
55
|
+
value?: string | number;
|
|
56
|
+
unit?: string;
|
|
57
|
+
avatar?: string | React.ReactNode;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface ListCardProps extends Omit<BaseCardProps, "variant" | "header" | "body"> {
|
|
61
|
+
items?: ListItem[];
|
|
62
|
+
title?: string;
|
|
63
|
+
subtitle?: string;
|
|
64
|
+
showAvatars?: boolean;
|
|
65
|
+
showStatus?: boolean;
|
|
66
|
+
showActions?: boolean;
|
|
67
|
+
showTimestamp?: boolean;
|
|
68
|
+
dense?: boolean;
|
|
69
|
+
divided?: boolean;
|
|
70
|
+
actions?: React.ReactNode;
|
|
71
|
+
itemActions?: (item: ListItem, index: number) => React.ReactNode;
|
|
72
|
+
onItemClick?: (item: ListItem, index: number) => void;
|
|
73
|
+
loading?: boolean;
|
|
74
|
+
error?: string | Error;
|
|
75
|
+
emptyMessage?: string;
|
|
76
|
+
emptyIcon?: React.ReactNode;
|
|
77
|
+
maxBodyHeight?: string | number;
|
|
78
|
+
}
|
|
79
|
+
|
|
44
80
|
export default function ListCard({
|
|
45
81
|
items = [],
|
|
46
82
|
title,
|
|
@@ -60,7 +96,7 @@ export default function ListCard({
|
|
|
60
96
|
emptyIcon,
|
|
61
97
|
maxBodyHeight,
|
|
62
98
|
...cardProps
|
|
63
|
-
}) {
|
|
99
|
+
}: ListCardProps) {
|
|
64
100
|
const header = (
|
|
65
101
|
<div className="flex items-start justify-between gap-3">
|
|
66
102
|
<div className="min-w-0">
|
|
@@ -96,7 +132,9 @@ export default function ListCard({
|
|
|
96
132
|
|
|
97
133
|
const padY = dense ? "py-2" : "py-3";
|
|
98
134
|
|
|
99
|
-
const scrollStyle = maxBodyHeight
|
|
135
|
+
const scrollStyle: React.CSSProperties = maxBodyHeight
|
|
136
|
+
? { maxHeight: typeof maxBodyHeight === "number" ? `${maxBodyHeight}px` : maxBodyHeight, overflowY: "auto" }
|
|
137
|
+
: {};
|
|
100
138
|
|
|
101
139
|
const body =
|
|
102
140
|
loading ? (
|
|
@@ -189,5 +227,3 @@ export default function ListCard({
|
|
|
189
227
|
|
|
190
228
|
return <BaseCard variant="widget" header={header} body={body} isLoading={false} {...cardProps} />;
|
|
191
229
|
}
|
|
192
|
-
|
|
193
|
-
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import BaseCard from "./BaseCard";
|
|
2
|
+
import BaseCard, { BaseCardProps } from "./BaseCard";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
type ChangeType = "positive" | "negative" | "neutral";
|
|
5
|
+
type Color = "default" | "primary" | "success" | "warning" | "danger";
|
|
6
|
+
type Layout = "default" | "compact";
|
|
7
|
+
|
|
8
|
+
const CHANGE_STYLES: Record<ChangeType, string> = {
|
|
5
9
|
positive: "text-emerald-700 dark:text-emerald-400",
|
|
6
10
|
negative: "text-rose-700 dark:text-rose-400",
|
|
7
11
|
neutral: "text-slate-600 dark:text-slate-300"
|
|
8
12
|
};
|
|
9
13
|
|
|
10
|
-
const COLOR_STYLES = {
|
|
14
|
+
const COLOR_STYLES: Record<Color, string> = {
|
|
11
15
|
default: "bg-slate-100 text-slate-800 dark:bg-slate-800 dark:text-slate-100",
|
|
12
16
|
primary: "bg-brand-100 text-brand-800 dark:bg-brand-950/40 dark:text-brand-200",
|
|
13
17
|
success: "bg-emerald-100 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-200",
|
|
@@ -15,6 +19,23 @@ const COLOR_STYLES = {
|
|
|
15
19
|
danger: "bg-rose-100 text-rose-800 dark:bg-rose-950/40 dark:text-rose-200"
|
|
16
20
|
};
|
|
17
21
|
|
|
22
|
+
export interface MetricCardProps extends Omit<BaseCardProps, "variant" | "padding" | "size" | "header" | "body" | "footer"> {
|
|
23
|
+
title: string;
|
|
24
|
+
value: string | number;
|
|
25
|
+
subtitle?: string;
|
|
26
|
+
change?: string | number;
|
|
27
|
+
changeType?: ChangeType;
|
|
28
|
+
icon?: React.ReactNode;
|
|
29
|
+
color?: Color;
|
|
30
|
+
trend?: string;
|
|
31
|
+
trendIcon?: React.ReactNode;
|
|
32
|
+
layout?: Layout;
|
|
33
|
+
footer?: React.ReactNode;
|
|
34
|
+
actions?: React.ReactNode;
|
|
35
|
+
loading?: boolean;
|
|
36
|
+
error?: string | Error;
|
|
37
|
+
}
|
|
38
|
+
|
|
18
39
|
export default function MetricCard({
|
|
19
40
|
title,
|
|
20
41
|
value,
|
|
@@ -31,7 +52,7 @@ export default function MetricCard({
|
|
|
31
52
|
loading = false,
|
|
32
53
|
error,
|
|
33
54
|
...cardProps
|
|
34
|
-
}) {
|
|
55
|
+
}: MetricCardProps) {
|
|
35
56
|
const changeClass = CHANGE_STYLES[changeType] ?? CHANGE_STYLES.neutral;
|
|
36
57
|
const pillClass = COLOR_STYLES[color] ?? COLOR_STYLES.default;
|
|
37
58
|
|
|
@@ -105,5 +126,3 @@ export default function MetricCard({
|
|
|
105
126
|
/>
|
|
106
127
|
);
|
|
107
128
|
}
|
|
108
|
-
|
|
109
|
-
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useState } from "react";
|
|
2
2
|
|
|
3
3
|
const PLACEHOLDER_METRICS = [
|
|
4
4
|
{ label: "Metric A", value: "—", trend: null },
|
|
@@ -6,21 +6,27 @@ const PLACEHOLDER_METRICS = [
|
|
|
6
6
|
{ label: "Metric C", value: "—", trend: null },
|
|
7
7
|
];
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
export interface Metric {
|
|
10
|
+
label: string;
|
|
11
|
+
value: string | number;
|
|
12
|
+
trend?: string | number | null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface MetricsStripProps {
|
|
16
|
+
metrics?: Metric[];
|
|
17
|
+
title?: string;
|
|
18
|
+
collapsible?: boolean;
|
|
19
|
+
collapsed?: boolean;
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
17
23
|
export default function MetricsStrip({
|
|
18
24
|
metrics = [],
|
|
19
25
|
title,
|
|
20
26
|
collapsible = false,
|
|
21
27
|
collapsed: initialCollapsed = false,
|
|
22
28
|
className = "",
|
|
23
|
-
}) {
|
|
29
|
+
}: MetricsStripProps) {
|
|
24
30
|
const [collapsed, setCollapsed] = useState(initialCollapsed);
|
|
25
31
|
const items = metrics.length ? metrics : PLACEHOLDER_METRICS;
|
|
26
32
|
|
|
@@ -70,8 +76,12 @@ export default function MetricsStrip({
|
|
|
70
76
|
);
|
|
71
77
|
}
|
|
72
78
|
|
|
73
|
-
|
|
74
|
-
|
|
79
|
+
interface TrendBadgeProps {
|
|
80
|
+
trend: string | number;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function TrendBadge({ trend }: TrendBadgeProps) {
|
|
84
|
+
const isPositive = String(trend).startsWith?.("+") || (typeof trend === "number" && trend > 0);
|
|
75
85
|
const color = isPositive ? "text-red-500" : "text-emerald-500";
|
|
76
86
|
const label = typeof trend === "number" ? (trend > 0 ? `+${trend}` : trend) : trend;
|
|
77
87
|
return <span className={`text-xs ${color}`}>{label}</span>;
|
|
@@ -1,27 +1,48 @@
|
|
|
1
|
-
import
|
|
2
|
-
import BaseCard from "./BaseCard";
|
|
1
|
+
import BaseCard, { BaseCardProps } from "./BaseCard";
|
|
3
2
|
import UIText from "../ui/Text";
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
type Variant = "default" | "primary" | "secondary" | "accent";
|
|
5
|
+
type Size = "sm" | "md" | "lg" | "xl";
|
|
6
|
+
type Alignment = "left" | "center" | "right";
|
|
7
|
+
|
|
8
|
+
const VARIANT_STYLES: Record<Variant, string> = {
|
|
6
9
|
default: "bg-white dark:bg-slate-900",
|
|
7
10
|
primary: "bg-brand-50 dark:bg-brand-950/30",
|
|
8
11
|
secondary: "bg-slate-50 dark:bg-slate-950/30",
|
|
9
12
|
accent: "bg-emerald-50 dark:bg-emerald-950/25"
|
|
10
13
|
};
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
interface SizeConfig {
|
|
16
|
+
title: string;
|
|
17
|
+
desc: string;
|
|
18
|
+
pad: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const SIZE_STYLES: Record<Size, SizeConfig> = {
|
|
13
22
|
sm: { title: "text-lg", desc: "text-sm", pad: "p-4" },
|
|
14
23
|
md: { title: "text-xl", desc: "text-sm", pad: "p-5" },
|
|
15
24
|
lg: { title: "text-2xl", desc: "text-base", pad: "p-6" },
|
|
16
25
|
xl: { title: "text-3xl", desc: "text-base", pad: "p-7" }
|
|
17
26
|
};
|
|
18
27
|
|
|
19
|
-
const ALIGN_STYLES = {
|
|
28
|
+
const ALIGN_STYLES: Record<Alignment, string> = {
|
|
20
29
|
left: "text-left items-start",
|
|
21
30
|
center: "text-center items-center",
|
|
22
31
|
right: "text-right items-end"
|
|
23
32
|
};
|
|
24
33
|
|
|
34
|
+
export interface SectionCardProps extends Omit<BaseCardProps, "variant" | "padding" | "body"> {
|
|
35
|
+
title?: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
label?: string;
|
|
38
|
+
variant?: Variant;
|
|
39
|
+
showDivider?: boolean;
|
|
40
|
+
alignment?: Alignment;
|
|
41
|
+
size?: Size;
|
|
42
|
+
isDark?: boolean;
|
|
43
|
+
className?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
25
46
|
export default function SectionCard({
|
|
26
47
|
title,
|
|
27
48
|
description,
|
|
@@ -33,7 +54,7 @@ export default function SectionCard({
|
|
|
33
54
|
isDark = false,
|
|
34
55
|
className = "",
|
|
35
56
|
...cardProps
|
|
36
|
-
}) {
|
|
57
|
+
}: SectionCardProps) {
|
|
37
58
|
const s = SIZE_STYLES[size] ?? SIZE_STYLES.md;
|
|
38
59
|
const align = ALIGN_STYLES[alignment] ?? ALIGN_STYLES.left;
|
|
39
60
|
const variantClass = VARIANT_STYLES[variant] ?? VARIANT_STYLES.default;
|
|
@@ -79,5 +100,3 @@ export default function SectionCard({
|
|
|
79
100
|
/>
|
|
80
101
|
);
|
|
81
102
|
}
|
|
82
|
-
|
|
83
|
-
|
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import MetricCard from "./MetricCard";
|
|
2
|
+
import MetricCard, { MetricCardProps } from "./MetricCard";
|
|
3
3
|
import { getSemanticMetric } from "../data/chartDataProvider";
|
|
4
4
|
|
|
5
|
+
export interface SemanticMetricCardProps extends Omit<MetricCardProps, "value"> {
|
|
6
|
+
semanticId: string;
|
|
7
|
+
metricId?: string;
|
|
8
|
+
value?: string | number;
|
|
9
|
+
unit?: string;
|
|
10
|
+
format?: string;
|
|
11
|
+
changeLabel?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
seriesName?: string;
|
|
14
|
+
availableFilters?: string[];
|
|
15
|
+
showFilters?: boolean;
|
|
16
|
+
compact?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
5
19
|
export default function SemanticMetricCard({
|
|
6
20
|
semanticId,
|
|
7
21
|
metricId,
|
|
@@ -21,7 +35,7 @@ export default function SemanticMetricCard({
|
|
|
21
35
|
className,
|
|
22
36
|
loading = false,
|
|
23
37
|
...rest
|
|
24
|
-
}) {
|
|
38
|
+
}: SemanticMetricCardProps) {
|
|
25
39
|
const metric = React.useMemo(() => getSemanticMetric(semanticId, metricId), [semanticId, metricId]);
|
|
26
40
|
|
|
27
41
|
const resolvedTitle = title ?? metric?.title ?? metricId ?? "Metric";
|
|
@@ -32,13 +46,12 @@ export default function SemanticMetricCard({
|
|
|
32
46
|
const resolvedChangeType = metric?.changeType ?? "neutral";
|
|
33
47
|
const resolvedColor = metric?.color ?? "default";
|
|
34
48
|
|
|
35
|
-
// Note: unit/format/etc. are accepted for forward compatibility; basic rendering is handled by MetricCard for now.
|
|
36
49
|
return (
|
|
37
50
|
<MetricCard
|
|
38
51
|
title={resolvedTitle}
|
|
39
52
|
subtitle={resolvedSubtitle}
|
|
40
53
|
value={resolvedValue}
|
|
41
|
-
change={
|
|
54
|
+
change={changeLabel ? `${changeLabel} ${resolvedChange ?? ""}`.trim() : resolvedChange}
|
|
42
55
|
changeType={resolvedChangeType}
|
|
43
56
|
color={resolvedColor}
|
|
44
57
|
trend={resolvedTrend}
|
|
@@ -49,4 +62,3 @@ export default function SemanticMetricCard({
|
|
|
49
62
|
/>
|
|
50
63
|
);
|
|
51
64
|
}
|
|
52
|
-
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import SemanticMetricCard from "./SemanticMetricCard";
|
|
2
|
+
import SemanticMetricCard, { SemanticMetricCardProps } from "./SemanticMetricCard";
|
|
3
|
+
|
|
4
|
+
export interface SemanticMetricCardWithLoadingProps extends SemanticMetricCardProps {
|
|
5
|
+
simulateInitialLoad?: boolean;
|
|
6
|
+
minInitialDelayMs?: number;
|
|
7
|
+
maxInitialDelayMs?: number;
|
|
8
|
+
loading?: boolean;
|
|
9
|
+
}
|
|
3
10
|
|
|
4
11
|
export default function SemanticMetricCardWithLoading({
|
|
5
12
|
simulateInitialLoad = true,
|
|
@@ -7,7 +14,7 @@ export default function SemanticMetricCardWithLoading({
|
|
|
7
14
|
maxInitialDelayMs = 900,
|
|
8
15
|
loading: loadingProp,
|
|
9
16
|
...props
|
|
10
|
-
}) {
|
|
17
|
+
}: SemanticMetricCardWithLoadingProps) {
|
|
11
18
|
const [loading, setLoading] = React.useState(Boolean(simulateInitialLoad));
|
|
12
19
|
|
|
13
20
|
React.useEffect(() => {
|
|
@@ -20,4 +27,3 @@ export default function SemanticMetricCardWithLoading({
|
|
|
20
27
|
|
|
21
28
|
return <SemanticMetricCard loading={loadingProp ?? loading} {...props} />;
|
|
22
29
|
}
|
|
23
|
-
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import TableCard from "./TableCard";
|
|
2
|
+
import TableCard, { TableCardProps, TableColumn } from "./TableCard";
|
|
3
3
|
import { getSemanticDataset } from "../data/chartDataProvider";
|
|
4
4
|
|
|
5
|
+
export interface SemanticTableCardProps extends Omit<TableCardProps, "data" | "columns"> {
|
|
6
|
+
semanticId: string;
|
|
7
|
+
dataOverride?: unknown[];
|
|
8
|
+
columnsOverride?: TableColumn[];
|
|
9
|
+
compact?: boolean;
|
|
10
|
+
striped?: boolean;
|
|
11
|
+
isDark?: boolean;
|
|
12
|
+
simulateInitialLoad?: boolean;
|
|
13
|
+
minInitialDelayMs?: number;
|
|
14
|
+
maxInitialDelayMs?: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
5
17
|
export default function SemanticTableCard({
|
|
6
18
|
semanticId,
|
|
7
19
|
dataOverride,
|
|
@@ -19,7 +31,7 @@ export default function SemanticTableCard({
|
|
|
19
31
|
minInitialDelayMs,
|
|
20
32
|
maxInitialDelayMs,
|
|
21
33
|
...rest
|
|
22
|
-
}) {
|
|
34
|
+
}: SemanticTableCardProps) {
|
|
23
35
|
const ds = React.useMemo(() => getSemanticDataset(semanticId), [semanticId]);
|
|
24
36
|
const table = ds?.table;
|
|
25
37
|
|
|
@@ -45,4 +57,3 @@ export default function SemanticTableCard({
|
|
|
45
57
|
/>
|
|
46
58
|
);
|
|
47
59
|
}
|
|
48
|
-
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import SemanticTableCard, { SemanticTableCardProps } from "./SemanticTableCard";
|
|
2
|
+
|
|
3
|
+
export interface SemanticTableCardWithLoadingProps extends SemanticTableCardProps {
|
|
4
|
+
simulateInitialLoad?: boolean;
|
|
5
|
+
minInitialDelayMs?: number;
|
|
6
|
+
maxInitialDelayMs?: number;
|
|
7
|
+
loading?: boolean;
|
|
8
|
+
}
|
|
3
9
|
|
|
4
10
|
export default function SemanticTableCardWithLoading({
|
|
5
11
|
simulateInitialLoad = true,
|
|
@@ -7,8 +13,7 @@ export default function SemanticTableCardWithLoading({
|
|
|
7
13
|
maxInitialDelayMs = 900,
|
|
8
14
|
loading: loadingProp,
|
|
9
15
|
...props
|
|
10
|
-
}) {
|
|
11
|
-
// Leverage TableCard's simulateInitialLoad by default; also allow explicit loading override.
|
|
16
|
+
}: SemanticTableCardWithLoadingProps) {
|
|
12
17
|
return (
|
|
13
18
|
<SemanticTableCard
|
|
14
19
|
{...props}
|
|
@@ -19,4 +24,3 @@ export default function SemanticTableCardWithLoading({
|
|
|
19
24
|
/>
|
|
20
25
|
);
|
|
21
26
|
}
|
|
22
|
-
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import BaseCard from "./BaseCard";
|
|
2
|
+
import BaseCard, { BaseCardProps } from "./BaseCard";
|
|
3
3
|
import UIText from "../ui/Text";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
type Status = "operational" | "degraded" | "outage" | "maintenance";
|
|
6
|
+
type Layout = "list" | "grid" | "timeline";
|
|
7
|
+
|
|
8
|
+
interface StatusMeta {
|
|
9
|
+
label: string;
|
|
10
|
+
dot: string;
|
|
11
|
+
chip: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const STATUS_META: Record<Status, StatusMeta> = {
|
|
6
15
|
operational: {
|
|
7
16
|
label: "Operational",
|
|
8
17
|
dot: "bg-emerald-500",
|
|
@@ -25,15 +34,15 @@ const STATUS_META = {
|
|
|
25
34
|
}
|
|
26
35
|
};
|
|
27
36
|
|
|
28
|
-
function normalizeStatus(status) {
|
|
37
|
+
function normalizeStatus(status: string | undefined): Status {
|
|
29
38
|
const s = String(status ?? "operational").toLowerCase();
|
|
30
39
|
if (s === "ok" || s === "healthy" || s === "up") return "operational";
|
|
31
40
|
if (s === "warn" || s === "warning" || s === "partial") return "degraded";
|
|
32
41
|
if (s === "down" || s === "critical") return "outage";
|
|
33
|
-
return STATUS_META[s] ? s : "operational";
|
|
42
|
+
return STATUS_META[s as Status] ? (s as Status) : "operational";
|
|
34
43
|
}
|
|
35
44
|
|
|
36
|
-
function formatTimestamp(ts) {
|
|
45
|
+
function formatTimestamp(ts: string | Date | undefined): string {
|
|
37
46
|
if (!ts) return "";
|
|
38
47
|
try {
|
|
39
48
|
const d = ts instanceof Date ? ts : new Date(ts);
|
|
@@ -44,7 +53,11 @@ function formatTimestamp(ts) {
|
|
|
44
53
|
}
|
|
45
54
|
}
|
|
46
55
|
|
|
47
|
-
|
|
56
|
+
interface StatusChipProps {
|
|
57
|
+
status: string | undefined;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function StatusChip({ status }: StatusChipProps) {
|
|
48
61
|
const key = normalizeStatus(status);
|
|
49
62
|
const meta = STATUS_META[key];
|
|
50
63
|
return (
|
|
@@ -55,7 +68,23 @@ function StatusChip({ status }) {
|
|
|
55
68
|
);
|
|
56
69
|
}
|
|
57
70
|
|
|
58
|
-
|
|
71
|
+
export interface StatusItem {
|
|
72
|
+
id?: string | number;
|
|
73
|
+
title?: string;
|
|
74
|
+
name?: string;
|
|
75
|
+
description?: string;
|
|
76
|
+
status?: string;
|
|
77
|
+
timestamp?: string | Date;
|
|
78
|
+
value?: string | number;
|
|
79
|
+
unit?: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
interface ItemRowProps {
|
|
83
|
+
item: StatusItem;
|
|
84
|
+
showTimestamp: boolean;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function ItemRow({ item, showTimestamp }: ItemRowProps) {
|
|
59
88
|
const name = item?.title ?? item?.name ?? "Item";
|
|
60
89
|
const desc = item?.description;
|
|
61
90
|
const value = item?.value;
|
|
@@ -89,7 +118,12 @@ function ItemRow({ item, showTimestamp }) {
|
|
|
89
118
|
);
|
|
90
119
|
}
|
|
91
120
|
|
|
92
|
-
|
|
121
|
+
interface TimelineProps {
|
|
122
|
+
items: StatusItem[];
|
|
123
|
+
showTimestamp: boolean;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function Timeline({ items, showTimestamp }: TimelineProps) {
|
|
93
127
|
return (
|
|
94
128
|
<div className="relative mt-4">
|
|
95
129
|
<div className="absolute left-3 top-0 h-full w-px bg-slate-200 dark:bg-slate-800" aria-hidden="true" />
|
|
@@ -110,6 +144,21 @@ function Timeline({ items, showTimestamp }) {
|
|
|
110
144
|
);
|
|
111
145
|
}
|
|
112
146
|
|
|
147
|
+
export interface StatusCardProps extends Omit<BaseCardProps, "variant" | "header" | "body"> {
|
|
148
|
+
title?: string;
|
|
149
|
+
subtitle?: string;
|
|
150
|
+
status?: string;
|
|
151
|
+
items?: StatusItem[];
|
|
152
|
+
layout?: Layout;
|
|
153
|
+
showProgress?: boolean;
|
|
154
|
+
showTimestamp?: boolean;
|
|
155
|
+
actions?: React.ReactNode;
|
|
156
|
+
loading?: boolean;
|
|
157
|
+
error?: string | Error;
|
|
158
|
+
emptyMessage?: string;
|
|
159
|
+
maxBodyHeight?: string | number;
|
|
160
|
+
}
|
|
161
|
+
|
|
113
162
|
export default function StatusCard({
|
|
114
163
|
title,
|
|
115
164
|
subtitle,
|
|
@@ -124,7 +173,7 @@ export default function StatusCard({
|
|
|
124
173
|
emptyMessage = "No status items.",
|
|
125
174
|
maxBodyHeight,
|
|
126
175
|
...cardProps
|
|
127
|
-
}) {
|
|
176
|
+
}: StatusCardProps) {
|
|
128
177
|
const overall = normalizeStatus(status);
|
|
129
178
|
const header = (
|
|
130
179
|
<div className="flex items-start justify-between gap-3">
|
|
@@ -166,7 +215,9 @@ export default function StatusCard({
|
|
|
166
215
|
const okCount = items.filter((it) => normalizeStatus(it?.status) === "operational").length;
|
|
167
216
|
const percentOk = total > 0 ? Math.round((okCount / total) * 100) : 100;
|
|
168
217
|
|
|
169
|
-
const scrollStyle = maxBodyHeight
|
|
218
|
+
const scrollStyle: React.CSSProperties = maxBodyHeight
|
|
219
|
+
? { maxHeight: typeof maxBodyHeight === "number" ? `${maxBodyHeight}px` : maxBodyHeight, overflowY: "auto" }
|
|
220
|
+
: {};
|
|
170
221
|
|
|
171
222
|
const itemsContent = loading ? (
|
|
172
223
|
<div className="space-y-3">
|
|
@@ -216,5 +267,3 @@ export default function StatusCard({
|
|
|
216
267
|
|
|
217
268
|
return <BaseCard variant="status" header={header} body={body} {...cardProps} />;
|
|
218
269
|
}
|
|
219
|
-
|
|
220
|
-
|