@gearbox-protocol/ui-kit 4.2.1 → 4.4.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,136 +1,126 @@
1
- import { jsx as e, jsxs as p } from "react/jsx-runtime";
2
- import { createContext as O, useContext as E, useMemo as f, Children as B, useRef as g, useEffect as q, isValidElement as z } from "react";
3
- import { SectionHeading as D } from "../section-heading/section-heading.js";
4
- import { Stack as u } from "../stack/stack.js";
5
- import { useTitleText as N } from "../text/use-title-text.js";
6
- import { TabControl as F } from "../../tab-control/tab-control.js";
7
- import { TabItem as M } from "../../tab-control/tab-item.js";
8
- import { TabberTest as S } from "./constants.js";
9
- import { useDetailScrollSpy as P } from "./use-detail-scroll-spy.js";
10
- const R = O({});
11
- function j({
12
- id: r,
13
- title: o,
14
- heading: s = o,
15
- actions: c,
16
- children: m,
17
- hideHeading: a = !1
1
+ import { jsx as o, jsxs as u } from "react/jsx-runtime";
2
+ import { createContext as y, useContext as R, useMemo as b, Children as j, useRef as h, useEffect as I, isValidElement as H } from "react";
3
+ import { SectionHeading as O } from "../section-heading/section-heading.js";
4
+ import { Stack as x } from "../stack/stack.js";
5
+ import { useTitleText as w } from "../text/use-title-text.js";
6
+ import { TabControl as A } from "../../tab-control/tab-control.js";
7
+ import { TabItem as B } from "../../tab-control/tab-item.js";
8
+ import { TabberTest as T } from "./constants.js";
9
+ import { useDetailScrollSpy as E } from "./use-detail-scroll-spy.js";
10
+ const v = y({});
11
+ function k({
12
+ id: e,
13
+ title: r,
14
+ heading: c = r,
15
+ actions: a,
16
+ children: l,
17
+ hideHeading: s = !1
18
18
  }) {
19
- const l = E(R), i = N(), n = !a;
20
- return /* @__PURE__ */ e(
19
+ const n = R(v), d = w(), i = !s;
20
+ return /* @__PURE__ */ o(
21
21
  "section",
22
22
  {
23
- ref: l[r],
23
+ ref: n[e],
24
24
  className: "scroll-mt-28",
25
- "data-scroll-section": r,
26
- "data-testid": S.section,
27
- children: /* @__PURE__ */ p(u, { gap: "md", children: [
28
- n || c ? /* @__PURE__ */ p("div", { className: "flex items-center justify-between gap-3", children: [
29
- n ? /* @__PURE__ */ e(D, { children: i(s) }) : /* @__PURE__ */ e("span", {}),
30
- c
25
+ "data-scroll-section": e,
26
+ "data-testid": T.section,
27
+ children: /* @__PURE__ */ u(x, { gap: "md", children: [
28
+ i || a ? /* @__PURE__ */ u("div", { className: "flex items-center justify-between gap-3", children: [
29
+ i ? /* @__PURE__ */ o(O, { children: d(c) }) : /* @__PURE__ */ o("span", {}),
30
+ a
31
31
  ] }) : null,
32
- m
32
+ l
33
33
  ] })
34
34
  }
35
35
  );
36
36
  }
37
- j.displayName = "TabberSection";
38
- function T(r) {
39
- return z(r) && r.type === j;
37
+ k.displayName = "TabberSection";
38
+ function q(e) {
39
+ return H(e) && e.type === k;
40
40
  }
41
- function V({
42
- item: r,
43
- ...o
41
+ function z({
42
+ item: e,
43
+ ...r
44
44
  }) {
45
- return /* @__PURE__ */ p("div", { className: "flex items-stretch overflow-x-auto overflow-y-hidden [&::-webkit-scrollbar]:h-0 [scrollbar-width:none]", children: [
46
- /* @__PURE__ */ e("div", { className: "min-w-0 basis-0 grow pb-px", children: /* @__PURE__ */ e(F, { ...o, showBorder: !0 }) }),
47
- r && /* @__PURE__ */ e("div", { className: "w-auto shrink-0 grow-0 basis-auto", children: r })
45
+ return /* @__PURE__ */ u("div", { className: "flex items-stretch overflow-x-auto overflow-y-hidden [&::-webkit-scrollbar]:h-0 [scrollbar-width:none]", children: [
46
+ /* @__PURE__ */ o("div", { className: "min-w-0 basis-0 grow pb-px", children: /* @__PURE__ */ o(A, { ...r, showBorder: !0 }) }),
47
+ e && /* @__PURE__ */ o("div", { className: "w-auto shrink-0 grow-0 basis-auto", children: e })
48
48
  ] });
49
49
  }
50
- function $({
51
- children: r,
52
- observeKey: o,
53
- initialSection: s,
54
- testId: c,
55
- mobileManagePane: m
50
+ function U({
51
+ children: e,
52
+ observeKey: r,
53
+ initialSection: c,
54
+ testId: a
56
55
  }) {
57
- const a = f(
58
- () => B.toArray(r).filter(T),
59
- [r]
60
- ), l = f(
61
- () => a.filter((t) => t.props.beforeBar !== !0),
62
- [a]
63
- ), i = l.map((t) => t.props.id).join("|"), n = f(
64
- () => i === "" ? [] : i.split("|"),
65
- [i]
66
- ), w = g({}), d = f(() => {
56
+ const l = b(
57
+ () => j.toArray(e).filter(q),
58
+ [e]
59
+ ), s = l.map((t) => t.props.id).join("|"), n = b(
60
+ () => s === "" ? [] : s.split("|"),
61
+ [s]
62
+ ), d = h({}), i = b(() => {
67
63
  const t = {
68
- ...w.current
64
+ ...d.current
69
65
  };
70
- for (const y of n)
71
- t[y] === void 0 && (t[y] = { current: null });
72
- return w.current = t, t;
73
- }, [n]), A = N(), { activeSection: b, scrollToSection: h } = P(
74
- d,
66
+ for (const S of n)
67
+ t[S] === void 0 && (t[S] = { current: null });
68
+ return d.current = t, t;
69
+ }, [n]), C = w(), { activeSection: m, scrollToSection: f } = E(
70
+ i,
75
71
  n,
76
- o
77
- ), x = g(!1), v = g(o);
78
- q(() => {
79
- if (o !== v.current && (v.current = o, x.current = !1), x.current || !o) return;
80
- const t = s ?? n[0];
81
- x.current = !0, !(t === void 0 || t === n[0]) && d[t] !== void 0 && requestAnimationFrame(() => {
82
- h(t);
72
+ r
73
+ ), p = h(!1), g = h(r);
74
+ I(() => {
75
+ if (r !== g.current && (g.current = r, p.current = !1), p.current || !r) return;
76
+ const t = c ?? n[0];
77
+ p.current = !0, !(t === void 0 || t === n[0]) && i[t] !== void 0 && requestAnimationFrame(() => {
78
+ f(t);
83
79
  });
84
- }, [o, s, h, n, d]);
85
- const I = l.map((t) => ({
80
+ }, [r, c, f, n, i]);
81
+ const N = l.map((t) => ({
86
82
  id: t.props.id,
87
- item: /* @__PURE__ */ e(
88
- M,
83
+ item: /* @__PURE__ */ o(
84
+ B,
89
85
  {
90
- selected: b === t.props.id,
91
- label: A(t.props.title)
86
+ selected: m === t.props.id,
87
+ label: C(t.props.title)
92
88
  }
93
89
  )
94
- })), C = B.toArray(r), k = C.filter(
95
- (t) => T(t) && t.props.beforeBar === !0
96
- ), H = C.filter(
97
- (t) => !(T(t) && t.props.beforeBar === !0)
98
- );
99
- return /* @__PURE__ */ e(u, { gap: "lg", "data-testid": c ?? S.root, children: /* @__PURE__ */ p(R.Provider, { value: d, children: [
100
- k.length > 0 ? /* @__PURE__ */ e(u, { gap: "xl", children: k }) : null,
101
- m,
102
- /* @__PURE__ */ e(W, { testId: S.bar, children: /* @__PURE__ */ e(
103
- V,
90
+ }));
91
+ return /* @__PURE__ */ o(x, { gap: "lg", "data-testid": a ?? T.root, children: /* @__PURE__ */ u(v.Provider, { value: i, children: [
92
+ /* @__PURE__ */ o(D, { testId: T.bar, children: /* @__PURE__ */ o(
93
+ z,
104
94
  {
105
95
  state: {
106
- id: b,
107
- index: n.indexOf(b),
96
+ id: m,
97
+ index: n.indexOf(m),
108
98
  handleTabChange: (t) => {
109
- h(t);
99
+ f(t);
110
100
  }
111
101
  },
112
- tabs: I,
102
+ tabs: N,
113
103
  item: null
114
104
  }
115
105
  ) }),
116
- /* @__PURE__ */ e(u, { gap: "xl", children: H })
106
+ /* @__PURE__ */ o(x, { gap: "xl", children: e })
117
107
  ] }) });
118
108
  }
119
- function W({
120
- children: r,
121
- testId: o
109
+ function D({
110
+ children: e,
111
+ testId: r
122
112
  }) {
123
- return /* @__PURE__ */ e(
113
+ return /* @__PURE__ */ o(
124
114
  "div",
125
115
  {
126
116
  className: "sticky top-0 z-20 -mx-1 px-1 pt-3 sm:pt-4 bg-background/75 backdrop-blur-md backdrop-saturate-150",
127
- "data-testid": o,
128
- children: r
117
+ "data-testid": r,
118
+ children: e
129
119
  }
130
120
  );
131
121
  }
132
122
  export {
133
- $ as Tabber,
134
- j as TabberSection,
135
- S as TabberTest
123
+ U as Tabber,
124
+ k as TabberSection,
125
+ T as TabberTest
136
126
  };