@0xsquid/ui 2.8.2-xrpl-beta.0 → 2.8.2

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
@@ -20831,8 +20831,8 @@ function QrCode({ matrix, size: renderedSize, imageUrl }) {
20831
20831
  } }) }))] }));
20832
20832
  }
20833
20833
 
20834
- function QrCodeModal({ qrData, imageUrl, handleClose, handleGoBack, isModalOpen, footerText, title, }) {
20835
- return (jsxRuntime.jsxs(Modal, { onBackdropClick: handleClose, isOpen: isModalOpen, children: [jsxRuntime.jsxs(ModalContent, { addGap: true, children: [jsxRuntime.jsx(NavigationBar, { displayBackButton: !!handleGoBack, onBackButtonClick: handleGoBack, subtitle: title, transparent: true }), jsxRuntime.jsx("div", { className: "tw-flex tw-items-center tw-justify-center tw-gap-squid-xs tw-self-stretch tw-px-squid-m tw-py-squid-xs", children: jsxRuntime.jsx("div", { className: "tw-flex tw-aspect-square tw-size-[22.5rem] tw-items-center tw-justify-center tw-rounded-squid-m tw-border tw-border-material-light-thin tw-bg-grey-900 tw-p-squid-m tw-shadow-elevation-light-1", children: qrData ? (jsxRuntime.jsx(QrCode, { matrix: qrData, size: 320, imageUrl: imageUrl })) : (jsxRuntime.jsx(Loader, { className: "tw-text-grey-300", size: "32", strokeWidth: "3" })) }) }), jsxRuntime.jsx("footer", { className: "tw-flex tw-flex-col tw-items-center tw-gap-squid-xs tw-self-stretch tw-px-squid-m tw-pb-squid-l tw-pt-squid-xs", children: jsxRuntime.jsx(CaptionText, { className: "tw-text-center tw-text-grey-500", children: footerText }) })] }), jsxRuntime.jsx(Button$1, { size: "lg", variant: "secondary", label: "Cancel", onClick: handleClose })] }));
20834
+ function QrCodeModal({ qrData, imageUrl, handleClose, handleGoBack, isModalOpen, footerContent, title, isError, }) {
20835
+ return (jsxRuntime.jsxs(Modal, { onBackdropClick: handleClose, isOpen: isModalOpen, children: [jsxRuntime.jsxs(ModalContent, { addGap: true, className: "tw-pb-squid-s", children: [jsxRuntime.jsx(NavigationBar, { displayBackButton: !!handleGoBack, onBackButtonClick: handleGoBack, subtitle: title, transparent: true }), jsxRuntime.jsx("div", { className: "tw-flex tw-items-center tw-justify-center tw-gap-squid-xs tw-self-stretch tw-px-squid-m tw-py-squid-xs", children: jsxRuntime.jsx("div", { className: "tw-flex tw-aspect-square tw-size-[22.5rem] tw-items-center tw-justify-center tw-rounded-squid-m tw-border tw-border-material-light-thin tw-bg-grey-900 tw-p-squid-m tw-shadow-elevation-light-1", children: isError ? (jsxRuntime.jsx(SwapErrorIcon, {})) : qrData ? (jsxRuntime.jsx(QrCode, { matrix: qrData, size: 320, imageUrl: imageUrl })) : (jsxRuntime.jsx(Loader, { className: "tw-text-grey-300", size: "32", strokeWidth: "3" })) }) }), jsxRuntime.jsx("footer", { className: "tw-flex tw-flex-col tw-items-center tw-gap-squid-xs tw-self-stretch tw-px-squid-m tw-text-center tw-text-grey-500", children: footerContent })] }), jsxRuntime.jsx(Button$1, { size: "lg", variant: "secondary", label: "Cancel", onClick: handleClose })] }));
20836
20836
  }
20837
20837
 
20838
20838
  const AddressHeader = ({ direction, onClick, isDisabled, tooltip, label, walletIconUrl, isLoading, displayLabel = true, highlightLabel = false, showIcon = true, }) => {
@@ -20841,7 +20841,7 @@ const AddressHeader = ({ direction, onClick, isDisabled, tooltip, label, walletI
20841
20841
  (walletIconUrl ? (jsxRuntime.jsx(Image$1, { className: "!tw-h-6 !tw-w-6 !tw-rounded-lg", src: walletIconUrl })) : (jsxRuntime.jsx("div", { className: "tw-flex tw-h-6 tw-w-6 tw-items-center tw-justify-center tw-rounded-lg tw-bg-royal-500 tw-px-0.5 tw-text-grey-900 tw-outline tw-outline-1 tw-outline-material-light-thin", children: jsxRuntime.jsx(WalletIcon, { size: "18" }) }))), jsxRuntime.jsx(BodyText, { size: "small", className: cn(highlightLabel ? "tw-text-royal-500" : "tw-text-grey-300"), children: label }), jsxRuntime.jsx(ChevronArrowIcon, { className: cn(highlightLabel ? "tw-text-royal-500" : "tw-text-grey-600"), size: "16" })] })] }))] }) })) }));
