@skip-go/widget 2.4.6 → 2.4.8

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/build/index.es.js CHANGED
@@ -1532,71 +1532,34 @@ const disclosureStore = create(persist(() => defaultValues$2, {
1532
1532
  skipHydration: true,
1533
1533
  storage: createJSONStorage(() => window.sessionStorage),
1534
1534
  }));
1535
- const scrollStore = create(() => ({ value: [] }));
1536
- function persistScroll() {
1537
- scrollStore.setState((prev) => ({
1538
- value: prev.value.concat(window.scrollY),
1539
- }));
1540
- }
1541
- function restoreScroll() {
1542
- let value;
1543
- scrollStore.setState((prev) => {
1544
- value = prev.value.pop();
1545
- return prev;
1546
- });
1547
- window.scrollTo({
1548
- top: value,
1549
- behavior: "smooth",
1550
- });
1551
- }
1552
- function scrollTop() {
1553
- window.scrollTo({
1554
- top: 0,
1555
- behavior: "smooth",
1556
- });
1557
- }
1558
1535
  const disclosure = {
1559
1536
  open: (key, { closeAll = false } = {}) => {
1560
- persistScroll();
1561
1537
  disclosureStore.setState({
1562
1538
  ...(closeAll ? defaultValues$2 : {}),
1563
1539
  [key]: true,
1564
1540
  });
1565
- if (key.toLowerCase().endsWith("dialog")) {
1566
- scrollTop();
1567
- }
1568
1541
  },
1569
1542
  openJson: (json) => {
1570
1543
  disclosureStore.setState({ json });
1571
- persistScroll();
1572
- scrollTop();
1573
1544
  },
1574
1545
  close: (key) => {
1575
1546
  disclosureStore.setState({ [key]: false });
1576
- restoreScroll();
1577
1547
  },
1578
1548
  closeJson: () => {
1579
1549
  disclosureStore.setState({ json: undefined });
1580
- restoreScroll();
1581
1550
  },
1582
1551
  toggle: (key) => {
1583
1552
  let latest;
1584
1553
  disclosureStore.setState((prev) => {
1585
1554
  latest = !prev[key];
1586
- if (latest)
1587
- persistScroll();
1588
1555
  return { [key]: latest };
1589
1556
  });
1590
- if (typeof latest === "boolean" && !latest) {
1591
- restoreScroll();
1592
- }
1593
1557
  },
1594
1558
  set: (key, value) => {
1595
1559
  disclosureStore.setState({ [key]: value });
1596
1560
  },
1597
1561
  closeAll: () => {
1598
1562
  disclosureStore.setState(defaultValues$2);
1599
- restoreScroll();
1600
1563
  },
1601
1564
  rehydrate: () => disclosureStore.persist.rehydrate(),
1602
1565
  };
@@ -4081,8 +4044,9 @@ priceImpactPercent, priceImpactThresholdReached, route, sourceAsset, sourceChain
4081
4044
  maximumFractionDigits: 6,
4082
4045
  });
4083
4046
  return {
4084
- inAsset: `${computed} ${feeAsset.symbol}`,
4085
- inUSD: usdFeeAmount && `${formatUSD(usdFeeAmount)}`,
4047
+ assetAmount: Number(computed),
4048
+ formattedAssetAmount: `${computed} ${feeAsset.symbol}`,
4049
+ formattedUsdAmount: usdFeeAmount ? `${formatUSD(usdFeeAmount)}` : undefined
4086
4050
  };
4087
4051
  }
4088
4052
  if (axelarTransferOperation) {
@@ -4091,8 +4055,9 @@ priceImpactPercent, priceImpactThresholdReached, route, sourceAsset, sourceChain
4091
4055
  maximumFractionDigits: 6,
4092
4056
  });
4093
4057
  return {
4094
- inAsset: `${computed} ${feeAsset.symbol}`,
4095
- inUSD: `${formatUSD(usdFeeAmount)}`,
4058
+ assetAmount: Number(computed),
4059
+ formattedAssetAmount: `${computed} ${feeAsset.symbol}`,
4060
+ formattedUsdAmount: usdFeeAmount ? `${formatUSD(usdFeeAmount)}` : undefined
4096
4061
  };
4097
4062
  }
4098
4063
  }, [axelarTransferOperation, hyperlaneTransferOperation]);
@@ -4110,17 +4075,15 @@ priceImpactPercent, priceImpactThresholdReached, route, sourceAsset, sourceChain
4110
4075
  maximumFractionDigits: 6,
4111
4076
  });
