@gearbox-protocol/permissionless-ui 1.23.0 → 1.23.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,68 +1,68 @@
1
1
  import { jsx as f, jsxs as N, Fragment as S } from "react/jsx-runtime";
2
- import { useRef as b, useState as g, useCallback as p, useMemo as v, useEffect as w } from "react";
2
+ import { useRef as m, useState as g, useCallback as p, useMemo as v, useEffect as w } from "react";
3
3
  import { useNavigationAdapter as T } from "../navigation-context/navigation-context.js";
4
4
  import "@gearbox-protocol/sdk";
5
- import { cn as m } from "../../utils/cn.js";
5
+ import { cn as b } from "../../utils/cn.js";
6
6
  import "sonner";
7
7
  import "luxon";
8
8
  import "../../utils/z-index.js";
9
9
  function U(t) {
10
10
  if (!t) return null;
11
- const { width: n = 0, height: i = 0 } = t?.getBoundingClientRect() || {}, s = t?.offsetTop || 0, o = t?.offsetLeft || 0;
12
- return { width: n, height: i, left: o, top: s };
11
+ const { width: n = 0, height: i = 0 } = t?.getBoundingClientRect() || {}, o = t?.offsetTop || 0, s = t?.offsetLeft || 0;
12
+ return { width: n, height: i, left: s, top: o };
13
13
  }
14
14
  function $(t, n, i) {
15
- const s = b(null), [o, u] = g(null), d = b(null), l = p((r) => {
16
- u(r), d.current = r;
15
+ const o = m(null), [s, u] = g(null), l = m(null), d = p((r) => {
16
+ u(r), l.current = r;
17
17
  }, []);
18
18
  return w(() => {
19
19
  const r = i.current[t], e = () => {
20
- const c = U(r), h = c?.height !== d.current?.height, x = c?.width !== d.current?.width, C = c?.left !== d.current?.left, y = c?.top !== d.current?.top;
21
- (h || x || C || y) && l(c);
20
+ const c = U(r), h = c?.height !== l.current?.height, x = c?.width !== l.current?.width, y = c?.left !== l.current?.left, C = c?.top !== l.current?.top;
21
+ (h || x || y || C) && d(c);
22
22
  };
23
- s.current = e, e();
23
+ o.current = e, e();
24
24
  const a = r ? new ResizeObserver(e) : null;
25
25
  return r && a?.observe(r), () => {
26
26
  r && a?.unobserve(r);
27
27
  };
28
- }, [t, i, l]), w(() => {
28
+ }, [t, i, d]), w(() => {
29
29
  const r = n ? new ResizeObserver(() => {
30
- s.current?.();
30
+ o.current?.();
31
31
  }) : null;
32
32
  return n && r?.observe(n), () => {
33
33
  n && r?.unobserve(n);
34
34
  };
35
- }, [n]), o;
35
+ }, [n]), s;
36
36
  }
