@schandlergarcia/sf-web-components 1.9.38 → 1.9.39
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 +4 -1
- package/scripts/postinstall.mjs +36 -17
- package/src/components/library/cards/ActionList.jsx +38 -0
- package/src/components/library/cards/ActivityCard.jsx +56 -0
- package/src/components/library/cards/BaseCard.jsx +109 -0
- package/src/components/library/cards/CalloutCard.jsx +37 -0
- package/src/components/library/cards/ChartCard.jsx +105 -0
- package/src/components/library/cards/FeedPanel.jsx +39 -0
- package/src/components/library/cards/ListCard.jsx +193 -0
- package/src/components/library/cards/MetricCard.jsx +109 -0
- package/src/components/library/cards/MetricsStrip.jsx +78 -0
- package/src/components/library/cards/SectionCard.jsx +83 -0
- package/src/components/library/cards/SemanticMetricCard.jsx +52 -0
- package/src/components/library/cards/SemanticMetricCardWithLoading.jsx +23 -0
- package/src/components/library/cards/SemanticTableCard.jsx +48 -0
- package/src/components/library/cards/SemanticTableCardWithLoading.jsx +22 -0
- package/src/components/library/cards/StatusCard.jsx +220 -0
- package/src/components/library/cards/TableCard.jsx +337 -0
- package/src/components/library/cards/WidgetCard.jsx +90 -0
- package/src/components/library/charts/D3Chart.jsx +109 -0
- package/src/components/library/charts/D3ChartTemplates.jsx +126 -0
- package/src/components/library/charts/GeoMap.jsx +293 -0
- package/src/components/library/chat/ChatBar.jsx +256 -0
- package/src/components/library/chat/ChatInput.jsx +89 -0
- package/src/components/library/chat/ChatMessage.jsx +178 -0
- package/src/components/library/chat/ChatMessageList.jsx +73 -0
- package/src/components/library/chat/ChatPanel.jsx +97 -0
- package/src/components/library/chat/ChatSuggestions.jsx +28 -0
- package/src/components/library/chat/ChatToolCall.jsx +100 -0
- package/src/components/library/chat/ChatTypingIndicator.jsx +23 -0
- package/src/components/library/chat/ChatWelcome.jsx +43 -0
- package/src/components/library/chat/index.jsx +10 -0
- package/src/components/library/chat/useChatState.jsx +130 -0
- package/src/components/library/data/DataModeProvider.jsx +67 -0
- package/src/components/library/data/DataModeToggle.jsx +36 -0
- package/src/components/library/data/chartDataProvider.jsx +61 -0
- package/src/components/library/data/filterUtils.jsx +141 -0
- package/src/components/library/data/useDataSource.jsx +33 -0
- package/src/components/library/data/usePageFilters.jsx +99 -0
- package/src/components/library/filters/FilterBar.jsx +95 -0
- package/src/components/library/filters/SearchFilter.jsx +36 -0
- package/src/components/library/filters/SelectFilter.jsx +55 -0
- package/src/components/library/filters/ToggleFilter.jsx +52 -0
- package/src/components/library/filters/index.jsx +4 -0
- package/src/components/library/forms/FormField.jsx +291 -0
- package/src/components/library/forms/FormModal.jsx +201 -0
- package/src/components/library/forms/FormRenderer.jsx +46 -0
- package/src/components/library/forms/FormSection.jsx +69 -0
- package/src/components/library/forms/index.jsx +5 -0
- package/src/components/library/forms/useFormState.jsx +165 -0
- package/src/components/library/heroui/Accordion.jsx +26 -0
- package/src/components/library/heroui/Alert.jsx +8 -0
- package/src/components/library/heroui/Badge.jsx +8 -0
- package/src/components/library/heroui/Breadcrumbs.jsx +22 -0
- package/src/components/library/heroui/Button.jsx +58 -0
- package/src/components/library/heroui/Card.jsx +8 -0
- package/src/components/library/heroui/Collapsible.jsx +42 -0
- package/src/components/library/heroui/DatePicker.jsx +34 -0
- package/src/components/library/heroui/Dialog.jsx +37 -0
- package/src/components/library/heroui/Drawer.jsx +32 -0
- package/src/components/library/heroui/Dropdown.jsx +28 -0
- package/src/components/library/heroui/Field.jsx +51 -0
- package/src/components/library/heroui/Input.jsx +6 -0
- package/src/components/library/heroui/Kbd.jsx +8 -0
- package/src/components/library/heroui/Meter.jsx +8 -0
- package/src/components/library/heroui/Modal.jsx +32 -0
- package/src/components/library/heroui/Pagination.jsx +8 -0
- package/src/components/library/heroui/Popover.jsx +64 -0
- package/src/components/library/heroui/ProgressBar.jsx +8 -0
- package/src/components/library/heroui/ProgressCircle.jsx +8 -0
- package/src/components/library/heroui/ScrollShadow.jsx +8 -0
- package/src/components/library/heroui/Select.jsx +37 -0
- package/src/components/library/heroui/Separator.jsx +8 -0
- package/src/components/library/heroui/Skeleton.jsx +8 -0
- package/src/components/library/heroui/Tabs.jsx +26 -0
- package/src/components/library/heroui/Toast.jsx +25 -0
- package/src/components/library/heroui/Toggle.jsx +14 -0
- package/src/components/library/heroui/Tooltip.jsx +21 -0
- package/src/components/library/index.jsx +146 -0
- package/src/components/library/layout/PageContainer.jsx +11 -0
- package/src/components/library/skeletons/CardSkeleton.jsx +30 -0
- package/src/components/library/theme/AppThemeProvider.jsx +67 -0
- package/src/components/library/theme/tokens.jsx +72 -0
- package/src/components/library/ui/Alert.jsx +80 -0
- package/src/components/library/ui/Avatar.jsx +44 -0
- package/src/components/library/ui/BreadcrumbExtras.tsx +120 -0
- package/src/components/library/ui/Button.jsx +61 -0
- package/src/components/library/ui/Card.jsx +117 -0
- package/src/components/library/ui/Checkbox.jsx +17 -0
- package/src/components/library/ui/Chip.jsx +38 -0
- package/src/components/library/ui/Collapsible.tsx +31 -0
- package/src/components/library/ui/Container.jsx +56 -0
- package/src/components/library/ui/DatePicker.tsx +34 -0
- package/src/components/library/ui/Dialog.tsx +141 -0
- package/src/components/library/ui/EmptyState.jsx +46 -0
- package/src/components/library/ui/Field.tsx +82 -0
- package/src/components/library/ui/FieldGroup.jsx +17 -0
- package/src/components/library/ui/Input.jsx +21 -0
- package/src/components/library/ui/Label.jsx +22 -0
- package/src/components/library/ui/PaginationExtras.tsx +142 -0
- package/src/components/library/ui/Popover.tsx +39 -0
- package/src/components/library/ui/Select.tsx +113 -0
- package/src/components/library/ui/Spinner.d.ts +10 -0
- package/src/components/library/ui/Spinner.jsx +64 -0
- package/src/components/library/ui/Text.jsx +46 -0
- package/src/components/library/ui/Toggle.jsx +42 -0
- package/src/components/workspace/ComponentRegistry.jsx +297 -0
- package/src/lib/index.ts +1 -0
- package/src/lib/utils.ts +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schandlergarcia/sf-web-components",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.39",
|
|
4
4
|
"description": "Reusable Salesforce web components library with Tailwind CSS v4 and shadcn/ui",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,6 +28,9 @@
|
|
|
28
28
|
"dist",
|
|
29
29
|
"scripts",
|
|
30
30
|
"data",
|
|
31
|
+
"src/components",
|
|
32
|
+
"src/lib",
|
|
33
|
+
"src/types",
|
|
31
34
|
"README.md",
|
|
32
35
|
".a4drules"
|
|
33
36
|
],
|
package/scripts/postinstall.mjs
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Post-install script for @schandlergarcia/sf-web-components
|
|
5
5
|
*
|
|
6
6
|
* Automatically copies to the consuming project:
|
|
7
|
+
* - Component library source (src/components/library/)
|
|
7
8
|
* - Sample data (src/data/)
|
|
8
9
|
* - Skills (.a4drules/)
|
|
9
10
|
* - Scripts (scripts/)
|
|
@@ -65,7 +66,39 @@ if (!WEBAPP_DIR) {
|
|
|
65
66
|
|
|
66
67
|
let copiedCount = 0;
|
|
67
68
|
|
|
68
|
-
//
|
|
69
|
+
// Helper: Copy directory recursively
|
|
70
|
+
function copyRecursive(src, dest) {
|
|
71
|
+
if (fs.statSync(src).isDirectory()) {
|
|
72
|
+
if (!fs.existsSync(dest)) {
|
|
73
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
74
|
+
}
|
|
75
|
+
fs.readdirSync(src).forEach(file => {
|
|
76
|
+
copyRecursive(path.join(src, file), path.join(dest, file));
|
|
77
|
+
});
|
|
78
|
+
} else {
|
|
79
|
+
fs.copyFileSync(src, dest);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// 1. Copy component library source
|
|
84
|
+
try {
|
|
85
|
+
const targetComponentsDir = path.join(WEBAPP_DIR, 'src/components');
|
|
86
|
+
const sourceLibraryDir = path.join(PACKAGE_ROOT, 'src/components/library');
|
|
87
|
+
|
|
88
|
+
if (fs.existsSync(sourceLibraryDir)) {
|
|
89
|
+
const targetLibraryDir = path.join(targetComponentsDir, 'library');
|
|
90
|
+
|
|
91
|
+
if (!fs.existsSync(targetLibraryDir)) {
|
|
92
|
+
copyRecursive(sourceLibraryDir, targetLibraryDir);
|
|
93
|
+
console.log(' ✅ Component library → src/components/library/');
|
|
94
|
+
copiedCount++;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
} catch (err) {
|
|
98
|
+
console.log(' ⚠️ Could not copy component library:', err.message);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// 2. Copy sample data
|
|
69
102
|
try {
|
|
70
103
|
const dataDir = path.join(WEBAPP_DIR, 'src/data');
|
|
71
104
|
if (!fs.existsSync(dataDir)) {
|
|
@@ -84,26 +117,12 @@ try {
|
|
|
84
117
|
console.log(' ⚠️ Could not copy sample data:', err.message);
|
|
85
118
|
}
|
|
86
119
|
|
|
87
|
-
//
|
|
120
|
+
// 3. Copy .a4drules (skills)
|
|
88
121
|
try {
|
|
89
122
|
const targetRulesDir = path.join(WEBAPP_DIR, '.a4drules');
|
|
90
123
|
const sourceRulesDir = path.join(PACKAGE_ROOT, '.a4drules');
|
|
91
124
|
|
|
92
125
|
if (!fs.existsSync(targetRulesDir) && fs.existsSync(sourceRulesDir)) {
|
|
93
|
-
// Copy entire .a4drules directory recursively
|
|
94
|
-
function copyRecursive(src, dest) {
|
|
95
|
-
if (fs.statSync(src).isDirectory()) {
|
|
96
|
-
if (!fs.existsSync(dest)) {
|
|
97
|
-
fs.mkdirSync(dest, { recursive: true });
|
|
98
|
-
}
|
|
99
|
-
fs.readdirSync(src).forEach(file => {
|
|
100
|
-
copyRecursive(path.join(src, file), path.join(dest, file));
|
|
101
|
-
});
|
|
102
|
-
} else {
|
|
103
|
-
fs.copyFileSync(src, dest);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
126
|
copyRecursive(sourceRulesDir, targetRulesDir);
|
|
108
127
|
console.log(' ✅ Skills → .a4drules/');
|
|
109
128
|
copiedCount++;
|
|
@@ -112,7 +131,7 @@ try {
|
|
|
112
131
|
console.log(' ⚠️ Could not copy skills:', err.message);
|
|
113
132
|
}
|
|
114
133
|
|
|
115
|
-
//
|
|
134
|
+
// 4. Copy scripts
|
|
116
135
|
try {
|
|
117
136
|
const scriptsDir = path.join(WEBAPP_DIR, 'scripts');
|
|
118
137
|
if (!fs.existsSync(scriptsDir)) {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import UIButton from "../ui/Button";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Row of action buttons — typically used at the bottom of a dashboard section.
|
|
6
|
+
*
|
|
7
|
+
* @param {{ label: string, [key]: any }[] | string[]} actions
|
|
8
|
+
* @param {string} title
|
|
9
|
+
* @param {Function} onAction Called with the action object/string when clicked
|
|
10
|
+
*/
|
|
11
|
+
export default function ActionList({
|
|
12
|
+
actions = [],
|
|
13
|
+
title,
|
|
14
|
+
onAction,
|
|
15
|
+
className = "",
|
|
16
|
+
}) {
|
|
17
|
+
return (
|
|
18
|
+
<div className={`rounded-2xl border border-slate-200 bg-white p-4 dark:border-slate-800 dark:bg-slate-900 ${className}`}>
|
|
19
|
+
{title && (
|
|
20
|
+
<div className="mb-3 text-sm font-medium text-slate-900 dark:text-slate-50">
|
|
21
|
+
{title}
|
|
22
|
+
</div>
|
|
23
|
+
)}
|
|
24
|
+
<div className="flex flex-wrap gap-2">
|
|
25
|
+
{actions.map((action, i) => (
|
|
26
|
+
<UIButton
|
|
27
|
+
key={i}
|
|
28
|
+
size="sm"
|
|
29
|
+
variant={i === 0 ? "primary" : "outline"}
|
|
30
|
+
onClick={() => onAction?.(action)}
|
|
31
|
+
>
|
|
32
|
+
{typeof action === "string" ? action : action.label}
|
|
33
|
+
</UIButton>
|
|
34
|
+
))}
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { motion, AnimatePresence } from "framer-motion";
|
|
3
|
+
import { ArrowPathIcon, CheckCircleIcon, ExclamationCircleIcon, ClockIcon } from "@heroicons/react/24/outline";
|
|
4
|
+
import UIText from "../ui/Text";
|
|
5
|
+
|
|
6
|
+
const STATUS_ICON = {
|
|
7
|
+
working: { Icon: ArrowPathIcon, color: "text-indigo-500", spin: true },
|
|
8
|
+
pending: { Icon: ClockIcon, color: "text-slate-400", spin: false },
|
|
9
|
+
complete: { Icon: CheckCircleIcon, color: "text-emerald-500", spin: false },
|
|
10
|
+
error: { Icon: ExclamationCircleIcon, color: "text-red-500", spin: false },
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
function ActionItem({ action }) {
|
|
14
|
+
const s = STATUS_ICON[action.status] ?? STATUS_ICON.pending;
|
|
15
|
+
return (
|
|
16
|
+
<motion.div
|
|
17
|
+
initial={{ y: 12, opacity: 0 }}
|
|
18
|
+
animate={{ y: 0, opacity: 1 }}
|
|
19
|
+
exit={{ y: -12, opacity: 0 }}
|
|
20
|
+
className="rounded-lg border border-slate-100 bg-slate-50 p-3 dark:border-slate-800 dark:bg-slate-950/40"
|
|
21
|
+
>
|
|
22
|
+
<div className="flex items-start gap-2">
|
|
23
|
+
<s.Icon className={`mt-0.5 h-4 w-4 shrink-0 ${s.color} ${s.spin ? "animate-spin" : ""}`} />
|
|
24
|
+
<div className="min-w-0">
|
|
25
|
+
<div className="text-xs font-medium text-slate-700 dark:text-slate-200">{action.title ?? action.action}</div>
|
|
26
|
+
{(action.subtitle ?? action.traveler ?? action.timestamp ?? action.startedAt) && (
|
|
27
|
+
<div className="mt-0.5 text-[10px] text-slate-400">
|
|
28
|
+
{[action.subtitle, action.traveler, action.timestamp ?? action.startedAt].filter(Boolean).join(" · ")}
|
|
29
|
+
</div>
|
|
30
|
+
)}
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</motion.div>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default function ActivityCard({ title = "Activity", actions = [], className = "" }) {
|
|
38
|
+
if (actions.length === 0) return null;
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div className={className}>
|
|
42
|
+
{title && (
|
|
43
|
+
<UIText as="div" size="xs" weight="semibold" muted className="mb-2 uppercase tracking-wider">
|
|
44
|
+
{title}
|
|
45
|
+
</UIText>
|
|
46
|
+
)}
|
|
47
|
+
<div className="space-y-2">
|
|
48
|
+
<AnimatePresence>
|
|
49
|
+
{actions.map(a => (
|
|
50
|
+
<ActionItem key={a.id} action={a} />
|
|
51
|
+
))}
|
|
52
|
+
</AnimatePresence>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
const VARIANT_CLASSES = {
|
|
4
|
+
default: "",
|
|
5
|
+
metric: "",
|
|
6
|
+
chart: "",
|
|
7
|
+
table: "",
|
|
8
|
+
widget: "",
|
|
9
|
+
status: ""
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const SIZE_CLASSES = {
|
|
13
|
+
xs: "",
|
|
14
|
+
sm: "min-h-[80px]",
|
|
15
|
+
md: "min-h-[120px]",
|
|
16
|
+
lg: "min-h-[160px]",
|
|
17
|
+
xl: "min-h-[220px]",
|
|
18
|
+
full: ""
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const PADDING_CLASSES = {
|
|
22
|
+
none: "p-0",
|
|
23
|
+
xs: "p-2",
|
|
24
|
+
sm: "p-3",
|
|
25
|
+
default: "p-4",
|
|
26
|
+
lg: "p-6",
|
|
27
|
+
xl: "p-8"
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default function BaseCard({
|
|
31
|
+
header,
|
|
32
|
+
body,
|
|
33
|
+
footer,
|
|
34
|
+
children,
|
|
35
|
+
variant = "default",
|
|
36
|
+
size = "md",
|
|
37
|
+
padding = "default",
|
|
38
|
+
shadow = true,
|
|
39
|
+
radius = "2xl",
|
|
40
|
+
border = true,
|
|
41
|
+
isHoverable = false,
|
|
42
|
+
isPressable = false,
|
|
43
|
+
isLoading = false,
|
|
44
|
+
isDisabled = false,
|
|
45
|
+
isSelected = false,
|
|
46
|
+
className = "",
|
|
47
|
+
headerClassName = "",
|
|
48
|
+
bodyClassName = "",
|
|
49
|
+
footerClassName = "",
|
|
50
|
+
onPress,
|
|
51
|
+
onHover,
|
|
52
|
+
...rest
|
|
53
|
+
}) {
|
|
54
|
+
const Comp = isPressable ? "button" : "div";
|
|
55
|
+
|
|
56
|
+
const radiusClass = radius ? `rounded-${radius}` : "rounded-2xl";
|
|
57
|
+
const paddingClass = PADDING_CLASSES[padding] ?? PADDING_CLASSES.default;
|
|
58
|
+
const sizeClass = SIZE_CLASSES[size] ?? SIZE_CLASSES.md;
|
|
59
|
+
const variantClass = VARIANT_CLASSES[variant] ?? VARIANT_CLASSES.default;
|
|
60
|
+
|
|
61
|
+
const interactive = isHoverable || isPressable;
|
|
62
|
+
const disabled = isDisabled || (isPressable && !onPress);
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<Comp
|
|
66
|
+
type={isPressable ? "button" : undefined}
|
|
67
|
+
onClick={isPressable ? onPress : undefined}
|
|
68
|
+
onMouseEnter={onHover}
|
|
69
|
+
disabled={isPressable ? disabled : undefined}
|
|
70
|
+
className={[
|
|
71
|
+
"w-full text-left",
|
|
72
|
+
radiusClass,
|
|
73
|
+
border ? "border border-slate-200 dark:border-slate-800" : "border border-transparent",
|
|
74
|
+
"bg-white dark:bg-slate-900",
|
|
75
|
+
shadow ? "shadow-sm" : "",
|
|
76
|
+
sizeClass,
|
|
77
|
+
variantClass,
|
|
78
|
+
interactive ? "transition hover:-translate-y-[1px] hover:shadow-md" : "",
|
|
79
|
+
isSelected ? "ring-2 ring-brand-500" : "",
|
|
80
|
+
disabled ? "opacity-60" : "",
|
|
81
|
+
className
|
|
82
|
+
]
|
|
83
|
+
.filter(Boolean)
|
|
84
|
+
.join(" ")}
|
|
85
|
+
{...rest}
|
|
86
|
+
>
|
|
87
|
+
<div className={paddingClass}>
|
|
88
|
+
{header != null ? <div className={headerClassName}>{header}</div> : null}
|
|
89
|
+
|
|
90
|
+
{isLoading ? (
|
|
91
|
+
<div className={["mt-3 space-y-3", bodyClassName].filter(Boolean).join(" ")}>
|
|
92
|
+
<div className="h-4 w-1/3 animate-pulse rounded bg-slate-200 dark:bg-slate-800" />
|
|
93
|
+
<div className="h-4 w-2/3 animate-pulse rounded bg-slate-200 dark:bg-slate-800" />
|
|
94
|
+
<div className="h-4 w-1/2 animate-pulse rounded bg-slate-200 dark:bg-slate-800" />
|
|
95
|
+
</div>
|
|
96
|
+
) : (
|
|
97
|
+
<>
|
|
98
|
+
{body != null ? <div className={bodyClassName}>{body}</div> : null}
|
|
99
|
+
{children}
|
|
100
|
+
</>
|
|
101
|
+
)}
|
|
102
|
+
|
|
103
|
+
{footer != null ? <div className={footerClassName}>{footer}</div> : null}
|
|
104
|
+
</div>
|
|
105
|
+
</Comp>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
const TONE_CLASSES = {
|
|
4
|
+
neutral: "border-slate-200 bg-slate-50 text-slate-700 dark:border-slate-800 dark:bg-slate-950/30 dark:text-slate-200",
|
|
5
|
+
success: "border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-900/40 dark:bg-emerald-950/20 dark:text-emerald-200",
|
|
6
|
+
warning: "border-amber-200 bg-amber-50 text-amber-800 dark:border-amber-900/40 dark:bg-amber-950/20 dark:text-amber-200",
|
|
7
|
+
danger: "border-rose-200 bg-rose-50 text-rose-800 dark:border-rose-900/40 dark:bg-rose-950/20 dark:text-rose-200",
|
|
8
|
+
info: "border-blue-200 bg-blue-50 text-blue-800 dark:border-blue-900/40 dark:bg-blue-950/20 dark:text-blue-200",
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Highlighted callout box for important inline messages.
|
|
13
|
+
*
|
|
14
|
+
* @param {string} title
|
|
15
|
+
* @param {string|ReactNode} message
|
|
16
|
+
* @param {"neutral"|"success"|"warning"|"danger"|"info"} tone
|
|
17
|
+
* @param {ReactNode} icon Optional leading icon
|
|
18
|
+
*/
|
|
19
|
+
export default function CalloutCard({
|
|
20
|
+
title,
|
|
21
|
+
message,
|
|
22
|
+
tone = "neutral",
|
|
23
|
+
icon,
|
|
24
|
+
className = "",
|
|
25
|
+
}) {
|
|
26
|
+
return (
|
|
27
|
+
<div className={`rounded-xl border p-4 ${TONE_CLASSES[tone] ?? TONE_CLASSES.neutral} ${className}`}>
|
|
28
|
+
<div className="flex gap-3">
|
|
29
|
+
{icon && <div className="mt-0.5 shrink-0">{icon}</div>}
|
|
30
|
+
<div>
|
|
31
|
+
{title && <div className="mb-1 text-sm font-semibold">{title}</div>}
|
|
32
|
+
<div className="text-sm">{message}</div>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import BaseCard from "./BaseCard";
|
|
3
|
+
import UIText from "../ui/Text";
|
|
4
|
+
import UIChip from "../ui/Chip";
|
|
5
|
+
|
|
6
|
+
export default function ChartCard({
|
|
7
|
+
chart,
|
|
8
|
+
chartType,
|
|
9
|
+
title,
|
|
10
|
+
subtitle,
|
|
11
|
+
filters,
|
|
12
|
+
timeRange,
|
|
13
|
+
actions,
|
|
14
|
+
legend,
|
|
15
|
+
height = 280,
|
|
16
|
+
showGrid,
|
|
17
|
+
showAxes,
|
|
18
|
+
data,
|
|
19
|
+
loading = false,
|
|
20
|
+
error,
|
|
21
|
+
...cardProps
|
|
22
|
+
}) {
|
|
23
|
+
const header = (
|
|
24
|
+
<div className="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between">
|
|
25
|
+
<div className="min-w-0">
|
|
26
|
+
{title ? (
|
|
27
|
+
<UIText as="div" size="sm" weight="medium">
|
|
28
|
+
{title}
|
|
29
|
+
</UIText>
|
|
30
|
+
) : null}
|
|
31
|
+
{subtitle ? (
|
|
32
|
+
<UIText as="div" size="xs" muted className="mt-1">
|
|
33
|
+
{subtitle}
|
|
34
|
+
</UIText>
|
|
35
|
+
) : null}
|
|
36
|
+
</div>
|
|
37
|
+
<div className="flex flex-wrap items-center justify-end gap-2">
|
|
38
|
+
{filters ? <div className="flex items-center gap-2">{filters}</div> : null}
|
|
39
|
+
{timeRange ? (
|
|
40
|
+
<select
|
|
41
|
+
className="h-9 rounded-lg border border-slate-200 bg-white px-3 text-sm text-slate-900 shadow-sm dark:border-slate-800 dark:bg-slate-900 dark:text-slate-50"
|
|
42
|
+
value={timeRange.current}
|
|
43
|
+
onChange={(e) => timeRange.onChange?.(e.target.value)}
|
|
44
|
+
aria-label="Time range"
|
|
45
|
+
>
|
|
46
|
+
{timeRange.options?.map((opt) => (
|
|
47
|
+
<option key={opt.value ?? opt} value={opt.value ?? opt}>
|
|
48
|
+
{opt.label ?? opt}
|
|
49
|
+
</option>
|
|
50
|
+
))}
|
|
51
|
+
</select>
|
|
52
|
+
) : null}
|
|
53
|
+
{actions ? <div className="flex items-center gap-2">{actions}</div> : null}
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
if (error) {
|
|
59
|
+
return (
|
|
60
|
+
<BaseCard
|
|
61
|
+
variant="chart"
|
|
62
|
+
header={header}
|
|
63
|
+
body={
|
|
64
|
+
<div className="mt-4 rounded-xl border border-rose-200 bg-rose-50 p-4 text-sm text-rose-900 dark:border-rose-900/40 dark:bg-rose-950/30 dark:text-rose-100">
|
|
65
|
+
{String(error)}
|
|
66
|
+
</div>
|
|
67
|
+
}
|
|
68
|
+
{...cardProps}
|
|
69
|
+
/>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const hint = chartType ? <UIChip>{chartType}</UIChip> : null;
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<BaseCard
|
|
77
|
+
variant="chart"
|
|
78
|
+
header={
|
|
79
|
+
<div className="flex items-center justify-between gap-3">
|
|
80
|
+
<div className="min-w-0">{header}</div>
|
|
81
|
+
{hint}
|
|
82
|
+
</div>
|
|
83
|
+
}
|
|
84
|
+
body={
|
|
85
|
+
<div className="mt-4">
|
|
86
|
+
<div className="w-full" style={{ height }}>
|
|
87
|
+
{chart}
|
|
88
|
+
</div>
|
|
89
|
+
{legend ? <div className="mt-3">{legend}</div> : null}
|
|
90
|
+
{(showGrid != null || showAxes != null) && data ? (
|
|
91
|
+
<div className="mt-2 text-xs text-slate-500 dark:text-slate-400">
|
|
92
|
+
grid: {String(!!showGrid)} · axes: {String(!!showAxes)} · points: {data.length}
|
|
93
|
+
</div>
|
|
94
|
+
) : null}
|
|
95
|
+
{loading ? (
|
|
96
|
+
<div className="mt-3 text-xs text-slate-500 dark:text-slate-400">Loading…</div>
|
|
97
|
+
) : null}
|
|
98
|
+
</div>
|
|
99
|
+
}
|
|
100
|
+
{...cardProps}
|
|
101
|
+
/>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import UIText from "../ui/Text";
|
|
3
|
+
|
|
4
|
+
export default function FeedPanel({
|
|
5
|
+
title,
|
|
6
|
+
subtitle,
|
|
7
|
+
actions,
|
|
8
|
+
children,
|
|
9
|
+
width,
|
|
10
|
+
className = "",
|
|
11
|
+
headerClassName = "",
|
|
12
|
+
bodyClassName = "",
|
|
13
|
+
...rest
|
|
14
|
+
}) {
|
|
15
|
+
const widthStyle = width ? (typeof width === "number" ? { width: `${width}px` } : { width }) : undefined;
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div
|
|
19
|
+
className={`flex shrink-0 flex-col overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm dark:border-slate-800 dark:bg-slate-900 ${className}`}
|
|
20
|
+
style={widthStyle}
|
|
21
|
+
{...rest}
|
|
22
|
+
>
|
|
23
|
+
{(title || subtitle || actions) && (
|
|
24
|
+
<div className={`shrink-0 border-b border-slate-100 px-4 py-3 dark:border-slate-800 ${headerClassName}`}>
|
|
25
|
+
<div className="flex items-start justify-between gap-3">
|
|
26
|
+
<div className="min-w-0">
|
|
27
|
+
{title && <UIText as="div" size="sm" weight="semibold">{title}</UIText>}
|
|
28
|
+
{subtitle && <UIText as="div" size="xs" muted className="mt-0.5">{subtitle}</UIText>}
|
|
29
|
+
</div>
|
|
30
|
+
{actions && <div className="shrink-0">{actions}</div>}
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
)}
|
|
34
|
+
<div className={`flex-1 overflow-y-auto ${bodyClassName}`}>
|
|
35
|
+
{children}
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import BaseCard from "./BaseCard";
|
|
3
|
+
import UIText from "../ui/Text";
|
|
4
|
+
import UIChip from "../ui/Chip";
|
|
5
|
+
|
|
6
|
+
function formatTimestamp(ts) {
|
|
7
|
+
if (!ts) return "";
|
|
8
|
+
try {
|
|
9
|
+
const d = ts instanceof Date ? ts : new Date(ts);
|
|
10
|
+
if (Number.isNaN(d.getTime())) return String(ts);
|
|
11
|
+
return d.toLocaleString(undefined, { dateStyle: "medium", timeStyle: "short" });
|
|
12
|
+
} catch {
|
|
13
|
+
return String(ts);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function Avatar({ item }) {
|
|
18
|
+
const avatar = item?.avatar;
|
|
19
|
+
const name = item?.title ?? item?.name ?? "Item";
|
|
20
|
+
if (!avatar) return null;
|
|
21
|
+
if (typeof avatar === "string") {
|
|
22
|
+
return (
|
|
23
|
+
<img
|
|
24
|
+
src={avatar}
|
|
25
|
+
alt=""
|
|
26
|
+
className="h-9 w-9 rounded-full border border-slate-200 object-cover dark:border-slate-800"
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
if (React.isValidElement(avatar)) {
|
|
31
|
+
return (
|
|
32
|
+
<div className="flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-slate-200 bg-slate-50 dark:border-slate-800 dark:bg-slate-800">
|
|
33
|
+
{avatar}
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
return (
|
|
38
|
+
<div className="h-9 w-9 rounded-full border border-slate-200 bg-slate-100 text-xs font-semibold text-slate-700 dark:border-slate-800 dark:bg-slate-800 dark:text-slate-200 grid place-items-center">
|
|
39
|
+
{String(name).slice(0, 2).toUpperCase()}
|
|
40
|
+
</div>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default function ListCard({
|
|
45
|
+
items = [],
|
|
46
|
+
title,
|
|
47
|
+
subtitle,
|
|
48
|
+
showAvatars = true,
|
|
49
|
+
showStatus = true,
|
|
50
|
+
showActions = true,
|
|
51
|
+
showTimestamp = true,
|
|
52
|
+
dense = false,
|
|
53
|
+
divided = true,
|
|
54
|
+
actions,
|
|
55
|
+
itemActions,
|
|
56
|
+
onItemClick,
|
|
57
|
+
loading = false,
|
|
58
|
+
error,
|
|
59
|
+
emptyMessage = "No items.",
|
|
60
|
+
emptyIcon,
|
|
61
|
+
maxBodyHeight,
|
|
62
|
+
...cardProps
|
|
63
|
+
}) {
|
|
64
|
+
const header = (
|
|
65
|
+
<div className="flex items-start justify-between gap-3">
|
|
66
|
+
<div className="min-w-0">
|
|
67
|
+
{title ? (
|
|
68
|
+
<UIText as="div" size="sm" weight="medium">
|
|
69
|
+
{title}
|
|
70
|
+
</UIText>
|
|
71
|
+
) : null}
|
|
72
|
+
{subtitle ? (
|
|
73
|
+
<UIText as="div" size="xs" muted className="mt-1">
|
|
74
|
+
{subtitle}
|
|
75
|
+
</UIText>
|
|
76
|
+
) : null}
|
|
77
|
+
</div>
|
|
78
|
+
{actions ? <div className="shrink-0">{actions}</div> : null}
|
|
79
|
+
</div>
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
if (error) {
|
|
83
|
+
return (
|
|
84
|
+
<BaseCard
|
|
85
|
+
variant="widget"
|
|
86
|
+
header={header}
|
|
87
|
+
body={
|
|
88
|
+
<div className="mt-4 rounded-xl border border-rose-200 bg-rose-50 p-4 text-sm text-rose-900 dark:border-rose-900/40 dark:bg-rose-950/30 dark:text-rose-100">
|
|
89
|
+
{String(error)}
|
|
90
|
+
</div>
|
|
91
|
+
}
|
|
92
|
+
{...cardProps}
|
|
93
|
+
/>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const padY = dense ? "py-2" : "py-3";
|
|
98
|
+
|
|
99
|
+
const scrollStyle = maxBodyHeight ? { maxHeight: maxBodyHeight, overflowY: "auto" } : {};
|
|
100
|
+
|
|
101
|
+
const body =
|
|
102
|
+
loading ? (
|
|
103
|
+
<div className="mt-4 space-y-3">
|
|
104
|
+
{Array.from({ length: 4 }).map((_, i) => (
|
|
105
|
+
<div key={i} className="flex items-center gap-3 rounded-xl border border-slate-200 bg-white p-3 dark:border-slate-800 dark:bg-slate-900">
|
|
106
|
+
{showAvatars ? <div className="h-9 w-9 animate-pulse rounded-full bg-slate-200 dark:bg-slate-800" /> : null}
|
|
107
|
+
<div className="flex-1 space-y-2">
|
|
108
|
+
<div className="h-4 w-1/3 animate-pulse rounded bg-slate-200 dark:bg-slate-800" />
|
|
109
|
+
<div className="h-3 w-2/3 animate-pulse rounded bg-slate-200 dark:bg-slate-800" />
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
))}
|
|
113
|
+
</div>
|
|
114
|
+
) : items.length === 0 ? (
|
|
115
|
+
<div className="mt-4 rounded-xl border border-dashed border-slate-300 bg-slate-50 p-6 text-center dark:border-slate-700 dark:bg-slate-950/30">
|
|
116
|
+
{emptyIcon ? <div className="mb-2">{emptyIcon}</div> : null}
|
|
117
|
+
<UIText size="sm" muted>
|
|
118
|
+
{emptyMessage}
|
|
119
|
+
</UIText>
|
|
120
|
+
</div>
|
|
121
|
+
) : (
|
|
122
|
+
<div className="mt-4 overflow-hidden rounded-xl border border-slate-200 bg-white dark:border-slate-800 dark:bg-slate-900">
|
|
123
|
+
<ul className={divided ? "divide-y divide-slate-200 dark:divide-slate-800" : ""} style={scrollStyle}>
|
|
124
|
+
{items.map((item, idx) => {
|
|
125
|
+
const key = item?.id ?? idx;
|
|
126
|
+
const name = item?.title ?? item?.name ?? "Item";
|
|
127
|
+
const desc = item?.description;
|
|
128
|
+
const status = item?.status;
|
|
129
|
+
const ts = item?.timestamp;
|
|
130
|
+
const itemValue = item?.value;
|
|
131
|
+
const itemUnit = item?.unit;
|
|
132
|
+
const right = showActions ? itemActions?.(item, idx) : null;
|
|
133
|
+
|
|
134
|
+
return (
|
|
135
|
+
<li
|
|
136
|
+
key={key}
|
|
137
|
+
className={[
|
|
138
|
+
"group flex items-start justify-between gap-3 px-4",
|
|
139
|
+
padY,
|
|
140
|
+
onItemClick ? "cursor-pointer hover:bg-slate-50 dark:hover:bg-slate-950/30" : ""
|
|
141
|
+
]
|
|
142
|
+
.filter(Boolean)
|
|
143
|
+
.join(" ")}
|
|
144
|
+
onClick={() => onItemClick?.(item, idx)}
|
|
145
|
+
>
|
|
146
|
+
<div className="flex min-w-0 items-start gap-3">
|
|
147
|
+
{showAvatars ? <Avatar item={item} /> : null}
|
|
148
|
+
<div className="min-w-0">
|
|
149
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
150
|
+
<div className="text-sm font-semibold text-slate-900 dark:text-slate-50">
|
|
151
|
+
{name}
|
|
152
|
+
</div>
|
|
153
|
+
{showStatus && status ? (
|
|
154
|
+
<UIChip>{String(status)}</UIChip>
|
|
155
|
+
) : null}
|
|
156
|
+
</div>
|
|
157
|
+
{desc ? (
|
|
158
|
+
<div className="mt-1 text-sm text-slate-600 dark:text-slate-300">{desc}</div>
|
|
159
|
+
) : null}
|
|
160
|
+
{showTimestamp && ts ? (
|
|
161
|
+
<div className="mt-1 text-xs text-slate-500 dark:text-slate-400">
|
|
162
|
+
{formatTimestamp(ts)}
|
|
163
|
+
</div>
|
|
164
|
+
) : null}
|
|
165
|
+
</div>
|
|
166
|
+
</div>
|
|
167
|
+
|
|
168
|
+
<div className="flex shrink-0 items-center gap-2">
|
|
169
|
+
{itemValue != null ? (
|
|
170
|
+
<div className="text-right">
|
|
171
|
+
<div className="text-sm font-semibold text-slate-900 dark:text-slate-50">
|
|
172
|
+
{String(itemValue)}
|
|
173
|
+
{itemUnit ? <span className="ml-1 text-xs font-medium text-slate-500 dark:text-slate-400">{itemUnit}</span> : null}
|
|
174
|
+
</div>
|
|
175
|
+
</div>
|
|
176
|
+
) : null}
|
|
177
|
+
{right ? (
|
|
178
|
+
<div className="opacity-100 sm:opacity-0 sm:group-hover:opacity-100">
|
|
179
|
+
{right}
|
|
180
|
+
</div>
|
|
181
|
+
) : null}
|
|
182
|
+
</div>
|
|
183
|
+
</li>
|
|
184
|
+
);
|
|
185
|
+
})}
|
|
186
|
+
</ul>
|
|
187
|
+
</div>
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
return <BaseCard variant="widget" header={header} body={body} isLoading={false} {...cardProps} />;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
|