@0xsquid/ui 0.27.3-beta.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 CHANGED
@@ -6622,11 +6622,9 @@ function convertUSDToTokenAmount(usdAmount, tokenPrice, maxDecimals) {
6622
6622
  const price = new BigNumber(tokenPrice);
6623
6623
  return amount.dividedBy(price).decimalPlaces(maxDecimals).toString();
6624
6624
  }
6625
- const INTL_TOKEN_AMOUNT_FORMATTER = new Intl.NumberFormat("en-US", {
6626
- minimumFractionDigits: 0,
6627
- maximumFractionDigits: 4,
6628
- minimumSignificantDigits: 2,
6629
- maximumSignificantDigits: 4,
6625
+ const INTL_NUMBER_FORMATTER = new Intl.NumberFormat("en-US", {
6626
+ minimumFractionDigits: 2,
6627
+ maximumFractionDigits: 5,
6630
6628
  });
6631
6629
  /**
6632
6630
  * Formats a number to the en-US number format
@@ -6634,24 +6632,8 @@ const INTL_TOKEN_AMOUNT_FORMATTER = new Intl.NumberFormat("en-US", {
6634
6632
  * @param amount - The number to format
6635
6633
  * @returns The formatted string
6636
6634
  */
6637
- function formatTokenAmount(amount = "0") {
6638
- return INTL_TOKEN_AMOUNT_FORMATTER.format(amount);
6639
- }
6640
- const INTL_USD_AMOUNT_FORMATTER = new Intl.NumberFormat("en-US", {
6641
- style: "currency",
6642
- currency: "USD",
6643
- minimumFractionDigits: 2,
6644
- maximumFractionDigits: 2,
6645
- notation: "compact",
6646
- compactDisplay: "short",
6647
- });
6648
- function formatUsdAmount(amount = "0", { includeSign = true, formatIfVerySmall = 0.01 } = {}) {
6649
- const parsedAmount = Number(amount);
6650
- if (parsedAmount < formatIfVerySmall && parsedAmount > 0) {
6651
- return includeSign ? "<$0.01" : "<0.01";
6652
- }
6653
- const formattedAmount = INTL_USD_AMOUNT_FORMATTER.format(parsedAmount);
6654
- return includeSign ? formattedAmount : formattedAmount.replace("$", "");
6635
+ function formatAmount(amount) {
6636
+ return INTL_NUMBER_FORMATTER.format(amount);
6655
6637
  }
6656
6638
  function trimExtraDecimals(value, maxDecimals) {
6657
6639
  var _a;
@@ -18764,6 +18746,21 @@ function DropdownMenuItemWithSubmenu(_a) {
18764
18746
  }, children: submenu })) })) }));
18765
18747
  }
18766
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
+
18767
18764
  const dropdownPositionClassMap$1 = {
18768
18765
  top: "tw-right-full tw-bottom-[50px]",
18769
18766
  bottom: "tw-right-full tw-top-[50px]",
@@ -18779,6 +18776,14 @@ const collapsedListItemClassMap = {
18779
18776
  };
18780
18777
  function ListItem(_a) {
18781
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);
18782
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");
18783
18788
  // 'small' variant does not have detail
18784
18789
  const showDetail = size === "large" && (!!detail || !!icon || showDetailOnHoverOnly);
@@ -18809,17 +18814,31 @@ function ListItem(_a) {
18809
18814
  const isInteractive = !!props.onClick;
18810
18815
  const ItemTag = isInteractive ? "button" : "div";
18811
18816
  const itemProps = isInteractive ? props : {};
18812
- const { isDropdownOpen, dropdownRef, openDropdown, openDropdownButtonRef, itemRef, menuRef, dropdownStyles, } = useDropdownMenu({
18813
- itemsContainerRef,
18814
- });
18815
- return (jsxRuntime.jsxs("li", Object.assign({}, containerProps, { ref: itemRef, className: cn("tw-relative tw-flex tw-max-w-full tw-bg-grey-900 tw-text-grey-300 tw-highlight-adjacent", listItemSizeMap[size], extraPadding && "tw-px-squid-xs", compactOnMobile
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
18816
18832
  ? `${collapsedListItemClassMap[size]} mobile-lg:tw-w-full`
18817
- : "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 ? (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",
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",
18818
18834
  // 'large' variant has extra padding
18819
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" &&
18820
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
18821
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"
18822
- : "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: openDropdown, isActive: isDropdownOpen, className: "peer-hover/list-item:tw-opacity-100" })), isDropdownOpen && !!dropdownMenuContent ? (jsxRuntime.jsx(DropdownMenu, { menuRef: menuRef, isHidden: !dropdownStyles, className: cn(!!dropdownStyles &&
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 &&
18823
18842
  dropdownPositionClassMap$1[dropdownStyles.position]), dropdownRef: dropdownRef, children: dropdownMenuContent })) : null] })));
