@gearbox-protocol/permissionless-ui 1.22.0-next.67 → 1.22.0-next.69
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/app-bar/app-bar.cjs +1 -0
- package/dist/cjs/components/app-bar/index.cjs +1 -0
- package/dist/cjs/components/page-title/page-title.cjs +1 -1
- package/dist/cjs/components/slider/slider-mark.cjs +1 -1
- package/dist/cjs/components/slider/slider.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/esm/components/app-bar/app-bar.js +198 -0
- package/dist/esm/components/app-bar/index.js +12 -0
- package/dist/esm/components/page-title/page-title.js +44 -36
- package/dist/esm/components/slider/slider-mark.js +18 -15
- package/dist/esm/components/slider/slider.js +54 -51
- package/dist/esm/index.js +759 -749
- package/dist/globals.css +1 -1
- package/dist/types/components/app-bar/app-bar.d.ts +133 -0
- package/dist/types/components/app-bar/index.d.ts +1 -0
- package/dist/types/components/slider/slider-mark.d.ts +2 -1
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
import { jsx as f } from "react/jsx-runtime";
|
|
2
|
-
import { useSliderContext as
|
|
3
|
-
import { getThumbInBoundsOffset as
|
|
4
|
-
function C({ value: r, min:
|
|
5
|
-
const
|
|
2
|
+
import { useSliderContext as i } from "./slider-context.js";
|
|
3
|
+
import { getThumbInBoundsOffset as p, getIntervalBounds as d, resolveColor as b } from "./types.js";
|
|
4
|
+
function C({ value: r, min: t, max: o, onClick: n }) {
|
|
5
|
+
const a = i()?.colorIntervals, s = o - t;
|
|
6
6
|
if (s <= 0) return null;
|
|
7
|
-
const
|
|
7
|
+
const c = (r - t) / s * 100, l = p(c), u = m(r, a);
|
|
8
8
|
return /* @__PURE__ */ f(
|
|
9
|
-
"
|
|
9
|
+
"button",
|
|
10
10
|
{
|
|
11
|
-
|
|
11
|
+
type: "button",
|
|
12
|
+
tabIndex: -1,
|
|
13
|
+
className: "absolute h-2.5 w-2.5 rounded-full -translate-x-1/2 -translate-y-1/2 pointer-events-auto cursor-pointer border-0 p-0 appearance-none bg-transparent",
|
|
12
14
|
style: {
|
|
13
|
-
left: `calc(${
|
|
15
|
+
left: `calc(${c}% + ${l}px)`,
|
|
14
16
|
top: "50%",
|
|
15
|
-
backgroundColor:
|
|
16
|
-
}
|
|
17
|
+
backgroundColor: u ?? "hsl(var(--gray-40))"
|
|
18
|
+
},
|
|
19
|
+
onClick: () => n?.(r)
|
|
17
20
|
}
|
|
18
21
|
);
|
|
19
22
|
}
|
|
20
|
-
function
|
|
21
|
-
if (
|
|
22
|
-
for (const
|
|
23
|
-
const { start: n, end: e } = d(
|
|
23
|
+
function m(r, t) {
|
|
24
|
+
if (t)
|
|
25
|
+
for (const o of t) {
|
|
26
|
+
const { start: n, end: e } = d(o);
|
|
24
27
|
if (r >= n && r <= e)
|
|
25
|
-
return
|
|
28
|
+
return b(o.color) ?? "hsl(var(--success))";
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
31
|
export {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as u, jsxs as j } from "react/jsx-runtime";
|
|
2
2
|
import { LEVERAGE_DECIMALS as I } from "@gearbox-protocol/sdk";
|
|
3
3
|
import * as C from "@radix-ui/react-slider";
|
|
4
4
|
import * as X from "react";
|
|
5
|
-
import { useMemo as y, useRef as
|
|
6
|
-
import { cn as
|
|
5
|
+
import { useMemo as y, useRef as B, useState as q, useLayoutEffect as H } from "react";
|
|
6
|
+
import { cn as V } from "../../utils/cn.js";
|
|
7
7
|
import "sonner";
|
|
8
8
|
import "luxon";
|
|
9
9
|
import { SliderProvider as J } from "./slider-context.js";
|
|
@@ -17,23 +17,23 @@ function R(t, n, o) {
|
|
|
17
17
|
}
|
|
18
18
|
function Y(t, n, o, a) {
|
|
19
19
|
const r = /* @__PURE__ */ new Set([t]);
|
|
20
|
-
for (let
|
|
21
|
-
r.add(t + o *
|
|
22
|
-
return r.add(n), [...r].sort((
|
|
20
|
+
for (let s = 1; n >= t + o * s; s += 1)
|
|
21
|
+
r.add(t + o * s);
|
|
22
|
+
return r.add(n), [...r].sort((s, i) => s - i);
|
|
23
23
|
}
|
|
24
24
|
function Z(t, n, o) {
|
|
25
25
|
if (t.length === 0) return t;
|
|
26
26
|
const a = t.length - 1, r = {
|
|
27
27
|
point: Math.max(t[0].point, n),
|
|
28
28
|
type: t[0].type
|
|
29
|
-
},
|
|
29
|
+
}, s = {
|
|
30
30
|
point: Math.min(t[a].point, o),
|
|
31
31
|
type: t[a].type
|
|
32
|
-
},
|
|
33
|
-
return [r, ...Object.values(
|
|
32
|
+
}, i = t.slice(1, a).reduce((l, c) => (c.point !== r.point && c.point !== s.point && (l[c.point] = c), l), {});
|
|
33
|
+
return [r, ...Object.values(i), s];
|
|
34
34
|
}
|
|
35
35
|
function tt(t, n, o, a, r) {
|
|
36
|
-
const
|
|
36
|
+
const s = R(t, o, 1), l = Y(s, n, r).map(
|
|
37
37
|
(c) => ({
|
|
38
38
|
point: R(c, o, a),
|
|
39
39
|
type: "base"
|
|
@@ -42,15 +42,15 @@ function tt(t, n, o, a, r) {
|
|
|
42
42
|
return Z(l, t, n);
|
|
43
43
|
}
|
|
44
44
|
function et(t, n, o) {
|
|
45
|
-
const a = t, r = R(a, o, 1),
|
|
45
|
+
const a = t, r = R(a, o, 1), s = Math.abs(r - a), i = n.reduce(
|
|
46
46
|
(p, x) => {
|
|
47
47
|
const N = x !== void 0 ? Math.abs(x - a) : Number.MAX_SAFE_INTEGER;
|
|
48
48
|
return p[N] = x || 0, p;
|
|
49
49
|
},
|
|
50
50
|
[]
|
|
51
51
|
), l = {
|
|
52
|
-
[
|
|
53
|
-
...
|
|
52
|
+
[s]: r,
|
|
53
|
+
...i
|
|
54
54
|
}, c = Math.min(
|
|
55
55
|
...Object.keys(l).map((p) => Number(p))
|
|
56
56
|
);
|
|
@@ -66,88 +66,91 @@ const ot = X.forwardRef(
|
|
|
66
66
|
to: o,
|
|
67
67
|
value: a,
|
|
68
68
|
onChangeValue: r,
|
|
69
|
-
onSubmitValue:
|
|
70
|
-
colorIntervals:
|
|
69
|
+
onSubmitValue: s,
|
|
70
|
+
colorIntervals: i,
|
|
71
71
|
precision: l = 10,
|
|
72
72
|
markerStep: c = 100,
|
|
73
|
-
epsilon:
|
|
73
|
+
epsilon: A = 8,
|
|
74
74
|
colorIntervalLabel: p,
|
|
75
75
|
...x
|
|
76
76
|
}, N) => {
|
|
77
|
-
const [
|
|
78
|
-
() =>
|
|
79
|
-
[
|
|
80
|
-
),
|
|
81
|
-
const { minDistance:
|
|
77
|
+
const [f, m] = n > o ? [o, n] : [n, o], v = Array.isArray(l) ? l[0] : l, F = y(() => E / v, [v]), G = y(
|
|
78
|
+
() => i?.flatMap((e) => [e.start, e.end]) || [],
|
|
79
|
+
[i]
|
|
80
|
+
), D = (e) => {
|
|
81
|
+
const { minDistance: d, minPoint: h } = et(
|
|
82
82
|
e,
|
|
83
83
|
G,
|
|
84
84
|
E
|
|
85
85
|
);
|
|
86
|
-
return
|
|
86
|
+
return d < A ? nt(h, f, m) : e;
|
|
87
87
|
}, $ = (e) => {
|
|
88
|
-
e.length > 0 && r(
|
|
88
|
+
e.length > 0 && r(D(e[0]));
|
|
89
89
|
}, z = (e) => {
|
|
90
|
-
|
|
90
|
+
s && e.length > 0 && s(D(e[0]));
|
|
91
91
|
}, k = y(() => c ? tt(
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
f,
|
|
93
|
+
m,
|
|
94
94
|
E,
|
|
95
|
-
|
|
95
|
+
v,
|
|
96
96
|
c
|
|
97
|
-
).map((
|
|
98
|
-
if (!
|
|
99
|
-
const e =
|
|
97
|
+
).map((d) => d.point) : void 0, [f, m, v, c]), L = B(null), S = B(null), [T, O] = q(void 0), P = y(() => {
|
|
98
|
+
if (!i?.length) return;
|
|
99
|
+
const e = i[i.length - 1], { start: d, end: h } = U(e), b = m - f;
|
|
100
100
|
if (b <= 0) return;
|
|
101
|
-
const g = (
|
|
101
|
+
const g = (d - f) / b * 100, M = (h - f) / b * 100, W = _(g), w = _(M);
|
|
102
102
|
return {
|
|
103
|
-
pct: (g +
|
|
104
|
-
offsetPx: (
|
|
103
|
+
pct: (g + M) / 2,
|
|
104
|
+
offsetPx: (W + w) / 2
|
|
105
105
|
};
|
|
106
|
-
}, [
|
|
106
|
+
}, [i, f, m]);
|
|
107
107
|
return H(() => {
|
|
108
|
-
const e =
|
|
109
|
-
if (!P || !e || !
|
|
108
|
+
const e = L.current, d = S.current;
|
|
109
|
+
if (!P || !e || !d) {
|
|
110
110
|
O(void 0);
|
|
111
111
|
return;
|
|
112
112
|
}
|
|
113
113
|
const h = () => {
|
|
114
|
-
const g = e.offsetWidth,
|
|
115
|
-
O(Math.max(0, Math.min(w, g -
|
|
114
|
+
const g = e.offsetWidth, M = d.offsetWidth, w = P.pct / 100 * g + P.offsetPx - M / 2;
|
|
115
|
+
O(Math.max(0, Math.min(w, g - M)));
|
|
116
116
|
};
|
|
117
117
|
h();
|
|
118
118
|
const b = new ResizeObserver(h);
|
|
119
119
|
return b.observe(e), () => b.disconnect();
|
|
120
|
-
}, [P]), /* @__PURE__ */
|
|
121
|
-
/* @__PURE__ */
|
|
120
|
+
}, [P]), /* @__PURE__ */ u(J, { colorIntervals: i, min: f, max: m, children: /* @__PURE__ */ j("div", { className: "relative w-full px-[9px] pb-3", children: [
|
|
121
|
+
/* @__PURE__ */ u("div", { className: "relative", children: /* @__PURE__ */ j(
|
|
122
122
|
C.Root,
|
|
123
123
|
{
|
|
124
124
|
ref: N,
|
|
125
|
-
className:
|
|
125
|
+
className: V(
|
|
126
126
|
"relative flex w-full touch-none select-none items-center",
|
|
127
127
|
t
|
|
128
128
|
),
|
|
129
|
-
min:
|
|
130
|
-
max:
|
|
129
|
+
min: f,
|
|
130
|
+
max: m,
|
|
131
131
|
step: F,
|
|
132
132
|
value: [a],
|
|
133
133
|
onValueChange: $,
|
|
134
134
|
onValueCommit: z,
|
|
135
135
|
...x,
|
|
136
136
|
children: [
|
|
137
|
-
/* @__PURE__ */
|
|
138
|
-
k && k.length > 0 && /* @__PURE__ */
|
|
137
|
+
/* @__PURE__ */ u(C.Track, { className: "relative h-1 grow overflow-hidden bg-gray-40 mx-[9px] cursor-pointer", children: /* @__PURE__ */ u(Q, {}) }),
|
|
138
|
+
k && k.length > 0 && /* @__PURE__ */ u("div", { className: "absolute inset-0 pointer-events-none flex items-center", children: /* @__PURE__ */ u("div", { className: "relative w-full", children: k.map((e) => /* @__PURE__ */ u(
|
|
139
139
|
K,
|
|
140
140
|
{
|
|
141
141
|
value: e,
|
|
142
|
-
min:
|
|
143
|
-
max:
|
|
142
|
+
min: f,
|
|
143
|
+
max: m,
|
|
144
|
+
onClick: (d) => {
|
|
145
|
+
r(d), s?.(d);
|
|
146
|
+
}
|
|
144
147
|
},
|
|
145
148
|
`mark-${e}`
|
|
146
149
|
)) }) }),
|
|
147
|
-
/* @__PURE__ */
|
|
150
|
+
/* @__PURE__ */ u(
|
|
148
151
|
C.Thumb,
|
|
149
152
|
{
|
|
150
|
-
className:
|
|
153
|
+
className: V(
|
|
151
154
|
"relative block h-[18px] w-[18px] rounded-full bg-foreground",
|
|
152
155
|
"cursor-grab active:cursor-grabbing",
|
|
153
156
|
"focus-visible:outline-none",
|
|
@@ -160,10 +163,10 @@ const ot = X.forwardRef(
|
|
|
160
163
|
]
|
|
161
164
|
}
|
|
162
165
|
) }),
|
|
163
|
-
p &&
|
|
166
|
+
p && i && i.length > 0 && /* @__PURE__ */ u("div", { ref: L, className: "relative h-[14px] mt-2.5", children: /* @__PURE__ */ u(
|
|
164
167
|
"div",
|
|
165
168
|
{
|
|
166
|
-
ref:
|
|
169
|
+
ref: S,
|
|
167
170
|
className: "absolute text-[11px] font-medium leading-[126%] text-success whitespace-nowrap",
|
|
168
171
|
style: T !== void 0 ? { left: `${T}px` } : void 0,
|
|
169
172
|
children: p
|