@0xsquid/ui 2.0.6 → 2.0.8-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/dist/cjs/index.js +143 -64
  2. package/dist/cjs/types/components/badges/BadgeImage.d.ts +1 -1
  3. package/dist/cjs/types/components/controls/NumericInput.d.ts +1 -0
  4. package/dist/cjs/types/components/layout/SwapConfiguration.d.ts +1 -0
  5. package/dist/cjs/types/components/layout/TokenDetailsView.d.ts +39 -0
  6. package/dist/cjs/types/components/layout/index.d.ts +3 -2
  7. package/dist/cjs/types/components/typography/BodyText.d.ts +5 -1
  8. package/dist/cjs/types/components/typography/CaptionText.d.ts +7 -2
  9. package/dist/cjs/types/services/internal/colorService.d.ts +2 -1
  10. package/dist/cjs/types/stories/layout/SwapConfiguration.stories.d.ts +2 -1
  11. package/dist/cjs/types/stories/layout/TokenDetailsView.stories.d.ts +13 -0
  12. package/dist/esm/index.js +142 -65
  13. package/dist/esm/types/components/badges/BadgeImage.d.ts +1 -1
  14. package/dist/esm/types/components/controls/NumericInput.d.ts +1 -0
  15. package/dist/esm/types/components/layout/SwapConfiguration.d.ts +1 -0
  16. package/dist/esm/types/components/layout/TokenDetailsView.d.ts +39 -0
  17. package/dist/esm/types/components/layout/index.d.ts +3 -2
  18. package/dist/esm/types/components/typography/BodyText.d.ts +5 -1
  19. package/dist/esm/types/components/typography/CaptionText.d.ts +7 -2
  20. package/dist/esm/types/services/internal/colorService.d.ts +2 -1
  21. package/dist/esm/types/stories/layout/SwapConfiguration.stories.d.ts +2 -1
  22. package/dist/esm/types/stories/layout/TokenDetailsView.stories.d.ts +13 -0
  23. package/dist/index.css +1 -1
  24. package/dist/index.d.ts +85 -35
  25. package/package.json +1 -1