18824
18843
  }
18825
18844
  const ListItemActionsButton = React$1.forwardRef((props, ref) => {
@@ -25001,20 +25020,6 @@ function DayPicker(props) {
25001
25020
  return (jsxRuntime.jsx(RootProvider, __assign({}, props, { children: jsxRuntime.jsx(Root, { initialProps: props }) })));
25002
25021
  }
25003
25022
 
25004
- function useOnClickOutside(callback) {
25005
- const ref = React$1.useRef(null);
25006
- React$1.useEffect(() => {
25007
- const handleClick = (e) => {
25008
- if (ref.current && !ref.current.contains(e.target)) {
25009
- callback();
25010
- }
25011
- };
25012
- document.addEventListener("click", handleClick);
25013
- return () => document.removeEventListener("click", handleClick);
25014
- }, [callback]);
25015
- return { ref };
25016
- }
25017
-
25018
25023
  function TransactionFilters({ chainType, setChainType, chain, setChain, fromDate, setFromDate, toDate, setToDate, status = [], setStatus, chains, }) {
25019
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))) }) })] }));
25020
25025
  }
@@ -26600,18 +26605,14 @@ function NumericInput(_a) {
26600
26605
  return "0";
26601
26606
  if (userInputType === UserInputType.TOKEN) {
26602
26607
  if (direction === "from") {
26603
- return formatUsdAmount(convertTokenAmountToUSD(inputValue, token.price, maxUsdDecimals), {
26604
- includeSign: false,
26605
- });
26608
+ return formatAmount(convertTokenAmountToUSD(inputValue, token.price, maxUsdDecimals));
26606
26609
  }
26607
26610
  else {
26608
- return formatUsdAmount((_a = inputModeButton === null || inputModeButton === void 0 ? void 0 : inputModeButton.amountUsd) !== null && _a !== void 0 ? _a : "0", {
26609
- includeSign: false,
26610
- });
26611
+ return formatAmount((_a = inputModeButton === null || inputModeButton === void 0 ? void 0 : inputModeButton.amountUsd) !== null && _a !== void 0 ? _a : "0");
26611
26612
  }
26612
26613
  }
26613
26614
  else {
26614
- return formatTokenAmount(convertUSDToTokenAmount(inputValue, token.price, token.decimals));
26615
+ return formatAmount(convertUSDToTokenAmount(inputValue, token.price, token.decimals));
26615
26616
  }
26616
26617
  }, [
26617
26618
  inputValue,
@@ -26628,7 +26629,7 @@ function NumericInput(_a) {
26628
26629
  : "tw-text-grey-300";
26629
26630
  const BalanceChipTag = balanceChipClickable ? "button" : "div";
26630
26631
  const balanceFormatted = React$1.useMemo(() => {
26631
- return formatTokenAmount(balance !== null && balance !== void 0 ? balance : "0");
26632
+ return formatAmount(balance !== null && balance !== void 0 ? balance : "0");
26632
26633
  }, [balance]);
26633
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]";
26634
26635
  const inputRef = React$1.useRef(null);
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
2
- export declare function useOnClickOutside(callback: () => void): {
3
- ref: import("react").RefObject<HTMLDivElement>;
1
+ import { RefObject } from "react";
2
+ export declare function useOnClickOutside(callback: () => void, externalRef?: RefObject<HTMLElement>): {
3
+ ref: RefObject<HTMLElement>;
4
4
  };
@@ -19,11 +19,5 @@ export declare function convertUSDToTokenAmount(usdAmount: string | number, toke
19
19
  * @param amount - The number to format
20
20
  * @returns The formatted string
21
21
  */
22
- export declare function formatTokenAmount(amount?: number | bigint | string): string;
23
- interface FormatUsdAmountOptions {
24
- includeSign?: boolean;
25
- formatIfVerySmall?: number;
26
- }
27
- export declare function formatUsdAmount(amount?: number | bigint | string, { includeSign, formatIfVerySmall }?: FormatUsdAmountOptions): string;
22
+ export declare function formatAmount(amount: number | bigint | string): string;
28
23
  export declare function trimExtraDecimals(value: string, maxDecimals?: number): string;
29
- export {};
package/dist/esm/index.js CHANGED
@@ -6602,11 +6602,9 @@ function convertUSDToTokenAmount(usdAmount, tokenPrice, maxDecimals) {
6602
6602
  const price = new BigNumber(tokenPrice);
6603
6603
  return amount.dividedBy(price).decimalPlaces(maxDecimals).toString();
6604
6604
  }
6605
- const INTL_TOKEN_AMOUNT_FORMATTER = new Intl.NumberFormat("en-US", {
6606
- minimumFractionDigits: 0,
6607
- maximumFractionDigits: 4,
6608
- minimumSignificantDigits: 2,
6609
- maximumSignificantDigits: 4,
6605
+ const INTL_NUMBER_FORMATTER = new Intl.NumberFormat("en-US", {
6606
+ minimumFractionDigits: 2,
6607
+ maximumFractionDigits: 5,
6610
6608
  });
6611
6609
  /**
6612
6610
  * Formats a number to the en-US number format
@@ -6614,24 +6612,8 @@ const INTL_TOKEN_AMOUNT_FORMATTER = new Intl.NumberFormat("en-US", {
6614
6612
  * @param amount - The number to format
6615
6613
  * @returns The formatted string
6616
6614
  */
6617
- function formatTokenAmount(amount = "0") {
6618
- return INTL_TOKEN_AMOUNT_FORMATTER.format(amount);
6619
- }
6620
- const INTL_USD_AMOUNT_FORMATTER = new Intl.NumberFormat("en-US", {
6621
- style: "currency",
6622
- currency: "USD",
6623
- minimumFractionDigits: 2,
6624
- maximumFractionDigits: 2,
6625
- notation: "compact",
6626
- compactDisplay: "short",
6627
- });
6628
- function formatUsdAmount(amount = "0", { includeSign = true, formatIfVerySmall = 0.01 } = {}) {
6629
- const parsedAmount = Number(amount);
6630
- if (parsedAmount < formatIfVerySmall && parsedAmount > 0) {
6631
- return includeSign ? "<$0.01" : "<0.01";
6632
- }
6633
- const formattedAmount = INTL_USD_AMOUNT_FORMATTER.format(parsedAmount);
6634
- return includeSign ? formattedAmount : formattedAmount.replace("$", "");
6615
+ function formatAmount(amount) {
6616
+ return INTL_NUMBER_FORMATTER.format(amount);
6635
6617
  }
6636
6618
  function trimExtraDecimals(value, maxDecimals) {
6637
6619
  var _a;
@@ -18744,6 +18726,21 @@ function DropdownMenuItemWithSubmenu(_a) {
18744
18726
  }, children: submenu })) })) }));
