@gearbox-protocol/permissionless-ui 1.22.0-next.41 → 1.22.0-next.43

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 (49) hide show
  1. package/dist/cjs/components/block-sync/block-sync.cjs +1 -1
  2. package/dist/cjs/components/checkbox/checkbox-labeled.cjs +1 -1
  3. package/dist/cjs/components/client-adapters/styled-rounded-image/styled-rounded-image.cjs +1 -1
  4. package/dist/cjs/components/complex-input/complex-input.cjs +1 -1
  5. package/dist/cjs/components/complex-input/index.cjs +1 -1
  6. package/dist/cjs/components/currency-button/currency-button.cjs +1 -1
  7. package/dist/cjs/components/help-tip/help-tip.cjs +1 -1
  8. package/dist/cjs/components/index.cjs +1 -1
  9. package/dist/cjs/components/smart-number-input/balance-indicator.cjs +1 -0
  10. package/dist/cjs/components/smart-number-input/index.cjs +1 -1
  11. package/dist/cjs/components/smart-number-input/smart-number-input.cjs +1 -1
  12. package/dist/cjs/hooks/index.cjs +1 -1
  13. package/dist/cjs/hooks/use-debounce-call.cjs +1 -1
  14. package/dist/cjs/hooks/use-hf.cjs +1 -1
  15. package/dist/cjs/hooks/use-media-query.cjs +1 -1
  16. package/dist/cjs/hooks/use-smart-number-input.cjs +1 -0
  17. package/dist/cjs/index.cjs +1 -1
  18. package/dist/cjs/utils/format-money.cjs +1 -1
  19. package/dist/esm/components/block-sync/block-sync.js +7 -5
  20. package/dist/esm/components/checkbox/checkbox-labeled.js +5 -3
  21. package/dist/esm/components/client-adapters/styled-rounded-image/styled-rounded-image.js +5 -3
  22. package/dist/esm/components/complex-input/complex-input.js +57 -102
  23. package/dist/esm/components/complex-input/index.js +2 -3
  24. package/dist/esm/components/currency-button/currency-button.js +96 -74
  25. package/dist/esm/components/help-tip/help-tip.js +19 -19
  26. package/dist/esm/components/index.js +456 -455
  27. package/dist/esm/components/smart-number-input/balance-indicator.js +60 -0
  28. package/dist/esm/components/smart-number-input/index.js +4 -2
  29. package/dist/esm/components/smart-number-input/smart-number-input.js +139 -146
  30. package/dist/esm/hooks/index.js +38 -35
  31. package/dist/esm/hooks/use-debounce-call.js +7 -14
  32. package/dist/esm/hooks/use-hf.js +33 -25
  33. package/dist/esm/hooks/use-media-query.js +12 -11
  34. package/dist/esm/hooks/use-smart-number-input.js +10 -0
  35. package/dist/esm/index.js +590 -586
  36. package/dist/esm/utils/format-money.js +3 -5
  37. package/dist/globals.css +1 -1
  38. package/dist/types/components/complex-input/complex-input.d.ts +1 -33
  39. package/dist/types/components/currency-button/currency-button.d.ts +26 -61
  40. package/dist/types/components/smart-number-input/balance-indicator.d.ts +41 -0
  41. package/dist/types/components/smart-number-input/index.d.ts +1 -0
  42. package/dist/types/components/smart-number-input/smart-number-input.d.ts +29 -102
  43. package/dist/types/components/token-template/token-template.d.ts +2 -5
  44. package/dist/types/hooks/index.d.ts +1 -0
  45. package/dist/types/hooks/use-debounce-call.d.ts +1 -19
  46. package/dist/types/hooks/use-hf.d.ts +2 -1
  47. package/dist/types/hooks/use-media-query.d.ts +4 -0
  48. package/dist/types/hooks/use-smart-number-input.d.ts +1 -0
  49. package/package.json +1 -1
@@ -1,39 +1,7 @@
1
- import { TokenData } from '@gearbox-protocol/sdk';
2
1
  import { InputProps } from '../input';
3
2
  import { WithTitleProps } from '../with-title';