37
37
  function A({
38
38
  tabs: t,
39
39
  state: n,
40
- variant: i = "auto",
41
- showBorder: s = !0,
42
- tabItemWrapPadding: o
40
+ showBorder: i = !0,
41
+ tabItemWrapPadding: o,
42
+ variant: s = "auto"
43
43
  }) {
44
- const u = b(null), d = b({}), l = $(
44
+ const u = m(null), l = m({}), d = $(
45
45
  n.id,
46
46
  u.current,
47
- d
47
+ l
48
48
  ), r = (e, a) => () => n.handleTabChange(e, a);
49
- return /* @__PURE__ */ f("div", { className: "relative w-full flex flex-col flex-wrap", children: /* @__PURE__ */ N(
49
+ return /* @__PURE__ */ f("div", { className: "relative w-full flex flex-col flex-wrap overflow-y-hidden", children: /* @__PURE__ */ N(
50
50
  "div",
51
51
  {
52
52
  ref: u,
53
- className: m(
54
- "relative bottom-[-1px] w-full max-w-full grow-0 shrink-0 basis-full flex items-stretch overflow-x-auto overflow-y-hidden",
53
+ className: b(
54
+ "relative w-full max-w-full grow-0 shrink-0 basis-full flex items-stretch overflow-x-auto overflow-y-hidden",
55
55
  "scrollbar-hidden",
56
- s && "border-b border-border"
56
+ i && "after:content-[''] after:absolute after:bottom-0 after:left-0 after:right-0 after:h-px after:bg-border"
57
57
  ),
58
58
  children: [
59
- l && /* @__PURE__ */ f(
59
+ d && /* @__PURE__ */ f(
60
60
  "div",
61
61
  {
62
- className: "absolute bottom-[-1px] left-0 h-[3px] bg-accent transition-[transform] duration-200 ease-in-out pointer-events-none",
62
+ className: "absolute left-0 h-[3px] bg-accent transition-[transform] duration-200 ease-in-out pointer-events-none bottom-[-1px]",
63
63
  style: {
64
- width: `${l.width}px`,
65
- transform: `translate(${l.left}px)`
64
+ width: `${d.width}px`,
65
+ transform: `translate(${d.left}px)`
66
66
  }
67
67
  }
68
68
  ),
@@ -72,15 +72,15 @@ function A({
72
72
  "button",
73
73
  {
74
74
  ref: (x) => {
75
- d.current[e.id] = x;
75
+ l.current[e.id] = x;
76
76
  },
77
77
  type: "button",
78
78
  onClick: e.disabled ? void 0 : r(e.id, a),
79
79
  disabled: e.disabled,
80
- className: m(
80
+ className: b(
81
81
  "flex items-center bg-transparent border-none shrink-0 text-foreground",
82
82
  o ? "" : "p-0 pb-3.5",
83
- i === "equal" ? "grow shrink-0 basis-[0%] justify-center min-w-0" : !h && "mr-10 max-[500px]:mr-8",
83
+ s === "equal" ? "grow shrink-0 basis-[0%] justify-center min-w-0" : !h && "mr-10 max-[500px]:mr-8",
84
84
  e.disabled && "cursor-not-allowed",
85
85
  !e.disabled && "cursor-pointer",
86
86
  !e.disabled && "hover:text-foreground hover:[&>*]:text-foreground"
@@ -99,14 +99,14 @@ function B({
99
99
  icon: t,
100
100
  label: n,
101
101
  selected: i,
102
- textSize: s = "default",
103
- amount: o
102
+ textSize: o = "default",
103
+ amount: s
104
104
  }) {
105
105
  return /* @__PURE__ */ N(S, { children: [
106
106
  t && /* @__PURE__ */ f(
107
107
  "div",
108
108
  {
109
- className: m(
109
+ className: b(
110
110
  "mr-3",
111
111
  i ? "text-foreground" : "text-secondary-foreground"
112
112
  ),
@@ -116,39 +116,39 @@ function B({
116
116
  /* @__PURE__ */ f(
117
117
  "div",
118
118
  {
119
- className: m(
119
+ className: b(
120
120
  "m-0 p-0 whitespace-nowrap",
121
- s === "default" && "text-sm leading-[17px] font-normal",
122
- s === "unset" && "text-[unset] leading-[unset] font-[unset]",
121
+ o === "default" && "text-sm leading-[17px] font-normal",
122
+ o === "unset" && "text-[unset] leading-[unset] font-[unset]",
123
123
  i ? "text-foreground" : "text-secondary-foreground"
124
124
  ),
125
125
  children: n
126
126
  }
127
127
  ),
128
- !!o && /* @__PURE__ */ f("div", { className: "ml-1.5", children: /* @__PURE__ */ f("div", { className: "py-0.5 px-[9px] text-[11px] leading-[150%] font-normal bg-gray-50 rounded-[19px]", children: o }) })
128
+ !!s && /* @__PURE__ */ f("div", { className: "ml-1.5", children: /* @__PURE__ */ f("div", { className: "py-0.5 px-[9px] text-[11px] leading-[150%] font-normal bg-gray-50 rounded-[19px]", children: s }) })
129
129
  ] });
130
130
  }
131
131
  function F(t, n = 0) {
132
- const [i, s] = g(t), [o, u] = g(n), d = p((l, r) => {
133
- s(l), u(r);
132
+ const [i, o] = g(t), [s, u] = g(n), l = p((d, r) => {
133
+ o(d), u(r);
134
134
  }, []);
135
- return { id: i, index: o, handleTabChange: d };
135
+ return { id: i, index: s, handleTabChange: l };
136
136
  }
137
137
  function I(t) {
138
- const { useLocation: n, useNavigate: i } = T(), { hash: s } = n(), o = i(), u = v(
138
+ const { useLocation: n, useNavigate: i } = T(), { hash: o } = n(), s = i(), u = v(
139
139
  () => t.reduce(
140
140
  (a, c, h) => (a[c.id] = { id: c.id, index: h }, a),
141
141
  {}
142
142
  ),
143
143
  [t]
144
- ), d = v(() => s.slice(1).toLowerCase(), [s]), { id: l, index: r } = u[d] || {}, e = p(
144
+ ), l = v(() => o.slice(1).toLowerCase(), [o]), { id: d, index: r } = u[l] || {}, e = p(
145
145
  (a) => {
146
- o(`#${a}`);
146
+ s(`#${a}`);
147
147
  },
148
- [o]
148
+ [s]
149
149
  );
150
150
  return {
151
- id: l,
151
+ id: d,
152
152
  index: r,
153
153
  handleTabChange: e
154
154
  };
@@ -158,19 +158,19 @@ function M({
158
158
  pathRoot: n,
159
159
  selectedSection: i
160
160
  }) {
161
- const { useNavigate: s } = T(), o = s(), u = v(
161
+ const { useNavigate: o } = T(), s = o(), u = v(
162
162
  () => t.reduce(
163
163
  (e, a, c) => (e[a.id] = { id: a.id, index: c }, e),
164
164
  {}
165
165
  ),
166
166
  [t]
167
- ), d = p(
167
+ ), l = p(
168
168
  (e) => {
169
- o(`${n}/${e}`);
169
+ s(`${n}/${e}`);
170
170
  },
171
- [o, n]
172
- ), { id: l, index: r } = u[i] || {};
173
- return { id: l, index: r, handleTabChange: d };
171
+ [s, n]
172
+ ), { id: d, index: r } = u[i] || {};
173
+ return { id: d, index: r, handleTabChange: l };
174
174
  }
175
175
  export {
176
176
  A as TabControl,
@@ -1,5 +1,5 @@
1
- import { jsxs as f, jsx as r } from "react/jsx-runtime";
2
- import { useMemo as d, useCallback as P, useRef as N } from "react";
1
+ import { jsxs as d, jsx as t } from "react/jsx-runtime";
2
+ import { useMemo as u, useCallback as $, useRef as I } from "react";
3
3
  import { toast as q } from "sonner";
4
4
  import { useIsMobile as J } from "../../hooks/use-media-query.js";
5
5
  import "@gearbox-protocol/sdk";
@@ -7,10 +7,10 @@ import { cn as K } from "../../utils/cn.js";
7
7
  import "luxon";
8
8
  import "../../utils/z-index.js";
9
9
  import { RangeButtons as Q } from "../buttons/range-buttons/range-buttons.js";
10
- import { DEFAULT_SERIES_COLORS as l } from "../graph/graph.js";
11
- import { GraphViewWithData as X } from "../graph/graph-view.js";
12
- import { GraphDropdown as Y } from "./graph-dropdown.js";
13
- const Z = ({ size: e = 16 }) => /* @__PURE__ */ f(
10
+ import { DEFAULT_SERIES_COLORS as N, getSeriesColorPalette as X } from "../graph/graph.js";
11
+ import { GraphViewWithData as Y } from "../graph/graph-view.js";
12
+ import { GraphDropdown as Z } from "./graph-dropdown.js";
13
+ const G = ({ size: e = 16 }) => /* @__PURE__ */ d(
14
14
  "svg",
15
15
  {
16
16
  width: e,
@@ -23,11 +23,11 @@ const Z = ({ size: e = 16 }) => /* @__PURE__ */ f(
23
23
  strokeLinejoin: "round",
24
24
  "aria-label": "Expand fullscreen",
25
25
  children: [
26
- /* @__PURE__ */ r("title", { children: "Expand fullscreen" }),
27
- /* @__PURE__ */ r("path", { d: "M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3" })
26
+ /* @__PURE__ */ t("title", { children: "Expand fullscreen" }),
27
+ /* @__PURE__ */ t("path", { d: "M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3" })
28
28
  ]
29
29
  }
30
- ), G = ({ size: e = 16 }) => /* @__PURE__ */ f(
30
+ ), U = ({ size: e = 16 }) => /* @__PURE__ */ d(
31
31
  "svg",
32
32
  {
33
33
  width: e,
@@ -40,121 +40,121 @@ const Z = ({ size: e = 16 }) => /* @__PURE__ */ f(
40
40
  strokeLinejoin: "round",
41
41
  "aria-label": "Exit fullscreen",
42
42
  children: [
43
- /* @__PURE__ */ r("title", { children: "Exit fullscreen" }),
44
- /* @__PURE__ */ r("path", { d: "M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3" })
43
+ /* @__PURE__ */ t("title", { children: "Exit fullscreen" }),
44
+ /* @__PURE__ */ t("path", { d: "M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3" })
45
45
  ]
46
46
  }
47
47
  );
48
- function he({
48
+ function pe({
49
49
  data: e,
50
50
  yMeasureUnit: n,
51
- height: h = 306,
52
- defaultGraph: p,
53
- onGraphSelected: x,
54
- graphs: v,
51
+ height: f = 306,
52
+ defaultGraph: h,
53
+ onGraphSelected: p,
54
+ graphs: x,
55
55
  isMultipleSelect: L,
56
- range: j,
57
- rangeList: A,
58
- setRange: E,
59
- onGraphExpanded: g,
60
- isGraphExpanded: S,
56
+ range: S,
57
+ rangeList: y,
58
+ setRange: j,
59
+ onGraphExpanded: v,
60
+ isGraphExpanded: E,
61
61
  onUnselectSeries: R,
62
62
  graphsWithNoData: V,
63
63
  loadingGraphs: B,
64
- noDataMessage: k = "No data available for this graph",
64
+ noDataMessage: A = "No data available for this graph",
65
65
  currentValueDecimals: M,
66
66
  containerClassName: _,
67
67
  ...F
68
68
  }) {
69
- const s = d(() => Array.isArray(e) ? e : e ? [e] : [], [e]), C = d(() => Array.isArray(e) && e.length > 1, [e]), D = J(), T = P(
70
- (m, w) => {
71
- q.error(k);
69
+ const l = u(() => Array.isArray(e) ? e : e ? [e] : [], [e]), C = u(() => Array.isArray(e) && e.length > 1, [e]), k = J(), T = $(
70
+ (a, g) => {
71
+ q.error(A);
72
72
  },
73
- [k]
74
- ), W = d(() => {
73
+ [A]
74
+ ), W = u(() => {
75
75
  if (n)
76
76
  return Array.isArray(n) ? n[0] : n;
77
- }, [n]), z = (!D && g || A.length > 0 || x && v && p) && /* @__PURE__ */ f("div", { className: "z-10 w-full flex flex-row flex-wrap sm:flex-nowrap items-center gap-2", children: [
78
- /* @__PURE__ */ r("div", { children: x && v && p && /* @__PURE__ */ r(
79
- Y,
77
+ }, [n]), z = (!k && v || y.length > 0 || p && x && h) && /* @__PURE__ */ d("div", { className: "z-10 w-full flex flex-row flex-wrap sm:flex-nowrap items-center gap-2", children: [
78
+ /* @__PURE__ */ t("div", { children: p && x && h && /* @__PURE__ */ t(
79
+ Z,
80
80
  {
81
- onSelected: x,
82
- items: v,
83
- defaultItem: p,
81
+ onSelected: p,
82
+ items: x,
83
+ defaultItem: h,
84
84
  multiple: L,
85
85
  graphsWithNoData: V,
86
86
  loadingGraphs: B,
87
87
  onNoDataSelected: T
88
88
  }
89
89
  ) }),
90
- /* @__PURE__ */ f("div", { className: "flex flex-row flex-nowrap justify-start sm:justify-end items-center flex-1", children: [
91
- /* @__PURE__ */ r(Q, { range: j, rangeList: A, setRange: E }),
92
- !D && g && /* @__PURE__ */ r(
90
+ /* @__PURE__ */ d("div", { className: "flex flex-row flex-nowrap justify-start sm:justify-end items-center flex-1", children: [
91
+ /* @__PURE__ */ t(Q, { range: S, rangeList: y, setRange: j }),
92
+ !k && v && /* @__PURE__ */ t(
93
93
  "button",
94
94
  {
95
95
  type: "button",
96
96
  className: "px-2.5 py-1.5 flex min-w-[44px] min-h-[26px] justify-center items-center text-xs leading-[14px] font-medium text-center rounded-md border cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring bg-muted border-muted text-muted-foreground hover:border-secondary ml-1.5",
97
- onClick: g,
98
- children: S ? /* @__PURE__ */ r(G, { size: 16 }) : /* @__PURE__ */ r(Z, { size: 16 })
97
+ onClick: v,
98
+ children: E ? /* @__PURE__ */ t(U, { size: 16 }) : /* @__PURE__ */ t(G, { size: 16 })
99
99
  }
100
100
  )
101
101
  ] })
102
- ] }), a = N(/* @__PURE__ */ new Map()), b = N(0), H = d(() => {
103
- const m = Array.isArray(n) ? n : void 0;
104
- return s.map((w, I) => {
105
- const c = w?.title || `Series ${I + 1}`;
106
- if (!a.current.has(c)) {
107
- const t = new Set(
108
- Array.from(a.current.values())
102
+ ] }), s = I(/* @__PURE__ */ new Map()), b = I(0), H = u(() => {
103
+ const a = Array.isArray(n) ? n : void 0;
104
+ return l.map((g, D) => {
105
+ const m = g?.title || `Series ${D + 1}`;
106
+ if (!s.current.has(m)) {
107
+ const r = new Set(
108
+ Array.from(s.current.values())
109
109
  );
110
110
  let o = b.current;
111
- for (let i = 0; i < l.length; i++) {
112
- const u = (b.current + i) % l.length;
113
- if (!t.has(u)) {
114
- o = u;
111
+ for (let i = 0; i < N.length; i++) {
112
+ const c = (b.current + i) % N.length;
113
+ if (!r.has(c)) {
114
+ o = c;
115
115
  break;
116
116
  }
117
117
  }
118
- a.current.set(c, o), b.current = (o + 1) % l.length;
118
+ s.current.set(m, o), b.current = o + 1;
119
119
  }
120
- const $ = a.current.get(c) ?? 0, y = l[$ % l.length];
120
+ const P = s.current.get(m) ?? 0, w = X(P);
121
121
  return {
122
- data: [...w?.data || []].sort((t, o) => {
123
- const i = typeof t.time == "number" ? t.time : Number(t.time), u = typeof o.time == "number" ? o.time : Number(o.time);
124
- return i - u;
125
- }).reduce((t, o) => {
122
+ data: [...g?.data || []].sort((r, o) => {
123
+ const i = typeof r.time == "number" ? r.time : Number(r.time), c = typeof o.time == "number" ? o.time : Number(o.time);
124
+ return i - c;
125
+ }).reduce((r, o) => {
126
126
  const i = o.time;
127
- return t.length === 0 || t[t.length - 1].time !== i ? t.push({
127
+ return r.length === 0 || r[r.length - 1].time !== i ? r.push({
128
128
  time: i,
129
129
  value: o.value
130
- }) : t[t.length - 1] = {
130
+ }) : r[r.length - 1] = {
131
131
  time: i,
132
132
  value: o.value
133
- }, t;
133
+ }, r;
134
134
  }, []),
135
- label: c,
136
- yMeasureUnit: m?.[I] ?? (Array.isArray(n) ? void 0 : n),
137
- color: y.line,
138
- topColor: y.top,
139
- bottomColor: y.bottom
135
+ label: m,
136
+ yMeasureUnit: a?.[D] ?? (Array.isArray(n) ? void 0 : n),
137
+ color: w.line,
138
+ topColor: w.top,
139
+ bottomColor: w.bottom
140
140
  };
141
141
  });
142
- }, [s, n]), O = C && s.length > 0 ? s.some((m) => !m) : !e;
143
- return /* @__PURE__ */ r(
142
+ }, [l, n]), O = C && l.length > 0 ? l.some((a) => !a) : !e;
143
+ return /* @__PURE__ */ t(
144
144
  "div",
145
145
  {
146
146
  style: {
147
147
  width: "100%",
148
- height: h ? `${h}px` : void 0
148
+ height: f ? `${f}px` : void 0
149
149
  },
150
150
  className: "w-full",
151
- children: /* @__PURE__ */ r(
152
- X,
151
+ children: /* @__PURE__ */ t(
152
+ Y,
153
153
  {
154
154
  series: H,
155
155
  loading: O,
156
156
  toolbar: z,
157
- size: h ? "full" : "default",
157
+ size: f ? "full" : "default",
158
158
  containerClassName: K("h-full", _),
159
159
  showLegend: C,
160
160
  onUnselectSeries: R,
@@ -167,5 +167,5 @@ function he({
167
167
  );
168
168
  }
169
169
  export {
170
- he as TradingView
170
+ pe as TradingView
171
171
  };