18745
18727
  }
18746
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
+
18747
18744
  const dropdownPositionClassMap$1 = {
18748
18745
  top: "tw-right-full tw-bottom-[50px]",
18749
18746
  bottom: "tw-right-full tw-top-[50px]",
@@ -18759,6 +18756,14 @@ const collapsedListItemClassMap = {
18759
18756
  };
18760
18757
  function ListItem(_a) {
18761
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);
18762
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");
18763
18768
  // 'small' variant does not have detail
18764
18769
  const showDetail = size === "large" && (!!detail || !!icon || showDetailOnHoverOnly);
@@ -18789,17 +18794,31 @@ function ListItem(_a) {
18789
18794
  const isInteractive = !!props.onClick;
18790
18795
  const ItemTag = isInteractive ? "button" : "div";
18791
18796
  const itemProps = isInteractive ? props : {};
18792
- const { isDropdownOpen, dropdownRef, openDropdown, openDropdownButtonRef, itemRef, menuRef, dropdownStyles, } = useDropdownMenu({
18793
- itemsContainerRef,
18794
- });
18795
- return (jsxs("li", Object.assign({}, containerProps, { ref: itemRef, className: cn("tw-relative tw-flex tw-max-w-full tw-bg-grey-900 tw-text-grey-300 tw-highlight-adjacent", listItemSizeMap[size], extraPadding && "tw-px-squid-xs", compactOnMobile
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
18796
18812
  ? `${collapsedListItemClassMap[size]} mobile-lg:tw-w-full`
18797
- : "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 ? (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",
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",
18798
18814
  // 'large' variant has extra padding
18799
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" &&
18800
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
18801
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"
18802
- : "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: openDropdown, isActive: isDropdownOpen, className: "peer-hover/list-item:tw-opacity-100" })), isDropdownOpen && !!dropdownMenuContent ? (jsx(DropdownMenu, { menuRef: menuRef, isHidden: !dropdownStyles, className: cn(!!dropdownStyles &&
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 &&
18803
18822
  dropdownPositionClassMap$1[dropdownStyles.position]), dropdownRef: dropdownRef, children: dropdownMenuContent })) : null] })));