3
+ import { BalanceIndicatorProps } from '..';
4
4
  import type * as React from "react";
5
- export type BalanceIndicatorSize = "sm" | "md";
6
- export interface BalanceIndicatorProps {
7
- /**
8
- * Label before balance (e.g. "Balance")
9
- */
10
- title?: React.ReactNode;
11
- /**
12
- * Maximum amount available
13
- */
14
- maxAmount: bigint;
15
- /**
16
- * Token data
17
- */
18
- token: TokenData | undefined;
19
- /**
20
- * Size variant (matches interface SmartNumberInputSize)
21
- */
22
- size?: BalanceIndicatorSize;
23
- /**
24
- * Whether the indicator is disabled
25
- */
26
- disabled?: boolean;
27
- /**
28
- * Whether to show max button / clickable amount
29
- */
30
- maxButton?: boolean;
31
- /**
32
- * Callback when max is clicked
33
- */
34
- onMaxButtonClick?: () => void;
35
- }
36
- export declare function BalanceIndicator({ title, maxAmount, token, disabled, maxButton, onMaxButtonClick, size, }: BalanceIndicatorProps): import("react/jsx-runtime").JSX.Element;
37
5
  export interface ComplexInputProps {
38
6
  /**
39
7
  * Props for title wrapper
@@ -1,79 +1,44 @@
1
- import { NetworkType, TokenData } from '@gearbox-protocol/sdk';
1
+ import { NetworkType } from '@gearbox-protocol/sdk';
2
+ import { VariantProps } from 'class-variance-authority';
3
+ import { TokenDataLike } from '..';
2
4
  import type * as React from "react";
3
- /**
4
- * Size variants for CurrencyButton
5
- */
6
- export type CurrencyButtonSize = "sm" | "md" | "lg" | "old" | "default";
7
- export interface CurrencyButtonProps {
8
- /**
9
- * Custom title override (uses token.symbol by default)
10
- */
5
+ declare const blockVariants: (props?: ({
6
+ size?: "xs" | "sm" | "md" | null | undefined;
7
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
8
+ export interface CurrencyButtonProps extends VariantProps<typeof blockVariants> {
9
+ /** Override title (e.g. for tooltip). */
11
10
  title?: string;
12
- /**
13
- * Maximum length for symbol display
14
- * @default 12
15
- */
11
+ /** Max length for symbol display. @default 13 */
16
12
  maxLength?: number;
17
- /**
18
- * Token data to display
19
- */
20
- token?: TokenData;
21
- /**
22
- * Whether the button is disabled
23
- */
13
+ /** Token to display. */
14
+ token?: TokenDataLike;
15
+ /** When true, button does not respond to click. */
24
16
  disabled?: boolean;
25
- /**
26
- * Callback when button is clicked to open token selection
27
- * If not provided, button acts as a static display
28
- */
17
+ /** Called when button is clicked to open token select. When set and not disabled, block is clickable. */
29
18
  showSelectDialog?: () => void;
30
- /**
31
- * Size variant
32
- * @default "md"
33
- */
34
- size?: CurrencyButtonSize;
35
- /**
36
- * Whether the button is in active/selected state
37
- */
19
+ /** When true, expand icon is rotated (e.g. dropdown open). @default false */
38
20
  active?: boolean;
39
- /**
40
- * Chain ID for multi-chain support
41
- */
21
+ /** Chain ID for token/network. */
42
22
  chainId?: number;
43
- /**
44
- * Network type for multi-chain support
45
- */
23
+ /** Network type. */
46
24
  network?: NetworkType;
47
- /**
48
- * Additional CSS class
49
- */
25
+ /** Extra class name. */
50
26
  className?: string;
51
- /**
52
- * Children to render (fallback when no token)
53
- */
27
+ /** Fallback content when no token (e.g. "Select token"). */
54
28
  children?: React.ReactNode;
55
29
  }
56
30
  /**
57
- * CurrencyButton — a button for selecting/displaying a token
31
+ * CurrencyButton — token display with optional expand icon and click-to-select.
58
32
  *
59
- * Shows token icon and symbol with an optional expand chevron when selectable.
33
+ * @usage
34
+ * Use as the token selector trigger in SmartNumberInput or similar.
35
+ * When showSelectDialog is set and not disabled, block is clickable and shows expand icon.
60
36
  *
61
37
  * @example
62
38
  * ```tsx
63
- * // Static display
64
- * <CurrencyButton token={tokenData} />
65
- *
66
- * // With selection
67
- * <CurrencyButton
68
- * token={selectedToken}
69
- * showSelectDialog={() => setOpen(true)}
70
- * size="md"
71
- * />
72
- *
73
- * // Placeholder
74
- * <CurrencyButton showSelectDialog={() => setOpen(true)}>
75
- * Select token
76
- * </CurrencyButton>
39
+ * <CurrencyButton token={token} showSelectDialog={() => setOpen(true)} size="md" />
40
+ * <CurrencyButton showSelectDialog={() => setOpen(true)}>Select token</CurrencyButton>
77
41
  * ```
78
42
  */
79
- export declare function CurrencyButton({ title, maxLength, token, disabled, showSelectDialog, size, active, chainId, network, className, children, }: CurrencyButtonProps): import("react/jsx-runtime").JSX.Element;
43
+ export declare function CurrencyButton({ title, maxLength, token, disabled, showSelectDialog, size: sizeProp, active, chainId, network, className, children, }: CurrencyButtonProps): import("react/jsx-runtime").JSX.Element;
44
+ export {};
@@ -0,0 +1,41 @@
1
+ import { TokenDataLike } from '.';
2
+ import type * as React from "react";
3
+ /** Size variant matching A (SmartNumberInputSize). */
4
+ export type BalanceIndicatorSize = "sm" | "md";
5
+ export interface BalanceIndicatorProps {
6
+ /** Label before balance (e.g. "Balance"). */
7
+ title?: React.ReactNode;
8
+ /** Token for formatting amount. */
9
+ token: TokenDataLike | undefined;
10
+ /** Max amount to display (formatted via TokenTemplate). */
11
+ maxAmount?: bigint;
12
+ /** When true, balance row is non-interactive. */
13
+ disabled?: boolean;
14
+ /** When true, show max button or clickable amount. @default true */
15
+ maxButton?: boolean;
16
+ /** Size variant. */
17
+ size: BalanceIndicatorSize;
18
+ /** Called when max is clicked. */
19
+ onMaxButtonClick: () => void;
20
+ /** Extra class name. */
21
+ className?: string;
22
+ }
23
+ /**
24
+ * BalanceIndicator — balance label + formatted max amount with optional max button.
25
+ * Subcomponent of SmartNumberInput (matches A BalanceIndicator + Label/MaxWrapper/MaxButton).
26
+ *
27
+ * @usage
28
+ * Renders "Balance: &lt;amount&gt;" with optional inline (sm) or separate (md) max button.
29
+ *
30
+ * @example
31
+ * ```tsx
32
+ * <BalanceIndicator
33
+ * token={token}
34
+ * maxAmount={balance}
35
+ * size="md"
36
+ * maxButton
37
+ * onMaxButtonClick={() => setAmount(max)}
38
+ * />
39
+ * ```
40
+ */
41
+ export declare function BalanceIndicator({ title, className, maxAmount, token, disabled, maxButton, onMaxButtonClick, size, }: BalanceIndicatorProps): import("react/jsx-runtime").JSX.Element;
@@ -1 +1,2 @@
1
+ export * from './balance-indicator';
1
2
  export * from './smart-number-input';
@@ -1,133 +1,60 @@
1
+ import { NetworkType } from '@gearbox-protocol/sdk';
1
2
  import * as React from "react";
3
+ /** A-matching SmartNumberInput size for layout (styles.tsx). */
4
+ export type SmartNumberInputSize = "sm" | "md";
2
5
  /**
3
6
  * Token data for legacy API compatibility
4
7
  * Uses generic type to accept any TokenData-like object
5
8
  */
6
9
  export interface TokenDataLike {
7
10
  symbol: string;
11
+ title: string;
8
12
  decimals?: number;
9
13
  }
10
14
  export interface SmartNumberInputProps {
11
- /**
12
- * Current amount value as string
13
- */
15
+ /** Current amount value as string. */
14
16
  amount: string;
15
- /**
16
- * Token symbol to display (new API)
17
- */
18
- tokenSymbol?: string;
19
- /**
20
- * Token icon element (new API)
21
- */
22
- tokenIcon?: React.ReactNode;
23
- /**
24
- * Token data object (legacy API from interface)
25
- * If provided, tokenSymbol and tokenIcon will be derived from it
26
- */
27
- token?: TokenDataLike;
28
- /**
29
- * Label for the input
30
- */
17
+ /** Token data (from interface). */
18
+ token: TokenDataLike | undefined;
19
+ /** Label for the input. */
31
20
  label?: React.ReactNode;
32
- /**
33
- * Max balance to display as string (new API)
34
- */
35
- maxBalance?: string;
36
- /**
37
- * Max amount as bigint (legacy API from interface)
38
- */
21
+ /** Max button label (e.g. "Balance"). */
22
+ maxButtonLabel?: React.ReactNode;
23
+ /** Max amount to display. */
39
24
  maxAmount?: bigint;
40
- /**
41
- * Max amount limit as bigint (legacy API from interface)
42
- */
25
+ /** Max amount limit (capped when max amount exceeds this). */
43
26
  maxAmountLimit?: bigint;
44
- /**
45
- * Max button label
46
- */
47
- maxButtonLabel?: React.ReactNode;
48
- /**
49
- * Show max button (new API)
50
- */
51
- showMaxButton?: boolean;
52
- /**
53
- * Show max button (legacy API alias)
54
- */
55
- maxButton?: boolean;
56
- /**
57
- * Chain ID for network icon (legacy API)
58
- */
27
+ /** Chain ID for network icon. */
59
28
  chainId?: number;
60
- /**
61
- * Network type for display (legacy API)
62
- */
63
- network?: string;
64
- /**
65
- * Input is disabled
66
- */
29
+ /** Network type for display. */
30
+ network?: NetworkType;
31
+ /** Show max button. @default true */
32
+ maxButton?: boolean;
33
+ /** Input is disabled. */
67
34
  disabled?: boolean;
68
- /**
69
- * Input is active/focused
70
- */
35
+ /** Size variant (from interface SmartNumberInputSize). */
36
+ size?: SmartNumberInputSize;
37
+ /** When true, currency dropdown is open (expand icon rotated). */
71
38
  active?: boolean;
72
- /**
73
- * Size variant
74
- */
75
- size?: "sm" | "default" | "md" | "lg";
76
- /**
77
- * Callback when amount changes (new API)
78
- */
79
- onAmountChange?: (value: string) => void;
80
- /**
81
- * Callback when amount changes with bigint (legacy API from interface)
82
- * Called with (value: bigint, valueView: string)
83
- */
39
+ /** Callback when amount changes. Called with (value: bigint, valueView: string). */
84
40
  onSetAmount?: (value: bigint, valueView: string) => void;
85
- /**
86
- * Callback when max button is clicked (new API)
87
- */
88
- onMaxClick?: () => void;
89
- /**
90
- * Callback to show token select dialog (new API)
91
- */
92
- onTokenSelect?: () => void;
93
- /**
94
- * Callback to show token select dialog (legacy API from interface)
95
- */
41
+ /** Callback to show token select dialog. */
96
42
  onShowSelectDialog?: () => void;
97
- /**
98
- * Callback when remove button is clicked
99
- */
43
+ /** Callback when remove button is clicked. */
100
44
  onRemove?: () => void;
101
- /**
102
- * Focus callback
103
- */
45
+ /** Focus callback. */
104
46
  onFocus?: () => void;
105
- /**
106
- * Blur callback
107
- */
47
+ /** Blur callback. */
108
48
  onBlur?: () => void;
109
- /**
110
- * Additional class names
111
- */
112
- className?: string;
113
49
  }
114
50
  /**
115
- * SmartNumberInput — token amount input with balance display
51
+ * SmartNumberInput — token amount input with balance display (matches interface).
116
52
  *
117
- * Supports both new API (tokenSymbol, onAmountChange) and legacy API (token, onSetAmount)
53
+ * @usage
54
+ * Use for token amount input with balance row and optional token selector.
118
55
  *
119
56
  * @example
120
57
  * ```tsx
121
- * // New API
122
- * <SmartNumberInput
123
- * amount={amount}
124
- * tokenSymbol="ETH"
125
- * maxBalance="1.5 ETH"
126
- * onAmountChange={setAmount}
127
- * onMaxClick={handleMax}
128
- * />
129
- *
130
- * // Legacy API (from interface)
131
58
  * <SmartNumberInput
132
59
  * amount={amountView}
133
60
  * token={tokenData}
@@ -1,14 +1,11 @@
1
- import { TokenData } from '@gearbox-protocol/sdk';
2
1
  import { ParseSmallNumberResult } from '../../utils';
3
2
  import { negativeTokenTemplate, tokenTemplateString } from '../../utils/templates';
3
+ import { TokenDataLike } from '..';
4
4
  import { FormattedNumberStringProps } from '../formatted-number';
5
5
  import type * as React from "react";
6
- type PartialTokenData = Pick<TokenData, "title" | "decimals"> & {
7
- symbol?: string;
8
- };
9
6
  export interface TokenTemplateProps extends Omit<FormattedNumberStringProps, "value"> {
10
7
  value: bigint | string | number | undefined;
11
- token: PartialTokenData | undefined;
8
+ token: TokenDataLike | undefined;
12
9
  precision?: number;
13
10
  maxLength?: number;
14
11
  formatter?: (amount: bigint | string | number | undefined, decimals: number, precision?: number) => string | ParseSmallNumberResult;
@@ -8,3 +8,4 @@ export * from './use-liquidation';
8
8
  export * from './use-media-query';
9
9
  export * from './use-opened-state';
10
10
  export * from './use-previous';
11
+ export * from './use-smart-number-input';
@@ -1,19 +1 @@
1
- /**
2
- * Returns a debounced function caller that delays execution
3
- *
4
- * @param delay - Delay in milliseconds
5
- * @returns A function that accepts a callback to be called after the delay
6
- *
7
- * @example
8
- * ```tsx
9
- * const debouncedCall = useDebounceCall(300);
10
- *
11
- * const handleChange = (value: string) => {
12
- * debouncedCall(() => {
13
- * // This will be called 300ms after the last handleChange
14
- * fetchResults(value);
15
- * });
16
- * };
17
- * ```
18
- */
19
- export declare function useDebounceCall(delay: number): (fn: () => void) => void;
1
+ export declare function useDebounceCall(delay?: number): (arg: () => void) => void;
@@ -9,7 +9,8 @@ export interface UseHFProps {
9
9
  underlyingToken: Address;
10
10
  debt: bigint;
11
11
  tokensList: Record<Address, TokenData>;
12
+ allowZeroDebt?: boolean;
12
13
  }
13
- export declare function useHF({ assets, quotas, prices, liquidationThresholds, underlyingToken, debt, quotasInfo, tokensList, }: UseHFProps): {
14
+ export declare function useHF({ assets, quotas, prices, liquidationThresholds, underlyingToken, debt, quotasInfo, allowZeroDebt, tokensList, }: UseHFProps): {
14
15
  hf: number;
15
16
  };
@@ -11,6 +11,10 @@
11
11
  * ```
12
12
  */
13
13
  export declare function useMediaQuery(query: string): boolean;
14
+ /**
15
+ * Checks if the viewport is mobile-sized (max-width: 500px-)
16
+ */
17
+ export declare const useIsExtraSmall: () => boolean;
14
18
  /**
15
19
  * Checks if the viewport is mobile-sized (max-width: 768px)
16
20
  */
@@ -0,0 +1 @@
1
+ export declare function useSmartNumberInput(initialAmount?: bigint, initialView?: string): readonly [bigint, string, (value: bigint, valueView: string) => void];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/permissionless-ui",
3
- "version": "1.22.0-next.41",
3
+ "version": "1.22.0-next.43",
4
4
  "description": "Internal UI components",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/index.js",