@gearbox-protocol/ui-kit 3.8.1 → 3.9.0

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,76 +1,78 @@
1
- import { jsx as l, Fragment as G, jsxs as C } from "react/jsx-runtime";
2
- import * as b from "react";
3
- import { HeadCell as D } from "../../head-cell/head-cell.js";
4
- import { HelpTip as $ } from "../../help-tip/help-tip.js";
5
- import { GridLoadingLine as A } from "../../table/grid-loading-line.js";
6
- import { GridTable as E, GridTableHeader as F, GridTableBody as X, GridTableRow as k, GridTableHead as q, GridTableCell as P } from "../../table/grid-table.js";
7
- import { TableLoaderGuard as J } from "../../table/table-loader-guard.js";
8
- import { TableLineSm as K, TableCellSm as Q } from "../../table/table-sm.js";
1
+ import { jsx as t, Fragment as I, jsxs as N } from "react/jsx-runtime";
2
+ import * as C from "react";
3
+ import { HeadCell as q } from "../../head-cell/head-cell.js";
4
+ import { HelpTip as R } from "../../help-tip/help-tip.js";
5
+ import { GridLoadingLine as J } from "../../table/grid-loading-line.js";
6
+ import { GridTable as K, GridTableHeader as Q, GridTableBody as U, GridTableRow as O, GridTableHead as V, GridTableCell as j } from "../../table/grid-table.js";
7
+ import { TableLoaderGuard as W } from "../../table/table-loader-guard.js";
8
+ import { TableLineSm as Y, TableCellSm as Z } from "../../table/table-sm.js";
9
9
  import "@gearbox-protocol/sdk/common-utils";
10
10
  import "@gearbox-protocol/sdk";