18804
18823
  }
18805
18824
  const ListItemActionsButton = forwardRef((props, ref) => {
@@ -24981,20 +25000,6 @@ function DayPicker(props) {
24981
25000
  return (jsx(RootProvider, __assign({}, props, { children: jsx(Root, { initialProps: props }) })));
24982
25001
  }
24983
25002
 
24984
- function useOnClickOutside(callback) {
24985
- const ref = useRef(null);
24986
- useEffect(() => {
24987
- const handleClick = (e) => {
24988
- if (ref.current && !ref.current.contains(e.target)) {
24989
- callback();
24990
- }
24991
- };
24992
- document.addEventListener("click", handleClick);
24993
- return () => document.removeEventListener("click", handleClick);
24994
- }, [callback]);
24995
- return { ref };
24996
- }
24997
-
24998
25003
  function TransactionFilters({ chainType, setChainType, chain, setChain, fromDate, setFromDate, toDate, setToDate, status = [], setStatus, chains, }) {
24999
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))) }) })] }));
25000
25005
  }
@@ -26580,18 +26585,14 @@ function NumericInput(_a) {
26580
26585
  return "0";
26581
26586
  if (userInputType === UserInputType.TOKEN) {
26582
26587
  if (direction === "from") {
26583
- return formatUsdAmount(convertTokenAmountToUSD(inputValue, token.price, maxUsdDecimals), {
26584
- includeSign: false,
26585
- });
26588
+ return formatAmount(convertTokenAmountToUSD(inputValue, token.price, maxUsdDecimals));
26586
26589
  }
26587
26590
  else {
26588
- return formatUsdAmount((_a = inputModeButton === null || inputModeButton === void 0 ? void 0 : inputModeButton.amountUsd) !== null && _a !== void 0 ? _a : "0", {
26589
- includeSign: false,
26590
- });
26591
+ return formatAmount((_a = inputModeButton === null || inputModeButton === void 0 ? void 0 : inputModeButton.amountUsd) !== null && _a !== void 0 ? _a : "0");
26591
26592
  }
26592
26593
  }
26593
26594
  else {
26594
- return formatTokenAmount(convertUSDToTokenAmount(inputValue, token.price, token.decimals));
26595
+ return formatAmount(convertUSDToTokenAmount(inputValue, token.price, token.decimals));
26595
26596
  }
26596
26597
  }, [
26597
26598
  inputValue,
@@ -26608,7 +26609,7 @@ function NumericInput(_a) {
26608
26609
  : "tw-text-grey-300";
26609
26610
  const BalanceChipTag = balanceChipClickable ? "button" : "div";
26610
26611
  const balanceFormatted = useMemo(() => {
26611
- return formatTokenAmount(balance !== null && balance !== void 0 ? balance : "0");
26612
+ return formatAmount(balance !== null && balance !== void 0 ? balance : "0");
26612
26613
  }, [balance]);
26613
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]";
26614
26615
  const inputRef = useRef(null);
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
2
- export declare function useOnClickOutside(callback: () => void): {
3
- ref: import("react").RefObject<HTMLDivElement>;
1
+ import { RefObject } from "react";
2
+ export declare function useOnClickOutside(callback: () => void, externalRef?: RefObject<HTMLElement>): {
3
+ ref: RefObject<HTMLElement>;
4
4
  };
@@ -19,11 +19,5 @@ export declare function convertUSDToTokenAmount(usdAmount: string | number, toke
19
19
  * @param amount - The number to format
20
20
  * @returns The formatted string
21
21
  */
22
- export declare function formatTokenAmount(amount?: number | bigint | string): string;
23
- interface FormatUsdAmountOptions {
24
- includeSign?: boolean;
25
- formatIfVerySmall?: number;
26
- }
27
- export declare function formatUsdAmount(amount?: number | bigint | string, { includeSign, formatIfVerySmall }?: FormatUsdAmountOptions): string;
22
+ export declare function formatAmount(amount: number | bigint | string): string;
28
23
  export declare function trimExtraDecimals(value: string, maxDecimals?: number): string;
29
- export {};
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-beta.0",
8
+ "version": "0.27.3",
9
9
  "author": "",
10
10
  "license": "MIT",
11
11
  "resolutions": {