4112
4077
  return {
4113
- amount: Number(inAsset),
4114
- inAsset: `${inAsset} ${fee[0].originAsset.symbol}`,
4115
- inUSD: `${formatUSD(computedUsd)}`,
4078
+ assetAmount: Number(inAsset),
4079
+ formattedAssetAmount: `${inAsset} ${fee[0].originAsset.symbol}`,
4080
+ formattedUsdAmount: `${formatUSD(computedUsd)}`
4116
4081
  };
4117
4082
  }, [isSmartRelay, route.estimatedFees]);
4118
4083
  const totalAmountOut = useMemo(() => {
4119
- if (isSmartRelay) {
4120
- return String(parseFloat(amountOut) + ((smartRelayFee === null || smartRelayFee === void 0 ? void 0 : smartRelayFee.amount) || 0));
4121
- }
4122
- return amountOut;
4123
- }, [amountOut, isSmartRelay, smartRelayFee === null || smartRelayFee === void 0 ? void 0 : smartRelayFee.amount]);
4084
+ var _a, _b;
4085
+ return String(parseFloat(amountOut) + ((_a = smartRelayFee === null || smartRelayFee === void 0 ? void 0 : smartRelayFee.assetAmount) !== null && _a !== void 0 ? _a : 0) + ((_b = bridgingFee === null || bridgingFee === void 0 ? void 0 : bridgingFee.assetAmount) !== null && _b !== void 0 ? _b : 0));
4086
+ }, [amountOut, smartRelayFee === null || smartRelayFee === void 0 ? void 0 : smartRelayFee.assetAmount, bridgingFee === null || bridgingFee === void 0 ? void 0 : bridgingFee.assetAmount]);
4124
4087
  if (!(sourceChain && sourceAsset && destinationChain && destinationAsset)) {
4125
4088
  return null;
4126
4089
  }
@@ -4129,7 +4092,7 @@ priceImpactPercent, priceImpactThresholdReached, route, sourceAsset, sourceChain
4129
4092
  return (jsxs("div", { children: [jsxs("button", { className: "mr-2 tabular-nums", onClick: toggle, children: ["1 ", ((_a = left.recommendedSymbol) !== null && _a !== void 0 ? _a : '').replace(/\sEthereum$/, ''), " =", ' ', conversion.toLocaleString('en-US', {
4130
4093
  maximumFractionDigits: 4,
4131
4094
  }), ' ', ((_b = right.recommendedSymbol) !== null && _b !== void 0 ? _b : '').replace(/\sEthereum$/, '')] }), jsx("span", { className: "tabular-nums text-neutral-400", children: jsx(UsdValue, { error: null, chainId: right.chainID, denom: right.denom, coingeckoID: right.coingeckoID, value: conversion.toString() }) })] }));
