@0xsquid/ui 0.27.3-alpha.0 → 0.27.3
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/cjs/index.js +122 -50
- package/dist/cjs/types/components/layout/AppContainer.d.ts +0 -1
- package/dist/cjs/types/components/layout/PipeSeparator.d.ts +1 -1
- package/dist/cjs/types/components/layout/useOnClickOutside.d.ts +3 -3
- package/dist/cjs/types/components/views/SwapProgressView.d.ts +2 -2
- package/dist/cjs/types/core/numbers.d.ts +23 -0
- package/dist/cjs/types/types/components.d.ts +2 -2
- package/dist/cjs/types/types/index.d.ts +1 -1
- package/dist/esm/index.js +116 -44
- package/dist/esm/types/components/layout/AppContainer.d.ts +0 -1
- package/dist/esm/types/components/layout/PipeSeparator.d.ts +1 -1
- package/dist/esm/types/components/layout/useOnClickOutside.d.ts +3 -3
- package/dist/esm/types/components/views/SwapProgressView.d.ts +2 -2
- package/dist/esm/types/core/numbers.d.ts +23 -0
- package/dist/esm/types/types/components.d.ts +2 -2
- package/dist/esm/types/types/index.d.ts +1 -1
- package/dist/index.d.ts +6 -7
- package/package.json +2 -5
package/dist/cjs/index.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var React$1 = require('react');
|
|
5
|
-
var reactHooks = require('@0xsquid/react-hooks');
|
|
6
5
|
|
|
7
6
|
function _interopNamespaceDefault(e) {
|
|
8
7
|
var n = Object.create(null);
|
|
@@ -6596,6 +6595,59 @@ var debounce_1 = debounce;
|
|
|
6596
6595
|
|
|
6597
6596
|
var debounce$1 = /*@__PURE__*/getDefaultExportFromCjs(debounce_1);
|
|
6598
6597
|
|
|
6598
|
+
/**
|
|
6599
|
+
* Convert token amount to USD
|
|
6600
|
+
* @param {string|number} tokenAmount - The amount of tokens
|
|
6601
|
+
* @param {string|number} tokenPrice - The price of one token in USD
|
|
6602
|
+
* @returns {BigNumber} - The equivalent amount in USD
|
|
6603
|
+
*/
|
|
6604
|
+
function convertTokenAmountToUSD(tokenAmount, tokenPrice, maxDecimals = 2) {
|
|
6605
|
+
if (!tokenAmount || !tokenPrice)
|
|
6606
|
+
return "";
|
|
6607
|
+
const amount = new BigNumber(tokenAmount);
|
|
6608
|
+
const price = new BigNumber(tokenPrice);
|
|
6609
|
+
return amount.multipliedBy(price).decimalPlaces(maxDecimals).toString();
|
|
6610
|
+
}
|
|
6611
|
+
/**
|
|
6612
|
+
* Convert USD to token amount
|
|
6613
|
+
* @param {string|number} usdAmount - The amount in USD
|
|
6614
|
+
* @param {string|number} tokenPrice - The price of one token in USD
|
|
6615
|
+
* @param {number} maxDecimals - The maximum number of decimals
|
|
6616
|
+
* @returns {BigNumber} - The equivalent amount of tokens
|
|
6617
|
+
*/
|
|
6618
|
+
function convertUSDToTokenAmount(usdAmount, tokenPrice, maxDecimals) {
|
|
6619
|
+
if (!usdAmount || !tokenPrice || !maxDecimals)
|
|
6620
|
+
return "0";
|
|
6621
|
+
const amount = new BigNumber(usdAmount);
|
|
6622
|
+
const price = new BigNumber(tokenPrice);
|
|
6623
|
+
return amount.dividedBy(price).decimalPlaces(maxDecimals).toString();
|
|
6624
|
+
}
|
|
6625
|
+
const INTL_NUMBER_FORMATTER = new Intl.NumberFormat("en-US", {
|
|
6626
|
+
minimumFractionDigits: 2,
|
|
6627
|
+
maximumFractionDigits: 5,
|
|
6628
|
+
});
|
|
6629
|
+
/**
|
|
6630
|
+
* Formats a number to the en-US number format
|
|
6631
|
+
*
|
|
6632
|
+
* @param amount - The number to format
|
|
6633
|
+
* @returns The formatted string
|
|
6634
|
+
*/
|
|
6635
|
+
function formatAmount(amount) {
|
|
6636
|
+
return INTL_NUMBER_FORMATTER.format(amount);
|
|
6637
|
+
}
|
|
6638
|
+
function trimExtraDecimals(value, maxDecimals) {
|
|
6639
|
+
var _a;
|
|
6640
|
+
const split = value.split(".");
|
|
6641
|
+
if (split.length > 1) {
|
|
6642
|
+
const decimals = (_a = split[1]) !== null && _a !== void 0 ? _a : "";
|
|
6643
|
+
if (maxDecimals && decimals.length > maxDecimals) {
|
|
6644
|
+
const newValue = `${split[0]}.${decimals.slice(0, maxDecimals)}`;
|
|
6645
|
+
return newValue;
|
|
6646
|
+
}
|
|
6647
|
+
}
|
|
6648
|
+
return value;
|
|
6649
|
+
}
|
|
6650
|
+
|
|
6599
6651
|
function SwapInputsIcon() {
|
|
6600
6652
|
return (jsxRuntime.jsxs("svg", { width: "20", height: "21", viewBox: "0 0 20 21", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("g", { clipPath: "url(#clip0_40_7936)", children: jsxRuntime.jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M20 10.5C20 16.0228 15.5228 20.5 10 20.5C4.47715 20.5 0 16.0228 0 10.5C0 4.97715 4.47715 0.5 10 0.5C15.5228 0.5 20 4.97715 20 10.5ZM8.38268 4.57612C8.75636 4.7309 9 5.09554 9 5.5V15.5C9 16.0523 8.55228 16.5 8 16.5C7.44772 16.5 7 16.0523 7 15.5V7.91421L5.70711 9.20711C5.31658 9.59763 4.68342 9.59763 4.29289 9.20711C3.90237 8.81658 3.90237 8.18342 4.29289 7.79289L7.29289 4.79289C7.57889 4.5069 8.00901 4.42134 8.38268 4.57612ZM11 15.5C11 15.9045 11.2436 16.2691 11.6173 16.4239C11.991 16.5787 12.4211 16.4931 12.7071 16.2071L15.7071 13.2071C16.0976 12.8166 16.0976 12.1834 15.7071 11.7929C15.3166 11.4024 14.6834 11.4024 14.2929 11.7929L13 13.0858V5.5C13 4.94771 12.5523 4.5 12 4.5C11.4477 4.5 11 4.94771 11 5.5V15.5Z", fill: "currentColor" }) }), jsxRuntime.jsx("defs", { children: jsxRuntime.jsx("clipPath", { id: "clip0_40_7936", children: jsxRuntime.jsx("rect", { width: "20", height: "20", fill: "white", transform: "translate(0 0.5)" }) }) })] }));
|
|
6601
6653
|
}
|
|
@@ -17817,8 +17869,9 @@ function NavigationBar(_a) {
|
|
|
17817
17869
|
: "tw-flex"), children: jsxRuntime.jsx(HeadingText, { size: "small", children: title }) })) : null] })));
|
|
17818
17870
|
}
|
|
17819
17871
|
|
|
17820
|
-
function PipeSeparator(
|
|
17821
|
-
|
|
17872
|
+
function PipeSeparator(_a) {
|
|
17873
|
+
var { className } = _a, props = __rest$1(_a, ["className"]);
|
|
17874
|
+
return (jsxRuntime.jsx("div", Object.assign({}, props, { className: cn("tw-h-[0.8em] tw-w-[2px] tw-rounded-full tw-bg-[currentColor]", className) })));
|
|
17822
17875
|
}
|
|
17823
17876
|
|
|
17824
17877
|
function CollapsibleMenu({ children, menuRef, isOpen, transitionDuration, size, className, }) {
|
|
@@ -18693,6 +18746,21 @@ function DropdownMenuItemWithSubmenu(_a) {
|
|
|
18693
18746
|
}, children: submenu })) })) }));
|
|
18694
18747
|
}
|
|
18695
18748
|
|
|
18749
|
+
function useOnClickOutside(callback, externalRef) {
|
|
18750
|
+
const internalRef = React$1.useRef(null);
|
|
18751
|
+
const ref = externalRef || internalRef;
|
|
18752
|
+
React$1.useEffect(() => {
|
|
18753
|
+
const handleMouseDown = (e) => {
|
|
18754
|
+
if (ref.current && !ref.current.contains(e.target)) {
|
|
18755
|
+
callback();
|
|
18756
|
+
}
|
|
18757
|
+
};
|
|
18758
|
+
document.addEventListener("mousedown", handleMouseDown);
|
|
18759
|
+
return () => document.removeEventListener("mousedown", handleMouseDown);
|
|
18760
|
+
}, [callback, ref]);
|
|
18761
|
+
return { ref };
|
|
18762
|
+
}
|
|
18763
|
+
|
|
18696
18764
|
const dropdownPositionClassMap$1 = {
|
|
18697
18765
|
top: "tw-right-full tw-bottom-[50px]",
|
|
18698
18766
|
bottom: "tw-right-full tw-top-[50px]",
|
|
@@ -18708,6 +18776,14 @@ const collapsedListItemClassMap = {
|
|
|
18708
18776
|
};
|
|
18709
18777
|
function ListItem(_a) {
|
|
18710
18778
|
var { itemTitle, mainImageUrl, subtitle, subtitleOnHover, detail, icon, secondaryImageUrl, placeholderImageUrl, size = "large", mainIcon, className, isSelected, onDetailClick, showDetailOnHoverOnly, rounded = false, detailButtonClassName, loading, containerProps, compactOnMobile, extraPadding = true, itemsContainerRef, dropdownMenuContent } = _a, props = __rest$1(_a, ["itemTitle", "mainImageUrl", "subtitle", "subtitleOnHover", "detail", "icon", "secondaryImageUrl", "placeholderImageUrl", "size", "mainIcon", "className", "isSelected", "onDetailClick", "showDetailOnHoverOnly", "rounded", "detailButtonClassName", "loading", "containerProps", "compactOnMobile", "extraPadding", "itemsContainerRef", "dropdownMenuContent"]);
|
|
18779
|
+
const { isDropdownOpen, dropdownRef, openDropdown, closeDropdown, openDropdownButtonRef, itemRef, menuRef, dropdownStyles, } = useDropdownMenu({
|
|
18780
|
+
itemsContainerRef,
|
|
18781
|
+
});
|
|
18782
|
+
useOnClickOutside(() => {
|
|
18783
|
+
if (isDropdownOpen) {
|
|
18784
|
+
closeDropdown();
|
|
18785
|
+
}
|
|
18786
|
+
}, itemRef);
|
|
18711
18787
|
const subtitleClassName = cn("tw-h-[14px] tw-max-w-full tw-truncate !tw-leading-[16px] tw-text-grey-500", compactOnMobile ? "tw-hidden mobile-lg:tw-block" : "tw-block");
|
|
18712
18788
|
// 'small' variant does not have detail
|
|
18713
18789
|
const showDetail = size === "large" && (!!detail || !!icon || showDetailOnHoverOnly);
|
|
@@ -18738,22 +18814,37 @@ function ListItem(_a) {
|
|
|
18738
18814
|
const isInteractive = !!props.onClick;
|
|
18739
18815
|
const ItemTag = isInteractive ? "button" : "div";
|
|
18740
18816
|
const itemProps = isInteractive ? props : {};
|
|
18741
|
-
const
|
|
18742
|
-
|
|
18743
|
-
|
|
18744
|
-
|
|
18817
|
+
const handleInteraction = (e) => {
|
|
18818
|
+
var _a;
|
|
18819
|
+
e.preventDefault();
|
|
18820
|
+
e.stopPropagation();
|
|
18821
|
+
if ("onClick" in props && e.type === "click") {
|
|
18822
|
+
(_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
18823
|
+
}
|
|
18824
|
+
};
|
|
18825
|
+
// Handle List item click, close dropdown if it's open
|
|
18826
|
+
const handleItemClick = (e) => {
|
|
18827
|
+
handleInteraction(e);
|
|
18828
|
+
if (isDropdownOpen)
|
|
18829
|
+
closeDropdown();
|
|
18830
|
+
};
|
|
18831
|
+
return (jsxRuntime.jsxs("li", Object.assign({}, containerProps, { ref: itemRef, className: cn("tw-highlight-adjacent tw-relative tw-flex tw-max-w-full tw-bg-grey-900 tw-text-grey-300", listItemSizeMap[size], extraPadding && "tw-px-squid-xs", compactOnMobile
|
|
18745
18832
|
? `${collapsedListItemClassMap[size]} mobile-lg:tw-w-full`
|
|
18746
|
-
: "tw-w-full", className), children: [jsxRuntime.jsxs(ItemTag, Object.assign({}, itemProps, { className: cn("tw-group/list-item tw-peer/list-item tw-relative tw-flex tw-w-full tw-max-w-full tw-items-center tw-justify-start tw-gap-squid-xs tw-rounded-squid-s tw-px-squid-xs tw-py-squid-xxs", (isSelected || isDropdownOpen) && "tw-bg-material-light-thin", isInteractive && "hover:tw-bg-material-light-thin"), children: [size === "large" ? (jsxRuntime.jsx("div", { className: "tw-h-10 tw-w-10", children: mainIcon
|
|
18833
|
+
: "tw-w-full", className), children: [jsxRuntime.jsxs(ItemTag, Object.assign({}, itemProps, { onClick: handleItemClick, className: cn("tw-group/list-item tw-peer/list-item tw-relative tw-flex tw-w-full tw-max-w-full tw-items-center tw-justify-start tw-gap-squid-xs tw-rounded-squid-s tw-px-squid-xs tw-py-squid-xxs", (isSelected || isDropdownOpen) && "tw-bg-material-light-thin", isInteractive && "hover:tw-bg-material-light-thin"), children: [size === "large" ? (jsxRuntime.jsx("div", { className: "tw-h-10 tw-w-10", children: mainIcon ? (mainIcon) : (jsxRuntime.jsx(BadgeImage, { extraMarginForBadge: false, imageUrl: mainImageUrl, badgeUrl: secondaryImageUrl, placeholderImageUrl: placeholderImageUrl, size: "md", rounded: rounded })) })) : (jsxRuntime.jsx("div", { className: "tw-flex tw-min-h-[30px] tw-min-w-[30px] tw-items-center tw-justify-center", children: mainIcon ? (mainIcon) : (jsxRuntime.jsx("img", { src: mainImageUrl, className: "tw-h-[30px] tw-w-[30px] tw-rounded-squid-xs" })) })), jsxRuntime.jsxs("div", { className: cn("tw-flex tw-h-[40px] tw-flex-1 tw-flex-col tw-items-start tw-justify-center tw-gap-squid-xxs",
|
|
18747
18834
|
// 'large' variant has extra padding
|
|
18748
18835
|
size === "large" ? "tw-w-[56%] tw-pl-squid-xxs" : "tw-w-[67%]"), children: [typeof itemTitle === "string" ? (jsxRuntime.jsx(BodyText, { size: "small", className: cn("tw-max-w-full tw-truncate", subtitle && "tw-h-[17px] !tw-leading-[17px]", compactOnMobile ? "tw-hidden mobile-lg:tw-block" : "tw-block"), children: itemTitle })) : (itemTitle), size === "large" &&
|
|
18749
18836
|
((loading === null || loading === void 0 ? void 0 : loading.subtitle) ? (loadingComponent()) : subtitle ? (jsxRuntime.jsxs(CaptionText, { className: subtitleClassName, children: [subtitleOnHover && (jsxRuntime.jsx(CaptionText, { className: cn(subtitleClassName, "tw-hidden group-hover/list-item:tw-block"), children: subtitleOnHover })), subtitle] })) : null)] }), showDetail && (jsxRuntime.jsxs(DetailTag, Object.assign({}, detailProps, { className: cn("tw-flex tw-w-fit tw-items-center tw-justify-center tw-rounded-squid-xs", size === "large" ? "tw-h-squid-xl" : "tw-h-squid-l", showDetailOnHoverOnly
|
|
18750
18837
|
? "tw-opacity-0 hover:tw-opacity-100 focus:tw-opacity-100 group-hover/list-item:tw-opacity-100 group-focus/list-item:tw-opacity-100"
|
|
18751
|
-
: "tw-flex", isDetailInteractive && "hover:tw-bg-material-light-thin", detailButtonClassName), children: [!!detail && (jsxRuntime.jsx(CaptionText, { className: "min-tw-w-4 min-tw-h-4 tw-px-squid-xxs tw-leading-[10px]", children: detail })), icon ? (jsxRuntime.jsx("span", { className: "tw-flex tw-items-center tw-justify-center tw-px-[3px] tw-py-2", children: icon })) : null] })))
|
|
18838
|
+
: "tw-flex", isDetailInteractive && "hover:tw-bg-material-light-thin", detailButtonClassName), children: [!!detail && (jsxRuntime.jsx(CaptionText, { className: "min-tw-w-4 min-tw-h-4 tw-px-squid-xxs tw-leading-[10px]", children: detail })), icon ? (jsxRuntime.jsx("span", { className: "tw-flex tw-items-center tw-justify-center tw-px-[3px] tw-py-2", children: icon })) : null] }))), !!dropdownMenuContent && (jsxRuntime.jsx(ListItemActionsButton, { ref: openDropdownButtonRef, onClick: (e) => {
|
|
18839
|
+
e.stopPropagation();
|
|
18840
|
+
isDropdownOpen ? closeDropdown() : openDropdown();
|
|
18841
|
+
}, isActive: isDropdownOpen, className: "tw-z-20 peer-hover/list-item:tw-opacity-100" }))] })), isDropdownOpen && !!dropdownMenuContent ? (jsxRuntime.jsx(DropdownMenu, { menuRef: menuRef, isHidden: !dropdownStyles, className: cn(!!dropdownStyles &&
|
|
18752
18842
|
dropdownPositionClassMap$1[dropdownStyles.position]), dropdownRef: dropdownRef, children: dropdownMenuContent })) : null] })));
|
|
18753
18843
|
}
|
|
18754
|
-
const ListItemActionsButton = React$1.forwardRef((
|
|
18755
|
-
|
|
18756
|
-
|
|
18844
|
+
const ListItemActionsButton = React$1.forwardRef((props, ref) => {
|
|
18845
|
+
return (jsxRuntime.jsx("button", Object.assign({}, props, { ref: ref, className: cn("tw-peer tw-absolute tw-right-squid-s tw-top-squid-xxs tw-flex tw-h-squid-xl tw-w-squid-xl tw-items-center tw-justify-center tw-rounded-squid-xs tw-p-2 tw-text-grey-300 hover:tw-bg-material-light-thin hover:tw-opacity-100 focus-visible:tw-opacity-100", props.isActive
|
|
18846
|
+
? "tw-bg-material-light-thin tw-opacity-100"
|
|
18847
|
+
: "tw-opacity-0", props.className), children: jsxRuntime.jsx(DotGrid1x3HorizontalIcon, { size: "24" }) })));
|
|
18757
18848
|
});
|
|
18758
18849
|
|
|
18759
18850
|
const dropdownPositionClassMap = {
|
|
@@ -19169,7 +19260,6 @@ const SwapStepsCollapsed = React$1.forwardRef((props, ref) => {
|
|
|
19169
19260
|
// show separator for all steps except the first one
|
|
19170
19261
|
showStepSeparator: index > 0, link: step.link, status: newStepIndex < index ? "pending" : step.status }, index))) }), jsxRuntime.jsx("footer", { className: "tw-flex tw-max-h-[55px] tw-min-h-[55px] tw-w-full tw-justify-center tw-gap-squid-xs tw-self-stretch tw-px-squid-s tw-pb-squid-s", children: jsxRuntime.jsx(Button$1, { size: "md", variant: "secondary", onClick: footerButton === null || footerButton === void 0 ? void 0 : footerButton.onClick, link: footerButton === null || footerButton === void 0 ? void 0 : footerButton.link, label: footerButton === null || footerButton === void 0 ? void 0 : footerButton.label, className: "tw-w-full", containerClassName: "tw-w-full" }) })] }) })] }) }) }));
|
|
19171
19262
|
});
|
|
19172
|
-
SwapStepsCollapsed.displayName = "SwapStepsCollapsed";
|
|
19173
19263
|
|
|
19174
19264
|
const WIDTH_SM = "69";
|
|
19175
19265
|
const HEIGHT_SM = "31";
|
|
@@ -24930,20 +25020,6 @@ function DayPicker(props) {
|
|
|
24930
25020
|
return (jsxRuntime.jsx(RootProvider, __assign({}, props, { children: jsxRuntime.jsx(Root, { initialProps: props }) })));
|
|
24931
25021
|
}
|
|
24932
25022
|
|
|
24933
|
-
function useOnClickOutside(callback) {
|
|
24934
|
-
const ref = React$1.useRef(null);
|
|
24935
|
-
React$1.useEffect(() => {
|
|
24936
|
-
const handleClick = (e) => {
|
|
24937
|
-
if (ref.current && !ref.current.contains(e.target)) {
|
|
24938
|
-
callback();
|
|
24939
|
-
}
|
|
24940
|
-
};
|
|
24941
|
-
document.addEventListener("click", handleClick);
|
|
24942
|
-
return () => document.removeEventListener("click", handleClick);
|
|
24943
|
-
}, [callback]);
|
|
24944
|
-
return { ref };
|
|
24945
|
-
}
|
|
24946
|
-
|
|
24947
25023
|
function TransactionFilters({ chainType, setChainType, chain, setChain, fromDate, setFromDate, toDate, setToDate, status = [], setStatus, chains, }) {
|
|
24948
25024
|
return (jsxRuntime.jsxs("div", { className: "tw-flex tw-flex-col", children: [jsxRuntime.jsx(FilterSection, { title: "Chain", children: jsxRuntime.jsx(ChainsFilter, { chainType: chainType, setChainType: setChainType, chain: chain, setChain: setChain, chains: chains }) }), jsxRuntime.jsx(FilterSection, { title: "Date", initCollapsed: true, children: jsxRuntime.jsx(DateFilters, { fromDate: fromDate, setFromDate: setFromDate, toDate: toDate, setToDate: setToDate }) }), jsxRuntime.jsx(FilterSection, { title: "Status", initCollapsed: true, children: jsxRuntime.jsx("div", { className: "tw-flex tw-flex-col tw-gap-squid-xxs", children: ["success", "ongoing", "error"].map((s) => (jsxRuntime.jsx(StatusFilter, { status: s, selected: status.length === 0 || status.includes(s), onChange: () => setStatus(arrayToggle(status, s)), icon: s === "ongoing" ? jsxRuntime.jsx(DotGrid1x3HorizontalIcon, {}) : undefined }, s))) }) })] }));
|
|
24949
25025
|
}
|
|
@@ -25125,9 +25201,7 @@ function PopLayout(props) {
|
|
|
25125
25201
|
}
|
|
25126
25202
|
|
|
25127
25203
|
function Toast({ headerContent, actionsContent, description, chipLabel, title, }) {
|
|
25128
|
-
return (jsxRuntime.jsxs(Menu, { contentClassName: "tw-px-squid-m tw-pb-squid-s tw-pt-squid-xxs",
|
|
25129
|
-
className: "tw-flex tw-flex-col tw-items-center tw-justify-center tw-gap-squid-xs",
|
|
25130
|
-
}, rounded: "sm", children: [headerContent, jsxRuntime.jsx("header", { className: "tw-flex tw-flex-col tw-items-center tw-justify-center tw-self-stretch tw-px-0 tw-py-squid-xxs", children: jsxRuntime.jsx(BodyText, { size: "small", className: "tw-text-grey-100", children: title }) }), jsxRuntime.jsx(CaptionText, { className: "tw-text-center tw-text-material-light-thick", children: description }), jsxRuntime.jsx("menu", { className: "tw-flex tw-flex-col tw-items-center tw-justify-center tw-gap-squid-xs tw-self-stretch tw-pt-squid-xs", children: actionsContent }), chipLabel && (jsxRuntime.jsx(Chip, { label: chipLabel, className: "tw-absolute tw-right-squid-xs tw-top-squid-xs" }))] }));
|
|
25204
|
+
return (jsxRuntime.jsxs(Menu, { contentClassName: "tw-px-squid-m tw-pb-squid-s tw-pt-squid-xxs", contentWrapperClassName: "tw-flex tw-flex-col tw-items-center tw-justify-center tw-gap-squid-xs", rounded: "sm", children: [headerContent, jsxRuntime.jsx("header", { className: "tw-flex tw-flex-col tw-items-center tw-justify-center tw-self-stretch tw-px-0 tw-py-squid-xxs", children: jsxRuntime.jsx(BodyText, { size: "small", className: "tw-text-grey-100", children: title }) }), jsxRuntime.jsx(CaptionText, { className: "tw-text-center tw-text-material-light-thick", children: description }), jsxRuntime.jsx("menu", { className: "tw-flex tw-flex-col tw-items-center tw-justify-center tw-gap-squid-xs tw-self-stretch tw-pt-squid-xs", children: actionsContent }), chipLabel && (jsxRuntime.jsx(Chip, { label: chipLabel, className: "tw-absolute tw-right-squid-xs tw-top-squid-xs" }))] }));
|
|
25131
25205
|
}
|
|
25132
25206
|
|
|
25133
25207
|
var lib = {};
|
|
@@ -26241,7 +26315,10 @@ const tooltipThresholdPaddingMap = {
|
|
|
26241
26315
|
xl: "40px",
|
|
26242
26316
|
xxl: "60px",
|
|
26243
26317
|
};
|
|
26244
|
-
const TooltipContainer = (
|
|
26318
|
+
const TooltipContainer = (_a) => {
|
|
26319
|
+
var { className } = _a, props = __rest$1(_a, ["className"]);
|
|
26320
|
+
return (jsxRuntime.jsx("div", Object.assign({}, props, { className: cn("tw-relative", className) })));
|
|
26321
|
+
};
|
|
26245
26322
|
const TooltipTriggerWrapper = (_a) => {
|
|
26246
26323
|
var { elementRef } = _a, props = __rest$1(_a, ["elementRef"]);
|
|
26247
26324
|
return jsxRuntime.jsx("div", Object.assign({}, props, { ref: elementRef }));
|
|
@@ -26432,10 +26509,10 @@ function NumericInput(_a) {
|
|
|
26432
26509
|
}
|
|
26433
26510
|
}, [forcedAmount]);
|
|
26434
26511
|
const updateInputValue = React$1.useCallback((newValue) => {
|
|
26435
|
-
const safeNewValue =
|
|
26512
|
+
const safeNewValue = trimExtraDecimals(newValue, token.decimals);
|
|
26436
26513
|
const formattedAmount = userInputType === UserInputType.TOKEN
|
|
26437
26514
|
? safeNewValue
|
|
26438
|
-
:
|
|
26515
|
+
: convertTokenAmountToUSD(safeNewValue, token.price, maxUsdDecimals);
|
|
26439
26516
|
setInputValue(formattedAmount);
|
|
26440
26517
|
}, [userInputType, token.price, direction, token.decimals]);
|
|
26441
26518
|
const onBalanceButtonClick = React$1.useCallback(() => {
|
|
@@ -26448,7 +26525,7 @@ function NumericInput(_a) {
|
|
|
26448
26525
|
onAmountChange,
|
|
26449
26526
|
]);
|
|
26450
26527
|
const handleInputChange = (e) => {
|
|
26451
|
-
|
|
26528
|
+
let value = e.target.value.replace(/,/g, "."); // Replace commas with dots
|
|
26452
26529
|
const maxDecimalsForInputType = userInputType === UserInputType.TOKEN ? token.decimals : maxUsdDecimals;
|
|
26453
26530
|
const isValidAmount = new RegExp(`^\\d*\\.?\\d{0,${maxDecimalsForInputType}}$`).test(value);
|
|
26454
26531
|
if (isValidAmount) {
|
|
@@ -26469,8 +26546,8 @@ function NumericInput(_a) {
|
|
|
26469
26546
|
var _a;
|
|
26470
26547
|
if (inputValue !== "") {
|
|
26471
26548
|
const convertedAmount = userInputType === UserInputType.TOKEN
|
|
26472
|
-
?
|
|
26473
|
-
:
|
|
26549
|
+
? convertTokenAmountToUSD(inputValue, token.price, maxUsdDecimals)
|
|
26550
|
+
: convertUSDToTokenAmount(inputValue, token.price, token.decimals);
|
|
26474
26551
|
setInputValue(convertedAmount);
|
|
26475
26552
|
}
|
|
26476
26553
|
setUserInputType((prevMode) => prevMode === UserInputType.TOKEN
|
|
@@ -26487,7 +26564,7 @@ function NumericInput(_a) {
|
|
|
26487
26564
|
isUsdAmountVerySmall: false,
|
|
26488
26565
|
};
|
|
26489
26566
|
if (userInputType === UserInputType.TOKEN) {
|
|
26490
|
-
const usdRawAmount =
|
|
26567
|
+
const usdRawAmount = convertTokenAmountToUSD(amount, token.price, maxUsdDecimals);
|
|
26491
26568
|
const tokenRawAmount = amount;
|
|
26492
26569
|
const isTokenAmountVerySmall = !!tokenRawAmount &&
|
|
26493
26570
|
RegExpNonZeroValue.test(tokenRawAmount) &&
|
|
@@ -26504,7 +26581,7 @@ function NumericInput(_a) {
|
|
|
26504
26581
|
};
|
|
26505
26582
|
}
|
|
26506
26583
|
else {
|
|
26507
|
-
const tokenRawAmount =
|
|
26584
|
+
const tokenRawAmount = convertUSDToTokenAmount(amount, token.price, token.decimals);
|
|
26508
26585
|
const usdRawAmount = amount;
|
|
26509
26586
|
const isUsdAmountVerySmall = (!!usdRawAmount &&
|
|
26510
26587
|
RegExpNonZeroValue.test(usdRawAmount) &&
|
|
@@ -26528,18 +26605,14 @@ function NumericInput(_a) {
|
|
|
26528
26605
|
return "0";
|
|
26529
26606
|
if (userInputType === UserInputType.TOKEN) {
|
|
26530
26607
|
if (direction === "from") {
|
|
26531
|
-
return
|
|
26532
|
-
includeSign: false,
|
|
26533
|
-
});
|
|
26608
|
+
return formatAmount(convertTokenAmountToUSD(inputValue, token.price, maxUsdDecimals));
|
|
26534
26609
|
}
|
|
26535
26610
|
else {
|
|
26536
|
-
return
|
|
26537
|
-
includeSign: false,
|
|
26538
|
-
});
|
|
26611
|
+
return formatAmount((_a = inputModeButton === null || inputModeButton === void 0 ? void 0 : inputModeButton.amountUsd) !== null && _a !== void 0 ? _a : "0");
|
|
26539
26612
|
}
|
|
26540
26613
|
}
|
|
26541
26614
|
else {
|
|
26542
|
-
return
|
|
26615
|
+
return formatAmount(convertUSDToTokenAmount(inputValue, token.price, token.decimals));
|
|
26543
26616
|
}
|
|
26544
26617
|
}, [
|
|
26545
26618
|
inputValue,
|
|
@@ -26556,7 +26629,7 @@ function NumericInput(_a) {
|
|
|
26556
26629
|
: "tw-text-grey-300";
|
|
26557
26630
|
const BalanceChipTag = balanceChipClickable ? "button" : "div";
|
|
26558
26631
|
const balanceFormatted = React$1.useMemo(() => {
|
|
26559
|
-
return
|
|
26632
|
+
return formatAmount(balance !== null && balance !== void 0 ? balance : "0");
|
|
26560
26633
|
}, [balance]);
|
|
26561
26634
|
const containerClassname = "tw-px-squid-xs tw-pb-[15px] tw-pt-[5px] tw-text-heading-small tw-font-heading-regular mobile-lg:tw-px-squid-m tw-relative tw-h-[65px] mobile-sm-height:tw-h-[75px]";
|
|
26562
26635
|
const inputRef = React$1.useRef(null);
|
|
@@ -61958,7 +62031,7 @@ const getSwapProgressTitle = ({ fromToken, toToken, swapState, }) => {
|
|
|
61958
62031
|
return "Needs gas on destination";
|
|
61959
62032
|
}
|
|
61960
62033
|
};
|
|
61961
|
-
const getSwapProgressDescriptions = ({ swapState, toAmount, toChain, toToken, toAddressFormatted,
|
|
62034
|
+
const getSwapProgressDescriptions = ({ swapState, toAmount, toChain, toToken, toAddressFormatted, }) => {
|
|
61962
62035
|
switch (swapState) {
|
|
61963
62036
|
case SwapState.CONFIRM: {
|
|
61964
62037
|
return "Authenticate the transaction in your wallet.";
|
|
@@ -61979,7 +62052,7 @@ const getSwapProgressDescriptions = ({ swapState, toAmount, toChain, toToken, to
|
|
|
61979
62052
|
return "You declined the transaction in your wallet.";
|
|
61980
62053
|
}
|
|
61981
62054
|
case SwapState.PARTIAL_SUCCESS: {
|
|
61982
|
-
return `You received a refund of
|
|
62055
|
+
return `You received a refund of axlUSDC to your wallet ${toAddressFormatted} on ${toChain === null || toChain === void 0 ? void 0 : toChain.networkName}.`;
|
|
61983
62056
|
}
|
|
61984
62057
|
case SwapState.NEEDS_GAS: {
|
|
61985
62058
|
return "Add gas to the transaction via Axelarscan to complete the swap";
|
|
@@ -61996,7 +62069,7 @@ const swapProgressButtonTexts = {
|
|
|
61996
62069
|
[SwapState.PARTIAL_SUCCESS]: "Cancel",
|
|
61997
62070
|
[SwapState.NEEDS_GAS]: "Go to Axelarscan",
|
|
61998
62071
|
};
|
|
61999
|
-
function SwapProgressView({ steps, isOpen = true, handleClose, handleComplete, socialLink, supportLink, fromAmount, fromChain, fromToken, toAmount, toChain, toToken, fromAddressFormatted, toAddressFormatted, swapState, estimatedTimeToComplete, footerButton,
|
|
62072
|
+
function SwapProgressView({ steps, isOpen = true, handleClose, handleComplete, socialLink, supportLink, fromAmount, fromChain, fromToken, toAmount, toChain, toToken, fromAddressFormatted, toAddressFormatted, swapState, estimatedTimeToComplete, footerButton, }) {
|
|
62000
62073
|
const [showSwapInfoSection, setShowSwapInfoSection] = React$1.useState(true);
|
|
62001
62074
|
const isFirstRenderRef = React$1.useRef(true);
|
|
62002
62075
|
const { timer, stopTimer, startTimer } = useTimer({
|
|
@@ -62026,7 +62099,6 @@ function SwapProgressView({ steps, isOpen = true, handleClose, handleComplete, s
|
|
|
62026
62099
|
toChain,
|
|
62027
62100
|
toToken,
|
|
62028
62101
|
toAddressFormatted,
|
|
62029
|
-
refundTokenSymbol,
|
|
62030
62102
|
});
|
|
62031
62103
|
return {
|
|
62032
62104
|
headerTitle,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ComponentProps } from "react";
|
|
2
|
-
export declare function PipeSeparator(props: ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function PipeSeparator({ className, ...props }: ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function useOnClickOutside(callback: () => void): {
|
|
3
|
-
ref:
|
|
1
|
+
import { RefObject } from "react";
|
|
2
|
+
export declare function useOnClickOutside(callback: () => void, externalRef?: RefObject<HTMLElement>): {
|
|
3
|
+
ref: RefObject<HTMLElement>;
|
|
4
4
|
};
|
|
@@ -3,13 +3,14 @@ import { SwapStepsCollapsedFooterButton } from "../layout/SwapStepsCollapsed";
|
|
|
3
3
|
type ChainData = {
|
|
4
4
|
networkName: string;
|
|
5
5
|
logoUrl: string;
|
|
6
|
+
bgColor: string;
|
|
6
7
|
};
|
|
7
8
|
type Token = {
|
|
8
9
|
symbol: string;
|
|
9
10
|
logoUrl: string;
|
|
10
11
|
bgColor: string;
|
|
11
12
|
};
|
|
12
|
-
export declare function SwapProgressView({ steps, isOpen, handleClose, handleComplete, socialLink, supportLink, fromAmount, fromChain, fromToken, toAmount, toChain, toToken, fromAddressFormatted, toAddressFormatted, swapState, estimatedTimeToComplete, footerButton,
|
|
13
|
+
export declare function SwapProgressView({ steps, isOpen, handleClose, handleComplete, socialLink, supportLink, fromAmount, fromChain, fromToken, toAmount, toChain, toToken, fromAddressFormatted, toAddressFormatted, swapState, estimatedTimeToComplete, footerButton, }: {
|
|
13
14
|
steps: SwapStep[];
|
|
14
15
|
handleClose?: (swapState: SwapState) => void;
|
|
15
16
|
handleComplete?: () => void;
|
|
@@ -27,6 +28,5 @@ export declare function SwapProgressView({ steps, isOpen, handleClose, handleCom
|
|
|
27
28
|
swapState: SwapState;
|
|
28
29
|
estimatedTimeToComplete?: string;
|
|
29
30
|
footerButton?: SwapStepsCollapsedFooterButton;
|
|
30
|
-
refundTokenSymbol?: string;
|
|
31
31
|
}): import("react/jsx-runtime").JSX.Element;
|
|
32
32
|
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert token amount to USD
|
|
3
|
+
* @param {string|number} tokenAmount - The amount of tokens
|
|
4
|
+
* @param {string|number} tokenPrice - The price of one token in USD
|
|
5
|
+
* @returns {BigNumber} - The equivalent amount in USD
|
|
6
|
+
*/
|
|
7
|
+
export declare function convertTokenAmountToUSD(tokenAmount: string | number, tokenPrice: string | number, maxDecimals?: number): string;
|
|
8
|
+
/**
|
|
9
|
+
* Convert USD to token amount
|
|
10
|
+
* @param {string|number} usdAmount - The amount in USD
|
|
11
|
+
* @param {string|number} tokenPrice - The price of one token in USD
|
|
12
|
+
* @param {number} maxDecimals - The maximum number of decimals
|
|
13
|
+
* @returns {BigNumber} - The equivalent amount of tokens
|
|
14
|
+
*/
|
|
15
|
+
export declare function convertUSDToTokenAmount(usdAmount: string | number, tokenPrice: string | number, maxDecimals: number): string;
|
|
16
|
+
/**
|
|
17
|
+
* Formats a number to the en-US number format
|
|
18
|
+
*
|
|
19
|
+
* @param amount - The number to format
|
|
20
|
+
* @returns The formatted string
|
|
21
|
+
*/
|
|
22
|
+
export declare function formatAmount(amount: number | bigint | string): string;
|
|
23
|
+
export declare function trimExtraDecimals(value: string, maxDecimals?: number): string;
|
|
@@ -13,11 +13,11 @@ export type DescriptionBlock = {
|
|
|
13
13
|
value: string;
|
|
14
14
|
rounded?: boolean;
|
|
15
15
|
};
|
|
16
|
-
export
|
|
16
|
+
export type SwapStep = {
|
|
17
17
|
descriptionBlocks: DescriptionBlock[];
|
|
18
18
|
link?: string;
|
|
19
19
|
status: ActionStatus;
|
|
20
|
-
}
|
|
20
|
+
};
|
|
21
21
|
export declare enum SwapState {
|
|
22
22
|
CONFIRM = 0,
|
|
23
23
|
PROGRESS = 1,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export type { SquidTheme } from "./config";
|
|
2
2
|
export * from "./utils";
|
|
3
|
-
export type { SwapState, ThemeType, SwapStep, HistoryItemStatus, ActionStatus, AssetsButtonVariant,
|
|
3
|
+
export type { SwapState, ThemeType, SwapStep, HistoryItemStatus, ActionStatus, AssetsButtonVariant, } from "./components";
|
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import * as React$1 from 'react';
|
|
3
3
|
import React__default$1, { useState, createContext, useContext, useMemo, useRef, useEffect, useLayoutEffect, useInsertionEffect, useCallback, forwardRef, Fragment as Fragment$1, createElement, useId as useId$1, Component, cloneElement, Children, isValidElement, useImperativeHandle } from 'react';
|
|
4
|
-
import { trimExtraDecimals, convertTokenAmountToUSD, formatUsdAmount, formatTokenAmount, convertUSDToTokenAmount } from '@0xsquid/react-hooks';
|
|
5
4
|
|
|
6
5
|
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
|
|
7
6
|
|
|
@@ -6576,6 +6575,59 @@ var debounce_1 = debounce;
|
|
|
6576
6575
|
|
|
6577
6576
|
var debounce$1 = /*@__PURE__*/getDefaultExportFromCjs(debounce_1);
|
|
6578
6577
|
|
|
6578
|
+
/**
|
|
6579
|
+
* Convert token amount to USD
|
|
6580
|
+
* @param {string|number} tokenAmount - The amount of tokens
|
|
6581
|
+
* @param {string|number} tokenPrice - The price of one token in USD
|
|
6582
|
+
* @returns {BigNumber} - The equivalent amount in USD
|
|
6583
|
+
*/
|
|
6584
|
+
function convertTokenAmountToUSD(tokenAmount, tokenPrice, maxDecimals = 2) {
|
|
6585
|
+
if (!tokenAmount || !tokenPrice)
|
|
6586
|
+
return "";
|
|
6587
|
+
const amount = new BigNumber(tokenAmount);
|
|
6588
|
+
const price = new BigNumber(tokenPrice);
|
|
6589
|
+
return amount.multipliedBy(price).decimalPlaces(maxDecimals).toString();
|
|
6590
|
+
}
|
|
6591
|
+
/**
|
|
6592
|
+
* Convert USD to token amount
|
|
6593
|
+
* @param {string|number} usdAmount - The amount in USD
|
|
6594
|
+
* @param {string|number} tokenPrice - The price of one token in USD
|
|
6595
|
+
* @param {number} maxDecimals - The maximum number of decimals
|
|
6596
|
+
* @returns {BigNumber} - The equivalent amount of tokens
|
|
6597
|
+
*/
|
|
6598
|
+
function convertUSDToTokenAmount(usdAmount, tokenPrice, maxDecimals) {
|
|
6599
|
+
if (!usdAmount || !tokenPrice || !maxDecimals)
|
|
6600
|
+
return "0";
|
|
6601
|
+
const amount = new BigNumber(usdAmount);
|
|
6602
|
+
const price = new BigNumber(tokenPrice);
|
|
6603
|
+
return amount.dividedBy(price).decimalPlaces(maxDecimals).toString();
|
|
6604
|
+
}
|
|
6605
|
+
const INTL_NUMBER_FORMATTER = new Intl.NumberFormat("en-US", {
|
|
6606
|
+
minimumFractionDigits: 2,
|
|
6607
|
+
maximumFractionDigits: 5,
|
|
6608
|
+
});
|
|
6609
|
+
/**
|
|
6610
|
+
* Formats a number to the en-US number format
|
|
6611
|
+
*
|
|
6612
|
+
* @param amount - The number to format
|
|
6613
|
+
* @returns The formatted string
|
|
6614
|
+
*/
|
|
6615
|
+
function formatAmount(amount) {
|
|
6616
|
+
return INTL_NUMBER_FORMATTER.format(amount);
|
|
6617
|
+
}
|
|
6618
|
+
function trimExtraDecimals(value, maxDecimals) {
|
|
6619
|
+
var _a;
|
|
6620
|
+
const split = value.split(".");
|
|
6621
|
+
if (split.length > 1) {
|
|
6622
|
+
const decimals = (_a = split[1]) !== null && _a !== void 0 ? _a : "";
|
|
6623
|
+
if (maxDecimals && decimals.length > maxDecimals) {
|
|
6624
|
+
const newValue = `${split[0]}.${decimals.slice(0, maxDecimals)}`;
|
|
6625
|
+
return newValue;
|
|
6626
|
+
}
|
|
6627
|
+
}
|
|
6628
|
+
return value;
|
|
6629
|
+
}
|
|
6630
|
+
|
|
6579
6631
|
function SwapInputsIcon() {
|
|
6580
6632
|
return (jsxs("svg", { width: "20", height: "21", viewBox: "0 0 20 21", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsx("g", { clipPath: "url(#clip0_40_7936)", children: jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M20 10.5C20 16.0228 15.5228 20.5 10 20.5C4.47715 20.5 0 16.0228 0 10.5C0 4.97715 4.47715 0.5 10 0.5C15.5228 0.5 20 4.97715 20 10.5ZM8.38268 4.57612C8.75636 4.7309 9 5.09554 9 5.5V15.5C9 16.0523 8.55228 16.5 8 16.5C7.44772 16.5 7 16.0523 7 15.5V7.91421L5.70711 9.20711C5.31658 9.59763 4.68342 9.59763 4.29289 9.20711C3.90237 8.81658 3.90237 8.18342 4.29289 7.79289L7.29289 4.79289C7.57889 4.5069 8.00901 4.42134 8.38268 4.57612ZM11 15.5C11 15.9045 11.2436 16.2691 11.6173 16.4239C11.991 16.5787 12.4211 16.4931 12.7071 16.2071L15.7071 13.2071C16.0976 12.8166 16.0976 12.1834 15.7071 11.7929C15.3166 11.4024 14.6834 11.4024 14.2929 11.7929L13 13.0858V5.5C13 4.94771 12.5523 4.5 12 4.5C11.4477 4.5 11 4.94771 11 5.5V15.5Z", fill: "currentColor" }) }), jsx("defs", { children: jsx("clipPath", { id: "clip0_40_7936", children: jsx("rect", { width: "20", height: "20", fill: "white", transform: "translate(0 0.5)" }) }) })] }));
|
|
6581
6633
|
}
|
|
@@ -17797,8 +17849,9 @@ function NavigationBar(_a) {
|
|
|
17797
17849
|
: "tw-flex"), children: jsx(HeadingText, { size: "small", children: title }) })) : null] })));
|
|
17798
17850
|
}
|
|
17799
17851
|
|
|
17800
|
-
function PipeSeparator(
|
|
17801
|
-
|
|
17852
|
+
function PipeSeparator(_a) {
|
|
17853
|
+
var { className } = _a, props = __rest$1(_a, ["className"]);
|
|
17854
|
+
return (jsx("div", Object.assign({}, props, { className: cn("tw-h-[0.8em] tw-w-[2px] tw-rounded-full tw-bg-[currentColor]", className) })));
|
|
17802
17855
|
}
|
|
17803
17856
|
|
|
17804
17857
|
function CollapsibleMenu({ children, menuRef, isOpen, transitionDuration, size, className, }) {
|
|
@@ -18673,6 +18726,21 @@ function DropdownMenuItemWithSubmenu(_a) {
|
|
|
18673
18726
|
}, children: submenu })) })) }));
|
|
18674
18727
|
}
|
|
18675
18728
|
|
|
18729
|
+
function useOnClickOutside(callback, externalRef) {
|
|
18730
|
+
const internalRef = useRef(null);
|
|
18731
|
+
const ref = externalRef || internalRef;
|
|
18732
|
+
useEffect(() => {
|
|
18733
|
+
const handleMouseDown = (e) => {
|
|
18734
|
+
if (ref.current && !ref.current.contains(e.target)) {
|
|
18735
|
+
callback();
|
|
18736
|
+
}
|
|
18737
|
+
};
|
|
18738
|
+
document.addEventListener("mousedown", handleMouseDown);
|
|
18739
|
+
return () => document.removeEventListener("mousedown", handleMouseDown);
|
|
18740
|
+
}, [callback, ref]);
|
|
18741
|
+
return { ref };
|
|
18742
|
+
}
|
|
18743
|
+
|
|
18676
18744
|
const dropdownPositionClassMap$1 = {
|
|
18677
18745
|
top: "tw-right-full tw-bottom-[50px]",
|
|
18678
18746
|
bottom: "tw-right-full tw-top-[50px]",
|
|
@@ -18688,6 +18756,14 @@ const collapsedListItemClassMap = {
|
|
|
18688
18756
|
};
|
|
18689
18757
|
function ListItem(_a) {
|
|
18690
18758
|
var { itemTitle, mainImageUrl, subtitle, subtitleOnHover, detail, icon, secondaryImageUrl, placeholderImageUrl, size = "large", mainIcon, className, isSelected, onDetailClick, showDetailOnHoverOnly, rounded = false, detailButtonClassName, loading, containerProps, compactOnMobile, extraPadding = true, itemsContainerRef, dropdownMenuContent } = _a, props = __rest$1(_a, ["itemTitle", "mainImageUrl", "subtitle", "subtitleOnHover", "detail", "icon", "secondaryImageUrl", "placeholderImageUrl", "size", "mainIcon", "className", "isSelected", "onDetailClick", "showDetailOnHoverOnly", "rounded", "detailButtonClassName", "loading", "containerProps", "compactOnMobile", "extraPadding", "itemsContainerRef", "dropdownMenuContent"]);
|
|
18759
|
+
const { isDropdownOpen, dropdownRef, openDropdown, closeDropdown, openDropdownButtonRef, itemRef, menuRef, dropdownStyles, } = useDropdownMenu({
|
|
18760
|
+
itemsContainerRef,
|
|
18761
|
+
});
|
|
18762
|
+
useOnClickOutside(() => {
|
|
18763
|
+
if (isDropdownOpen) {
|
|
18764
|
+
closeDropdown();
|
|
18765
|
+
}
|
|
18766
|
+
}, itemRef);
|
|
18691
18767
|
const subtitleClassName = cn("tw-h-[14px] tw-max-w-full tw-truncate !tw-leading-[16px] tw-text-grey-500", compactOnMobile ? "tw-hidden mobile-lg:tw-block" : "tw-block");
|
|
18692
18768
|
// 'small' variant does not have detail
|
|
18693
18769
|
const showDetail = size === "large" && (!!detail || !!icon || showDetailOnHoverOnly);
|
|
@@ -18718,22 +18794,37 @@ function ListItem(_a) {
|
|
|
18718
18794
|
const isInteractive = !!props.onClick;
|
|
18719
18795
|
const ItemTag = isInteractive ? "button" : "div";
|
|
18720
18796
|
const itemProps = isInteractive ? props : {};
|
|
18721
|
-
const
|
|
18722
|
-
|
|
18723
|
-
|
|
18724
|
-
|
|
18797
|
+
const handleInteraction = (e) => {
|
|
18798
|
+
var _a;
|
|
18799
|
+
e.preventDefault();
|
|
18800
|
+
e.stopPropagation();
|
|
18801
|
+
if ("onClick" in props && e.type === "click") {
|
|
18802
|
+
(_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
18803
|
+
}
|
|
18804
|
+
};
|
|
18805
|
+
// Handle List item click, close dropdown if it's open
|
|
18806
|
+
const handleItemClick = (e) => {
|
|
18807
|
+
handleInteraction(e);
|
|
18808
|
+
if (isDropdownOpen)
|
|
18809
|
+
closeDropdown();
|
|
18810
|
+
};
|
|
18811
|
+
return (jsxs("li", Object.assign({}, containerProps, { ref: itemRef, className: cn("tw-highlight-adjacent tw-relative tw-flex tw-max-w-full tw-bg-grey-900 tw-text-grey-300", listItemSizeMap[size], extraPadding && "tw-px-squid-xs", compactOnMobile
|
|
18725
18812
|
? `${collapsedListItemClassMap[size]} mobile-lg:tw-w-full`
|
|
18726
|
-
: "tw-w-full", className), children: [jsxs(ItemTag, Object.assign({}, itemProps, { className: cn("tw-group/list-item tw-peer/list-item tw-relative tw-flex tw-w-full tw-max-w-full tw-items-center tw-justify-start tw-gap-squid-xs tw-rounded-squid-s tw-px-squid-xs tw-py-squid-xxs", (isSelected || isDropdownOpen) && "tw-bg-material-light-thin", isInteractive && "hover:tw-bg-material-light-thin"), children: [size === "large" ? (jsx("div", { className: "tw-h-10 tw-w-10", children: mainIcon
|
|
18813
|
+
: "tw-w-full", className), children: [jsxs(ItemTag, Object.assign({}, itemProps, { onClick: handleItemClick, className: cn("tw-group/list-item tw-peer/list-item tw-relative tw-flex tw-w-full tw-max-w-full tw-items-center tw-justify-start tw-gap-squid-xs tw-rounded-squid-s tw-px-squid-xs tw-py-squid-xxs", (isSelected || isDropdownOpen) && "tw-bg-material-light-thin", isInteractive && "hover:tw-bg-material-light-thin"), children: [size === "large" ? (jsx("div", { className: "tw-h-10 tw-w-10", children: mainIcon ? (mainIcon) : (jsx(BadgeImage, { extraMarginForBadge: false, imageUrl: mainImageUrl, badgeUrl: secondaryImageUrl, placeholderImageUrl: placeholderImageUrl, size: "md", rounded: rounded })) })) : (jsx("div", { className: "tw-flex tw-min-h-[30px] tw-min-w-[30px] tw-items-center tw-justify-center", children: mainIcon ? (mainIcon) : (jsx("img", { src: mainImageUrl, className: "tw-h-[30px] tw-w-[30px] tw-rounded-squid-xs" })) })), jsxs("div", { className: cn("tw-flex tw-h-[40px] tw-flex-1 tw-flex-col tw-items-start tw-justify-center tw-gap-squid-xxs",
|
|
18727
18814
|
// 'large' variant has extra padding
|
|
18728
18815
|
size === "large" ? "tw-w-[56%] tw-pl-squid-xxs" : "tw-w-[67%]"), children: [typeof itemTitle === "string" ? (jsx(BodyText, { size: "small", className: cn("tw-max-w-full tw-truncate", subtitle && "tw-h-[17px] !tw-leading-[17px]", compactOnMobile ? "tw-hidden mobile-lg:tw-block" : "tw-block"), children: itemTitle })) : (itemTitle), size === "large" &&
|
|
18729
18816
|
((loading === null || loading === void 0 ? void 0 : loading.subtitle) ? (loadingComponent()) : subtitle ? (jsxs(CaptionText, { className: subtitleClassName, children: [subtitleOnHover && (jsx(CaptionText, { className: cn(subtitleClassName, "tw-hidden group-hover/list-item:tw-block"), children: subtitleOnHover })), subtitle] })) : null)] }), showDetail && (jsxs(DetailTag, Object.assign({}, detailProps, { className: cn("tw-flex tw-w-fit tw-items-center tw-justify-center tw-rounded-squid-xs", size === "large" ? "tw-h-squid-xl" : "tw-h-squid-l", showDetailOnHoverOnly
|
|
18730
18817
|
? "tw-opacity-0 hover:tw-opacity-100 focus:tw-opacity-100 group-hover/list-item:tw-opacity-100 group-focus/list-item:tw-opacity-100"
|
|
18731
|
-
: "tw-flex", isDetailInteractive && "hover:tw-bg-material-light-thin", detailButtonClassName), children: [!!detail && (jsx(CaptionText, { className: "min-tw-w-4 min-tw-h-4 tw-px-squid-xxs tw-leading-[10px]", children: detail })), icon ? (jsx("span", { className: "tw-flex tw-items-center tw-justify-center tw-px-[3px] tw-py-2", children: icon })) : null] })))
|
|
18818
|
+
: "tw-flex", isDetailInteractive && "hover:tw-bg-material-light-thin", detailButtonClassName), children: [!!detail && (jsx(CaptionText, { className: "min-tw-w-4 min-tw-h-4 tw-px-squid-xxs tw-leading-[10px]", children: detail })), icon ? (jsx("span", { className: "tw-flex tw-items-center tw-justify-center tw-px-[3px] tw-py-2", children: icon })) : null] }))), !!dropdownMenuContent && (jsx(ListItemActionsButton, { ref: openDropdownButtonRef, onClick: (e) => {
|
|
18819
|
+
e.stopPropagation();
|
|
18820
|
+
isDropdownOpen ? closeDropdown() : openDropdown();
|
|
18821
|
+
}, isActive: isDropdownOpen, className: "tw-z-20 peer-hover/list-item:tw-opacity-100" }))] })), isDropdownOpen && !!dropdownMenuContent ? (jsx(DropdownMenu, { menuRef: menuRef, isHidden: !dropdownStyles, className: cn(!!dropdownStyles &&
|
|
18732
18822
|
dropdownPositionClassMap$1[dropdownStyles.position]), dropdownRef: dropdownRef, children: dropdownMenuContent })) : null] })));
|
|
18733
18823
|
}
|
|
18734
|
-
const ListItemActionsButton = forwardRef((
|
|
18735
|
-
|
|
18736
|
-
|
|
18824
|
+
const ListItemActionsButton = forwardRef((props, ref) => {
|
|
18825
|
+
return (jsx("button", Object.assign({}, props, { ref: ref, className: cn("tw-peer tw-absolute tw-right-squid-s tw-top-squid-xxs tw-flex tw-h-squid-xl tw-w-squid-xl tw-items-center tw-justify-center tw-rounded-squid-xs tw-p-2 tw-text-grey-300 hover:tw-bg-material-light-thin hover:tw-opacity-100 focus-visible:tw-opacity-100", props.isActive
|
|
18826
|
+
? "tw-bg-material-light-thin tw-opacity-100"
|
|
18827
|
+
: "tw-opacity-0", props.className), children: jsx(DotGrid1x3HorizontalIcon, { size: "24" }) })));
|
|
18737
18828
|
});
|
|
18738
18829
|
|
|
18739
18830
|
const dropdownPositionClassMap = {
|
|
@@ -19149,7 +19240,6 @@ const SwapStepsCollapsed = forwardRef((props, ref) => {
|
|
|
19149
19240
|
// show separator for all steps except the first one
|
|
19150
19241
|
showStepSeparator: index > 0, link: step.link, status: newStepIndex < index ? "pending" : step.status }, index))) }), jsx("footer", { className: "tw-flex tw-max-h-[55px] tw-min-h-[55px] tw-w-full tw-justify-center tw-gap-squid-xs tw-self-stretch tw-px-squid-s tw-pb-squid-s", children: jsx(Button$1, { size: "md", variant: "secondary", onClick: footerButton === null || footerButton === void 0 ? void 0 : footerButton.onClick, link: footerButton === null || footerButton === void 0 ? void 0 : footerButton.link, label: footerButton === null || footerButton === void 0 ? void 0 : footerButton.label, className: "tw-w-full", containerClassName: "tw-w-full" }) })] }) })] }) }) }));
|
|
19151
19242
|
});
|
|
19152
|
-
SwapStepsCollapsed.displayName = "SwapStepsCollapsed";
|
|
19153
19243
|
|
|
19154
19244
|
const WIDTH_SM = "69";
|
|
19155
19245
|
const HEIGHT_SM = "31";
|
|
@@ -24910,20 +25000,6 @@ function DayPicker(props) {
|
|
|
24910
25000
|
return (jsx(RootProvider, __assign({}, props, { children: jsx(Root, { initialProps: props }) })));
|
|
24911
25001
|
}
|
|
24912
25002
|
|
|
24913
|
-
function useOnClickOutside(callback) {
|
|
24914
|
-
const ref = useRef(null);
|
|
24915
|
-
useEffect(() => {
|
|
24916
|
-
const handleClick = (e) => {
|
|
24917
|
-
if (ref.current && !ref.current.contains(e.target)) {
|
|
24918
|
-
callback();
|
|
24919
|
-
}
|
|
24920
|
-
};
|
|
24921
|
-
document.addEventListener("click", handleClick);
|
|
24922
|
-
return () => document.removeEventListener("click", handleClick);
|
|
24923
|
-
}, [callback]);
|
|
24924
|
-
return { ref };
|
|
24925
|
-
}
|
|
24926
|
-
|
|
24927
25003
|
function TransactionFilters({ chainType, setChainType, chain, setChain, fromDate, setFromDate, toDate, setToDate, status = [], setStatus, chains, }) {
|
|
24928
25004
|
return (jsxs("div", { className: "tw-flex tw-flex-col", children: [jsx(FilterSection, { title: "Chain", children: jsx(ChainsFilter, { chainType: chainType, setChainType: setChainType, chain: chain, setChain: setChain, chains: chains }) }), jsx(FilterSection, { title: "Date", initCollapsed: true, children: jsx(DateFilters, { fromDate: fromDate, setFromDate: setFromDate, toDate: toDate, setToDate: setToDate }) }), jsx(FilterSection, { title: "Status", initCollapsed: true, children: jsx("div", { className: "tw-flex tw-flex-col tw-gap-squid-xxs", children: ["success", "ongoing", "error"].map((s) => (jsx(StatusFilter, { status: s, selected: status.length === 0 || status.includes(s), onChange: () => setStatus(arrayToggle(status, s)), icon: s === "ongoing" ? jsx(DotGrid1x3HorizontalIcon, {}) : undefined }, s))) }) })] }));
|
|
24929
25005
|
}
|
|
@@ -25105,9 +25181,7 @@ function PopLayout(props) {
|
|
|
25105
25181
|
}
|
|
25106
25182
|
|
|
25107
25183
|
function Toast({ headerContent, actionsContent, description, chipLabel, title, }) {
|
|
25108
|
-
return (jsxs(Menu, { contentClassName: "tw-px-squid-m tw-pb-squid-s tw-pt-squid-xxs",
|
|
25109
|
-
className: "tw-flex tw-flex-col tw-items-center tw-justify-center tw-gap-squid-xs",
|
|
25110
|
-
}, rounded: "sm", children: [headerContent, jsx("header", { className: "tw-flex tw-flex-col tw-items-center tw-justify-center tw-self-stretch tw-px-0 tw-py-squid-xxs", children: jsx(BodyText, { size: "small", className: "tw-text-grey-100", children: title }) }), jsx(CaptionText, { className: "tw-text-center tw-text-material-light-thick", children: description }), jsx("menu", { className: "tw-flex tw-flex-col tw-items-center tw-justify-center tw-gap-squid-xs tw-self-stretch tw-pt-squid-xs", children: actionsContent }), chipLabel && (jsx(Chip, { label: chipLabel, className: "tw-absolute tw-right-squid-xs tw-top-squid-xs" }))] }));
|
|
25184
|
+
return (jsxs(Menu, { contentClassName: "tw-px-squid-m tw-pb-squid-s tw-pt-squid-xxs", contentWrapperClassName: "tw-flex tw-flex-col tw-items-center tw-justify-center tw-gap-squid-xs", rounded: "sm", children: [headerContent, jsx("header", { className: "tw-flex tw-flex-col tw-items-center tw-justify-center tw-self-stretch tw-px-0 tw-py-squid-xxs", children: jsx(BodyText, { size: "small", className: "tw-text-grey-100", children: title }) }), jsx(CaptionText, { className: "tw-text-center tw-text-material-light-thick", children: description }), jsx("menu", { className: "tw-flex tw-flex-col tw-items-center tw-justify-center tw-gap-squid-xs tw-self-stretch tw-pt-squid-xs", children: actionsContent }), chipLabel && (jsx(Chip, { label: chipLabel, className: "tw-absolute tw-right-squid-xs tw-top-squid-xs" }))] }));
|
|
25111
25185
|
}
|
|
25112
25186
|
|
|
25113
25187
|
var lib = {};
|
|
@@ -26221,7 +26295,10 @@ const tooltipThresholdPaddingMap = {
|
|
|
26221
26295
|
xl: "40px",
|
|
26222
26296
|
xxl: "60px",
|
|
26223
26297
|
};
|
|
26224
|
-
const TooltipContainer = (
|
|
26298
|
+
const TooltipContainer = (_a) => {
|
|
26299
|
+
var { className } = _a, props = __rest$1(_a, ["className"]);
|
|
26300
|
+
return (jsx("div", Object.assign({}, props, { className: cn("tw-relative", className) })));
|
|
26301
|
+
};
|
|
26225
26302
|
const TooltipTriggerWrapper = (_a) => {
|
|
26226
26303
|
var { elementRef } = _a, props = __rest$1(_a, ["elementRef"]);
|
|
26227
26304
|
return jsx("div", Object.assign({}, props, { ref: elementRef }));
|
|
@@ -26428,7 +26505,7 @@ function NumericInput(_a) {
|
|
|
26428
26505
|
onAmountChange,
|
|
26429
26506
|
]);
|
|
26430
26507
|
const handleInputChange = (e) => {
|
|
26431
|
-
|
|
26508
|
+
let value = e.target.value.replace(/,/g, "."); // Replace commas with dots
|
|
26432
26509
|
const maxDecimalsForInputType = userInputType === UserInputType.TOKEN ? token.decimals : maxUsdDecimals;
|
|
26433
26510
|
const isValidAmount = new RegExp(`^\\d*\\.?\\d{0,${maxDecimalsForInputType}}$`).test(value);
|
|
26434
26511
|
if (isValidAmount) {
|
|
@@ -26508,18 +26585,14 @@ function NumericInput(_a) {
|
|
|
26508
26585
|
return "0";
|
|
26509
26586
|
if (userInputType === UserInputType.TOKEN) {
|
|
26510
26587
|
if (direction === "from") {
|
|
26511
|
-
return
|
|
26512
|
-
includeSign: false,
|
|
26513
|
-
});
|
|
26588
|
+
return formatAmount(convertTokenAmountToUSD(inputValue, token.price, maxUsdDecimals));
|
|
26514
26589
|
}
|
|
26515
26590
|
else {
|
|
26516
|
-
return
|
|
26517
|
-
includeSign: false,
|
|
26518
|
-
});
|
|
26591
|
+
return formatAmount((_a = inputModeButton === null || inputModeButton === void 0 ? void 0 : inputModeButton.amountUsd) !== null && _a !== void 0 ? _a : "0");
|
|
26519
26592
|
}
|
|
26520
26593
|
}
|
|
26521
26594
|
else {
|
|
26522
|
-
return
|
|
26595
|
+
return formatAmount(convertUSDToTokenAmount(inputValue, token.price, token.decimals));
|
|
26523
26596
|
}
|
|
26524
26597
|
}, [
|
|
26525
26598
|
inputValue,
|
|
@@ -26536,7 +26609,7 @@ function NumericInput(_a) {
|
|
|
26536
26609
|
: "tw-text-grey-300";
|
|
26537
26610
|
const BalanceChipTag = balanceChipClickable ? "button" : "div";
|
|
26538
26611
|
const balanceFormatted = useMemo(() => {
|
|
26539
|
-
return
|
|
26612
|
+
return formatAmount(balance !== null && balance !== void 0 ? balance : "0");
|
|
26540
26613
|
}, [balance]);
|
|
26541
26614
|
const containerClassname = "tw-px-squid-xs tw-pb-[15px] tw-pt-[5px] tw-text-heading-small tw-font-heading-regular mobile-lg:tw-px-squid-m tw-relative tw-h-[65px] mobile-sm-height:tw-h-[75px]";
|
|
26542
26615
|
const inputRef = useRef(null);
|
|
@@ -61938,7 +62011,7 @@ const getSwapProgressTitle = ({ fromToken, toToken, swapState, }) => {
|
|
|
61938
62011
|
return "Needs gas on destination";
|
|
61939
62012
|
}
|
|
61940
62013
|
};
|
|
61941
|
-
const getSwapProgressDescriptions = ({ swapState, toAmount, toChain, toToken, toAddressFormatted,
|
|
62014
|
+
const getSwapProgressDescriptions = ({ swapState, toAmount, toChain, toToken, toAddressFormatted, }) => {
|
|
61942
62015
|
switch (swapState) {
|
|
61943
62016
|
case SwapState.CONFIRM: {
|
|
61944
62017
|
return "Authenticate the transaction in your wallet.";
|
|
@@ -61959,7 +62032,7 @@ const getSwapProgressDescriptions = ({ swapState, toAmount, toChain, toToken, to
|
|
|
61959
62032
|
return "You declined the transaction in your wallet.";
|
|
61960
62033
|
}
|
|
61961
62034
|
case SwapState.PARTIAL_SUCCESS: {
|
|
61962
|
-
return `You received a refund of
|
|
62035
|
+
return `You received a refund of axlUSDC to your wallet ${toAddressFormatted} on ${toChain === null || toChain === void 0 ? void 0 : toChain.networkName}.`;
|
|
61963
62036
|
}
|
|
61964
62037
|
case SwapState.NEEDS_GAS: {
|
|
61965
62038
|
return "Add gas to the transaction via Axelarscan to complete the swap";
|
|
@@ -61976,7 +62049,7 @@ const swapProgressButtonTexts = {
|
|
|
61976
62049
|
[SwapState.PARTIAL_SUCCESS]: "Cancel",
|
|
61977
62050
|
[SwapState.NEEDS_GAS]: "Go to Axelarscan",
|
|
61978
62051
|
};
|
|
61979
|
-
function SwapProgressView({ steps, isOpen = true, handleClose, handleComplete, socialLink, supportLink, fromAmount, fromChain, fromToken, toAmount, toChain, toToken, fromAddressFormatted, toAddressFormatted, swapState, estimatedTimeToComplete, footerButton,
|
|
62052
|
+
function SwapProgressView({ steps, isOpen = true, handleClose, handleComplete, socialLink, supportLink, fromAmount, fromChain, fromToken, toAmount, toChain, toToken, fromAddressFormatted, toAddressFormatted, swapState, estimatedTimeToComplete, footerButton, }) {
|
|
61980
62053
|
const [showSwapInfoSection, setShowSwapInfoSection] = useState(true);
|
|
61981
62054
|
const isFirstRenderRef = useRef(true);
|
|
61982
62055
|
const { timer, stopTimer, startTimer } = useTimer({
|
|
@@ -62006,7 +62079,6 @@ function SwapProgressView({ steps, isOpen = true, handleClose, handleComplete, s
|
|
|
62006
62079
|
toChain,
|
|
62007
62080
|
toToken,
|
|
62008
62081
|
toAddressFormatted,
|
|
62009
|
-
refundTokenSymbol,
|
|
62010
62082
|
});
|
|
62011
62083
|
return {
|
|
62012
62084
|
headerTitle,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ComponentProps } from "react";
|
|
2
|
-
export declare function PipeSeparator(props: ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function PipeSeparator({ className, ...props }: ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function useOnClickOutside(callback: () => void): {
|
|
3
|
-
ref:
|
|
1
|
+
import { RefObject } from "react";
|
|
2
|
+
export declare function useOnClickOutside(callback: () => void, externalRef?: RefObject<HTMLElement>): {
|
|
3
|
+
ref: RefObject<HTMLElement>;
|
|
4
4
|
};
|
|
@@ -3,13 +3,14 @@ import { SwapStepsCollapsedFooterButton } from "../layout/SwapStepsCollapsed";
|
|
|
3
3
|
type ChainData = {
|
|
4
4
|
networkName: string;
|
|
5
5
|
logoUrl: string;
|
|
6
|
+
bgColor: string;
|
|
6
7
|
};
|
|
7
8
|
type Token = {
|
|
8
9
|
symbol: string;
|
|
9
10
|
logoUrl: string;
|
|
10
11
|
bgColor: string;
|
|
11
12
|
};
|
|
12
|
-
export declare function SwapProgressView({ steps, isOpen, handleClose, handleComplete, socialLink, supportLink, fromAmount, fromChain, fromToken, toAmount, toChain, toToken, fromAddressFormatted, toAddressFormatted, swapState, estimatedTimeToComplete, footerButton,
|
|
13
|
+
export declare function SwapProgressView({ steps, isOpen, handleClose, handleComplete, socialLink, supportLink, fromAmount, fromChain, fromToken, toAmount, toChain, toToken, fromAddressFormatted, toAddressFormatted, swapState, estimatedTimeToComplete, footerButton, }: {
|
|
13
14
|
steps: SwapStep[];
|
|
14
15
|
handleClose?: (swapState: SwapState) => void;
|
|
15
16
|
handleComplete?: () => void;
|
|
@@ -27,6 +28,5 @@ export declare function SwapProgressView({ steps, isOpen, handleClose, handleCom
|
|
|
27
28
|
swapState: SwapState;
|
|
28
29
|
estimatedTimeToComplete?: string;
|
|
29
30
|
footerButton?: SwapStepsCollapsedFooterButton;
|
|
30
|
-
refundTokenSymbol?: string;
|
|
31
31
|
}): import("react/jsx-runtime").JSX.Element;
|
|
32
32
|
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert token amount to USD
|
|
3
|
+
* @param {string|number} tokenAmount - The amount of tokens
|
|
4
|
+
* @param {string|number} tokenPrice - The price of one token in USD
|
|
5
|
+
* @returns {BigNumber} - The equivalent amount in USD
|
|
6
|
+
*/
|
|
7
|
+
export declare function convertTokenAmountToUSD(tokenAmount: string | number, tokenPrice: string | number, maxDecimals?: number): string;
|
|
8
|
+
/**
|
|
9
|
+
* Convert USD to token amount
|
|
10
|
+
* @param {string|number} usdAmount - The amount in USD
|
|
11
|
+
* @param {string|number} tokenPrice - The price of one token in USD
|
|
12
|
+
* @param {number} maxDecimals - The maximum number of decimals
|
|
13
|
+
* @returns {BigNumber} - The equivalent amount of tokens
|
|
14
|
+
*/
|
|
15
|
+
export declare function convertUSDToTokenAmount(usdAmount: string | number, tokenPrice: string | number, maxDecimals: number): string;
|
|
16
|
+
/**
|
|
17
|
+
* Formats a number to the en-US number format
|
|
18
|
+
*
|
|
19
|
+
* @param amount - The number to format
|
|
20
|
+
* @returns The formatted string
|
|
21
|
+
*/
|
|
22
|
+
export declare function formatAmount(amount: number | bigint | string): string;
|
|
23
|
+
export declare function trimExtraDecimals(value: string, maxDecimals?: number): string;
|
|
@@ -13,11 +13,11 @@ export type DescriptionBlock = {
|
|
|
13
13
|
value: string;
|
|
14
14
|
rounded?: boolean;
|
|
15
15
|
};
|
|
16
|
-
export
|
|
16
|
+
export type SwapStep = {
|
|
17
17
|
descriptionBlocks: DescriptionBlock[];
|
|
18
18
|
link?: string;
|
|
19
19
|
status: ActionStatus;
|
|
20
|
-
}
|
|
20
|
+
};
|
|
21
21
|
export declare enum SwapState {
|
|
22
22
|
CONFIRM = 0,
|
|
23
23
|
PROGRESS = 1,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export type { SquidTheme } from "./config";
|
|
2
2
|
export * from "./utils";
|
|
3
|
-
export type { SwapState, ThemeType, SwapStep, HistoryItemStatus, ActionStatus, AssetsButtonVariant,
|
|
3
|
+
export type { SwapState, ThemeType, SwapStep, HistoryItemStatus, ActionStatus, AssetsButtonVariant, } from "./components";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/// <reference types="trusted-types" />
|
|
3
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
3
|
import * as react from 'react';
|
|
5
4
|
import react__default, { ReactNode, ComponentProps } from 'react';
|
|
@@ -38,11 +37,11 @@ type DescriptionBlock = {
|
|
|
38
37
|
value: string;
|
|
39
38
|
rounded?: boolean;
|
|
40
39
|
};
|
|
41
|
-
|
|
40
|
+
type SwapStep = {
|
|
42
41
|
descriptionBlocks: DescriptionBlock[];
|
|
43
42
|
link?: string;
|
|
44
43
|
status: ActionStatus;
|
|
45
|
-
}
|
|
44
|
+
};
|
|
46
45
|
declare enum SwapState {
|
|
47
46
|
CONFIRM = 0,
|
|
48
47
|
PROGRESS = 1,
|
|
@@ -1457,7 +1456,7 @@ interface NavigationBarProps extends React.ComponentProps<"nav"> {
|
|
|
1457
1456
|
}
|
|
1458
1457
|
declare function NavigationBar({ title, displayBackButton, logoUrl, transparent, displayButtonShadows, onBackButtonClick, actions, isLoading, ...props }: NavigationBarProps): react_jsx_runtime.JSX.Element;
|
|
1459
1458
|
|
|
1460
|
-
declare function PipeSeparator(props: ComponentProps<"div">): react_jsx_runtime.JSX.Element;
|
|
1459
|
+
declare function PipeSeparator({ className, ...props }: ComponentProps<"div">): react_jsx_runtime.JSX.Element;
|
|
1461
1460
|
|
|
1462
1461
|
interface CollapsibleMenuProps {
|
|
1463
1462
|
menuRef: React.MutableRefObject<HTMLDivElement | null>;
|
|
@@ -2383,13 +2382,14 @@ declare function SwapDetailsView({ isLoading, canToggleBoostMode, }: {
|
|
|
2383
2382
|
type ChainData = {
|
|
2384
2383
|
networkName: string;
|
|
2385
2384
|
logoUrl: string;
|
|
2385
|
+
bgColor: string;
|
|
2386
2386
|
};
|
|
2387
2387
|
type Token = {
|
|
2388
2388
|
symbol: string;
|
|
2389
2389
|
logoUrl: string;
|
|
2390
2390
|
bgColor: string;
|
|
2391
2391
|
};
|
|
2392
|
-
declare function SwapProgressView({ steps, isOpen, handleClose, handleComplete, socialLink, supportLink, fromAmount, fromChain, fromToken, toAmount, toChain, toToken, fromAddressFormatted, toAddressFormatted, swapState, estimatedTimeToComplete, footerButton,
|
|
2392
|
+
declare function SwapProgressView({ steps, isOpen, handleClose, handleComplete, socialLink, supportLink, fromAmount, fromChain, fromToken, toAmount, toChain, toToken, fromAddressFormatted, toAddressFormatted, swapState, estimatedTimeToComplete, footerButton, }: {
|
|
2393
2393
|
steps: SwapStep[];
|
|
2394
2394
|
handleClose?: (swapState: SwapState) => void;
|
|
2395
2395
|
handleComplete?: () => void;
|
|
@@ -2407,7 +2407,6 @@ declare function SwapProgressView({ steps, isOpen, handleClose, handleComplete,
|
|
|
2407
2407
|
swapState: SwapState;
|
|
2408
2408
|
estimatedTimeToComplete?: string;
|
|
2409
2409
|
footerButton?: SwapStepsCollapsedFooterButton;
|
|
2410
|
-
refundTokenSymbol?: string;
|
|
2411
2410
|
}): react_jsx_runtime.JSX.Element;
|
|
2412
2411
|
|
|
2413
2412
|
interface BaseTransactionViewProps {
|
|
@@ -2655,4 +2654,4 @@ declare const baseTailwindConfig: Config;
|
|
|
2655
2654
|
*/
|
|
2656
2655
|
declare const cn: (...inputs: ClassValue[]) => string;
|
|
2657
2656
|
|
|
2658
|
-
export { type ActionButton, ActionLayout, ActionLineOutRow, ActionProperties, ActionRow, type ActionStatus, ActionStatusRow, ActionWrapper, AddressButton, type AllOrNone, AnimationWrapper, AppContainer, Approve, ApproveAction, ArrowBottomTopIcon, ArrowButton, ArrowCornerDownRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowOutOfBoxIcon, ArrowRightDownCircleIcon, ArrowRightDownIcon, ArrowRightIcon, ArrowRightUpCircleIcon, ArrowRightUpIcon, ArrowRotate, ArrowSplit, ArrowTriangle, ArrowUpIcon, ArrowWallDownIcon, ArrowsSwapIcon, AssetsButton, type AssetsButtonVariant, AssetsView, BackpackIcon, BadgeImage, BankIcon, type BaseActionProps, type BaseTransactionViewProps, BellAlarmIcon, BlockSkeleton, BodyText, Boost, BoostBadge, BoostButton, BorderedContainer, Breadcrumb, BridgeAction, BridgeHeader, BridgeProperties, BridgeTransactionView, BrokenHeartIcon, BubblesIcon, Button, BuyNFTHeader, BuyNFTProperties, BuyNFTTransactionView, CSS_VARS, Calendar, CaptionText, CatSquareIcon, ChainLink, Checkmark1Icon, Checkmark2Icon, ChevronArrowIcon, ChevronDownSmallIcon, ChevronGrabberVerticalIcon, ChevronLargeDownIcon, ChevronLargeRightIcon, ChevronRightSmallIcon, ChevronTopIcon, ChevronTopSmallIcon, Chip, type ChipProps, CircleMinusIcon, CirclePlusIcon, CircleX, CircleXFilledIcon, ClockOutlineIcon, ClockSolidIcon, CoinsAddIcon, CoinsIcon, Collapse, CollapsibleMenu, CollectionIcon, ColorPaletteIcon, CompassRoundOutlinedIcon, CompassRoundSolidIcon, ConsoleIcon, Copy, CrossAnimatedIcon, DashboardFast,
|
|
2657
|
+
export { type ActionButton, ActionLayout, ActionLineOutRow, ActionProperties, ActionRow, type ActionStatus, ActionStatusRow, ActionWrapper, AddressButton, type AllOrNone, AnimationWrapper, AppContainer, Approve, ApproveAction, ArrowBottomTopIcon, ArrowButton, ArrowCornerDownRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowOutOfBoxIcon, ArrowRightDownCircleIcon, ArrowRightDownIcon, ArrowRightIcon, ArrowRightUpCircleIcon, ArrowRightUpIcon, ArrowRotate, ArrowSplit, ArrowTriangle, ArrowUpIcon, ArrowWallDownIcon, ArrowsSwapIcon, AssetsButton, type AssetsButtonVariant, AssetsView, BackpackIcon, BadgeImage, BankIcon, type BaseActionProps, type BaseTransactionViewProps, BellAlarmIcon, BlockSkeleton, BodyText, Boost, BoostBadge, BoostButton, BorderedContainer, Breadcrumb, BridgeAction, BridgeHeader, BridgeProperties, BridgeTransactionView, BrokenHeartIcon, BubblesIcon, Button, BuyNFTHeader, BuyNFTProperties, BuyNFTTransactionView, CSS_VARS, Calendar, CaptionText, CatSquareIcon, ChainLink, Checkmark1Icon, Checkmark2Icon, ChevronArrowIcon, ChevronDownSmallIcon, ChevronGrabberVerticalIcon, ChevronLargeDownIcon, ChevronLargeRightIcon, ChevronRightSmallIcon, ChevronTopIcon, ChevronTopSmallIcon, Chip, type ChipProps, CircleMinusIcon, CirclePlusIcon, CircleX, CircleXFilledIcon, ClockOutlineIcon, ClockSolidIcon, CoinsAddIcon, CoinsIcon, Collapse, CollapsibleMenu, CollectionIcon, ColorPaletteIcon, CompassRoundOutlinedIcon, CompassRoundSolidIcon, ConsoleIcon, Copy, CrossAnimatedIcon, DashboardFast, DescriptionBlocks, DetailsToolbar, DiscordIcon, DockIconAnalytics, DockIconCheckout, DockIconHelp, DockIconProfile, DockIconScan, DockIconSwap, DockSwapIcon, DollarOutlinedIcon, DollarSolidIcon, DotGrid1x3HorizontalIcon, DropdownMenu, DropdownMenuItem, type DropdownMenuItemProps, DropdownMenuTitle, type DropdownPosition, type DropdownStyles, EmojiMeh, EmojiSadIcon, EmptyHeartIcon, ErrorMessage, EthereumIcon, ExplosionIcon, EyeOpenIcon, FeeButton, FeesAction, type FeesActionProps, FeesLines, FeesTotal, FilledHeartIcon, FilterAscendingIcon, FilterButton, FilterIcon, FilterTimelineIcon, GasIcon, GhostIcon, GithubIcon, HashLink, HeadingText, HeartSmallIcon, HelpIcon, HistoryItem, type HistoryItemStatus, HomeIcon, IconButton, IconLabel, Image, ImageIcon, ImageSparkle, IncompleteAction, InfinityIcon, InfoBox, Inline, Input, InteractionHeader, InteractionProperties, InteractionTransactionView, Join, LightningIcon, LimitIcon, LinkIcon, List, ListItem, ListItemActionsButton, Loader, LoadingProvider, LoadingSkeleton, MEDIA_QUERIES, MainView, MaxIcon, Menu, MenuItem, MenuSwapIcon, MirrorIcon, Modal, ModalContent, ModalContentDivider, MoonIcon, NavigationBar, NotAllowedIcon, NumericInput, PathSquareIcon, PercentIcon, PieChartIcon, PipeSeparator, PlusIcon, PoopIcon, PowerIcon, ProductCard, ProfileHeader, ProfileHeaderBackground, PropertiesLayout, PropertyListItem, type PropertyListItemProps, PunkIcon, RangeInput, ReceiptBillIcon, ReceiveNFTAction, ReceiveTokensAction, RecipientView, RefreshIcon, ReorderIcon, RouteStep, STEP_ITEM_HEIGHT, SearchIcon, SectionTitle, SendTokensAction, SettingsButton, type SettingsButtonProps, type SettingsControl, SettingsGearIcon, SettingsItem, type SettingsItemProps, SettingsSlider, SettingsSliderIcon, type SettingsSliderProps, ShoppingBagIcon, SizeTransition, SmileIcon, SnapIcon, SortIcon, SparkleIcon, SparklesIcon, SquareArrowCenter, SquareArrowTopLeftIcon, SquareArrowTopRight2Icon, SquidConfigProvider, SquidLogo, type SquidTheme, StakeAction, StartAction, StocksIcon, SuccessAction, SunIcon, SunriseIcon, SwapAction, SwapConfiguration, SwapDetailsView, SwapErrorIcon, SwapHeader, type SwapHeaderProps, SwapIcon, SwapInputsIcon, SwapProgressView, SwapProgressViewHeader, SwapProperties, type SwapPropertiesProps, SwapState, type SwapStep, SwapStepItem, SwapStepSeparator, SwapStepsCollapsed, type SwapStepsCollapsedFooterButton, SwapSuccessIcon, SwapTransactionView, SwapWarningIcon, Switch, type SwitchProps, TagIcon, TagIconFilled, TextSkeleton, type ThemeType, ThumbsUp, Tick, TimeFliesIcon, Timeline, Timestamp, Toast, TokenPair, Tooltip, type TooltipProps, type TooltipThreshold, type TooltipWidth, TradingViewStepsIcon, TransactionAction, type TransactionActionProps, type TransactionActionType, TransactionFilters, TransactionHeader, TransactionHeaderLayout, type TransactionHeaderProps, type TransactionHeaderType, TransactionItem, TransactionProperties, type TransactionPropertiesProps, type TransactionPropertiesType, TransactionSearch, TransactionState, TransactionView, TransactionViewLayout, type TransactionViewProps, type TransactionViewType, Transfer, TranslateIcon, TriangleExclamation, UsdAmount, WalletFilledIcon, WalletIcon, WalletLink, WalletsView, WrapAction, XSocial, baseTailwindConfig, cn, darkTheme, lightTheme, linkActionTimelineProps, statusTextClassMap, useCollapsibleMenu, useDropdownMenu, useMediaQuery, useOnResize, useRect, useTimer, useVersion };
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"url": "git+https://github.com/0xsquid/squid-ui.git"
|
|
6
6
|
},
|
|
7
7
|
"description": "Squid's UI components",
|
|
8
|
-
"version": "0.27.3
|
|
8
|
+
"version": "0.27.3",
|
|
9
9
|
"author": "",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"resolutions": {
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
"test": "vitest"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@0xsquid/react-hooks": "3.0.4",
|
|
33
32
|
"@lottiefiles/react-lottie-player": "3.5.0",
|
|
34
33
|
"bignumber.js": "9.1.2",
|
|
35
34
|
"clsx": "2.1.1",
|
|
@@ -52,7 +51,6 @@
|
|
|
52
51
|
},
|
|
53
52
|
"homepage": "https://github.com/0xsquid/squid-ui#readme",
|
|
54
53
|
"devDependencies": {
|
|
55
|
-
"@0xsquid/squid-types": "0.1.104",
|
|
56
54
|
"@chromatic-com/storybook": "^1.2.22",
|
|
57
55
|
"@release-it/conventional-changelog": "github:release-it/conventional-changelog",
|
|
58
56
|
"@rollup/plugin-commonjs": "^25.0.7",
|
|
@@ -120,7 +118,6 @@
|
|
|
120
118
|
},
|
|
121
119
|
"peerDependencies": {
|
|
122
120
|
"react": "^16.0.0 || ^17.0.0 || ^18.0.0",
|
|
123
|
-
"react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0"
|
|
124
|
-
"@0xsquid/react-hooks": "^3.0.4"
|
|
121
|
+
"react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0"
|
|
125
122
|
}
|
|
126
123
|
}
|