20842
20842
  };
20843
20843
  function SwapConfiguration({ amount, tokenPrice = 0, isFetching: isFetchingProp = false, chain, token, direction = "from", onAmountChange, balance, criticalPriceImpactPercentage, error, priceImpactPercentage, maxUsdDecimals, isInputInteractive = true, isLoading = false, inputModeButton, balanceButton, assetsButton, walletButton, showNumericInputDetails = true, fullHeight = true, debounceInput = true, showWalletButtonHeader = true, }) {
20844
- var _a, _b, _c;
20844
+ var _a, _b, _c, _d, _e;
20845
20845
  const isFetching = isFetchingProp || isLoading;
20846
20846
  const [forcedAmount, setForcedAmount] = React$1.useState(amount);
20847
20847
  const prevRef = React$1.useRef({
@@ -20851,8 +20851,10 @@ function SwapConfiguration({ amount, tokenPrice = 0, isFetching: isFetchingProp
20851
20851
  });
20852
20852
  // Save previous amount between renders for transition animation.
20853
20853
  React$1.useEffect(() => {
20854
- if (direction === "from")
20854
+ if (direction === "from") {
20855
+ setForcedAmount(amount);
20855
20856
  return;
20857
+ }
20856
20858
  const { amount: prevAmount, chain: prevChain, token: prevToken, } = prevRef.current;
20857
20859
  const currentChain = JSON.stringify(chain);
20858
20860
  const currentToken = JSON.stringify(token);
@@ -20866,11 +20868,9 @@ function SwapConfiguration({ amount, tokenPrice = 0, isFetching: isFetchingProp
20866
20868
  }
20867
20869
  setForcedAmount(prevRef.current.amount);
20868
20870
  }, [amount, chain, token]);
20869
- return (jsxRuntime.jsxs("section", { className: cn("tw-relative tw-flex tw-w-full tw-flex-col tw-border-t tw-border-t-material-light-thin tw-bg-grey-900 mobile-lg:tw-w-card-large", fullHeight && "tw-h-full tw-pb-squid-m"), children: [jsxRuntime.jsx(AddressHeader, { direction: direction, onClick: walletButton === null || walletButton === void 0 ? void 0 : walletButton.onClick, isDisabled: walletButton === null || walletButton === void 0 ? void 0 : walletButton.disabled, tooltip: walletButton === null || walletButton === void 0 ? void 0 : walletButton.tooltip, label: (walletButton === null || walletButton === void 0 ? void 0 : walletButton.address) ||
20870
- (walletButton === null || walletButton === void 0 ? void 0 : walletButton.emptyAddressLabel) ||
20871
- (direction === "from" ? "Connect wallet" : "Select recipient"), walletIconUrl: walletButton === null || walletButton === void 0 ? void 0 : walletButton.walletIconUrl, isLoading: isLoading, displayLabel: showWalletButtonHeader, highlightLabel: !(walletButton === null || walletButton === void 0 ? void 0 : walletButton.address), showIcon: (_a = walletButton === null || walletButton === void 0 ? void 0 : walletButton.showIcon) !== null && _a !== void 0 ? _a : true }), jsxRuntime.jsx("div", { className: "tw-px-squid-m mobile-lg:tw-px-squid-l", children: jsxRuntime.jsx(AssetsButton, Object.assign({}, assetsButton, { chain: chain, token: token, isLoading: isLoading })) }), jsxRuntime.jsx(NumericInput, { inputMode: "decimal", pattern: "[0-9.,]*", token: {
20872
- decimals: (_b = token === null || token === void 0 ? void 0 : token.decimals) !== null && _b !== void 0 ? _b : 18,
20873
- symbol: (_c = token === null || token === void 0 ? void 0 : token.symbol) !== null && _c !== void 0 ? _c : "",
20871
+ return (jsxRuntime.jsxs("section", { className: cn("tw-relative tw-flex tw-w-full tw-flex-col tw-border-t tw-border-t-material-light-thin tw-bg-grey-900 mobile-lg:tw-w-card-large", fullHeight && "tw-h-full tw-pb-squid-m"), children: [jsxRuntime.jsx(AddressHeader, { direction: direction, onClick: walletButton === null || walletButton === void 0 ? void 0 : walletButton.onClick, isDisabled: walletButton === null || walletButton === void 0 ? void 0 : walletButton.disabled, tooltip: walletButton === null || walletButton === void 0 ? void 0 : walletButton.tooltip, label: (_b = (_a = walletButton === null || walletButton === void 0 ? void 0 : walletButton.address) !== null && _a !== void 0 ? _a : walletButton === null || walletButton === void 0 ? void 0 : walletButton.emptyAddressLabel) !== null && _b !== void 0 ? _b : (direction === "from" ? "Connect wallet" : "Select recipient"), walletIconUrl: walletButton === null || walletButton === void 0 ? void 0 : walletButton.walletIconUrl, isLoading: isLoading, displayLabel: showWalletButtonHeader, highlightLabel: !(walletButton === null || walletButton === void 0 ? void 0 : walletButton.address), showIcon: (_c = walletButton === null || walletButton === void 0 ? void 0 : walletButton.showIcon) !== null && _c !== void 0 ? _c : true }), jsxRuntime.jsx("div", { className: "tw-px-squid-m mobile-lg:tw-px-squid-l", children: jsxRuntime.jsx(AssetsButton, Object.assign({}, assetsButton, { chain: chain, token: token, isLoading: isLoading })) }), jsxRuntime.jsx(NumericInput, { inputMode: "decimal", pattern: "[0-9.,]*", token: {
20872
+ decimals: (_d = token === null || token === void 0 ? void 0 : token.decimals) !== null && _d !== void 0 ? _d : 18,
20873
+ symbol: (_e = token === null || token === void 0 ? void 0 : token.symbol) !== null && _e !== void 0 ? _e : "",
20874
20874
  price: tokenPrice,
20875
20875
  }, onAmountChange: (value) => {
20876
20876
  onAmountChange === null || onAmountChange === void 0 ? void 0 : onAmountChange(value);
@@ -1,11 +1,13 @@
1
+ /// <reference types="react" />
1
2
  interface QrCodeModalProps {
2
3
  qrData: boolean[][] | undefined;
3
4
  imageUrl?: string;
4
5
  handleClose: () => void;
5
6
  handleGoBack?: () => void;
6
7
  isModalOpen: boolean | undefined;
7
- footerText: string;
8
+ footerContent: React.ReactNode;
8
9
  title: string;
10
+ isError?: boolean;
9
11
  }
10
- export declare function QrCodeModal({ qrData, imageUrl, handleClose, handleGoBack, isModalOpen, footerText, title, }: QrCodeModalProps): import("react/jsx-runtime").JSX.Element;
12
+ export declare function QrCodeModal({ qrData, imageUrl, handleClose, handleGoBack, isModalOpen, footerContent, title, isError, }: QrCodeModalProps): import("react/jsx-runtime").JSX.Element;
11
13
  export {};
@@ -5,4 +5,5 @@ export default meta;
5
5
  type Story = StoryObj<typeof meta>;
6
6
  export declare const QrData: Story;
7
7
  export declare const Loading: Story;
8
+ export declare const Error: Story;
8
9
  export declare const GoBackButton: Story;
package/dist/esm/index.js CHANGED
@@ -20811,8 +20811,8 @@ function QrCode({ matrix, size: renderedSize, imageUrl }) {
20811
20811
  } }) }))] }));
20812
20812
  }
20813
20813
 
20814
- function QrCodeModal({ qrData, imageUrl, handleClose, handleGoBack, isModalOpen, footerText, title, }) {
20815
- return (jsxs(Modal, { onBackdropClick: handleClose, isOpen: isModalOpen, children: [jsxs(ModalContent, { addGap: true, children: [jsx(NavigationBar, { displayBackButton: !!handleGoBack, onBackButtonClick: handleGoBack, subtitle: title, transparent: true }), jsx("div", { className: "tw-flex tw-items-center tw-justify-center tw-gap-squid-xs tw-self-stretch tw-px-squid-m tw-py-squid-xs", children: jsx("div", { className: "tw-flex tw-aspect-square tw-size-[22.5rem] tw-items-center tw-justify-center tw-rounded-squid-m tw-border tw-border-material-light-thin tw-bg-grey-900 tw-p-squid-m tw-shadow-elevation-light-1", children: qrData ? (jsx(QrCode, { matrix: qrData, size: 320, imageUrl: imageUrl })) : (jsx(Loader, { className: "tw-text-grey-300", size: "32", strokeWidth: "3" })) }) }), jsx("footer", { className: "tw-flex tw-flex-col tw-items-center tw-gap-squid-xs tw-self-stretch tw-px-squid-m tw-pb-squid-l tw-pt-squid-xs", children: jsx(CaptionText, { className: "tw-text-center tw-text-grey-500", children: footerText }) })] }), jsx(Button$1, { size: "lg", variant: "secondary", label: "Cancel", onClick: handleClose })] }));
20814
+ function QrCodeModal({ qrData, imageUrl, handleClose, handleGoBack, isModalOpen, footerContent, title, isError, }) {
20815
+ return (jsxs(Modal, { onBackdropClick: handleClose, isOpen: isModalOpen, children: [jsxs(ModalContent, { addGap: true, className: "tw-pb-squid-s", children: [jsx(NavigationBar, { displayBackButton: !!handleGoBack, onBackButtonClick: handleGoBack, subtitle: title, transparent: true }), jsx("div", { className: "tw-flex tw-items-center tw-justify-center tw-gap-squid-xs tw-self-stretch tw-px-squid-m tw-py-squid-xs", children: jsx("div", { className: "tw-flex tw-aspect-square tw-size-[22.5rem] tw-items-center tw-justify-center tw-rounded-squid-m tw-border tw-border-material-light-thin tw-bg-grey-900 tw-p-squid-m tw-shadow-elevation-light-1", children: isError ? (jsx(SwapErrorIcon, {})) : qrData ? (jsx(QrCode, { matrix: qrData, size: 320, imageUrl: imageUrl })) : (jsx(Loader, { className: "tw-text-grey-300", size: "32", strokeWidth: "3" })) }) }), jsx("footer", { className: "tw-flex tw-flex-col tw-items-center tw-gap-squid-xs tw-self-stretch tw-px-squid-m tw-text-center tw-text-grey-500", children: footerContent })] }), jsx(Button$1, { size: "lg", variant: "secondary", label: "Cancel", onClick: handleClose })] }));
20816
20816
  }
20817
20817
 
20818
20818
  const AddressHeader = ({ direction, onClick, isDisabled, tooltip, label, walletIconUrl, isLoading, displayLabel = true, highlightLabel = false, showIcon = true, }) => {
@@ -20821,7 +20821,7 @@ const AddressHeader = ({ direction, onClick, isDisabled, tooltip, label, walletI
20821
20821
  (walletIconUrl ? (jsx(Image$1, { className: "!tw-h-6 !tw-w-6 !tw-rounded-lg", src: walletIconUrl })) : (jsx("div", { className: "tw-flex tw-h-6 tw-w-6 tw-items-center tw-justify-center tw-rounded-lg tw-bg-royal-500 tw-px-0.5 tw-text-grey-900 tw-outline tw-outline-1 tw-outline-material-light-thin", children: jsx(WalletIcon, { size: "18" }) }))), jsx(BodyText, { size: "small", className: cn(highlightLabel ? "tw-text-royal-500" : "tw-text-grey-300"), children: label }), jsx(ChevronArrowIcon, { className: cn(highlightLabel ? "tw-text-royal-500" : "tw-text-grey-600"), size: "16" })] })] }))] }) })) }));