package/dist/cjs/index.js CHANGED
@@ -2699,10 +2699,12 @@ function mapToCssVariables(obj) {
2699
2699
  const badgeSizeClassMap = {
2700
2700
  sm: "tw-w-4 tw-h-4",
2701
2701
  md: "tw-w-5 tw-h-5",
2702
+ lg: "tw-w-5 tw-h-5",
2702
2703
  };
2703
2704
  const mainImageSizeClassMap = {
2704
2705
  sm: "tw-w-8 tw-h-8",
2705
2706
  md: "tw-w-10 tw-h-10",
2707
+ lg: "tw-w-[60px] tw-h-[60px]",
2706
2708
  };
2707
2709
  const loadingSkeletonClassName = "tw-bg-grey-500";
2708
2710
  var ImageState;
@@ -2717,7 +2719,11 @@ function BadgeImage({ imageUrl: _imageUrl, badgeUrl, size = "sm", extraMarginFor
2717
2719
  badge: ImageState.LOADING,
2718
2720
  mainImage: ImageState.LOADING,
2719
2721
  });
2720
- const badgeImageClassName = cn("tw-absolute -tw-right-1/3 tw-bottom-0 tw-z-10 tw-m-0 -tw-translate-x-1/3 tw-rounded-md tw-border-[1px] tw-border-grey-800", badgeSizeClassMap[size]);
2722
+ const badgeImageClassName = cn(
2723
+ // "tw-absolute -tw-right-[5px] tw-bottom-0 tw-z-10 tw-m-0 tw-rounded-md tw-border-[1px] tw-border-grey-800",
2724
+ size === "lg"
2725
+ ? "tw-absolute tw-right-0 tw-bottom-0 tw-z-10 tw-m-0 tw-rounded-md tw-border-[2px] tw-border-grey-800"
2726
+ : "tw-absolute -tw-right-1/3 tw-bottom-0 tw-z-10 tw-m-0 -tw-translate-x-1/3 tw-rounded-md tw-border-[1px] tw-border-grey-800", badgeSizeClassMap[size]);
2721
2727
  const mainImageClassName = cn("tw-h-full tw-w-full tw-absolute", rounded ? " tw-rounded-full" : "tw-rounded-squid-xs");
2722
2728
  return imageUrl ? (jsxRuntime.jsxs("div", { className: cn("tw-relative", extraMarginForBadge && badgeUrl ? "tw-mr-1.5" : null, mainImageSizeClassMap[size]), children: [imagesLoadState.mainImage !== ImageState.LOADED &&
2723
2729
  (placeholderImageUrl ? (jsxRuntime.jsx("img", { src: placeholderImageUrl, alt: "", className: mainImageClassName })) : (jsxRuntime.jsx("div", { className: cn(mainImageClassName, loadingSkeletonClassName) }))), jsxRuntime.jsx("img", { src: imageUrl, alt: "", onError: () => {
@@ -2786,6 +2792,37 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
2786
2792
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
2787
2793
  };
2788
2794
 
2795
+ const LoadingContext = React$1.createContext(false);
2796
+ const LoadingProvider = LoadingContext.Provider;
2797
+ function LoadingSkeleton({ className, height = "20", isLoading: isLoadingProp, children, width = "100", }) {
2798
+ const contextValue = React$1.useContext(LoadingContext);
2799
+ const isLoading = isLoadingProp !== undefined ? isLoadingProp : contextValue;
2800
+ if (children && !isLoading)
2801
+ return children;
2802
+ return (jsxRuntime.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: width, height: height, viewBox: "0 0 100 20", fill: "none", className: className, children: [jsxRuntime.jsx("g", { clipPath: "url(#clip0_1246_29063)", children: jsxRuntime.jsx("rect", { width: "100", height: "20", fill: "url(#paint0_linear_1246_29063)" }) }), jsxRuntime.jsxs("defs", { children: [jsxRuntime.jsxs("linearGradient", { id: "paint0_linear_1246_29063", x1: "0", y1: "10", x2: "100", y2: "10", gradientUnits: "userSpaceOnUse", className: "tw-animate-loading-gradient tw-text-material-light-thin", children: [jsxRuntime.jsx("stop", { stopColor: "currentColor" }), jsxRuntime.jsx("stop", { offset: "0.395881", stopColor: "currentColor" }), jsxRuntime.jsx("stop", { offset: "0.597867", stopColor: "currentColor", className: "group-data-[squid-theme-type=dark]:tw-text-material-light-average group-data-[squid-theme-type=light]:tw-text-transparent" }), jsxRuntime.jsx("stop", { offset: "0.697004", stopColor: "currentColor" })] }), jsxRuntime.jsx("clipPath", { id: "clip0_1246_29063", children: jsxRuntime.jsx("path", { d: "M0 10C0 4.47715 4.47715 0 10 0H90C95.5228 0 100 4.47715 100 10C100 15.5228 95.5229 20 90 20H10C4.47716 20 0 15.5228 0 10Z", fill: "white" }) })] })] }));
2803
+ }
2804
+ function TextSkeleton(_a) {
2805
+ var { className, width = ["4em", "6em"], children, isLoading } = _a, props = __rest$1(_a, ["className", "width", "children", "isLoading"]);
2806
+ const minWidthVar = "--min-width";
2807
+ const minWidth = Array.isArray(width) ? width[0] : width;
2808
+ const maxWidthVar = "--max-width";
2809
+ const maxWidth = Array.isArray(width) ? width[1] : width;
2810
+ const t = React$1.useMemo(Math.random, []);
2811
+ if (isLoading === false)
2812
+ return children;
2813
+ return (jsxRuntime.jsx("span", Object.assign({ className: cn("loading-gradient tw-inline-flex tw-rounded-full", className), style: {
2814
+ ["--min-width"]: minWidth,
2815
+ ["--max-width"]: maxWidth,
2816
+ width: calcLerp(`var(${minWidthVar})`, `var(${maxWidthVar})`, t),
2817
+ } }, props, { children: "\u00A0" })));
2818
+ }
2819
+ function BlockSkeleton(_a) {
2820
+ var { isLoading, className, children } = _a, props = __rest$1(_a, ["isLoading", "className", "children"]);
2821
+ if (isLoading === false)
2822
+ return children;
2823
+ return (jsxRuntime.jsx("div", Object.assign({ className: cn("loading-gradient tw-rounded-squid-s", className) }, props)));
2824
+ }
2825
+
2789
2826
  // font size, line height, and letter spacing classes
2790
2827
  const textClassMap$1 = {
2791
2828
  small: "tw-text-body-small tw-tracking-body-small tw-leading-body-small tw-font-body-small",
@@ -2793,15 +2830,25 @@ const textClassMap$1 = {
2793
2830
  large: "tw-text-body-large tw-tracking-body-large tw-leading-body-large tw-font-body-large",
2794
2831
  };
2795
2832
  function BodyText(_a) {
2796
- var { size, children, bold = false, tight = false } = _a, props = __rest$1(_a, ["size", "children", "bold", "tight"]);
2833
+ var _b, _c;
2834
+ var { size, children, bold = false, tight = false, loading } = _a, props = __rest$1(_a, ["size", "children", "bold", "tight", "loading"]);
2797
2835
  const fontWeightClass = bold ? "!tw-font-bold" : "!tw-font-regular";
2798
- return (jsxRuntime.jsx("span", Object.assign({}, props, { className: cn(textClassMap$1[size], fontWeightClass, tight && "!tw-leading-[1]", props.className), children: children })));
2836
+ const className = cn(textClassMap$1[size], fontWeightClass, tight && "!tw-leading-[1]", props.className);
2837
+ if ((_b = loading === null || loading === void 0 ? void 0 : loading.isLoading) !== null && _b !== void 0 ? _b : false) {
2838
+ return (jsxRuntime.jsx(TextSkeleton, { className: className, width: (_c = loading === null || loading === void 0 ? void 0 : loading.width) !== null && _c !== void 0 ? _c : "100%", isLoading: true }));
2839
+ }
2840
+ return (jsxRuntime.jsx("span", Object.assign({}, props, { className: className, children: children })));
2799
2841
  }
2800
2842
 
2801
2843
  function CaptionText(_a) {
2802
- var { children, bold = false } = _a, props = __rest$1(_a, ["children", "bold"]);
2803
- const boldClass = bold && "!tw-font-bold";
2804
- return (jsxRuntime.jsx("span", Object.assign({}, props, { className: cn(boldClass, "tw-text-caption tw-font-caption tw-leading-caption", props.className), children: children })));
2844
+ var _b, _c;
2845
+ var { children, bold = false, loading } = _a, props = __rest$1(_a, ["children", "bold", "loading"]);
2846
+ const boldClass = bold ? "!tw-font-bold" : "";
2847
+ const className = cn("tw-text-caption tw-font-caption tw-leading-caption", boldClass, props.className);
2848
+ if ((_b = loading === null || loading === void 0 ? void 0 : loading.isLoading) !== null && _b !== void 0 ? _b : false) {
2849
+ return (jsxRuntime.jsx(TextSkeleton, { className: className, width: (_c = loading === null || loading === void 0 ? void 0 : loading.width) !== null && _c !== void 0 ? _c : "100%", isLoading: true }));
2850
+ }
2851
+ return (jsxRuntime.jsx("span", Object.assign({}, props, { className: className, children: children })));
2805
2852
  }
2806
2853
 
2807
2854
  // font size, line height, and letter spacing classes
@@ -2840,37 +2887,6 @@ function IconLabel({ src, children, variant }) {
2840
2887
  return (jsxRuntime.jsxs("div", { className: "tw-inline-flex tw-items-center tw-gap-squid-xxs", children: [src && jsxRuntime.jsx(Image$1, { src: src, variant: variant }), typeof children === "string" ? (jsxRuntime.jsx(CaptionText, { children: children })) : (children)] }));
2841
2888
  }
2842
2889
 
2843
- const LoadingContext = React$1.createContext(false);
2844
- const LoadingProvider = LoadingContext.Provider;
2845
- function LoadingSkeleton({ className, height = "20", isLoading: isLoadingProp, children, width = "100", }) {
2846
- const contextValue = React$1.useContext(LoadingContext);
2847
- const isLoading = isLoadingProp !== undefined ? isLoadingProp : contextValue;
2848
- if (children && !isLoading)
2849
- return children;
2850
- return (jsxRuntime.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: width, height: height, viewBox: "0 0 100 20", fill: "none", className: className, children: [jsxRuntime.jsx("g", { clipPath: "url(#clip0_1246_29063)", children: jsxRuntime.jsx("rect", { width: "100", height: "20", fill: "url(#paint0_linear_1246_29063)" }) }), jsxRuntime.jsxs("defs", { children: [jsxRuntime.jsxs("linearGradient", { id: "paint0_linear_1246_29063", x1: "0", y1: "10", x2: "100", y2: "10", gradientUnits: "userSpaceOnUse", className: "tw-animate-loading-gradient tw-text-material-light-thin", children: [jsxRuntime.jsx("stop", { stopColor: "currentColor" }), jsxRuntime.jsx("stop", { offset: "0.395881", stopColor: "currentColor" }), jsxRuntime.jsx("stop", { offset: "0.597867", stopColor: "currentColor", className: "group-data-[squid-theme-type=dark]:tw-text-material-light-average group-data-[squid-theme-type=light]:tw-text-transparent" }), jsxRuntime.jsx("stop", { offset: "0.697004", stopColor: "currentColor" })] }), jsxRuntime.jsx("clipPath", { id: "clip0_1246_29063", children: jsxRuntime.jsx("path", { d: "M0 10C0 4.47715 4.47715 0 10 0H90C95.5228 0 100 4.47715 100 10C100 15.5228 95.5229 20 90 20H10C4.47716 20 0 15.5228 0 10Z", fill: "white" }) })] })] }));
2851
- }
2852
- function TextSkeleton(_a) {
2853
- var { className, width = ["4em", "6em"], children, isLoading } = _a, props = __rest$1(_a, ["className", "width", "children", "isLoading"]);
2854
- const minWidthVar = "--min-width";
2855
- const minWidth = Array.isArray(width) ? width[0] : width;
2856
- const maxWidthVar = "--max-width";
2857
- const maxWidth = Array.isArray(width) ? width[1] : width;
2858
- const t = React$1.useMemo(Math.random, []);
2859
- if (isLoading === false)
2860
- return children;
2861
- return (jsxRuntime.jsx("span", Object.assign({ className: cn("loading-gradient tw-inline-flex tw-rounded-full", className), style: {
2862
- ["--min-width"]: minWidth,
2863
- ["--max-width"]: maxWidth,
2864
- width: calcLerp(`var(${minWidthVar})`, `var(${maxWidthVar})`, t),
2865
- } }, props, { children: "\u00A0" })));
2866
- }
2867
- function BlockSkeleton(_a) {
2868
- var { isLoading, className, children } = _a, props = __rest$1(_a, ["isLoading", "className", "children"]);
2869
- if (isLoading === false)
2870
- return children;
2871
- return (jsxRuntime.jsx("div", Object.assign({ className: cn("loading-gradient tw-rounded-squid-s", className) }, props)));
2872
- }
2873
-
2874
2890
  function Checkmark1Icon({ className, size = "16", }) {
2875
2891
  return (jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 16 16", fill: "none", className: className, children: jsxRuntime.jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M12.8809 2.82977C13.3432 3.13201 13.4729 3.75174 13.1706 4.21399L7.50398 12.8807C7.3318 13.144 7.04572 13.3109 6.73174 13.3313C6.41777 13.3517 6.11252 13.2231 5.90775 12.9842L2.90775 9.4842C2.54833 9.06487 2.59689 8.43357 3.01622 8.07415C3.43554 7.71473 4.06684 7.76329 4.42627 8.18262L6.55918 10.671L11.4967 3.11949C11.7989 2.65725 12.4187 2.52753 12.8809 2.82977Z", fill: "currentColor" }) }));
2876
2892
  }
