@babylonlabs-io/core-ui 1.30.0 → 1.32.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/Icons/common/ThemeIcon.d.ts +2 -0
- package/dist/components/Icons/common/ThemeIcon.js +7 -0
- package/dist/components/Icons/index.d.ts +1 -0
- package/dist/components/Icons/index.js +1 -0
- package/dist/components/Menu/MenuItem.d.ts +14 -0
- package/dist/components/Menu/MenuItem.js +14 -7
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +800 -763
- package/dist/index.es.js.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/widgets/sections/PreviewModal/PreviewModal.d.ts +3 -3
- package/dist/widgets/sections/PreviewModal/PreviewModal.js +2 -2
- package/dist/widgets/sections/PreviewModal/PreviewModal.stories.d.ts +1 -0
- package/dist/widgets/sections/PreviewModal/PreviewModal.stories.js +40 -1
- package/dist/widgets/sections/SettingMenu/SettingMenu.stories.d.ts +1 -0
- package/dist/widgets/sections/SettingMenu/SettingMenu.stories.js +15 -1
- package/dist/widgets/sections/SettingMenu/components/SettingMenuItem.d.ts +15 -0
- package/dist/widgets/sections/SettingMenu/components/SettingMenuItem.js +3 -3
- package/package.json +1 -1
|
@@ -28,10 +28,10 @@ interface PreviewModalProps {
|
|
|
28
28
|
* Labels should match the exact ones defined internally (e.g. "Stake Amount", "Transaction Fees").
|
|
29
29
|
*/
|
|
30
30
|
visibleFields?: string[];
|
|
31
|
-
/**
|
|
32
|
-
|
|
31
|
+
/** Warning lines rendered under the "Attention!" section. */
|
|
32
|
+
warnings: string[];
|
|
33
33
|
/** Label for the primary action button; defaults to "Proceed to Signing" */
|
|
34
34
|
proceedLabel?: string;
|
|
35
35
|
}
|
|
36
|
-
export declare const PreviewModal: ({ open, processing, onClose, onProceed, bsns, finalityProviders, details, visibleFields,
|
|
36
|
+
export declare const PreviewModal: ({ open, processing, onClose, onProceed, bsns, finalityProviders, details, visibleFields, warnings, proceedLabel, }: PropsWithChildren<PreviewModalProps>) => import("react/jsx-runtime").JSX.Element;
|
|
37
37
|
export {};
|
|
@@ -12,7 +12,7 @@ function ResponsiveDialog({ className, ...restProps }) {
|
|
|
12
12
|
const DialogComponent = isMobileView ? MobileDialog : Dialog;
|
|
13
13
|
return _jsx(DialogComponent, { ...restProps, className: twMerge("w-[41.25rem] max-w-full", className) });
|
|
14
14
|
}
|
|
15
|
-
export const PreviewModal = ({ open, processing = false, onClose, onProceed, bsns, finalityProviders, details, visibleFields,
|
|
15
|
+
export const PreviewModal = ({ open, processing = false, onClose, onProceed, bsns, finalityProviders, details, visibleFields, warnings, proceedLabel = "Proceed to Signing", }) => {
|
|
16
16
|
const allFields = [
|
|
17
17
|
{ label: "Stake Amount", value: details.stakeAmount },
|
|
18
18
|
{ label: "Fee Rate", value: details.feeRate },
|
|
@@ -44,5 +44,5 @@ export const PreviewModal = ({ open, processing = false, onClose, onProceed, bsn
|
|
|
44
44
|
];
|
|
45
45
|
}),
|
|
46
46
|
];
|
|
47
|
-
return (_jsxs(ResponsiveDialog, { open: open, onClose: onClose, children: [_jsx(DialogHeader, { title: "Preview", onClose: onClose, className: "text-accent-primary" }), _jsxs(DialogBody, { className: "no-scrollbar mb-8 mt-4 flex max-h-[calc(100vh-12rem)] flex-col gap-4 overflow-y-auto text-accent-primary", children: [_jsx(Table, { data: tableData }), _jsx("div", { className: "flex flex-col", children: fields.map((field, index) => (_jsxs("div", { className: "flex flex-row items-center justify-between py-3", children: [_jsx(Text, { variant: "body1", className: "text-secondary font-normal", children: field.label }), _jsx(Text, { variant: "body1", className: "text-right font-normal", children: field.value })] }, index))) }), _jsx("div", { className: "border-divider w-full border-t" }), _jsxs("div", { className: "pt-2", children: [_jsx(Heading, { variant: "h6", className: "text-primary mb-2", children: "Attention!" }),
|
|
47
|
+
return (_jsxs(ResponsiveDialog, { open: open, onClose: onClose, children: [_jsx(DialogHeader, { title: "Preview", onClose: onClose, className: "text-accent-primary" }), _jsxs(DialogBody, { className: "no-scrollbar mb-8 mt-4 flex max-h-[calc(100vh-12rem)] flex-col gap-4 overflow-y-auto text-accent-primary", children: [_jsx(Table, { data: tableData }), _jsx("div", { className: "flex flex-col", children: fields.map((field, index) => (_jsxs("div", { className: "flex flex-row items-center justify-between py-3", children: [_jsx(Text, { variant: "body1", className: "text-secondary font-normal", children: field.label }), _jsx(Text, { variant: "body1", className: "text-right font-normal", children: field.value })] }, index))) }), _jsx("div", { className: "border-divider w-full border-t" }), _jsxs("div", { className: "pt-2", children: [_jsx(Heading, { variant: "h6", className: "text-primary mb-2", children: "Attention!" }), warnings.map((line, idx) => (_jsx(Text, { variant: "body2", className: "text-secondary", children: line }, idx)))] })] }), _jsxs(DialogFooter, { className: "flex flex-col gap-4 pb-8 pt-0 sm:flex-row", children: [_jsx(Button, { variant: "contained", color: "primary", onClick: onProceed, className: "w-full sm:flex-1 sm:order-2", disabled: processing, children: processing ? "Processing..." : proceedLabel }), _jsx(Button, { variant: "outlined", color: "primary", onClick: onClose, className: "w-full sm:flex-1 sm:order-1", children: "Cancel" })] })] }));
|
|
48
48
|
};
|
|
@@ -43,6 +43,10 @@ export const Default = {
|
|
|
43
43
|
unbonding: "~ 1 day",
|
|
44
44
|
unbondingFee: "0 BTC",
|
|
45
45
|
},
|
|
46
|
+
warnings: [
|
|
47
|
+
"1. No third party possesses your staked BTC. You are the only one who can unbond and withdraw your stake.",
|
|
48
|
+
"2. Your stake will first be sent to Babylon Genesis for verification (~20 seconds), then you will be prompted to submit it to the Bitcoin ledger. It will be marked as 'Pending' until it receives 10 Bitcoin confirmations.",
|
|
49
|
+
],
|
|
46
50
|
},
|
|
47
51
|
};
|
|
48
52
|
export const ValidatorOnly = {
|
|
@@ -70,7 +74,42 @@ export const ValidatorOnly = {
|
|
|
70
74
|
unbondingFee: "0 BTC",
|
|
71
75
|
},
|
|
72
76
|
visibleFields: ["Stake Amount", "Transaction Fees"],
|
|
73
|
-
|
|
77
|
+
warnings: [
|
|
78
|
+
"The staking transaction may take up to one (1) hour to process.",
|
|
79
|
+
"Funds will not be deducted instantly; maintain sufficient balance until confirmed.",
|
|
80
|
+
],
|
|
74
81
|
proceedLabel: "Stake",
|
|
75
82
|
},
|
|
76
83
|
};
|
|
84
|
+
export const CustomWarnings = {
|
|
85
|
+
args: {
|
|
86
|
+
open: true,
|
|
87
|
+
processing: false,
|
|
88
|
+
onClose: () => { },
|
|
89
|
+
onProceed: () => { },
|
|
90
|
+
bsns: [
|
|
91
|
+
{
|
|
92
|
+
icon: _jsx(PlaceholderIcon, { text: "B", bgColor: "bg-black" }),
|
|
93
|
+
name: "Babylon Genesis",
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
finalityProviders: [],
|
|
97
|
+
details: {
|
|
98
|
+
stakeAmount: "0.25 BTC",
|
|
99
|
+
feeRate: "4 sat/vB",
|
|
100
|
+
transactionFees: "0.00005 BTC",
|
|
101
|
+
term: {
|
|
102
|
+
blocks: "40320 blocks",
|
|
103
|
+
duration: "~ 4 weeks",
|
|
104
|
+
},
|
|
105
|
+
unbonding: "~ 1 day",
|
|
106
|
+
unbondingFee: "0 BTC",
|
|
107
|
+
},
|
|
108
|
+
warnings: [
|
|
109
|
+
"1. Custom line one for this integration.",
|
|
110
|
+
"2. Second line explaining processing behavior.",
|
|
111
|
+
"3. Optional extra note about timelock reset in expansions.",
|
|
112
|
+
],
|
|
113
|
+
proceedLabel: "Proceed",
|
|
114
|
+
},
|
|
115
|
+
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from "react";
|
|
3
|
+
import { FaSun, FaMoon } from "react-icons/fa";
|
|
3
4
|
import { SettingMenu } from "./SettingMenu";
|
|
4
5
|
import { Button } from "@/components/Button";
|
|
5
6
|
import { useIsMobile } from "@/hooks/useIsMobile";
|
|
7
|
+
import { ThemeIcon } from "@/components/Icons";
|
|
6
8
|
export default {
|
|
7
9
|
title: "Widgets/sections/SettingMenu",
|
|
8
10
|
component: SettingMenu,
|
|
@@ -11,7 +13,6 @@ export default {
|
|
|
11
13
|
},
|
|
12
14
|
tags: ["autodocs"],
|
|
13
15
|
};
|
|
14
|
-
const ThemeIcon = () => (_jsxs("svg", { width: "40", height: "40", viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("rect", { width: "40", height: "40", rx: "20", fill: "#387085", fillOpacity: "0.12" }), _jsx("path", { d: "M20 30C25.52 30 30 25.52 30 20C30 14.48 25.52 10 20 10C14.48 10 10 14.48 10 20C10 25.52 14.48 30 20 30ZM21 12.07C24.94 12.56 28 15.92 28 20C28 24.08 24.95 27.44 21 27.93V12.07Z", fill: "#387085" })] }));
|
|
15
16
|
const ReportABugIcon = () => (_jsxs("svg", { width: "40", height: "40", viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("rect", { width: "40", height: "40", rx: "20", fill: "#387085", fillOpacity: "0.12" }), _jsx("path", { d: "M23.73 11H16.27L11 16.27V23.73L16.27 29H23.73L29 23.73V16.27L23.73 11ZM20 25.3C19.28 25.3 18.7 24.72 18.7 24C18.7 23.28 19.28 22.7 20 22.7C20.72 22.7 21.3 23.28 21.3 24C21.3 24.72 20.72 25.3 20 25.3ZM21 21H19V15H21V21Z", fill: "#387085" })] }));
|
|
16
17
|
export const Default = () => {
|
|
17
18
|
const [selectedTheme, setSelectedTheme] = useState("auto");
|
|
@@ -33,3 +34,16 @@ export const Default = () => {
|
|
|
33
34
|
};
|
|
34
35
|
return (_jsx("div", { className: "p-4", children: _jsxs(SettingMenu, { children: [_jsx(SettingMenu.Title, { children: "Settings" }), _jsxs(SettingMenu.Group, { background: "secondary", children: [_jsxs(SettingMenu.SubMenu, { icon: _jsx(ThemeIcon, {}), children: ["Theme", _jsx(SettingMenu.Description, { children: getThemeDescription() }), _jsx(SettingMenu.Item, { selected: selectedTheme === "light", onClick: () => handleThemeChange("light"), children: "Light" }), _jsx(SettingMenu.Item, { selected: selectedTheme === "dark", onClick: () => handleThemeChange("dark"), children: "Dark" }), _jsx(SettingMenu.Item, { selected: selectedTheme === "auto", onClick: () => handleThemeChange("auto"), children: "Auto" })] }), _jsx(SettingMenu.Item, { icon: _jsx(ReportABugIcon, {}), onClick: () => console.log("Report bug clicked"), children: "Report a Bug" })] }), isMobile && _jsx(SettingMenu.Spacer, {}), _jsxs(SettingMenu.Group, { background: "secondary", children: [_jsx(SettingMenu.Item, { onClick: () => window.open("https://example.com/terms", "_blank"), children: "Terms of Use" }), _jsx(SettingMenu.Item, { onClick: () => window.open("https://example.com/privacy", "_blank"), children: "Privacy Policy" })] }), _jsx(SettingMenu.Spacer, {}), _jsx(SettingMenu.CustomContent, { className: "my-4 flex justify-center", children: _jsx(Button, { className: "!bg-[#D5FCE8] !text-black", variant: "contained", children: "Switch to BABY Staking" }) })] }) }));
|
|
35
36
|
};
|
|
37
|
+
export const WithThemeToggle = () => {
|
|
38
|
+
const [isLightMode, setIsLightMode] = useState(false);
|
|
39
|
+
const isMobile = useIsMobile();
|
|
40
|
+
return (_jsx("div", { className: "p-4", children: _jsxs(SettingMenu, { children: [_jsx(SettingMenu.Title, { children: "Settings" }), _jsxs(SettingMenu.Group, { background: "secondary", children: [_jsxs(SettingMenu.Item, { icon: _jsx(ThemeIcon, {}), toggle: {
|
|
41
|
+
value: isLightMode,
|
|
42
|
+
onChange: (value) => {
|
|
43
|
+
setIsLightMode(value);
|
|
44
|
+
console.log("Theme changed to:", value ? "Light" : "Dark");
|
|
45
|
+
},
|
|
46
|
+
activeIcon: _jsx(FaSun, { size: 10 }),
|
|
47
|
+
inactiveIcon: _jsx(FaMoon, { size: 10 })
|
|
48
|
+
}, children: ["Theme", _jsx(SettingMenu.Description, { children: "Light mode" })] }), _jsx(SettingMenu.Item, { icon: _jsx(ReportABugIcon, {}), onClick: () => console.log("Report bug clicked"), children: "Report a Bug" })] }), isMobile && _jsx(SettingMenu.Spacer, {}), _jsxs(SettingMenu.Group, { background: "secondary", children: [_jsx(SettingMenu.Item, { onClick: () => window.open("https://example.com/terms", "_blank"), children: "Terms of Use" }), _jsx(SettingMenu.Item, { onClick: () => window.open("https://example.com/privacy", "_blank"), children: "Privacy Policy" })] }), _jsx(SettingMenu.Spacer, {}), _jsx(SettingMenu.CustomContent, { className: "my-4 flex justify-center", children: _jsx(Button, { className: "!bg-[#D5FCE8] !text-black", variant: "contained", children: "Switch to BABY Staking" }) })] }) }));
|
|
49
|
+
};
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import React, { ReactNode } from "react";
|
|
2
|
+
interface SettingMenuItemToggleProps {
|
|
3
|
+
/** Current toggle value */
|
|
4
|
+
value?: boolean;
|
|
5
|
+
/** Default toggle value */
|
|
6
|
+
defaultValue?: boolean;
|
|
7
|
+
/** Toggle change handler */
|
|
8
|
+
onChange?: (value: boolean) => void;
|
|
9
|
+
/** Icon to show when toggle is active */
|
|
10
|
+
activeIcon?: React.ReactNode;
|
|
11
|
+
/** Icon to show when toggle is inactive */
|
|
12
|
+
inactiveIcon?: React.ReactNode;
|
|
13
|
+
}
|
|
2
14
|
export interface SettingMenuItemProps {
|
|
3
15
|
/** Icon element */
|
|
4
16
|
icon?: ReactNode;
|
|
@@ -12,7 +24,10 @@ export interface SettingMenuItemProps {
|
|
|
12
24
|
selected?: boolean;
|
|
13
25
|
/** Additional CSS classes */
|
|
14
26
|
className?: string;
|
|
27
|
+
/** Toggle configuration - when provided, renders a toggle switch as suffix */
|
|
28
|
+
toggle?: SettingMenuItemToggleProps;
|
|
15
29
|
/** Children (label and description) */
|
|
16
30
|
children: ReactNode;
|
|
17
31
|
}
|
|
18
32
|
export declare const SettingMenuItem: React.FC<SettingMenuItemProps>;
|
|
33
|
+
export {};
|
|
@@ -3,11 +3,11 @@ import React from "react";
|
|
|
3
3
|
import { MenuItem } from "@/components/Menu/MenuItem";
|
|
4
4
|
import { ChevronRightIcon } from "@/elements/Icons";
|
|
5
5
|
import { SettingMenuDescription } from "./SettingMenuDescription";
|
|
6
|
-
export const SettingMenuItem = ({ icon, suffix, onClick, disabled = false, selected = false, className = "", children, }) => {
|
|
6
|
+
export const SettingMenuItem = ({ icon, suffix, onClick, disabled = false, selected = false, className = "", toggle, children, }) => {
|
|
7
7
|
const childrenArray = React.Children.toArray(children);
|
|
8
8
|
const label = childrenArray.find((child) => typeof child === "string" || (React.isValidElement(child) && child.type !== SettingMenuDescription));
|
|
9
9
|
const description = childrenArray.find((child) => React.isValidElement(child) && child.type === SettingMenuDescription);
|
|
10
10
|
const labelText = typeof label === "string" ? label : "";
|
|
11
|
-
const defaultSuffix = onClick ? _jsx(ChevronRightIcon, {}) : undefined;
|
|
12
|
-
return (_jsx(MenuItem, { icon: icon, name: labelText, description: description ? description.props.children : undefined, onClick: onClick, disabled: disabled, selected: selected, className: className, suffix: suffix || defaultSuffix }));
|
|
11
|
+
const defaultSuffix = onClick && !toggle ? _jsx(ChevronRightIcon, {}) : undefined;
|
|
12
|
+
return (_jsx(MenuItem, { icon: icon, name: labelText, description: description ? description.props.children : undefined, onClick: onClick, disabled: disabled, selected: selected, className: className, suffix: suffix || defaultSuffix, toggle: toggle }));
|
|
13
13
|
};
|