@babylonlabs-io/core-ui 1.17.0 → 1.19.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.
@@ -0,0 +1 @@
1
+ export { RewardsPreviewModal } from "./RewardsPreviewModal";
@@ -0,0 +1 @@
1
+ export { RewardsPreviewModal } from "./RewardsPreviewModal";
@@ -0,0 +1,49 @@
1
+ interface BalanceDetails {
2
+ balance: number | string;
3
+ symbol: string;
4
+ price?: number;
5
+ displayUSD?: boolean;
6
+ decimals?: number;
7
+ }
8
+ interface RewardData {
9
+ amount: string | number | undefined;
10
+ currencyIcon: string;
11
+ currencyName: string;
12
+ placeholder?: string;
13
+ displayBalance?: boolean;
14
+ balanceDetails?: BalanceDetails;
15
+ min?: string;
16
+ step?: string;
17
+ chainName?: string;
18
+ subtitle?: string;
19
+ /** Amount currently staked */
20
+ stakedAmount?: string | number;
21
+ /** Token name for the staked amount display */
22
+ stakedTokenName?: string;
23
+ }
24
+ interface UnbondingModalProps {
25
+ open: boolean;
26
+ onClose: () => void;
27
+ /** Optional title for the dialog – defaults to "Unbonding" */
28
+ title?: string;
29
+ /** Optional description text to display in the modal */
30
+ description?: string;
31
+ /** Reward data for the AmountItem */
32
+ reward: RewardData;
33
+ /** USD amount display */
34
+ amountUsd?: string;
35
+ /** onChange handler for the amount input */
36
+ onChange?: React.ChangeEventHandler<HTMLInputElement>;
37
+ /** onKeyDown handler for the amount input */
38
+ onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;
39
+ /** Whether the amount input should be disabled */
40
+ disabled?: boolean;
41
+ /** Warning text to display below the amount section */
42
+ warningText?: string;
43
+ /** Text for the action button */
44
+ actionButtonText?: string;
45
+ /** Click handler for the action button */
46
+ onActionClick?: () => void;
47
+ }
48
+ export declare const UnbondingModal: ({ open, onClose, title, description, reward, amountUsd, onChange, onKeyDown, disabled, warningText, actionButtonText, onActionClick, }: UnbondingModalProps) => import("react/jsx-runtime").JSX.Element;
49
+ export {};
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Dialog, MobileDialog, DialogBody, DialogHeader, DialogFooter } from "@/components/Dialog";
3
+ import { Text } from "@/components/Text";
4
+ import { AmountItem } from "@/components/AmountItem";
5
+ import { SubSection } from "@/components/SubSection";
6
+ import { Warning } from "@/components/Warning";
7
+ import { Button } from "@/components/Button";
8
+ import { WINDOW_BREAKPOINT, MAX_WINDOW_HEIGHT } from "../../../utils/constants";
9
+ import { useIsMobile } from "@/hooks/useIsMobile";
10
+ import { twMerge } from "tailwind-merge";
11
+ function ResponsiveDialog({ className, ...restProps }) {
12
+ const isMobileView = useIsMobile(WINDOW_BREAKPOINT);
13
+ const DialogComponent = isMobileView ? MobileDialog : Dialog;
14
+ return _jsx(DialogComponent, { ...restProps, className: twMerge("w-[41.25rem] max-w-full", className) });
15
+ }
16
+ export const UnbondingModal = ({ open, onClose, title = "Unbonding", description, reward, amountUsd = "", onChange = () => { }, onKeyDown = () => { }, disabled = false, warningText, actionButtonText = "Unbond", onActionClick, }) => {
17
+ return (_jsxs(ResponsiveDialog, { open: open, onClose: onClose, children: [_jsx(DialogHeader, { title: title, onClose: onClose, className: "text-accent-primary" }), _jsxs(DialogBody, { style: { maxHeight: MAX_WINDOW_HEIGHT }, className: "no-scrollbar mt-4 flex flex-col gap-6 overflow-y-auto text-accent-primary", children: [description && (_jsx("div", { children: _jsx(Text, { variant: "body2", className: "text-accent-secondary whitespace-pre-line", children: description }) })), _jsx(SubSection, { className: "flex w-full flex-col content-center justify-between gap-4", children: _jsx(AmountItem, { amount: reward.amount, currencyIcon: reward.currencyIcon, currencyName: reward.currencyName, placeholder: reward.placeholder ?? "Enter Amount", displayBalance: reward.displayBalance, balanceDetails: reward.balanceDetails, min: reward.min ?? "0", step: reward.step ?? "any", autoFocus: false, onChange: onChange, onKeyDown: onKeyDown, amountUsd: amountUsd, disabled: disabled, subtitle: `Staked: ${reward.stakedAmount || 0} ${reward.stakedTokenName || reward.currencyName}` }) }), warningText && (_jsx(Warning, { children: warningText }))] }), actionButtonText && (_jsx(DialogFooter, { className: "flex justify-end mt-[80px]", children: _jsx(Button, { onClick: onActionClick, children: actionButtonText }) }))] }));
18
+ };
@@ -0,0 +1,7 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { UnbondingModal } from "./UnbondingModal";
3
+ declare const meta: Meta<typeof UnbondingModal>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const Default: Story;
7
+ export declare const BABYUnbonding: Story;
@@ -0,0 +1,81 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { UnbondingModal } from "./UnbondingModal";
4
+ import { ScrollLocker } from "@/context/Dialog.context";
5
+ import { Button } from "@/components/Button";
6
+ const meta = {
7
+ component: UnbondingModal,
8
+ tags: ["autodocs"],
9
+ };
10
+ export default meta;
11
+ export const Default = {
12
+ args: {
13
+ reward: {
14
+ amount: "",
15
+ currencyIcon: "/images/fps/lombard.jpeg",
16
+ currencyName: "BTC",
17
+ placeholder: "Enter Amount",
18
+ displayBalance: true,
19
+ balanceDetails: {
20
+ balance: "1.5",
21
+ symbol: "BTC",
22
+ price: 65000,
23
+ displayUSD: true,
24
+ decimals: 8,
25
+ },
26
+ min: "0",
27
+ step: "any",
28
+ chainName: "Bitcoin Network",
29
+ stakedAmount: "1.2",
30
+ stakedTokenName: "BTC",
31
+ },
32
+ amountUsd: "$0.00",
33
+ warningText: "Once the unstaking period begins:\n• You will not receive staking rewards\n• It will take 50 hours for the amount to be liquid\n• But you will be able to cancel the unstaking process anytime, as this chain currently supports the function",
34
+ actionButtonText: "Unbond",
35
+ onActionClick: () => alert("Unbond clicked!"),
36
+ },
37
+ render: (props) => {
38
+ const [visible, setVisibility] = useState(false);
39
+ return (_jsxs(ScrollLocker, { children: [_jsx(Button, { onClick: () => {
40
+ setVisibility(true);
41
+ }, children: "Open Unbonding Modal" }), _jsx(UnbondingModal, { reward: props.reward, amountUsd: props.amountUsd, warningText: props.warningText, actionButtonText: props.actionButtonText, onActionClick: props.onActionClick, open: visible, onClose: () => {
42
+ setVisibility(false);
43
+ } })] }));
44
+ },
45
+ };
46
+ export const BABYUnbonding = {
47
+ args: {
48
+ title: "Unbond Babylon Labs 0",
49
+ description: "Choose how much BABY you'd like to unbond from your current delegation.\nUnbonded tokens will enter a waiting period before they become available to withdraw. Your remaining stake will continue earning rewards.",
50
+ reward: {
51
+ amount: "",
52
+ currencyIcon: "/images/fps/lombard.jpeg",
53
+ currencyName: "BABY",
54
+ placeholder: "Enter Amount",
55
+ displayBalance: true,
56
+ balanceDetails: {
57
+ balance: "1000",
58
+ symbol: "BABY",
59
+ price: 0.05,
60
+ displayUSD: true,
61
+ decimals: 18,
62
+ },
63
+ min: "0",
64
+ step: "any",
65
+ stakedAmount: "30",
66
+ stakedTokenName: "BABY",
67
+ },
68
+ amountUsd: "$0.00",
69
+ warningText: "Once the unstaking period begins:\n• You will not receive staking rewards\n• It will take 50 hours for the amount to be liquid\n• But you will be able to cancel the unstaking process anytime, as this chain currently supports the function",
70
+ actionButtonText: "Unbond BABY",
71
+ onActionClick: () => alert("Unbond BABY clicked!"),
72
+ },
73
+ render: (props) => {
74
+ const [visible, setVisibility] = useState(false);
75
+ return (_jsxs(ScrollLocker, { children: [_jsx(Button, { onClick: () => {
76
+ setVisibility(true);
77
+ }, children: "Open Unbonding Modal with Title & Description" }), _jsx(UnbondingModal, { title: props.title, description: props.description, reward: props.reward, amountUsd: props.amountUsd, warningText: props.warningText, actionButtonText: props.actionButtonText, onActionClick: props.onActionClick, open: visible, onClose: () => {
78
+ setVisibility(false);
79
+ } })] }));
80
+ },
81
+ };
@@ -0,0 +1 @@
1
+ export { UnbondingModal } from "./UnbondingModal";
@@ -0,0 +1 @@
1
+ export { UnbondingModal } from "./UnbondingModal";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonlabs-io/core-ui",
3
- "version": "1.17.0",
3
+ "version": "1.19.0",
4
4
  "type": "module",
5
5
  "types": "dist/index.d.ts",
6
6
  "publishConfig": {