@@ -16957,6 +16973,20 @@ function SizeTransition(_a) {
16957
16973
  return (jsxRuntime.jsx("div", Object.assign({}, props, { className: cn("tw-transition-[width,height], tw-duration-200", className), style: { width: contentsRect.width, height: contentsRect.height }, children: jsxRuntime.jsx("div", { ref: contentsRef, className: "tw-inline-block", children: children }) })));
16958
16974
  }
16959
16975
 
16976
+ function CollapsibleMenu({ children, menuRef, isOpen, transitionDuration, size, className, }) {
16977
+ return (jsxRuntime.jsx("aside", { style: Object.assign({ transitionDuration, transitionTimingFunction: isOpen
16978
+ ? "cubic-bezier(0.4, 1.3, 0.4, 1)"
16979
+ : undefined, [CSS_VARS.COLLAPSIBLE_MENU_OPEN_WIDTH]: size.open.width, [CSS_VARS.COLLAPSIBLE_MENU_OPEN_HEIGHT]: size.open.height, [CSS_VARS.COLLAPSIBLE_MENU_CLOSED_WIDTH]: size.closed.width, [CSS_VARS.COLLAPSIBLE_MENU_CLOSED_HEIGHT]: size.closed.height }, (isOpen
16980
+ ? {
16981
+ width: `var(${CSS_VARS.COLLAPSIBLE_MENU_OPEN_WIDTH})`,
16982
+ height: `var(${CSS_VARS.COLLAPSIBLE_MENU_OPEN_HEIGHT})`,
16983
+ }
16984
+ : {
16985
+ width: `var(${CSS_VARS.COLLAPSIBLE_MENU_CLOSED_WIDTH})`,
16986
+ height: `var(${CSS_VARS.COLLAPSIBLE_MENU_CLOSED_HEIGHT})`,
16987
+ })), className: cn("tw-fixed tw-z-40 tw-flex tw-flex-col tw-overflow-hidden tw-bg-grey-900 tw-text-grey-100 tw-shadow-elevation-light-3 tw-outline-material-light-thin", className), ref: menuRef, children: children }));
16988
+ }
16989
+
16960
16990
  function DescriptionBlocks(_a) {
16961
16991
  var { className, blocks: blocksProp } = _a, props = __rest$1(_a, ["className", "blocks"]);
16962
16992
  const blocks = typeof blocksProp === "string"
@@ -18040,20 +18070,6 @@ function PipeSeparator(props) {
18040
18070
  return (jsxRuntime.jsx("div", Object.assign({}, props, { className: cn("tw-h-[0.8em] tw-w-[2px] tw-rounded-full tw-bg-[currentColor]", props.className) })));
18041
18071
  }
18042
18072
 
18043
- function CollapsibleMenu({ children, menuRef, isOpen, transitionDuration, size, className, }) {
18044
- return (jsxRuntime.jsx("aside", { style: Object.assign({ transitionDuration, transitionTimingFunction: isOpen
18045
- ? "cubic-bezier(0.4, 1.3, 0.4, 1)"
18046
- : undefined, [CSS_VARS.COLLAPSIBLE_MENU_OPEN_WIDTH]: size.open.width, [CSS_VARS.COLLAPSIBLE_MENU_OPEN_HEIGHT]: size.open.height, [CSS_VARS.COLLAPSIBLE_MENU_CLOSED_WIDTH]: size.closed.width, [CSS_VARS.COLLAPSIBLE_MENU_CLOSED_HEIGHT]: size.closed.height }, (isOpen
18047
- ? {
18048
- width: `var(${CSS_VARS.COLLAPSIBLE_MENU_OPEN_WIDTH})`,
18049
- height: `var(${CSS_VARS.COLLAPSIBLE_MENU_OPEN_HEIGHT})`,
18050
- }
18051
- : {
18052
- width: `var(${CSS_VARS.COLLAPSIBLE_MENU_CLOSED_WIDTH})`,
18053
- height: `var(${CSS_VARS.COLLAPSIBLE_MENU_CLOSED_HEIGHT})`,
18054
- })), className: cn("tw-fixed tw-z-40 tw-flex tw-flex-col tw-overflow-hidden tw-bg-grey-900 tw-text-grey-100 tw-shadow-elevation-light-3 tw-outline-material-light-thin", className), ref: menuRef, children: children }));
18055
- }
18056
-
18057
18073
  const createStoreImpl = (createState) => {
18058
18074
  let state;
18059
18075
  const listeners = /* @__PURE__ */ new Set();
@@ -19490,6 +19506,49 @@ const SwapStepsCollapsed = React$1.forwardRef((props, ref) => {
19490
19506
  });
19491
19507
  SwapStepsCollapsed.displayName = "SwapStepsCollapsed";
19492
19508
 
19509
+ function Toast({ headerContent, actionsContent, description, chipLabel, title, }) {
19510
+ return (jsxRuntime.jsxs(Menu, { contentClassName: "tw-px-squid-m tw-pb-squid-s tw-pt-squid-xxs", contentWrapperProps: {
19511
+ className: "tw-flex tw-flex-col tw-items-center tw-justify-center tw-gap-squid-xs",
19512
+ }, 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" }))] }));
19513
+ }
19514
+
19515
+ const DEFAULT_TIMEFRAME = "1D";
19516
+ const DefaultChart = ({ timeframe, }) => (jsxRuntime.jsx("div", { className: "tw-flex tw-h-full tw-w-full tw-items-center tw-justify-center", children: jsxRuntime.jsxs(BodyText, { size: "small", children: ["Chart (", timeframe, ")"] }) }));
19517
+ const TokenModalHeader = ({ token, chain, onLikeToken, onClose, }) => (jsxRuntime.jsxs("div", { className: "tw-flex tw-w-full tw-items-start tw-justify-between", children: [jsxRuntime.jsx("div", { className: "tw-flex tw-items-center tw-gap-squid-xs tw-pb-squid-xs", children: jsxRuntime.jsx(BadgeImage, { imageUrl: token.image, badgeUrl: chain.image, size: "lg", rounded: true }) }), jsxRuntime.jsxs("span", { className: "tw-flex tw-items-center tw-gap-squid-xxs", children: [jsxRuntime.jsx(IconButton, { className: "tw-text-grey-300", onClick: onLikeToken, icon: jsxRuntime.jsx(EmptyHeartIcon, {}) }), jsxRuntime.jsx(IconButton, { className: "tw-text-grey-300", onClick: onClose, icon: jsxRuntime.jsx(CircleXFilledIcon, {}) })] })] }));
19518
+ const TokenInfo = ({ token, tokenPrice, priceChange, loading, }) => (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs(BodyText, { size: "large", loading: { isLoading: loading, width: "100px" }, children: ["$", tokenPrice.toLocaleString()] }), jsxRuntime.jsxs("div", { className: "tw-flex tw-flex-row tw-justify-between", children: [jsxRuntime.jsx(BodyText, { size: "small", children: token.name }), jsxRuntime.jsxs("div", { className: "tw-flex tw-items-center tw-gap-squid-xxs", children: [jsxRuntime.jsxs(BodyText, { size: "small", className: "tw-text-grey-500", loading: { isLoading: loading, width: "40px" }, children: [Math.abs(priceChange).toFixed(2), "%"] }), !loading && (jsxRuntime.jsx(ArrowTriangle, { className: `${priceChange >= 0 ? "tw-rotate-180 tw-text-status-positive" : "tw-text-status-negative"}` }))] })] })] }));
19519
+ const BalanceInfo = ({ balance, balanceUSD, token, loading, }) => (jsxRuntime.jsxs("div", { className: "tw-flex tw-flex-col", children: [jsxRuntime.jsx(CaptionText, { className: "tw-text-grey-400", children: "Balance" }), jsxRuntime.jsxs("div", { className: "tw-flex tw-flex-row tw-justify-between", children: [jsxRuntime.jsxs("span", { className: "tw-flex tw-flex-row tw-items-center tw-gap-squid-xxs", children: [jsxRuntime.jsx("img", { src: token.image, alt: token.name, className: "tw-h-squid-m tw-w-squid-m tw-rounded-full" }), jsxRuntime.jsxs(BodyText, { size: "small", loading: { isLoading: loading, width: "80px" }, children: [balance.toFixed(6), " ", token.symbol] })] }), jsxRuntime.jsxs(CaptionText, { className: "tw-text-grey-400", loading: { isLoading: loading, width: "60px" }, children: ["$", balanceUSD.toFixed(2)] })] })] }));
19520
+ const MarketDataItem = ({ label, value, showDollar, loading, }) => (jsxRuntime.jsxs("div", { className: "tw-flex tw-flex-col", children: [jsxRuntime.jsx(CaptionText, { className: "tw-text-grey-500", children: label }), jsxRuntime.jsxs(CaptionText, { loading: { isLoading: loading, width: "60px" }, children: [showDollar && jsxRuntime.jsx("span", { className: "tw-text-grey-500", children: "$" }), value] })] }));
19521
+ const TokenMarketData = ({ volume24h, marketCap, totalSupply, loading, }) => (jsxRuntime.jsxs("div", { className: "tw-flex tw-h-full tw-w-full tw-flex-row tw-items-center tw-justify-between", children: [jsxRuntime.jsx(MarketDataItem, { label: "24h volume", value: volume24h, showDollar: true, loading: loading }), jsxRuntime.jsx(MarketDataItem, { label: "Market cap", value: marketCap, showDollar: true, loading: loading }), jsxRuntime.jsx(MarketDataItem, { label: "Total supply", value: totalSupply, loading: loading })] }));
19522
+ const SwapButton = ({ label, color, icon, onClick, textColor, }) => (jsxRuntime.jsxs("div", { className: "tw-flex tw-flex-1 tw-flex-col tw-items-center tw-justify-center tw-gap-squid-xs", children: [jsxRuntime.jsx(IconButton, { icon: icon, className: "tw-text-grey-900", style: {
19523
+ height: "40px",
19524
+ width: "40px",
19525
+ borderRadius: "100%",
19526
+ backgroundColor: color,
19527
+ color: textColor,
19528
+ }, onClick: onClick }), jsxRuntime.jsx(CaptionText, { className: "tw-text-grey-400", children: label })] }));
19529
+ const SwapButtons = ({ token, onSwapFrom, onSwapTo, }) => (jsxRuntime.jsxs("div", { className: "tw-flex tw-justify-between tw-py-5", children: [jsxRuntime.jsx(SwapButton, { label: "Swap From", color: token.color, textColor: token.textColor, icon: jsxRuntime.jsx(ArrowUpIcon, {}), onClick: () => {
19530
+ onSwapFrom({ address: token.address, chainId: token.chainId });
19531
+ } }), jsxRuntime.jsx(SwapButton, { label: "Swap To", color: token.color, textColor: token.textColor, icon: jsxRuntime.jsx(ArrowDownIcon, {}), onClick: () => {
19532
+ onSwapTo({ address: token.address, chainId: token.chainId });
19533
+ } })] }));
19534
+ const TimeframeChip = ({ label, isSelected, onClick, }) => (jsxRuntime.jsx(Chip, { className: cn("tw-w-squid-xl tw-cursor-pointer hover:tw-bg-material-light-thin", isSelected
19535
+ ? "!tw-bg-grey-300 !tw-text-grey-900"
19536
+ : "tw-bg-transparent !tw-text-grey-600"), label: label, onClick: onClick }));
19537
+ const ChartTimeframeSelector = ({ selectedTimeframe, onTimeframeChange, }) => {
19538
+ const timeframes = ["1H", "1D", "1W", "1Y"];
19539
+ return (jsxRuntime.jsx("div", { className: "tw-mt-squid-s tw-flex tw-justify-center tw-gap-squid-xs", children: timeframes.map((timeframe) => (jsxRuntime.jsx(TimeframeChip, { label: timeframe, isSelected: selectedTimeframe === timeframe, onClick: () => {
19540
+ onTimeframeChange(timeframe);
19541
+ } }, timeframe))) }));
19542
+ };
19543
+ const TokenDetailsView = ({ isOpen, onClose, token, chain, tokenPrice, priceChange, balance, balanceUSD, volume24h, marketCap, totalSupply, loading, onLikeToken, Chart = DefaultChart, initialTimeframe = DEFAULT_TIMEFRAME, onTimeframeChange = () => { }, onSwapFrom, onSwapTo, }) => {
19544
+ const [selectedTimeframe, setSelectedTimeframe] = React$1.useState(initialTimeframe);
19545
+ const handleTimeframeChange = (timeframe) => {
19546
+ setSelectedTimeframe(timeframe);
19547
+ onTimeframeChange(timeframe);
19548
+ };
19549
+ return (jsxRuntime.jsx(Modal, { isOpen: isOpen, onBackdropClick: onClose, width: "extra-large", className: "tw-my-auto", children: jsxRuntime.jsxs(ModalContent, { className: "tw-flex tw-min-h-[631px] tw-flex-col tw-pt-squid-m", children: [jsxRuntime.jsxs("div", { className: "tw-px-squid-m", children: [jsxRuntime.jsx(TokenModalHeader, { token: token, chain: chain, loading: loading, onLikeToken: onLikeToken, onClose: onClose }), jsxRuntime.jsx(TokenInfo, { token: token, tokenPrice: tokenPrice, priceChange: priceChange, loading: loading })] }), jsxRuntime.jsxs("div", { className: "tw-flex tw-w-full tw-grow tw-flex-col tw-justify-between tw-text-center", children: [jsxRuntime.jsx("span", { className: "tw-flex tw-h-full tw-grow tw-items-center tw-justify-center", children: loading ? jsxRuntime.jsx(Loader, {}) : jsxRuntime.jsx(Chart, { timeframe: selectedTimeframe }) }), jsxRuntime.jsx(ChartTimeframeSelector, { selectedTimeframe: selectedTimeframe, onTimeframeChange: handleTimeframeChange })] }), jsxRuntime.jsx("hr", { className: "tw-my-squid-xs tw-h-px tw-border-0 tw-bg-material-light-thin" }), jsxRuntime.jsxs("div", { className: "tw-flex tw-flex-col", children: [jsxRuntime.jsxs("div", { className: "tw-gap-squid-sm tw-flex tw-flex-col tw-px-squid-m", children: [jsxRuntime.jsx(BalanceInfo, { balance: balance, balanceUSD: balanceUSD, token: token, loading: loading }), jsxRuntime.jsx("hr", { className: "tw-my-squid-xs tw-h-px tw-border-0 tw-bg-material-light-thin" }), jsxRuntime.jsx(TokenMarketData, { volume24h: volume24h, marketCap: marketCap, totalSupply: totalSupply, loading: loading })] }), jsxRuntime.jsx("hr", { className: "tw-my-squid-xs tw-h-px tw-border-0 tw-bg-material-light-thin" }), jsxRuntime.jsx(SwapButtons, { token: token, onSwapFrom: onSwapFrom, onSwapTo: onSwapTo })] })] }) }));
19550
+ };
19551
+
19493
19552
  const WIDTH_SM = "69";
19494
19553
  const HEIGHT_SM = "31";
19495
19554
  const WIDTH_MD = "94";
@@ -25429,12 +25488,6 @@ function PopLayout(props) {
25429
25488
  return jsxRuntime.jsx(motion.div, Object.assign({ ref: ref }, props));
25430
25489
  }
25431
25490
 
25432
- function Toast({ headerContent, actionsContent, description, chipLabel, title, }) {
25433
- return (jsxRuntime.jsxs(Menu, { contentClassName: "tw-px-squid-m tw-pb-squid-s tw-pt-squid-xxs", contentWrapperProps: {
25434
- className: "tw-flex tw-flex-col tw-items-center tw-justify-center tw-gap-squid-xs",
25435
- }, 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" }))] }));
25436
- }
25437
-
25438
25491
  var lib = {};
25439
25492
 
25440
25493
  var uaParser_min = {exports: {}};
@@ -26881,7 +26934,7 @@ function NumericInput(_a) {
26881
26934
  ? "tw-opacity-0"
26882
26935
  : "" }), jsxRuntime.jsx(CaptionText, { bold: true, children: priceImpactPercentage.toString().concat("%") })] })) : null] }) }))), jsxRuntime.jsx(Tooltip, Object.assign({}, (isLoading ? undefined : balanceButton === null || balanceButton === void 0 ? void 0 : balanceButton.tooltip), { tooltipWidth: "max", childrenClassName: "tw-rounded-squid-s", containerClassName: "tw-rounded-squid-s", children: jsxRuntime.jsxs(BalanceChipTag, { onClick: onBalanceButtonClick, className: cn(buttonClassName, balanceChipClickable
26883
26936
  ? interactiveChipClassName
26884
- : notInteractiveChipClassName), children: [jsxRuntime.jsx(CaptionText, { className: "tw-opacity-66", children: "Balance" }), jsxRuntime.jsx(CaptionText, { children: balanceFormatted }), jsxRuntime.jsx(Chip, { label: "Max" })] }) }))] }))] }));
26937
+ : notInteractiveChipClassName), children: [jsxRuntime.jsx(CaptionText, { className: "tw-opacity-66", children: "Balance" }), jsxRuntime.jsx(CaptionText, { children: balanceFormatted }), !(balanceButton === null || balanceButton === void 0 ? void 0 : balanceButton.hideMaxChip) && jsxRuntime.jsx(Chip, { label: "Max" })] }) }))] }))] }));
26885
26938
  }
