@gearbox-protocol/permissionless-ui 1.23.0 → 1.24.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,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,16 +1,16 @@
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";
3
- import { toast as q } from "sonner";
4
- import { useIsMobile as J } from "../../hooks/use-media-query.js";
1
+ import { jsxs as d, jsx as t } from "react/jsx-runtime";
2
+ import { useMemo as u, useCallback as q, useRef as I } from "react";
3
+ import { toast as J } from "sonner";
4
+ import { useIsMobile as K } from "../../hooks/use-media-query.js";
5
5
  import "@gearbox-protocol/sdk";
6
- import { cn as K } from "../../utils/cn.js";
6
+ import { cn as Q } from "../../utils/cn.js";
7
7
  import "luxon";
8
8
  import "../../utils/z-index.js";
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(
9
+ import { RangeButtons as X } from "../buttons/range-buttons/range-buttons.js";
10
+ import { DEFAULT_SERIES_COLORS as N, getSeriesColorPalette as Y } from "../graph/graph.js";
11
+ import { GraphViewWithData as Z } from "../graph/graph-view.js";
12
+ import { GraphDropdown as G } from "./graph-dropdown.js";
13
+ const U = ({ 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
+ ), ee = ({ size: e = 16 }) => /* @__PURE__ */ d(
31
31
  "svg",
32
32
  {
33
33
  width: e,
@@ -40,132 +40,134 @@ 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 xe({
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
- ...F
67
+ useSharedPriceScale: F,
68
+ ...T
68
69
  }) {
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);
70
+ const l = u(() => Array.isArray(e) ? e : e ? [e] : [], [e]), C = u(() => Array.isArray(e) && e.length > 1, [e]), k = K(), W = q(
71
+ (a, g) => {
72
+ J.error(A);
72
73
  },
73
- [k]
74
- ), W = d(() => {
74
+ [A]
75
+ ), z = u(() => {
75
76
  if (n)
76
77
  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,
78
+ }, [n]), H = (!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: [
79
+ /* @__PURE__ */ t("div", { children: p && x && h && /* @__PURE__ */ t(
80
+ G,
80
81
  {
81
- onSelected: x,
82
- items: v,
83
- defaultItem: p,
82
+ onSelected: p,
83
+ items: x,
84
+ defaultItem: h,
84
85
  multiple: L,
85
86
  graphsWithNoData: V,
86
87
  loadingGraphs: B,
87
- onNoDataSelected: T
88
+ onNoDataSelected: W
88
89
  }
89
90
  ) }),
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(
91
+ /* @__PURE__ */ d("div", { className: "flex flex-row flex-nowrap justify-start sm:justify-end items-center flex-1", children: [
92
+ /* @__PURE__ */ t(X, { range: S, rangeList: y, setRange: j }),
93
+ !k && v && /* @__PURE__ */ t(
93
94
  "button",
94
95
  {
95
96
  type: "button",
96
97
  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 })
98
+ onClick: v,
99
+ children: E ? /* @__PURE__ */ t(ee, { size: 16 }) : /* @__PURE__ */ t(U, { size: 16 })
99
100
  }
100
101
  )
101
102
  ] })
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())
103
+ ] }), s = I(/* @__PURE__ */ new Map()), b = I(0), O = u(() => {
104
+ const a = Array.isArray(n) ? n : void 0;
105
+ return l.map((g, D) => {
106
+ const m = g?.title || `Series ${D + 1}`;
107
+ if (!s.current.has(m)) {
108
+ const r = new Set(
109
+ Array.from(s.current.values())
109
110
  );
110
111
  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;
112
+ for (let i = 0; i < N.length; i++) {
113
+ const c = (b.current + i) % N.length;
114
+ if (!r.has(c)) {
115
+ o = c;
115
116
  break;
116
117
  }
117
118
  }
118
- a.current.set(c, o), b.current = (o + 1) % l.length;
119
+ s.current.set(m, o), b.current = o + 1;
119
120
  }
120
- const $ = a.current.get(c) ?? 0, y = l[$ % l.length];
121
+ const $ = s.current.get(m) ?? 0, w = Y($);
121
122
  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) => {
123
+ data: [...g?.data || []].sort((r, o) => {
124
+ const i = typeof r.time == "number" ? r.time : Number(r.time), c = typeof o.time == "number" ? o.time : Number(o.time);
125
+ return i - c;
126
+ }).reduce((r, o) => {
126
127
  const i = o.time;
127
- return t.length === 0 || t[t.length - 1].time !== i ? t.push({
128
+ return r.length === 0 || r[r.length - 1].time !== i ? r.push({
128
129
  time: i,
129
130
  value: o.value
130
- }) : t[t.length - 1] = {
131
+ }) : r[r.length - 1] = {
131
132
  time: i,
132
133
  value: o.value
133
- }, t;
134
+ }, r;
134
135
  }, []),
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
136
+ label: m,
137
+ yMeasureUnit: a?.[D] ?? (Array.isArray(n) ? void 0 : n),
138
+ color: w.line,
139
+ topColor: w.top,
140
+ bottomColor: w.bottom
140
141
  };
141
142
  });
142
- }, [s, n]), O = C && s.length > 0 ? s.some((m) => !m) : !e;
143
- return /* @__PURE__ */ r(
143
+ }, [l, n]), P = C && l.length > 0 ? l.some((a) => !a) : !e;
144
+ return /* @__PURE__ */ t(
144
145
  "div",
145
146
  {
146
147
  style: {
147
148
  width: "100%",
148
- height: h ? `${h}px` : void 0
149
+ height: f ? `${f}px` : void 0
149
150
  },
150
151
  className: "w-full",
151
- children: /* @__PURE__ */ r(
152
- X,
152
+ children: /* @__PURE__ */ t(
153
+ Z,
153
154
  {
154
- series: H,
155
- loading: O,
156
- toolbar: z,
157
- size: h ? "full" : "default",
158
- containerClassName: K("h-full", _),
155
+ series: O,
156
+ loading: P,
157
+ toolbar: H,
158
+ size: f ? "full" : "default",
159
+ containerClassName: Q("h-full", _),
159
160
  showLegend: C,
160
161
  onUnselectSeries: R,
161
- yMeasureUnit: W,
162
+ yMeasureUnit: z,
162
163
  currentValueDecimals: M,
163
- ...F
164
+ useSharedPriceScale: F,
165
+ ...T
164
166
  }
165
167
  )
166
168
  }
167
169
  );
168
170
  }
169
171
  export {
170
- he as TradingView
172
+ xe as TradingView
171
173
  };