@gearbox-protocol/ui-kit 4.0.0-next.28 → 4.0.0-next.29

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 r=require("react/jsx-runtime"),J=require("@radix-ui/react-tooltip"),Q=require("react");require("@gearbox-protocol/sdk/onchain");const h=require("../../utils/cn.cjs");require("sonner");require("@gearbox-protocol/sdk/common-utils");require("luxon");const U=require("../../utils/z-index.cjs");function I(c){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const i in c)if(i!=="default"){const t=Object.getOwnPropertyDescriptor(c,i);Object.defineProperty(s,i,t.get?t:{enumerable:!0,get:()=>c[i]})}}return s.default=c,Object.freeze(s)}const l=I(J),e=I(Q),g=e.createContext({lockParent:()=>{},unlockParent:()=>{}}),N=e.createContext(!1),S=7,Y=12;function L({children:c,title:s,placement:i="top",trigger:t="hover",triangle:z=!0,delayShow:P=5,maxWidth:b="200px",minWidth:A,type:H="tooltip",open:v,onOpenChange:y,className:M,triggerClassName:C,useTitleAsTrigger:K=!1}){const[W,B]=e.useState(!1),[T,R]=e.useState(!1),k=e.useRef(null),f=e.useRef(null),m=v!==void 0,a=m?v:W,o=e.useCallback(n=>{m?y?.(n):B(n)},[m,y]),u=e.useContext(g),G=e.useMemo(()=>({lockParent:()=>R(!0),unlockParent:()=>R(!1)}),[]),w=e.useRef(!1);w.current=T;const d=e.useRef(null),p=e.useCallback(()=>{d.current!==null&&(clearTimeout(d.current),d.current=null)},[]),V=e.useCallback(n=>{if(t!=="click"){if(n){p(),o(!0),u.lockParent();return}d.current=setTimeout(()=>{d.current=null,!w.current&&(o(!1),u.unlockParent())},100)}},[t,o,u,p]);e.useEffect(()=>p,[p]);const X=e.useCallback(n=>{t==="click"&&(n.stopPropagation(),o(!a))},[t,a,o]),Z=e.useCallback(n=>{t==="click"&&(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),n.stopPropagation(),o(!a))},[t,a,o]);e.useEffect(()=>{if(t!=="click"||!a)return;const n=x=>{const q=x.target;k.current&&!k.current.contains(q)&&f.current&&!f.current.contains(q)&&o(!1)},_=x=>{x.key==="Escape"&&o(!1)};return document.addEventListener("pointerdown",n),document.addEventListener("keydown",_),()=>{document.removeEventListener("pointerdown",n),document.removeEventListener("keydown",_)}},[t,a,o]);const j=e.useRef(u.unlockParent);j.current=u.unlockParent,e.useEffect(()=>()=>j.current(),[]);const O=H==="modal-tooltip",D=z&&!O,$=h.cn(U.Z_INDEX.TOOLTIP,"pointer-events-auto","animate-in fade-in-0 zoom-in-75 duration-150","data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-75 data-[state=closed]:duration-150",O?"bg-transparent p-0":"rounded bg-black/85 px-2 py-1 text-[0.85rem] leading-[1.5] font-normal text-center text-white/85 antialiased break-words min-w-0",M),F=e.useContext(N),E=r.jsxs(l.Root,{open:a||T,onOpenChange:V,delayDuration:t==="click"?0:P,children:[r.jsx(l.Trigger,{asChild:!0,children:K?s:t==="click"?r.jsx("button",{ref:f,type:"button",onClick:X,onKeyDown:Z,className:h.cn("inline-flex appearance-none border-0 bg-transparent p-0 text-inherit font-inherit cursor-pointer",C),children:s}):r.jsx("span",{ref:f,className:h.cn("inline-flex",C),children:s})}),r.jsx(l.Portal,{children:r.jsxs(l.Content,{ref:k,side:i,sideOffset:D?S-4:8,collisionPadding:8,className:$,style:{maxWidth:b?`min(${b}, calc(100vw - 16px))`:"calc(100vw - 16px)",minWidth:A},children:[r.jsx(g.Provider,{value:G,children:c}),D&&r.jsx(l.Arrow,{width:Y,height:S,className:"fill-black/85"})]})})]});return F?E:r.jsx(N.Provider,{value:!0,children:r.jsx(l.Provider,{delayDuration:t==="click"?0:P,skipDelayDuration:300,children:E})})}L.displayName="SimpleTooltip";exports.SimpleTooltip=L;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),J=require("@radix-ui/react-tooltip"),Q=require("react");require("@gearbox-protocol/sdk/onchain");const h=require("../../utils/cn.cjs");require("sonner");require("@gearbox-protocol/sdk/common-utils");require("luxon");const U=require("../../utils/z-index.cjs");function L(c){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const i in c)if(i!=="default"){const t=Object.getOwnPropertyDescriptor(c,i);Object.defineProperty(s,i,t.get?t:{enumerable:!0,get:()=>c[i]})}}return s.default=c,Object.freeze(s)}const l=L(J),e=L(Q),N=e.createContext({lockParent:()=>{},unlockParent:()=>{}}),S=e.createContext(!1),I=7,Y=12;function z({children:c,title:s,placement:i="top",trigger:t="hover",triangle:A=!0,delayShow:v=5,maxWidth:P="200px",minWidth:b,type:H="tooltip",open:y,onOpenChange:C,className:M,triggerClassName:T,useTitleAsTrigger:K=!1}){const[W,B]=e.useState(!1),[w,R]=e.useState(!1),m=e.useRef(null),f=e.useRef(null),k=y!==void 0,a=k?y:W,o=e.useCallback(n=>{k?C?.(n):B(n)},[k,C]),u=e.useContext(N),$=e.useMemo(()=>({lockParent:()=>R(!0),unlockParent:()=>R(!1)}),[]),j=e.useRef(!1);j.current=w;const d=e.useRef(null),p=e.useCallback(()=>{d.current!==null&&(clearTimeout(d.current),d.current=null)},[]),G=e.useCallback(n=>{if(t!=="click"){if(n){p(),o(!0),u.lockParent();return}d.current=setTimeout(()=>{d.current=null,!j.current&&(o(!1),u.unlockParent())},100)}},[t,o,u,p]);e.useEffect(()=>p,[p]);const V=e.useCallback(n=>{t==="click"&&(n.stopPropagation(),o(!a))},[t,a,o]),X=e.useCallback(n=>{t==="click"&&(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),n.stopPropagation(),o(!a))},[t,a,o]);e.useEffect(()=>{if(t!=="click"||!a)return;const n=x=>{const g=x.target;m.current&&!m.current.contains(g)&&f.current&&!f.current.contains(g)&&o(!1)},q=x=>{x.key==="Escape"&&o(!1)};return document.addEventListener("pointerdown",n),document.addEventListener("keydown",q),()=>{document.removeEventListener("pointerdown",n),document.removeEventListener("keydown",q)}},[t,a,o]);const O=e.useRef(u.unlockParent);O.current=u.unlockParent,e.useEffect(()=>()=>O.current(),[]);const D=H==="modal-tooltip",E=A&&!D,Z=h.cn(U.Z_INDEX.TOOLTIP,"pointer-events-auto","animate-in fade-in-0 zoom-in-75 duration-150","data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-75 data-[state=closed]:duration-150",D?"bg-transparent p-0":"rounded bg-black/85 px-2 py-1 text-[0.85rem] leading-[1.5] font-normal text-center text-white/85 antialiased break-words min-w-0",M),F=e.useContext(S),_=r.jsxs(l.Root,{open:a||w,onOpenChange:G,delayDuration:t==="click"?0:v,children:[r.jsx(l.Trigger,{asChild:!0,children:K?s:t==="click"?r.jsx("button",{ref:f,type:"button",onClick:V,onKeyDown:X,className:h.cn("inline-flex appearance-none border-0 bg-transparent p-0 text-inherit font-inherit cursor-pointer",T),children:s}):r.jsx("span",{ref:f,className:h.cn("inline-flex",T),children:s})}),r.jsx(l.Portal,{children:r.jsxs(l.Content,{ref:m,side:i,sideOffset:E?I-4:8,collisionPadding:8,className:Z,style:{maxWidth:P?`min(${P}, calc(100vw - 16px))`:"calc(100vw - 16px)",minWidth:b?`min(${b}, calc(100vw - 16px))`:void 0},children:[r.jsx(N.Provider,{value:$,children:c}),E&&r.jsx(l.Arrow,{width:Y,height:I,className:"fill-black/85"})]})})]});return F?_:r.jsx(S.Provider,{value:!0,children:r.jsx(l.Provider,{delayDuration:t==="click"?0:v,skipDelayDuration:300,children:_})})}z.displayName="SimpleTooltip";exports.SimpleTooltip=z;
@@ -1,4 +1,4 @@
1
- import { jsxs as L, jsx as r } from "react/jsx-runtime";
1
+ import { jsxs as I, jsx as r } from "react/jsx-runtime";
2
2
  import * as a from "@radix-ui/react-tooltip";