4132
- } }), jsx("div", { className: "flex-grow" }), jsxs(Collapsible.Trigger, { className: cn('relative flex items-center gap-1 text-xs', "before:absolute before:-inset-2 before:content-['']", 'text-neutral-400'), children: [jsxs("span", { className: cn('animate-slide-left-and-fade tabular-nums text-neutral-400 transition-opacity', detailsOpen && 'hidden'), children: ["Slippage: ", slippage, "%"] }), jsx(ChevronDownIcon$1, { className: cn('h-4 w-4 transition', detailsOpen ? 'rotate-180' : 'rotate-0') })] })] }), jsx(Collapsible.Content, { className: cn('overflow-hidden', 'data-[state=open]:animate-collapsible-open', 'data-[state=closed]:animate-collapsible-closed'), children: jsxs("dl", { className: cn('mb-2 mt-4 grid grid-cols-2 gap-2', '[&_dt]:text-start [&_dt]:text-neutral-400', '[&_dd]:text-end [&_dd]:tabular-nums'), children: [priceImpactPercent ? (jsxs(Fragment, { children: [jsx("dt", { className: priceImpactThresholdReached ? 'text-red-500' : '', children: "Price Impact" }), jsx("dd", { className: priceImpactThresholdReached ? 'text-red-500' : '', children: formatPercent(priceImpactPercent) })] })) : null, jsx("dt", { children: "Slippage" }), jsxs("dd", { children: [jsx(SimpleTooltip, { label: "Click to change maximum slippage", children: jsx(StyledThemedButton, { className: cn('mr-1 inline-flex items-center gap-1 p-1 text-xs transition-colors', 'text-red-500', 'rounded'), onClick: () => disclosure.open('settingsDialog'), children: jsx(PencilSquareIcon, { className: "h-3 w-3" }) }) }), slippage, "%"] }), sourceFeeAsset && (jsxs(Fragment, { children: [jsx("dt", { children: "Estimated Transaction Fee" }), sourceChain.chainID !== 'stride-1' ? (jsxs("dd", { children: [gasRequired !== null && gasRequired !== void 0 ? gasRequired : '-', " ", sourceFeeAsset.recommendedSymbol] })) : (jsx("dd", { children: "--" }))] })), bridgingFee && (jsxs(Fragment, { children: [jsx("dt", { children: "Bridging Fee" }), jsxs("dd", { children: [(_b = bridgingFee === null || bridgingFee === void 0 ? void 0 : bridgingFee.inAsset) !== null && _b !== void 0 ? _b : '-', ' ', jsx("span", { className: "text-sm tabular-nums text-neutral-400", children: (_c = bridgingFee === null || bridgingFee === void 0 ? void 0 : bridgingFee.inUSD) !== null && _c !== void 0 ? _c : '-' })] })] })), smartRelayFee && (jsxs(Fragment, { children: [jsx("dt", { children: "Relayer Fee" }), jsxs("dd", { children: [(_d = smartRelayFee === null || smartRelayFee === void 0 ? void 0 : smartRelayFee.inAsset) !== null && _d !== void 0 ? _d : '-', ' ', jsx("span", { className: "text-sm tabular-nums text-neutral-400", children: (_e = smartRelayFee === null || smartRelayFee === void 0 ? void 0 : smartRelayFee.inUSD) !== null && _e !== void 0 ? _e : '-' })] })] }))] }) })] }));
4095
+ } }), jsx("div", { className: "flex-grow" }), jsxs(Collapsible.Trigger, { className: cn('relative flex items-center gap-1 text-xs', "before:absolute before:-inset-2 before:content-['']", 'text-neutral-400'), children: [jsxs("span", { className: cn('animate-slide-left-and-fade tabular-nums text-neutral-400 transition-opacity', detailsOpen && 'hidden'), children: ["Slippage: ", slippage, "%"] }), jsx(ChevronDownIcon$1, { className: cn('h-4 w-4 transition', detailsOpen ? 'rotate-180' : 'rotate-0') })] })] }), jsx(Collapsible.Content, { className: cn('overflow-hidden', 'data-[state=open]:animate-collapsible-open', 'data-[state=closed]:animate-collapsible-closed'), children: jsxs("dl", { className: cn('mb-2 mt-4 grid grid-cols-2 gap-2', '[&_dt]:text-start [&_dt]:text-neutral-400', '[&_dd]:text-end [&_dd]:tabular-nums'), children: [priceImpactPercent ? (jsxs(Fragment, { children: [jsx("dt", { className: priceImpactThresholdReached ? 'text-red-500' : '', children: "Price Impact" }), jsx("dd", { className: priceImpactThresholdReached ? 'text-red-500' : '', children: formatPercent(priceImpactPercent) })] })) : null, jsx("dt", { children: "Slippage" }), jsxs("dd", { children: [jsx(SimpleTooltip, { label: "Click to change maximum slippage", children: jsx(StyledThemedButton, { className: cn('mr-1 inline-flex items-center gap-1 p-1 text-xs transition-colors', 'text-red-500', 'rounded'), onClick: () => disclosure.open('settingsDialog'), children: jsx(PencilSquareIcon, { className: "h-3 w-3" }) }) }), slippage, "%"] }), sourceFeeAsset && (jsxs(Fragment, { children: [jsx("dt", { children: "Estimated Transaction Fee" }), sourceChain.chainID !== 'stride-1' ? (jsxs("dd", { children: [gasRequired !== null && gasRequired !== void 0 ? gasRequired : '-', " ", sourceFeeAsset.recommendedSymbol] })) : (jsx("dd", { children: "--" }))] })), bridgingFee && (jsxs(Fragment, { children: [jsx("dt", { children: "Bridging Fee" }), jsxs("dd", { children: [(_b = bridgingFee === null || bridgingFee === void 0 ? void 0 : bridgingFee.formattedAssetAmount) !== null && _b !== void 0 ? _b : '-', ' ', jsx("span", { className: "text-sm tabular-nums text-neutral-400", children: (_c = bridgingFee === null || bridgingFee === void 0 ? void 0 : bridgingFee.formattedUsdAmount) !== null && _c !== void 0 ? _c : '-' })] })] })), smartRelayFee && (jsxs(Fragment, { children: [jsx("dt", { children: "Relayer Fee" }), jsxs("dd", { children: [(_d = smartRelayFee === null || smartRelayFee === void 0 ? void 0 : smartRelayFee.formattedAssetAmount) !== null && _d !== void 0 ? _d : '-', ' ', jsx("span", { className: "text-sm tabular-nums text-neutral-400", children: (_e = smartRelayFee === null || smartRelayFee === void 0 ? void 0 : smartRelayFee.formattedUsdAmount) !== null && _e !== void 0 ? _e : '-' })] })] }))] }) })] }));
4133
4096
  };
4134
4097
 
4135
4098
  const iconMap = {