@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
@@ -0,0 +1,60 @@
1
+ import { jsxs as s, jsx as t } from "react/jsx-runtime";
2
+ import { cva as x } from "class-variance-authority";
3
+ import { TextButton as u } from "../text-button/text-button.js";
4
+ import { TokenTemplate as f } from "../token-template/token-template.js";
5
+ import "react";
6
+ import "@gearbox-protocol/sdk";
7
+ import { cn as a } from "../../utils/cn.js";
8
+ import "sonner";
9
+ const b = x("font-normal leading-[130%] text-foreground", {
10
+ variants: {
11
+ size: {
12
+ sm: "text-xs",
13
+ md: "text-sm"
14
+ }
15
+ },
16
+ defaultVariants: { size: "md" }
17
+ });
18
+ function j({
19
+ title: m = "Balance",
20
+ className: i,
21
+ maxAmount: l,
22
+ token: c,
23
+ disabled: d,
24
+ maxButton: p = !0,
25
+ onMaxButtonClick: r,
26
+ size: e = "sm"
27
+ }) {
28
+ const o = !d && p, n = /* @__PURE__ */ t(f, { value: l, token: c, showSymbol: !1 });
29
+ return /* @__PURE__ */ s(
30
+ "div",
31
+ {
32
+ className: a("flex shrink-0 basis-auto items-center", i),
33
+ "data-testid": "balance-indicator",
34
+ children: [
35
+ /* @__PURE__ */ s("span", { className: a(b({ size: e })), children: [
36
+ m,
37
+ ": ",
38
+ o && e === "sm" ? /* @__PURE__ */ t(u, { onClick: r, children: n }) : n
39
+ ] }),
40
+ o && e !== "sm" && /* @__PURE__ */ t("div", { className: "ml-2", children: /* @__PURE__ */ t(
41
+ "button",
42
+ {
43
+ type: "button",
44
+ onClick: r,
45
+ "data-testid": "balance-max",
46
+ className: a(
47
+ "rounded-[6px] border-0 py-[3px] px-1 text-[11px]! leading-[13px]!",
48
+ "text-center uppercase text-foreground",
49
+ "bg-gray-70 hover:bg-gray-90 transition-colors"
50
+ ),
51
+ children: "max"
52
+ }
53
+ ) })
54
+ ]
55
+ }
56
+ );
57
+ }
58
+ export {
59
+ j as BalanceIndicator
60
+ };
@@ -1,4 +1,6 @@
1
- import { SmartNumberInput as t } from "./smart-number-input.js";
1
+ import { BalanceIndicator as t } from "./balance-indicator.js";
2
+ import { SmartNumberInput as e } from "./smart-number-input.js";
2
3
  export {
3
- t as SmartNumberInput
4
+ t as BalanceIndicator,
5
+ e as SmartNumberInput
4
6
  };
@@ -1,136 +1,131 @@
1
- import { jsx as s, jsxs as d } from "react/jsx-runtime";
2
- import * as G from "react";
3
- import "../buttons/back-button/back-button.js";
4
- import { Button as H } from "../buttons/button/button.js";
5
- import "../buttons/copy-button/copy-button.js";
6
- import "../buttons/external-button/external-button.js";
7
- import "../buttons/filter-button/filter-button.js";
8
- import "../buttons/navigation-button/navigation-button.js";
1
+ import { jsxs as d, jsx as e } from "react/jsx-runtime";
2
+ import { cva as u } from "class-variance-authority";
3
+ import * as g from "react";
4
+ import { CurrencyButton as E } from "../currency-button/currency-button.js";
5
+ import { faXmark as G } from "@fortawesome/free-solid-svg-icons";
6
+ import { FaIcon as H } from "../icons/fa-icon.js";
7
+ import { useIsMobile as J, useIsTablet as K, useIsDesktop as O } from "../../hooks/use-media-query.js";
8
+ import { bnToInputView as P } from "../../utils/bn-to-input-view.js";
9
9
  import "@gearbox-protocol/sdk";
