@0xsquid/ui 0.15.0 → 0.15.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.
@@ -1,13 +1,31 @@
1
- import type { InputHTMLAttributes } from 'react';
2
- import { InputMode } from '../../types/components';
3
- interface Props extends InputHTMLAttributes<HTMLInputElement> {
4
- onParsedValueChanged: (value: string) => void;
5
- initialValue?: string;
6
- forcedUpdateValue?: string;
7
- 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
+ };
8
24
  balance?: string;
9
- tokenPrice?: number;
10
- numericInputMode?: InputMode;
25
+ priceImpactPercentage?: string;
26
+ criticalPriceImpactPercentage?: number;
27
+ direction?: SwapDirection;
28
+ amountUsd?: string;
11
29
  }
12
- export declare const NumericInput: ({ onParsedValueChanged, initialValue, forcedUpdateValue, maxDecimals, balance, tokenPrice, numericInputMode, ...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;
13
31
  export {};
@@ -4,6 +4,7 @@ interface SwapConfigurationProps {
4
4
  priceImpactPercentage?: string;
5
5
  amount?: string;
6
6
  forcedAmount?: string;
7
+ amountUsd?: string;
7
8
  tokenPrice?: number;
8
9
  balance?: string;
9
10
  isFetching?: boolean;
@@ -22,12 +23,11 @@ interface SwapConfigurationProps {
22
23
  onAmountChange?: (amount: string) => void;
23
24
  onWalletButtonClick?: () => void;
24
25
  onAssetsButtonClick?: () => void;
25
- onBalanceButtonClick?: () => void;
26
26
  error?: {
27
27
  message: string;
28
28
  };
29
29
  criticalPriceImpactPercentage?: number;
30
30
  emptyAddressLabel?: string;
31
31
  }
32
- export declare function SwapConfiguration({ priceImpactPercentage, amount, forcedAmount: _forcedAmount, balance, tokenPrice, isFetching, chain, token, direction, onAmountChange, onWalletButtonClick, onAssetsButtonClick, onBalanceButtonClick, 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;
33
33
  export {};
@@ -4,19 +4,20 @@
4
4
  * @param {string|number} tokenPrice - The price of one token in USD
5
5
  * @returns {BigNumber} - The equivalent amount in USD
6
6
  */
7
- export declare function convertTokenAmountToUSD(tokenAmount: string | number, tokenPrice: string | number): string;
7
+ export declare function convertTokenAmountToUSD(tokenAmount: string | number, tokenPrice: string | number, maxDecimals?: number): string;
8
8
  /**
9
9
  * Convert USD to token amount
10
10
  * @param {string|number} usdAmount - The amount in USD
11
11
  * @param {string|number} tokenPrice - The price of one token in USD
12
+ * @param {number} maxDecimals - The maximum number of decimals
12
13
  * @returns {BigNumber} - The equivalent amount of tokens
13
14
  */
14
- export declare function convertUSDToTokenAmount(usdAmount: string | number, tokenPrice: string | number): string;
15
+ export declare function convertUSDToTokenAmount(usdAmount: string | number, tokenPrice: string | number, maxDecimals: number): string;
15
16
  /**
16
- * Formats a number to USD
17
+ * Formats a number to the en-US number format
17
18
  *
18
- * @param amount - The amount to format
19
- * @returns The formatted currency string
19
+ * @param amount - The number to format
20
+ * @returns The formatted string
20
21
  */
21
- export declare function formatUSD(amount: number | bigint | string): string;
22
- export declare function trimExtraDecimals(value: string, maxDecimals: number): string;
22
+ export declare function formatAmount(amount: number | bigint | string): string;
23
+ export declare function trimExtraDecimals(value: string, maxDecimals?: number): string;
@@ -1,2 +1,2 @@
1
1
  export type { SquidTheme } from './config';
2
- export type { SwapState, ThemeType, SwapStep } from './components';
2
+ export type { SwapState, ThemeType, SwapStep, SwapStepItemStatus, } from './components';
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;
@@ -74,7 +74,6 @@ declare enum SwapState {
74
74
  }
75
75
  type ThemeType = 'light' | 'dark';
76
76
  type SwapStepItemStatus = 'pending' | 'waiting' | 'ongoing' | 'executed' | 'success' | 'error' | 'warning';
77
- type InputMode = 'token' | 'price';
78
77
 
79
78
  interface BoostButtonProps {
80
79
  boostMode: BoostMode;
@@ -125,16 +124,35 @@ interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
125
124
  }
126
125
  declare function Input({ placeholder, showIcon, showPasteButton, className, icon, isError, onPasteButtonClick, containerClassName, ...props }: InputProps): react_jsx_runtime.JSX.Element;
127
126
 
128
- interface Props extends InputHTMLAttributes<HTMLInputElement> {
129
- onParsedValueChanged: (value: string) => void;
130
- initialValue?: string;
131
- forcedUpdateValue?: string;
132
- 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
+ };
133
149
  balance?: string;
134
- tokenPrice?: number;
135
- numericInputMode?: InputMode;
150
+ priceImpactPercentage?: string;
151
+ criticalPriceImpactPercentage?: number;
152
+ direction?: SwapDirection;
153
+ amountUsd?: string;
136
154
  }
137
- declare const NumericInput: ({ onParsedValueChanged, initialValue, forcedUpdateValue, maxDecimals, balance, tokenPrice, numericInputMode, ...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;
138
156
 
139
157
  interface SettingsSliderProps {
140
158
  value: number;
@@ -407,6 +425,7 @@ interface SwapConfigurationProps {
407
425
  priceImpactPercentage?: string;
408
426
  amount?: string;
409
427
  forcedAmount?: string;
428
+ amountUsd?: string;
410
429
  tokenPrice?: number;
411
430
  balance?: string;
412
431
  isFetching?: boolean;
@@ -425,14 +444,13 @@ interface SwapConfigurationProps {
425
444
  onAmountChange?: (amount: string) => void;
426
445
  onWalletButtonClick?: () => void;
427
446
  onAssetsButtonClick?: () => void;
428
- onBalanceButtonClick?: () => void;
429
447
  error?: {
430
448
  message: string;
431
449
  };
432
450
  criticalPriceImpactPercentage?: number;
433
451
  emptyAddressLabel?: string;
434
452
  }
435
- declare function SwapConfiguration({ priceImpactPercentage, amount, forcedAmount: _forcedAmount, balance, tokenPrice, isFetching, chain, token, direction, onAmountChange, onWalletButtonClick, onAssetsButtonClick, onBalanceButtonClick, 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;
@@ -547,4 +565,4 @@ declare function useDropdownMenu(props?: {
547
565
  openDropdownButtonRef: React.RefObject<HTMLButtonElement>;
548
566
  };
549
567
 
550
- export { AddressButton, ArrowButton, AssetsButton, BadgeImage, BodyText, Boost, BoostButton, BorderedContainer, Button, CaptionText, Chip, DetailsToolbar, DropdownMenu, DropdownMenuItem, type DropdownMenuItemProps, ErrorMessage, FeeButton, HeadingText, HistoryItem, InfoBox, Input, ListItem, LoadingSkeleton, Menu, MenuItem, Modal, ModalContent, ModalContentDivider, NavigationBar, NumericInput, ProductCard, ProfileHeaderBackground, SectionTitle, SettingsButton, type SettingsButtonProps, type SettingsControl, SettingsItem, type SettingsItemProps, SettingsSlider, type SettingsSliderProps, SquidConfigProvider, type SquidTheme, SwapConfiguration, SwapDetailListItem, SwapProgressView, SwapProgressViewHeader, SwapState, type SwapStep, SwapStepItem, SwapStepsCollapsed, Switch, type ThemeType, TokenPair, Tooltip, type TooltipProps, type TooltipThreshold, type TooltipWidth, UsdAmount, useDropdownMenu };
568
+ export { AddressButton, ArrowButton, AssetsButton, BadgeImage, BodyText, Boost, BoostButton, BorderedContainer, Button, CaptionText, Chip, DetailsToolbar, DropdownMenu, DropdownMenuItem, type DropdownMenuItemProps, ErrorMessage, FeeButton, HeadingText, HistoryItem, InfoBox, Input, ListItem, LoadingSkeleton, Menu, MenuItem, Modal, ModalContent, ModalContentDivider, NavigationBar, NumericInput, ProductCard, ProfileHeaderBackground, SectionTitle, SettingsButton, type SettingsButtonProps, type SettingsControl, SettingsItem, type SettingsItemProps, SettingsSlider, type SettingsSliderProps, SquidConfigProvider, type SquidTheme, SwapConfiguration, SwapDetailListItem, SwapProgressView, SwapProgressViewHeader, SwapState, type SwapStep, SwapStepItem, type SwapStepItemStatus, SwapStepsCollapsed, Switch, type ThemeType, TokenPair, Tooltip, type TooltipProps, type TooltipThreshold, type TooltipWidth, UsdAmount, useDropdownMenu };
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.15.0",
8
+ "version": "0.15.2",
9
9
  "author": "",
10
10
  "license": "MIT",
11
11
  "resolutions": {