26886
26939
 
26887
26940
  function SettingsSlider({ value, type, onChange, decimalsFormat, max, min, isSelected = false, }) {
@@ -62604,19 +62657,43 @@ function rgbToHex(r, g, b) {
62604
62657
  // let bgColor = '#17191C'
62605
62658
  // let resultingColor = blendColors(foregroundColor, bgColor)
62606
62659
  // console.log(resultingColor) // Output: ~#2f3033
62607
- function blendColors(foreground, background) {
62608
- const fg = hexToRgb(foreground);
62609
- const bg = hexToRgb(background);
62660
+ function blendColors(foreground, background, factor = 1) {
62661
+ const fg = parseColor(foreground);
62662
+ const bg = parseColor(background);
62610
62663
  if (fg == null || bg == null)
62611
62664
  return null;
62612
- const r = Math.round(fg.r * fg.a + bg.r * (1 - fg.a));
62613
- const g = Math.round(fg.g * fg.a + bg.g * (1 - fg.a));
62614
- const b = Math.round(fg.b * fg.a + bg.b * (1 - fg.a));
62665
+ const r = Math.round(fg.r * (1 - factor) + bg.r * factor);
62666
+ const g = Math.round(fg.g * (1 - factor) + bg.g * factor);
62667
+ const b = Math.round(fg.b * (1 - factor) + bg.b * factor);
62615
62668
  return rgbToHex(r, g, b);
62616
62669
  }
62617
62670
  const isValidHexColor = (hex) => {
62618
62671
  return /^#([0-9A-F]{3}|[0-9A-F]{6}|[0-9A-F]{4}|[0-9A-F]{8})$/i.test(hex);
62619
62672
  };
62673
+ function parseColor(color) {
62674
+ var _a, _b, _c, _d;
62675
+ if (color.startsWith("#")) {
62676
+ return hexToRgb(color);
62677
+ }
62678
+ else if (color.startsWith("rgb")) {
62679
+ const match = color.match(/\d+(\.\d+)?/g);
62680
+ if (match) {
62681
+ return {
62682
+ r: parseInt((_a = match[0]) !== null && _a !== void 0 ? _a : "0"),
62683
+ g: parseInt((_b = match[1]) !== null && _b !== void 0 ? _b : "0"),
62684
+ b: parseInt((_c = match[2]) !== null && _c !== void 0 ? _c : "0"),
62685
+ a: match[3] ? parseFloat((_d = match[3]) !== null && _d !== void 0 ? _d : "0") : 1,
62686
+ };
62687
+ }
62688
+ }
62689
+ return null;
62690
+ }
62691
+ const getColorBrightness = (color) => {
62692
+ const rgb = parseColor(color);
62693
+ if (!rgb)
62694
+ return 0;
62695
+ return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
62696
+ };
62620
62697
 
62621
62698
  function ThemeProvider(_a) {
62622
62699
  var { theme = lightTheme, children, themeType = "light" } = _a, props = __rest$1(_a, ["theme", "children", "themeType"]);
@@ -62874,6 +62951,7 @@ exports.TimeFliesIcon = TimeFliesIcon;
62874
62951
  exports.Timeline = Timeline;
62875
62952
  exports.Timestamp = Timestamp;
62876
62953
  exports.Toast = Toast;
62954
+ exports.TokenDetailsView = TokenDetailsView;
62877
62955
  exports.TokenPair = TokenPair;
62878
62956
  exports.Tooltip = Tooltip;
62879
62957
  exports.TradingViewStepsIcon = TradingViewStepsIcon;
@@ -62902,6 +62980,7 @@ exports.blendColors = blendColors;
62902
62980
  exports.cn = cn;
62903
62981
  exports.darkTheme = darkTheme;
62904
62982
  exports.defaultTheme = defaultTheme;
62983
+ exports.getColorBrightness = getColorBrightness;
62905
62984
  exports.getContrastColor = getContrastColor;
62906
62985
  exports.getHexColorFromOpacityPercentage = getHexColorFromOpacityPercentage;
62907
62986
  exports.hexToRgb = hexToRgb;
@@ -10,6 +10,6 @@ interface BadgeImageProps {
10
10
  */
11
11
  placeholderImageUrl?: string;
12
12
  }
13
- type BadgeSize = "sm" | "md";
13
+ type BadgeSize = "sm" | "md" | "lg";
14
14
  export declare function BadgeImage({ imageUrl: _imageUrl, badgeUrl, size, extraMarginForBadge, rounded, placeholderImageUrl, }: BadgeImageProps): import("react/jsx-runtime").JSX.Element | null;
15
15
  export {};
@@ -32,6 +32,7 @@ interface NumericInputProps extends React.InputHTMLAttributes<HTMLInputElement>
32
32
  isInteractive?: boolean;
33
33
  balanceButton?: {
34
34
  tooltip?: Omit<TooltipProps, "children">;
35
+ hideMaxChip?: boolean;
35
36
  };
36
37
  }
37
38
  export declare function NumericInput({ priceImpactPercentage, balance, error, criticalPriceImpactPercentage, token, onAmountChange, forcedAmount, maxUsdDecimals, formatIfVerySmall, showDetails, isLoading, direction, inputModeButton, isInteractive, balanceButton, ...props }: NumericInputProps): import("react/jsx-runtime").JSX.Element;
@@ -33,6 +33,7 @@ interface SwapConfigurationProps {
33
33
  };
34
34
  balanceButton?: {
35
35
  tooltip?: Omit<TooltipProps, "children">;
36
+ hideMaxChip?: boolean;
36
37
  };
37
38
  assetsButton?: {
38
39
  tooltip?: Omit<TooltipProps, "children">;
@@ -0,0 +1,39 @@
1
+ /// <reference types="react" />
2
+ interface Token {
3
+ address: string;
4
+ name: string;
5
+ symbol: string;
6
+ image: string;
7
+ color: string;
8
+ textColor: string;
9
+ chainId: string;
10
+ }
11
+ interface Chain {
12
+ name: string;
13
+ image: string;
14
+ }
15
+ export type Timeframe = "1H" | "1D" | "1W" | "1Y";
16
+ interface TokenDetailsViewProps {
17
+ isOpen: boolean;
18
+ onClose: () => void;
19
+ token: Token;
20
+ chain: Chain;
21
+ tokenPrice: number;
22
+ priceChange: number;
23
+ balance: number;
24
+ balanceUSD: number;
25
+ volume24h: string;
26
+ marketCap: string;
27
+ totalSupply: string;
28
+ loading: boolean;
29
+ onLikeToken: () => void;
30
+ Chart?: React.ComponentType<{
31
+ timeframe: Timeframe;
32
+ }>;
33
+ initialTimeframe?: Timeframe;
34
+ onTimeframeChange?: (timeframe: Timeframe) => void;
35
+ onSwapFrom: (token: Pick<Token, "address" | "chainId">) => void;
36
+ onSwapTo: (token: Pick<Token, "address" | "chainId">) => void;
37
+ }
38
+ export declare const TokenDetailsView: ({ isOpen, onClose, token, chain, tokenPrice, priceChange, balance, balanceUSD, volume24h, marketCap, totalSupply, loading, onLikeToken, Chart, initialTimeframe, onTimeframeChange, onSwapFrom, onSwapTo, }: TokenDetailsViewProps) => import("react/jsx-runtime").JSX.Element;
39
+ export {};
@@ -3,6 +3,7 @@ export * from "./AppContainer";
3
3
  export * from "./Boost";
4
4
  export * from "./Breadcrumb";
5
5
  export * from "./Collapse";
6
+ export * from "./CollapsibleMenu";
6
7
  export * from "./DescriptionBlocks";
7
8
  export * from "./DetailsToolbar";
8
9
  export * from "./DropdownMenu";
@@ -15,12 +16,13 @@ export * from "./Modal";
15
16
  export * from "./ModalContent";
16
17
  export * from "./NavigationBar";
17
18
  export * from "./PipeSeparator";
18
- export * from "./CollapsibleMenu";
19
19
  export * from "./ProductCard";
20
20
  export * from "./ProfileHeaderBackground";
21
21
  export * from "./SwapConfiguration";
22
22
  export * from "./SwapProgressViewHeader";
23
23
  export * from "./SwapStepsCollapsed";
24
+ export * from "./Toast";
25
+ export * from "./TokenDetailsView";
24
26
  export * from "./TokenPair";
25
27
  export * from "./TransactionFilters";
26
28
  export * from "./TransactionHeader/BridgeHeader";
@@ -38,4 +40,3 @@ export * from "./TransactionProperties/SwapProperties";
38
40
  export * from "./TransactionProperties/TransactionProperties";
39
41
  export * from "./TransactionSearch";
40
42
  export * from "./Transfer";
41
- export * from "./Toast";
@@ -5,6 +5,10 @@ interface BodyTextProps extends React.HTMLAttributes<HTMLSpanElement> {
5
5
  size: TextSize;
6
6
  bold?: boolean;
7
7
  tight?: boolean;
8
+ loading?: {
9
+ isLoading?: boolean;
10
+ width?: string;
11
+ };
8
12
  }
9
- export declare function BodyText({ size, children, bold, tight, ...props }: BodyTextProps): import("react/jsx-runtime").JSX.Element;
13
+ export declare function BodyText({ size, children, bold, tight, loading, ...props }: BodyTextProps): import("react/jsx-runtime").JSX.Element;
10
14
  export {};
@@ -1,6 +1,11 @@
1
- /// <reference types="react" />
1
+ import { type ReactNode } from "react";
2
2
  interface CaptionProps extends React.HTMLAttributes<HTMLSpanElement> {
3
+ children: ReactNode;
3
4
  bold?: boolean;
5
+ loading?: {
6
+ isLoading?: boolean;
7
+ width?: string;
8
+ };
4
9
  }
5
- export declare function CaptionText({ children, bold, ...props }: CaptionProps): import("react/jsx-runtime").JSX.Element;
10
+ export declare function CaptionText({ children, bold, loading, ...props }: CaptionProps): import("react/jsx-runtime").JSX.Element;
6
11
  export {};
@@ -29,5 +29,6 @@ export declare function hexToRgb(hex: string): {
29
29
  a: number;
30
30
  } | null;
31
31
  export declare function rgbToHex(r: number, g: number, b: number): string;
32
- export declare function blendColors(foreground: string, background: string): string | null;
32
+ export declare function blendColors(foreground: string, background: string, factor?: number): string | null;
33
33
  export declare const isValidHexColor: (hex: string) => boolean;
34
+ export declare const getColorBrightness: (color: string) => number;
@@ -1,4 +1,4 @@
1
- import { Meta, StoryObj } from "@storybook/react";
1
+ import { type Meta, type StoryObj } from "@storybook/react";
2
2
  import { SwapConfiguration } from "../../components/layout/SwapConfiguration";
3
3
  declare const meta: Meta<typeof SwapConfiguration>;
4
4
  export default meta;
@@ -25,6 +25,7 @@ export declare const FromAddressEmpty: Story;
25
25
  export declare const ToAddressEmpty: Story;
26
26
  export declare const Error: Story;
27
27
  export declare const WithTooltips: Story;
28
+ export declare const HideMaxChip: Story;
28
29
  export declare const WithoutSourceConnectLabels: Story;
29
30
  export declare const WithoutDestConnectLabels: Story;
30
31
  export declare const AddressOnly: Story;
@@ -0,0 +1,13 @@
1
+ import { type Meta, type StoryObj } from "@storybook/react";
2
+ import { TokenDetailsView } from "../../components/layout/TokenDetailsView";
3
+ declare const meta: Meta<typeof TokenDetailsView>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const Default: Story;
7
+ export declare const PositivePriceChange: Story;
8
+ export declare const LowBalance: Story;
9
+ export declare const HighBalance: Story;
10
+ export declare const DifferentToken: Story;
11
+ export declare const Closed: Story;
12
+ export declare const Loading: Story;
13
+ export declare const WithFakeChart: Story;