3
3
  import * as e from "react";
4
4
  import "@gearbox-protocol/sdk/onchain";
@@ -7,63 +7,63 @@ import "sonner";
7
7
  import "@gearbox-protocol/sdk/common-utils";
8
8
  import "luxon";
9
9
  import { Z_INDEX as F } from "../../utils/z-index.js";
10
- const I = e.createContext({ lockParent: () => {
10
+ const A = e.createContext({ lockParent: () => {
11
11
  }, unlockParent: () => {
12
- } }), A = e.createContext(!1), H = 7, J = 12;
12
+ } }), H = e.createContext(!1), K = 7, J = 12;
13
13
  function Q({
14
- children: K,
14
+ children: S,
15
15
  title: d,
16
- placement: S = "top",
16
+ placement: W = "top",
17
17
  trigger: n = "hover",
18
- triangle: W = !0,
18
+ triangle: _ = !0,
19
19
  delayShow: h = 5,
20
- maxWidth: C = "200px",
21
- minWidth: _,
20
+ maxWidth: v = "200px",
21
+ minWidth: C,
22
22
  type: j = "tooltip",
23
- open: P,
24
- onOpenChange: v,
23
+ open: x,
24
+ onOpenChange: P,
25
25
  className: z,
26
- triggerClassName: x,
26
+ triggerClassName: w,
27
27
  useTitleAsTrigger: B = !1
28
28
  }) {
29
- const [M, g] = e.useState(!1), [y, w] = e.useState(!1), f = e.useRef(null), i = e.useRef(null), p = P !== void 0, c = p ? P : M, o = e.useCallback(
29
+ const [M, $] = e.useState(!1), [y, R] = e.useState(!1), f = e.useRef(null), l = e.useRef(null), p = x !== void 0, c = p ? x : M, o = e.useCallback(
30
30
  (t) => {
31
- p ? v?.(t) : g(t);
31
+ p ? P?.(t) : $(t);
32
32
  },
33
- [p, v]
34
- ), s = e.useContext(I), G = e.useMemo(
33
+ [p, P]
34
+ ), s = e.useContext(A), g = e.useMemo(
35
35
  () => ({
36
- lockParent: () => w(!0),
37
- unlockParent: () => w(!1)
36
+ lockParent: () => R(!0),
37
+ unlockParent: () => R(!1)
38
38
  }),
39
39
  []
40
- ), R = e.useRef(!1);
41
- R.current = y;
42
- const l = e.useRef(
40
+ ), T = e.useRef(!1);
41
+ T.current = y;
42
+ const i = e.useRef(
43
43
  null
44
44
  ), u = e.useCallback(() => {
45
- l.current !== null && (clearTimeout(l.current), l.current = null);
46
- }, []), V = e.useCallback(
45
+ i.current !== null && (clearTimeout(i.current), i.current = null);
46
+ }, []), G = e.useCallback(
47
47
  (t) => {
48
48
  if (n !== "click") {
49
49
  if (t) {
50
50
  u(), o(!0), s.lockParent();
51
51
  return;
52
52
  }
53
- l.current = setTimeout(() => {
54
- l.current = null, !R.current && (o(!1), s.unlockParent());
53
+ i.current = setTimeout(() => {
54
+ i.current = null, !T.current && (o(!1), s.unlockParent());
55
55
  }, 100);
56
56
  }
57
57
  },
58
58
  [n, o, s, u]
59
59
  );
60
60
  e.useEffect(() => u, [u]);
61
- const X = e.useCallback(
61
+ const V = e.useCallback(
62
62
  (t) => {
63
63
  n === "click" && (t.stopPropagation(), o(!c));
64
64
  },
65
65
  [n, c, o]
66
- ), Z = e.useCallback(
66
+ ), X = e.useCallback(
67
67
  (t) => {
68
68
  n === "click" && (t.key === "Enter" || t.key === " ") && (t.preventDefault(), t.stopPropagation(), o(!c));
69
69
  },
@@ -72,71 +72,73 @@ function Q({
72
72
  e.useEffect(() => {
73
73
  if (n !== "click" || !c) return;
74
74
  const t = (m) => {
75
- const N = m.target;
76
- f.current && !f.current.contains(N) && i.current && !i.current.contains(N) && o(!1);
77
- }, O = (m) => {
75
+ const L = m.target;
76
+ f.current && !f.current.contains(L) && l.current && !l.current.contains(L) && o(!1);
77
+ }, N = (m) => {
78
78
  m.key === "Escape" && o(!1);
79
79
  };
80
- return document.addEventListener("pointerdown", t), document.addEventListener("keydown", O), () => {
81
- document.removeEventListener("pointerdown", t), document.removeEventListener("keydown", O);
80
+ return document.addEventListener("pointerdown", t), document.addEventListener("keydown", N), () => {
81
+ document.removeEventListener("pointerdown", t), document.removeEventListener("keydown", N);
82
82
  };
83
83
  }, [n, c, o]);
84
- const T = e.useRef(s.unlockParent);
85
- T.current = s.unlockParent, e.useEffect(() => () => T.current(), []);
86
- const b = j === "modal-tooltip", D = W && !b, $ = k(
84
+ const b = e.useRef(s.unlockParent);
85
+ b.current = s.unlockParent, e.useEffect(() => () => b.current(), []);
86
+ const D = j === "modal-tooltip", E = _ && !D, Z = k(
87
87
  F.TOOLTIP,
88
88
  "pointer-events-auto",
89
89
  "animate-in fade-in-0 zoom-in-75 duration-150",
90
90
  "data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-75 data-[state=closed]:duration-150",
91
- b ? "bg-transparent p-0" : "rounded bg-black/85 px-2 py-1 text-[0.85rem] leading-[1.5] font-normal text-center text-white/85 antialiased break-words min-w-0",
91
+ D ? "bg-transparent p-0" : "rounded bg-black/85 px-2 py-1 text-[0.85rem] leading-[1.5] font-normal text-center text-white/85 antialiased break-words min-w-0",
92
92
  z
93
- ), q = e.useContext(A), E = /* @__PURE__ */ L(
93
+ ), q = e.useContext(H), O = /* @__PURE__ */ I(
94
94
  a.Root,
95
95
  {
96
96
  open: c || y,
97
- onOpenChange: V,
97
+ onOpenChange: G,
98
98
  delayDuration: n === "click" ? 0 : h,
99
99
  children: [
100
100
  /* @__PURE__ */ r(a.Trigger, { asChild: !0, children: B ? d : n === "click" ? /* @__PURE__ */ r(
101
101
  "button",
102
102
  {
103
- ref: i,
103
+ ref: l,
104
104
  type: "button",
105
- onClick: X,
106
- onKeyDown: Z,
105
+ onClick: V,
106
+ onKeyDown: X,
107
107
  className: k(
108
108
  "inline-flex appearance-none border-0 bg-transparent p-0 text-inherit font-inherit cursor-pointer",
109
- x
109
+ w
110
110
  ),
111
111
  children: d
112
112
  }
113
113
  ) : /* @__PURE__ */ r(
114
114
  "span",
115
115
  {
116
- ref: i,
117
- className: k("inline-flex", x),
116
+ ref: l,
117
+ className: k("inline-flex", w),
118
118
  children: d
119
119
  }
120
120
  ) }),
121
- /* @__PURE__ */ r(a.Portal, { children: /* @__PURE__ */ L(
121
+ /* @__PURE__ */ r(a.Portal, { children: /* @__PURE__ */ I(
122
122
  a.Content,
123
123
  {
124
124
  ref: f,
125
- side: S,
126
- sideOffset: D ? H - 4 : 8,
125
+ side: W,
126
+ sideOffset: E ? K - 4 : 8,
127
127
  collisionPadding: 8,
128
- className: $,
128
+ className: Z,
129
129
  style: {
130
- maxWidth: C ? `min(${C}, calc(100vw - 16px))` : "calc(100vw - 16px)",
131
- minWidth: _
130
+ maxWidth: v ? `min(${v}, calc(100vw - 16px))` : "calc(100vw - 16px)",
131
+ // min-width wins over max-width in CSS; cap it the same way or a
132
+ // 400px breakdown overflows a phone.
133
+ minWidth: C ? `min(${C}, calc(100vw - 16px))` : void 0
132
134
  },
133
135
  children: [
134
- /* @__PURE__ */ r(I.Provider, { value: G, children: K }),
135
- D && /* @__PURE__ */ r(
136
+ /* @__PURE__ */ r(A.Provider, { value: g, children: S }),
137
+ E && /* @__PURE__ */ r(
136
138
  a.Arrow,
137
139
  {
138
140
  width: J,
139
- height: H,
141
+ height: K,
140
142
  className: "fill-black/85"
141
143
  }
142
144
  )
@@ -146,12 +148,12 @@ function Q({
146
148
  ]
147
149
  }
148
150
  );
149
- return q ? E : /* @__PURE__ */ r(A.Provider, { value: !0, children: /* @__PURE__ */ r(
151
+ return q ? O : /* @__PURE__ */ r(H.Provider, { value: !0, children: /* @__PURE__ */ r(
150
152
  a.Provider,
151
153
  {
152
154
  delayDuration: n === "click" ? 0 : h,
153
155
  skipDelayDuration: 300,
154
- children: E
156
+ children: O
155
157
  }
156
158
  ) });
157
159
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/ui-kit",
3
- "version": "4.0.0-next.28",
3
+ "version": "4.0.0-next.29",
4
4
  "description": "Internal UI components",
5
5
  "repository": {
6
6
  "type": "git",