10
- import { cn as g } from "../../utils/cn.js";
10
+ import { parseInputToBN as Q } from "../../utils/parse-input-to-bn.js";
11
+ import { cn as x } from "../../utils/cn.js";
11
12
  import "sonner";
12
- import "../buttons/tab-button/tab-button.js";
13
- import { faXmark as J } from "@fortawesome/free-solid-svg-icons";
14
- import { FaIcon as K } from "../icons/fa-icon.js";
15
- import { TokenIcon as Q } from "../token-icon/token-icon.js";
16
- function U(n, r) {
17
- let t = n.replace(/^0+(?=\d)/, "");
18
- if ((t === "" || t === ".") && (t = "0"), !/^[0-9]*\.?[0-9]*$/.test(t))
19
- return [null, null];
20
- try {
21
- const e = t.split("."), a = e[0] || "0", p = (e[1] || "").slice(0, r).padEnd(r, "0");
22
- return [BigInt(a + p), t];
23
- } catch {
24
- return [null, null];
25
- }
26
- }
27
- function T(n, r) {
28
- const t = n.toString().padStart(r + 1, "0"), e = t.slice(0, -r) || "0", a = t.slice(-r).replace(/0+$/, "");
29
- return a ? `${e}.${a}` : e;
30
- }
31
- function W(n, r) {
32
- const t = T(n, r), e = Number.parseFloat(t);
33
- return e === 0 ? "0" : e < 1e-4 ? "< 0.0001" : e.toLocaleString(void 0, { maximumFractionDigits: 4 });
34
- }
35
- const Y = G.forwardRef(
36
- ({
37
- amount: n,
38
- tokenSymbol: r,
39
- tokenIcon: t,
40
- token: e,
41
- label: a = "Amount",
42
- maxBalance: p,
43
- maxAmount: o,
44
- maxAmountLimit: m,
45
- maxButtonLabel: $ = "Max",
46
- showMaxButton: j,
47
- maxButton: z,
48
- chainId: Z,
49
- network: L,
50
- disabled: i = !1,
51
- active: y = !1,
52
- size: N = "default",
53
- onAmountChange: b,
54
- onSetAmount: c,
55
- onMaxClick: x,
56
- onTokenSelect: M,
57
- onShowSelectDialog: P,
58
- onRemove: w,
59
- onFocus: S,
60
- onBlur: F,
61
- className: V
62
- }, _) => {
63
- const D = j ?? z ?? !0, h = r ?? e?.symbol, I = t ?? (e?.symbol ? /* @__PURE__ */ s(Q, { symbol: e.symbol, size: 24 }) : void 0), v = e?.decimals ?? 18, B = p ?? (o !== void 0 ? W(o, v) : void 0), f = M ?? P, E = {
64
- sm: "p-3",
65
- md: "p-3.5",
66
- default: "p-4",
67
- lg: "p-5"
68
- }, O = {
69
- sm: "text-lg",
70
- md: "text-xl",
71
- default: "text-2xl",
72
- lg: "text-3xl"
73
- }, R = (u) => {
74
- const l = u.target.value;
75
- if (!(!/^[0-9]*\.?[0-9]*$/.test(l) && l !== "") && (b && b(l), c)) {
76
- const [k, C] = U(l, v);
77
- k !== null && C !== null && c(k, C);
13
+ import { BalanceIndicator as U } from "./balance-indicator.js";
14
+ const W = u(
15
+ "relative w-full text-foreground bg-gray-20 border border-gray-30 transition-[background-color] duration-100 ease-linear [&:hover]:bg-gray-30 [&:hover]:border-gray-40 data-[active=true]:bg-gray-30 data-[active=true]:outline data-[active=true]:outline-2 data-[active=true]:outline-primary data-[active=true]:outline-offset-[-2px] data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[disabled=true]:cursor-not-allowed",
16
+ {
17
+ variants: {
18
+ size: {
19
+ sm: "px-3 py-[7px] h-[60px] rounded-[8px]",
20
+ md: "pl-4 pr-3 py-[10px] h-[82px] rounded-lg"
78
21
  }
79
- }, X = () => {
80
- if (x) {
81
- x();
82
- return;
22
+ },
23
+ defaultVariants: { size: "md" }
24
+ }
25
+ ), Y = u("font-medium text-foreground", {
26
+ variants: {
27
+ size: {
28
+ sm: "text-xs",
29
+ md: "text-sm"
30
+ }
31
+ },
32
+ defaultVariants: { size: "md" }
33
+ }), Z = u(
34
+ "w-full p-0 bg-transparent border-none outline-none text-foreground placeholder:text-secondary-foreground focus:outline-none",
35
+ {
36
+ variants: {
37
+ size: {
38
+ sm: "text-[18px]! leading-[21px]!",
39
+ md: "text-[28px]! leading-[33px]!"
83
40
  }
84
- if (c && o !== void 0) {
85
- const u = o && m && o > m ? m : o, l = T(u, v);
86
- c(u, l);
41
+ },
42
+ defaultVariants: { size: "md" }
43
+ }
44
+ ), _ = g.forwardRef(
45
+ ({
46
+ amount: v,
47
+ token: t,
48
+ label: y = "Amount",
49
+ maxAmount: a,
50
+ maxAmountLimit: o,
51
+ maxButtonLabel: w,
52
+ chainId: z,
53
+ network: N,
54
+ maxButton: C = !0,
55
+ disabled: n = !1,
56
+ active: V = !1,
57
+ size: I = "md",
58
+ onSetAmount: r,
59
+ onShowSelectDialog: c,
60
+ onRemove: m,
61
+ onFocus: B,
62
+ onBlur: k
63
+ }, M) => {
64
+ const p = t?.decimals ?? 18, j = (i) => {
65
+ const l = i.target.value, [b, h] = Q(l, p);
66
+ b === null || h === null || r && r(b, h);
67
+ }, F = () => {
68
+ if (r) {
69
+ const i = a && o && a > o ? o : a || 0n, l = P(i, p);
70
+ r(i, l);
87
71
  }
88
- }, q = D && (x || c && o !== void 0);
72
+ }, [L, f] = g.useState(!1), T = () => {
73
+ f(!0), B?.();
74
+ }, D = () => {
75
+ f(!1), k?.();
76
+ }, s = I ?? "md", R = J(), S = K(), X = O(), $ = R ? 20 : S ? 30 : X ? 26 : 30, q = !!(t || c);
89
77
  return /* @__PURE__ */ d(
90
78
  "div",
91
79
  {
92
- ref: _,
93
- className: g(
94
- "relative rounded-xl border bg-card transition-colors border-border",
95
- y && "border-primary",
96
- i && "opacity-50 cursor-not-allowed",
97
- E[N],
98
- V
99
- ),
100
- "data-active": y,
101
- "data-disabled": i,
80
+ ref: M,
81
+ className: W({ size: s }),
82
+ "data-testid": "smart-number-input-root",
83
+ "data-active": L,
84
+ "data-disabled": n,
102
85
  children: [
103
- w && /* @__PURE__ */ s(
104
- "button",
86
+ m && /* @__PURE__ */ e(
87
+ "div",
105
88
  {
106
- type: "button",
107
- onClick: w,
108
- className: "absolute -top-2 -right-2 flex h-5 w-5 items-center justify-center rounded-full bg-muted hover:bg-muted/80 text-muted-foreground",
109
- children: /* @__PURE__ */ s(K, { icon: J, className: "size-3" })
110
- }
111
- ),
112
- /* @__PURE__ */ d("div", { className: "flex items-center justify-between mb-2", children: [
113
- /* @__PURE__ */ s("span", { className: "text-sm text-muted-foreground", children: a }),
114
- B !== void 0 && /* @__PURE__ */ d("div", { className: "flex items-center gap-2", children: [
115
- /* @__PURE__ */ d("span", { className: "text-sm text-muted-foreground", children: [
116
- "Balance: ",
117
- B
118
- ] }),
119
- q && /* @__PURE__ */ s(
120
- H,
89
+ className: "absolute top-0 right-0 flex h-5 w-5 translate-x-1/2 -translate-y-1/2 items-center justify-center",
90
+ "data-testid": "smart-number-input-close",
91
+ children: /* @__PURE__ */ e(
92
+ "button",
121
93
  {
122
- variant: "ghost",
123
- size: "xs",
124
- onClick: X,
125
- disabled: i,
126
- className: "text-primary hover:text-primary/80",
127
- children: $
94
+ type: "button",
95
+ onClick: m,
96
+ className: "flex h-5 w-5 items-center justify-center rounded-full bg-muted hover:bg-muted/80 text-muted-foreground",
97
+ children: /* @__PURE__ */ e(H, { icon: G, className: "size-3" })
128
98
  }
129
99
  )
130
- ] })
100
+ }
101
+ ),
102
+ /* @__PURE__ */ d("div", { className: "mb-2 flex justify-between text-sm leading-[120%]", children: [
103
+ /* @__PURE__ */ e(
104
+ "span",
105
+ {
106
+ className: x(
107
+ Y({ size: s }),
108
+ "grow shrink-0 basis-0"
109
+ ),
110
+ "data-testid": "smart-number-input-label",
111
+ children: y
112
+ }
113
+ ),
114
+ a !== void 0 && t && /* @__PURE__ */ e(
115
+ U,
116
+ {
117
+ title: w,
118
+ token: t,
119
+ maxAmount: a,
120
+ size: s,
121
+ disabled: n,
122
+ maxButton: C,
123
+ onMaxButtonClick: F
124
+ }
125
+ )
131
126
  ] }),
132
- /* @__PURE__ */ d("div", { className: "flex items-center gap-3", children: [
133
- /* @__PURE__ */ s(
127
+ /* @__PURE__ */ d("div", { className: "flex w-full max-w-full shrink-0 basis-full items-center", children: [
128
+ /* @__PURE__ */ e("div", { className: "mr-3 grow shrink-0 basis-0", children: /* @__PURE__ */ e(
134
129
  "input",
135
130
  {
136
131
  type: "text",
@@ -140,41 +135,39 @@ const Y = G.forwardRef(
140
135
  spellCheck: "false",
141
136
  pattern: "^[0-9]*[.,]?[0-9]*$",
142
137
  placeholder: "0",
143
- value: n,
144
- onChange: R,
145
- onFocus: S,
146
- onBlur: F,
147
- disabled: i || !b && !c,
148
- className: g(
149
- "flex-1 bg-transparent border-none outline-none text-foreground font-medium placeholder:text-muted-foreground",
150
- O[N]
151
- )
138
+ value: v,
139
+ onChange: j,
140
+ onFocus: T,
141
+ onBlur: D,
142
+ disabled: n || !r,
143
+ className: x(Z({ size: s })),
144
+ "data-testid": "smart-number-input-input",
145
+ minLength: 1,
146
+ maxLength: 79,
147
+ title: "Amount"
152
148
  }
153
- ),
154
- (h || I) && /* @__PURE__ */ d(
155
- "button",
149
+ ) }),
150
+ q ? /* @__PURE__ */ e(
151
+ E,
156
152
  {
157
- type: "button",
158
- onClick: f,
159
- disabled: i || !f,
160
- className: g(
161
- "flex items-center gap-2 rounded-full bg-secondary px-3 py-1.5 text-sm font-medium transition-colors",
162
- f && !i && "hover:bg-secondary/80 cursor-pointer",
163
- !f && "cursor-default"
164
- ),
165
- children: [
166
- I,
167
- h && /* @__PURE__ */ s("span", { children: h })
168
- ]
153
+ active: V,
154
+ size: s,
155
+ disabled: n,
156
+ token: t,
157
+ showSelectDialog: c,
158
+ chainId: z,
159
+ network: N,
160
+ maxLength: $,
161
+ children: t?.symbol ?? "Select token"
169
162
  }
170
- )
163
+ ) : null
171
164
  ] })
172
165
  ]
173
166
  }
174
167
  );
175
168
  }
176
169
  );
177
- Y.displayName = "SmartNumberInput";
170
+ _.displayName = "SmartNumberInput";
178
171
  export {
179
- Y as SmartNumberInput
172
+ _ as SmartNumberInput
180
173
  };
@@ -2,51 +2,54 @@ import { useCheckboxSelect as t } from "./use-checkbox-select.js";
2
2
  import { useControllableState as i } from "./use-controllable-state.js";
3
3
  import { useDebounce as u } from "./use-debounce.js";
4
4
  import { useDebounceCall as l } from "./use-debounce-call.js";
5
- import { getSortForField as p, useFilterAllSelected as x, useRangeFilter as m, useSelectFilter as n, useSort as A } from "./use-filter.js";
6
- import { useHF as f } from "./use-hf.js";
7
- import { useEditPriceManually as I, useLiquidationGraphParams as E, useLiquidationHeatmap as d } from "./use-liquidation/index.js";
8
- import { useIsDesktop as b, useIsMobile as D, useIsTablet as F, useMediaQuery as S } from "./use-media-query.js";
9
- import { useOpenedState as T } from "./use-opened-state.js";
10
- import { usePrevious as O } from "./use-previous.js";
11
- import { CELL_BAD as v, CELL_CURRENT as G, CELL_GOOD as M, CELL_HOVERED as R, CELL_LIQUIDATION as U, CELL_OK as N, DEFAULT_AXIS_MAX as g, DEFAULT_AXIS_MIN as H, formatAxisLabel as X, formatAxisTipLabel as k, formatAxisTipPrice as y, getCellClass as Q, isPointInCell as V, useAxis as B, useFixedAssets as K, useIsAxisInRelativeUnits as W, useLiquidationGraphActivePrice as j, useLiquidationGraphCurrentActiveValue as w, usePriceInNumber as z, useWithLiquidationGraphActivePrices as J } from "./use-liquidation/utils.js";
5
+ import { getSortForField as L, useFilterAllSelected as m, useRangeFilter as x, useSelectFilter as n, useSort as A } from "./use-filter.js";
6
+ import { useHF as I } from "./use-hf.js";
7
+ import { useEditPriceManually as C, useLiquidationGraphParams as E, useLiquidationHeatmap as d } from "./use-liquidation/index.js";
8
+ import { useIsDesktop as b, useIsExtraSmall as _, useIsMobile as D, useIsTablet as F, useMediaQuery as P } from "./use-media-query.js";
9
+ import { useOpenedState as h } from "./use-opened-state.js";
10
+ import { usePrevious as q } from "./use-previous.js";
11
+ import { useSmartNumberInput as G } from "./use-smart-number-input.js";
12
+ import { CELL_BAD as N, CELL_CURRENT as R, CELL_GOOD as U, CELL_HOVERED as g, CELL_LIQUIDATION as H, CELL_OK as X, DEFAULT_AXIS_MAX as k, DEFAULT_AXIS_MIN as y, formatAxisLabel as Q, formatAxisTipLabel as V, formatAxisTipPrice as B, getCellClass as K, isPointInCell as W, useAxis as j, useFixedAssets as w, useIsAxisInRelativeUnits as z, useLiquidationGraphActivePrice as J, useLiquidationGraphCurrentActiveValue as Y, usePriceInNumber as Z, useWithLiquidationGraphActivePrices as $ } from "./use-liquidation/utils.js";
12
13
  export {
13
- v as CELL_BAD,
14
- G as CELL_CURRENT,
15
- M as CELL_GOOD,
16
- R as CELL_HOVERED,
17
- U as CELL_LIQUIDATION,
18
- N as CELL_OK,
19
- g as DEFAULT_AXIS_MAX,
20
- H as DEFAULT_AXIS_MIN,
21
- X as formatAxisLabel,
22
- k as formatAxisTipLabel,
23
- y as formatAxisTipPrice,
24
- Q as getCellClass,
25
- p as getSortForField,
26
- V as isPointInCell,
27
- B as useAxis,
14
+ N as CELL_BAD,
15
+ R as CELL_CURRENT,
16
+ U as CELL_GOOD,
17
+ g as CELL_HOVERED,
18
+ H as CELL_LIQUIDATION,
19
+ X as CELL_OK,
20
+ k as DEFAULT_AXIS_MAX,
21
+ y as DEFAULT_AXIS_MIN,
22
+ Q as formatAxisLabel,
23
+ V as formatAxisTipLabel,
24
+ B as formatAxisTipPrice,
25
+ K as getCellClass,
26
+ L as getSortForField,
27
+ W as isPointInCell,
28
+ j as useAxis,
28
29
  t as useCheckboxSelect,
29
30
  i as useControllableState,
30
31
  u as useDebounce,
31
32
  l as useDebounceCall,
32
- I as useEditPriceManually,
33
- x as useFilterAllSelected,
34
- K as useFixedAssets,
35
- f as useHF,
36
- W as useIsAxisInRelativeUnits,
33
+ C as useEditPriceManually,
34
+ m as useFilterAllSelected,
35
+ w as useFixedAssets,
36
+ I as useHF,
37
+ z as useIsAxisInRelativeUnits,
37
38
  b as useIsDesktop,
39
+ _ as useIsExtraSmall,
38
40
  D as useIsMobile,
39
41
  F as useIsTablet,
40
- j as useLiquidationGraphActivePrice,
41
- w as useLiquidationGraphCurrentActiveValue,
42
+ J as useLiquidationGraphActivePrice,
43
+ Y as useLiquidationGraphCurrentActiveValue,
42
44
  E as useLiquidationGraphParams,
43
45
  d as useLiquidationHeatmap,
44
- S as useMediaQuery,
45
- T as useOpenedState,
46
- O as usePrevious,
47
- z as usePriceInNumber,
48
- m as useRangeFilter,
46
+ P as useMediaQuery,
47
+ h as useOpenedState,
48
+ q as usePrevious,
49
+ Z as usePriceInNumber,
50
+ x as useRangeFilter,
49
51
  n as useSelectFilter,
52
+ G as useSmartNumberInput,
50
53
  A as useSort,
51
- J as useWithLiquidationGraphActivePrices
54
+ $ as useWithLiquidationGraphActivePrices
52
55
  };
@@ -1,17 +1,10 @@
1
- import { useRef as c, useCallback as n, useEffect as o } from "react";
2
- function f(r) {
3
- const e = c(null), t = n(
4
- (u) => {
5
- e.current && clearTimeout(e.current), e.current = setTimeout(() => {
6
- u();
7
- }, r);
8
- },
9
- [r]
10
- );
11
- return o(() => () => {
12
- e.current && clearTimeout(e.current);
13
- }, []), t;
1
+ import "react";
2
+ import { useDebounce as o } from "./use-debounce.js";
3
+ import "@gearbox-protocol/sdk";
4
+ const n = (e) => e();
5
+ function b(e) {
6
+ return o(n, e);
14
7
  }
15
8
  export {
16
- f as useDebounceCall
9
+ b as useDebounceCall
17
10
  };
@@ -1,35 +1,43 @@
1
- import { CreditAccountData_Legacy as p } from "@gearbox-protocol/sdk";
2
- import { useMemo as u } from "react";
3
- function x({
4
- assets: r,
1
+ import { CreditAccountData_Legacy as l } from "@gearbox-protocol/sdk";
2
+ import { useMemo as p } from "react";
3
+ function _({
4
+ assets: e,
5
5
  quotas: c,
6
- prices: m,
7
- liquidationThresholds: t,
6
+ prices: n,
7
+ liquidationThresholds: u,
8
8
  underlyingToken: f,
9
- debt: o,
10
- quotasInfo: a,
11
- tokensList: e
9
+ debt: t,
10
+ quotasInfo: o,
11
+ allowZeroDebt: m = !1,
12
+ tokensList: a
12
13
  }) {
13
- return { hf: u(() => p.calcHealthFactor({
14
- assets: r,
15
- quotas: c,
16
- prices: m,
17
- liquidationThresholds: t,
18
- underlyingToken: f,
19
- debt: o,
20
- quotasInfo: a,
21
- tokensList: e
22
- }), [
23
- r,
14
+ return { hf: p(() => {
15
+ try {
16
+ return t === 0n && !m ? 0 : l.calcHealthFactor({
17
+ assets: e,
18
+ quotas: c,
19
+ prices: n,
20
+ liquidationThresholds: u,
21
+ underlyingToken: f,
22
+ debt: t,
23
+ quotasInfo: o,
24
+ tokensList: a
25
+ });
26
+ } catch (r) {
27
+ return typeof r == "object" && r !== null && "reason" in r && r.reason === "overflow" ? Number.MAX_SAFE_INTEGER : 0;
28
+ }
29
+ }, [
30
+ e,
24
31
  c,
25
- m,
26
- t,
32
+ n,
33
+ u,
27
34
  f,
35
+ t,
28
36
  o,
29
- a,
30
- e
37
+ m,
38
+ a
31
39
  ]) };
32
40
  }
33
41
  export {
34
- x as useHF
42
+ _ as useHF
35
43
  };
@@ -1,17 +1,18 @@
1
- import { useState as c, useEffect as o } from "react";
2
- function s(n) {
3
- const [t, a] = c(!1);
4
- return o(() => {
1
+ import { useState as c, useEffect as m } from "react";
2
+ function t(n) {
3
+ const [s, a] = c(!1);
4
+ return m(() => {
5
5
  const e = window.matchMedia(n);
6
- e.matches !== t && a(e.matches);
6
+ e.matches !== s && a(e.matches);
7
7
  const i = () => a(e.matches);
8
8
  return e.addEventListener("change", i), () => e.removeEventListener("change", i);
9
- }, [t, n]), t;
9
+ }, [s, n]), s;
10
10
  }
11
- const h = () => s("(max-width: 768px)"), d = () => s("(min-width: 768px) and (max-width: 1024px)"), r = () => s("(min-width: 1024px)");
11
+ const h = () => t("(max-width: 500px)"), d = () => t("(max-width: 768px)"), r = () => t("(min-width: 768px) and (max-width: 1024px)"), u = () => t("(min-width: 1024px)");
12
12
  export {
13
- r as useIsDesktop,
14
- h as useIsMobile,
15
- d as useIsTablet,
16
- s as useMediaQuery
13
+ u as useIsDesktop,
14
+ h as useIsExtraSmall,
15
+ d as useIsMobile,
16
+ r as useIsTablet,
17
+ t as useMediaQuery
17
18
  };
@@ -0,0 +1,10 @@
1
+ import { useState as t, useCallback as i } from "react";
2
+ function p(n = 0n, e = "") {
3
+ const [o, u] = t(n), [m, a] = t(e), s = i((r, c) => {
4
+ u(r), a(c);
5
+ }, []);
6
+ return [o, m, s];
7
+ }
8
+ export {
9
+ p as useSmartNumberInput
10
+ };