@gearbox-protocol/permissionless-ui 1.24.1 → 1.24.2
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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react/jsx-runtime"),i=require("react"),p=require("../navigation-context/navigation-context.cjs");require("@gearbox-protocol/sdk");const x=require("../../utils/cn.cjs");require("sonner");require("luxon");require("../../utils/z-index.cjs");function w(n){if(!n)return null;const{width:r=0,height:o=0}=n?.getBoundingClientRect()||{},a=n?.offsetTop||0,s=n?.offsetLeft||0;return{width:r,height:o,left:s,top:a}}function C(n,r,o){const a=i.useRef(null),[s,h]=i.useState(null),l=i.useRef(null),d=i.useCallback(e=>{h(e),l.current=e},[]);return i.useEffect(()=>{const e=o.current[n],c=()=>{const u=w(e),b=u?.height!==l.current?.height,g=u?.width!==l.current?.width,m=u?.left!==l.current?.left,v=u?.top!==l.current?.top;(b||g||m||v)&&d(u)};a.current=c,c();const t=e?new ResizeObserver(c):null;return e&&t?.observe(e),()=>{e&&t?.unobserve(e)}},[n,o,d]),i.useEffect(()=>{const e=r?new ResizeObserver(()=>{a.current?.()}):null;return r&&e?.observe(r),()=>{r&&e?.unobserve(r)}},[r]),s}function T({className:n,tabs:r,state:o,showBorder:a=!0,tabItemWrapPadding:s,variant:h="auto"}){const l=i.useRef(null),d=i.useRef({}),e=C(o.id,l.current,d),c=(t,u)=>()=>o.handleTabChange(t,u);return f.jsx("div",{className:x.cn("relative w-full flex flex-col flex-wrap overflow-y-hidden",n),children:f.jsxs("div",{ref:l,className:x.cn("relative w-full max-w-full grow-0 shrink-0 basis-full flex items-stretch overflow-x-auto overflow-y-hidden","scrollbar-hidden",a&&"after:content-[''] after:absolute after:bottom-0 after:left-0 after:right-0 after:h-px after:bg-border"),children:[e&&f.jsx("div",{className:"absolute left-0 h-[3px] bg-accent transition-[transform] duration-200 ease-in-out pointer-events-none bottom-[-1px]",style:{width:`${e.width}px`,transform:`translate(${e.left}px)`}}),r.map((t,u,b)=>{const g=u===b.length-1;return f.jsx("button",{ref:m=>{d.current[t.id]=m},type:"button",onClick:t.disabled?void 0:c(t.id,u),disabled:t.disabled,className:x.cn("flex items-center bg-transparent border-none shrink-0 text-foreground",s?"":"p-0 pb-3.5",h==="equal"?"grow shrink-0 basis-[0%] justify-center min-w-0":!g&&"mr-10 max-[500px]:mr-8",t.disabled&&"cursor-not-allowed",!t.disabled&&"cursor-pointer",!t.disabled&&"hover:text-foreground hover:[&>*]:text-foreground"),style:s?{padding:s}:void 0,children:t.item},`tab-item-${t.id}`)})]})})}function j({icon:n,label:r,selected:o,textSize:a="default",amount:s}){return f.jsxs(f.Fragment,{children:[n&&f.jsx("div",{className:x.cn("mr-3",o?"text-foreground":"text-secondary-foreground"),children:n}),f.jsx("div",{className:x.cn("m-0 p-0 whitespace-nowrap",a==="default"&&"text-sm leading-[17px] font-normal",a==="unset"&&"text-[unset] leading-[unset] font-[unset]",o?"text-foreground":"text-secondary-foreground"),children:r}),!!s&&f.jsx("div",{className:"ml-1.5",children:f.jsx("div",{className:"py-0.5 px-[9px] text-[11px] leading-[150%] font-normal bg-gray-50 rounded-[19px]",children:s})})]})}function y(n,r=0){const[o,a]=i.useState(n),[s,h]=i.useState(r),l=i.useCallback((d,e)=>{a(d),h(e)},[]);return{id:o,index:s,handleTabChange:l}}function N(n){const{useLocation:r,useNavigate:o}=p.useNavigationAdapter(),{hash:a}=r(),s=o(),h=i.useMemo(()=>n.reduce((t,u,b)=>(t[u.id]={id:u.id,index:b},t),{}),[n]),l=i.useMemo(()=>a.slice(1).toLowerCase(),[a]),{id:d,index:e}=h[l]||{},c=i.useCallback(t=>{s(`#${t}`)},[s]);return{id:d,index:e,handleTabChange:c}}function S({defaultTabs:n,pathRoot:r,selectedSection:o}){const{useNavigate:a}=p.useNavigationAdapter(),s=a(),h=i.useMemo(()=>n.reduce((c,t,u)=>(c[t.id]={id:t.id,index:u},c),{}),[n]),l=i.useCallback(c=>{s(`${r}/${c}`)},[s,r]),{id:d,index:e}=h[o]||{};return{id:d,index:e,handleTabChange:l}}exports.TabControl=T;exports.TabItem=j;exports.useHashTabs=N;exports.useSectionTab=S;exports.useTabControl=y;
|
|
@@ -1,176 +1,186 @@
|
|
|
1
|
-
import { jsx as f, jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { useNavigationAdapter as
|
|
1
|
+
import { jsx as f, jsxs as T, Fragment as S } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as b, useState as v, useCallback as p, useMemo as w, useEffect as N } from "react";
|
|
3
|
+
import { useNavigationAdapter as y } from "../navigation-context/navigation-context.js";
|
|
4
4
|
import "@gearbox-protocol/sdk";
|
|
5
|
-
import { cn as
|
|
5
|
+
import { cn as m } from "../../utils/cn.js";
|
|
6
6
|
import "sonner";
|
|
7
7
|
import "luxon";
|
|
8
8
|
import "../../utils/z-index.js";
|
|
9
|
-
function U(
|
|
10
|
-
if (!
|
|
11
|
-
const { width:
|
|
12
|
-
return { width:
|
|
9
|
+
function U(n) {
|
|
10
|
+
if (!n) return null;
|
|
11
|
+
const { width: r = 0, height: s = 0 } = n?.getBoundingClientRect() || {}, i = n?.offsetTop || 0, o = n?.offsetLeft || 0;
|
|
12
|
+
return { width: r, height: s, left: o, top: i };
|
|
13
13
|
}
|
|
14
|
-
function $(
|
|
15
|
-
const
|
|
16
|
-
u(
|
|
14
|
+
function $(n, r, s) {
|
|
15
|
+
const i = b(null), [o, u] = v(null), l = b(null), c = p((e) => {
|
|
16
|
+
u(e), l.current = e;
|
|
17
17
|
}, []);
|
|
18
|
-
return
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
(h || x ||
|
|
18
|
+
return N(() => {
|
|
19
|
+
const e = s.current[n], d = () => {
|
|
20
|
+
const a = U(e), h = a?.height !== l.current?.height, x = a?.width !== l.current?.width, g = a?.left !== l.current?.left, C = a?.top !== l.current?.top;
|
|
21
|
+
(h || x || g || C) && c(a);
|
|
22
22
|
};
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
return
|
|
26
|
-
|
|
23
|
+
i.current = d, d();
|
|
24
|
+
const t = e ? new ResizeObserver(d) : null;
|
|
25
|
+
return e && t?.observe(e), () => {
|
|
26
|
+
e && t?.unobserve(e);
|
|
27
27
|
};
|
|
28
|
-
}, [
|
|
29
|
-
const
|
|
30
|
-
|
|
28
|
+
}, [n, s, c]), N(() => {
|
|
29
|
+
const e = r ? new ResizeObserver(() => {
|
|
30
|
+
i.current?.();
|
|
31
31
|
}) : null;
|
|
32
|
-
return
|
|
33
|
-
|
|
32
|
+
return r && e?.observe(r), () => {
|
|
33
|
+
r && e?.unobserve(r);
|
|
34
34
|
};
|
|
35
|
-
}, [
|
|
35
|
+
}, [r]), o;
|
|
36
36
|
}
|
|
37
37
|
function A({
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
className: n,
|
|
39
|
+
tabs: r,
|
|
40
|
+
state: s,
|
|
40
41
|
showBorder: i = !0,
|
|
41
42
|
tabItemWrapPadding: o,
|
|
42
|
-
variant:
|
|
43
|
+
variant: u = "auto"
|
|
43
44
|
}) {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
),
|
|
49
|
-
return /* @__PURE__ */ f(
|
|
45
|
+
const l = b(null), c = b({}), e = $(
|
|
46
|
+
s.id,
|
|
47
|
+
l.current,
|
|
48
|
+
c
|
|
49
|
+
), d = (t, a) => () => s.handleTabChange(t, a);
|
|
50
|
+
return /* @__PURE__ */ f(
|
|
50
51
|
"div",
|
|
51
52
|
{
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"scrollbar-hidden",
|
|
56
|
-
i && "after:content-[''] after:absolute after:bottom-0 after:left-0 after:right-0 after:h-px after:bg-border"
|
|
53
|
+
className: m(
|
|
54
|
+
"relative w-full flex flex-col flex-wrap overflow-y-hidden",
|
|
55
|
+
n
|
|
57
56
|
),
|
|
58
|
-
children:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
"
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
57
|
+
children: /* @__PURE__ */ T(
|
|
58
|
+
"div",
|
|
59
|
+
{
|
|
60
|
+
ref: l,
|
|
61
|
+
className: m(
|
|
62
|
+
"relative w-full max-w-full grow-0 shrink-0 basis-full flex items-stretch overflow-x-auto overflow-y-hidden",
|
|
63
|
+
"scrollbar-hidden",
|
|
64
|
+
i && "after:content-[''] after:absolute after:bottom-0 after:left-0 after:right-0 after:h-px after:bg-border"
|
|
65
|
+
),
|
|
66
|
+
children: [
|
|
67
|
+
e && /* @__PURE__ */ f(
|
|
68
|
+
"div",
|
|
69
|
+
{
|
|
70
|
+
className: "absolute left-0 h-[3px] bg-accent transition-[transform] duration-200 ease-in-out pointer-events-none bottom-[-1px]",
|
|
71
|
+
style: {
|
|
72
|
+
width: `${e.width}px`,
|
|
73
|
+
transform: `translate(${e.left}px)`
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
),
|
|
77
|
+
r.map((t, a, h) => {
|
|
78
|
+
const x = a === h.length - 1;
|
|
79
|
+
return /* @__PURE__ */ f(
|
|
80
|
+
"button",
|
|
81
|
+
{
|
|
82
|
+
ref: (g) => {
|
|
83
|
+
c.current[t.id] = g;
|
|
84
|
+
},
|
|
85
|
+
type: "button",
|
|
86
|
+
onClick: t.disabled ? void 0 : d(t.id, a),
|
|
87
|
+
disabled: t.disabled,
|
|
88
|
+
className: m(
|
|
89
|
+
"flex items-center bg-transparent border-none shrink-0 text-foreground",
|
|
90
|
+
o ? "" : "p-0 pb-3.5",
|
|
91
|
+
u === "equal" ? "grow shrink-0 basis-[0%] justify-center min-w-0" : !x && "mr-10 max-[500px]:mr-8",
|
|
92
|
+
t.disabled && "cursor-not-allowed",
|
|
93
|
+
!t.disabled && "cursor-pointer",
|
|
94
|
+
!t.disabled && "hover:text-foreground hover:[&>*]:text-foreground"
|
|
95
|
+
),
|
|
96
|
+
style: o ? { padding: o } : void 0,
|
|
97
|
+
children: t.item
|
|
98
|
+
},
|
|
99
|
+
`tab-item-${t.id}`
|
|
100
|
+
);
|
|
101
|
+
})
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
)
|
|
95
105
|
}
|
|
96
|
-
)
|
|
106
|
+
);
|
|
97
107
|
}
|
|
98
108
|
function B({
|
|
99
|
-
icon:
|
|
100
|
-
label:
|
|
101
|
-
selected:
|
|
102
|
-
textSize:
|
|
103
|
-
amount:
|
|
109
|
+
icon: n,
|
|
110
|
+
label: r,
|
|
111
|
+
selected: s,
|
|
112
|
+
textSize: i = "default",
|
|
113
|
+
amount: o
|
|
104
114
|
}) {
|
|
105
|
-
return /* @__PURE__ */
|
|
106
|
-
|
|
115
|
+
return /* @__PURE__ */ T(S, { children: [
|
|
116
|
+
n && /* @__PURE__ */ f(
|
|
107
117
|
"div",
|
|
108
118
|
{
|
|
109
|
-
className:
|
|
119
|
+
className: m(
|
|
110
120
|
"mr-3",
|
|
111
|
-
|
|
121
|
+
s ? "text-foreground" : "text-secondary-foreground"
|
|
112
122
|
),
|
|
113
|
-
children:
|
|
123
|
+
children: n
|
|
114
124
|
}
|
|
115
125
|
),
|
|
116
126
|
/* @__PURE__ */ f(
|
|
117
127
|
"div",
|
|
118
128
|
{
|
|
119
|
-
className:
|
|
129
|
+
className: m(
|
|
120
130
|
"m-0 p-0 whitespace-nowrap",
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
131
|
+
i === "default" && "text-sm leading-[17px] font-normal",
|
|
132
|
+
i === "unset" && "text-[unset] leading-[unset] font-[unset]",
|
|
133
|
+
s ? "text-foreground" : "text-secondary-foreground"
|
|
124
134
|
),
|
|
125
|
-
children:
|
|
135
|
+
children: r
|
|
126
136
|
}
|
|
127
137
|
),
|
|
128
|
-
!!
|
|
138
|
+
!!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 }) })
|
|
129
139
|
] });
|
|
130
140
|
}
|
|
131
|
-
function F(
|
|
132
|
-
const [
|
|
133
|
-
|
|
141
|
+
function F(n, r = 0) {
|
|
142
|
+
const [s, i] = v(n), [o, u] = v(r), l = p((c, e) => {
|
|
143
|
+
i(c), u(e);
|
|
134
144
|
}, []);
|
|
135
|
-
return { id:
|
|
145
|
+
return { id: s, index: o, handleTabChange: l };
|
|
136
146
|
}
|
|
137
|
-
function I(
|
|
138
|
-
const { useLocation:
|
|
139
|
-
() =>
|
|
140
|
-
(
|
|
147
|
+
function I(n) {
|
|
148
|
+
const { useLocation: r, useNavigate: s } = y(), { hash: i } = r(), o = s(), u = w(
|
|
149
|
+
() => n.reduce(
|
|
150
|
+
(t, a, h) => (t[a.id] = { id: a.id, index: h }, t),
|
|
141
151
|
{}
|
|
142
152
|
),
|
|
143
|
-
[
|
|
144
|
-
), l =
|
|
145
|
-
(
|
|
146
|
-
|
|
153
|
+
[n]
|
|
154
|
+
), l = w(() => i.slice(1).toLowerCase(), [i]), { id: c, index: e } = u[l] || {}, d = p(
|
|
155
|
+
(t) => {
|
|
156
|
+
o(`#${t}`);
|
|
147
157
|
},
|
|
148
|
-
[
|
|
158
|
+
[o]
|
|
149
159
|
);
|
|
150
160
|
return {
|
|
151
|
-
id:
|
|
152
|
-
index:
|
|
153
|
-
handleTabChange:
|
|
161
|
+
id: c,
|
|
162
|
+
index: e,
|
|
163
|
+
handleTabChange: d
|
|
154
164
|
};
|
|
155
165
|
}
|
|
156
166
|
function M({
|
|
157
|
-
defaultTabs:
|
|
158
|
-
pathRoot:
|
|
159
|
-
selectedSection:
|
|
167
|
+
defaultTabs: n,
|
|
168
|
+
pathRoot: r,
|
|
169
|
+
selectedSection: s
|
|
160
170
|
}) {
|
|
161
|
-
const { useNavigate:
|
|
162
|
-
() =>
|
|
163
|
-
(
|
|
171
|
+
const { useNavigate: i } = y(), o = i(), u = w(
|
|
172
|
+
() => n.reduce(
|
|
173
|
+
(d, t, a) => (d[t.id] = { id: t.id, index: a }, d),
|
|
164
174
|
{}
|
|
165
175
|
),
|
|
166
|
-
[
|
|
176
|
+
[n]
|
|
167
177
|
), l = p(
|
|
168
|
-
(
|
|
169
|
-
|
|
178
|
+
(d) => {
|
|
179
|
+
o(`${r}/${d}`);
|
|
170
180
|
},
|
|
171
|
-
[
|
|
172
|
-
), { id:
|
|
173
|
-
return { id:
|
|
181
|
+
[o, r]
|
|
182
|
+
), { id: c, index: e } = u[s] || {};
|
|
183
|
+
return { id: c, index: e, handleTabChange: l };
|
|
174
184
|
}
|
|
175
185
|
export {
|
|
176
186
|
A as TabControl,
|
|
@@ -4,13 +4,14 @@ export interface TabControl<T extends string> {
|
|
|
4
4
|
disabled?: boolean;
|
|
5
5
|
}
|
|
6
6
|
export interface TabControlProps<T extends string> {
|
|
7
|
+
className?: string;
|
|
7
8
|
tabs: Array<TabControl<T>>;
|
|
8
9
|
state: UseTabControlReturnType<T>;
|
|
9
10
|
showBorder?: boolean;
|
|
10
11
|
variant?: "equal" | "auto";
|
|
11
12
|
tabItemWrapPadding?: string;
|
|
12
13
|
}
|
|
13
|
-
export declare function TabControl<T extends string>({ tabs, state: controlState, showBorder, tabItemWrapPadding, variant, }: TabControlProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare function TabControl<T extends string>({ className, tabs, state: controlState, showBorder, tabItemWrapPadding, variant, }: TabControlProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
14
15
|
interface TabItemProps {
|
|
15
16
|
icon?: React.ReactNode;
|
|
16
17
|
label: React.ReactNode;
|