@babylonlabs-io/core-ui 1.23.0 → 1.24.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.
@@ -1,6 +1,8 @@
1
1
  export interface ActivityCardDetailItem {
2
2
  label: string;
3
3
  value: string | React.ReactNode;
4
+ collapsible?: boolean;
5
+ nestedDetails?: ActivityCardDetailItem[];
4
6
  }
5
7
  export interface ActivityListItemData {
6
8
  icon?: string | React.ReactNode;
@@ -20,6 +22,9 @@ export interface ActivityCardData {
20
22
  formattedAmount: string;
21
23
  icon?: string | React.ReactNode;
22
24
  iconAlt?: string;
25
+ chainName?: string;
26
+ chainIcon?: string | React.ReactNode;
27
+ chainIconAlt?: string;
23
28
  details: ActivityCardDetailItem[];
24
29
  optionalDetails?: ActivityCardDetailItem[];
25
30
  listItems?: {
@@ -1,7 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Button } from "../../../components/Button";
2
3
  import { ActivityCardActionSection } from "./components/ActivityCardActionSection";
3
4
  import { ActivityCardAmountSection } from "./components/ActivityCardAmountSection";
4
5
  import { ActivityCardDetailsSection } from "./components/ActivityCardDetailsSection";
5
6
  export function ActivityCard({ data, className }) {
6
- return (_jsxs("div", { className: `w-full bg-secondary-highlight p-3 sm:p-4 space-y-3 sm:space-y-4 rounded ${className || ""}`, children: [_jsx(ActivityCardAmountSection, { formattedAmount: data.formattedAmount, icon: data.icon, iconAlt: data.iconAlt, primaryAction: data.primaryAction }), _jsx(ActivityCardDetailsSection, { details: data.details, optionalDetails: data.optionalDetails, listItems: data.listItems }), data.secondaryActions && data.secondaryActions.length > 0 && (_jsx(ActivityCardActionSection, { actions: data.secondaryActions }))] }));
7
+ return (_jsxs("div", { className: `w-full bg-secondary-highlight p-3 sm:p-4 rounded flex flex-col justify-between ${className || ""}`, children: [_jsxs("div", { className: "space-y-3 sm:space-y-4", children: [_jsx(ActivityCardAmountSection, { formattedAmount: data.formattedAmount, icon: data.icon, iconAlt: data.iconAlt, chainName: data.chainName, chainIcon: data.chainIcon, chainIconAlt: data.chainIconAlt }), _jsx(ActivityCardDetailsSection, { details: data.details, optionalDetails: data.optionalDetails, listItems: data.listItems }), data.secondaryActions && data.secondaryActions.length > 0 && (_jsx(ActivityCardActionSection, { actions: data.secondaryActions }))] }), data.primaryAction && (_jsx(Button, { variant: "outlined", className: `mt-4 ${data.primaryAction.className || ""}`, onClick: data.primaryAction.onClick, fluid: data.primaryAction.fullWidth !== false, children: data.primaryAction.label }))] }));
7
8
  }
@@ -1,4 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
2
  import { ActivityCard } from "./ActivityCard";
3
+ import { WarningIcon } from "../../../components/Icons";
2
4
  const meta = {
3
5
  component: ActivityCard,
4
6
  tags: ["autodocs"],
@@ -8,6 +10,9 @@ export const Basic = {
8
10
  args: {
9
11
  data: {
10
12
  formattedAmount: "1.5 BTC",
13
+ chainName: "Babylon Labs",
14
+ chainIcon: "https://placehold.co/32x32?text=B",
15
+ chainIconAlt: "Babylon Labs",
11
16
  details: [
12
17
  { label: "Status", value: "Confirmed" },
13
18
  { label: "Date", value: "Mar 15, 2024" },
@@ -22,6 +27,9 @@ export const WithIcon = {
22
27
  formattedAmount: "2.3 BTC",
23
28
  icon: "/images/fps/lombard.jpeg",
24
29
  iconAlt: "Lombard Protocol",
30
+ chainName: "Babylon Labs",
31
+ chainIcon: "https://placehold.co/32x32?text=B",
32
+ chainIconAlt: "Babylon Labs",
25
33
  details: [
26
34
  { label: "Status", value: "Pending" },
27
35
  { label: "Date", value: "Mar 16, 2024" },
@@ -36,13 +44,24 @@ export const WithPrimaryAction = {
36
44
  formattedAmount: "0.75 BTC",
37
45
  icon: "/images/fps/pumpbtc.jpeg",
38
46
  iconAlt: "PumpBTC",
47
+ chainName: "Babylon Labs",
48
+ chainIcon: "https://placehold.co/32x32?text=B",
49
+ chainIconAlt: "Babylon Labs",
39
50
  details: [
40
- { label: "Status", value: "Pending" },
41
- { label: "Date", value: "Mar 16, 2024" },
42
- { label: "Confirmations", value: "2/6" },
51
+ { label: "Commission", value: "1%" },
52
+ { label: "Inception", value: "Mar 16, 2024" },
53
+ {
54
+ label: "Pending",
55
+ value: "7 BABY",
56
+ collapsible: true,
57
+ nestedDetails: [
58
+ { label: "Pending Stake", value: "10 BABY" },
59
+ { label: "Pending Unbonding", value: "3 BABY" },
60
+ ]
61
+ },
43
62
  ],
44
63
  primaryAction: {
45
- label: "View Details",
64
+ label: "Unbond",
46
65
  onClick: () => alert("Primary action clicked"),
47
66
  variant: "contained",
48
67
  },
@@ -55,6 +74,9 @@ export const WithSecondaryActions = {
55
74
  formattedAmount: "5.0 BTC",
56
75
  icon: "/images/fps/solv.jpeg",
57
76
  iconAlt: "Solv Protocol",
77
+ chainName: "Babylon Labs",
78
+ chainIcon: "https://placehold.co/32x32?text=B",
79
+ chainIconAlt: "Babylon Labs",
58
80
  details: [
59
81
  { label: "Status", value: "Completed" },
60
82
  { label: "Date", value: "Mar 14, 2024" },
@@ -83,6 +105,9 @@ export const WithOptionalDetails = {
83
105
  formattedAmount: "3.2 BTC",
84
106
  icon: "/images/wallets/keystone.svg",
85
107
  iconAlt: "Keystone Wallet",
108
+ chainName: "Babylon Labs",
109
+ chainIcon: "https://placehold.co/32x32?text=B",
110
+ chainIconAlt: "Babylon Labs",
86
111
  details: [
87
112
  { label: "Status", value: "Confirmed" },
88
113
  { label: "Date", value: "Mar 15, 2024" },
@@ -101,6 +126,9 @@ export const WithListItems = {
101
126
  formattedAmount: "10.5 BTC",
102
127
  icon: "/images/wallets/binance.webp",
103
128
  iconAlt: "Binance Wallet",
129
+ chainName: "Babylon Labs",
130
+ chainIcon: "https://placehold.co/32x32?text=B",
131
+ chainIconAlt: "Babylon Labs",
104
132
  details: [
105
133
  { label: "Status", value: "Completed" },
106
134
  { label: "Date", value: "Mar 13, 2024" },
@@ -131,6 +159,9 @@ export const Complete = {
131
159
  formattedAmount: "7.8 BTC",
132
160
  icon: "/images/fps/lombard.jpeg",
133
161
  iconAlt: "Lombard Protocol",
162
+ chainName: "Babylon Labs",
163
+ chainIcon: "https://placehold.co/32x32?text=B",
164
+ chainIconAlt: "Babylon Labs",
134
165
  details: [
135
166
  { label: "Status", value: "Confirmed" },
136
167
  { label: "Date", value: "Mar 12, 2024" },
@@ -185,6 +216,9 @@ export const LargeAmount = {
185
216
  formattedAmount: "1,234.56789 BTC",
186
217
  icon: "/images/fps/pumpbtc.jpeg",
187
218
  iconAlt: "PumpBTC",
219
+ chainName: "Babylon Labs",
220
+ chainIcon: "https://placehold.co/32x32?text=B",
221
+ chainIconAlt: "Babylon Labs",
188
222
  details: [
189
223
  { label: "Status", value: "High Value Transaction" },
190
224
  { label: "Date", value: "Mar 16, 2024" },
@@ -202,26 +236,29 @@ export const ErrorState = {
202
236
  args: {
203
237
  data: {
204
238
  formattedAmount: "0.5 BTC",
205
- icon: "/images/status/warning.svg",
239
+ icon: _jsx(WarningIcon, { size: 32, variant: "error" }),
206
240
  iconAlt: "Warning",
241
+ chainName: "Babylon Labs",
242
+ chainIcon: "https://placehold.co/32x32?text=B",
243
+ chainIconAlt: "Babylon Labs",
207
244
  details: [
208
245
  { label: "Status", value: "Failed" },
209
246
  { label: "Date", value: "Mar 16, 2024" },
210
247
  { label: "Error", value: "Insufficient funds" },
211
248
  ],
212
249
  secondaryActions: [
213
- {
214
- label: "Retry",
215
- onClick: () => alert("Retry clicked"),
216
- variant: "contained",
217
- size: "small",
218
- },
219
250
  {
220
251
  label: "Cancel",
221
252
  onClick: () => alert("Cancel clicked"),
222
253
  variant: "outlined",
223
254
  size: "small",
224
255
  },
256
+ {
257
+ label: "Retry",
258
+ onClick: () => alert("Retry clicked"),
259
+ variant: "contained",
260
+ size: "small",
261
+ },
225
262
  ],
226
263
  },
227
264
  },
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Button } from "../../../../components/Button";
3
3
  export function ActivityCardActionSection({ actions, }) {
4
- return (_jsx("div", { className: "mt-4 sm:mt-6 space-y-2", children: actions.map((action, index) => (_jsx(Button, { variant: action.variant || "outlined", size: action.size || "small", className: `sm:bbn-btn-medium ${action.fullWidth ? "w-full" : ""} ${action.className || ""}`, onClick: action.onClick, children: action.label }, index))) }));
4
+ return (_jsx("div", { className: "mt-4 sm:mt-6 flex gap-2", children: actions.map((action, index) => (_jsx(Button, { variant: action.variant || "outlined", className: `sm:bbn-btn-medium flex-1 ${action.className || ""}`, onClick: action.onClick, fluid: true, children: action.label }, `${action.label}-${index}`))) }));
5
5
  }
@@ -1,9 +1,10 @@
1
- import { ActivityCardActionButton } from "../ActivityCard";
2
1
  interface ActivityCardAmountSectionProps {
3
2
  formattedAmount: string;
4
3
  icon?: string | React.ReactNode;
5
4
  iconAlt?: string;
6
- primaryAction?: ActivityCardActionButton;
5
+ chainName?: string;
6
+ chainIcon?: string | React.ReactNode;
7
+ chainIconAlt?: string;
7
8
  }
8
- export declare function ActivityCardAmountSection({ formattedAmount, icon, iconAlt, primaryAction, }: ActivityCardAmountSectionProps): import("react/jsx-runtime").JSX.Element;
9
+ export declare function ActivityCardAmountSection({ formattedAmount, icon, iconAlt, chainName, chainIcon, chainIconAlt, }: ActivityCardAmountSectionProps): import("react/jsx-runtime").JSX.Element;
9
10
  export {};
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Button } from "../../../../components/Button";
3
- export function ActivityCardAmountSection({ formattedAmount, icon, iconAlt, primaryAction, }) {
4
- return (_jsxs("div", { className: "flex items-center justify-between mb-4 sm:mb-6", children: [_jsxs("div", { className: "flex items-center gap-2", children: [icon &&
5
- (typeof icon === "string" ? (_jsx("img", { src: icon, alt: iconAlt || "icon", className: "w-6 h-6 sm:w-8 sm:h-8" })) : (icon)), _jsx("span", { className: "text-base sm:text-lg font-medium text-accent-primary", children: formattedAmount })] }), primaryAction && (_jsx(Button, { variant: primaryAction.variant || "contained", size: primaryAction.size || "small", className: `sm:bbn-btn-medium ${primaryAction.className || ""}`, onClick: primaryAction.onClick, children: primaryAction.label }))] }));
2
+ export function ActivityCardAmountSection({ formattedAmount, icon, iconAlt, chainName, chainIcon, chainIconAlt, }) {
3
+ return (_jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("div", { className: "flex items-center gap-2", children: [icon &&
4
+ (typeof icon === "string" ? (_jsx("img", { src: icon, alt: iconAlt || "icon", className: "w-6 h-6 sm:w-8 sm:h-8" })) : (icon)), _jsx("span", { className: "text-base sm:text-lg font-medium text-accent-primary", children: formattedAmount })] }), chainName && (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "text-base sm:text-lg font-medium text-accent-primary", children: chainName }), chainIcon &&
5
+ (typeof chainIcon === "string" ? (_jsx("img", { src: chainIcon, alt: chainIconAlt || "chain icon", className: "w-6 h-6 sm:w-8 sm:h-8" })) : (chainIcon))] }))] }));
6
6
  }
@@ -1,10 +1,19 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
2
3
  import { ActivityListItem } from "./ActivityListItem";
3
- function DetailRow({ label, value }) {
4
+ import { CollapseIcon, OpenIcon } from "../../../../components/Icons";
5
+ function DetailRow({ label, value, collapsible = false, nestedDetails }) {
6
+ const [isExpanded, setIsExpanded] = useState(false);
7
+ const handleToggle = () => {
8
+ setIsExpanded(!isExpanded);
9
+ };
10
+ if (collapsible) {
11
+ return (_jsxs("div", { className: "space-y-3", children: [_jsxs("div", { className: "flex items-center justify-between gap-2 min-w-0 overflow-x-auto", children: [_jsxs("div", { className: "flex items-center gap-2 flex-shrink-0", children: [_jsx("span", { className: "text-xs sm:text-sm text-accent-secondary", children: label }), _jsx("button", { onClick: handleToggle, className: "w-5 h-5 flex-shrink-0 hover:opacity-70 transition-opacity", "aria-label": isExpanded ? "Collapse" : "Expand", children: isExpanded ? (_jsx(CollapseIcon, { size: 20, variant: "secondary" })) : (_jsx(OpenIcon, { size: 20, variant: "secondary" })) })] }), _jsx("span", { className: "text-xs sm:text-sm text-accent-primary font-medium text-right min-w-0 overflow-x-auto whitespace-nowrap", children: value })] }), isExpanded && nestedDetails && (_jsx("div", { className: "bg-surface p-3 sm:p-4 rounded space-y-3 sm:space-y-4 overflow-x-auto", children: nestedDetails.map((detail, index) => (_jsx(DetailRow, { label: detail.label, value: detail.value, collapsible: detail.collapsible, nestedDetails: detail.nestedDetails }, index))) }))] }));
12
+ }
4
13
  return (_jsxs("div", { className: "flex items-center justify-between gap-2 min-w-0 overflow-x-auto", children: [_jsx("span", { className: "text-xs sm:text-sm text-accent-secondary flex-shrink-0", children: label }), _jsx("span", { className: "text-xs sm:text-sm text-accent-primary font-medium text-right min-w-0 overflow-x-auto whitespace-nowrap", children: value })] }));
5
14
  }
6
15
  export function ActivityCardDetailsSection({ details, optionalDetails, listItems, }) {
7
16
  const hasOptionalDetails = optionalDetails && optionalDetails.length > 0;
8
17
  const hasListItems = listItems && listItems.length > 0;
9
- return (_jsxs("div", { className: "space-y-3 sm:space-y-4 overflow-x-auto", children: [_jsx("div", { className: "space-y-4 sm:space-y-6", children: details.map((detail, detailIndex) => (_jsx(DetailRow, { label: detail.label, value: detail.value }, detailIndex))) }), hasListItems && (_jsx("div", { className: "space-y-3 sm:space-y-4", children: listItems.map((listSection, sectionIndex) => (_jsx("div", { className: "bg-surface p-3 sm:p-4 rounded space-y-3 sm:space-y-4 overflow-x-auto", children: _jsxs("div", { className: "flex justify-between items-start gap-2", children: [_jsx("span", { className: "text-xs sm:text-sm text-accent-secondary", children: listSection.label }), _jsx("div", { className: "flex flex-wrap gap-2", children: listSection.items.map((item, itemIndex) => (_jsx(ActivityListItem, { item: item }, item.id || itemIndex))) })] }) }, sectionIndex))) })), hasOptionalDetails && (_jsx("div", { className: "bg-surface p-3 sm:p-4 rounded space-y-3 sm:space-y-4 overflow-x-auto", children: optionalDetails.map((detail, index) => (_jsx(DetailRow, { label: detail.label, value: detail.value }, index))) }))] }));
18
+ return (_jsxs("div", { className: "space-y-3 sm:space-y-4 overflow-x-auto", children: [_jsx("div", { className: "space-y-4 sm:space-y-6", children: details.map((detail, detailIndex) => (_jsx(DetailRow, { label: detail.label, value: detail.value, collapsible: detail.collapsible, nestedDetails: detail.nestedDetails }, detailIndex))) }), hasListItems && (_jsx("div", { className: "space-y-3 sm:space-y-4", children: listItems.map((listSection, sectionIndex) => (_jsx("div", { className: "bg-surface p-3 sm:p-4 rounded space-y-3 sm:space-y-4 overflow-x-auto", children: _jsxs("div", { className: "flex justify-between items-start gap-2", children: [_jsx("span", { className: "text-xs sm:text-sm text-accent-secondary", children: listSection.label }), _jsx("div", { className: "flex flex-wrap gap-2", children: listSection.items.map((item, itemIndex) => (_jsx(ActivityListItem, { item: item }, item.id || itemIndex))) })] }) }, sectionIndex))) })), hasOptionalDetails && (_jsx("div", { className: "bg-surface p-3 sm:p-4 rounded space-y-3 sm:space-y-4 overflow-x-auto", children: optionalDetails.map((detail, index) => (_jsx(DetailRow, { label: detail.label, value: detail.value, collapsible: detail.collapsible, nestedDetails: detail.nestedDetails }, index))) }))] }));
10
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonlabs-io/core-ui",
3
- "version": "1.23.0",
3
+ "version": "1.24.0",
4
4
  "type": "module",
5
5
  "types": "dist/index.d.ts",
6
6
  "publishConfig": {