@0xsquid/ui 0.14.0 → 0.15.1

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.
@@ -1,11 +1,31 @@
1
- import type { InputHTMLAttributes } from 'react';
2
- interface Props extends InputHTMLAttributes<HTMLInputElement> {
3
- onParsedValueChanged: (value: string) => void;
4
- initialValue?: string;
5
- forcedUpdateValue?: string;
6
- maxDecimals?: number;
1
+ import { SwapDirection } from '../../types/components';
2
+ interface Token {
3
+ price: number;
4
+ symbol: string;
5
+ decimals: number;
6
+ }
7
+ interface NumericInputProps {
8
+ token: Token;
9
+ onAmountChange: (tokenAmount: string) => void;
10
+ forcedAmount?: string;
11
+ maxDecimals?: {
12
+ token: number;
13
+ usd: number;
14
+ };
15
+ formatIfVerySmall?: {
16
+ token: string;
17
+ usd: string;
18
+ };
19
+ showDetails?: boolean;
20
+ isLoading?: boolean;
21
+ error?: {
22
+ message: string;
23
+ };
7
24
  balance?: string;
8
- tokenPrice?: number;
25
+ priceImpactPercentage?: string;
26
+ criticalPriceImpactPercentage?: number;
27
+ direction?: SwapDirection;
28
+ amountUsd?: string;
9
29
  }
10
- export declare const NumericInput: ({ onParsedValueChanged, initialValue, forcedUpdateValue, maxDecimals, balance, tokenPrice, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
30
+ export declare function NumericInput({ priceImpactPercentage, balance, error, criticalPriceImpactPercentage, token, onAmountChange, forcedAmount, maxDecimals, formatIfVerySmall, showDetails, isLoading, direction, amountUsd, }: NumericInputProps): import("react/jsx-runtime").JSX.Element;
11
31
  export {};
@@ -4,7 +4,7 @@ interface SwapConfigurationProps {
4
4
  priceImpactPercentage?: string;
5
5
  amount?: string;
6
6
  forcedAmount?: string;
7
- swapAmountUsd?: string;
7
+ amountUsd?: string;
8
8
  tokenPrice?: number;
9
9
  balance?: string;
10
10
  isFetching?: boolean;
@@ -23,13 +23,11 @@ interface SwapConfigurationProps {
23
23
  onAmountChange?: (amount: string) => void;
24
24
  onWalletButtonClick?: () => void;
25
25
  onAssetsButtonClick?: () => void;
26
- onBalanceButtonClick?: () => void;
27
26
  error?: {
28
27
  message: string;
29
28
  };
30
29
  criticalPriceImpactPercentage?: number;
31
30
  emptyAddressLabel?: string;
32
- onSwapAmountButtonClick?: () => void;
33
31
  }
34
- export declare function SwapConfiguration({ priceImpactPercentage, amount, forcedAmount, swapAmountUsd, balance, tokenPrice, isFetching, chain, token, direction, onAmountChange, onWalletButtonClick, onAssetsButtonClick, onBalanceButtonClick, onSwapAmountButtonClick, address, error, criticalPriceImpactPercentage, emptyAddressLabel, }: SwapConfigurationProps): import("react/jsx-runtime").JSX.Element;
32
+ export declare function SwapConfiguration({ amount, tokenPrice, isFetching, chain, token, direction, onAmountChange, onWalletButtonClick, onAssetsButtonClick, address, emptyAddressLabel, balance, criticalPriceImpactPercentage, error, priceImpactPercentage, amountUsd, }: SwapConfigurationProps): import("react/jsx-runtime").JSX.Element;
35
33
  export {};
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Convert token amount to USD
3
+ * @param {string|number} tokenAmount - The amount of tokens
4
+ * @param {string|number} tokenPrice - The price of one token in USD
5
+ * @returns {BigNumber} - The equivalent amount in USD
6
+ */
7
+ export declare function convertTokenAmountToUSD(tokenAmount: string | number, tokenPrice: string | number, maxDecimals?: number): string;
8
+ /**
9
+ * Convert USD to token amount
10
+ * @param {string|number} usdAmount - The amount in USD
11
+ * @param {string|number} tokenPrice - The price of one token in USD
12
+ * @param {number} maxDecimals - The maximum number of decimals
13
+ * @returns {BigNumber} - The equivalent amount of tokens
14
+ */
15
+ export declare function convertUSDToTokenAmount(usdAmount: string | number, tokenPrice: string | number, maxDecimals: number): string;
16
+ /**
17
+ * Formats a number to the en-US number format
18
+ *
19
+ * @param amount - The number to format
20
+ * @returns The formatted string
21
+ */
22
+ export declare function formatAmount(amount: number | bigint | string): string;
23
+ export declare function trimExtraDecimals(value: string, maxDecimals?: number): string;
@@ -26,3 +26,4 @@ export declare enum SwapState {
26
26
  export type DetailsToolbarState = 'full' | 'loading' | 'empty' | 'error';
27
27
  export type ThemeType = 'light' | 'dark';
28
28
  export type SwapStepItemStatus = 'pending' | 'waiting' | 'ongoing' | 'executed' | 'success' | 'error' | 'warning';
29
+ export type InputMode = 'token' | 'price';
package/dist/index.css CHANGED
@@ -677,6 +677,10 @@ video {
677
677
  left: 2px;
678
678
  }
679
679
 
680
+ .tw-left-\[30px\] {
681
+ left: 30px;
682
+ }
683
+
680
684
  .tw-left-\[54px\] {
681
685
  left: 54px;
682
686
  }
@@ -733,6 +737,10 @@ video {
733
737
  top: 1.75rem;
734
738
  }
735
739
 
740
+ .tw-top-\[11px\] {
741
+ top: 11px;
742
+ }
743
+
736
744
  .tw-top-\[52px\] {
737
745
  top: 52px;
738
746
  }
@@ -872,6 +880,10 @@ video {
872
880
  height: 2rem;
873
881
  }
874
882
 
883
+ .tw-h-\[100vh\] {
884
+ height: 100vh;
885
+ }
886
+
875
887
  .tw-h-\[10px\] {
876
888
  height: 10px;
877
889
  }
@@ -1113,6 +1125,10 @@ video {
1113
1125
  width: 1.5px;
1114
1126
  }
1115
1127
 
1128
+ .tw-w-\[100vw\] {
1129
+ width: 100vw;
1130
+ }
1131
+
1116
1132
  .tw-w-\[1260px\] {
1117
1133
  width: 1260px;
1118
1134
  }
@@ -2152,6 +2168,10 @@ video {
2152
2168
  padding-left: 20px;
2153
2169
  }
2154
2170
 
2171
+ .tw-pl-\[33px\] {
2172
+ padding-left: 33px;
2173
+ }
2174
+
2155
2175
  .tw-pl-\[44px\] {
2156
2176
  padding-left: 44px;
2157
2177
  }
@@ -2343,6 +2363,10 @@ video {
2343
2363
  line-height: 13px;
2344
2364
  }
2345
2365
 
2366
+ .tw-leading-\[43px\] {
2367
+ line-height: 43px;
2368
+ }
2369
+
2346
2370
  .tw-leading-body-large {
2347
2371
  line-height: 39.34px;
2348
2372
  }
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
- import React$1, { InputHTMLAttributes } from 'react';
3
+ import React$1 from 'react';
4
4
 
5
5
  interface BadgeImageProps {
6
6
  imageUrl?: string;
@@ -124,15 +124,35 @@ interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
124
124
  }
125
125
  declare function Input({ placeholder, showIcon, showPasteButton, className, icon, isError, onPasteButtonClick, containerClassName, ...props }: InputProps): react_jsx_runtime.JSX.Element;
126
126
 
127
- interface Props extends InputHTMLAttributes<HTMLInputElement> {
128
- onParsedValueChanged: (value: string) => void;
129
- initialValue?: string;
130
- forcedUpdateValue?: string;
131
- maxDecimals?: number;
127
+ interface Token$1 {
128
+ price: number;
129
+ symbol: string;
130
+ decimals: number;
131
+ }
132
+ interface NumericInputProps {
133
+ token: Token$1;
134
+ onAmountChange: (tokenAmount: string) => void;
135
+ forcedAmount?: string;
136
+ maxDecimals?: {
137
+ token: number;
138
+ usd: number;
139
+ };
140
+ formatIfVerySmall?: {
141
+ token: string;
142
+ usd: string;
143
+ };
144
+ showDetails?: boolean;
145
+ isLoading?: boolean;
146
+ error?: {
147
+ message: string;
148
+ };
132
149
  balance?: string;
133
- tokenPrice?: number;
150
+ priceImpactPercentage?: string;
151
+ criticalPriceImpactPercentage?: number;
152
+ direction?: SwapDirection;
153
+ amountUsd?: string;
134
154
  }
135
- declare const NumericInput: ({ onParsedValueChanged, initialValue, forcedUpdateValue, maxDecimals, balance, tokenPrice, ...props }: Props) => react_jsx_runtime.JSX.Element;
155
+ declare function NumericInput({ priceImpactPercentage, balance, error, criticalPriceImpactPercentage, token, onAmountChange, forcedAmount, maxDecimals, formatIfVerySmall, showDetails, isLoading, direction, amountUsd, }: NumericInputProps): react_jsx_runtime.JSX.Element;
136
156
 
137
157
  interface SettingsSliderProps {
138
158
  value: number;
@@ -405,7 +425,7 @@ interface SwapConfigurationProps {
405
425
  priceImpactPercentage?: string;
406
426
  amount?: string;
407
427
  forcedAmount?: string;
408
- swapAmountUsd?: string;
428
+ amountUsd?: string;
409
429
  tokenPrice?: number;
410
430
  balance?: string;
411
431
  isFetching?: boolean;
@@ -424,15 +444,13 @@ interface SwapConfigurationProps {
424
444
  onAmountChange?: (amount: string) => void;
425
445
  onWalletButtonClick?: () => void;
426
446
  onAssetsButtonClick?: () => void;
427
- onBalanceButtonClick?: () => void;
428
447
  error?: {
429
448
  message: string;
430
449
  };
431
450
  criticalPriceImpactPercentage?: number;
432
451
  emptyAddressLabel?: string;
433
- onSwapAmountButtonClick?: () => void;
434
452
  }
435
- declare function SwapConfiguration({ priceImpactPercentage, amount, forcedAmount, swapAmountUsd, balance, tokenPrice, isFetching, chain, token, direction, onAmountChange, onWalletButtonClick, onAssetsButtonClick, onBalanceButtonClick, onSwapAmountButtonClick, address, error, criticalPriceImpactPercentage, emptyAddressLabel, }: SwapConfigurationProps): react_jsx_runtime.JSX.Element;
453
+ declare function SwapConfiguration({ amount, tokenPrice, isFetching, chain, token, direction, onAmountChange, onWalletButtonClick, onAssetsButtonClick, address, emptyAddressLabel, balance, criticalPriceImpactPercentage, error, priceImpactPercentage, amountUsd, }: SwapConfigurationProps): react_jsx_runtime.JSX.Element;
436
454
 
437
455
  interface SwapProgressViewHeaderProps {
438
456
  title: string;
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.14.0",
8
+ "version": "0.15.1",
9
9
  "author": "",
10
10
  "license": "MIT",
11
11
  "resolutions": {
@@ -28,6 +28,7 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@lottiefiles/react-lottie-player": "3.5.0",
31
+ "bignumber.js": "9.1.2",
31
32
  "clsx": "2.1.0",
32
33
  "color": "4.2.3",
33
34
  "tailwind-merge": "2.3.0"