@gearbox-protocol/permissionless-ui 1.26.2 → 1.26.3
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.
- package/dist/cjs/components/graph/formatters.cjs +1 -1
- package/dist/cjs/components/graph/graph-tooltip.cjs +1 -1
- package/dist/cjs/components/graph/graph.cjs +1 -1
- package/dist/cjs/components/graph/index.cjs +1 -1
- package/dist/cjs/components/index.cjs +1 -1
- package/dist/cjs/components/trading-view/trading-view.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/esm/components/graph/formatters.js +147 -105
- package/dist/esm/components/graph/graph-tooltip.js +8 -8
- package/dist/esm/components/graph/graph.js +341 -302
- package/dist/esm/components/graph/index.js +16 -15
- package/dist/esm/components/index.js +440 -439
- package/dist/esm/components/trading-view/trading-view.js +147 -143
- package/dist/esm/index.js +589 -588
- package/dist/types/components/graph/formatters.d.ts +10 -1
- package/dist/types/components/graph/index.d.ts +1 -1
- package/dist/types/components/graph/plugins/vertical-line.d.ts +2 -2
- package/dist/types/components/trading-view/trading-view.d.ts +2 -0
- package/package.json +6 -6
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { jsxs as y, jsx as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { toast as
|
|
4
|
-
import { useIsMobile as
|
|
1
|
+
import { jsxs as y, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as S, useCallback as oe, useRef as C } from "react";
|
|
3
|
+
import { toast as ne } from "sonner";
|
|
4
|
+
import { useIsMobile as ie } from "../../hooks/use-media-query.js";
|
|
5
5
|
import "@gearbox-protocol/sdk";
|
|
6
|
-
import { cn as
|
|
6
|
+
import { cn as le } from "../../utils/cn.js";
|
|
7
7
|
import "luxon";
|
|
8
8
|
import "../../utils/z-index.js";
|
|
9
|
-
import { RangeButtons as
|
|
10
|
-
import { DEFAULT_SERIES_COLORS as
|
|
11
|
-
import { GraphViewWithData as
|
|
12
|
-
import { GraphDropdown as
|
|
13
|
-
const
|
|
9
|
+
import { RangeButtons as se } from "../buttons/range-buttons/range-buttons.js";
|
|
10
|
+
import { DEFAULT_SERIES_COLORS as M, getSeriesColorPalette as ce } from "../graph/graph.js";
|
|
11
|
+
import { GraphViewWithData as ue } from "../graph/graph-view.js";
|
|
12
|
+
import { GraphDropdown as me } from "./graph-dropdown.js";
|
|
13
|
+
const ae = ({ size: e = 16 }) => /* @__PURE__ */ y(
|
|
14
14
|
"svg",
|
|
15
15
|
{
|
|
16
16
|
width: e,
|
|
@@ -23,11 +23,11 @@ const ce = ({ size: e = 16 }) => /* @__PURE__ */ y(
|
|
|
23
23
|
strokeLinejoin: "round",
|
|
24
24
|
"aria-label": "Expand fullscreen",
|
|
25
25
|
children: [
|
|
26
|
-
/* @__PURE__ */
|
|
27
|
-
/* @__PURE__ */
|
|
26
|
+
/* @__PURE__ */ i("title", { children: "Expand fullscreen" }),
|
|
27
|
+
/* @__PURE__ */ i("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
|
-
),
|
|
30
|
+
), de = ({ size: e = 16 }) => /* @__PURE__ */ y(
|
|
31
31
|
"svg",
|
|
32
32
|
{
|
|
33
33
|
width: e,
|
|
@@ -40,202 +40,206 @@ const ce = ({ size: e = 16 }) => /* @__PURE__ */ y(
|
|
|
40
40
|
strokeLinejoin: "round",
|
|
41
41
|
"aria-label": "Exit fullscreen",
|
|
42
42
|
children: [
|
|
43
|
-
/* @__PURE__ */
|
|
44
|
-
/* @__PURE__ */
|
|
43
|
+
/* @__PURE__ */ i("title", { children: "Exit fullscreen" }),
|
|
44
|
+
/* @__PURE__ */ i("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
|
-
),
|
|
48
|
-
function
|
|
47
|
+
), z = "permissionless-ui:tradingview-series-colors:";
|
|
48
|
+
function E(e) {
|
|
49
49
|
if (typeof window > "u" || !window.localStorage)
|
|
50
50
|
return /* @__PURE__ */ new Map();
|
|
51
51
|
try {
|
|
52
|
-
const t = window.localStorage.getItem(
|
|
52
|
+
const t = window.localStorage.getItem(z + e);
|
|
53
53
|
if (!t) return /* @__PURE__ */ new Map();
|
|
54
|
-
const
|
|
55
|
-
return
|
|
56
|
-
Object.entries(
|
|
57
|
-
([,
|
|
54
|
+
const s = JSON.parse(t);
|
|
55
|
+
return s == null || typeof s != "object" ? /* @__PURE__ */ new Map() : new Map(
|
|
56
|
+
Object.entries(s).filter(
|
|
57
|
+
([, c]) => typeof c == "number" && c >= 0 && c < M.length
|
|
58
58
|
)
|
|
59
59
|
);
|
|
60
60
|
} catch {
|
|
61
61
|
return /* @__PURE__ */ new Map();
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function fe(e, t) {
|
|
65
65
|
if (!(typeof window > "u" || !window.localStorage))
|
|
66
66
|
try {
|
|
67
67
|
window.localStorage.setItem(
|
|
68
|
-
|
|
68
|
+
z + e,
|
|
69
69
|
JSON.stringify(Object.fromEntries(t))
|
|
70
70
|
);
|
|
71
71
|
} catch {
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
function
|
|
74
|
+
function _(e, t) {
|
|
75
75
|
if (t.size === 0) return;
|
|
76
|
-
const
|
|
77
|
-
for (const [
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
const s = E(e);
|
|
77
|
+
for (const [c, h] of t)
|
|
78
|
+
s.set(c, h);
|
|
79
|
+
fe(e, s);
|
|
80
80
|
}
|
|
81
|
-
function
|
|
81
|
+
function Ne({
|
|
82
82
|
data: e,
|
|
83
83
|
yMeasureUnit: t,
|
|
84
|
-
height:
|
|
85
|
-
defaultGraph:
|
|
86
|
-
onGraphSelected:
|
|
87
|
-
graphs:
|
|
88
|
-
isMultipleSelect:
|
|
89
|
-
range:
|
|
90
|
-
rangeList:
|
|
91
|
-
setRange:
|
|
92
|
-
onGraphExpanded:
|
|
93
|
-
isGraphExpanded:
|
|
94
|
-
onUnselectSeries:
|
|
95
|
-
graphsWithNoData:
|
|
96
|
-
loadingGraphs:
|
|
97
|
-
noDataMessage:
|
|
98
|
-
currentValueDecimals:
|
|
99
|
-
containerClassName:
|
|
100
|
-
useSharedPriceScale:
|
|
101
|
-
showCurrentValue:
|
|
102
|
-
yScaleMin:
|
|
103
|
-
yScaleMinMultiple:
|
|
104
|
-
seriesColorPersistenceKey:
|
|
105
|
-
...
|
|
84
|
+
height: s = 306,
|
|
85
|
+
defaultGraph: c,
|
|
86
|
+
onGraphSelected: h,
|
|
87
|
+
graphs: d,
|
|
88
|
+
isMultipleSelect: V,
|
|
89
|
+
range: B,
|
|
90
|
+
rangeList: k,
|
|
91
|
+
setRange: F,
|
|
92
|
+
onGraphExpanded: A,
|
|
93
|
+
isGraphExpanded: T,
|
|
94
|
+
onUnselectSeries: W,
|
|
95
|
+
graphsWithNoData: D,
|
|
96
|
+
loadingGraphs: H,
|
|
97
|
+
noDataMessage: N = "No data available for this graph",
|
|
98
|
+
currentValueDecimals: J,
|
|
99
|
+
containerClassName: $,
|
|
100
|
+
useSharedPriceScale: X,
|
|
101
|
+
showCurrentValue: q,
|
|
102
|
+
yScaleMin: Q,
|
|
103
|
+
yScaleMinMultiple: Y,
|
|
104
|
+
seriesColorPersistenceKey: u,
|
|
105
|
+
...Z
|
|
106
106
|
}) {
|
|
107
|
-
const
|
|
108
|
-
(
|
|
109
|
-
|
|
107
|
+
const b = S(() => Array.isArray(e) ? e : e ? [e] : [], [e]), j = S(() => Array.isArray(e) && e.length > 1, [e]), R = ie(), G = oe(
|
|
108
|
+
(p, v) => {
|
|
109
|
+
ne.error(N);
|
|
110
110
|
},
|
|
111
|
-
[
|
|
112
|
-
),
|
|
111
|
+
[N]
|
|
112
|
+
), U = S(() => {
|
|
113
113
|
if (t)
|
|
114
114
|
return Array.isArray(t) ? t[0] : t;
|
|
115
|
-
}, [t]), P = (!
|
|
116
|
-
/* @__PURE__ */
|
|
117
|
-
|
|
115
|
+
}, [t]), P = (!R && A || k.length > 0 || h && d && c) && /* @__PURE__ */ y("div", { className: "z-10 w-full flex flex-row flex-wrap sm:flex-nowrap items-center gap-2", children: [
|
|
116
|
+
/* @__PURE__ */ i("div", { children: h && d && c && /* @__PURE__ */ i(
|
|
117
|
+
me,
|
|
118
118
|
{
|
|
119
|
-
onSelected:
|
|
120
|
-
items:
|
|
121
|
-
defaultItem:
|
|
122
|
-
multiple:
|
|
123
|
-
graphsWithNoData:
|
|
124
|
-
loadingGraphs:
|
|
125
|
-
onNoDataSelected:
|
|
119
|
+
onSelected: h,
|
|
120
|
+
items: d,
|
|
121
|
+
defaultItem: c,
|
|
122
|
+
multiple: V,
|
|
123
|
+
graphsWithNoData: D,
|
|
124
|
+
loadingGraphs: H,
|
|
125
|
+
onNoDataSelected: G
|
|
126
126
|
}
|
|
127
127
|
) }),
|
|
128
128
|
/* @__PURE__ */ y("div", { className: "flex flex-row flex-nowrap justify-start sm:justify-end items-center flex-1", children: [
|
|
129
|
-
/* @__PURE__ */
|
|
130
|
-
!
|
|
129
|
+
/* @__PURE__ */ i(se, { range: B, rangeList: k, setRange: F }),
|
|
130
|
+
!R && A && /* @__PURE__ */ i(
|
|
131
131
|
"button",
|
|
132
132
|
{
|
|
133
133
|
type: "button",
|
|
134
134
|
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",
|
|
135
|
-
onClick:
|
|
136
|
-
children:
|
|
135
|
+
onClick: A,
|
|
136
|
+
children: T ? /* @__PURE__ */ i(de, { size: 16 }) : /* @__PURE__ */ i(ae, { size: 16 })
|
|
137
137
|
}
|
|
138
138
|
)
|
|
139
139
|
] })
|
|
140
|
-
] }),
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
140
|
+
] }), n = C(/* @__PURE__ */ new Map()), f = C(0), L = C(!1);
|
|
141
|
+
if (d && d.length > 0 && !L.current) {
|
|
142
|
+
L.current = !0;
|
|
143
|
+
const p = u ? E(u) : /* @__PURE__ */ new Map(), v = String(d[0].value);
|
|
144
|
+
n.current.set(v, 0), f.current = 1;
|
|
145
|
+
for (let r = 1; r < d.length; r++) {
|
|
146
|
+
const m = String(d[r].value);
|
|
147
|
+
if (n.current.has(m)) continue;
|
|
148
|
+
const x = p.get(m) ?? r;
|
|
149
|
+
n.current.set(m, x), f.current = Math.max(f.current, x + 1);
|
|
150
|
+
}
|
|
151
|
+
u && _(
|
|
152
|
+
u,
|
|
153
|
+
n.current
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
const K = S(() => {
|
|
157
|
+
const p = Array.isArray(t) ? t : void 0;
|
|
158
|
+
if (u) {
|
|
159
|
+
const r = E(u);
|
|
160
|
+
for (const [m, w] of r)
|
|
161
|
+
n.current.has(m) || (n.current.set(m, w), f.current = Math.max(
|
|
162
|
+
f.current,
|
|
163
|
+
w + 1
|
|
164
|
+
));
|
|
155
165
|
}
|
|
156
|
-
const
|
|
157
|
-
const
|
|
158
|
-
if (!
|
|
166
|
+
const v = b.map((r, m) => {
|
|
167
|
+
const w = r?.title || `Series ${m + 1}`, x = r?.id || w;
|
|
168
|
+
if (!n.current.has(x)) {
|
|
159
169
|
const o = new Set(
|
|
160
|
-
Array.from(
|
|
170
|
+
Array.from(n.current.values())
|
|
161
171
|
);
|
|
162
|
-
let
|
|
163
|
-
for (let
|
|
164
|
-
const g = (
|
|
172
|
+
let l = f.current;
|
|
173
|
+
for (let a = 0; a < M.length; a++) {
|
|
174
|
+
const g = (f.current + a) % M.length;
|
|
165
175
|
if (!o.has(g)) {
|
|
166
|
-
|
|
176
|
+
l = g;
|
|
167
177
|
break;
|
|
168
178
|
}
|
|
169
179
|
}
|
|
170
|
-
|
|
180
|
+
n.current.set(x, l), f.current = l + 1;
|
|
171
181
|
}
|
|
172
|
-
const
|
|
173
|
-
const
|
|
174
|
-
return
|
|
175
|
-
}).reduce((o,
|
|
176
|
-
const
|
|
177
|
-
return o.length === 0 || o[o.length - 1].time !==
|
|
178
|
-
|
|
179
|
-
value: n.value
|
|
180
|
-
}) : o[o.length - 1] = {
|
|
181
|
-
time: c,
|
|
182
|
-
value: n.value
|
|
183
|
-
}, o;
|
|
184
|
-
}, []), k = l?.lineColor ?? l?.color ?? void 0;
|
|
182
|
+
const te = n.current.get(x) ?? 0, I = ce(te), re = [...r?.data || []].sort((o, l) => {
|
|
183
|
+
const a = typeof o.time == "number" ? o.time : Number(o.time), g = typeof l.time == "number" ? l.time : Number(l.time);
|
|
184
|
+
return a - g;
|
|
185
|
+
}).reduce((o, l) => {
|
|
186
|
+
const a = l.time;
|
|
187
|
+
return o.length === 0 || o[o.length - 1].time !== a ? o.push({ time: a, value: l.value }) : o[o.length - 1] = { time: a, value: l.value }, o;
|
|
188
|
+
}, []), O = r?.lineColor ?? r?.color ?? void 0;
|
|
185
189
|
return {
|
|
186
|
-
data:
|
|
187
|
-
label:
|
|
188
|
-
yMeasureUnit:
|
|
189
|
-
...
|
|
190
|
-
lineColor:
|
|
191
|
-
...
|
|
192
|
-
topColor:
|
|
190
|
+
data: re,
|
|
191
|
+
label: w,
|
|
192
|
+
yMeasureUnit: p?.[m] ?? (Array.isArray(t) ? void 0 : t),
|
|
193
|
+
...O != null ? {
|
|
194
|
+
lineColor: O,
|
|
195
|
+
...r?.topColor != null && {
|
|
196
|
+
topColor: r.topColor
|
|
193
197
|
},
|
|
194
|
-
...
|
|
195
|
-
bottomColor:
|
|
198
|
+
...r?.bottomColor != null && {
|
|
199
|
+
bottomColor: r.bottomColor
|
|
196
200
|
}
|
|
197
201
|
} : {
|
|
198
|
-
color:
|
|
199
|
-
topColor:
|
|
200
|
-
bottomColor:
|
|
202
|
+
color: I.line,
|
|
203
|
+
topColor: I.top,
|
|
204
|
+
bottomColor: I.bottom
|
|
201
205
|
}
|
|
202
206
|
};
|
|
203
207
|
});
|
|
204
|
-
return
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
),
|
|
208
|
-
}, [
|
|
209
|
-
return /* @__PURE__ */
|
|
208
|
+
return u && n.current.size > 0 && _(
|
|
209
|
+
u,
|
|
210
|
+
n.current
|
|
211
|
+
), v;
|
|
212
|
+
}, [b, t, u]), ee = j && b.length > 0 ? b.some((p) => !p) : !e;
|
|
213
|
+
return /* @__PURE__ */ i(
|
|
210
214
|
"div",
|
|
211
215
|
{
|
|
212
216
|
style: {
|
|
213
217
|
width: "100%",
|
|
214
|
-
height:
|
|
218
|
+
height: s ? `${s}px` : void 0
|
|
215
219
|
},
|
|
216
220
|
className: "w-full",
|
|
217
|
-
children: /* @__PURE__ */
|
|
218
|
-
|
|
221
|
+
children: /* @__PURE__ */ i(
|
|
222
|
+
ue,
|
|
219
223
|
{
|
|
220
|
-
series:
|
|
221
|
-
loading:
|
|
224
|
+
series: K,
|
|
225
|
+
loading: ee,
|
|
222
226
|
toolbar: P,
|
|
223
|
-
size:
|
|
224
|
-
containerClassName:
|
|
225
|
-
showLegend:
|
|
226
|
-
onUnselectSeries:
|
|
227
|
-
yMeasureUnit:
|
|
228
|
-
currentValueDecimals:
|
|
229
|
-
useSharedPriceScale:
|
|
230
|
-
showCurrentValue:
|
|
231
|
-
yScaleMin:
|
|
232
|
-
yScaleMinMultiple:
|
|
233
|
-
...
|
|
227
|
+
size: s ? "full" : "default",
|
|
228
|
+
containerClassName: le("h-full", $),
|
|
229
|
+
showLegend: j,
|
|
230
|
+
onUnselectSeries: W,
|
|
231
|
+
yMeasureUnit: U,
|
|
232
|
+
currentValueDecimals: J,
|
|
233
|
+
useSharedPriceScale: X,
|
|
234
|
+
showCurrentValue: q,
|
|
235
|
+
yScaleMin: Q,
|
|
236
|
+
yScaleMinMultiple: Y,
|
|
237
|
+
...Z
|
|
234
238
|
}
|
|
235
239
|
)
|
|
236
240
|
}
|
|
237
241
|
);
|
|
238
242
|
}
|
|
239
243
|
export {
|
|
240
|
-
|
|
244
|
+
Ne as TradingView
|
|
241
245
|
};
|