20822
20822
  };
20823
20823
  function SwapConfiguration({ amount, tokenPrice = 0, isFetching: isFetchingProp = false, chain, token, direction = "from", onAmountChange, balance, criticalPriceImpactPercentage, error, priceImpactPercentage, maxUsdDecimals, isInputInteractive = true, isLoading = false, inputModeButton, balanceButton, assetsButton, walletButton, showNumericInputDetails = true, fullHeight = true, debounceInput = true, showWalletButtonHeader = true, }) {
20824
- var _a, _b, _c;
20824
+ var _a, _b, _c, _d, _e;
20825
20825
  const isFetching = isFetchingProp || isLoading;
20826
20826
  const [forcedAmount, setForcedAmount] = useState(amount);
20827
20827
  const prevRef = useRef({
@@ -20831,8 +20831,10 @@ function SwapConfiguration({ amount, tokenPrice = 0, isFetching: isFetchingProp
20831
20831
  });
20832
20832
  // Save previous amount between renders for transition animation.
20833
20833
  useEffect(() => {
20834
- if (direction === "from")
20834
+ if (direction === "from") {
20835
+ setForcedAmount(amount);
20835
20836
  return;
20837
+ }
20836
20838
  const { amount: prevAmount, chain: prevChain, token: prevToken, } = prevRef.current;
20837
20839
  const currentChain = JSON.stringify(chain);
20838
20840
  const currentToken = JSON.stringify(token);
@@ -20846,11 +20848,9 @@ function SwapConfiguration({ amount, tokenPrice = 0, isFetching: isFetchingProp
20846
20848
  }
20847
20849
  setForcedAmount(prevRef.current.amount);
20848
20850
  }, [amount, chain, token]);
20849
- return (jsxs("section", { className: cn("tw-relative tw-flex tw-w-full tw-flex-col tw-border-t tw-border-t-material-light-thin tw-bg-grey-900 mobile-lg:tw-w-card-large", fullHeight && "tw-h-full tw-pb-squid-m"), children: [jsx(AddressHeader, { direction: direction, onClick: walletButton === null || walletButton === void 0 ? void 0 : walletButton.onClick, isDisabled: walletButton === null || walletButton === void 0 ? void 0 : walletButton.disabled, tooltip: walletButton === null || walletButton === void 0 ? void 0 : walletButton.tooltip, label: (walletButton === null || walletButton === void 0 ? void 0 : walletButton.address) ||
20850
- (walletButton === null || walletButton === void 0 ? void 0 : walletButton.emptyAddressLabel) ||
20851
- (direction === "from" ? "Connect wallet" : "Select recipient"), walletIconUrl: walletButton === null || walletButton === void 0 ? void 0 : walletButton.walletIconUrl, isLoading: isLoading, displayLabel: showWalletButtonHeader, highlightLabel: !(walletButton === null || walletButton === void 0 ? void 0 : walletButton.address), showIcon: (_a = walletButton === null || walletButton === void 0 ? void 0 : walletButton.showIcon) !== null && _a !== void 0 ? _a : true }), jsx("div", { className: "tw-px-squid-m mobile-lg:tw-px-squid-l", children: jsx(AssetsButton, Object.assign({}, assetsButton, { chain: chain, token: token, isLoading: isLoading })) }), jsx(NumericInput, { inputMode: "decimal", pattern: "[0-9.,]*", token: {
20852
- decimals: (_b = token === null || token === void 0 ? void 0 : token.decimals) !== null && _b !== void 0 ? _b : 18,
20853
- symbol: (_c = token === null || token === void 0 ? void 0 : token.symbol) !== null && _c !== void 0 ? _c : "",
20851
+ return (jsxs("section", { className: cn("tw-relative tw-flex tw-w-full tw-flex-col tw-border-t tw-border-t-material-light-thin tw-bg-grey-900 mobile-lg:tw-w-card-large", fullHeight && "tw-h-full tw-pb-squid-m"), children: [jsx(AddressHeader, { direction: direction, onClick: walletButton === null || walletButton === void 0 ? void 0 : walletButton.onClick, isDisabled: walletButton === null || walletButton === void 0 ? void 0 : walletButton.disabled, tooltip: walletButton === null || walletButton === void 0 ? void 0 : walletButton.tooltip, label: (_b = (_a = walletButton === null || walletButton === void 0 ? void 0 : walletButton.address) !== null && _a !== void 0 ? _a : walletButton === null || walletButton === void 0 ? void 0 : walletButton.emptyAddressLabel) !== null && _b !== void 0 ? _b : (direction === "from" ? "Connect wallet" : "Select recipient"), walletIconUrl: walletButton === null || walletButton === void 0 ? void 0 : walletButton.walletIconUrl, isLoading: isLoading, displayLabel: showWalletButtonHeader, highlightLabel: !(walletButton === null || walletButton === void 0 ? void 0 : walletButton.address), showIcon: (_c = walletButton === null || walletButton === void 0 ? void 0 : walletButton.showIcon) !== null && _c !== void 0 ? _c : true }), jsx("div", { className: "tw-px-squid-m mobile-lg:tw-px-squid-l", children: jsx(AssetsButton, Object.assign({}, assetsButton, { chain: chain, token: token, isLoading: isLoading })) }), jsx(NumericInput, { inputMode: "decimal", pattern: "[0-9.,]*", token: {
20852
+ decimals: (_d = token === null || token === void 0 ? void 0 : token.decimals) !== null && _d !== void 0 ? _d : 18,
20853
+ symbol: (_e = token === null || token === void 0 ? void 0 : token.symbol) !== null && _e !== void 0 ? _e : "",
20854
20854
  price: tokenPrice,
20855
20855
  }, onAmountChange: (value) => {
20856
20856
  onAmountChange === null || onAmountChange === void 0 ? void 0 : onAmountChange(value);
@@ -1,11 +1,13 @@
1
+ /// <reference types="react" />
1
2
  interface QrCodeModalProps {
2
3
  qrData: boolean[][] | undefined;
3
4
  imageUrl?: string;
4
5
  handleClose: () => void;
5
6
  handleGoBack?: () => void;
6
7
  isModalOpen: boolean | undefined;
7
- footerText: string;
8
+ footerContent: React.ReactNode;
8
9
  title: string;
10
+ isError?: boolean;
9
11
  }
10
- export declare function QrCodeModal({ qrData, imageUrl, handleClose, handleGoBack, isModalOpen, footerText, title, }: QrCodeModalProps): import("react/jsx-runtime").JSX.Element;
12
+ export declare function QrCodeModal({ qrData, imageUrl, handleClose, handleGoBack, isModalOpen, footerContent, title, isError, }: QrCodeModalProps): import("react/jsx-runtime").JSX.Element;
11
13
  export {};
@@ -5,4 +5,5 @@ export default meta;
5
5
  type Story = StoryObj<typeof meta>;
6
6
  export declare const QrData: Story;
7
7
  export declare const Loading: Story;
8
+ export declare const Error: Story;
8
9
  export declare const GoBackButton: Story;
package/dist/index.d.ts CHANGED
@@ -1251,10 +1251,11 @@ interface QrCodeModalProps {
1251
1251
  handleClose: () => void;
1252
1252
  handleGoBack?: () => void;
1253
1253
  isModalOpen: boolean | undefined;
1254
- footerText: string;
1254
+ footerContent: React.ReactNode;
1255
1255
  title: string;
1256
+ isError?: boolean;
1256
1257
  }
1257
- declare function QrCodeModal({ qrData, imageUrl, handleClose, handleGoBack, isModalOpen, footerText, title, }: QrCodeModalProps): react_jsx_runtime.JSX.Element;
1258
+ declare function QrCodeModal({ qrData, imageUrl, handleClose, handleGoBack, isModalOpen, footerContent, title, isError, }: QrCodeModalProps): react_jsx_runtime.JSX.Element;
1258
1259
 
1259
1260
  interface AddressHeaderProps {
1260
1261
  direction: SwapDirection;
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": "2.8.2-xrpl-beta.0",
8
+ "version": "2.8.2",
9
9
  "author": "",
10
10
  "license": "MIT",
11
11
  "resolutions": {