11
- import { useIsMobile as U, useIsMedium as V } from "../../../hooks/use-media-query.js";
12
- import { cn as T } from "../../../utils/cn.js";
13
- function j({
11
+ import { useIsMobile as _, useIsMedium as w } from "../../../hooks/use-media-query.js";
12
+ import { poolTableTestIds as k } from "../../../test-ids/pool-table.js";
13
+ import { cn as L } from "../../../utils/cn.js";
14
+ function H({
14
15
  last: e,
15
- className: n,
16
+ className: l,
16
17
  ...d
17
18
  }) {
18
- return /* @__PURE__ */ l(
19
- k,
19
+ return /* @__PURE__ */ t(
20
+ O,
20
21
  {
21
- className: T(e && "*:after:hidden", n),
22
+ className: L(e && "*:after:hidden", l),
22
23
  ...d
23
24
  }
24
25
  );
25
26
  }
26
- function W({
27
+ function ee({
27
28
  columns: e,
28
- sort: n,
29
+ sort: l,
29
30
  isMedium: d
30
31
  }) {
31
- return /* @__PURE__ */ l(k, { noHover: !0, height: "35px", children: e.map((i) => {
32
+ return /* @__PURE__ */ t(O, { noHover: !0, height: "35px", children: e.map((i) => {
32
33
  if (i.hideOnMedium && d) return null;
33
- const s = i.sort, a = s && n ? {
34
- direction: n.state?.field === s.field ? n.state.sort : null,
35
- onSort: () => n.set(s.field, s.defaultDirection ?? "desc")
34
+ const s = i.sort, a = s && l ? {
35
+ direction: l.state?.field === s.field ? l.state.sort : null,
36
+ onSort: () => l.set(s.field, s.defaultDirection ?? "desc")
36
37
  } : void 0, p = typeof i.header == "function" ? i.header(a) : i.header;
37
- return /* @__PURE__ */ l(
38
- q,
38
+ return /* @__PURE__ */ t(
39
+ V,
39
40
  {
40
41
  justify: i.align === "right" ? "end" : i.align === "center" ? "center" : "start",
41
42
  size: "sm",
42
43
  gapBefore: i.gapBefore,
43
- className: T(i.className, i.headerClassName),
44
- children: a ? /* @__PURE__ */ C(G, { children: [
45
- /* @__PURE__ */ l(
46
- D,
44
+ className: L(i.className, i.headerClassName),
45
+ children: a ? /* @__PURE__ */ N(I, { children: [
46
+ /* @__PURE__ */ t(
47
+ q,
47
48
  {
48
49
  title: p,
49
50
  sortDirection: a.direction ?? void 0,
50
51
  onSort: a.onSort
51
52
  }
52
53
  ),
53
- i.headerTip && /* @__PURE__ */ l($, { className: "ml-1.5", children: i.headerTip })
54
- ] }) : /* @__PURE__ */ C(G, { children: [
54
+ i.headerTip && /* @__PURE__ */ t(R, { className: "ml-1.5", children: i.headerTip })
55
+ ] }) : /* @__PURE__ */ N(I, { children: [
55
56
  p,
56
- i.headerTip && /* @__PURE__ */ l($, { className: "ml-1.5", children: i.headerTip })
57
+ i.headerTip && /* @__PURE__ */ t(R, { className: "ml-1.5", children: i.headerTip })
57
58
  ] })
58
59
  },
59
60
  i.id
60
61
  );
61
62
  }) });
62
63
  }
63
- function Y({
64
+ function ie({
64
65
  row: e,
65
- columns: n,
66
+ columns: l,
66
67
  last: d,
67
68
  rowHeight: i,
68
69
  isSmall: s,
69
70
  isMedium: a,
70
71
  mobileColumnsXs: p,
71
- mobileColumnsMd: h
72
+ mobileColumnsMd: c,
73
+ rowTestId: u
72
74
  }) {
73
- const f = b.useMemo(
75
+ const f = C.useMemo(
74
76
  () => ({
75
77
  pool: e.pool,
76
78
  tokensList: e.tokensList,
@@ -82,99 +84,113 @@ function Y({
82
84
  isMobile: s
83
85
  }),
84
86
  [e, s]
85
- ), N = a ? n.filter((r) => !r.hideOnMedium) : n;
87
+ ), M = a ? l.filter((n) => !n.hideOnMedium) : l;
86
88
  if (s) {
87
- const r = n.filter((t) => !t.hideOnMobile), [c, ...M] = r, u = (t) => t.mobileCell ? t.mobileCell(f) : t.cell(f);
88
- return /* @__PURE__ */ l(j, { last: d, href: e.href, children: /* @__PURE__ */ l(P, { span: "full", size: "sm", className: "px-3 py-0!", children: /* @__PURE__ */ l(
89
- K,
89
+ const n = l.filter((r) => !r.hideOnMobile), [g, ...x] = n, T = (r) => r.mobileCell ? r.mobileCell(f) : r.cell(f);
90
+ return /* @__PURE__ */ t(H, { last: d, href: e.href, "data-testid": u, children: /* @__PURE__ */ t(j, { span: "full", size: "sm", className: "px-3 py-0!", children: /* @__PURE__ */ t(
91
+ Y,
90
92
  {
91
- title: c ? u(c) : void 0,
93
+ title: g ? T(g) : void 0,
92
94
  columnsXs: p,
93
- columnsMd: h,
95
+ columnsMd: c,
94
96
  className: "w-full",
95
- children: M.map((t) => /* @__PURE__ */ l(Q, { title: t.mobileTitle, children: u(t) }, t.id))
97
+ children: x.map((r) => /* @__PURE__ */ t(Z, { title: r.mobileTitle, children: T(r) }, r.id))
96
98
  }
97
99
  ) }) });
98
100
  }
99
- return /* @__PURE__ */ l(j, { last: d, href: e.href, height: `${i}px`, children: N.map((r) => /* @__PURE__ */ l(
100
- P,
101
+ return /* @__PURE__ */ t(
102
+ H,
101
103
  {
102
- textAlign: r.align ?? "left",
103
- size: "sm",
104
- gapBefore: r.gapBefore,
105
- className: r.className,
106
- children: r.cell(f)
107
- },
108
- r.id
109
- )) });
104
+ last: d,
105
+ href: e.href,
106
+ height: `${i}px`,
107
+ "data-testid": u,
108
+ children: M.map((n) => /* @__PURE__ */ t(
109
+ j,
110
+ {
111
+ textAlign: n.align ?? "left",
112
+ size: "sm",
113
+ gapBefore: n.gapBefore,
114
+ className: n.className,
115
+ children: n.cell(f)
116
+ },
117
+ n.id
118
+ ))
119
+ }
120
+ );
110
121
  }
111
- function oe({
122
+ function fe({
112
123
  columns: e,
113
- rows: n,
124
+ rows: l,
114
125
  loading: d = !1,
115
126
  partialLoading: i = !1,
116
127
  error: s,
117
128
  emptyContent: a,
118
129
  skeletonRows: p = 5,
119
- rowHeight: h = 75,
120
- size: f = "lg",
121
- mobileColumnsXs: N = 3,
122
- mobileColumnsMd: r = 3,
123
- className: c,
124
- wrapperClassName: M,
125
- sort: u
130
+ rowHeight: c = 75,
131
+ size: u = "lg",
132
+ mobileColumnsXs: f = 3,
133
+ mobileColumnsMd: M = 3,
134
+ className: n,
135
+ wrapperClassName: g,
136
+ sort: x,
137
+ rowTestId: T,
138
+ loaderTestId: r
126
139
  }) {
127
- const t = U(), g = V(), m = b.useMemo(
128
- () => g ? e.filter((o) => !o.hideOnMedium) : e,
129
- [e, g]
130
- ), I = b.useMemo(() => t ? "1fr" : m.map((o) => o.width ?? "1fr").join(" "), [t, m]), v = b.useMemo(() => {
131
- const o = m.map((H, O) => {
132
- const L = H.gapBefore;
133
- if (!L || L === "none") return null;
134
- const z = L === "md" ? "pl-10" : "pl-5";
135
- return `[&:nth-child(${O + 1})]:${z}`;
136
- }).filter(Boolean).join(" "), y = m[m.length - 1]?.className?.includes("pr-4") ? "last:pr-4" : "";
137
- return T("px-1 py-2 first:pl-4", y, o);
138
- }, [m]), x = d || !n, R = !x && n && n.length === 0, B = i && !x;
139
- return s ? null : R && a ? /* @__PURE__ */ l(G, { children: a }) : /* @__PURE__ */ C(
140
- E,
140
+ const z = T ?? k.poolLine, B = r ?? k.poolLineLoading, h = _(), b = w(), m = C.useMemo(
141
+ () => b ? e.filter((o) => !o.hideOnMedium) : e,
142
+ [e, b]
143
+ ), D = C.useMemo(() => h ? "1fr" : m.map((o) => o.width ?? "1fr").join(" "), [h, m]), S = C.useMemo(() => {
144
+ const o = m.map((E, F) => {
145
+ const G = E.gapBefore;
146
+ if (!G || G === "none") return null;
147
+ const X = G === "md" ? "pl-10" : "pl-5";
148
+ return `[&:nth-child(${F + 1})]:${X}`;
149
+ }).filter(Boolean).join(" "), v = m[m.length - 1]?.className?.includes("pr-4") ? "last:pr-4" : "";
150
+ return L("px-1 py-2 first:pl-4", v, o);
151
+ }, [m]), y = d || !l, A = !y && l && l.length === 0, $ = i && !y;
152
+ return s ? null : A && a ? /* @__PURE__ */ t(I, { children: a }) : /* @__PURE__ */ N(
153
+ K,
141
154
  {
142
- cols: I,
155
+ cols: D,
143
156
  gap: 0,
144
- size: f,
145
- wrapperClassName: T("overflow-visible", M),
146
- className: c,
157
+ size: u,
158
+ wrapperClassName: L("overflow-visible", g),
159
+ className: n,
147
160
  children: [
148
- !t && /* @__PURE__ */ l(F, { children: /* @__PURE__ */ l(W, { columns: e, sort: u, isMedium: g }) }),
149
- /* @__PURE__ */ l(
150
- J,
161
+ !h && /* @__PURE__ */ t(Q, { children: /* @__PURE__ */ t(ee, { columns: e, sort: x, isMedium: b }) }),
162
+ /* @__PURE__ */ t(
163
+ W,
151
164
  {
152
- showGuard: x,
165
+ showGuard: y,
153
166
  rows: p,
154
- columns: t ? 1 : m.length,
155
- height: `${h}px`,
156
- cellClassName: t ? "px-1 py-2 first:pl-4 last:pr-4" : v,
157
- children: /* @__PURE__ */ C(X, { children: [
158
- n?.map((o, S, y) => /* @__PURE__ */ l(
159
- Y,
167
+ columns: h ? 1 : m.length,
168
+ height: `${c}px`,
169
+ "data-testid": B,
170
+ cellClassName: h ? "px-1 py-2 first:pl-4 last:pr-4" : S,
171
+ children: /* @__PURE__ */ N(U, { children: [
172
+ l?.map((o, P, v) => /* @__PURE__ */ t(
173
+ ie,
160
174
  {
161
175
  row: o,
162
176
  columns: e,
163
- last: S === y.length - 1 && !B,
164
- rowHeight: h,
165
- isSmall: t,
166
- isMedium: g,
167
- mobileColumnsXs: N,
168
- mobileColumnsMd: r
177
+ last: P === v.length - 1 && !$,
178
+ rowHeight: c,
179
+ isSmall: h,
180
+ isMedium: b,
181
+ mobileColumnsXs: f,
182
+ mobileColumnsMd: M,
183
+ rowTestId: z
169
184
  },
170
185
  `${o.chainId}-${o.pool.address}`
171
186
  )),
172
- B && /* @__PURE__ */ l(
173
- A,
187
+ $ && /* @__PURE__ */ t(
188
+ J,
174
189
  {
175
- height: `${h}px`,
190
+ height: `${c}px`,
176
191
  columns: m.length,
177
- cellClassName: v,
192
+ cellClassName: S,
193
+ "data-testid": B,
178
194
  last: !0
179
195
  }
180
196
  )
@@ -186,5 +202,5 @@ function oe({
186
202
  );
187
203
  }
188
204
  export {
189
- oe as PoolTable
205
+ fe as PoolTable
190
206
  };